jQuery(document).ready(function($) {
  $('a[rel*=facebox]').facebox({
    loading_image : 'loading.gif',
    close_image   : 'closelabel.gif'
  });
  /*$('.tp').hover(
    function() {
      $(".cover", this).stop().animate({top:'0px'},{queue:false,duration:150});
	  },
    function() {
	    $(".cover", this).stop().animate({top:'150px'},{queue:false,duration:450});
    }
  );*/
  $("div.scrollable").scrollable().mousewheel();
  //$('input[type="password"],input[type="text"],textarea').labelify({text: "label"});
});


function change_picture(pic, fade) {
    $('#comments_content').html('');
    var src = $(pic).attr("src").replace("thumbnail_", "normal_");
    var wrap = $("#picwrap");
    $("#picwrap img").one('load', function() {
        wrap.fadeTo("medium", 0.8).fadeTo("fast", 1);
        wrap.find("img").attr("src", src).attr("alt", $(pic).attr("alt"));
        $("#picwrap h2").html($(pic).attr("title"));
    }).each(function() {
      if ((this.complete || this.readyState == 'complete'))
        $(this).load();
    });
}

$(function() {
  $(".items img.active").attr('class','');
  if (window.location.hash) {
    change_picture($(window.location.hash).attr('class','active'), true);
    var pid = window.location.hash.replace("#i","");
    $('#picture_id').attr("value", pid);
    get_comments(pid);
  }
  else
    $(".items img:first").attr('class','active');
  $(".items img").click(function() {
    change_picture(this, true);
    var pid = $(this).attr("id").replace("i","");
    $('#picture_id').attr("value", pid);
    get_comments(pid);
  });
});

