//+++++++++++++ LIST OF FUNCTIONS +++++++++++++++
//+ buildCallShipperOptions                     +
//+ buildTimeOptions                            +
//+ checkCube                                   +
//+ checkDimension                              +
//+ checkEmailRequired                          +
//+ convertComma                                +
//+ EditAdditionalServices                      +
//+ EditCODInformation                          +
//+ EditCommodityInformation                    +
//+ EditCustInfo                                +
//+ EditOtherOptions                            +
//+ EditReferenceNumbers                        +
//+ EditRequesterInfo                           +
//+ EditRequiredFields                          +
//+ EditShipmentSpecifics                       +
//+ FormatSummary                               +
//+ initCallShipperOptions                      +
//+ initTimesList                               +
//+ objCallShipper                              +
//+ objTime                                     +
//+ openClientLocationWin                       +
//+ openCubeWizard                              +
//+ openLocationListWin                         +
//+ openLocationWin                             +
//+ resyncEmail                                 +
//+ SetFocus                                    +
//+ showUnitHelp                                +
//+ SubmitForm                                  +
//+ Validate2                                   +
//+ ValidateAdditionalServices                  +
//+ ValidateCODInformation                      +
//+ ValidateCommodityInformation                +
//+ ValidateCustInfo                            +
//+ ValidateOtherOptions                        +
//+ ValidateReferenceNumbers                    +
//+ ValidateRequesterInfo                       +
//+ ValidateShipmentSpecifics                   +
//+ ValidCommodities                            +
//+ ValidCommodityInfo                          +
//+ ValidCurrencyAmount                         +
//+ ValidDeclaredUnit                           +
//+ ValidEMailAddresses                         +
//+ ValidPartyInfo                              +
//+ ValidPartyInfo2                             +
//+ ValidPhoneNumbers                           +
//+ ValidPronumber                              +
//+ ValidRefnos                                 +
//+ ValidRequesterAffiliation                   +
//+ ValidRequesterContactInfo                   +
//+ ValidShipDate                               +
//+ ValidTruckPackNumber                        +
//+++++++++++++++++++++++++++++++++++++++++++++++

//+++++++++++++++++++ Global ++++++++++++++++++++
var errmsg;
var objForm;
var shp = 0;
var con = 1;
var cod = 2;
var intMaxSteps = 8;
var intTotalWeight;
var objShpLookUpButton;
var objConsLookUpButton;
var jsFormName = 'frmBOL';
var arrCallShipper = new Array();
var arrTimes = new Array();


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ BUILD CALL SHIPPER OPTIONS                                          +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function buildCallShipperOptions(def) {
   for (var z = 0; z < arrCallShipper.length; z++) {
      if (arrCallShipper[z].opt == def) {
         document.writeln("<OPTION SELECTED=SELECTED VALUE='"+arrCallShipper[z].opt+"'>"+arrCallShipper[z].yesorno+"</OPTION>")
      }
      else {
         document.writeln("<OPTION VALUE='"+arrCallShipper[z].opt+"'>"+arrCallShipper[z].yesorno+"</OPTION>")
      }
   }
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ BUILD TIME OPTIONS                                                  +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function buildTimeOptions(def) {
   for (var z = 0; z < arrTimes.length; z++) {
      if (arrTimes[z].militaryTime == def) {
         document.writeln("<OPTION SELECTED=SELECTED VALUE='"+arrTimes[z].militaryTime+"'>"+arrTimes[z].civilianTime+"</OPTION>")
      }
      else {
         document.writeln("<OPTION VALUE='"+arrTimes[z].militaryTime+"'>"+arrTimes[z].civilianTime+"</OPTION>")
      }
   }
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ CHECK CUBE                                                          +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function checkCube() {
   if ((objForm.txtCuft.value.length > 0) &&
       (isInteger(objForm.txtCuft.value)) &&
       (objForm.txtCuft.value > 0)) {
      objForm.txtLength.value = ""
      objForm.txtWidth.value = ""
      objForm.txtHeight.value = ""
   }
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ CHECK DIMENSION                                                     +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function checkDimension() {
   var intCubicFeet
   if ((objForm.txtLength.value.length > 0) &&
      (isInteger(objForm.txtLength.value))  &&
      (objForm.txtLength.value > 0)         &&
      (objForm.txtWidth.value.length > 0)   &&
      (isInteger(objForm.txtWidth.value))   &&
      (objForm.txtWidth.value > 0)          &&
      (objForm.txtHeight.value.length > 0)  &&
      (isInteger(objForm.txtHeight.value))  &&
      (objForm.txtHeight.value > 0))   {
      intCubicFeet = (objForm.txtLength.value) * (objForm.txtWidth.value) * (objForm.txtHeight.value)
      objForm.txtCuft.value = intCubicFeet }
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ CHECK EMAIL REQUIRED                                                +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function checkEmailRequired(blnRequire,intSub) {
   var strNotRequired = "E-mail Address:&nbsp;"
   var strRequired = "E-mail Address*:&nbsp;"

   if (blnRequire) {
      eval('document.getElementById("txtCopyEmailLabel'+intSub+'")').innerHTML = '<FONT CLASS="pgTxtT">' + strRequired + '</FONT>'
   }
   else {
      eval('document.getElementById("txtCopyEmailLabel'+intSub+'")').innerHTML = '<FONT CLASS="pgTxtT">' + strNotRequired + '</FONT>'
   }
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ CONVERT COMMA                                                       +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function convertComma() {
   //Convert commas in text boxes to ASCII character 255 ("ÿ") to prevent problems with
   //comma-delimited fields.  Convert back to commas prior to saving information.
   var intCtr
   var objFormField
   var objRegExp = new RegExp(",","g")
   var strReplaced
   for (intCtr = 0; intCtr <= 3; intCtr++)
   {
      objFormField = new String(objForm.txtAcctName[intCtr].value)
      strReplaced = objFormField.replace(objRegExp, "ÿ")
      objForm.txtAcctName[intCtr].value = strReplaced

      if (intCtr <= 2)
      {
         objFormField = new String(objForm.txtAcctNamePlus[intCtr].value)
         strReplaced = objFormField.replace(objRegExp, "ÿ")
         objForm.txtAcctNamePlus[intCtr].value = strReplaced
      }

      objFormField = new String(objForm.txtAcctAddr[intCtr].value)
      strReplaced = objFormField.replace(objRegExp, "ÿ")
      objForm.txtAcctAddr[intCtr].value = strReplaced

      objFormField = new String(objForm.txtAcctCity[intCtr].value)
      strReplaced = objFormField.replace(objRegExp, "ÿ")
      objForm.txtAcctCity[intCtr].value = strReplaced

      objFormField = new String(objForm.txtAcctZip[intCtr].value)
      strReplaced = objFormField.replace(objRegExp, "ÿ")
      objForm.txtAcctZip[intCtr].value = strReplaced

      if (intCtr <= 2)
      {
         objFormField = new String(objForm.txtAcctPhone[intCtr].value)
         strReplaced = objFormField.replace(objRegExp, "ÿ")
         objForm.txtAcctPhone[intCtr].value = strReplaced

         objFormField = new String(objForm.txtAcctPhoneExt[intCtr].value)
         strReplaced = objFormField.replace(objRegExp, "ÿ")
         objForm.txtAcctPhoneExt[intCtr].value = strReplaced

         objFormField = new String(objForm.txtAcctEMail[intCtr].value)
         strReplaced = objFormField.replace(objRegExp, "ÿ")
         objForm.txtAcctEMail[intCtr].value = strReplaced
      }
   }

   if (!document.getElementById("txtWeight1"))
   {
      objFormField = new String(document.getElementById("txtHandled0").value)
      strReplaced = objFormField.replace(objRegExp, "ÿ")
      document.getElementById("txtHandled0").value = strReplaced

      objFormField = new String(document.getElementById("txtPackages0").value)
      strReplaced = objFormField.replace(objRegExp, "ÿ")
      document.getElementById("txtPackages0").value = strReplaced

      objFormField = new String(document.getElementById("txtWeight0").value)
      strReplaced = objFormField.replace(objRegExp, "ÿ")
      document.getElementById("txtWeight0").value = strReplaced

      objFormField = new String(document.getElementById("txtItem0").value)
      strReplaced = objFormField.replace(objRegExp, "ÿ")
      document.getElementById("txtItem0").value = strReplaced

      objFormField = new String(document.getElementById("txtSub0").value)
      strReplaced = objFormField.replace(objRegExp, "ÿ")
      document.getElementById("txtSub0").value = strReplaced

      objFormField = new String(document.getElementById("txtCube0").value)
      strReplaced = objFormField.replace(objRegExp, "ÿ")
      document.getElementById("txtCube0").value = strReplaced

      objFormField = new String(document.getElementById("txtDescription0").value)
      strReplaced = objFormField.replace(objRegExp, "ÿ")
      document.getElementById("txtDescription0").value = strReplaced
   }
   else
   {
      for (var intCtr = 0; intCtr < intCurItems; intCtr++)
      {
         objFormField = new String(eval('document.getElementById("txtHandled'+(intCtr)+'")').value)
         strReplaced = objFormField.replace(objRegExp, "ÿ")
         eval('document.getElementById("txtHandled'+(intCtr)+'")').value = strReplaced

         objFormField = new String(eval('document.getElementById("txtPackages'+(intCtr)+'")').value)
         strReplaced = objFormField.replace(objRegExp, "ÿ")
         eval('document.getElementById("txtPackages'+(intCtr)+'")').value = strReplaced

         objFormField = new String(eval('document.getElementById("txtWeight'+(intCtr)+'")').value)
         strReplaced = objFormField.replace(objRegExp, "ÿ")
         eval('document.getElementById("txtWeight'+(intCtr)+'")').value = strReplaced

         objFormField = new String(eval('document.getElementById("txtItem'+(intCtr)+'")').value)
         strReplaced = objFormField.replace(objRegExp, "ÿ")
         eval('document.getElementById("txtItem'+(intCtr)+'")').value = strReplaced

         objFormField = new String(eval('document.getElementById("txtSub'+(intCtr)+'")').value)
         strReplaced = objFormField.replace(objRegExp, "ÿ")
         eval('document.getElementById("txtSub'+(intCtr)+'")').value = strReplaced

         objFormField = new String(eval('document.getElementById("txtCube'+(intCtr)+'")').value)
         strReplaced = objFormField.replace(objRegExp, "ÿ")
         eval('document.getElementById("txtCube'+(intCtr)+'")').value = strReplaced

         objFormField = new String(eval('document.getElementById("txtDescription'+(intCtr)+'")').value)
         strReplaced = objFormField.replace(objRegExp, "ÿ")
         eval('document.getElementById("txtDescription'+(intCtr)+'")').value = strReplaced
      }
   }

   objFormField = new String(objForm.txtPronumber.value)
   strReplaced = objFormField.replace(objRegExp, "ÿ")
   objForm.txtPronumber.value = strReplaced

   if (blnShowDeclaredValue == "True")
   {
      objFormField = new String(objForm.txtDeclaredValueAmount.value)
      strReplaced = objFormField.replace(objRegExp, "ÿ")
      objForm.txtDeclaredValueAmount.value = strReplaced
   }

   objFormField = new String(objForm.txtSpecialInstructions.value)
   strReplaced = objFormField.replace(objRegExp, "ÿ")
   objForm.txtSpecialInstructions.value = strReplaced

   if (blnNSPQuoteTemplate != "True")
   {
      objFormField = new String(document.getElementById("txtBOLNumber").value)
      strReplaced = objFormField.replace(objRegExp, "ÿ")
      document.getElementById("txtBOLNumber").value = strReplaced
   }

   if (!document.getElementById("txtPONumber1"))
   {
      objFormField = new String(document.getElementById("txtPONumber0").value)
      strReplaced = objFormField.replace(objRegExp, "ÿ")
      document.getElementById("txtPONumber0").value = strReplaced
   }
   else
   {
      for (var intCtr = 0; intCtr < intCurrentRefno; intCtr++)
      {
         objFormField = new String(eval('document.getElementById("txtPONumber'+intCtr+'")').value)
         strReplaced = objFormField.replace(objRegExp, "ÿ")
         eval('document.getElementById("txtPONumber'+intCtr+'")').value = strReplaced
      }
   }

   if (!document.getElementById("txtCustRefNumber1"))
   {
      objFormField = new String(document.getElementById("txtCustRefNumber0").value)
      strReplaced = objFormField.replace(objRegExp, "ÿ")
      document.getElementById("txtCustRefNumber0").value = strReplaced
   }
   else
   {
      for (var intCtr = 0; intCtr < intCurrentRefno; intCtr++)
      {
         objFormField = new String(eval('document.getElementById("txtCustRefNumber'+intCtr+'")').value)
         strReplaced = objFormField.replace(objRegExp, "ÿ")
         eval('document.getElementById("txtCustRefNumber'+intCtr+'")').value = strReplaced
      }
   }

   objFormField = new String(objForm.txtCopyAddEmail.value)
   strReplaced = objFormField.replace(objRegExp, "ÿ")
   objForm.txtCopyAddEmail.value = strReplaced
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ EDIT ADDITIONAL SERVICES                                            +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function EditAdditionalServices() {
   // Display the quote basis section again to edit or review.
   SummarizeThisAndEditNext(6,intMaxSteps)
   return true
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ EDIT COD INFORMATION                                                +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function EditCODInformation() {
   // Display the quote basis section again to edit or review.
   SummarizeThisAndEditNext(2,intMaxSteps)
   return true
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ EDIT COMMODITY INFORMATION                                          +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function EditCommodityInformation() {
   // Display the quote basis section again to edit or review.
   SummarizeThisAndEditNext(3,intMaxSteps)
   return true
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ EDIT CUST INFO                                                      +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function EditCustInfo() {
   // Display the quote basis section again to edit or review.
   SummarizeThisAndEditNext(1,intMaxSteps)
   return true
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ EDIT OTHER OPTIONS                                                  +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function EditOtherOptions() {
   // Display the quote basis section again to edit or review.
   SummarizeThisAndEditNext(7,intMaxSteps)
   return true
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ EDIT REFERENCE NUMBERS                                              +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function EditReferenceNumbers() {
   // Display the quote basis section again to edit or review.
   SummarizeThisAndEditNext(5,intMaxSteps)
   return true
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ EDIT REQUESTER AFFILIATION                                          +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function EditRequesterInfo() {
   // Display the quote basis section again to edit or review.
   SummarizeThisAndEditNext(0,intMaxSteps)
   return true
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ EDIT REQUIRED FIELDS                                                +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function EditRequiredFields() {
   if (isWhitespace(objForm.txtAcctName[shp].value)) {
      errmsg = 'Shipper name is required'
      return warnInvalid(objForm.txtAcctName[shp],errmsg)
   }
   if (isWhitespace(objForm.txtAcctName[con].value)) {
      errmsg = 'Consignee name is required'
      return warnInvalid(objForm.txtAcctName[con],errmsg)
   }
   if ((isWhitespace(objForm.txtAcctCity[shp].value)) &&
       (isWhitespace(objForm.cboAcctState[shp].value)) &&
       (isWhitespace(objForm.txtAcctZip[shp].value)))
   {  errmsg = 'Shipper city, state and ZIP code are required'
      return warnInvalid(objForm.txtAcctCity[shp],errmsg)
   }
   if ((isWhitespace(objForm.txtAcctCity[con].value)) &&
       (isWhitespace(objForm.cboAcctState[con].value)) &&
       (isWhitespace(objForm.txtAcctZip[con].value)))
   {  errmsg = 'Consignee city, state and ZIP code are required'
      return warnInvalid(objForm.txtAcctCity[con],errmsg)
   }
   return true
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ EDIT SHIPMENT SPECIFICS                                             +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function EditShipmentSpecifics() {
   // Display the quote basis section again to edit or review.
   SummarizeThisAndEditNext(4,intMaxSteps)
   return true
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ FORMAT SUMMARY                                                      +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function FormatSummary(intCur) {
   switch(intCur) {
      case 1:
         document.getElementById("RequesterInfo").innerHTML = FormatRequesterInfo()
         break;
      case 2:
         document.getElementById("CustInfo").innerHTML = FormatCustInfo(0,"Origin") + FormatCustInfo(1,"Destination")
         break;
      case 3:
         document.getElementById("CODInformation").innerHTML = FormatCustInfo(2,"COD")
         RequireClass()
         break;
      case 4:
         document.getElementById("CommodityInformation").innerHTML = FormatCommodityInfo("CLASS")
         break;
      case 5:
         document.getElementById("ShipmentSpecifics").innerHTML = FormatShipmentSpecifics()
         break;
      case 6:
         document.getElementById("ReferenceNumbers").innerHTML = FormatReferenceNumbers()
         break;
      case 7:
         document.getElementById("AdditionalServices").innerHTML = FormatAdditionalServices(false)
         break;
      case 8:
         document.getElementById("OtherOptions").innerHTML = FormatOtherOptions('Bill of Lading',2,0)
         break;
      default:
         break;
   }
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ INIT CALL SHIPPER OPTIONS                                           +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function initCallShipperOptions()
{
   arrCallShipper[0]  = new objCallShipper(' ','Yes')
   arrCallShipper[1]  = new objCallShipper('N','No')
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ INIT TIMES LIST                                                     +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function initTimesList()
{
   arrTimes[0]  = new objTime('     ','- - : - -')
   arrTimes[1]  = new objTime('00:00','Midnight')
   arrTimes[2]  = new objTime('00:30','12:30 AM')
   arrTimes[3]  = new objTime('01:00',' 1:00 AM')
   arrTimes[4]  = new objTime('01:30',' 1:30 AM')
   arrTimes[5]  = new objTime('02:00',' 2:00 AM')
   arrTimes[6]  = new objTime('02:30',' 2:30 AM')
   arrTimes[7]  = new objTime('03:00',' 3:00 AM')
   arrTimes[8]  = new objTime('03:30',' 3:30 AM')
   arrTimes[9]  = new objTime('04:00',' 4:00 AM')
   arrTimes[10] = new objTime('04:30',' 4:30 AM')
   arrTimes[11] = new objTime('05:00',' 5:00 AM')
   arrTimes[12] = new objTime('05:30',' 5:30 AM')
   arrTimes[13] = new objTime('06:00',' 6:00 AM')
   arrTimes[14] = new objTime('06:30',' 6:30 AM')
   arrTimes[15] = new objTime('07:00',' 7:00 AM')
   arrTimes[16] = new objTime('07:30',' 7:30 AM')
   arrTimes[17] = new objTime('08:00',' 8:00 AM')
   arrTimes[18] = new objTime('08:30',' 8:30 AM')
   arrTimes[19] = new objTime('09:00',' 9:00 AM')
   arrTimes[20] = new objTime('09:30',' 9:30 AM')
   arrTimes[21] = new objTime('10:00','10:00 AM')
   arrTimes[22] = new objTime('10:30','10:30 AM')
   arrTimes[23] = new objTime('11:00','11:00 AM')
   arrTimes[24] = new objTime('11:30','11:30 AM')
   arrTimes[25] = new objTime('12:00','Noon')
   arrTimes[26] = new objTime('12:30','12:30 PM')
   arrTimes[27] = new objTime('13:00',' 1:00 PM')
   arrTimes[28] = new objTime('13:30',' 1:30 PM')
   arrTimes[29] = new objTime('14:00',' 2:00 PM')
   arrTimes[30] = new objTime('14:30',' 2:30 PM')
   arrTimes[31] = new objTime('15:00',' 3:00 PM')
   arrTimes[32] = new objTime('15:30',' 3:30 PM')
   arrTimes[33] = new objTime('16:00',' 4:00 PM')
   arrTimes[34] = new objTime('16:30',' 4:30 PM')
   arrTimes[35] = new objTime('17:00',' 5:00 PM')
   arrTimes[36] = new objTime('17:30',' 5:30 PM')
   arrTimes[37] = new objTime('18:00',' 6:00 PM')
   arrTimes[38] = new objTime('18:30',' 6:30 PM')
   arrTimes[39] = new objTime('19:00',' 7:00 PM')
   arrTimes[40] = new objTime('19:30',' 7:30 PM')
   arrTimes[41] = new objTime('20:00',' 8:00 PM')
   arrTimes[42] = new objTime('20:30',' 8:30 PM')
   arrTimes[43] = new objTime('21:00',' 9:00 PM')
   arrTimes[44] = new objTime('21:30',' 9:30 PM')
   arrTimes[45] = new objTime('22:00','10:00 PM')
   arrTimes[46] = new objTime('22:30','10:30 PM')
   arrTimes[47] = new objTime('23:00','11:00 PM')
   arrTimes[48] = new objTime('23:30','11:30 PM')
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ OBJ CALL SHIPPER                                                    +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function objCallShipper(opt, yesorno)
{
   this.opt        = opt
   this.yesorno = yesorno
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ OBJ TIME                                                            +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function objTime(militaryTime, civilianTime)
{
   this.militaryTime   = militaryTime
   this.civilianTime   = civilianTime
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ OPEN CLIENT LOCATION WINDOW                                         +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function openClientLocationWin(seq)
{  //for lack of a better word, I try to use the word "Client" to describe our customers' customer
   if (ns4)
   { var intWinSizeY = 400 }
   else
   { var intWinSizeY = 320 }

   upWinXY('xWin','/tools/shared/custlocwindow.asp?FormName=frmBOL&FormMulti=True&blnName=False&blnContact=True&FormNum='+seq+'&AcctNum=' + gstrCustAcct + '&Password=' + gstrCustPswd,550,intWinSizeY,false)
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ OPEN CUBE WIZARD                                                    +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function openCubeWizard()
{
//   if ((strQType == "FULL") || (strQType == "GEN")) {
      upWinXY('xWin','/tools/shared/cubewizard.asp?FormName='+objForm.name+'&FullForm=Y',345,340,'no')
//   }
//   else {
//      upWinXY('xWin','/tools/shared/cubewizard.asp?FormName='+objForm.name,345,340,'no')
//   }
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ OPEN LOCATION LIST WINDOW                                           +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function openLocationListWin()
{  //open custlocwindow.asp: the pop up window that displays a list of client locations to chose from
   upWinXY('xWin','/tools/shared/custlocwindow.asp?FormName=' + jsFormName +
           '&FormNum=' + intstrBlankLabelOccurence +
           '&NP=' + jsblnShowNamePlus +
           '&CN=' + jsblnShowContactName +
           '&CP=' + jsblnShowContactPhone +
           '&CF=' + jsblnShowContactFax +
           '&CE=' + jsblnShowContactEmail +
           '&FormMulti=True',550,320,false)
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ OPEN LOCATION WINDOW                                                +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function openLocationWin(seq)
{
   if (seq == 0) {
      if (objForm.chkAffShp.checked == true) {
         upWinXY('xWin','/tools/shared/locationswindow.asp?FormName=frmBOL&FormMulti=Y&FormNum=0',550,320,false) }
      else {
         openClientLocationWin(seq) }
   }
   if (seq == 1) {
      if (objForm.chkAffCon.checked == true) {
         upWinXY('xWin','/tools/shared/locationswindow.asp?FormName=frmBOL&FormMulti=Y&FormNum=1',550,320,false) }
      else {
         openClientLocationWin(seq) }
   }
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ RESYNC EMAIL ADDRESSES BETWEEN CUSTINFO AND COPY/CONFIRM            +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function resyncEmail(objUpdatedField,intSub) {
   var blnUpdateCustInfo = false
   var blnUpdateCopyConfirm = false
   var strUpdatedField = objUpdatedField.name
   var strRECopyConfirm = /Copy|Confirm/
   var strRECustInfo = /Acct/

   blnUpdateCustInfo = strRECopyConfirm.test(strUpdatedField)
   blnUpdateCopyConfirm = strRECustInfo.test(strUpdatedField)

   if (blnUpdateCustInfo) {
      if (objForm.txtAcctEMail[intSub]) {
         objForm.txtAcctEMail[intSub].value = objUpdatedField.value
      }
   }

   if (blnUpdateCopyConfirm) {
      if (eval('objForm.txtCopyEmail'+intSub)) {
         eval('objForm.txtCopyEmail'+intSub).value = objUpdatedField.value
      }
      if (eval('objForm.txtConfirmEmail'+intSub)) {
         eval('objForm.txtConfirmEmail'+intSub).value = objUpdatedField.value
      }
   }
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ SET FOCUS                                                           +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function SetFocus(intCur) {
   // This function sets the focus to the first item of the section to be edited.
   switch(intCur) {
      case 0:
         if (objForm.txtContactName) {
            objForm.txtContactName.focus()
         }
         break;
      case 1:
         if (objForm.txtAcctName[0]) {
            objForm.txtAcctName[0].focus()
         }
         else if (objForm.txtAcctName) {
            objForm.txtAcctName.focus()
         }
         break;
      case 2:
         if (objForm.txtCODAmount) {
            objForm.txtCODAmount.focus()
         }
         break;
      case 3:
         if (document.getElementById("txtHandled0")) {
            document.getElementById("txtHandled0").focus()
         }
         break;
      case 4:
         if (objForm.cboYear) {
            objForm.cboYear.focus()
         }
         else if (objForm.txtLength) {
            objForm.txtLength.focus()
         }
         else if (objForm.txtLinearFeet) {
            objForm.txtLinearFeet.focus()
         }
         else if (objForm.txtDeclaredValueAmount) {
            objForm.txtDeclaredValueAmount.focus()
         }
         else if (objForm.txtCODAmt) {
            objForm.txtCODAmt.focus()
         }
         else if (objForm.txtPronumber) {
            objForm.txtPronumber.focus()
         }
         else if (objForm.cboShipperLoad) {
            objForm.cboShipperLoad.focus()
         }
         else if (objForm.cboConsigneeUnload) {
            objForm.cboConsigneeUnload.focus()
         }
         else if (objForm.cboHazardousMaterial) {
            objForm.cboHazardousMaterial.focus()
         }
         else if (objForm.txtSpecialInstructions) {
            objForm.txtSpecialInstructions.focus()
         }
         break;
      case 5:
         if (objForm.txtBOLNumber) {
            objForm.txtBOLNumber.focus()
         }
         break;
      case 6:
		   if (document.getElementById("chkARR"))
		   {
   		   document.getElementById("chkARR").focus()
         }
         break;
      case 7:
         if (objForm.chkCopyEmail0) {
            objForm.chkCopyEmail0.focus()
         }
         else if (objForm.chkCopyEmail1) {
            objForm.chkCopyEmail1.focus()
         }
         else if (objForm.chkConfirmEmail0) {
            objForm.chkConfirmEmail0.focus()
         }
         else {
            objForm.chkConfirmEmail1.focus()
         }
         break;
      case 8:
         if (document.getElementById("cmdSubmit2")) {
            document.getElementById("cmdSubmit2").focus()
         }
         else if (document.getElementById("cmdSubmit1")) {
            document.getElementById("cmdSubmit1").focus()
         }
         break;
      default:
         break;
   }
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ SHOW UNIT HELP                                                      +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function showUnitHelp() {
  upWinXY("xWin","/units.asp",320,500,true)
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ SUBMIT FORM                                                         +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function SubmitForm(blnCreateBlank) {
   var blnValid = false
   var blnEditFound = false

   if (blnCreateBlank) {
      if (objForm.hidCreateBlank) {
         objForm.hidCreateBlank.value = "Y"
      }
   }
   for (var i=1;i<=intMaxSteps;i++) {
      if (eval('document.getElementById("Edit'+i+'")').className == 'visibleRow')
      {
         blnEditFound = true
         switch (i) {
            case 1:
               blnValid = ValidateRequesterInfo(i,blnCreateBlank)
               break;
            case 2:
               blnValid = ValidateCustInfo(i)
               break;
            case 3:
               blnValid = ValidateCODInformation(i)
               break;
            case 4:
               blnValid = ValidateCommodityInformation(i)
               break;
            case 5:
               blnValid = ValidateShipmentSpecifics(i)
               break;
            case 6:
               blnValid = ValidateReferenceNumbers(i)
               break;
            case 7:
               blnValid = ValidateAdditionalServices(i)
               break;
            case 8:
               blnValid = ValidateOtherOptions(i)
               break;
            default:
               blnValid = true
               break;
         }
      }
      if (blnValid)
      {
         break
      }
   }

   if ((blnValid) || (!blnEditFound))
   {
      objForm.FormAction.value = "B";
      objForm.action = "bol.asp";

      objForm.submit();
      DisplayWait("Your bill of lading request is processing.\nPlease stand by.");
   }
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ VALIDATE ADDITIONAL SERVICES                                        +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function ValidateAdditionalServices(StepNum) {
   // Validate The Additional Service Options
   if (!ValidAdditionalServiceOptions(objForm))
   {
   	return false
   }

   SummarizeThisAndEditNext(StepNum,intMaxSteps)
   return true
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ VALIDATE COD INFORMATION                                            +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function ValidateCODInformation(StepNum) {
   //Edit Currency Amounts
   if (!ValidCurrencyAmount())
   {
      return false
   }

   if ((parseInt(objForm.txtCODAmount.value,10) > 0) && (!ValidPartyInfo(2))) {
      return false
   }

   if ((objForm.txtCODAmount.value == 0) &&
      ((!isWhitespace(objForm.txtAcctName[cod].value)) || (!isWhitespace(objForm.txtAcctAddr[cod].value)) ||
       (!isWhitespace(objForm.txtAcctCity[cod].value)) || (!isWhitespace(objForm.txtAcctZip[cod].value))))
   {
      return warnInvalid(objForm.txtCODAmount,"COD Amount required with COD Name, Address, City, or Zip.")
   }

   SummarizeThisAndEditNext(StepNum,intMaxSteps)
   return true
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ VALIDATE COMMODITY INFORMATION                                      +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function ValidateCommodityInformation(StepNum) {
   if (!ValidCommodities())
   {
      return false
   }

   SummarizeThisAndEditNext(StepNum,intMaxSteps)
   return true
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ VALIDATE CUST INFO                                                  +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function ValidateCustInfo(StepNum) {
   // Validate The Customer Information.
   if (!ValidPartyInfo(0)) { return false }
   if (!ValidPartyInfo(1)) { return false }

   if (document.getElementById("Summary8").className == 'visibleRow') {
      SummarizeThisAndEditNext(8,intMaxSteps)
   }
   SummarizeThisAndEditNext(StepNum,intMaxSteps)
   return true
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ VALIDATE OTHER OPTIONS                                              +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function ValidateOtherOptions(StepNum) {
   // Validate Send Copy To Email Address
   if (objForm.txtCopyAddEmail) {
      if ((!isWhitespace(objForm.txtCopyAddEmail.value)) && (!ValidEMail(objForm.txtCopyAddEmail.value))) {
         return warnInvalid(objForm.txtCopyAddEmail,'Please enter a valid "Send Copy To" E-mail Address.')
      }
   }

   // Validate Send Confirmation To Email Address
   if (objForm.txtConfirmAddEmail) {
      if ((!isWhitespace(objForm.txtConfirmAddEmail.value)) && (!ValidEMail(objForm.txtConfirmAddEmail.value))) {
         return warnInvalid(objForm.txtConfirmAddEmail,'Please enter a valid "Send Confirmation To" E-mail Address.')
      }
   }

   // See if # of Labels field exists
   if (objForm.txtSLMaxNum) {
      // Valid Ship Lab Number is required if Create Shipping Labels checked
      if (!(objForm.txtSLMaxNum.value == '') && (!ValidSLNum(objForm.txtSLMaxNum.value))) {
         return warnInvalid(objForm.txtSLMaxNum,"Please enter the number of labels you want to create.")
      }

      // See if start Postions field exists
      if (objForm.txtSLStartNum) {
         // Valid ShipLab Start Number is required if Create Shipping Labels checked
         if (!(objForm.txtSLMaxNum.value == '') && (!ValidSLStartNum(objForm.txtSLStartNum.value))) {
            return warnInvalid(objForm.txtSLStartNum,"Please enter a number between 1 and 6.")
         }

         // Valid ShipLab Start and Max Numbers combination is required if Create Shipping Labels checked
         if (!(objForm.txtSLMaxNum.value == '') && (!ValidSLNums(objForm.txtSLMaxNum.value, objForm.txtSLStartNum.value))) {
            return warnInvalid(objForm.txtSLStartNum,"The selected combination does not fit on one page. Please start with label 1 if printing more than one page.")
         }
      }
   }

   // Do this last so we don't have to return to the validation for this section after user is prompted to enter email address (if needed)
   // Shipper email required if Send Copy or Confirmation to shipper email checked
   if (objForm.chkCopyEmail0) {
      if ((objForm.chkCopyEmail0.checked == true) &&
         (isWhitespace(objForm.txtAcctEMail[0].value)))
      { return warnInvalid(objForm.txtAcctEMail[0],"Valid Origin E-mail is required to Send Copy.") }
   }
   if (objForm.chkCopyEmail1) {
      if ((objForm.chkCopyEmail1.checked == true) &&
         (isWhitespace(objForm.txtAcctEMail[1].value)))
      { return warnInvalid(objForm.txtAcctEMail[1],"Valid Destination E-mail is required to Send Copy.") }
   }

   if (objForm.chkConfirmEmail0) {
      if ((objForm.chkConfirmEmail0.checked == true) &&
         (isWhitespace(objForm.txtAcctEMail[0].value)))
      { return warnInvalid(objForm.txtAcctEMail[0],"Valid Origin E-mail is required to Send Confirmation.") }
   }
   if (objForm.chkConfirmEmail1) {
      if ((objForm.chkConfirmEmail1.checked == true) &&
         (isWhitespace(objForm.txtAcctEMail[1].value)))
      { return warnInvalid(objForm.txtAcctEMail[1],"Valid Origin E-mail is required to Send Confirmation.") }
   }

   if (document.getElementById("Summary2").className == 'visibleRow') {
      SummarizeThisAndEditNext(2,intMaxSteps)
   }
   SummarizeThisAndEditNext(StepNum,intMaxSteps)
   return true
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ VALIDATE REFERENCE NUMBERS                                          +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function ValidateReferenceNumbers(StepNum) {
   // Edit Reference Numbers
   if (!ValidRefnos()) {
      return false
   }

   SummarizeThisAndEditNext(StepNum,intMaxSteps)
   return true
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ VALIDATE REQUESTER AFFILIATION                                      +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function ValidateRequesterInfo(StepNum,blnCreateBlank) {
   if (!ValidRequesterAffiliation(blnCreateBlank)) { return false }
   if (!ValidRequesterContactInfo()) { return false }

   SummarizeThisAndEditNext(StepNum,intMaxSteps)
   return true
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ VALIDATE SHIPMENT SPECIFICS                                         +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function ValidateShipmentSpecifics(StepNum) {
   //Edit Ship Date
   if (!ValidShipDate()) {
      return false
   }

/*	 Removed the pronumber from Pickup Request per Michael 03/24/2003 UNSANDL.
   //Edit Pronumber
   if (!ValidPronumber()) {
      return false
   }
*/

   //Edit Special Instructions
   if (objForm.txtInstructions.value.length > 370) {
      return warnInvalid(objForm.txtInstructions,"Special Instructions limited to 10 lines.")
   }

   SummarizeThisAndEditNext(StepNum,intMaxSteps)
   return true
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ VALID COMMODITIES                                                   +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function ValidCommodities() {
   //Edit The Commodity Information
   intTotalWeight = 0;
   if (!document.getElementById("txtWeight1")) {
      if (!ValidCommodityInfo(0,
         document.getElementById("txtHandled0"),
         document.getElementById("cboHandledType0"),
         document.getElementById("txtPackages0"),
         document.getElementById("cboPackagesType0"),
         document.getElementById("txtWeight0"),
         document.getElementById("txtItem0"),
         document.getElementById("txtSub0"),
         document.getElementById("cboClass0"),
         document.getElementById("chkHazmat0"),
         document.getElementById("txtUNNumber0"),
         document.getElementById("txtHazMatPhoneNum0"),
         document.getElementById("txtHazMatPhoneExt0"),
         document.getElementById("txtDescription0"),
         document.getElementById("txtCube0")))
      { return false }
   }
   else {
      for (var i = 0; i < intCurItems; i++) {
         if (!ValidCommodityInfo(i,
            eval('document.getElementById("txtHandled'+i+'")'),
            eval('document.getElementById("cboHandledType'+i+'")'),
            eval('document.getElementById("txtPackages'+i+'")'),
            eval('document.getElementById("cboPackagesType'+i+'")'),
            eval('document.getElementById("txtWeight'+i+'")'),
            eval('document.getElementById("txtItem'+i+'")'),
            eval('document.getElementById("txtSub'+i+'")'),
            eval('document.getElementById("cboClass'+i+'")'),
            eval('document.getElementById("chkHazmat'+i+'")'),
            eval('document.getElementById("txtUNNumber'+i+'")'),
            eval('document.getElementById("txtHazMatPhoneNum'+i+'")'),
            eval('document.getElementById("txtHazMatPhoneExt'+i+'")'),
            eval('document.getElementById("txtDescription'+i+'")'),
            eval('document.getElementById("txtCube'+i+'")')))
         { return false }
      }
   }
   return true
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ VALID COMMODITY INFORMATION                                         +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function ValidCommodityInfo(i,txtHandled,cboHandledType,txtPackages,cboPackagesType,txtWeight,txtItem,txtSub,cboClass,chkHazmat,txtUNNumber,txtHazMatPhoneNum,txtHazMatPhoneExt,txtDescription,txtCube) {

   if ((isWhitespace(txtHandled.value)) &&
       (cboHandledType.selectedIndex < 1) &&
       (isWhitespace(txtPackages.value)) &&
       (cboPackagesType.selectedIndex < 1) &&
       (isWhitespace(txtWeight.value)) &&
       (isWhitespace(txtItem.value)) &&
       (isWhitespace(txtSub.value)) &&
       (cboClass.selectedIndex < 1) &&
       (!chkHazmat.checked) &&
       (isWhitespace(txtDescription.value)) &&
       (isWhitespace(txtCube.value)))
   {
      return true
   }

   txtUNNumber.value = txtUNNumber.value.toUpperCase() ;
/*
   //After the first commodity, it is ok when all the fields are empty for the other commodities.  (For Netscape)
   if ((i > 0) &&
      ((isWhitespace(txtItem.value))&&(isWhitespace(txtSub.value))) &&
      ((cboClass.selectedIndex < 1)&&(isWhitespace(txtDescription.value))))
   {
      return true
   }
*/

   //Validate Handled Units
   if ((!isInteger(txtHandled.value))&&(!isWhitespace(txtHandled.value)))
   {
      errmsg = "Valid # of Handling Units in whole numbers is required."
      return warnInvalid(txtHandled,errmsg)
   }

   //Validate Package Units
   if ((!isWhitespace(txtPackages.value))&&(!isInteger(txtPackages.value)))
   {
      errmsg = "Valid # of Packages in whole numbers is required."
      return warnInvalid(txtPackages,errmsg)
   }

   //Validate Weight
   if (((!isWhitespace(txtWeight.value))&&(!isInteger(txtWeight.value)))||(txtWeight.value == "0"))
   {
      errmsg = "Valid Weight in whole numbers is required."
      return warnInvalid(txtWeight,errmsg)
   }

   // for TruckPack boxes
   if (isInteger(txtWeight.value))
   {
      intTotalWeight = intTotalWeight + parseInt(txtWeight.value,10)
   }

   if ((isWhitespace(txtWeight.value))&&
      ((!isWhitespace(txtPackages.value))||(!isWhitespace(txtHandled.value))))
   {
      errmsg = "Valid Weight in whole numbers is required."
      return warnInvalid(txtWeight,errmsg)
   }

   //NMFC item must be 6 numbers (if entered)
   if ((!isWhitespace(txtItem.value))&&
      ((txtItem.value.length < 6)||(!isInteger(txtItem.value))))
   {
      return warnInvalid(txtItem,"NMFC item must be 6 digits.")
   }

   //NMFC sub must be 2 numbers (if entered)
   if ((!isWhitespace(txtSub.value))&&
      ((txtSub.value.length < 2)||(!isInteger(txtSub.value))))
   {
      return warnInvalid(txtSub,"NMFC sub must be 2 digits.")
   }

   //Validate Cube
   if ((!isWhitespace(txtCube.value))&&(!isInteger(txtCube.value)))
   {
      errmsg = "Valid Cube in whole numbers is required."
      return warnInvalid(txtCube,errmsg)
   }

   //Haz Mat UN Number must start with UN or NA followed by 4 numbers (if entered)
   if (!isWhitespace(txtUNNumber.value))
   {  if (((txtUNNumber.value.substr(0,2) != 'UN') && (txtUNNumber.value.substr(0,2) != 'NA')) || (!isInteger(txtUNNumber.value.substr(2,4))))
      { return warnInvalid(txtUNNumber,"UN/NA number must begin with 'UN' or 'NA' followed by 4 digits.") }
   }

   //Haz Mat Emergency Contact Number
   if (!isWhitespace(txtHazMatPhoneNum.value))
   {  if (!checkUSPhone(txtHazMatPhoneNum,"Hazardous Materials Emergency Contact Phone Number","true"))
      { return false ;}
   }

   if ((isWhitespace(txtHazMatPhoneNum.value)) && (!isWhitespace(txtHazMatPhoneExt.value)))
   {  return warnInvalid(txtHazMatPhoneNum, "Phone number required with extension.") ;  }

   if ((!isWhitespace(txtHazMatPhoneExt.value)) &&  (!isInteger(txtHazMatPhoneExt.value)))
   { return warnInvalid(txtHazMatPhoneExt, "Please enter a valid phone extension.") ;  }

   return true
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ VALID CURRENCY AMOUNT                                               +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function ValidCurrencyAmount() {
   var blnInvalidAmount = false
   var intChar = 0
   var intLength = 0
   var objChar
   var strChar = ""

   objChar = new String(objForm.txtCODAmount.value)
   intLength = objChar.length

   for (var intChar = 0; intChar < intLength; intChar++) {
      strChar = objChar.substr(intChar,1)
      if ((!isInteger(strChar)) && (strChar != ".")) {
         blnInvalidAmount = true }
      if ((strChar == ".") && (intChar != intLength - 3)) {
         errmsg = "COD Amount: Up to 9 digits or 9 digits plus decimal plus 2 digits"
         return warnInvalid(objForm.txtCODAmount,errmsg) }
   }

   if (blnInvalidAmount == true) {
      errmsg = "COD Amount can only include numbers and a decimal point"
      return warnInvalid(objForm.txtCODAmount,errmsg)
   }
   if ((objChar.substr((intLength - 3),1) != ".") && (intLength > 9)) {
      errmsg = "COD Amount: Up to 9 digits or 9 digits plus decimal plus 2 digits"
      return warnInvalid(objForm.txtCODAmount,errmsg)
   }
   return true
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ VALID DECLARED UNIT                                                 +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function ValidDeclaredUnit() {
   //Declared Unit must be entered if Declared Value is not blank.
   if (blnShowDeclaredValue == "True") {
      if ((objForm.txtDeclaredValueAmount.value > 0) &&
          (objForm.cboDeclaredValuePer.selectedIndex < 1)) {
         errmsg = "Unit required with Declared Value."
         return warnInvalid(objForm.cboDeclaredValuePer,errmsg) }
   }
   return true
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ VALID EMAIL ADDRESSES                                               +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function ValidEMailAddresses() {
   //Requester Contact E-mail address must be valid if entered
   if ((!isWhitespace(objForm.txtContactEmail.value)) &&
       (!ValidEMail(objForm.txtContactEmail.value))) {
      errmsg = "Invalid Requester Contact E-mail Address."
      return warnInvalid(objForm.txtContactEmail,errmsg) }

   //Shipper E-mail address must be valid if entered
   if ((!isWhitespace(objForm.txtAcctEMail[0].value)) &&
       (!ValidEMail(objForm.txtAcctEMail[0].value))) {
      errmsg = "Invalid Shipper E-mail Address."
      return warnInvalid(objForm.txtAcctEMail[0],errmsg) }

   //Consignee E-mail address must be valid if entered
   if ((!isWhitespace(objForm.txtAcctEMail[1].value)) &&
       (!ValidEMail(objForm.txtAcctEMail[1].value))) {
      errmsg = "Invalid Consignee E-mail Address."
      return warnInvalid(objForm.txtAcctEMail[1],errmsg) }

   //Third party E-mail address must be valid if entered
   if ((!isWhitespace(objForm.txtAcctEMail[2].value)) &&
       (!ValidEMail(objForm.txtAcctEMail[2].value))) {
      errmsg = "Invalid Third Party E-mail Address."
      return warnInvalid(objForm.txtAcctEMail[2],errmsg) }

   //Additional Copy E-mail address must be valid if entered
   if ((!isWhitespace(objForm.txtCopyAddEmail.value)) &&
       (!ValidEMail(objForm.txtCopyAddEmail.value))) {
      errmsg = "Invalid Additional Copy E-mail Address."
      return warnInvalid(objForm.txtCopyAddEmail,errmsg) }

   return true
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ VALID PARTY INFORMATION                                             +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function ValidPartyInfo(i) {
   if ((isWhitespace(objForm.txtAcctCity[i].value))  &&
       (objForm.cboAcctState[i].selectedIndex < 1) &&
       (isWhitespace(objForm.txtAcctZip[i].value))   &&
       (i < 2))
   { return true }

   var txtParty = " "
   if (i==0) {
      txtParty = "Origin" }
   if (i==1) {
      txtParty = "Destination" }
   if (i==2) {
      txtParty = "COD Remit-To" }

   if (i==2) {
      if (isWhitespace(objForm.txtAcctName[cod].value)) {
         errmsg = txtParty + ' Name is required with COD Amount.'
         return warnInvalid(objForm.txtAcctName[cod],errmsg)
      }
      if (isWhitespace(objForm.txtAcctAddr[cod].value)) {
         errmsg = txtParty + ' Address is required with COD Amount.'
         return warnInvalid(objForm.txtAcctAddr[cod],errmsg)
      }
      if ((isWhitespace(objForm.txtAcctCity[i].value)) && (isWhitespace(objForm.txtAcctZip[i].value))) {
         errmsg = txtParty + ' City and State OR Zip/Postal Code is required with COD Amount.'
         return warnInvalid(objForm.txtAcctCity[cod],errmsg)
      }
   }

   // Validate zip codes // added 03.05.01 ulwilli
   if (objForm.txtAcctZip[i]) {
      if (!isEmpty(objForm.txtAcctZip[i].value)) {
         if ((eval('objForm.radAcctCountry'+i+'[0]').checked) && (!ValidUSZip(objForm.txtAcctZip[i])))
         {  return warnInvalid(objForm.txtAcctZip[i],"An invalid United States zip code was entered for the "+txtParty+"."); }

         if ((eval('objForm.radAcctCountry'+i+'[1]').checked) && (!ValidCAZip(objForm.txtAcctZip[i])))
         {  return warnInvalid(objForm.txtAcctZip[i],"An invalid Canadian postal code was entered for the "+txtParty+"."); }

         if ((eval('objForm.radAcctCountry'+i+'[2]').checked) && (!ValidMXZip(objForm.txtAcctZip[i])))
         {   return warnInvalid(objForm.txtAcctZip[i],"An invalid Mexican postal code was entered for the "+txtParty+"."); }
      }
   }

   // Validate customer city(s), state(s) & zip(s)
   if (objForm.txtAcctCity[i] && objForm.cboAcctState[i]) {
      if ((!isEmpty(objForm.txtAcctCity[i].value) && objForm.cboAcctState[i].selectedIndex == 0) ||
           (isEmpty(objForm.txtAcctCity[i].value) && objForm.cboAcctState[i].selectedIndex > 0) ||
           (isEmpty(objForm.txtAcctCity[i].value) && objForm.cboAcctState[i].selectedIndex == 0 && isEmpty(objForm.txtAcctZip[i].value)))
      {
         return warnInvalid(objForm.txtAcctZip[i],"A city and state OR zip/postal code is required for the "+txtParty+".")
      }
   }

   // Validate the Customer Phone Number(s)
   if (objForm.txtAcctPhone[i]) {
      if (!isWhitespace(objForm.txtAcctPhone[i].value))
      { if (!checkUSPhone(objForm.txtAcctPhone[i],txtParty,"true"))
         { return false }
      }
      if ((isWhitespace(objForm.txtAcctPhone[i].value)) &&
          (!isWhitespace(objForm.txtAcctPhoneExt[i].value)))
      { errmsg = txtParty + " Phone number required with extension."
         return warnInvalid(objForm.txtAcctPhone[i],errmsg)
      }
      if ((!isWhitespace(objForm.txtAcctPhoneExt[i].value)) &&
          (!isInteger(objForm.txtAcctPhoneExt[i].value)))
      { errmsg = "Please enter a valid phone extension for the " + txtParty + "."
         return warnInvalid(objForm.txtAcctPhoneExt[i],errmsg)
      }
   }

   //Change Numbers To The (999)999-9999 Format Even If They Are Not Required
   if (objForm.txtAcctPhone[i]) {
      if ((objForm.txtAcctPhone[i].value.length > 0) && (!checkUSPhone (objForm.txtAcctPhone[i], txtParty + " Phone", "false")))
      {  return false }
   }
   if (objForm.txtAcctFax[i]) {
      if ((objForm.txtAcctFax[i].value.length > 0)  && (!checkUSPhone (objForm.txtAcctFax[i], txtParty + " Fax", "false")))
      {  return false }
   }

   // Validate Customer E-mail Addresses
   if (objForm.txtAcctEMail[i]) {
      if ((!isWhitespace(objForm.txtAcctEMail[i].value)) &&
          (!ValidEMail(objForm.txtAcctEMail[i].value))) {
         errmsg = "Invalid " + txtParty + " E-mail address."
         return warnInvalid(objForm.txtAcctEMail[i],errmsg)
      }
   }

   return true
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ VALID CUSTOMER INFORMATION                                          +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//function ValidPartyInfo2(i) {
//   var txtParty = " "
//   if (i==0) {
//      txtParty = "Origin"
//   }
//   if (i==1) {
//      txtParty = "Destination"
//   }
//
//   // Validate customer city(s), state(s) & zip(s)
//   if ((!isEmpty(objForm.txtAcctCity[i].value) && objForm.cboAcctState[i].selectedIndex == 0) ||
//        (isEmpty(objForm.txtAcctCity[i].value) && objForm.cboAcctState[i].selectedIndex > 0) ||
//        (isEmpty(objForm.txtAcctCity[i].value) && objForm.cboAcctState[i].selectedIndex == 0 && isEmpty(objForm.txtAcctZip[i].value)))
//   {
//      return warnInvalid(objForm.txtAcctZip[i],"A city and state OR zip/postal code is required for the "+txtParty+".")
//   }
//
//   // Validate zip codes
//   if (!isEmpty(objForm.txtAcctZip[i].value))
//   {
//
//      if ((eval('objForm.radAcctCountry'+i+'[0]').checked) && (!ValidUSZip(objForm.txtAcctZip[i])))
//      {  return warnInvalid(objForm.txtAcctZip[i],"An invalid United States zip code was entered for the "+txtParty+"."); }
//
//      if ((eval('objForm.radAcctCountry'+i+'[1]').checked) && (!ValidCAZip(objForm.txtAcctZip[i])))
//      {  return warnInvalid(objForm.txtAcctZip[i],"An invalid Canadian postal code was entered for the "+txtParty+"."); }
//
//      if ((eval('objForm.radAcctCountry'+i+'[2]').checked) && (!ValidMXZip(objForm.txtAcctZip[i])))
//      {   return warnInvalid(objForm.txtAcctZip[i],"An invalid Mexican postal code was entered for the "+txtParty+"."); }
//   }
//
/*
   ----------------------------------------------------------------------
   RemoteCityCoding goes here.................
   ----------------------------------------------------------------------
   SetValuesForRemoteCityCoding()
   jsValidateCityCodeRS('nspquotes.asp',true,objForm.txtAcctCity[0],objForm.cboAcctState[0],objForm.txtAcctZip[0],objForm.radAcctCountry0,true,objForm.txtAcctCity[1],objForm.cboAcctState[1],objForm.txtAcctZip[1],objForm.radAcctCountry1,false,'','','','',true);
   return false
*/
//   return true
//}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ VALID PHONE NUMBERS                                                 +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function ValidPhoneNumbers() {
   //Shipper
   if (!isWhitespace(objForm.txtAcctPhone[shp].value))
   { if (!checkUSPhone(objForm.txtAcctPhone[shp],"Shipper Phone","true"))
      { return false }
   }
   if ((isWhitespace(objForm.txtAcctPhone[shp].value)) &&
       (!isWhitespace(objForm.txtAcctPhoneExt[shp].value)))
   { errmsg = "Phone number required with extension."
      return warnInvalid(objForm.txtAcctPhone[shp],errmsg)
   }
   if ((!isWhitespace(objForm.txtAcctPhoneExt[shp].value)) &&
       (!isInteger(objForm.txtAcctPhoneExt[shp].value)))
   { errmsg = "Please enter a valid phone extension."
      return warnInvalid(objForm.txtAcctPhoneExt[shp],errmsg)
   }
   //   if (!isWhitespace(objForm.txtAcctFax[shp].value))
   //   { if (!checkUSPhone(objForm.txtAcctFax[shp],"Shipper Fax","true"))
   //      { return false }
   //   }

   //Consignee
   if (!isWhitespace(objForm.txtAcctPhone[con].value))
   { if (!checkUSPhone(objForm.txtAcctPhone[con],"Consignee Phone","true"))
      { return false }
   }
   if ((isWhitespace(objForm.txtAcctPhone[con].value)) &&
       (!isWhitespace(objForm.txtAcctPhoneExt[con].value)))
   { errmsg = "Phone number required with extension."
      return warnInvalid(objForm.txtAcctPhone[con],errmsg)
   }
   if ((!isWhitespace(objForm.txtAcctPhoneExt[con].value)) &&
       (!isInteger(objForm.txtAcctPhoneExt[con].value)))
   { errmsg = "Please enter a valid phone extension."
      return warnInvalid(objForm.txtAcctPhoneExt[con],errmsg)
   }
   //   if (!isWhitespace(objForm.txtAcctFax[con].value))
   //   { if (!checkUSPhone(objForm.txtAcctFax[con],"Consignee Fax","true"))
   //      { return false }
   //   }

   //Requester Contact
   if (!isWhitespace(objForm.txtContactPhone.value))
   { if (!checkUSPhone(objForm.txtContactPhone,"Requester Contact","true"))
      { return false }
   }
   if ((isWhitespace(objForm.txtContactPhone.value)) &&
       (!isWhitespace(objForm.txtContactPhoneExt.value)))
   { errmsg = "Phone number required with extension."
      return warnInvalid(objForm.txtContactPhone,errmsg)
   }
   if ((!isWhitespace(objForm.txtContactPhoneExt.value)) &&
       (!isInteger(objForm.txtContactPhoneExt.value)))
   { errmsg = "Please enter a valid phone extension."
      return warnInvalid(objForm.txtContactPhoneExt,errmsg)
   }
    if (!isWhitespace(objForm.txtContactFax.value))
   { if (!checkUSPhone(objForm.txtContactFax,"Requester Contact","true"))
      { return false }
   }
   return true
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ VALID PRONUMBER                                                     +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function ValidPronumber()
{ if ((!isWhitespace(objForm.txtPronumber.value)) &&
       (!ValidABFPro(objForm.txtPronumber)))
   { errmsg = 'Valid ABF Pronumber is 9 digits (plus 1 or 2 letters).'
      return warnInvalid(objForm.txtPronumber,errmsg)
   }
   return true
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ VALID REFERENCE NUMBERS                                             +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function ValidRefnos()
{
   var intCtr = 0;
   var intDupCtr = 0;
   var txtRefno;
   var CustRefNum;
   var intTotHandled = 0;
   var intTotPackages = 0;
   var intTotWeight = 0;
   var intTotPOPieces = 0;
   var intTotPOWeight = 0;

   CustRefNum = document.getElementById("txtCustRefNumber0").value
   txtRefno = document.getElementById("txtBOLNumber").value
   txtRefno = txtRefno.toUpperCase()
   document.getElementById("txtBOLNumber").value = txtRefno

   if ((txtRefno == '?')       ||
       (txtRefno == 'UNK')     ||
       (txtRefno == 'UNKNOWN') ||
       (txtRefno == 'N/A')     ||
       (txtRefno == 'NA')      ||
       (txtRefno == 'N/S')     ||
       (txtRefno == 'NS')      ||
       (txtRefno == 'X')       ||
       (txtRefno == 'XX')      ||
       (txtRefno == 'XXX')     ||
       (txtRefno == 'XXXX')    ||
       (txtRefno == 'NONE'))
   {
      return warnInvalid(document.getElementById("txtBOLNumber"),"Invalid BOL Number; leave blank if not available.")
   }

   if ((!document.getElementById("txtWeight1")) &&
      (!document.getElementById("txtHandled1")) &&
      (!document.getElementById("txtHandled1")))
   {
      if (isInteger(document.getElementById("txtHandled0").value))
      {
         intTotHandled = intTotHandled + parseInt(document.getElementById("txtHandled0").value)
      }
      if (isInteger(document.getElementById("txtPackages0").value))
      {
         intTotPackages = intTotPackages + parseInt(document.getElementById("txtPackages0").value)
      }
      if (isInteger(document.getElementById("txtWeight0").value))
      {
         intTotWeight = intTotWeight + parseInt(document.getElementById("txtWeight0").value)
      }
   }
   else
   {
      for (var i = 0; i < intCurItems; i++)
      {
         if (isInteger(eval('document.getElementById("txtWeight'+i+'")').value))
         {
            intTotHandled = intTotHandled + parseInt(eval('document.getElementById("txtHandled'+i+'")').value)
         }
         if (isInteger(eval('document.getElementById("txtPackages'+i+'")').value))
         {
            intTotPackages = intTotPackages + parseInt(eval('document.getElementById("txtPackages'+i+'")').value)
         }
         if (isInteger(eval('document.getElementById("txtWeight'+i+'")').value))
         {
            intTotWeight = intTotWeight + parseInt(eval('document.getElementById("txtWeight'+i+'")').value)
         }
      }
   }

   if (!document.getElementById("txtPONumber1"))
   {
      txtRefno = document.getElementById("txtPONumber0").value
      txtRefno = txtRefno.toUpperCase()
      document.getElementById("txtPONumber0").value = txtRefno
      if ((txtRefno == '?')       ||
          (txtRefno == 'UNK')     ||
          (txtRefno == 'UNKNOWN') ||
          (txtRefno == 'N/A')     ||
          (txtRefno == 'NA')      ||
          (txtRefno == 'N/S')     ||
          (txtRefno == 'NS')      ||
          (txtRefno == 'X')       ||
          (txtRefno == 'XX')      ||
          (txtRefno == 'XXX')     ||
          (txtRefno == 'XXXX')    ||
          (txtRefno == 'NONE'))
      {
         return warnInvalid(document.getElementById("txtPONumber0"),"Invalid PO Number; leave blank if not available.")
      }
      if ((isWhitespace(document.getElementById("txtPONumber0").value))&&
       ( (!isWhitespace(document.getElementById("txtPOPieces0").value))||
         (!isWhitespace(document.getElementById("txtPOWeight0").value))||
         (!isWhitespace(document.getElementById("txtPODept0").value))))
      {
         return warnInvalid(document.getElementById("txtPONumber0"),"PO Number required with Pcs, Wt, or Dept.")
      }
      if ((!isWhitespace(document.getElementById("txtPOPieces0").value))&&(!isInteger(document.getElementById("txtPOPieces0").value)))
      {
         return warnInvalid(document.getElementById("txtPOPieces0"),"PO Pcs must be numeric.")
      }
      if ((!isWhitespace(document.getElementById("txtPOWeight0").value))&&(!isInteger(document.getElementById("txtPOWeight0").value)))
      {
         return warnInvalid(document.getElementById("txtPOWeight0"),"PO Wt must be numeric.")
      }
      if ((intTotHandled != 0)&&(intTotPackages != 0)&&(document.getElementById("txtPOPieces0").value != 0)&&
          (parseInt(document.getElementById("txtPOPieces0").value) != intTotHandled)&&
          (parseInt(document.getElementById("txtPOPieces0").value) != intTotPackages))
      {
         return warnInvalid(document.getElementById("txtPOPieces0")," PO Pcs does not equal total Handling Units or total Packages.")
      }
      if ((intTotWeight != 0)&&(document.getElementById("txtPOWeight0").value != 0)&&
          (parseInt(document.getElementById("txtPOWeight0").value) != intTotWeight))
      {
         return warnInvalid(document.getElementById("txtPOWeight0"),"PO Wt does not equal total Commodities Weight.")
      }
   }
   else
   {
      for (var intCtr = 0; intCtr < intCurrentRefno; intCtr++)
      {
         txtRefno = eval('document.getElementById("txtPONumber'+intCtr+'")').value
         txtRefno = txtRefno.toUpperCase()
         eval('document.getElementById("txtPONumber'+intCtr+'")').value = txtRefno
         if ((txtRefno == '?')       ||
             (txtRefno == 'UNK')     ||
             (txtRefno == 'UNKNOWN') ||
             (txtRefno == 'N/A')     ||
             (txtRefno == 'NA')      ||
             (txtRefno == 'N/S')     ||
             (txtRefno == 'NS')      ||
             (txtRefno == 'X')       ||
             (txtRefno == 'XX')      ||
             (txtRefno == 'XXX')     ||
             (txtRefno == 'XXXX')    ||
             (txtRefno == 'NONE'))
         {
            return warnInvalid(eval('document.getElementById("txtPONumber'+intCtr+'")'),"Invalid PO Number; leave blank if not available.")
         }
         else
         {
            for (var intDupCtr = intCtr + 1; intDupCtr < intCurrentRefno; intDupCtr++)
            {
               txtRefno = eval('document.getElementById("txtPONumber'+intDupCtr+'")').value
               txtRefno = txtRefno.toUpperCase()
               eval('document.getElementById("txtPONumber'+intDupCtr+'")').value = txtRefno
               if ((eval('document.getElementById("txtPONumber'+intCtr+'")').value == eval('document.getElementById("txtPONumber'+intDupCtr+'")').value) &&
                   (eval('document.getElementById("txtPONumber'+intCtr+'")').value > " "))
               {
                  return warnInvalid(eval('document.getElementById("txtPONumber'+intCtr+'")'),"Duplicate PO Number.")
               }
            }
         }
         if ((isWhitespace(eval('document.getElementById("txtPONumber'+intCtr+'")').value))&&
          ( (!isWhitespace(eval('document.getElementById("txtPOPieces'+intCtr+'")').value))||
            (!isWhitespace(eval('document.getElementById("txtPOWeight'+intCtr+'")').value))||
            (!isWhitespace(eval('document.getElementById("txtPODept'+intCtr+'")').value))))
         {
            return warnInvalid(eval('document.getElementById("txtPONumber'+intCtr+'")'),"PO Number required with Pcs, Wt, or Dept.")
         }
         if ((!isWhitespace(eval('document.getElementById("txtPOPieces'+intCtr+'")').value))&&(!isInteger(eval('document.getElementById("txtPOPieces'+intCtr+'")').value)))
         {
            return warnInvalid(eval('document.getElementById("txtPOPieces'+intCtr+'")'),"PO Pcs must be numeric.")
         }
         if ((!isWhitespace(eval('document.getElementById("txtPOWeight'+intCtr+'")').value))&&(!isInteger(eval('document.getElementById("txtPOWeight'+intCtr+'")').value)))
         {
            return warnInvalid(eval('document.getElementById("txtPOWeight'+intCtr+'")'),"PO Wt must be numeric.")
         }
         if (isInteger(eval('document.getElementById("txtPOPieces'+intCtr+'")').value))
         {
            intTotPOPieces = intTotPOPieces + parseInt(eval('document.getElementById("txtPOPieces'+intCtr+'")').value)
         }
         if (isInteger(eval('document.getElementById("txtPOWeight'+intCtr+'")').value))
         {
            intTotPOWeight = intTotPOWeight + parseInt(eval('document.getElementById("txtPOWeight'+intCtr+'")').value)
         }
      }
      if ((intTotHandled != 0)&&(intTotPackages != 0)&&(intTotPOPieces != 0)&&
          (intTotPOPieces != intTotHandled)&&(intTotPOPieces != intTotPackages))
      {
         return warnInvalid(document.getElementById("txtPOPieces0"),"Total PO Pcs does not equal total Handling Units or total Packages.")
      }
      if ((intTotWeight != 0)&&(intTotPOWeight != 0)&&(intTotPOWeight != intTotWeight))
      {
         return warnInvalid(document.getElementById("txtPOWeight0"),"Total PO Wt does not equal total Commodities Weight.")
      }
   }

   if (!document.getElementById("txtCustRefNumber1"))
   {
      txtRefno = CustRefNum
      txtRefno = txtRefno.toUpperCase()
      document.getElementById("txtCustRefNumber0").value = txtRefno
      if ((txtRefno == '?')       ||
          (txtRefno == 'UNK')     ||
          (txtRefno == 'UNKNOWN') ||
          (txtRefno == 'N/A')     ||
          (txtRefno == 'NA')      ||
          (txtRefno == 'N/S')     ||
          (txtRefno == 'NS')      ||
          (txtRefno == 'X')       ||
          (txtRefno == 'XX')      ||
          (txtRefno == 'XXX')     ||
          (txtRefno == 'XXXX')    ||
          (txtRefno == 'NONE'))
      {
         return warnInvalid(document.getElementById("txtCustRefNumber0"),"Invalid Cust Ref Number; leave blank if not available.")
      }
   }
   else
   {
      for (var intCtr = 0; intCtr < intCurrentRefno; intCtr++)
      {
         txtRefno = eval('document.getElementById("txtCustRefNumber'+intCtr+'")').value
         txtRefno = txtRefno.toUpperCase()
         eval('document.getElementById("txtCustRefNumber'+intCtr+'")').value = txtRefno
         if ((txtRefno == '?')        ||
             (txtRefno == 'UNK')      ||
             (txtRefno == 'UNKNOWN')  ||
             (txtRefno == 'N/A')      ||
             (txtRefno == 'NA')       ||
             (txtRefno == 'N/S')      ||
             (txtRefno == 'NS')       ||
             (txtRefno == 'X')        ||
             (txtRefno == 'XX')       ||
             (txtRefno == 'XXX')      ||
             (txtRefno == 'XXXX')     ||
             (txtRefno == 'NONE'))
         {
            return warnInvalid(eval('document.getElementById("txtCustRefNumber'+intCtr+'")'),"Invalid Cust Ref Number; leave blank if not available.")
         }
         else
         {
            for (var intDupCtr = intCtr + 1; intDupCtr < intCurrentRefno; intDupCtr++)
            {
               txtRefno = eval('document.getElementById("txtCustRefNumber'+intDupCtr+'")').value
               txtRefno = txtRefno.toUpperCase()
               eval('document.getElementById("txtCustRefNumber'+intDupCtr+'")').value = txtRefno
               if ((eval('document.getElementById("txtCustRefNumber'+intCtr+'").value == document.getElementById("txtCustRefNumber'+intDupCtr+'").value')) &&
                   (eval('document.getElementById("txtCustRefNumber'+intCtr+'")').value > " "))
               {
                  return warnInvalid(eval('document.getElementById("txtCustRefNumber'+intCtr+'")'),"Duplicate Cust Ref Number.")
               }
            }
         }
      }
   }
   return true;
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ VALID REQUESTER AFFILIATION                                         +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function ValidRequesterAffiliation(blnCreateBlank) {
   // Validate Payment Terms
   if (blnCreateBlank) {
      if (objForm.optPay) {
         objForm.optPay[0].checked = true
      }
   }
   else {
      if (objForm.optPay) {
         if ((!objForm.optPay[0].checked) && (!objForm.optPay[1].checked)) {
            return warnInvalid(objForm.optPay[0],'Please select the payment terms to complete your Bill of Lading.')
         }
      }
   }

   if (objForm.optPay) {
      if ((objForm.chkAffShp.checked == true) &&
         (objForm.chkAffCon.checked == false) &&
         (objForm.optPay[1].checked == true))
      {
         return warnInvalid(objForm.optPay[0],'The payment terms must be PREPAID if only the shipper is checked.')
      }
      if ((objForm.chkAffShp.checked == false) &&
         (objForm.chkAffCon.checked == true)   &&
         (objForm.optPay[0].checked == true))
      {
         return warnInvalid(objForm.optPay[1],'The payment terms must be COLLECT if only the consignee is checked.')
      }
   }
   return true
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ VALID REQUESTER CONTACT INFO                                        +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function ValidRequesterContactInfo()
{
   // Validate the Contact Email Address
   if ((!isWhitespace(objForm.txtContactEmail.value)) &&
       (!ValidEMail(objForm.txtContactEmail.value))) {
      errmsg = 'Invalid Requester Contact E-mail Address'
      return warnInvalid(objForm.txtContactEmail,errmsg) }

   // Validate the Contact Phone Number / Fax Number
   if (!isWhitespace(objForm.txtContactPhone.value))
   { if (!checkUSPhone(objForm.txtContactPhone,"Requester Contact Phone","true"))
      { return false }
   }
   if ((isWhitespace(objForm.txtContactPhone.value)) &&
       (!isWhitespace(objForm.txtContactPhoneExt.value)))
   { errmsg = "Phone number required with extension."
      return warnInvalid(objForm.txtContactPhone,errmsg)
   }
   if ((!isWhitespace(objForm.txtContactPhoneExt.value)) &&
       (!isInteger(objForm.txtContactPhoneExt.value)))
   { errmsg = "Please enter a valid phone extension."
      return warnInvalid(objForm.txtContactPhoneExt,errmsg)
   }
    if (!isWhitespace(objForm.txtContactFax.value))
   { if (!checkUSPhone(objForm.txtContactFax,"Requester Contact Fax","true"))
      { return false }
   }

   //change numbers to the (nnn)nnn-nnnn format even if they are not required
   if ((objForm.txtContactPhone.value.length > 0) && (!checkUSPhone (objForm.txtContactPhone, "Contact Phone", "false")))
   {  return false }

   if ((objForm.txtContactFax.value.length > 0)  && (!checkUSPhone (objForm.txtContactFax, "Contact Fax", "false")))
   {  return false }

   return true
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ VALID SHIP DATE                                                     +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function ValidShipDate() {
   if ((objForm.cboYear.length == 0)  ||
       (objForm.cboMonth.length == 0) ||
       (objForm.cboDay.length == 0)) {
      errmsg = "Ship date is required"
      return warnInvalid("",errmsg) }
   return true
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ VALID TRUCKPACK NUMBER                                              +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function ValidTruckPackNumber(objForm)
{
   if (objForm.chkTRPACK)
   {
      if ((objForm.chkTRPACK.checked==true) && (!isInteger(objForm.txtTRPACK.value)))
      {
         return warnInvalid(objForm.txtTRPACK,"Valid number of TruckPack boxes is required.");
      }

      if (!document.getElementById("txtWeight1"))
      {
         intTotalWeight = parseInt(document.getElementById("txtWeight0").value,10);
      }

      if ((objForm.chkTRPACK.checked==true) && (intTotalWeight/(parseInt(objForm.txtTRPACK.value,10))>1500))
      {
         return warnInvalid(objForm.txtTRPACK,"One TruckPack box can hold a maximum of 1500 lbs. Please enter a number of TruckPack boxes for this shipment.");
      }
   }

   return true;
}
