


function Form1_Validator(theForm)
{
  if (theForm.elements['s-name'].value == "")
  {
    alert("Please enter a value for the \'Name\' field.");
    theForm.elements['s-name'].focus();
    return false;
  }


  if (theForm.email.value == "")
  {
    alert("Please enter a value for the \'Email\' field.");
    theForm.email.focus();
    return false;
  }

  if (theForm.address.value == "")
  {
    alert("Please enter a value for the\'Address\' field.");
    theForm.address.focus();
    return false;
  }

  if (theForm.zip.value == "")
  {
    alert("Please enter a value for the \'ZIP\' field.");
    theForm.zip.focus();
    return false;
  }

  if (theForm.city.value == "")
  {
    alert("Please enter a value for the \'City\' field.");
    theForm.city.focus();
    return false;
  }

  if (theForm.state.value == "")
  {
    alert("Please enter a value for the \'State/Province\' field.");
    theForm.state.focus();
    return false;
  }

  if (theForm.phone.value == "")
  {
    alert("Please enter a value for the \'Phone\' field.");
    theForm.phone.focus();
    return false;
  }

  if (!isNumber(theForm.phone)) return false;
  if (!validateEmail(theForm.email.value)) 
  {
    alert("Enter correct E-mail address");
    theForm.email.focus();
    return false;
  }
  return true;
}

function isNumber(f)
{var data=f.value;
var numStr="0123456789 -()+"; var th;  var counter=0;  var ret=false;
 for(var i=0; i < data.length; i++)
 {th = data.substring(i, i+1); if(numStr.indexOf(th) != -1) counter++;}
 if(counter == data.length) return true; 
 alert("Enter correct phone number");
 f.select(); f.focus(); 
 return(ret);
}


function validateEmail(em) {
  var str = new String(em);
  if (window.RegExp) {
    var reg1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
    var reg2str = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,4})(\\]?)$";
    var reg1 = new RegExp(reg1str);
    var reg2 = new RegExp(reg2str);
    if (!reg1.test(str) && reg2.test(str)) {
      return true;
    }
    return false;
  } else {
    if(str.indexOf("@") >= 0)
      return true;
    return false;
  }
}
