
(function($){

    $.fn.extend( {

        LightBoxBlue: function(options){

       

            var defaults = {};

            var options = $.extend(defaults, options);

           

	

            return this.each(function(){

                var __e = $(this);
				

//inizio lightbox

$(__e).click(function(){
		var imgAttr = $(this).attr("href");			  
		// var imgAttr = imgAttr;
		//alert(imgAttr);
					  
		var h = $(document).height();
		var w = $(document).width();	
		$("body").append("<div id=\"BZ_overlay\"><div id=\"BZ_overcontent\"><div class=\"close\"><a href=\"#\"><img src=\"img/butt-close-lb.png\" alt=\"Chiudi\" /></a></div><img src=\"#\" class=\"anteprima\" /></div></div>"); 		
		$("#BZ_overlay").height(h);
		$("#BZ_overlay").width(w);
		$("#BZ_overlay").hide().fadeIn(300);
		$("#BZ_overcontent").hide().fadeIn(300);
		$(".close").hide();
		$("#BZ_overcontent").append('<div class="loading"><img src="img/lightbox-ico-loading.gif" /></div').show();
		$('img.anteprima').css("border","1px solid #000").hide(); 
		
			$('img.anteprima').attr('src',imgAttr).load(function()
			{
			
				var width_img = $(this).width();
				var height_img = $(this).height();

				
				$("#BZ_overcontent").animate({'height':height_img});				
				$("#BZ_overcontent").animate({'width': width_img+2});//+2 per il bordo sull'immagine
				$("#BZ_overcontent").queue(function() {
					
						$(".loading").remove();
						$("#BZ_overcontent").dequeue();
					
					
					});
					
				$("#BZ_overcontent").queue(function() {
				
						$("img.anteprima").fadeIn(1000);
						$(".close").fadeIn(1000);
						$("#BZ_overcontent").dequeue();
				
				});
				
				
				//$('img.anteprima').dequeue();
			
			
			});
		 
				
//---------funzione per chiudere lightbox-----------

function closeOver() {
	$("#BZ_overlay").remove();
	$("#BZ_overcontent").remove();
	return false;
}



$(".close,#BZ_overlay").bind("click",closeOver);//funzione per chiudere lightbox

$('#BZ_overcontent').click(function(event) {
  event.stopPropagation();
})
		
	return false;	
			  
});	




			  
			  
			  
			  
			  
			  
			  
			  
//fine lightbox			  

            });

        }    

    });

})(jQuery);




