
function portfolio_img_hover(){
	jQuery(".portfolio_full_img_holder").hover(
		function(){jQuery(this).find('.hover_fade').stop().animate({opacity:0.4},400);},
		function(){jQuery(this).find('.hover_fade').stop().animate({opacity:1},400);}
	);
}

jQuery(document).ready(function(){

	jQuery(this).delay(50,function(){
	
		var $imgContainerId="div[id^='image_loader_']";
		
		var $images=jQuery($imgContainerId+' span img');
		
		var $max=$images.length;jQuery('.rm_portfolio_img').remove();
		
		var $loadDiv=null;if($max>0){LoadImage(0,$max);}
		
		function LoadImage(index,$max){
		
			if(index<$max){
			
				jQuery('<span id="img'+(index+1)+'"></span>').each(function(){
					jQuery(this).appendTo('#image_loader_'+(index+1)+' a.load_portfolio_img');
				});
				
				var $img=new Image();
				
				var $curr=jQuery("#img"+(index+1));
				
				jQuery($img).load(function() {	
				
					jQuery(this).css('display','none');
					
					jQuery(this).attr({alt:""});
					
					jQuery(this).addClass('hover_fade');
					
					jQuery($curr).append(this);
					
					jQuery(this).fadeIn(100,function(){
					
						jQuery('#image_loader_'+(index+1)).find('.loading_gallery_full').remove();
						
						jQuery('#image_loader_'+(index+1)).find('.roll_over').css('display','block');
						
						if(index==($max-1))
							{portfolio_img_hover();}
						else
							{LoadImage(index+1,$max);}
					});
					
				}).error(function(){
					jQuery($curr).remove();LoadImage(index+1,$max);
				}).attr('src',jQuery($images[index]).attr('src'));
			
			}
		}
	});
});

jQuery.preLoadImages("http://themes.mysitemyway.com/infocus/wp-content/themes/infocus/images/zoom_large.png");
