
  /*<!-- Validation & Input Limiting Functions -->*/

  /*
  Get Browser Type
  */
  
  var isNS = (navigator.appName=="Netscape")?1:0;
  var isIEa = (navigator.appName=="Microsoft Internet Explorer")?1:0;
  var isIEb = (navigator.appName=="Microsoft")?1:0;
  var isOP = (navigator.appName=="Opera")?1:0;
  
  isIEc=document.all;
  isNN=!document.all&&document.getElementById;
  isN4=document.layers;
  
//  alert('isNS: '+isNS+'isIEa: '+isIEa+'isIEb: '+isIEb+'isOP: '+isOP+']\n[isIEc: '+isIEc+' isNN: '+isNN+'isN4: '+isN4+']');
   
  //-------------------------------------------------------------------
  // 
  //
  //
  //    
  //   
  //-------------------------------------------------------------------

  function key_control(e) {
    if(e.keyCode==13) {
      e.keyCode=9;
    }  
  }

  //-------------------------------------------------------------------
  // 
  //
  //
  //    
  //   
  //-------------------------------------------------------------------

  function limitText(limitField, limitCount, limitNum) {
    if (limitField.value.length > limitNum) {
      limitField.value = limitField.value.substring(0, limitNum);
    } else {
      limitCount.value = limitNum - limitField.value.length;
    }
  }

  //-------------------------------------------------------------------
  //
  // Input keypress limiting functions
  //   
  //    
  //   
  //-------------------------------------------------------------------
  
  function numonly(e) {            // [0-9]
    var validKeys=[];
    var validKeyRange=[['48','57']];
    return checkKeys(e,validKeys,validKeyRange);
  }
  
  function numspconly(e) {         // [0-9 .]
    var validKeys=['32','46'];
    var validKeyRange=[['48','57']];
    return checkKeys(e,validKeys,validKeyRange);
  }
  
  function numslashonly(e) {         // [0-9 /]
    var validKeys=['32','47'];
    var validKeyRange=[['48','57']];
    return checkKeys(e,validKeys,validKeyRange);
  }
  
  function numspchexonly(e) {      // [0-9a-fA-F ]
    var validKeys=['32'];
    var validKeyRange=[['48','57'],['65','70'],['97','102']];
    return checkKeys(e,validKeys,validKeyRange);
  }
  
  function charonly(e) {           // [A-Za-z -]
    var validKeys=['32','45'];
    var validKeyRange=[['65','90'],['97','122']];
    return checkKeys(e,validKeys,validKeyRange);
  }

  function stdchar(e) {            // [0-9A-Za-z -./]
    var validKeys=['32','45','46','47'];
    var validKeyRange=[['48','57'],['65','90'],['97','122']];
    return checkKeys(e,validKeys,validKeyRange);
  }

  function stdchar2(e) {           // [0-9A-Za-z #$%&(),-./]
    var validKeys=['32','35','36','37','38','40','41','44','45','46','47'];
    var validKeyRange=[['48','57'],['65','90'],['97','122']];
    return checkKeys(e,validKeys,validKeyRange);
  }
  
  function emailchar(e) {          // [0-9A-Za-z -.@_]
    var validKeys=['32','45','46','64','95'];
    var validKeyRange=[['48','57'],['65','90'],['97','122']];
    return checkKeys(e,validKeys,validKeyRange);
  }

  function datechar(e) {           // [0-9/]
    var validKeys=['47'];
    var validKeyRange=[['48','57']];
    return checkKeys(e,validKeys,validKeyRange);
  }
  
  function timechar12(e) {         // [0-9 :AMPamp]
    var validKeys=['32','58','65','77','80','97','109','112'];
    var validKeyRange=[['48','57']];
    return checkKeys(e,validKeys,validKeyRange);
  }
  
  function timechar24(e) {         // [0-9:]
    var validKeys=['58'];
    var validKeyRange=[['48','57']];
    return checkKeys(e,validKeys,validKeyRange);
  }

  function monetary(e) {           // [0-9-.]
    var validKeys=['45','46'];
    var validKeyRange=[['48','57']];
    return checkKeys(e,validKeys,validKeyRange);
  }

  //-------------------------------------------------------------------
  // 
  // 
  //   
  //    
  //   
  //-------------------------------------------------------------------
  
  function checkKeys(e,validKeys,validKeyRange) {
    var keyID=getKey(e); // Get KeyCode
    
    // Add valid control keys to validKey Array (0=misc, 8=delete, 13=carriage return)
    var controlKeys=['0','8','13'];
    validKeys=validKeys.concat(controlKeys)
    
    if (checkValidKey(keyID,validKeys)) { return true; } // Check individual valid keys
    if (checkValidKeyRange(keyID,validKeyRange)) { return true; } // Check valid key ranges
    
    return false;
  }

  function getKey(e) {
    if(!isNS) { var keyID=e.keyCode; } 
         else { var keyID=e.which;   }
    return keyID
  }
  
  function checkValidKey(keyID,validKeys) {
    // Check individual valid keys
    for (var i in validKeys) {
      if (keyID == validKeys[i]) { return true; }
    }
  }
  
  function checkValidKeyRange(keyID,validKeyRange) {
    // Check valid key ranges
    var min, max;
    for (var id in validKeyRange) {
      min=validKeyRange[id][0];
      max=validKeyRange[id][1];
      if (keyID >= min && keyID <= max) { return true; }
    }
  }

/******************************************************************************/
/*

  //-------------------------------------------------------------------
  // 
  // 
  //   
  //    
  //   
  //-------------------------------------------------------------------

  //-------------------------------------------------------------------
  // checkValueLength(stringVal,maxLength[,minLength])
  //   Checks a string value to see if it is too long
  //   Optionally checks for minimum length
  //-------------------------------------------------------------------
  function checkValueLength(stringVal,maxLength) {
    var minLength=(arguments.length>2)?arguments[2]:0;
    if (minLength<=stringVal.length && stringVal.length<=maxLength) { return true; }
    return false;
  }
  
  //-------------------------------------------------------------------
  // checkValidSelectBox(obj)
  //   Checks a selectbox to ensure the user has selected an option
  //    based on the SelectObject.value
  //   Uses the default value of 0 to be unselected
  //-------------------------------------------------------------------
  function checkValidSelectBox(obj,required) {
    if (required==0) { return true; }
    var defaultOption=(parseInt(obj.value)>=0)?0:'';
    var currentOption=obj.value.replace(/ /gi,'');
    if (currentOption==defaultOption) { return false; }
    return true;
  }
  
  //-------------------------------------------------------------------
  // checkValidTextInput(obj,required[,LimitType])
  //   Checks a selectbox to ensure the user has selected an option
  //    based on the SelectObject.value
  //   Uses the default value of 0 to be unselected
  //-------------------------------------------------------------------
  function checkValidTextInput(obj,required) {
    if ((required==0) && (obj.value.length==0)) { return true; }
    var LimitType=(arguments.length>2)?GetRegexMatch(arguments[2]):GetRegexMatch(6);
    if ((parseInt(arguments[2])==7) || (arguments[2]=='datechar')) {
      //date
      //if (!isDate(obj.value,'d/M/y')) return false;
      if (!isDate(obj.value,'dd/MM/yyyy')) return false;
    }
    if ((parseInt(arguments[2])==8) || (arguments[2]=='timechar12')) {
      // time 12 hour
      if (!isDate(obj.value,'h:mm')) return false;
    }
    if ((parseInt(arguments[2])==9) || (arguments[2]=='timechar24')) {
      // time 24 hour
      if (!isDate(obj.value,'H:mm')) return false;
    }
    if ((parseInt(arguments[2])==10) || (arguments[2]=='monetary')) {
      // strip comma's from value
      obj.value = obj.value.replace(/,/g,'');
    }
    return LimitType.test(obj.value);
  }
  
  
  //-------------------------------------------------------------------
  // checkValidTextInput(obj,LimitType,required)
  //   Checks a selectbox to ensure the user has selected an option
  //    based on the SelectObject.value
  //   Uses the default value of 0 to be unselected
  //-------------------------------------------------------------------
  function TFormValidate(obj,ValidateType,required) {
    switch(obj.type) {
      case 'hidden':
        return true;
        break;
      case 'select-one':
      case 'select-multiple':
        return checkValidSelectBox(obj,required,ValidateType);
        break;
      case 'text':
      case 'password':
      case 'textarea':
      default:
        //var ValidateType=(arguments.length>2)?arguments[2]:6;
        return checkValidTextInput(obj,required,ValidateType);
        break;
    }
  }

  function GetRegexMatch(regexType) {
    switch(regexType) {
      case  0: case 'numonly':        return /^[0-9]+$/;                     break;
      case  1: case 'numspconly':     return /^[0-9 ]+$/;                    break;
      case  2: case 'numspchexonly':  return /^[0-9a-fA-F ]+$/;              break;
      case  3: case 'charonly':       return /^[A-Za-z \-]+$/;               break;
      case  4: case 'stdchar':        return /^[0-9A-Za-z \-\.]+$/;          break;
      case  5: case 'emailchar':      return /^[0-9A-Za-z \-\.@]+$/;         break;
      case  6: case 'stdchar2':       return /^[0-9A-Za-z #\$%&()\-\.\/]+$/; break;
      case  7: case 'datechar':       return /^[0-9\/]+$/;                   break;
      case  8: case 'timechar12':     return /^[0-9 :AMPamp]+$/;             break;
      case  9: case 'timechar24':     return /^[0-9:]+$/;                    break;
      case 10: case 'monetary':       return /^[0-9]+\.[0-9]{2}$/;           break;
      default:                        return /.*//*;                           break;
    }
  }
*/