$(document).ready(function(){


	// HOVER
	$("a.nav").hover( 
		// over
		function(){
			var theImg = $(this).find('img:first');
			// store the original image src
			theImg.data( "originalsrc" , theImg.attr("src") );
			
			// add -over to the image unless it is already -over
			if (!theImg.attr("src").match(/-over/) ) {
				theImg.attr( "src", theImg.attr("src").replace(/\./, "-over.") );
			}
			
		},
		
		// out
		function(){
			var theImg = $(this).find('img:first');
			// replace the original src
			theImg.attr("src", theImg.data("originalsrc")).data("originalsrc", null);
		}
	);

});


window.onload = function() {
		// preload
		$("a.nav img").each(
			function() {
				if (!$(this).attr("src").match(/-over/) ) {
					$("<img>").attr( "src", $(this).attr("src").replace(/\./, "-over.") );
				}
			}
		);
}


function submitEmail() {
		
	if (!document.emailForm.name.value)
		{
			alert('Please enter your Name.');
			document.emailForm.name.focus();
			return false;
		}

	if (!document.emailForm.email.value)
		{
			alert('Please enter your Email.');
			document.emailForm.email.focus();
			return false;
		}						



	 var params = $("#emailForm").serialize();
	$.post("/cgi-bin/email.cgi", params,
	   	function(data){
		$("#submitButton").fadeOut('slow', function(){
			$("#email").attr('value', '');
			$("#name").attr('value', '');
			$("#submitButton").after(data);
			$("#success").fadeIn('slow');
		});
		
		setTimeout(function(){
				$("#success").fadeOut('slow',function(){
					$("#success").remove();
					$("#submitButton").fadeIn('slow');
				});
			}, 5000);

		
	});
	
	return false;
}


