// JavaScript Document
  $(document).ready(function() {
      $(window).load(function(){ // $(window).load() for Webkit browsers
           // center captions in gallery items
         $("div.gallery:not(.type2) > .item").each(function(){
         $caption = $(this).find("div.caption");
               $caption.css("top", function(){
                  return (($(this).parent().innerHeight()/2) - ($(this).outerHeight()/2)) +"px";
              }).css("left", function(){
                  return (($(this).parent().innerWidth()/2) - ($(this).outerWidth()/2)) +"px";
              }).find("li").css("opacity", 0.7).hover(function(){
                $(this).stop().animate({ opacity: 1 }, 250);
             },function(){
                $(this).stop().animate({ opacity: 0.7 }, 250);
           });
         });
    });
   
     // mouseover effect
     $("div.gallery:not(.type2) > .item *").mouseover(function(e){
         if($(e.target).is("img") || $(this).closest(".caption").is("div")){
           $(this).parents(".item").find("div.caption").stop().fadeTo(250, 1);
        }
     })
    // hide caption mouseout effect
    .mouseout(function(e){
        if($(e.target).is("img") || $(this).closest(".caption").is("div")){
            $(this).parents(".item").find("div.caption").stop().fadeTo(250, 0);
         }
   });
 });
 // remove gallery item
 function removeItem(e){
     // here you can make ajax request and remove selected images
    $item = $(e).parents(".item");
    $item.animate({ opacity: 0 }, 250, function(){
        $(this).animate({ width: 0 }, 250, function(){
            $(this).remove();
       });
     });
   return false;
 }


