
function validate() {

 var error_count = 0;
 var temp = "";
 var r = "*";
 
 // Validate Last Name Field
 if (document.email.lname.value.length<2) {temp=r;error_count++;}
 else {temp="";}
 s("l_error").innerText = temp;



 // Validate Email Address Field
 var input = document.email.address.value;
 var re = /^[\w\.\-]+\@[\w\.\-]+\.[a-z]+$/i;
 var match = re.exec(input);
 
 if (!match) {temp=r;error_count++;}
 else {temp="";}
 s("a_error").innerText = temp;



 // Validate Subject Field
 if (document.email.sub.value=="") {temp=r;error_count++;}
 else {temp="";}
 s("s_error").innerText = temp;

 // Validate Message Field
 if (document.email.msg.value=="") {
  document.email.msg.style.borderColor="red";
  error_count++;
 }
 else {
  document.email.msg.style.borderColor="white";
 }
 
 
 if (error_count>0) {
  s("warning").style.color = "red";
  return false;
 }
 

 // submit form
 document.email.submit(); 
}



function clear_form() {
 s("warning").style.color = "white";
 s("l_error").innerText = "";
 s("a_error").innerText = "";
 s("s_error").innerText = "";
 document.email.msg.style.borderColor="white";
}



function s(x) {
 return document.getElementById(x);
}




