$(document).ready(function() {
  //$(".mainimage").hide();
     

var hoverViewer = function(number){

	//declaring variables
	var hoverId = '#hoverviewer' + number;

	//alert(hoverId+' a' );
	 
	 $(hoverId+' a.hovering').hover(function(){
			//alert('This is a custom alert box', 'Alert Dialog');

			var imgHref = $(this).prev("img").attr("src");  //get the src of the thumbnail
			//console.log(imgHref);
			
    		$(hoverId+" .thumb a").removeClass("selected");  //remove .selected class from all other links
    		$(this).addClass("selected");  //add .selected class to current link
			$(hoverId+ " .big").stop();
			$(hoverId+ " .big").stop().fadeTo(700, 0, function() {  //fade image out
			$(hoverId+ " .mainimage").removeClass(".nodisplay");
    		$(hoverId+ " .big").attr("src",imgHref);  //give new image a src attribute
    		
		}).fadeTo("slow", 1);  //fade the image in
	},function(){  
		var imgHref = $(hoverId+ " .firstlink").prev("img").attr("src");  //get the src of the thumbnail
		$(hoverId+ " .big").stop().fadeTo(700, 0, function() {  //fade image out
			$(hoverId+ " .mainimage").removeClass(".nodisplay");
    		$(hoverId+ " .first").attr("src",imgHref);  //give new image a src attribute
    		
		}).fadeTo("slow", 1); 
	//for onmouseout not used here
	});

	
	}
	

	//execute function, pass along hoverviewer number argument
	
	for (var i in hoverviewerno){
		hoverViewer(hoverviewerno[i]);
	}
	

	
	
		
	
			
		
	});
	


