function checkWholeForm(theForm) {
    var why = "";
    why += isEmptyName(theForm.name.value);
    why += isEmptyTel(theForm.tel.value);
    why += checkEmail(theForm.email.value);
    why += isEmptyMessage(theForm.comments.value);
    why += isEmpty(theForm.came_from.value,"Please tell us how you heard about us.");
    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;    
}

function isEmptyName(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Please include your name.\n";
  }
return error;	  
}
function isEmpty(strng,msg) {
var error = "";
  if (strng.length == 0) {
     error = msg+".\n";
  }
return error;	  
}
// non-empty textbox
function isEmptyTel(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Please provide a contact number. \n";
  }else {
//test email for illegal characters
       var illegalChars= /[\@\<\>\,\;\:\\\"\[\]]/
         if (strng.match(illegalChars)) {
          error = "Your contact number contains illegal characters.\n";
       }
    }
return error;	  
}
function isEmptyMessage(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Please provide a message. \n";
  } 
return error;	  
}

function toggleLayer(whichLayer)
{
if (document.getElementById)
{
// this is the way the standards work
var style2 = document.getElementById(whichLayer).style;
style2.display = style2.display? "":"block";
}
else if (document.all)
{
// this is the way old msie versions work
var style2 = document.all[whichLayer].style;
style2.display = style2.display? "":"block";
}
else if (document.layers)
{
// this is the way nn4 works
var style2 = document.layers[whichLayer].style;
style2.display = style2.display? "":"block";
}
}
