// JavaScript Document

function checkWholeForm(Form) {
	var why = "";
//    document.write(theForm.email.value);
    why += checkEmail(Form.email.value);
    why += checkDetails(Form.details.value);

   if (why != "") {
       alert(why);
       return false;
    }

return true;
}

function checkWholeFormOrn(Form) {
	var why = "";
//    document.write(theForm.email.value);
    why += checkEmail(Form.email.value);
    why += checkDetailsOrn(Form.details.value);

   if (why != "") {
       alert(why);
       return false;
    }

return true;
}

function checkWholeForm_ContactMe(Form) {
	var why = "";
//    document.write(theForm.email.value);
    why += checkEmail(Form.email.value);
    why += checkContactDetails(Form.details.value);

   if (why != "") {
       alert(why);
       return false;
    }

return true;
}
function checkForm_ContactMe(Form) {
	var why = "";
    //document.write(Form.email.value);
    why += checkEmail(Form.email.value);
    why += checkName(Form.name.value);
    why += checkComments(Form.message.value);

   if (why != "") {
       alert(why);
       return false;
    }

return true;
}

function checkNewsLetterForm(Form) {
	var why = "";
//    document.write(theForm.email.value);
    why += checkEmail(Form.emailList.value);

   if (why != "") {
       alert(why);
       return false;
    }

return true;
}

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;    
}



// Details
function checkDetails (strng) {
var error = "";
  if (strng.length == 0) {
   error = "Please describe your new wreath in detail.\n";
}
return error;
}

function checkDetailsOrn (strng) {
var error = "";
  if (strng.length == 0) {
   error = "Please describe your new ornament in detail.\n";
}
return error;
}

function checkComments (strng) {
var error = "";
  if (strng.length == 0) {
   error = "Comments area is blank.\n";
}
return error;
}

function checkName (strng) {
var error = "";
  if (strng.length == 0) {
     error = "You didn't enter a Name.\n"
  }
return error;	  
}

// non-empty textbox

function isEmptyAmt(strng) {
var error = "";
  if (strng.length == 0) {
     error = "You didn't enter a Loan Amount.\n"
  }
return error;	  
}

function checkWholeContactForm(Form) {
	var why = "";
//    document.write(theForm.email.value);
    why += checkEmail(Form.email.value);
    why += checkDetails(Form.details.value);

   if (why != "") {
       alert(why);
       return false;
    }

return true;
}

// Details
function checkContactDetails (strng) {
var error = "";
  if (strng.length == 0) {
   error = "Please enter your comments.\n";
   }
return error;
}

