<!-- 


  function checkAddCart( )
  {
    if( document.addtocart.colorID )
    {
      if( document.addtocart.colorID.value == 0 ) 
      {
        alert("You must choose a color for this product.");
        return false;
      }
    }    
 
    if( document.addtocart.sizeID )
    {
      if( document.addtocart.sizeID.value == 0 ) 
      {
        alert("You must choose a size for this product.");
        return false;
      }
    }     

    var nQty = document.addtocart.intQty.value;
    if( nQty == "" || isNaN(nQty) || nQty == 0 )
    {
      alert("You have entered an invalid quantity.");
      return false;
    }
    return true;
  }
  
  
  function checkAddCartCorp()
  {
    var nQty = document.addtocart.intQty.value;
    if( nQty == "" || isNaN(nQty) || nQty == 0 )
    {
      alert("You have entered an invalid quantity.");
      return false;
    }
    return true;  
  }


 function CheckAddress( )
  {
    if( document.billaddress.strFname.value == "" ) 
    {
      alert("You must enter a first name for billing."); 
      return false;
    }
    if( document.billaddress.strLname.value == "" ) 
    {
      alert("You must enter a last name for billing."); 
      return false;
    }
    if( document.billaddress.strAddress1.value == "" ) 
    {
      alert("You must enter an address for billing."); 
      return false;
    }
    if( document.billaddress.strCity.value == "" ) 
    {
      alert("You must enter a city for billing."); 
      return false;
    }
    if( document.billaddress.strState.value == "" ) 
    {
      alert("You must enter a state for billing."); 
      return false;
    }     
    if( document.billaddress.strZip.value == "" ) 
    {
      alert("You must enter a ZIP for billing."); 
      return false;
    }
    if( document.billaddress.strDphone.value == "" ) 
    {
      alert("You must enter a daytime phone number for billing."); 
      return false;
    }
    if( document.billaddress.strEmail.value == "" || document.billaddress.strEmail.value.search("@") == -1  || document.billaddress.strEmail.value.indexOf(".") == -1 ) 
    {
      alert("You must enter a valid e-mail address."); 
      return false;
    }
    if( document.billaddress.strEmail2 )
    {
      if( document.billaddress.strEmail.value != document.billaddress.strEmail2.value ) 
      {
        alert("Your e-mail addresses do not match.");
        return false;
      }
    }
    if( document.billaddress.intDeliver[1].checked )
    {
      if( document.billaddress.strSFname.value == "" ) 
      {
        alert("You must enter a first name for shipping."); 
        return false;
      }
      if( document.billaddress.strSLname.value == "" ) 
      {
        alert("You must enter a last name for shipping."); 
        return false;
      }
      if( document.billaddress.strSAddress1.value == "" ) 
      {
        alert("You must enter an address for shipping."); 
        return false;
      }
      if( document.billaddress.strSCity.value == "" ) 
      {
        alert("You must enter a city for shipping."); 
        return false;
      }

      if( document.billaddress.strSState.value == "" ) 
      {
        alert("You must enter a state for shipping."); 
        return false;
      }
      if( document.billaddress.strSZip.value == "" ) 
      {
        alert("You must enter a ZIP for shipping."); 
        return false;
      }

      if( document.billaddress.strSDphone.value == "" ) 
      {
        alert("You must enter a daytime phone number for shipping."); 
        return false;
      }
    }
    if( document.billaddress.strPassword ) 
    {
      if( document.billaddress.strPassword.value != ""  &&  document.billaddress.strPassword2.value == "" ) 
      {
        alert("You must enter a password, and then re-type it.");
        return false;
      }
      if( document.billaddress.strPassword.value != document.billaddress.strPassword2.value ) 
      {
        alert("Your passwords don't match.");
        return false;
      }
    }
    if( !CheckPOBox() )
      return false;
    return true;
  }


    function ConfirmRemove( )
    {
      if( confirm("Are you sure you wish to remove this item from your cart?") ) 
        return true;
      else
        return false;
    }



    function CheckEmployeeOrder( )
    {
      if( document.billaddress.strFname.value == "" ) 
      {
        alert("You must enter an Event name and/or Company."); 
        return false;
      }
     //removed 3/26/2009, replaced 8/31/2009
      if( document.billaddress.strLname.value == "" ) 
      {
        alert("You must provide the name of the person receiving the items."); 
        return false;
      }    
/*       if( document.billaddress.strExt.value == "" )
      {
        alert("You must enter an extension number.");
        return false;
      }*/
      if( document.billaddress.strTHD.value == "" )
      {
        alert("You must enter a THD Assoc./Broker.");
        return false;
      }
      if( document.billaddress.strDeliverBy.value == "" )
      {
        alert("You must specify the date that the order is needed.)");
        return false;
      }      

      return true;
    }



    function Modify( contID )
    {
      var url = "./cart.asp?nID=2&contID=" + contID;
      openWindow(url, 500, 300);
    }

    function CheckoutModify( contID )
    {
      var url = "./checkout.asp?nID=12&contID=" + contID;
      openWindow(url, 500, 300);
    }

    function InvoiceModify( orderID, contID )
    {
      var url = "./orders.asp?nID=6&orderID=" + orderID + "&contID=" + contID;
      openWindow(url, 500, 300);
    }

    function AdminModify( contID )
    {
//      alert("MODIFY");
      var url = "./company-shop.asp?nID=12&contID=" + contID;
      openWindow(url, 500, 300);
    }


    function EmpModify( contID )
    {
      var url = "./employee-shop.asp?nID=12&contID=" + contID;
      openWindow(url, 500, 300);
    }
    
    function CorpModify( contID )
    {
      var url = "./corporate-shop.asp?nID=12&contID=" + contID;
      openWindow(url, 500, 300);
    }    
    

    function InvoiceAddMisc( orderID )
    {
      var url = "./orders.asp?nID=11&orderID=" + orderID;
      openWindow(url, 500, 300);
    }    



  function CheckPayment( )
  {
    var i = document.payment.intCardType.selectedIndex; 
    if( document.payment.intCardType.options[i].value == 0 )
    {
      alert("You must choose a credit card type.");
      return false;
    }
    if( document.payment.strCardnum.value == "" || document.payment.strCardnum.value.length != 16 )
    {
      alert("You must enter a valid 16-digit credit card number.");
      return false;
    }
    if( document.payment.strCardnum.value.search("-") != -1 || document.payment.strCardnum.value.search(" ") != -1 ) 
    {
      alert("You must enter your credit card number without blank spaces or dashes.");
      return false;
    } 

    var j = document.payment.intExpMonth.selectedIndex;
    if( document.payment.intExpMonth.options[j].value == 0 )
    {
      alert("You must enter the expiration month of your credit card.");
      return false;
    }

    var k = document.payment.intExpYear.selectedIndex; 
    if( document.payment.intExpYear.options[k].value == 0 )
    {
      alert("You must enter the expiration year of your credit card.");
      return false;
    } 

    if( !CheckCreditCardExp() ) 
      return false;

    var fOrderTotal = parseFloat( document.payment.fOrderTotal.value );
    if( isNaN( fOrderTotal ) )
    {
      alert("There is a problem with your order total.");
      return false;
    }
    else
    {
      if( fOrderTotal <= 0.0 ) 
      {
        alert("There is a problem with your order total.");
        return false;
      }
    }
    return true;
  }


  function CheckAdminPayment( )
  {
    if( !document.payment.intPayType[1].checked  ) 
    {
      var i = document.payment.intCardType.selectedIndex; 
      if( document.payment.intCardType.options[i].value == 0 )
      {
        alert("You must choose a credit card type.");
        return false;
      }
      if( document.payment.strCardnum.value == "" || document.payment.strCardnum.value.length != 16 )
      {
        alert("You must enter a valid 16-digit credit card number.");
        return false;
      }
      if( document.payment.strCardnum.value.search("-") != -1 || document.payment.strCardnum.value.search(" ") != -1 ) 
      {
        alert("You must enter your credit card number without blank spaces or dashes.");
        return false;
      } 

      var j = document.payment.intExpMonth.selectedIndex;
      if( document.payment.intExpMonth.options[j].value == 0 )
      {
        alert("You must enter the expiration month of your credit card.");
        return false;
      }

      var k = document.payment.intExpYear.selectedIndex; 
      if( document.payment.intExpYear.options[k].value == 0 )
      {
        alert("You must enter the expiration year of your credit card.");
        return false;
      } 

      if( !CheckCreditCardExp() ) 
        return false;

      var fOrderTotal = parseFloat( document.payment.fOrderTotal.value );
      if( isNaN( fOrderTotal ) )
      {
        alert("There is a problem with your order total.");
        return false;
      }
      else
      {
        if( fOrderTotal <= 0.0 ) 
        {
          alert("There is a problem with your order total.");
          return false;
        }
      }
    }
    return true;
  }



  function CheckEmpPayment( )
  {
    if( document.payment.intPayType[0].checked  ) 
    {
      var i = document.payment.intCardType.selectedIndex; 
      if( document.payment.intCardType.options[i].value == 0 )
      {
        alert("You must choose a credit card type.");
        return false;
      }
      if( document.payment.strCardnum.value == "" || document.payment.strCardnum.value.length != 16 )
      {
        alert("You must enter a valid 16-digit credit card number.");
        return false;
      }
      if( document.payment.strCardnum.value.search("-") != -1 || document.payment.strCardnum.value.search(" ") != -1 ) 
      {
        alert("You must enter your credit card number without blank spaces or dashes.");
        return false;
      } 

      var j = document.payment.intExpMonth.selectedIndex;
      if( document.payment.intExpMonth.options[j].value == 0 )
      {
        alert("You must enter the expiration month of your credit card.");
        return false;
      }

      var k = document.payment.intExpYear.selectedIndex; 
      if( document.payment.intExpYear.options[k].value == 0 )
      {
        alert("You must enter the expiration year of your credit card.");
        return false;
      } 

      if( !CheckCreditCardExp() ) 
        return false;

      var fOrderTotal = parseFloat( document.payment.fOrderTotal.value );
      if( isNaN( fOrderTotal ) )
      {
        alert("There is a problem with your order total.");
        return false;
      }
      else
      {
        if( fOrderTotal <= 0.0 ) 
        {
          alert("There is a problem with your order total.");
          return false;
        }
      }
    }
    if( document.payment.strPromo.value == "" ) 
    {
      alert("You must enter a promotional code.");
      return false;
    }
    return true;
  }



  function CheckCreditCardExp( )
  {
    var bValid  = 0;
    var dtToday = new Date();
    var nMonth  = document.payment.intExpMonth.value;
    var nYear   = document.payment.intExpYear.value;

    if( nYear < dtToday.getFullYear() )
     bValid = 0;
    else
    {
     if( nMonth >= (dtToday.getMonth()+1)  &&  nYear >= dtToday.getFullYear() )
       bValid = 1;
     else
       if( nMonth <= (dtToday.getMonth()+1)  &&  nYear > dtToday.getFullYear() )
         bValid = 1;
       else
         bValid = 0;
    }

    if( bValid )
    {
      return true;
    }
    else
    {
      alert( "Your credit card has expired." );
      return false;
    }
  }



  function CheckOrdersLogin( )
  {
    if (document.loginform.strUser.value == "") 
    {
      alert("You must enter your username.");
      return false;
    }
    if (document.loginform.strPass.value == "")
    {
      alert("You must enter a password.");
      return false;
    }
    return true;
  } 



    function ConfirmDeleteOrder( )
    {
      if( confirm("Are you sure you wish to delete this order?") ) 
        return true;
      else
        return false;
    }


    function CheckNotes( )
    {
      if( document.payment.txtNotes.value == "" )
      {
        alert("You cannot save any empty notes field.");
        return false;
      }
    }


    function FufillmentBilled( orderID )
    {
      if( orderID != 0  &&  document.payment.bBilled.checked ) 
      {
        var url = "./orders.asp?nID=3&orderID=" + orderID + "&a=1";
        if( confirm("Are you sure that you wish to mark this order as billed?\n\n(The customer will be e-mailed a reciept.)") )
          window.location.href = url;
        else
          document.payment.bBilled.checked = false;
      }
    }



    function FufillmentShipped( orderID )
    {
      if( orderID != 0  &&  document.payment.bShipped.checked ) 
      {      
/*        if( document.payment.strTrackingNum.value == "" )
        {
          alert("You cannot mark an order shipped until you've entered a tracking number.");
          document.payment.bShipped.checked = false;
          return false;
        }                      
      */
        var url = "./orders.asp?nID=3&orderID=" + orderID + "&a=2";
        if( confirm("Are you sure that you wish to mark this order as shipped?\n\n(The customer will be e-mailed a reciept.)") )
          window.location.href = url;
        else
          document.payment.bShipped.checked = false;
      }
      if( orderID != 0  &&  !document.payment.bShipped.checked ) 
      {
        var url = "./orders.asp?nID=3&orderID=" + orderID + "&a=6";
        if( confirm("Are you sure that you wish to mark this order as NOT shipped?") )
          window.location.href = url;
        else
          document.payment.bShipped.checked = true;
      }
    }


    function FufillmentDenied( orderID )
    {
      if( orderID != 0  &&  document.payment.bPayDenied.checked ) 
      {
        var url = "./orders.asp?nID=3&orderID=" + orderID + "&a=3";
        if( confirm("Are you sure that you wish to mark this order as 'Payment Denied'?") )
          window.location.href = url;
        else
          document.payment.bPayDenied.checked = false;
      }
    }



    function IsNumeric( strString )
    {
     var strValidChars = "0123456789.-";
     var strChar;
     var blnResult = true;

     if (strString.length == 0) return false;
     //  test strString consists of valid characters listed above
     for (i = 0; i < strString.length && blnResult == true; i++)
        {
        strChar = strString.charAt(i);
        if (strValidChars.indexOf(strChar) == -1)
           {
           blnResult = false;
           }
        }
     return blnResult;
    }



    function checkDateFilter( )
    {
      var mm1 = document.filter.mm1.value;
      var dd1 = document.filter.dd1.value;
      var yy1 = document.filter.yy1.value;
      var mm2 = document.filter.mm2.value;
      var dd2 = document.filter.dd2.value;
      var yy2 = document.filter.yy2.value;

      if( !IsNumeric(mm1) || !IsNumeric(dd1) || !IsNumeric(yy1) ) 
      {
        alert("You have entered an invalid beginning date.");
        return false;
      }
      if( !IsNumeric(mm2) || !IsNumeric(dd2) || !IsNumeric(yy2) ) 
      {
        alert("You have entered an invalid ending date.");
        return false;
      }      

      if( document.filter.mm1.value == "" || document.filter.dd1.value == "" || document.filter.yy1.value == "" )      
      {
        alert("You must enter a complete beginning date.");
        return false;
      }
      if( document.filter.mm2.value == "" || document.filter.dd2.value == "" || document.filter.yy2.value == "" ) 
      {
        alert("You must enter a complete ending date.");
        return false;
      }
      return true;
    }


    function CheckOrderNumSearch( )
    {
      if( !IsNumeric( document.ordernum.strOrder.value ) )
      {
        alert("You have entered an invalid order number.");
        return false;
      }
      return true;
    }



    function CheckPOBox( )
    {
      var sAdd = new Array(4);
      sAdd[0] = document.forms[0].strAddress1.value;
      sAdd[1] = document.forms[0].strAddress2.value;    
      sAdd[2] = document.forms[0].strSAddress1.value;
      sAdd[3] = document.forms[0].strSAddress2.value;

      for( var i=0; i < 4; i++ )
      {
        if( sAdd[i].indexOf("PO ") == 0 || sAdd[i].indexOf("P.O.") == 0 ||  sAdd[i].indexOf("po ") == 0 || sAdd[i].indexOf("p.o.") == 0 )
        {

          if( document.forms[0].intDeliver[1].checked && ( sAdd[i].indexOf("PO ") == -1 && sAdd[i].indexOf("P.O.") == -1 && sAdd[i].indexOf("po ") == -1 && sAdd[i].indexOf("p.o.") == -1) )
            return true;
          else
            if( !confirm("UPS does not deliver to PO Box addresses.\n\nIf your billing information is a PO Box, please also enter a 2nd address in the bottom form using a street address.\n\nClick OK to ignore and go to the next step.\nClick CANCEL to edit your address.") )
              return false;         
        }
      }
      return true;
    }



  function SelectShippingOption( shipID )
  {
    if( document.forms[0].intShip ) 
    {
      if( !isNaN(document.forms[0].intShip.length ) )
      {
        switch( shipID )
        {
          case 0: 
            shipID = 0;
            break;
          case 1: 
            shipID = 2;
            break;
          case 2: 
            shipID = 1;
            break;
          case 3: 
            shipID = 0;
            break;
          case 7:
            shipID = 1;
            break;
          case 8:
            shipID = 0;
            break;
          case 54:
            shipID = 2;
            break;
        }
        if( document.forms[0].intShip[ shipID ] )
          document.forms[0].intShip[ shipID ].checked = true;
      }
      else
      {
        document.delivery.intShip.checked = true;
      }
    }
    return true;
  }
 

  function CheckDelivery( )
  {
    if( document.forms[0].intDelivery )
    {
      if( document.forms[0].intDelivery.value == 0 )
      {
        alert("You must choose a delivery method and price.");
        return false;
      }
      else
        return true;
    }
  }



  function PayDeniedDetail( orderID )
  {
    var url = "../merch/detail.asp?nID=1&orderID=" + orderID;
    openWindow(url, 500, 400);
  }



  function InventoryEdit( pID )
  {
    var url = "../merch/inventory.asp?nID=10&pID=" + pID;
    openWindowScroll(url, 500, 500);
  }


  function ShopCompany(  )
  {
    var url = "../merch/company-shop.asp";
    openWindowScroll(url, 600, 600);
  }



  function ShopCustomer(  )
  {
    var url = "../merch/customer-shop.asp";
    openWindowScroll(url, 600, 600);
  }



 function CheckAdminAddress( )
  {
    if( document.billaddress.strFname.value == "" ) 
    {
      alert("You must enter a first name for billing."); 
      return false;
    }
    if( document.billaddress.strLname.value == "" ) 
    {
      alert("You must enter a last name for billing."); 
      return false;
    }
    if( document.billaddress.strAddress1.value == "" ) 
    {
      alert("You must enter an address for billing."); 
      return false;
    }
    if( document.billaddress.strCity.value == "" ) 
    {
      alert("You must enter a city for billing."); 
      return false;
    }


    var i = document.billaddress.strCountry.selectedIndex; 
    if( document.billaddress.strCountry.options[i].value != "US" )
    {
      if( document.billaddress.strProvince.value == "" ) 
      {
        alert("You must enter a province for billing.");
        return false;
      }
    }
    else
    {
      if( document.billaddress.strState.value == "" ) 
      {
        alert("You must enter a state for billing."); 
        return false;
      }     
      if( document.billaddress.strZip.value == "" ) 
      {
        alert("You must enter a ZIP for billing."); 
        return false;
      }
    }
    if( document.billaddress.strDphone.value == "" ) 
    {
      alert("You must enter a daytime phone number for billing."); 
      return false;
    }
    if( document.billaddress.strEmail.value != "" )
    {
      if(document.billaddress.strEmail.value.search("@") == -1  || document.billaddress.strEmail.value.indexOf(".") == -1 ) 
      {
        alert("You must enter a valid e-mail address."); 
        return false;
      }
    }
    if( document.billaddress.intDeliver[1].checked )
    {
      if( document.billaddress.strSFname.value == "" ) 
      {
        alert("You must enter a first name for shipping."); 
        return false;
      }
      if( document.billaddress.strSLname.value == "" ) 
      {
        alert("You must enter a last name for shipping."); 
        return false;
      }
      if( document.billaddress.strSAddress1.value == "" ) 
      {
        alert("You must enter an address for shipping."); 
        return false;
      }
      if( document.billaddress.strSCity.value == "" ) 
      {
        alert("You must enter a city for shipping."); 
        return false;
      }

      var j = document.billaddress.strSCountry.selectedIndex; 
      if( document.billaddress.strSCountry.options[j].value != "US" )
      {
        if( document.billaddress.strSProvince.value == "" ) 
        {
          alert("You must enter a province for shipping.");
          return false;
        }
      }
      else
      {
        if( document.billaddress.strSState.value == "" ) 
        {
          alert("You must enter a state for shipping."); 
          return false;
        }
        if( document.billaddress.strSZip.value == "" ) 
        {
          alert("You must enter a ZIP for shipping."); 
          return false;
        }
  
      }
      if( document.billaddress.strSDphone.value == "" ) 
      {
        alert("You must enter a daytime phone number for shipping."); 
        return false;
      }
    }
    if( document.billaddress.strPassword ) 
    {
      if( document.billaddress.strPassword.value != ""  &&  document.billaddress.strPassword2.value == "" ) 
      {
        alert("You must enter a password, and then re-type it.");
        return false;
      }
      if( document.billaddress.strPassword.value != document.billaddress.strPassword2.value ) 
      {
        alert("Your passwords don't match.");
        return false;
      }
    }
    if( !CheckPOBox() )
      return false;
    return true;
  }


 function CheckEmpAddress( )
  {
    if( document.billaddress.strFname.value == "" ) 
    {
      alert("You must enter a first name for billing."); 
      return false;
    }
    if( document.billaddress.strLname.value == "" ) 
    {
      alert("You must enter a last name for billing."); 
      return false;
    }
    if( document.billaddress.strAddress1.value == "" ) 
    {
      alert("You must enter an address for billing."); 
      return false;
    }
    if( document.billaddress.strCity.value == "" ) 
    {
      alert("You must enter a city for billing."); 
      return false;
    }


    var i = document.billaddress.strCountry.selectedIndex; 
    if( document.billaddress.strCountry.options[i].value != "US" )
    {
      if( document.billaddress.strProvince.value == "" ) 
      {
        alert("You must enter a province for billing.");
        return false;
      }
    }
    else
    {
      if( document.billaddress.strState.value == "" ) 
      {
        alert("You must enter a state for billing."); 
        return false;
      }     
      if( document.billaddress.strZip.value == "" ) 
      {
        alert("You must enter a ZIP for billing."); 
        return false;
      }
    }
    if( document.billaddress.strDphone.value == "" ) 
    {
      alert("You must enter a daytime phone number for billing."); 
      return false;
    }
    if( document.billaddress.strEmail.value == "" || document.billaddress.strEmail.value.search("@") == -1  || document.billaddress.strEmail.value.indexOf(".") == -1 ) 
    {
      if( !confirm("If you don't supply an email address, you will not receive a receipt for your purchase.\n\nDo you wish to continue?") )
        return false;
    }
    return true;
  }


  function ClearCardData( )
  {
    document.payment.strCardnum.value = "";
    document.payment.intExpMonth.selectedIndex = 0;
    document.payment.intExpYear.selectedIndex = 0;
    document.payment.intCardType.selectedIndex = 0;
  }


  function RecalculateTotal( )
  {
    var x = parseFloat(document.invoice.fOrderTotal.value) + parseFloat(document.invoice.fDelivery.value) + parseFloat(document.invoice.fTax.value);
    document.invoice.fCartTotal.value = formatDecimal(x, true, 2);
  }


  function UpdateShipping( strIn )
  {
    if( document.invoice ) 
    {
      document.invoice.fDelivery.value = strIn;
      RecalculateTotal();
    }
  }



  function formatDecimal(argvalue, addzero, decimaln) 
  {
    var numOfDecimal = (decimaln == null) ? 2 : decimaln;
    var number = 1;

    number = Math.pow(10, numOfDecimal);

    argvalue = Math.round(parseFloat(argvalue) * number) / number;
    // If you're using IE3.x, you will get error with the following line.
    // argvalue = argvalue.toString();
    // It works fine in IE4.
    argvalue = "" + argvalue;

    if (argvalue.indexOf(".") == 0)
      argvalue = "0" + argvalue;

    if (addzero == true) {
      if (argvalue.indexOf(".") == -1)
        argvalue = argvalue + ".";

      while ((argvalue.indexOf(".") + 1) > (argvalue.length - numOfDecimal))
        argvalue = argvalue + "0";
    }

    return argvalue;
  }


  function CheckAddMisc( )
  {
    if( document.product.strItem.value == "" )
    {
      alert("You must enter an item name.");
      return false;
    }   
  
    var nQty = document.product.intQty.value;
    if( nQty == "" || isNaN(nQty) || nQty == 0 )
    {
      alert("You have entered an invalid quantity.");
      return false;
    } 
    
    var fPrice = document.product.fPrice.value;
    if( fPrice == "" || isNaN(fPrice) || fPrice == 0 )
    {
      alert("You have entered an invalid cost.");
      return false;
    }      
  
    return true;
  }
// -->