// Main Funtion

function checkWholeForm(form1) {
    var why = "";

// ==========================================================
// Below is the editable area - remove the // to enable validateion
// This script was written by Duffy System Solutions
// Support Contact - bduffy@4duffy.com
// It is not recommended to have too many field validate
// ==========================================================

// ------------------------  PAGE 1  ------------------------
//Position requesting

    why += checkEmail(document.form1.email.value);
    why += checkFullName(document.form1.name.value);
    why += checksubject(document.form1.subject.value);
    why += checkmessage(document.form1.message.value);
    why += RandomNumVarify()

    if (why != "") {
       alert(why);
       return false;
    }

return true;
}





// email

function checkEmail (strng) {
var error="";
if (strng == "") {
   error = "You didn't enter an email address.\n";
}

    var emailFilter=/^.+@.+\..{2,3}$/;
    if (!(emailFilter.test(strng))) { 
       error = "Please enter a valid email address.\n";
    }
    else {
//test email for illegal characters
       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
         if (strng.match(illegalChars)) {
          error = "The email address contains illegal characters.\n";
       }
    }
return error;    
}


// FullName - 4-10 chars, uc, lc, and underscore only.

function checkFullName (strng) {
var error = "";
if (strng == "") {
   error = "You didn't enter your Name.\n";
}


    var illegalChars = /\W/; // allow letters, numbers, and underscores
    if ((strng.length < 4) || (strng.length > 50)) {
       error = "The name field is the wrong length. Please use Bettween 4 and 50 characters.\n";
    }
//    else if (illegalChars.test(strng)) {
//    error = "The name contains illegal characters.\n";
//    } 
return error;
}       


// checksubject textbox

function checksubject(strng) {
var error = "";
  if (strng.length == 0) {
     error = "The subject text box has not been filled in.\n"
  }
return error;	  
}


// checkmessage textbox

function checkmessage(strng) {
var error = "";
  if (strng.length == 0) {
     error = "The message text area has not been filled in.\n"
  }
return error;	  
}

// Page Random Number Validator
//     why += RandomNumVarify(document.form1.PageVerifiedval.value);

function RandomNumVarify(strng) {
var error = "";
  if (document.form1.FullEnteredVerCode.value != document.form1.FullRanVerCode.value) {
     error = "Please type in the correct number listed at the bottom of the page.\n"
  }
return error;	  
}


