$(window).load(function () 
 { 
         

         $('.imgThumb').click(function(e)
         {
                 if($('#modalbox-container').length == 0) 
                 {
                	 
                     var overlayWidth = $(window).width();
                     var overlayHeight = $(document).height();
                     
                     $("body").append('<div id="modalbox-overlay"></div>');
                     $("body").append('<div id="modalbox-container"></div>');
                     
                     $('#modalbox-overlay').css({'width':overlayWidth,'height':overlayHeight});
                     $('#modalbox-overlay').fadeIn(1200);
                     $('#modalbox-overlay').fadeTo("slow",0.8);
                     
                     $('#modalbox-container').css({'left':$(window).width()/2-$('#modalbox-container').width()/2,'top':$(window).scrollTop() + $(window).height()/2-$('#modalbox-container').height()/2});

                     
                     $('#modalbox-overlay').click(function () { 
                             $('#modalbox-container').remove();
                             $('#modalbox-overlay').remove();
                     }); 
                     
                     
                     $('#modalbox-container').click(function () { 
                             $('#modalbox-container').remove();
                             $('#modalbox-overlay').remove();
                     });
                     
                	 
                         var img = new Image();
                         img.src = $(this).attr('href');
                         var imgPass = $(this).attr('href');                        
                         
                         img.onload = function() 
                         {       
                        	 
                        	 $('#modalbox-container').css({'left':$(window).width()/2-img.width/2,'top':$(window).scrollTop() + $(window).height()/2-img.height/2});
                        	 $('#modalbox-container').animate({
                        	 	    width: img.width + "px",
                        	 	    height: img.height + "px"
                        	 	  }, 1500 );
                        	 
                        	 $('#modalbox-container').append('<img src="'+ imgPass +'" alt="" />');                         
                                 
                                 
                                 
                                 
                         }
                         
                 } 

                 return false;


         });


   
 });
