function _addInput (_id, _dsc, _len, _rqd, _eml) {
  this._id = _id;
  this._dsc = _dsc;
  this._len = _len;
  this._rqd = _rqd;
  this._eml = _eml;
}

arrInput = new Array();

function _input (_id, _dsc, _len, _rqd, _eml) {
  arrInput[arrInput.length] = new _addInput(_id, _dsc, _len, _rqd, _eml);
}

function VAL(obj) {
  strError = "";
  for (j=0; j<arrInput.length; j++) {
    if (eval("obj."+arrInput[j]._id).value=="" && arrInput[j]._rqd)  strError += "  • You have not completed \" "+arrInput[j]._dsc+" \"\n";
    else if (eval("obj."+arrInput[j]._id).value.length > arrInput[j]._len) strError += "  • You may not use more than " + arrInput[j]._len + " characters in \" "+arrInput[j]._dsc+" \"\n";
    else if (arrInput[j]._eml) {
      if (!(checkEmail(eval("obj."+arrInput[j]._id).value)))  strError += "  • You have entered an incorrect email address in \" "+arrInput[j]._dsc+" \"\n";
    } else {
      if (!(checkChars(eval("obj."+arrInput[j]._id).value)))  strError += "  • You have used invalid characters such as \"#$%*+/:;<=>[\]^` in \" "+arrInput[j]._dsc+" \"\n";
    }
  }
  if (strError!="") {
    alert("The following errors have occurred...\n\n" + strError);
    return false;
  } else return true;
}
 
function checkChars(str,full) {
  var bool = true;
  var strASCII = "|34|35|36|37|42|43|47|58|59|60|61|62|91|92|93|94|96|";
  var strAllow = "|10|13|"
  if(full!=1) strAllow += "47|";
  for (i=0; i<str.length; i++) 
    if ((str.charCodeAt(i)<32 || str.charCodeAt(i)>122 || strASCII.indexOf("|"+str.charCodeAt(i)+"|")>-1) && strAllow.indexOf("|"+str.charCodeAt(i)+"|")<0) bool = false;
  return bool;
}

function checkEmail(str) {
  if (str!="") {
    if (checkChars(str,1)) return ((str.lastIndexOf("@")>0) && (str.lastIndexOf(".")>str.lastIndexOf("@")) && (str.lastIndexOf(".")>2));
    else return false;
  } else return true;
}