// JavaScript Document
/***************************************************************
** define and instantiate validation objects
** the validation object accepts the following parameters:
**
**   realName: name used in the alerts (same as label on the page)
**
**   formEltName: this must be the name of the corresponding
**       HTML form element; make it the same as the object name
**
**   eltType: element type (we have to create this since IE3
**       doesn't support the type property for for elements)
**     text
**     textarea
**     checkbox
**     radio
**     select
**
**   uptoSnuff: function call that's evaluated during validation check
**     isText(str)
**     isSelect(formObj)
**     isRadio(formObj)
**     isCheck(formObj, form, [index of first checkbox in group],
**         [number of checkboxes])
**     isEmail(str)
**     isState(str)
**     isZipCode(str)
**     isPhoneNum(str)
**     isDate(str)
** 	   isSerialNum(str,n)
**
**   format: text representation of required format;
**       pass 'null' if no required format;
**       used in alert as an aid to user
***************************************************************/

function validation(realName, formEltName, eltType, upToSnuff, format) {
  this.realName = realName;
  this.formEltName = formEltName;
  this.eltType = eltType;
  this.upToSnuff = upToSnuff;
  this.format = format;
}

// create a new object for each form element you need to validate
var name = new validation("your name", "name", "text", "isText(str)", null);
var company = new validation("your company name", "company", "text", "isText(str)", null);
var teleno = new validation("your telephone number", "teleno", "text", "isText(str)", null);
var email = new validation("your email address", "email", "text", "isEmail(str)", null);
var service = new validation("service interested in", "service", "text", "isText(str)", null);
var client = new validation("the client option", "client", "radio", "isRadio(formObj)", null);

/***************************************************************
** Define the elts array:
** Add a new item to the array for each object you create above
** Make sure the value of the array element is the same as
** the name of the object, and that the array elements are listed
** in the same order the corresponding objects appear in the form
** (it's more clear to the user that way)
***************************************************************/
var elts = new Array(name,company,teleno,email,service,client);

/***************************************************************
** The main function keeps track of which fields the user missed
** or filled in incorrectly, and alerts the user so they can go
** back and fix what's wrong.
** Set allAtOnce to true if you want this "validation help" to
** alert the user to all mistakes at once; set it to false if
** you want it to show one mistake at a time
***************************************************************/
var allAtOnce = true;
