<!-- Hide Script..

//******************************************
//Generic Form Validation Scripts
//Created By: Chris Daniel
//Date:2/4/2011
//******************************************


function validateESubFormSubmit(theForm) {
var themessage = "";
//  themessage += validateUsername(theForm.username);
//  themessage += validatePassword(theForm.pwd);


// Validate Generally Required Fields running specified functions below
  themessage += validateEmail(theForm.email);
  themessage += validateZip(theForm.zip);

  if (themessage != "") {
   // alert("Invalid input.\n" + themessage);
   alert(themessage);
    return false;
  }

  return true;
}




function validateFormSubmit(theForm) {
var themessage = "";
//  themessage += validateUsername(theForm.username);
//  themessage += validatePassword(theForm.pwd);


// Validate Generally Required Fields running specified functions below
  themessage += validateName(theForm.name);
  themessage += validateEmail(theForm.email);
  themessage += validatePhone(theForm.phone);
  themessage += validateComments(theForm.comments);



  if (themessage != "") {
   // alert("Invalid input.\n" + themessage);
   alert(themessage);
    return false;
  }

  return true;
}



function validateBudgetFormSubmit(theForm) {
var themessage = "";

//Validate the Budget Comments Form
  themessage += validateZip(theForm.zip)
  themessage += validateComments(theForm.comments);
  themessage += validateEmail(theForm.email);

 
  if (themessage != "") {
   // alert("Invalid input.\n" + themessage);
   alert(themessage);
    return false;
  }

  return true;
}


//******************************************
// Required Validation Functions
//******************************************

function validateName(fld) {
    var error = "";
      if (fld.value.length == 0) {
        fld.style.background = 'Yellow'; 
        error = "Please submit your name.\n"
    } else {
        fld.style.background = 'White';
    }
    return error;   
}

function validateComments(fld) {
    var error = "";
      if (fld.value.length == 0) {
        fld.style.background = 'Yellow'; 
        error = "Please submit your comments.\n"
    } else {
        fld.style.background = 'White';
    }
    return error;   
}


function trim(s)
{
  return s.replace(/^\s+|\s+$/, '');
} 

function validateEmail(email) {
 var error="";
    var trimemail = trim(email.value);                        
    var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
    var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;
    
    if (email.value == "") {
        email.style.background = 'Yellow';
        error = "Please enter a valid email address.\n";
    } else if (!emailFilter.test(trimemail)) {              //test email for illegal characters
        email.style.background = 'Yellow';
        error = "Please enter a valid email address.\n";
    } else if (email.value.match(illegalChars)) {
        email.style.background = 'Yellow';
        error = "The email address provided contains illegal characters. Please try again.\n";
    } else {
        email.style.background = 'White';
    }
    return error;
}

function validatePhone(aPhone) {
    var error = "";
    var stripped = aPhone.value.replace(/[\(\)\.\-\ ]/g, '');     

   if (aPhone.value == "") {
        error = "Please enter a valid phone number.\n";
        aPhone.style.background = 'Yellow';
    } else if (isNaN(parseInt(stripped))) {
        error = "The phone number contains illegal characters.\n";
        aPhone.style.background = 'Yellow';
    } else if (!(stripped.length == 10)) {
        error = "The phone number length is incorrect. Make sure you include your area code.\n";
        aPhone.style.background = 'Yellow';
    } else {
        aPhone.style.background = 'White';
    }
    return error;
}


function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char; 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }


function validateZip(aZip) {
var error = "";

if (!IsNumeric(aZip.value) || aZip.value == "" || aZip.value.length!=5 ) {
	error = "Please enter a valid five digit zip code.\n";
	aZip.style.background = 'Yellow';

   } else {
        aZip.style.background = 'White';
    }
    return error;
}




//-->

