$(document).ready(function() {
		standardGallery();
	
});










function standardGallery(){
	$('#galleryList img').each(function(){
		var mainImgSrc = $(".mainImage").attr('src');
		var currentImgSrc = $(this).attr("src");

		$(this).fadeTo("slow", 0.50);
		$(this).mouseover(function(){$(this).fadeTo("fast", 1.00);});
		$(this).mouseout(function(){$(this).fadeTo("fast", 0.50);});
		
		$(this).click(function(){
			$(".mainImage").fadeTo("slow", 0.05);
			
			$(".mainImage").queue(function(){
				$(this).attr("src",currentImgSrc);
				if($('.imagezoom').length>0){zoomReset();$(".ui-slider").slider("moveTo", "6");	}
				$(".mainImage").dequeue();
			});
			$(".mainImage").fadeTo("slow", 1.00);
			setCurrentState(currentImgSrc);
			return false;
		});


		if(currentImgSrc ==mainImgSrc){
			$(this).fadeTo("fast", 1);
			$(this).unbind("mouseout");
		}
	});	
}

function setCurrentState(mainImg){
	$('#galleryList img').each(function(){
		var mainImgSrc = mainImg;
		var currentImgSrc = $(this).attr("src");

		if(currentImgSrc !=mainImgSrc){
			$(this).fadeTo("fast", 0.50);
			$(this).mouseout(function(){$(this).fadeTo("fast", 0.50);});
		} else{
			$(this).unbind("mouseout");
		}

		
	});

}
