var frm;

function hideElementsIE()
{  hide("reftype0")
   if ((objForm.hidShowMult.value == "Y")&&(objForm.hidSubmitted.value != "Y")) {
      hide("reftype1")
      hide("reftype2")
      hide("reftype3")
      hide("reftype4")
      hide("reftype5")
      hide("reftype6")
      hide("reftype7")
      hide("reftype8")
      hide("reftype9")
   }
}

function showElementsIE()
{  show("reftype0")
   if ((objForm.hidShowMult.value == "Y")&&(objForm.hidSubmitted.value != "Y")) {
      show("reftype1")
      show("reftype2")
      show("reftype3")
      show("reftype4")
      show("reftype5")
      show("reftype6")
      show("reftype7")
      show("reftype8")
      show("reftype9")
   }
}


function GoMultiple()
{  objForm.hidSubmitted.value = 'Y'
   objForm.hidShowMult.value = 'Y'
   objForm.multChange.value = 'Y'
   objForm.submit()
}

function AllRefType()
{  objForm.reftype1.options[objForm.reftype0.options.selectedIndex].selected = 1
   objForm.reftype2.options[objForm.reftype0.options.selectedIndex].selected = 1
   objForm.reftype3.options[objForm.reftype0.options.selectedIndex].selected = 1
   objForm.reftype4.options[objForm.reftype0.options.selectedIndex].selected = 1
   objForm.reftype5.options[objForm.reftype0.options.selectedIndex].selected = 1
   objForm.reftype6.options[objForm.reftype0.options.selectedIndex].selected = 1
   objForm.reftype7.options[objForm.reftype0.options.selectedIndex].selected = 1
   objForm.reftype8.options[objForm.reftype0.options.selectedIndex].selected = 1
   objForm.reftype9.options[objForm.reftype0.options.selectedIndex].selected = 1
}

function UpdateStatus(chkBox)
{
   if (chkBox.checked)
   {  if (chkBox.name == 'chkCancel')
      {  if (objForm.chkDelivered.checked)
         {  objForm.chkDelivered.click()    }
 	      if (objForm.chkDelayed.checked)
 	      {  objForm.chkDelayed.click()         }
         objForm.hidNotifyBy.value = 'C'
      }
      else
      {  if (objForm.chkCancel.checked)
         {  objForm.chkCancel.click()       }
         objForm.hidNotifyBy.value = 'E'
      }
   }
   else
   {  if ((chkBox.name == 'chkCancel') ||
       ( !(objForm.chkDelivered.checked) &&
         !(objForm.chkDelayed.checked) ) )
      {  objForm.hidNotifyBy.value = 'S'    }
   }
}

function Validate()
{  var blnNoRef = true
   var x = 0
   var t = 1
   var objRefNum
   var objRefType

   if (blnQuoteIdSignon == "False") {
      if (objForm.refno1 == null) {
         t = 1
         objForm.hidShowMult.value = 'N'
      }
      else {
         t=4
      }

      for (i = 0; i < t; i++) {
         objRefNum  = eval('objForm.refno' + i)
         objRefType = eval('objForm.reftype' + i)

         if (objRefNum.value != '') {
            blnNoRef = false
            if (objRefType.options.selectedIndex == 0) {
               if (!(ValidABFPro(objRefNum))) {
                  if (objForm.hidShowMult.value == 'Y') {
                     return warnInvalid(objRefNum, 'Invalid ABF pro number entered for reference ' + (i + 1) + ' - make sure you have selected the correct reference type.')
                  }
                  else {
                     return warnInvalid(objRefNum, 'Invalid ABF pro number entered - make sure you have selected the correct reference type.')
                  }
               }
            }
         }
      }

      if (blnNoRef)
      {   return warnInvalid(objForm.refno0, 'A reference number must be entered to track your shipment.') }
   }

   if (blnQuoteIdSignon == "False")
   {  if ((strAcctIn != "") && (strPswdIn != ""))
      {  if (objForm.txtEmail.value == '')
         {  if ((objForm.chkDelivered.checked) || (objForm.chkDelayed.checked))
            {  return warnInvalid(objForm.txtEmail, 'An E-mail address must be entered to setup notification.')  }
         }
         else
         {  if (!ValidEMail(objForm.txtEmail.value))
            {  return warnInvalid(objForm.txtEmail, 'Please verify that you have entered a valid E-mail address. A valid address is similar in format to webmaster@abfs.com and contains no spaces.') }
         }
      }
      else
      {  if (objForm.txtEmail.value == '')
         {  if ((objForm.chkDelivered.checked) || (objForm.chkDelayed.checked))
            {  return warnInvalid(objForm.txtEmail, 'An E-mail address must be entered to setup notification.') }
         }
         else
         {  if (!ValidEMail(objForm.txtEmail.value))
            {  return warnInvalid(objForm.txtEmail, 'Please verify that you have entered a valid E-mail address. A valid address is similar in format to webmaster@abfs.com and contains no spaces.') }
         }
	   }
   }

   return true;
}

function SubmitForm()
{
   if (Validate())
   {
      var strRefType
      var objRefType
      var blnDisplayWait = true

      objRefType = eval('objForm.reftype0')
      if (typeof objRefType.options != "undefined")
      {
         if (objForm.refno1 != null)
         {
            for (i = 0; i < 10; i++)
            {
               objRefType = eval('objForm.reftype' + i)
               strRefType = objRefType.options.selectedIndex
               if (strRefType == '9'|| strRefType == '10' || strRefType == '11' || strRefType == '12' || strRefType == '13')
                  {
                      blnDisplayWait = true;
                      if (((objForm.chkDelivered.checked) || (objForm.chkDelayed.checked) || (objForm.chkCancel.checked) ||
                           (objForm.chkException.checked) || (objForm.chkStatusChange.checked)) && objForm.hidShowMult.value == 'Y')
                      {
                        alert('E-mail notification will only be setup for ABF shipments.')
                        break
                      }
                  }
            }
         }
         else
         {
            objRefType = eval('objForm.reftype0')
            strRefType = objRefType.options.selectedIndex
            if (strRefType == '9'|| strRefType == '10' || strRefType == '11' || strRefType == '12' || strRefType == '13')
            {
               blnDisplayWait = true;
            }
         }
         if (blnDisplayWait == true)
         {
            DisplayWait('Your tracking request is being processed.\nPlease stand by.');
         }
      }

      objForm.hidSubmitted.value = 'Y';
      objForm.submit();
   }
}

function init() {
   var i = 1
   objForm = document.frmTrack

   if (document.getElementById("Edit1")) {
      document.getElementById("Edit1").className = "visible"
   }
   if (document.getElementById("Edit2")) {
      document.getElementById("Edit2").className = "visible"
   }

   do {
      if (eval('document.getElementById("Summary' + i + '")')) {
         eval('document.getElementById("Summary' + i + '")').className = "visible"
         i++
      }
      else {
         i=0
      }
   }
   while (i > 0)

   initFormForSubmit();
}