//function to valid the online contact us form
function validAppointment(obj)
{
   var bad = false;
   var errors = "";
   
   if (obj.Name.value.length == 0)
   {
	errors += "The Name field can't be empty.<br>";
	bad = true;
   }
   
   if (obj.Address1.value.length == 0)
   {
	errors += "The Address field can't be empty.<br>";
	bad = true;
   }
   
   if (obj.City.value.length == 0)
   {
	errors += "The City field can't be empty.<br>";
	bad = true;
   }
   
   if (obj.State.options[obj.State.selectedIndex].value.length == 0)
   {
	errors += "The State field can't be empty.<br>";
	bad = true;
   }
   
   if (obj.Zip.value.length == 0)
   {
	errors += "The Zip field can't be empty.<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.DateRequested.value.length == 0)
   {
	errors += "The Requested Date field can't be empty.<br>";
	bad = true;
   }
   
   if (obj.Comments.value.length == 0)
   {
	errors += "The Comments field can't be empty.<br>";
	bad = true;
   }
   
   
   if (bad)
   {
	error(errors);
	return false;
   }

   return true;
}

function isPhone(p)
{
	var phoneExp = /^\d{3}-\d{3}-\d{4}$/
	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';
}