

(function($){
    $.fn.preloadImages = function(options){

        var defaults = {
            showSpeed: 300,
            easing: 'easeOutQuad'
        };

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

        return this.each(function(){
            var container = $(this);
            var image = container.find('img');

            $(image).css({ "visibility": "hidden", "opacity": "0" });
            $(image).bind('load error', function(){
                $(this).css({ "visibility": "visible" }).animate({ opacity:"1" }, {duration:options.showSpeed, easing:options.easing}).parent(container).removeClass('preload');
            }).each(function(){
                if(this.complete || ($.browser.msie && parseInt($.browser.version) == 6)) { $(this).trigger('load'); }
            });
        });
    }
})(jQuery);

$(document).ready(function(){
    /*$('body').preloadImages({
        showSpeed: 500,   // length of fade-in animation, 500 is default
        easing: 'swing'   // optional easing, if you don't have any easing scripts - delete this option
    });
*/	
	
});

$(document).ready(function($){
   var all_img = $('body img');
  var count = all_img.length;
	
	function doMyThing() {
		$('.lightbox').prettyPhoto({social_tools:false, allow_resize:true});
		};
		
   $.each(all_img, function(index, img_item) {
	   if( $(img_item).parent().is('a')  ) {
		   var lb_item = $(img_item).parent();
		   if ( $(lb_item).hasClass('nolight') ) {
			   --count;
			   return;
		   } else {
		  $(lb_item).addClass('lightbox');	 
		   }
	   }
		    if (!--count) doMyThing();
	   });
  });
