//	***************************************************************************************
//	This general.js file contains general setup information for the jQuery/JavaScript tools
//	***************************************************************************************
$(document).ready(function(){ 
						   
		
	// Hide element on click where it contains: class="clickhide"
	$('.clickhide').click(function() { $(this).fadeOut(600); });
	
	
	
	
	
	
	// contact form validation
		var hasChecked = false;
		$("#submit").click(function () { 
			hasChecked = true;
			return checkForm();
		});
		
		$("#name,#email,#message").live('change click', function(){
			if(hasChecked == true)
			{
				return checkForm();
			}
		});
		
		function checkForm()
		{
			var hasError = false;
			var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
			
			if($("#name").val() == '') {
				$("#error-name").fadeIn();
				hasError = true;
			}else{
				$("#error-name").fadeOut();
			}
			
			if($("#email").val() == '') {
				$("#error-email").fadeIn();
				hasError = true;
			}else if(!emailReg.test( $("#email").val() )) {
				$("#error-email").fadeIn();
				hasError = true;
			}else{
				$("#error-email").fadeOut();
			}
			
			if($("#message").val() == '') {
				$("#error-message").fadeIn();
				hasError = true;
			}else{
				$("#error-message").fadeOut();
			}
			
			if(hasError == true)
			{
				return false;
			}else{
				return true;
			}
		}
		// end contact form validation
}); 