<!--

//****************************************************************************************  
//**************************  UTILITY FUNCTIONS *******************************************

  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 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 openWindow(url, w, h) {
      var options = "width=" + w + ",height=" + h + ",";
      options += "resizable=no,scrollbars=no,status=no,";
      options += "menubar=no,toolbar=no,left=0,top=0,directories=no";
      var newWin = window.open(url, 'newWin', options);
      newWin.focus();
    }

  function openWindowScroll(url, w, h) {
      var options = "width=" + w + ",height=" + h + ",";
      options += "resizable=no,scrollbars=yes,status=no,";
      options += "menubar=no,toolbar=no,left=0,top=0,directories=no";
      var newWin = window.open(url, 'newWin', options);
      newWin.focus();
    }

//****************************************************************************************  






//****************************************************************************************  
//**************************  PRODUCT FUNCTIONS *******************************************

  function ConfirmDelete( )
  {
    if( confirm("Are you sure you wish to delete this entry?") )
      return true;
    else
      return false;
  }

  function ConfirmRemove( )
  {
    if( confirm("Are you sure you wish to remove this item from your cart?") )
      return true;
    else
      return false;
  }


  function CheckAddProduct( )
  {
    if( document.product.intColor ) 
    {
      if( document.product.intColor.value == 0 )
      {
        alert("You must select a color.");
        return false;
      }
    }

    var intQty = document.product.intQty.value;  
    if( !IsNumeric(intQty) || intQty <= 0 )
    {
      alert("You have entered an invalid quantity.");
      return false;
    }

    return true;
  }
//****************************************************************************************  


//****************************************************************************************  
//**************************  SHOPPING CART FUNCTIONS ************************************


  function CheckLogin( )
  {
    if( document.accountlogin.strEmail.value == "" || document.accountlogin.strEmail.value.search("@") == -1  || document.accountlogin.strEmail.value.indexOf(".") == -1 ) 
    {
      alert("You must enter a valid email address.");
      return false;
    }
    if( document.accountlogin.strPass.value == "" )
    {
      alert("You must enter a password.");
      return false;
    }
    return true;
  } 


  function CheckPassword( )
  {
    if( document.lostpassword.strEmail.value == "" || document.lostpassword.strEmail.value.search("@") == -1  || document.lostpassword.strEmail.value.indexOf(".") == -1 ) 
    {
      alert("You must enter a valid email address.");
      return false;
    }    
  }


  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 CheckAccount( )
  {
    if( document.contact.strEmail.value == "" || document.contact.strEmail.value.search("@") == -1  || document.contact.strEmail.value.indexOf(".") == -1 ) 
    {
      alert("You must enter an e-mail address."); 
      return false;
    }
    if( document.contact.strPassword ) 
    {
      if( document.contact.strPassword.value == ""  ||  document.contact.strPassword2.value == "" ) 
      {
        alert("You must enter a password, and then re-type it.");
        return false;
      }
      if( document.contact.strPassword.value != document.contact.strPassword2.value ) 
      {
        alert("Your passwords don't match.");
        return false;
      }
    }
    if( document.contact.strFname.value == "" ) 
    {
      alert("You must enter a first name for billing."); 
      return false;
    }
    if( document.contact.strLname.value == "" ) 
    {
      alert("You must enter a last name for billing."); 
      return false;
    }
    if( document.contact.strAddress1.value == "" ) 
    {
      alert("You must enter an address for billing."); 
      return false;
    }
    if( document.contact.strCity.value == "" ) 
    {
      alert("You must enter a city for billing."); 
      return false;
    }
    var i = document.contact.strCountry.selectedIndex 
    if( document.contact.strCountry.options[i].value != "US" )
    {
      if( document.contact.strProvince.value == "" ) 
      {
        alert("You must enter a province for billing.");
        return false;
      }
      if( document.contact.strZip.value == "" ) 
      {
        alert("You must enter a ZIP for billing."); 
        return false;
      }
    }
    else
    {
      if( document.contact.strState.value == "" ) 
      {
        alert("You must enter a state for billing."); 
        return false;
      }     
      if( document.contact.strZip.value == "" ) 
      {
        alert("You must enter a ZIP for billing."); 
        return false;
      }      
    }
    if( document.contact.strDphone.value == "" ) 
    {
      alert("You must enter a daytime phone number for billing."); 
      return false;
    }
    if( document.contact.intDeliver[1].checked )
    {
      if( document.contact.strSFname.value == "" ) 
      {
        alert("You must enter a first name for shipping."); 
        return false;
      }
      if( document.contact.strSLname.value == "" ) 
      {
        alert("You must enter a last name for shipping."); 
        return false;
      }
      if( document.contact.strSAddress1.value == "" ) 
      {
        alert("You must enter an address for shipping."); 
        return false;
      }
      if( document.contact.strSCity.value == "" ) 
      {
        alert("You must enter a city for shipping."); 
        return false;
      }

      var j = document.contact.strSCountry.selectedIndex 
      if( document.contact.strSCountry.options[j].value != "US" )
      {
        if( document.contact.strSProvince.value == "" ) 
        {
          alert("You must enter a province for shipping.");
          return false;
        }
        if( document.contact.strSZip.value == "" ) 
        {
          alert("You must enter a ZIP for shipping."); 
          return false;
        }
      }
      else
      {
        if( document.contact.strSState.value == "" ) 
        {
          alert("You must enter a state for shipping."); 
          return false;
        }     
        if( document.contact.strSZip.value == "" ) 
        {
          alert("You must enter a ZIP for shipping."); 
          return false;
        }        
      }
      if( document.contact.strSDphone.value == "" ) 
      {
        alert("You must enter a daytime phone number for shipping."); 
        return false;
      }
    }
    if( !CheckPOBox() )
      return false;
    return true;
  }

  
  function CheckPayment( )
  {
    if( document.payment.intPayType == 1 ) 
    {
      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 == "" )
      {
        alert("You must enter a valid credit card number.");
        return false;
      }
      if( i == 3 ) // Amex requires 15 digits
      {
        if( document.payment.strCardnum.value.length != 15 )
        {
          alert("You must enter a valid 15-digit credit card number.");
          return false;
        }
      }
      if( i < 3 ) // VISA and MASTERCARD
      {
        if( 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;
    }
    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 ClearCardData( )
  {
    document.forms[0].strCardnum.value = "";
    document.forms[0].strCVV2.value = "";
    document.forms[0].intExpMonth.selectedIndex = 0;
    document.forms[0].intExpYear.selectedIndex = 0;
    document.forms[0].intCardType.selectedIndex = 0;
  }


  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.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 an 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;
      }
    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( !CheckPOBox() )
      return false;
    return true;
  }


  function UploadFiles( )
  {
    var i, strName, strFile, strVal, intFiles;
    strName  = new Array(5);
    strFile  = new Array(5);
    intFiles = 0;
  
    for( i = 1; i <= 5; i++ )
    {
      strVal = "document.upload.strFile" + i + ".value;";
      strName[ i ] = eval( strVal );
      if( strName[ i ] != "" )  intFiles++;
      strVal = "document.upload.strName" + i + ".value = strName[ i ];";
      eval( strVal );          
    }

    if( intFiles > 0 )
      return true;           
    else
    {
      alert("You haven't selected any files to upload.");
      return false;
    }
  }


//****************************************************************************************  
// -->