// JavaScript Document

function Contact_Form_Validator()
{


// return all the field names to default color
document.getElementById('ContactNameLabel').innerHTML = "<span style='color:#000000;'><span class='redText'>*</span>Your Name: </span>";
document.getElementById('ContactMessageLabel').innerHTML = "<span style='color:#000000;'><span class='redText'>*</span>Message: </span>";
document.getElementById('LabelUserCode').innerHTML = "<span style='color:#000000;'><span class='redText'>*</span>Enter Code: </span>";

  if (document.ContactForm.ContactName.value == "")
  {
    alert("Please enter your name.");
	document.getElementById('ContactNameLabel').innerHTML = "<span style='color:#FF0000;'>*Your Name: </span>";
    document.ContactForm.ContactName.focus();
	return (false);
  }
  
  
  if (document.ContactForm.copyTo.value != "") {
   var EmailAddress = document.ContactForm.copyTo.value;
   var EmailValid = EmailAddress.indexOf('@');
   
   // check for the @ character   
   if (EmailValid == '-1') {
   document.ContactForm.copyTo.focus();
   alert("Your email address must contain the @ character. Please enter a valid e-mail address.");
   return (false)
   }
   
   //check to make sure they have at least one character after the @ symbol (persits throws an error if not)
   if (EmailValid + 1 == EmailAddress.length){
   document.ContactForm.copyTo.focus();
   alert("Please enter a valid e-mail address.");
   return (false)
   }
   
   //check to make sure they have at least three characters
   if (EmailAddress.length < 3) {
   document.ContactForm.copyTo.focus();
   alert("Please enter a valid e-mail address.");
   return (false)
   }
   
 }
   
     
  
  if (document.ContactForm.ContactMessage.value == "")
  {
    alert("Please enter a message.");
	document.getElementById('ContactMessageLabel').innerHTML = "<span style='color:#FF0000;'>*Message: </span>";
    document.ContactForm.ContactMessage.focus();
	return (false);
  }
    
  if (ContactForm.TextBoxUserCode.value == "")
  {
    document.getElementById('LabelUserCode').innerHTML = "<span style='color:#FF0000;'>*Enter Code: </span>";
    ContactForm.TextBoxUserCode.focus();
	
    return (false);
  } 
    return (true);
}