var shp = 0;
var con = 1;
var intMaxItems = 15;
var intMaxSteps = 5;
var strFormAction;
var blnSubmittingForm = false;
var blnAddServValidated = false;

var frm;
var strQueryString;


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ CHECK GROUND DELIVERY / PICKUP                                      +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function CheckGRDDELPU() {
   var blnGRDDELPU = false;

   if (!blnAddServValidated)
   {
   	if (document.getElementById("txtPromoCode").value == "")
   	{
   		if (!document.getElementById("chkCustOpt0").checked)
   		{
   		   document.getElementById("chkRPU").checked = true;
         }

   		if (!document.getElementById("chkCustOpt1").checked)
   		{
   			document.getElementById("chkRDEL").checked = true;
         }

   	   for (var i = 0; i < intCurItems; i++) {
   	      if (parseInt(eval("document.getElementById('txtWeight" + i + "')").value) >= 250)
   	      {
   				if (!document.getElementById("chkCustOpt0").checked)
   				{
   					document.getElementById("chkGRDPU").checked = true;
   					document.getElementById("GRDPU").innerHTML  = "Liftgate-Ground Pickup*";
   	         }
   	         if (!document.getElementById("chkCustOpt1").checked)
   	         {
   					document.getElementById("chkGRDDEL").checked = true;
   					document.getElementById("GRDDEL").innerHTML  = "Liftgate-Ground Delivery*";
   	         }
   	         blnGRDDELPU = true;
   	      }
   		}
   	}
   	else
   	{
   		document.getElementById("chkRPU").checked = false;
   		document.getElementById("chkRDEL").checked = false;
   	}

   	if (blnGRDDELPU == false)
   	{
   		document.getElementById("chkGRDPU").checked  = false;
   		document.getElementById("chkGRDDEL").checked = false;
   //		document.getElementById("GRDPU").className 	= "pgTxt";
   		document.getElementById("GRDPU").innerHTML 	= "Liftgate-Ground Pickup";
   //		document.getElementById("GRDDEL").className  = "pgTxt";
   		document.getElementById("GRDDEL").innerHTML  = "Liftgate-Ground Delivery";
      }
   }
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ CUBE REQUIRED                                                       +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function CubeRequired(objForm) {
   var strTest
   strTest = objForm.cboAcctState[0][objForm.cboAcctState[0].selectedIndex].value
   if ((strTest == "GU") || (strTest == "HI") || (strTest == "PR") || (strTest == "VI")) {
      return true
   }
   strTest = objForm.cboAcctState[1][objForm.cboAcctState[1].selectedIndex].value
   if ((strTest == "GU") || (strTest == "HI") || (strTest == "PR") || (strTest == "VI")) {
      return true
   }

   if (!objForm.radAcctCountry0[0].checked)
      {  return true;  }

   if (!objForm.radAcctCountry1[0].checked)
      {  return true;  }

   if (parseInt(TotalWeight(objForm)) > 10000) {
      return true
   }
   return false
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ DESTINATION OPTION CHECK                                            +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function DestinationOptCheck(chkInput) {
   if (chkInput.checked)
   {
		DisableDeliveryOptions();
   }
   else
   {
		EnableDeliveryOptions();
		if (objForm.hidFirstTimeIn.value == "True")
      {
      	CheckGRDDELPU();
   	}
   }
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ EDIT QUOTE BASIS                                                    +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function EditQuoteBasis() {
   // Display the quote basis section again to edit or review.
	SummarizeThisAndEditNext(0,intMaxSteps)
   return true
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ FORMAT SUMMARY                                                      +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function FormatSummary(intCur) {
   switch(intCur) {
      case 1:
   		document.getElementById("QuoteBasis").innerHTML = FormatQuoteBasisText()
   		document.getElementById("PromoCode").innerHTML = FormatPromotionCode()
         break;
      case 2:
		   document.getElementById("ShipmentSpecifics").innerHTML = FormatShipmentSpecifics("Quote")
		   document.getElementById("CustInfo").innerHTML = FormatCustInfo(0,"Origin") + FormatCustInfo(1,"Destination")
		   switch(objForm.hidQuoteBasis.value) {
		      case 'CLASS':
		      	RequireCUBE()
		      	RequireClass(true)
		         break;
				case 'CUBE':
	         	RequireCUBE()
	         	break;
				case 'PALLET':
	         	RequirePALLET()
	         	break;
	         default:
	         	break;
	      }
         break;
      case 3:
		   document.getElementById("CommodityInfo").innerHTML = FormatCommodityInfo(objForm.hidQuoteBasis.value)
			if (!blnSubmittingForm)
			{
				OriginOptCheck(document.getElementById("chkCustOpt0"))
				DestinationOptCheck(document.getElementById("chkCustOpt1"))
			}
         break;
      case 4:
		   document.getElementById("AdditionalServices").innerHTML = FormatAdditionalServices(true)
         break;
      case 5:
			document.getElementById("TermsAndConditions").innerHTML = FormatTermsAndConditions()
         break;
      default:
         break;
   }
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ GET SELECTED COUNTRY                                                +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function getSelectedCountry(){
   var intSub
   for (intSub = 0; intSub < 3; intSub++){
      if(objForm.radAcctCountry[intSub].checked) {
         return intSub
      }
   }
   return intSub
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ HIDE ELEMENTS IE                                                    +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// there is nothing to hide, but the functions are called globally
function hideElementsIE() {
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ MANUAL QUOTE	                                                      +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function ManualQuote() {
	blnSubmittingForm = true

   // Display the Terms & Conditions summary again since we do not
   // revalidate that section and it has been made visible from the
   // ValidateAdditionalServices routine.
	SummarizeThisAndEditNext(5,intMaxSteps)

   // Edit The Requester Contact Information
   if (ValidRequesterContactInfo())
   {
      strFormAction = "M"
      objForm.FormAction.value = "M"
      objForm.submit()
      DisplayWait("Your rate quote is processing.\nPlease stand by.")
   }
   return false;
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ ORIGIN OPTION CHECK                                                 +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function OriginOptCheck(chkInput)
{
   if (chkInput.checked)
   {
		DisablePickupOptions();
      document.getElementById("txtShipDate").value = "My shipment should be dropped off on*: ";
   }
   else
   {
		EnablePickupOptions();
      document.getElementById("txtShipDate").value = "My shipment should be picked up on*: ";
		if (objForm.hidFirstTimeIn.value == "True")
      {
      	CheckGRDDELPU();
   	}
   }
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ PROCESS RADIO BUTTONS                                               +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function processRadioButtons(strQuoteBasis)
{
   objForm.hidQuoteBasis.value = strQuoteBasis
	if (strQuoteBasis == "CLASS")
	{
	   if (!document.getElementById("txtWeight1"))
	   {
	   	document.getElementById("txtFrtLength0").value	= ""
	   	document.getElementById("txtFrtWidth0").value	= ""
	   	document.getElementById("txtFrtHeight0").value	= ""
	   	document.getElementById("txtDescription0").value = ""
	   }
	   else
	   {
	      for (var i = 0; i < intCurItems; i++) {
            eval('document.getElementById("txtFrtLength'+i+'")').value	= ""
            eval('document.getElementById("txtFrtWidth'+i+'")').value	= ""
            eval('document.getElementById("txtFrtHeight'+i+'")').value	= ""
            eval('document.getElementById("txtDescription'+i+'")').value = ""
	      }
	   }
   	document.getElementById("txtShipDescMsg").value = "Enter weight and NMFC item/sub, class or description for each handling unit to be shipped."
	}
	else
	{
	   if (!document.getElementById("txtWeight1"))
	   {
	   	document.getElementById("txtItem0").value			 = ""
	   	document.getElementById("txtSub0").value			 = ""
	   	document.getElementById("cboClass0").value		 = ""
	   	document.getElementById("txtDescription0").value = ""
	   }
	   else
	   {
	      for (var i = 0; i < intCurItems; i++) {
            eval('document.getElementById("txtItem'+i+'")').value			 = ""
            eval('document.getElementById("txtSub'+i+'")').value			 = ""
            eval('document.getElementById("cboClass'+i+'")').value		 = ""
            eval('document.getElementById("txtDescription'+i+'")').value = ""
	      }
	   }
   	document.getElementById("txtShipDescMsg").value = "Enter weight and dimensions for each handling unit to be shipped."
	}
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ SET VALUES FOR REMOTE CITY CODING                                   +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function SetValuesForRemoteCityCoding()
{
   strShpConTpb = "YYN";

   if (document.getElementById("chkCustOpt").checked)
   {
      strShpOptChecked = "Y";
      strConOptChecked = "N";
   }
   else
   {
      strShpOptChecked = "N";
      strConOptChecked = "N";
   }

   if (objForm.optQuoteBasis[0].checked)
   {
      strAccount = "999997";
   }
   else if (objForm.optQuoteBasis[1].checked)
   {
      strAccount = "999996";
   }
   else
   {
      strAccount = "999998";
      strCheckTruckPack = "Y";
   }
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ SET FOCUS                                                           +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function SetFocus(intCur) {
	// This function sets the focus to the first item of the section to be edited.
	if (objForm.hidPageError.value == "True")
	{
		document.getElementById("pgError").focus()
	}
	else
	{
	   switch(intCur) {
	      case 0:
		      if (objForm.optQuoteBasis[0]) {
				   objForm.optQuoteBasis[0].focus()
				}
	         break;
	      case 1:
				if (objForm.txtAcctZip[0]) {
				   objForm.txtAcctZip[0].focus()
				}
	         break;
	      case 2:
			   switch(objForm.hidQuoteBasis.value) {
			      case 'CLASS':
					   if (document.getElementById("txtWeight0")) {
					      document.getElementById("txtWeight0").focus()
			         }
			         break;
					case 'CUBE':
					   if (document.getElementById("txtWeight0")) {
	   				   document.getElementById("txtWeight0").focus()
		            }
		         	break;
					case 'PALLET':
					   if (document.getElementById("txtWeightTP")) {
		   			   document.getElementById("txtWeightTP").focus()
		         	}
		         	break;
		         default:
		         	break;
		      }
	         break;
	      case 3:
	      	SetAdditionalServiceOptionFocus()
	         break;
	      case 4:
			   if (document.getElementById("chkAgreeTerms")) {
			      document.getElementById("chkAgreeTerms").focus()
			   }
	         break;
	      case 5:
	         if (document.getElementById("cmdSubmit2")) {
			      document.getElementById("cmdSubmit2").focus()
			   }
				else if (document.getElementById("cmdSubmit1")) {
			      document.getElementById("cmdSubmit1").focus()
			   }
	         break;
	      default:
	         if (document.getElementById("cmdManualRate")) {
	            document.getElementById("cmdManualRate").focus()
	         }
	         break;
	   }
	}
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ SHOW ELEMENTS IE                                                    +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// there is nothing to hide, but the functions are called globally
function showElementsIE() {
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ SUBMIT FORM                                                         +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function SubmitForm() {
	var blnValid = false

	blnSubmittingForm = true

	blnValid = ValidateQuoteBasis(1)

	if (blnValid)
	{
		blnValid = ValidateFromToLocs(2)
	}

	if (blnValid)
	{
		blnValid = ValidateShipmentDesc(3)
	}

	if (blnValid)
	{
		blnValid = ValidateAdditionalServices(4)
	}

/*
	if (blnValid)
	{
		blnValid = ValidateTermsAndConditions(5)
	}
*/

   if (blnValid && document.getElementById("Edit0"))
   {
		if (document.getElementById("Edit0").className == 'visibleRow')
		{
         blnValid = ManualQuote()
/*
         if (blnValid) {
      	   objForm.FormAction.value = "M";
      	   objForm.action = "quote.asp";
      	   DisplayWait("Your quote is processing.\nPlease stand by.");
      	   objForm.submit();
         }
*/
      }
   }
   else {
   	if (blnValid)
   	{
   	   objForm.FormAction.value = "Q";
   	   objForm.action = "quote.asp";
   	   DisplayWait("Your quote is processing.\nPlease stand by.");
   	   objForm.submit();
   	}
   }
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ SUMMARIZE TERMS AND CONDITIONS                                      +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function SummarizeTermsAndConditions(StepNum)
{
	if (document.getElementById("chkAgreeTerms").checked)
	{
		SummarizeThisAndEditNext(StepNum,intMaxSteps)
	}
	return true
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ TOTAL WEIGHT                                                        +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function TotalWeight(objForm)
{
   var intTotalWeight = 0

   for (var i = 0; i < intCurItems; i++) {
      intTotalWeight = intTotalWeight + parseInt(eval('document.getElementById("txtWeight'+i+'")').value)
   }

   return intTotalWeight
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ VALIDATE ADDITIONAL SERVICES                                        +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function ValidateAdditionalServices(StepNum) {
   // Validate The Additional Service Options
   if (!ValidAdditionalServiceOptions(document.frmRate))
   {
   	return false
   }
   blnAddServValidated = true
	SummarizeThisAndEditNext(StepNum,intMaxSteps)
   return true
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ VALIDATE FROM TO LOCS		                                          +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function ValidateFromToLocs(StepNum,blnSubmit) {
	// Validate The Customer Information.
   if (!ValidPartyInfo(0)) { return false }
   if (!ValidPartyInfo(1)) { return false }

   if (!((objForm.optPay[0].checked) || (objForm.optPay[1].checked)))
   {
      window.location.href="#shpinfo"
      return warnInvalid(objForm.optPay[0],"Please select where the freight charges will be paid.")
   }
	if (blnSubmit)
	{
		SubmitForm()
	}
	else
	{
		SummarizeThisAndEditNext(StepNum,intMaxSteps)
	}
   return true
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ VALIDATE QUOTE BASIS  			                                       +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function ValidateQuoteBasis(StepNum) {
   // Validate that a quote basis has been selected.
   if (objForm.hidQuoteBasis.value == "")
   {
//		*********************************** TruckPack removed per Chris Baltz on 3/12/2003 UNSANDL *****************************************
//		alert("Please select 1 of the 3 quote basis options (weight and dimensions [cube based]; weight and NMFC item or classification [class based]; or TruckPack boxes [TruckPack based]) and submit again.")
		alert("Please select 1 of the 2 quote basis options (weight and dimensions [cube based] or weight and NMFC item or classification [class based]) and submit again.")
      return false
   }

	// Validate the promotion code (if provided).
   if (!isEmpty(objForm.txtPromoCode.value) && objForm.txtPromoCode.value.length > 7)
   {
      return warnInvalid(objForm.txtPromoCode,"Invalid promotion code entered.  Please correct and try again.")
   }

	SummarizeThisAndEditNext(StepNum,intMaxSteps)
   return true
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ VALIDATE REQUESTER CONTACT INFO                                     +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function ValidRequesterContactInfo() {
   if (objForm.txtContactName.value.length < 1) {
      return warnInvalid(objForm.txtContactName,"A contact name is required.")
   }
   if (((objForm.radContactBy[0].checked) || (objForm.txtContactEmail.value.length > 0)) &&
      (!ValidEMail(objForm.txtContactEmail.value)) ) {
      return warnInvalid(objForm.txtContactEmail,"You entered an invalid E-mail address.")
   }
// Validate the Contact Phone Number
   if (((objForm.radContactBy[1].checked) || (objForm.txtContactPhone.value.length > 0)) &&
       (!checkUSPhone(objForm.txtContactPhone, "Contact Phone", "false"))) {
      return false
   }

   if (((objForm.radContactBy[2].checked) || (objForm.txtContactFax.value.length > 0)) &&
       (!checkUSPhone (objForm.txtContactFax, "Contact Fax", "false"))) {
      //return warnInvalid(objForm.txtContactFax,"You have requested to be contacted via fax.  Please provide a fax number.")
      return false
   }

   if ((objForm.txtContactPhoneExt.value.length > 0)&&(!isInteger(objForm.txtContactPhoneExt.value))) {
      return warnInvalid(objForm.txtContactPhoneExt,"Please enter a valid contact phone number extension.")
   }
   return true
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ VALIDATE SHIPMENT DESCRIPTION                                       +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function ValidateShipmentDesc(StepNum) {
	// Validate the Commodity Information
   if (objForm.hidQuoteBasis.value == 'PALLET')
   {
		if ((document.getElementById("txtWeightTP").value.length < 1)||
			 (!isInteger(document.getElementById("txtWeightTP").value))||
			 (document.getElementById("txtWeightTP").value == "0"))
		{
	      return warnInvalid(document.getElementById("txtWeightTP"),"Valid shipment weight is required.")
		}

	   if ((parseInt(document.getElementById("txtWeightTP").value) / parseInt(document.getElementById("txtWeightTP").value)) > 1500)
	   {
	      return warnInvalid(document.getElementById("txtWeightTP"),"Valid shipment weight for TruckPack can be no more that 1500 pounds per box.")
	   }

	   if ((document.getElementById("txtWeightTP").value.length < 1)||
	   	 (!isInteger(document.getElementById("txtWeightTP").value))||
	   	 (document.getElementById("txtWeightTP").value == "0"))
	   {
	      return warnInvalid(document.getElementById("txtWeightTP"),"Valid number of TruckPack cartons is required.")
	   }
	}
	else
	{
	   if (!document.getElementById("txtWeight1"))
	   {
	      if (!ValidCommodityInfo(0,
	         document.getElementById("txtWeight0"),
	         document.getElementById("txtItem0"),
	         document.getElementById("txtSub0"),
	         document.getElementById("cboClass0"),
	         document.getElementById("txtDescription0"),
	         document.getElementById("txtFrtLength0"),
	         document.getElementById("txtFrtWidth0"),
	         document.getElementById("txtFrtHeight0")))
	      { return false }
	   }
	   else
	   {
	      var intTotalWeight = 0
	      for (var i = 0; i < intCurItems; i++) {
	         if (!ValidCommodityInfo(i,
	            eval('document.getElementById("txtWeight'+i+'")'),
	            eval('document.getElementById("txtItem'+i+'")'),
	            eval('document.getElementById("txtSub'+i+'")'),
	            eval('document.getElementById("cboClass'+i+'")'),
	            eval('document.getElementById("txtDescription'+i+'")'),
	            eval('document.getElementById("txtFrtLength'+i+'")'),
	            eval('document.getElementById("txtFrtWidth'+i+'")'),
	            eval('document.getElementById("txtFrtHeight'+i+'")')))
	         { return false }

	         if (isInteger(eval('document.getElementById("txtWeight'+i+'")').value)) {
	            intTotalWeight = intTotalWeight + parseInt(eval('document.getElementById("txtWeight'+i+'")').value,10)
	         }
	      }
	   }
	}

	SummarizeThisAndEditNext(StepNum,intMaxSteps)
   return true
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ VALIDATE TERMS AND CONDITIONS                                       +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function ValidateTermsAndConditions(StepNum) {
	// Validate Terms and Conditions
	if (!(document.getElementById("chkAgreeTerms").checked))
	{
		return warnInvalid(objForm.txtTerms,"Please read and check the terms and conditions and press 'Submit Quote'")
	}

   strFormAction = "Q"
   objForm.FormAction.value = "Q"

   objForm.submit()
   DisplayWait("Your rate quote is processing.\nPlease stand by.")
   return true
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ VALIDATE COMMODITY INFO	                                          +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function ValidCommodityInfo(i,txtWeight,txtItem,txtSub,cboClass,txtDescription,txtFrtLength,txtFrtWidth,txtFrtHeight) {
// Validate shipment weight
   if ((trimWhiteSpace(txtWeight.value) == "")||(!isInteger(txtWeight.value))||(txtWeight.value == "0"))
   {
      return warnInvalid(txtWeight,"Valid shipment weight is required.")
   }

// Validate freight description or class or NMFC item & sub
   if (objForm.hidQuoteBasis.value == 'CLASS')
   {
      if ((trimWhiteSpace(txtDescription.value) == "") &&
          (trimWhiteSpace(txtItem.value) == "") &&
          (cboClass.selectedIndex < 1))
      {
         return warnInvalid(txtDescription,"A freight description OR class OR a valid NMFC Item and Sub is required for this commodity.")
      }

		//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.")
		}

      if (!ValidDimensions(txtFrtLength, txtFrtWidth, txtFrtHeight))
      {
      	return false
      }
      else
      {
         if (CubeRequired(objForm))
         {
            RequireCUBE()
            window.location.href="#QuoteBasis"
            if ((trimWhiteSpace(txtFrtLength.value) == "") && (trimWhiteSpace(txtFrtWidth.value) == "") && (trimWhiteSpace(txtFrtHeight.value) == ""))
            {
                return warnInvalid(txtFrtLength,"Shipment dimensions are required for offshore (or large, bulky shipments).")
            }
            else
            {
               if (!ValidDimensions(txtFrtLength, txtFrtWidth, txtFrtHeight))
               {
               	return false
               }
            }
         }
      }
   }
   else
   {
      if ((!ValidDimensions(txtFrtLength, txtFrtWidth, txtFrtHeight)))
      {
      	return false
      }
      if ((trimWhiteSpace(txtFrtLength.value) == "") ||
          (trimWhiteSpace(txtFrtWidth.value) == "") ||
          (trimWhiteSpace(txtFrtHeight.value) == ""))
      {
         return warnInvalid(txtFrtLength,"Valid freight dimensions are required for this commodity.")
      }
   }
   return true
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ VALIDATE DIMENSIONS			                                          +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function ValidDimensions(txtLength, txtWidth, txtHeight) {
   // If any freight dimension is entered, require all to be entered.
   if ((trimWhiteSpace(txtLength.value) != "") ||
   	 (trimWhiteSpace(txtWidth.value) != "") ||
   	 (trimWhiteSpace(txtHeight.value) != ""))
   {
      if (txtLength.value > 336)
         {return warnInvalid(txtLength,"A single piece of freight cannot exceed 336 inches in length.")}
      if (txtWidth.value > 96)
         {return warnInvalid(txtWidth,"A single piece of freight cannot exceed 96 inches in width.")}
      if (txtHeight.value > 96)
         {return warnInvalid(txtHeight,"A single piece of freight cannot exceed 96 inches in height.")}
      if ((trimWhiteSpace(txtLength.value) == "") || (!isInteger(txtLength.value)) || (txtLength.value < 1))
         {return warnInvalid(txtLength,"Invalid freight length.")}
      if ((trimWhiteSpace(txtWidth.value) == "") || (!isInteger(txtWidth.value)) || (txtWidth.value < 1))
         {return warnInvalid(txtWidth,"Invalid freight width.")}
      if ((trimWhiteSpace(txtHeight.value) == "") || (!isInteger(txtHeight.value)) || (txtHeight.value < 1))
      {
      	return warnInvalid(txtHeight,"Invalid freight height.")
      }
      else
      {
         if (txtLength.value < 12)
         {
            if (!(confirm("Commodity dimensions are required in inches.  You entered a commodity length less than a foot.  Is this correct?")))
            {
               txtLength.select()
               return false
            }
         }
         else
         {
            if (txtWidth.value < 12)
            {
               if (!(confirm("Commodity dimensions are required in inches.  You entered a commodity width less than a foot.  Is this correct?")))
               {
                  txtWidth.select()
                  return false
               }
            }
            else
            {
               if (txtHeight.value < 12)
               {
                  if (!(confirm("Commodity dimensions are required in inches.  You entered a commodity height less than a foot.  Is this correct?")))
                  {
                     txtHeight.select()
                     return false
                  }
               }
            }
         }
      }
   }
   return true
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ VALIDATE PARTY INFO			                                          +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function ValidPartyInfo(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 // added 03.05.01 ulwilli
   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+"."); }
   }

   // If Mexico is selected, uncheck the Bring-To-Origin-Terminal and Pick-Up-From-Destination-Terminal checkbox
   if ((objForm.radAcctCountry0[2].checked) && (document.getElementById("chkCustOpt0").checked))
   {
      document.getElementById("chkCustOpt0").checked = false
   }
   if ((objForm.radAcctCountry1[2].checked) && (document.getElementById("chkCustOpt1").checked))
   {
      document.getElementById("chkCustOpt1").checked = false
   }

/*
**********************************************************************
RemoteCityCoding goes here.................
**********************************************************************
   SetValuesForRemoteCityCoding()
   jsValidateCityCodeRS('quote.asp',true,frm.txtAcctCity[0],frm.cboAcctState[0],frm.txtAcctZip[0],frm.radAcctCountry0,true,frm.txtAcctCity[1],frm.cboAcctState[1],frm.txtAcctZip[1],frm.radAcctCountry1,false,'','','','',true);
   return false
*/
   return true
}