//WARNING: THIS IS A COMPRESSED FILE AND SHOULD NOT BE EDITED!!!
var intLoopCheck = 1;
var ConstMaxCommodities = 15;
function SubmitForm()
{  if (ValidFormData())
{  objForm.FormSubmitted.value = "Y";
DisplayWait("Your pickup request is processing.\nPlease stand by.");
objForm.submit();
}
}
function ValidFormData()
{  var regValidWeight = /^\d{0,6}$/ig;
if (!(objForm.chkAffShp.checked || objForm.chkAffCon.checked || objForm.chkAffTpb.checked)) {return warnInvalid(objForm.chkAffShp, 'Please indicate whether you are acting as the Shipper, Consignee, or Third Party.');}
if (isWhitespace(objForm.txtRequesterName.value))  {return warnInvalid(objForm.txtRequesterName,  'Please enter the Name of the requester.');}
if (isWhitespace(objForm.txtRequesterPhone.value)) {return warnInvalid(objForm.txtRequesterPhone, 'Please enter the Phone Number for the requester.');}
if (!checkUSPhone(objForm.txtRequesterPhone, "The requester phone number", false)) {return false;}
if (isWhitespace(objForm.txtAcctName.value))       {return warnInvalid(objForm.txtAcctName,     'Please enter the Company Name of the pickup location.');}
if (isWhitespace(objForm.txtAcctContact.value))    {return warnInvalid(objForm.txtAcctContact,  'Please enter the Contact Name for the pickup location.');}
if (isWhitespace(objForm.txtAcctAddr.value))       {return warnInvalid(objForm.txtAcctAddr,     'Please enter the Street Address for the pickup location.');}
if (isWhitespace(objForm.txtAcctPhone.value))      {return warnInvalid(objForm.txtAcctPhone,    'Please enter the Phone Number for the pickup location.');}
if (!checkUSPhone(objForm.txtAcctPhone, "The phone number for the pickup location", false)) {return false;}
if (isWhitespace(objForm.txtAcctZip.value))        {return warnInvalid(objForm.txtAcctZip,      'Please enter the Zip/Postal Code for the pickup location.');}
objForm.txtAcctZip.value = trimWhiteSpace(objForm.txtAcctZip.value);
if (!(validZipCode(objForm.txtAcctZip, objForm.cboAcctCountry.value))) {return warnInvalid(objForm.txtAcctZip,'The Origin Zip/Postal code "'+objForm.txtAcctZip.value+'" is invalid for the country selected.');}
if (objForm.chkAffShp.checked){
if (isWhitespace(objForm.cboAvailable.value))   {return warnInvalid(objForm.cboAvailable, 'Please enter the Shipment Available Time.');}
}
if (!ValidAdditionalServiceOptions(objForm)) {return false;}
for (var i=1; i<objForm.txtWeight.length; i++)
{  regValidWeight.lastIndex = 0;
if (!regValidWeight.test(objForm.txtWeight[i].value)) {return warnInvalid(objForm.txtWeight[i], 'Please enter a valid weight.  Weight can not contain decimal values.');}
if ((!isWhitespace(objForm.txtPieces[i].value))&&(!isInteger(objForm.txtPieces[i].value)))
{ return warnInvalid(objForm.txtPieces[i],"Please enter a valid handling units amount for this commodity.");}
if ((objForm.cboHandledType[i].selectedIndex < 1)&&(!isWhitespace(objForm.txtPieces[i].value)))
{ return warnInvalid(objForm.cboHandledType[i],"Please enter a valid handling units type for this commodity.");}
}
if(!CheckDate(objForm.txtPickupDate)) {return false;}
if (objForm.chkAcctEmailCopy.checked    && (isWhitespace(objForm.txtAcctEMail.value))) {return warnInvalid(objForm.txtAcctEMail,  'Please enter the Email Address that a copy of the Pickup Request for each destination should be sent to.');}
if (objForm.chkAcctEmailConfirm.checked && (isWhitespace(objForm.txtAcctEMail.value))) {return warnInvalid(objForm.txtAcctEMail,  'Please enter the Email Address that a notification should be sent to when the shipments for each destination are picked up.');}
if ((objForm.chkAcctEmailCopy.checked||objForm.chkAcctEmailConfirm.checked) && (!ValidEMail(objForm.txtAcctEMail.value)))
{  return warnInvalid(objForm.txtAcctEMail,'Invalid E-mail address found'); }
for (var i=1; i<=intNumDestinations; i++)
{  objForm.txtDestZip[i].value = trimWhiteSpace(objForm.txtDestZip[i].value);
if (objForm.txtDestZip[i].value != '')
{  if (!(validZipCode(objForm.txtDestZip[i], objForm.cboDestCountry[i].value))) {return warnInvalid(objForm.txtDestZip[i],'The Destination Zip/Postal code "'+objForm.txtDestZip[i].value+'" is invalid for the country selected.');}
if (objForm.hidPaymentTerms[i].value == '') {return warnInvalid(objForm.txtDestZip[i],   'Please select Payment Terms for the destination '+objForm.txtDestZip[i].value);}
if ((objForm.hidShipmentEmailCopy[i].value    != '') && (isWhitespace(objForm.txtShipmentEmail[i].value))) {return warnInvalid(objForm.txtShipmentEmail[i],  'Please enter the Email Address that a copy of the Pickup Request for the destination zip '+objForm.txtDestZip[i].value+' should be sent to.');}
if ((objForm.hidShipmentEmailConfirm[i].value != '') && (isWhitespace(objForm.txtShipmentEmail[i].value))) {return warnInvalid(objForm.txtShipmentEmail[i],  'Please enter the Email Address that the notification should be sent to when the shipment destined for '+objForm.txtDestZip[i].value+' is picked up.');}
if (((objForm.hidShipmentEmailCopy[i].value!='')||(objForm.hidShipmentEmailConfirm[i].value!='')) && (!ValidEMail(objForm.txtShipmentEmail[i].value))) {return warnInvalid(objForm.txtShipmentEmail[i],'Invalid E-mail address found');}
}
else
{  var oTextZip= GetNodeDescendants(GetNodeParent(objForm.txtDestZip[i], 'tblZipPrepaid'), 'spnDestZip')[0];
if ((oTextZip.className == 'formTxtR') && (isWhitespace(objForm.txtDestZip[i].value))) {return warnInvalid(objForm.txtDestZip[i],'Destination Zip/Postal code is missing.');}
}
}
return true;
}
function RequireTerms(oObj)
{  var bRequire = (!isWhitespace(oObj.value));
var oParent = GetNodeParent(oObj, 'DestFormFields');
var oRequired= GetNodeDescendants(oParent, 'tdPaymentTerms')[0];
if (bRequire) {RequireField(oRequired, true);}
else if (GetNodeDescendants(oParent, 'spnDestZip')[0].className == 'formTxt') {RequireField(oRequired, false);}
}
function ToggleRequiredFields(oObj)
{  var bRequire = false;
var oParent = GetNodeParent(oObj, 'DestFormFields');
var sFields = 'txtPieces~txtWeight~txtDeliveryInstructions';
var sRequired= 'spnDestZip~tdPaymentTerms';
var aFields = sFields.split("~");
var aRequired= sRequired.split("~");
for (var iSub=0; iSub<aFields.length; iSub++)
{  var oarrField = GetNodeDescendants(oParent, aFields[iSub]);
for (var iField=0; iField<oarrField.length; iField++)
{  if ((!isWhitespace(oarrField[iField].value))||(intNumDestinations==1)) {bRequire=true; break;}
}
if (bRequire) {break;}
}
for (var iSub=0; iSub<aRequired.length; iSub++)
{  var oRequired = GetNodeDescendants(oParent, aRequired[iSub])[0];
RequireField(oRequired, bRequire);
}
}
function RequireField(oObj, bRequire)
{  oObj.className = bRequire ? 'formTxtR' : 'formTxt';
if (bRequire)
{  if (GetInnerText(oObj).indexOf('*') < 0) {SetInnerText(oObj, GetInnerText(oObj) + '*');} }
else {SetInnerText(oObj, GetInnerText(oObj).replace('*', ''));}
}
function CheckDate(mObj)
{  oCal.blnDateRequired = true;
oCal.objDateField = mObj;
oCal.checkDate();
if (oCal.blnInvalidDate)  {return warnInvalid(mObj, 'Pickup Date is invalid.  Please use a valid format like \'mm/dd/yyyy\' or select from the calendar provided.');}
else if (oCal.blnPastDate){return warnInvalid(mObj, 'A Pickup can no longer be scheduled for this date.  Please enter or select another pickup date from the calendar provided.');}
return true;
}
function AddCommodity(mObj)
{  var oParent = GetNodeParent(mObj, 'CommodityParent');
var intNumCommodityRows = GetNodeDescendants(oParent, 'CommodityChild').length;
if (intNumCommodityRows < ConstMaxCommodities)
{  var oChild = GetNodeDescendants(oDestParent, 'CommodityChild')[0].cloneNode(true);
var oAddRow = GetNodeParent(mObj, 'AddCommodityRow');
oParent.insertBefore(oChild, oAddRow);
if (intNumCommodityRows==1) {ShowHideRemoveImage('Show', oParent, 'imgRemoveCommodity', 0);}
ShowHideRemoveImage('Show', oParent, 'imgRemoveCommodity', intNumCommodityRows);
UpdateCommodityCount(oParent, intNumCommodityRows+1);
}
if (intNumCommodityRows == ConstMaxCommodities) {warnInvalid('', 'The maximum number of commodites have been added for this Destination.'); }
}
function RemoveCommodity(mObj)
{  var oChild = GetNodeParent(mObj, 'CommodityChild');
var oParent = GetNodeParent(oChild, 'CommodityParent');
var intNumCommodityRows = GetNodeDescendants(oParent, 'CommodityChild').length;
if (intNumCommodityRows > 1)
{  oParent.removeChild(oChild);
UpdateCommodityCount(oParent, intNumCommodityRows-1);
}
if (intNumCommodityRows == 2) {ShowHideRemoveImage('Hide', oParent, 'imgRemoveCommodity', 0); }
}
function AddDestination()
{  if (intNumDestinations < intMaxDestinations)
{  var oChild = GetNodeDescendants(oDestParent, 'DestFormFields')[0].cloneNode(true);
oChild.className = 'visible';
oDestParent.appendChild(oChild);
ShowHideRemoveImage('Show', oDestParent, 'imgRemoveDestination', 1);
intNumDestinations++;
}
if (intNumDestinations == intMaxDestinations) {warnInvalid('', 'The maximum number of destinations have been added for this Pickup Request.'); }
}
function RemoveDestination(mObj)
{  if (intNumDestinations > 1)
{  var oChild = GetNodeParent(mObj, 'DestFormFields');
oDestParent.removeChild(oChild);
intNumDestinations--;
}
if (intNumDestinations == 1) {ShowHideRemoveImage('Hide', oDestParent, 'imgRemoveDestination', 1);}
var oZip = GetNodeDescendants(oDestParent, 'spnDestZip')[1];
var oTerms = GetNodeDescendants(oDestParent, 'tdPaymentTerms')[1];
RequireField(oZip, true);
RequireField(oTerms, true);
}
function clsLocation()
{  this.NamePlus = null;
this.Address = null;
this.City = null;
this.State = null;
this.Zip = null;
this.Country = null;
this.Contact = null;
this.Phone = null;
this.PhoneExt = null;
this.EMail = null;
this.Station = null;
this.AirlineCode = null;
this.ActualCity = null;
this.ActualState = null;
this.strType = null;
this.objField = null;
this.blnUseActual = false;
this.Update = function()
{  var objForm = GetNodeParent(this.objField, this.strType+'FormFields');
if (this.blnUseActual) {this.City = this.ActualCity; this.State = this.ActualState;}
if (this.NamePlus!=null) {getChildNodeByID(objForm, 'txt'+this.strType+'NamePlus').value = this.NamePlus;}
if (this.Address !=null) {getChildNodeByID(objForm, 'txt'+this.strType+'Addr').value = this.Address;}
if (this.City    !=null) {getChildNodeByID(objForm, 'txt'+this.strType+'City').value = this.City;}
if (this.State   !=null) {getChildNodeByID(objForm, 'txt'+this.strType+'State').value = this.State;}
if (this.Zip     !=null) {getChildNodeByID(objForm, 'txt'+this.strType+'Zip').value = this.Zip;}
if (this.Contact !=null) {getChildNodeByID(objForm, 'txt'+this.strType+'Contact').value = this.Contact;}
if (this.Phone   !=null) {getChildNodeByID(objForm, 'txt'+this.strType+'Phone').value = this.Phone;}
if (this.PhoneExt!=null) {getChildNodeByID(objForm, 'txt'+this.strType+'PhoneExt').value = this.PhoneExt;}
if (this.EMail   !=null) {getChildNodeByID(objForm, 'txt'+this.strType+'EMail').value = this.EMail;}
}
}
function hideContactDropDown(seq)  // Used in tools/shared/locationswindow-STC.js
{  document.getElementById('spnLocationContact').className = 'hidden'; }
function showContactDropDown(seq)  // Used in tools/shared/locationswindow-STC.js
{  document.getElementById('spnLocationContact').className = 'visible'; }
function addOption(text, val, combo)  // Used in tools/shared/locationswindow-STC.js
{  var myCombo = eval(combo);
myCombo.options[myCombo.options.length] = new Option(text,val);
}
function updateContactFields(mObj) //Used to set the values of the drop down generated in tools/shared/locationswindo_STC.js
{  var arrFields = mObj.value.split("~")
var oLoc = new clsLocation();
oLoc.objField= mObj;
oLoc.strType = 'Acct';
if (arrFields.length==6)
{  //oLoc.ContactId = arrFields[0];
oLoc.Contact = arrFields[1];
oLoc.Phone = arrFields[2];
oLoc.PhoneExt = arrFields[3];
oLoc.EMail = arrFields[5];
oLoc.Update();
}
hideContactDropDown();
}
function UpdateFormValues(mObj, mstrType)
{  var arrFields = mObj.value.split("|");
var oLoc = new clsLocation();
oLoc.objField= mObj;
oLoc.strType = mstrType;
if (arrFields.length==9)
{  oLoc.City = arrFields[0];
oLoc.State = arrFields[1];
oLoc.Zip = arrFields[2];
oLoc.Address = arrFields[3];
oLoc.Phone = arrFields[4];
oLoc.Station = arrFields[5];
oLoc.ActualCity = arrFields[6];
oLoc.ActualState = arrFields[7];
oLoc.AirlineCode = arrFields[8];
oLoc.NamePlus = 'C/O ABF SERVICE CENTER - '+oLoc.AirlineCode+'/'+oLoc.Station;
oLoc.blnUseActual= true;
oLoc.Update();
}
}
function ClearHiddenFields(mObj, mstrType)
{  var oLoc = new clsLocation();
oLoc.objField= mObj;
oLoc.strType = mstrType;
oLoc.City = '';
oLoc.State = '';
oLoc.NamePlus = '';
if (mstrType=='Dest') {oLoc.Address='';}
oLoc.Update();
}
function SetMyABFInfo()
{  if(objForm.chkAffShp.checked){Check_Affiliation(0);}
else {toggleCallShipper(true);jsClearLocation(0, false, true, true, false, true);}
objForm.txtDestCity[1].value = ((objForm.chkAffCon.checked) && (!(objForm.chkAffShp.checked))) ? jsUserCity    : objForm.txtDestCity[1].value;
objForm.txtDestState[1].value = ((objForm.chkAffCon.checked) && (!(objForm.chkAffShp.checked))) ? jsUserState   : objForm.txtDestState[1].value;
objForm.cboDestCountry[1].value = ((objForm.chkAffCon.checked) && (!(objForm.chkAffShp.checked))) ? jsUserCountry : objForm.cboDestCountry[1].value;
objForm.txtDestZip[1].value = ((objForm.chkAffCon.checked) && (!(objForm.chkAffShp.checked))) ? jsUserZip     : objForm.txtDestZip[1].value;
if (jsBlnAutoFillOn && (jsPaymentType != ''))
{  var oDestArray = GetNodeDescendants(oDestParent, 'DestFormFields');
for (var intX=0; intX<oDestArray.length; intX++)
{  var obPaymentTerms = getChildNodeByID(oDestArray[intX], ((jsPaymentType=='p') ? 'spnPrepaid' : 'spnCollect'));
SetPaymentTerms(obPaymentTerms);
}
}
}
function HandleShipmentAvailable()
{  var oLbl = document.getElementById('lblShipmentAvail');
oLbl.className = ((objForm.chkAffShp.checked) ? 'formTxtR' : 'formTxt')
var sInnerText = GetInnerText(oLbl);
if (objForm.chkAffShp.checked)
{  if (sInnerText.indexOf('*') < 0)
{SetInnerText(oLbl, sInnerText+'*');}
}
else {SetInnerText(oLbl, sInnerText.replace('*', ''));}
}
function displayMyLocationsContacts()
{  if (objForm.chkAffShp.checked) {upWinXY('xWin','/tools/shared/locationswindow.asp?FormName=frmMultiPickup&FormNum=0&PickupContact=Y',550,320,false);}
else                           {upWinXY('xWin','/tools/shared/custlocwindow.asp?FormName=frmMultiPickup&FormNum=0&CN=True&CP=True&CE=True&frmAction=FirstTimeIn',550,320,false);}
}
function SetPaymentTerms(mObj)
{  var blnPrepaid = (mObj.id == 'spnPrepaid');
var oPaymentTerms = GetNodeParent(mObj, 'spnPaymentTerms');
var oImage = getChildNodeByID(oPaymentTerms, (blnPrepaid ? 'imgPrepaid' : 'imgCollect'));
var oSiblingImg = getChildNodeByID(oPaymentTerms, (blnPrepaid ? 'imgCollect' : 'imgPrepaid'));
var oHidPaymentTerms = getChildNodeByID(oPaymentTerms, 'hidPaymentTerms');
oImage.src = '/images/icons/RadioInputSelected.png';
oSiblingImg.src = '/images/icons/RadioInput.png';
oHidPaymentTerms.value = (blnPrepaid ? 'P' : 'C');
}
function buildCalendar(mYear, mMonth, mDay)
{  oCal = new Calendar('oCal','spnShipDate','txtPickupDate', 220, 220, mYear, mMonth, mDay);
oCal.imageURL = '/images/cal.jpg';
oCal.popup = true;
oCal.draw();
}
function UpdateCommodityCount(mObj, mintCount)
{  var ohidDestCmdty = getChildNodeByID(mObj, 'hidDestCmdty');
ohidDestCmdty.value = mintCount;
}
function UpdateCommodityCounts()
{  for (var i=1; i<=intNumDestinations; i++)
{  var oParent = GetNodeParent(objForm.hidDestCmdty[i], 'CommodityParent');
var intNumCommodityRows = GetNodeDescendants(oParent, 'CommodityChild').length-1;
UpdateCommodityCount(oParent, intNumCommodityRows);
}
}
function ShowHideRemoveImage(mstrShowHide, mObj, mNode, mSub)
{  var oImage = GetNodeDescendants(mObj, mNode)[mSub];
oImage.className = (mstrShowHide=='Show') ? 'visibleHand' : 'hidden';
}
function DisplayEmailField(mObj, mstrParent, mstrField, mstrSibling)
{  var oParent= GetNodeParent(mObj, mstrParent);
var oNode = getChildNodeByID(oParent, mstrField);
var oSib = getChildNodeByID(oParent, mstrSibling);
oNode.className = (mObj.checked || oSib.checked) ? 'visible' : 'hidden';
}
function ShowHideOptionalNodes(oNode)
{  if (!oNode.hasChildNodes) {return false;}
for (var oChildNode = oNode.firstChild; (oChildNode != null); oChildNode = oChildNode.nextSibling)
{  if (oChildNode.id)
{  if (oChildNode.id.indexOf('optional') >= 0)
{oChildNode.className = (oChildNode.className.indexOf("hidden") >= 0) ? oChildNode.className.replace('hidden', 'visible') : oChildNode.className.replace('visible', 'hidden');}
}
ShowHideOptionalNodes(oChildNode)
}
}
function SetCheckBoxValue(mObj)
{  var oHidField = getRelativeNode('prev', mObj, 'INPUT');
oHidField.value = (mObj.checked) ? 'Y' : '';
}
function GetDestinationIndex(mObj)
{  var oDestArray = GetNodeDescendants(oDestParent, 'DestFormFields');
var oDest = GetNodeParent(mObj, 'DestFormFields');
for (var i=0; i < oDestArray.length; i++)
{  if (oDest == oDestArray[i])
{  return i; }
}
}
function SetSeqVars()
{  // The following "js_.." vars are need for requester_info.js  //if time permits clean up the requester_info code so that this is not necessary  -ulwilli
js_NameSeq = new Array(0,-1,-1);
js_NamePlusSeq = new Array(-1,-1,-1);
js_AddrSeq = new Array(0,-1,-1);
js_CtyStZipSeq = new Array(0,-1,-1);
js_CountrySeq = new Array(0,-1,-1);
js_ContactSeq = new Array(0,-1,-1);
js_PhoneSeq = new Array(0,-1,-1);
js_FaxSeq = new Array(-1,-1,-1);
js_EmailSeq = new Array(0,-1,-1);
}
function ShowHideForms()
{  document.getElementById('divDisplayForm').className= 'visible';
document.getElementById('divResults').className = 'hidden';
}
function ChangeBackgroundColor(mObj)   // this is just for testing purposes remove before installing -ljw
{  mObj.style.backgroundColor = ((mObj.style.backgroundColor=='#ffffff') || (mObj.style.backgroundColor=='rgb(255, 255, 255)')) ? '#d5dff3' : '#ffffff';}
function LookupCommodity(mObj)
{  oStartNode = mObj;
objCommodityLookup = new CommodityLookup();
objCommodityLookup.UpdateFields = SetFieldsFromCommodityLookup;
objCommodityLookup.Display();
}
function SetFieldsFromCommodityLookup()
{  var oCmdty = GetNodeParent(oStartNode, 'CommodityChild');
if (objCommodityLookup.SelectedCount > 1)
{  if (oCmdty.nextSibling.id != 'CommodityChild')
{  objCommodityLookup.blnMaxCmdtyReached = (GetNodeDescendants(GetNodeParent(oStartNode, 'CommodityParent'), 'CommodityChild').length == ConstMaxCommodities);
AddCommodity(getChildNodeByID(GetNodeParent(oStartNode, 'CommodityParent'), 'AddCommodity'));
if (!oCmdty.nextSibling) {return false;}
}
oCmdty = oCmdty.nextSibling;
oStartNode = getChildNodeByID(oCmdty, 'imgCommodityLookup');
}
getChildNodeByID(oCmdty, 'txtPieces').value = objCommodityLookup.HandlingNum;
SetDropDownValue(getChildNodeByID(oCmdty, 'cboHandledType'), objCommodityLookup.HandlingType);
getChildNodeByID(oCmdty, 'txtWeight').value = (objCommodityLookup.Weight != '')?objCommodityLookup.Weight:getChildNodeByID(oCmdty, 'txtWeight').value;
getChildNodeByID(oCmdty, 'chkHazmat').checked = (objCommodityLookup.HazMat=='Y');
SetCheckBoxValue(getChildNodeByID(oCmdty, 'chkHazmat'));
}