$(document).ready(function() {

  // lupa
  var div = $(".image");
  if (div) {
    var img = div.find('img');
    img.after('<div class="magnifier"><img src="/images/magnifier.gif" /></div>');
  }

  // soukrome i verejne obrazky ditete
  var div = $(".attach");
  if (div) {
    div.find('.desc').fadeTo("fast", 0);
    div.hover(
    function() {
      var desc = $(this).find('.desc');
      desc.fadeTo("fast", 1);
    },
    function() {
      var desc = $(this).find('.desc');
      desc.fadeTo("fast", 0);
    });
  }

  // efekty na detech
  var children = $("#contcont > div.children");
  children.css({ opacity: 0.75, cursor: 'hand' });
  children.click(function(){
    var href = $(this).find('a')[0].href;
    window.location = href;
  });
  children.hover(
  function(){
    $(this).fadeTo("fast", 1);
    $(this).css('border', 'solid 1px white');
    $(this).css('cursor', 'hand');
  },
  function(){
    $(this).fadeTo("fast", 0.75);
    $(this).css('border', 'solid 1px #d95e17');
    $(this).css('cursor', 'pointer');
  });

  var chview = $("#contcont > div.children-view");
  chview.hide().slideDown("slow");

  // vyber nahodneho ditete
  var adopt = $('#adoptujte_si a img');
  adopt.hover(
  function(){
    $(this).animate({ 
        width: "94%",
	//height: "94%",
	marginTop: "-11px"
      }, "fast" );
    $(this).next().animate({ marginTop: '-40px' }, "fast");
  },
  function(){
    $(this).animate({ 
        width: "70%",
	//height: "70%",
	marginTop: "0px"
      }, "fast" );
    $(this).next().animate({ marginTop: '0px' }, "fast");
  });

  $(".attach-group").css('display', 'none').attr('open', '0');

  // rozklikavaci seznam skupin fotek
  var groupheaders = $(".attachements h3 a");
  groupheaders.click(function(){
    var content = $(this).parent().next(".attach-group");
    var folder = $(this).parent();
    if (content.attr('open')=='1') {
      content.attr('open', '0');
      content.slideUp('fast');
      folder.css('background-image', 'url("/images/attach-folder-closed.gif")');
    } else {
      content.attr('open', '1');
      content.slideDown('fast');
      folder.css('background-image', 'url("/images/attach-folder-open.gif")');
     }

    return false;
  });

  $("a[rel^='lightbox']").prettyPhoto();

});

