// Contact form validation, so the homepage form doesn't throw you to the contacts page

function validateFormHP(formHP){
	var errors = false;
	var phone = $('#TelephoneNumber').val();
	var comments = $('#cfComments').val();
	var email = $('#EmailAddress').val();
	
	//console.debug('Comments is '+comments+'| Phone is '+phone+'| email is '+email+'|');
	
	if(comments == null || comments == "")
	{
		errors = true;
		$('#error-cfComments').html('Please enter a comment!');
	}
	else $('#error-cfComments').html('');
	
	if(phone == null || phone == "")
	{
		errors = true;
		$('#error-TelephoneNumber').html('Please enter a comment!');
	}
	else $('#error-TelephoneNumber').html('');

	if(email == null || email == "")
	{
		errors = true;
		$('#error-EmailAddress').html('Please enter an email address!');
	}
	else
	{
		var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
		if(!emailPattern.test(email)) 
		{
			errors = true;
			$('#error-EmailAddress').html('Please enter a valid email address');
		}
		else $('#error-EmailAddress').html('');
	}
	
	return !errors;
}
