$(document).ready(function(){
 $(".thumb-block a").hover(function(){
	var overlay = $(this).prev(".overlay");
	$(overlay).hide();
	},
	function(){
	var overlay = $(this).prev(".overlay");
	$(overlay).show();
	});
	
	
	$("#hero-controls a").click(function(){

	
		var caption = new Array();
		caption[1] ="Sunset Barn, Healdsburg, CA,  Canon EOS 1D 17mm ISO 100";
		caption[2] ="Sunset Rays, Arch Cape Oregon, Canon G10";
		caption[3] ="Sunrise, Bahia De Los Angelos,  Canon EOS 1D 17mm ISO 100";
		caption[4] ="Hedin Vineyard, Healdsburg, CA,  Canon EOS 1D 17mm ISO 100";
		caption[5] ="Wild Horse, Wyoming,  Canon EOS 1D 200mm ISO 800";
		caption[6] ="Peahi Surfing, Maui, HI,  Canon EOS 1D 600mm ISO 200";
		caption[7] ="Sunrise, Tulum, Mexico,  Canon EOS 1D 17mm ISO 100";
		caption[8] ="Helicopter Racing Waves, Peahi Maui, HI,  Canon EOS 1D 600mm ISO 100";
		caption[9] ="Beach Pongas at Sunrise, Tulum, Mexico  Canon EOS 1D 17mm ISO 100";

		var image = new Array();
		image[1] ="/images/home-hero/barn.jpg";
		image[2] ="/images/home-hero/arch_cape_sunset.jpg";
		image[3] ="/images/home-hero/baja.jpg";
		image[4] ="/images/home-hero/healdsburg.jpg";
		image[5] ="/images/home-hero/horse.jpg";
		image[6] ="/images/home-hero/jaws_maui.jpg";
		image[7] ="/images/home-hero/tulum.jpg";
		image[8] ="/images/home-hero/jaws_chopper.jpg";
		image[9] ="/images/home-hero/tulum_boats.jpg";	




	var direction = $(this).attr("class");
				
	var targetImage = $(this).attr("rel");
		var nextImage = parseInt(targetImage);
		if (direction == "next"){
			if(targetImage == 10){
				$("#hero-image img").attr("src", image[1]);
				$("#hero-controls .prev").attr("rel", "9");
				$("#hero-controls .next").attr("rel", "2");
				$("#hero-caption").empty().append(caption[1]);
			}
			else {	
			$("#hero-image img").attr("src", image[targetImage]);
			$("#hero-controls .prev").attr("rel", nextImage-1);
			$("#hero-controls .next").attr("rel", nextImage+1);
			$("#hero-caption").empty().append(caption[targetImage]);
			}
			
		}
		else if (direction == "prev"){
			if(targetImage == 0){
				$("#hero-image img").attr("src", image[9]);
				$("#hero-controls .prev").attr("rel", "8");
				$("#hero-controls .next").attr("rel", "1");
				$("#hero-caption").empty().append(caption[9]);
			}
			else {	
			$("#hero-image img").attr("src", image[targetImage]);
			$("#hero-controls .prev").attr("rel", nextImage-1);
			$("#hero-controls .next").attr("rel", nextImage+1);
			$("#hero-caption").empty().append(caption[targetImage]);
			}
		}
		else {}
	return false;
	});

});