//Check contact form
function checkEmail(string) {
return (string.indexOf(".") > 2) && (string.indexOf("@") > 0);
}

function validateForm() {
var errorMessage = "";

	for (i = 0; i<document.contactform.elements.length; i++) {
	
		if (document.contactform.elements[i].name == "email") {
		
			if (!checkEmail(document.contactform.elements[i].value)) {
			errorMessage = ('The email address is not properly formatted.');
			break;
			}
		
		}
		else if (!document.contactform.elements[i].value && (document.contactform.elements[i].className == 'requiredfield')){
		errorMessage = ('Please enter a ' + document.contactform.elements[i].name + '.');	
		break;
		}
		
	}
	
	if (errorMessage) {
	alert(errorMessage);
	return false;
	}
	else {
	return true;
	}

}


$(document).ready(function() {

	/*MENU GUI*/
	$(".button").hover(function() {
		if ($(this).attr("src").indexOf("_on") == -1) {
		var newSrc = $(this).attr("src").replace(".png","_on.png");
		$(this).attr("src",newSrc);
		}
	},
	function() {
		if($(this).attr("src").indexOf("_on.png") != -1) {
		var oldSrc = $(this).attr("src").replace("_on.png",".png");
		$(this).attr("src",oldSrc);
		}
	});
	
	$(".button").click(function() {
	$(this).blur();	
	});
	
	
	/*SWITCH GUI*/
	$(".switch").hover(function() {
	$(this).addClass("switchon");					
	},
	function() {
	$(this).removeClass("switchon");
	});
	
	
	/*REQUIRED FORM FIELDS*/
	$().find(".requiredfield, .requiredfield2").each(function(i){
		$(this).parent().prev().prepend("<span class=\"highlight\">*</span> ");
	});
	
});
