//function to valid the online contact us form
function validContact(obj) {
   var bad = false;
   var errors = "";
   
   if (obj.Name.value.length == 0) {
		errors += "The Last Name field can't be empty.<br>";
		bad = true;
   }
   
   if (obj.Phone.value.length > 0 && obj.Phone.value.length < 10) {
		errors += "The Phone Numer must be at least 10 digits.<br>";
		bad = true;
   }
   
   if (obj.Email.value.length == 0) {
		errors += "The Email field can't be empty.<br>";
		bad = true;
   }
   else if (!isEmail(obj.Email.value)) {
		errors += "The Email entered is invalid.<br>";
		bad = true;
   }
	
	if (obj.Captcha.value.length == 0) {
		errors += "The Security Code field can't be empty.<br>";
		bad = true;
   }
   else if (obj.Captcha.value.length != 6) {
		errors += "The Security Code entered is not the right length.<br>";
		bad = true;
   }
   
   if (bad) {
		error(errors);
		return false;
   }

   return true;
}

function isPhone(p)
{
	var phoneExp = /^\d{10}\d*$/
	return phoneExp.test(p);
}

function isEmail(e)
{
   var emailExp = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
   return emailExp.test(e);
}

function error(msg)
{
	msg = "<span>The following Errors Occurred:</span><br>" + msg;
	errorsDiv = document.getElementById('errors');
	errorsDiv.innerHTML = msg;
	errorsDiv.style.display = 'block';
}