<!--
// entry page script
function ChkMdl(){
    // ** function called if user uses submit button **
    UsrInputFrm = document.SbmtFrm;
    model = UsrInputFrm.MODELNO.value;
    //
    // *** remove any blank spaces ***
    var newval=""
    for (var x = 0; x < model.length; x++) {
      var TESTCHR = model.substr(x,1)
      if (TESTCHR != " ") {
        newval=newval + TESTCHR
      }
    }
    model=newval
    // ** check if null ** 
    if (model == ''){
      alert("Please enter a valid Model Number or the first two or more characters of the model number to search for similar models to choose from. Then click on the search button.");
      UsrInputFrm.MODELNO.value="";
      UsrInputFrm.MODELNO.focus();
      return false;
    }
    else
    {
      // ** pos of dash **
      //helen 06-28-01* mtest = model.indexOf("-",0)
      //helen 06-28-01*if (mtest > 1){
      // Get rid of '-' since Service model# does not keep '-'
      // ** take from 0 -> dash concat with pos after dash to end **
      //helen 06-28-01*  model = model.substring(0,mtest) + model.substring(mtest+1,model.length)
      //helen 06-28-01*}
      // make sure min two characters
      if (model.length < 2){
        alert("Please enter a minimum of two characters!");
        UsrInputFrm.MODELNO.focus();
        return false;
      }
      nbrchr=model.length
      if (nbrchr == "2"){
        model=model + "-"
      }
      // ** automaticly converts character to upper case **
      model = model.toUpperCase()
      UsrInputFrm.MODELNO.value = model ;
      var PgReq="";
      PgReq="DspDta";
      UsrInputFrm.action="JMdlPrtXrf.asp?PgReq=" + PgReq + "&MdlNbr=" + model ;
      UsrInputFrm.submit();
    }
}
// 
function ChkSubmitMdl(){
    // ** function called if user hit return key at input box **
    UsrInputFrm = document.SbmtFrm;
    model = UsrInputFrm.MODELNO.value;
    // *** remove any blank spaces ***
    var newval=""
    for (var x = 0; x < model.length; x++) {
      var TESTCHR = model.substr(x,1)
      if (TESTCHR != " ") {
        newval=newval + TESTCHR
      }
    }
    model=newval
    //
    if (model == ''){
      alert("Please enter a valid Model Number or the first two or more characters of the model number to search for similar models to choose from. Then click on the search button.")
      UsrInputFrm.MODELNO.value="";
      UsrInputFrm.MODELNO.focus();
      return false;
    }
    else
    {
      //helen 06/28/01 mtest = model.indexOf("-",0)
      //helen 06/28/01 if (mtest > 1){
      // Get rid of '-' since Service model# does not keep '-'
      //helen 06/28/01  model = model.substring(0,mtest) + model.substring(mtest+1,model.length)
      // helen 06/28/01 }
      if (model.length < 2){
        alert("Please enter a minimum of two characters!");
        UsrInputFrm.MODELNO.focus();
        return false;
      }
      nbrchr=model.length
      if (nbrchr == "2"){
        model=model + "-"
      }
      model = model.toUpperCase();
      UsrInputFrm.MODELNO.value = model ;
      var PgReq="";
      PgReq="DspDta";
      UsrInputFrm.action="JMdlPrtXrf.asp?PgReq=" + PgReq + "&MdlNbr=" + model ;
      UsrInputFrm.submit();

    }
}
//
function GetCat(){
    UsrInputFrm = document.SbmtFrm
    UsrInputFrm.MODELNO.value = "";
    Xcat = ''
    CPos = UsrInputFrm.DROPCATS.selectedIndex
    if (CPos == -1){
      var Xcat = ""
    }
    else
    {
      Xcat = UsrInputFrm.DROPCATS.options[CPos].value
    }
    // *** remove any blank spaces ***
    var newval=""
    for (var x = 0; x < Xcat.length; x++) {
      var TESTCHR = Xcat.substr(x,1)
      if (TESTCHR != " ") {
        newval=newval + TESTCHR
      }
    }
    Xcat=newval
    if (Xcat == ""){
      // * in case user selects a empty option *
      alert("Not a Valid Product Type. Please select a specific Product type from the List.")
      return false;
    }  
    // first clear out the box of old values
    var SelOpts = UsrInputFrm.DROPCATS
    var SelSubOpts = UsrInputFrm.DROPSUBCATS
    // clear sub cat box
    SelSubOpts.length=0
    var max = SelSubOpts.length
    for (var w = 0; w < max ; w++){      
      SelSubOpts[w] = new Option(blnkstr,"")
    }
    hform = document.SbmtFrm
    var SUBCATS = hform.jvasubcatcds.value 
    var SUBCATSDESCS = hform.jvasubcatdescs.value
    var PATCHK1 = new RegExp(Xcat)
    var PATCHK2 = /[0123456789]/
    var PATCHK3 = /\*/
    var i = 0
    var Cntr1 = 0
    var Cntr2 = 0
    //
    // ** increase size of subcat drop down box
     SelSubOpts.size="3"
    // ** decrease size of cat drop down box
     SelOpts.size="1"     
    // now get matching subcds and descs into dropdown box or array
    for (var w = 0; w < SUBCATS.length; w++){
      //
      var TSTCHR = SUBCATS.substr(w,1)
      if (PATCHK3.test(TSTCHR)){
        // ** keep trak of code buckets by counting astrice **
        Cntr1++
      }
      else
      {
        // 
        if (PATCHK1.test(SUBCATS.substr(w,1))){
          // ** found first and all matching subcats **
          if (PATCHK2.test(SUBCATS.substr(w + 2,1))){
            // ** its a three digit subcat code **
            NEWSC = SUBCATS.substr(w,3)
            w = w + 2
          }
          else
          { // ** its a two digit subcat code **
            NEWSC = SUBCATS.substr(w,2)
            w = w + 1
          }
          // ** now get corrosponding description by counting astrice **
          Cntr2 = 0
          for (var y = 0; y < SUBCATSDESCS.length; y++){
            var TSTCHR = SUBCATSDESCS.substr(y,1)
            // ** count buckets **
            if (PATCHK3.test(TSTCHR) || Cntr1 == 0){
              // ** found astrice or user chose first cat so Cntr1=0 **
              // ** check if cntrs are equal iv got description **
              if (Cntr1 != 0){
                Cntr2++
              }
              if (Cntr2 == Cntr1){
                // ** have start of corrosponding descrition  **
                // ** move to first real character of description if not first bucket **
                if (Cntr1 != 0){
                  y = y + 1
                }
                var NEWSCDESC = ""
                for (var z = y; z < SUBCATSDESCS.length; z++) {
                  TSTCHR = SUBCATSDESCS.substr(z,1)
                  if (PATCHK3.test(TSTCHR)){
                    // ** when find next astrice your done **
                    z = SUBCATSDESCS.length
                    y = SUBCATSDESCS.length
                  }
                  else
                  {
                    NEWSCDESC = NEWSCDESC + SUBCATSDESCS.substr(z,1)
                  }
                }
              }
            }
          }
          var blnkstr="                                                                                "
          if (i == 0){
            // AUTOMATICLY SELECT THE FIRST SUBCAT TO FORCE TO TOP **
            SelSubOpts.options[i] = new Option("Select Product Description","",1,1)
            i = i + 1
            SelSubOpts.options[i] = new Option(NEWSCDESC,NEWSC)
            i = i + 1
          }
          else
          {  
            SelSubOpts.options[i] = new Option(NEWSCDESC,NEWSC)
            i = i + 1
          }
        }
      }
    }
    return false;  
}
//
function SbmtCat(){
//alert("im in sbmtcat");
    UsrInputFrm = document.SbmtFrm
    UsrInputFrm.MODELNO.value = "";
    //
    // get users sub category choice into scat
    SubCat = '';
    CPos = UsrInputFrm.DROPSUBCATS.selectedIndex
    if (CPos == -1){
      var SubCat = "";
    }
    else
    {
      SubCat = UsrInputFrm.DROPSUBCATS.options[CPos].value
    }
    // *** remove any blank spaces ***
    var newval=""
    for (var x = 0; x < SubCat.length; x++) {
      var TESTCHR = SubCat.substr(x,1)
      if (TESTCHR != " ") {
        newval=newval + TESTCHR;
      }
    }
    SubCat=newval
    var PgReq="";
    if (SubCat == ""){
      // * in case user hits search button without selecting a category *
      alert("Please select a Product Category and then a Product description from the lists then click on the search button.")
      return false;
    }
    if (SubCat.length > 1){
      PgReq="CatSch";
      UsrInputFrm.action="JMdlPrtXrf.asp?PgReq=" + PgReq + "&SubCat=" + SubCat ;
      UsrInputFrm.submit();
    }
}
//
function PgOnLoad(){
    var UsrInputFrm = document.SbmtFrm
    var PgReq = "";
    PgReq = UsrInputFrm.PgReq.value
    if (PgReq == "UsrInput"){
      var SelOpts = UsrInputFrm.DROPCATS
        // set size of category drop down box ie only
        SelOpts.size="3"
      var SelSubOpts = UsrInputFrm.DROPSUBCATS
        //set size of sub cat drop down box ie only
        SelSubOpts.size="1"
      // clear any old values out
      var max = SelSubOpts.length
      for (var w = 0; w < max ; w++){
        SelSubOpts[w] = new Option("","")
      }
      SelSubOpts[0] = new Option("Select Product Description"," ",1,1)
      //
      var CdCnt = 0
      var StrDsc = 0
      var EndDsc = 0
      var NxtOpt = 1
      // ** set up a match for the string delimeter in descriptions
      var PATCHK3 = /\*/
      var CATS = UsrInputFrm.jvaAllCatCds.value 
      var CATDESCS = UsrInputFrm.jvaAllCatDescs.value
      for (var y = 0; y < CATDESCS.length ; y++){
        // count the characters to know end of description
        EndDsc++
        // pull out the first cat description by finding the "*"
        var TSTCHR = CATDESCS.substr(y,1)
        if (PATCHK3.test(TSTCHR)){
          // when find astrice we have end of description
          CDESC=CATDESCS.substr(StrDsc,EndDsc - 1)
          // move past the astrice at end of description we just added to box
          StrDsc = y + 1
          // reset description character length cntr
          EndDsc = 0
          CCODE=CATS.substr(CdCnt,1)
          CdCnt++
          //if (NxtOpt == 0){
          //  SelOpts.options[NxtOpt] = new Option(CDESC,CCODE,1,1)
          //  NxtOpt++
          //}
          //else
          //{ 
            SelOpts.options[NxtOpt] = new Option(CDESC,CCODE)
            NxtOpt++
          //}   
        } 
      }
    }
    //
    // give focus to the input box
    var mdlbox = UsrInputFrm.MODELNO
    mdlbox.focus();
    return 1;
}
//alert("im loading scripts " + scptload);
 ScptLoad = true ;
// -->





