jQuery(document).ready(function($) {
    	
		var images = new Array;				
		var loadComplete = false;
		var loadTemp = '';
		
	    var myPics = preloadImages ($(".hover_image"));
	
	    function preloadImages(pics) {	
			var count = 0; 
			
	        $.each(pics, function(){	      
	        	var numberOfImags = pics.length;
	        		
	        	pic_id 		= $(this).attr("id");
				image_src 	= $(this).attr("src");
        		images[pic_id] = new Image();
        							
				temp = image_src.match(/^(.+)\.([^\.]+)$/);
    				
				images[pic_id].src = temp['1'] + '_hover.' + temp['2'];
    			
    	/*		
				
		    	images[pic_id].onload = function() {			
		            if(images[pic_id].complete){
            			count++;
		            	if(count==numberOfImags)
						{
							loadComplete = true;
						}
					}
		 	  	}
		*/ 	    				         
	        });
 
	        return(images);
	    }
	
	
		//var original_src = "";		
			   	
	   $(".hover_image").hover(			   
			function () 
			{
   				//if(loadComplete)
  				//{
			   		//original_src = "";

			   		original_src = $(this).attr("src");			   						    
					var temp = new Array();					
					temp = original_src.match(/^(.+)\.([^\.]+)$/);
					if(temp.length>0)
					{
						hover_src =	temp['1'] + '_hover.' + temp['2']; 													   	 
			      		$(this).attr({"src": hover_src});
    				}
			  	//}						
   			}, 
		    function () 
			{
   				//if(loadComplete)
  				//{	
  					temp_src = $(this).attr("src");
  					var temp = new Array(); 
  					temp = temp_src.match(/^(.+)_hover\.([^\.]+)$/);
  					if(temp.length>0)
				  	{
				  		src =	temp['1'] + '.' + temp['2'];
						$(this).attr({"src": src});
					}
				//}	
    		});
        			    	     
	
	/** tour hover */
	   $(".zoom_hover").hover(
	      function () {   
			$(this).children('.zoom').show();		
	      }, 
	      function () {
			$(this).children('.zoom').hide();
	      }
  	  );
  	  
  	  	$(function() {
		$('a[rel*=external]').click( function() {
			window.open(this.href);
			return false;
		});
	});

});
