$(document).ready(function() {

	//SLIDESHOW NAV BUTTONS
	$("div.slideshow div.slide-left").add("div.slideshow div.slide-right").css("opacity","0.2");
	$("div.slideshow div.slide-left").add("div.slideshow div.slide-right").hover(
	function() {
		$(this).css("cursor","pointer").animate({opacity:1.0},"normal");
	}, function() {
		$(this).animate({opacity:0.2},"normal");
	});
	
	var which_slide = 1;
	var slideshow_length = $("div.slideshow div.placeholder ul li").length;
	
	//SLIDESHOW CLICK RIGHT
	$("div.slideshow div.slide-right").bind("click",function() {

		if (which_slide == 1) {
			$("div.slideshow div.placeholder ul").animate({left: "-940px"},"normal");
			which_slide = which_slide + 1;
		} else if (which_slide == 2) {
			$("div.slideshow div.placeholder ul").animate({left: "-1880px"},"normal");
			which_slide = which_slide + 1;
		} else if (which_slide == 3) {
			$("div.slideshow div.placeholder ul").animate({left: "-2820px"},"normal");
			which_slide = which_slide + 1;
		} else if (which_slide == 4) {
			$("div.slideshow div.placeholder ul").animate({left: "-3760px"},"normal");
			which_slide = which_slide + 1;
		} else if (which_slide == 5) {
			$("div.slideshow div.placeholder ul").animate({left: "-4700px"},"normal");
			which_slide = which_slide + 1;
		}
		
	});
	
	//SLIDESHOW CLICK LEFT
	$("div.slideshow div.slide-left").bind("click",function() {
	
		if (which_slide == 2) {
			$("div.slideshow div.placeholder ul").animate({left: "0px"},"normal");
			which_slide = which_slide - 1;
		} else if (which_slide == 3) {
			$("div.slideshow div.placeholder ul").animate({left: "-940px"},"normal");
			which_slide = which_slide - 1;
		} else if (which_slide == 4) {
			$("div.slideshow div.placeholder ul").animate({left: "-1880px"},"normal");
			which_slide = which_slide - 1;
		} else if (which_slide == 5) {
			$("div.slideshow div.placeholder ul").animate({left: "-2820px"},"normal");
			which_slide = which_slide - 1;
		} else if (which_slide == 6) {
			$("div.slideshow div.placeholder ul").animate({left: "-3760px"},"normal");
			which_slide = which_slide - 1;
		}
		
	});
	
	$("div.slideshow div.slide-left").bind("dblclick",function() {
		return false;
	});
	
	//CALL OUT HOVER
	$("div.callout ul li").hover(
	function() {
		$(this).css("backgroundPosition","right 25px");
	}, function() {
		$(this).css("backgroundPosition","0 25px");
	});
	
	//CONTACT TABLE
	$("form#contact_form table tr td:even").css("textAlign","right");
	$("form#contact_form table tr td:odd").css("textAlign","right");
	$("form#contact_form table tr:last td input").css("float","right");
	
	//CONTACT VALIDATION
	if ($("input#name")) {
		$("input#name").click(function() {
			$(this).css("backgroundColor","#ffffff").val("");
		});
	}
	
	if ($("input#email")) {
		$("input#email").click(function() {
			$(this).css("backgroundColor","#ffffff").val("");
		});
	}
	
	$("input#submit").click(function() {
	
		var hasError = false;
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
	
		var nameVal = $("input#name").val();
		if (nameVal == "") {
			$("input#name").css("backgroundColor","#ff572a");
			$("input#name").val("Required field");
			hasError = true;	
		}
		
		var emailVal = $("input#email").val();
		if (emailVal == "") {
			$("input#email").css("backgroundColor","#ff572a");
			$("input#email").val("Required field");
			hasError = true;
		} else if (!emailReg.test(emailVal)) {
			$("input#email").css("backgroundColor","#ff572a");
			$("input#email").val("Please submit a valid email address");
			hasError = true;
		}
		
		var commentsVal = $("textarea#comments").val();
		
		if (hasError == true) {
			return false;
		}
		
	});
	
	//FOOTER OPACITY
	$("div.footer").css("opacity","0.8");
	
	//GEAR PRODUCTS
	//SHIRT1
	$("ul.gear li.shirt1 form input[type=image]").hover(
		function() {
			$(this).attr("src","images/shirt001_hover.png");
		},
		function() {
			$(this).attr("src","images/shirt001.png");
		}
	);
	
	//SHIRT2
	$("ul.gear li.shirt2 form input[type=image]").hover(
		function() {
			$(this).attr("src","images/shirt002_hover.png");
		},
		function() {
			$(this).attr("src","images/shirt002.png");
		}
	);
	
	//SHIRT3	
	$("ul.gear li.shirt3 form input[type=image]").hover(
		function() {
			$(this).attr("src","images/shirt003_hover.png");
		},
		function() {
			$(this).attr("src","images/shirt003.png");
		}
	);
	
	//RECENT NEWS
	$("div.recent_posts div:last").addClass("last");
	
	/*
		//SLIDESHOW CLICK RIGHT
	$("div.slideshow div.slide-right").bind("click",function() {

		position = $("div.placeholder ul").position();
		position = position.left;
		
		if (which_slide >= 0 && which_slide <= (slideshow_length - 1)) {
			var new_position = (position - 940 + "px");
			$("div.slideshow div.placeholder ul").animate({left: new_position},"fast");
			which_slide = which_slide + 1;
		}
		
	});
	
	//SLIDESHOW CLICK LEFT
	$("div.slideshow div.slide-left").bind("click",function() {
	
		var position = $("div.placeholder ul").position();
		var position = position.left;
		
		if (which_slide >= 2 && which_slide <= (slideshow_length +1)) {
			var new_position = (position + 940) + "px";
			$("div.slideshow div.placeholder ul").animate({left: new_position},"fast");
			which_slide = which_slide - 1;
		}
		
	});
	*/
	
	
});