﻿ function Validate(theForm){
  
  if (theForm.IDX1.value == ""){
   alert("Please enter a origin zip-code.");
   theForm.IDX1.focus();
   return (false);
   }

  if (theForm.IDX2.value == ""){
   alert("Please enter a destination zip-code.");
   theForm.IDX2.focus();
   return (false);
   }

  if (theForm.IDX3.value == ""){
   alert("Please enter the number of pieces.");
   theForm.IDX3.focus();
   return (false);
   }

  var checkOK = "0123456789";
  var checkStr = theForm.IDX3.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    if (ch == ".")
    {
      allNum += ".";
      decPoints++;
    }
    else
      allNum += ch;
  }
  if (!allValid)
  {
    alert("Please check the piece count.");
    theForm.IDX3.focus();
    return (false);
  }
  
  
  if (theForm.IDX4.value == ""){
   alert("Please enter the total weight.");
   theForm.IDX4.focus();
   return (false);
   }

  var checkOK = "0123456789";
  var checkStr = theForm.IDX4.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    if (ch == ".")
    {
      allNum += ".";
      decPoints++;
    }
    else
      allNum += ch;
  }
  if (!allValid)
  {
    alert("Please check the weight.");
    theForm.IDX4.focus();
    return (false);
  }
  
  
  if (theForm.IDX4.value > 14000){
   alert("Weight limit exceeded!\n\nPlease contact our Air Ground Logistics Division\nat (800)716-7151 to get an accurate rate for\nshipments weighing over 14,000 lbs.");
   theForm.IDX4.focus();
   return (false);
   }

  

  return (true);
}


 function CkPickupDate(){
  if (document.thisQuote.PickupDate.selectedIndex == 0){
   document.thisQuote.PickupTime.disabled = true;
   document.thisQuote.PickupTime.options[0].selected = true;
   }
  else {
   document.thisQuote.PickupTime.disabled = false;
    if (document.thisQuote.PickupDate.selectedIndex == 1){
     document.thisQuote.PickupTime.options[0].selected = true;
     }
    else {
     document.thisQuote.PickupTime.options[1].selected = true;
    }
  }  
 }
 
 function CkDeliverDate(){
  if (document.thisQuote.DeliverDate.selectedIndex == 0){
   document.thisQuote.DeliverTime.disabled = true;
   document.thisQuote.DeliverTime.options[0].selected = true;
   }
  else {
   document.thisQuote.DeliverTime.disabled = false;
   document.thisQuote.DeliverTime.options[1].selected = true;
  }  
 }
 
  function openit(sURL){
  if (typeof(popupWin) != "object"){
   popupWin = window.open(sURL, 'newwin', 'scrollbars=no, toolbar=no, directories=no, menu bar=no, resizable=no, status=yes, width=300, height=350');
  } else {
  if (!popupWin.closed){ 
   popupWin.location.href = sURL;
  } else {
   popupWin = window.open(sURL, 'newwin', 'scrollbars=no, toolbar=no, directories=no, menu bar=no, resizable=no, status=yes, width=300, height=350');
  }
  }
  popupWin.focus();
  }

