$(document).ready(function(){
	$("#nav a").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
			if (theImg.data("originalsrc")) {
				theImg.attr("src", theImg.data("originalsrc"));
			}
		}
	);
	
	
	
	
});



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


function submitContact() {

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


	 var params = $("#contactForm").serialize();
	$.post("/cgi-bin/contact.cgi", params,
	   	function(data){
			if (data == 'ok') {
				$("#contactComplete").fadeIn('slow');

				setTimeout(function(){
					document.contactForm.reset()
					$("#contactComplete").fadeOut('slow');
				}, 5000);

			}
	});

	return false;
}
