// check whether a text field has been filled
function isTextFieldEmpty(ipField){
  var x=ipField.value.length;
  if(x<1){
    notFilled(ipField);
    return true;  // empty
  }
  return false;  // not empty
}
// similar to isTextFieldEmpty, this version includes the error
// message you should return if the field is empty, so the error
// alert doesn't take focus away from the field in question
function isTextFieldEmpty2(ipField,errString){
  var x=ipField.value.length;
  if(x<1){
    alert(errString);
    notFilled(ipField);
    return true;  // empty
  }
  return false;  // not empty
}
// set focus on a text field that hasn't been filled
function notFilled(ipField){
  ipField.focus();
  ipField.select();
}
//check whether a phone number is valid; allows "().+ -ext" chars.
function validPhoneNumber(ipField){
  var ch="";
  for(var i=0;i<ipField.value.length;i++){
    ch=ipField.value.substring(i,i+1);
    if((ch<"0"||ch>"9")&&ch!=" "&&ch!="-"&&ch!="x"&&ch!="e"
       &&ch!="t"&&ch!="("&&ch!=")"&&ch!="+"&&ch!="."){
      notFilled(ipField);
      return false;
    }
  }
  return true;
}
// get the name of all the elements in a form
function getFormElementNames(formName){
  var str1="";
  for(var i=0;i<formName.elements.length;i++){
    str1+=i+"\t"+formName.elements[i].name+"\n";
  }
  return str1;
}
// slightly different version of getFormElementNames, because 
//it allows you to specific where the numbering should start
function getFormElementNames2(formName,start){
  var str1="";
  for(var i=start;i<formName.elements.length;i++){
    str1+=i+"\t"+formName.elements[i].name+"\n";
  }
  return str1;
}
// looks to see if any checkboxes in a range of form elements have been checked
function anyCheckbox(formName,start,end){
  for(var i=start;i<=end;i++){
    if(formName.elements[i].checked==true){
      return true;  // at least one check box has been checked
    }
  }
  notFilled(formName.elements[start]);
  return false;  // no check box in the current range has been checked
}
function checkRadio(ipField){
  var tmpVal = "ERROR";
  for(var i=0;i<ipField.length;i++){
    if(ipField[i].checked==true){
      tmpVal=ipField[i].value;
    }
  }
  return tmpVal;
}
function validEmail(ipField){
  var loc=-1,loc2=-1;
  loc=ipField.value.indexOf("@");
  loc2=ipField.value.lastIndexOf(".");
  if(loc==-1||loc2==-1||loc2<loc){
   notFilled(ipField);
   return false;
  }
  return true;
}