
  function validateEmail(str) {

  var at="@"
  var dot="."
  var lat=str.indexOf(at)
  var lstr=str.length
  var ldot=str.indexOf(dot)
  if (str.indexOf(at)==-1){
  //alert("Invalid E-mail ID")
  return false
  }

  if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
  //alert("Invalid E-mail ID")
  return false
  }

  if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
  //alert("Invalid E-mail ID")
  return false
  }

  if (str.indexOf(at,(lat+1))!=-1){
  //alert("Invalid E-mail ID")
  return false
  }

  if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
  //alert("Invalid E-mail ID")
  return false
  }

  if (str.indexOf(dot,(lat+2))==-1){
  //alert("Invalid E-mail ID")
  return false
  }

  if (str.indexOf(" ")!=-1){
  //alert("Invalid E-mail ID")
  return false
  }

  return true
  }

  function validateZIP(field) {
  var valid = "0123456789-";
  var hyphencount = 0;

  if (field.length!=5 && field.length!=10) {
  //alert("Please enter your 5 digit or 5 digit+4 zip code.");
  return false;
  }
  for (var i=0; i < field.length; i++) {
  temp = "" + field.substring(i, i+1);
  if (temp == "-") hyphencount++;
  if (valid.indexOf(temp) == "-1") {
  //alert("Invalid characters in your zip code.  Please try again.");
  return false;
  }
  if ((hyphencount > 1) || ((field.length==10) && ""+field.charAt(5)!="-")) {
  //alert("The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'.   Please try again.");
  return false;
  }
  }
  return true;
  }

  function ValidateForm(){
  
  document.getElementById('liemail').style.display="none";
  document.getElementById('liall').style.display="none";
  document.getElementById('lireemail').style.display="none";
  document.getElementById('lizip').style.display="none";
  
  document.getElementById('errorarea').style.display="none";
  var valid=true;
  
  if(document.getElementById('email').value==''||document.getElementById('reemail').value==''||document.getElementById('zip').value=='')
  {
  document.getElementById('liall').style.display="";
  var valid=false;
  }

  if(!validateEmail(document.getElementById('email').value))
  {
  document.getElementById('liemail').style.display="";
  var valid=false;
  }
  if(document.getElementById('reemail').value!=document.getElementById('email').value)
  {
  document.getElementById('lireemail').style.display="";
  var valid=false;
  }
  if(!validateZIP(document.getElementById('zip').value))
  {
  document.getElementById('lizip').style.display="";
  var valid=false;
  }
  if(!valid)
  {
   document.getElementById('errorarea').style.display="";
   return false;
  }
  }

