<!--

     var findWindow = null ;
     var isNS = (navigator.appName=="Netscape") ;
     var myBrowser = (isNS) ? "NS":"IE" ;
     var myCart = "" ;

     var strVer = navigator.appVersion ;
     var strShow = (isNS)?"show":"visible" ;
     var scrWidth = screen.width ;
     var intWidth = 0 ;
     var strWidth = "" ;

         window.defaultStatus = "GourmetSleuth.com" ;

// ************************************************************************************************
// Function used throughout GourmetSleuth.com.
// ************************************************************************************************

// ================================================================================================
// This function is used in Customer.asp and called by the OnChange property of the Country drop-
// down menu. The idea is to allow the user to select any country and have the page detect non-USA
// destinations so that US Postal Service rates can be shown, rather than UPS rates for delivery
// within the USA.
// ================================================================================================

function changeCtry(thisTag){
         var thisCtry = eval("document.GSCART." + thisTag) ;
         var ctryIdx = thisCtry.selectedIndex ;

// ------------------------------------------------------------------------------------------------
// Get out if the user was on a choice and picked the drop-down header.
// ------------------------------------------------------------------------------------------------

         if (ctryIdx == 0){ return ; }

// ------------------------------------------------------------------------------------------------
// First things first: Check to see if the buyer is shipping anything to themselves. If they are,
// the value of BuyerSelf will be True. We need to know this because it tells us whether or not we
// can expect Shipping details.
// ------------------------------------------------------------------------------------------------

         if (document.GSCART.BuyerSelf.value == "True"){
             buyerSelf = true ;
            }
         else { buyerSelf = false ; }

// ------------------------------------------------------------------------------------------------
// Although we might abandon this routine because shipping information has superceded any further
// action, we can still adjust the State drop-down selection if appropriate. If the user has picked
// any country other than "0" (=USA), pre-select State to be "ZZ" (=International).
// ------------------------------------------------------------------------------------------------

         arrTag = thisTag.split("_") ;

         var stateTag = eval("document.GSCART." + arrTag[0] + "_States_" + arrTag[2]) ;

         if (thisCtry[ctryIdx].value != "0"){
             if (thisCtry[ctryIdx].value == "_pick_"){
                 stateTag.value = "_pick_" ;
                }
             else { stateTag.value = "ZZ" ; }
            }

// ------------------------------------------------------------------------------------------------
// But if the buyer picked the USA, we need to ensure the State choice is appropriate. So, we must
// take a look at the State drop-down choice and if the code is not one of the recognised state's
// codes, we must ask the user to "Select a state". Otherwise, leave the choice alone.
// ------------------------------------------------------------------------------------------------

         else { nonUSA = "AB,BC,MB,NB,NF,NT,NS,NU,ON,PE,QC,SK,YT,ZZ" ;
                if (nonUSA.indexOf(stateTag.value) >= 0){
                    stateTag.value = "_pick_" ;
                   }
              }

// ------------------------------------------------------------------------------------------------
// If buyerSelf is False, and thisTag is a Billing tag, we can bounce out. There is no point in
// setting any properties to ensure a recalc. of shipping rates if the buyer has bought something
// for a recipient. That shipping method will be handled separately. So, split the tag and find out
// if it's "Bill"
// ------------------------------------------------------------------------------------------------

         if ((!buyerSelf) && (arrTag[0] == "Bill")){ return ; }

// ------------------------------------------------------------------------------------------------
// We can now check to see if the buyer has checked the "Shipping same as Billing" details checkbox
// which will only appear if buyerSelf is true. The shipping section is hidden if the buyer is not
// buying anything for themselves.
// ------------------------------------------------------------------------------------------------

         if (buyerSelf){
             var copyBilling = document.GSCART.CopyBill ;

             if (copyBilling.checked){
                 shipAsBill = true ;
                }
             else { shipAsBill = false ; }
            }

// ------------------------------------------------------------------------------------------------
// Before proceeding with any further analysis, and if the buyer has bought something for themself,
// we must look at shipping related details. If the user has already started to enter shipping info
// any change to billing details can be ignored.
// ------------------------------------------------------------------------------------------------

         if (buyerSelf){
             if (arrTag[0] == "Bill"){
                 shipCtry = eval("document.GSCART.Ship" + "_Ctry_" + arrTag[2]) ;
                 if (shipCtry.selectIndex > 0){ return ; }
                }
            }

         var zipTag = eval("document.GSCART." + arrTag[0] + "_Zip") ;

// ------------------------------------------------------------------------------------------------
// Let's see if the buyer has bought something for themselves and changed some shipping related
// information. If they have, set the "ship same as bill" checkbox (set or not) to "unchecked" as
// the buyer has just defined their shipping details to be different from billing.
// ------------------------------------------------------------------------------------------------

         if (thisTag.indexOf("Ship") >= 0){
             if (buyerSelf){
                 document.GSCART.CopyBill.checked = false ;
                }
            }

// ------------------------------------------------------------------------------------------------
// If the buyer has changed their Billing country choice, we must first look at the shipping
// details, if there are any, before we set parameters and submit this page. If there are no
// shipping details, the buyer is obviously not buying for themselves, so any change in country
// is purely for billing details. There is no need to process the page.
// ------------------------------------------------------------------------------------------------

         if (thisTag.indexOf("Bill") >= 0){
             if (!buyerSelf){ return ; }

// ------------------------------------------------------------------------------------------------
// If we get this far we know the buyer is buying something for themselves. Now we need to take
// notice of the shipping details. Basically, if there is any choice in the Shipping State drop-
// down menu, we know the buyer has picked a state/province and this act will override any choice
// they now make for Billing, but only if shipAsBill is false.
// ------------------------------------------------------------------------------------------------

             if (!shipAsBill){
                 var shipState = eval("document.GSCART.Ship_States_" + arrTag[2]) ;
                 var shipIdx = shipState.selectedIndex ;

                 if (shipIdx != 0){ return ; }
                }
            }

         document.GSCART.KeyVal.value = thisTag ;
         document.GSCART.ItmVal.value = thisCtry[ctryIdx].value ;
         document.GSCART.TagName.value = thisTag
         document.GSCART.Action.value = "CTRY" ;
         }

function changeState(thisTag){
         var shipTag = eval("document.GSCART." + thisTag) ;
         var shipIdx = shipTag.selectedIndex ;

// ------------------------------------------------------------------------------------------------
// Get out if the user was on a choice and picked the drop-down header.
// ------------------------------------------------------------------------------------------------

         if (shipIdx == 0){ return ; }

// ------------------------------------------------------------------------------------------------
// First things first: Check to see if the buyer is shipping anything to themselves. If they are,
// the value of BuyerSelf will be True. We need to know this because it tells us whether or not we
// can expect Shipping details.
// ------------------------------------------------------------------------------------------------

         if (document.GSCART.BuyerSelf.value == "True"){
             buyerSelf = true ;
            }
         else { buyerSelf = false ; }

// ------------------------------------------------------------------------------------------------
// Find out what state the buyer chose.
// ------------------------------------------------------------------------------------------------

         pickState = shipTag[shipIdx].value ;

// ------------------------------------------------------------------------------------------------
// Let's see if the user picked "International" (state code="ZZ"). If they did, we can set the ctry
// code to "_pick_" and return from here without setting any further parameters. If they chose any
// Canadian provinces, it would be nice to set the country code to 67, other set it to 0=USA.
// ------------------------------------------------------------------------------------------------

         arrTag = thisTag.split("_") ;

         var thisCtry = eval("document.GSCART." + arrTag[0] + "_Ctry_" + arrTag[2]) ;

         if (pickState === "ZZ" || pickState === "_pick_"){
             thisCtry.value = "_pick_" ;
             return ;
            }

         provinceCanada = "AB,BC,MB,NB,NF,NT,NS,NU,ON,PE,QC,SK,YT" ;

         if (provinceCanada.indexOf(pickState) >= 0){
             thisCtry.value = "67" ;
            }
         else { thisCtry.value = "0" ; }

// ------------------------------------------------------------------------------------------------
// If buyerSelf is False, and thisTag is a Billing tag, we can bounce out. There is no point in
// setting any properties to ensure a recalc. of shipping rates if they buyer has bought something
// for a recipient. That shipping method will be handled separately. So, split the tag and find out
// if it's "Bill"
// ------------------------------------------------------------------------------------------------

         if ((!buyerSelf) && (arrTag[0] == "Bill")){ return ; }

// ------------------------------------------------------------------------------------------------
// Before proceeding with any further analysis, and if the buyer has bought something for themself,
// we must look at shipping related details. If the user has already started to enter shipping info
// any change to billing details can be ignored.
// ------------------------------------------------------------------------------------------------

         if (buyerSelf){
             if (arrTag[0] == "Bill"){
                 //shipState = eval("document.GSCART.Ship" + "_States_" + arrTag[2]) ;
                 //if (shipState.selectIndex > 0){ return ; }
                }
            }

// ------------------------------------------------------------------------------------------------
// Now establish the list of Canadian "state" codes and find out if the chosen state matches any.
// ------------------------------------------------------------------------------------------------

         provinceCanada = "AB,BC,MB,NB,NF,NT,NS,NU,ON,PE,QC,SK,YT" ;
         canadaIdx = provinceCanada.indexOf(pickState) ;

// ------------------------------------------------------------------------------------------------
// If the chosen state is a Canadian province, we can set the Country code to 67, regardless of the
// country code already selected. This ensures we do not get a conflict between the state and its
// country code. This will avoid any errors with the USPS interface.
// ------------------------------------------------------------------------------------------------

         if (canadaIdx >= 0){
             thisCtry.value = 67 ;
            }
         else { thisCtry.value = 0 } ;

// ------------------------------------------------------------------------------------------------
// Now check to see if the buyer bought something for themselves. If they did not, we do not want
// to change these and page values if they merely changed their billing details. We MUST NOT affect
// the shipping process by changing Billing detail.
// ------------------------------------------------------------------------------------------------

         if ((!buyerSelf) && (thisTag.indexOf("Bill") >= 0)){ return ; }

// ------------------------------------------------------------------------------------------------
// We can now check to see if the buyer has checked the "Shipping same as Billing" details checkbox
// which will only appear if buyerSelf is true. The shipping section is hidden if the buyer is not
// buying anything for themselves.
// ------------------------------------------------------------------------------------------------

         if (buyerSelf){
             var copyBilling = document.GSCART.CopyBill ;

             if (copyBilling.checked){
                 shipAsBill = true ;
                }
             else { shipAsBill = false ; }
            }

// ------------------------------------------------------------------------------------------------
// Let's see if the buyer has bought something for themselves and changed some shipping related
// information. If they have, set the "ship same as bill" checkbox (set or not) to "unchecked" as
// the buyer has just defined their shipping details to be different from billing.
// ------------------------------------------------------------------------------------------------

         if (thisTag.indexOf("Ship") >= 0){
             if (buyerSelf){
                 document.GSCART.CopyBill.checked = false ;
                }
            }

         if ((thisTag.indexOf("Bill") >=0) && (buyerSelf) && (!shipAsBill)){
             var shipState = eval("document.GSCART.Ship_States_" + arrTag[2]) ;
             var shipIdx = shipState.selectedIndex ;

             if (shipState[shipIdx].value != "_pick_"){ return ; }
            }

         document.GSCART.KeyVal.value = thisTag ;
         document.GSCART.ItmVal.value = pickState ;
         document.GSCART.TagName.value = thisTag ;
         document.GSCART.Action.value = "STATE" ;
         }

function checkEmail(thisEmail){

         if (window.RegExp){
             var reg1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)" ;
             var reg2str = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$" ;
             var reg1 = new RegExp(reg1str) ;
             var reg2 = new RegExp(reg2str) ;

             if (!reg1.test(thisEmail.value) && reg2.test(thisEmail.value)) return true ;
             return false ;
            }

         else { if(str.indexOf("@") >= 0) return true ;
                return false ;
              }
         }

function checkZip(testZip){
         testZip = testZip.replace(/[ ]/g, "") ;
         errorMsg = "Invalid Zip Code: Make sure your zip\nis correct. No Shipping To PO Boxes." ;

         if (testZip == ""){
             alert(errorMsg) ;
             return false ;
            }

         if ((testZip.length != 5) && (testZip.length != 10)){
             alert(errorMsg) ;
             return false ;
            }

         if (testZip <= 0){
             alert(errorMsg) ;
             return false ;
            }

         if (isNaN(testZip)){
             if (testZip.length >= 6){
                 zipDash = testZip.indexOf("-") ;

                 if (zipDash > 0){
                     zipParts = testZip.split("-") ;
                     zipPart5 = zipParts[0] ;
                     zipPart4 = zipParts[1] ;

                     if (zipPart5 == 0){
                         alert(errorMsg) ;
                         return false ;
                        }

                     if (zipPart4 == 0){
                         alert(errorMsg) ;
                         return false ;
                        }

                     if (zipPart5.length < 5){
                         alert(errorMsg) ;
                         return false ;
                        }

                     if (zipPart4.length < 4){
                         alert(errorMsg) ;
                         return false ;
                        }

                     if (!isNaN(zipPart5) && !isNaN(zipPart4)){ return true ; }
                    }
                }

             alert(errorMsg) ;
             return false ;
            }

         return true ;
         }

function recalcShip(){
         recalcTag = document.GSCART.TagName.value ;
         recalcMethod = document.GSCART.Action.value ;

         if (recalcTag.indexOf("Recip") < 0){
             copyBillDetail() ;
            }

         if (document.GSCART.BuyerSelf.value == "True"){
             if (document.GSCART.Ship_States_0.value == "_pick_"){
                 alert("Please select your 'Ship-To' state.") ;
                 return ;
                }
            }

         switch (recalcMethod){

// ------------------------------------------------------------------------------------------------
// This case checks the condition for a change in Country that has triggered this action. make sure
// the buyer did not select "Choose a Country" rather than a real choice.
// ------------------------------------------------------------------------------------------------

                case "CTRY":
                     var thisCtry = eval("document.GSCART." + recalcTag) ;
                     document.GSCART.submit() ;
                     break ;

                case "STATE":
                     var shipTag = eval("document.GSCART." + recalcTag) ;
                     var shipIdx = shipTag.selectedIndex ;

                     pickState = shipTag[shipIdx].value ;

// ------------------------------------------------------------------------------------------------
// Before proceeding, we must first check to see if the user is required to enter a zip code. This
// is essential for certain destinations in order for USPS to be able to price shipping. Typically
// military and US territories will require a zip code.
// ------------------------------------------------------------------------------------------------

                     requireZip = "AA,AE,AK,AP,AS,GU,HI,MH,MP,NT,PR,PW,VI,AA,AE,AK,AL,AP,AR,AS,AZ," +
                                  "CA,CO,CT,DC,DE,FL,GA,GU,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MH,MI," +
                                  "MN,MO,MP,MS,MT,NC,ND,NE,NH,NJ,NM,NT,NV,NY,OH,OK,OR,PA,PR,PW,RI," +
                                  "SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY,YT" ;

                     stateIdx = requireZip.indexOf(pickState) ;
                     arrTag = recalcTag.split("_") ;

// ------------------------------------------------------------------------------------------------
// If the state the buyer picked is one in the requireZip list, we can go back to the page and see
// if they actually entered a zip code. If not, send them an error message.
// ------------------------------------------------------------------------------------------------

                     if (stateIdx >= 0){
                         if (arrTag[0] == "Recip"){
                             thisZip = eval("document.GSCART.Zip_" + arrTag[2])  ;
                            }
                         else { thisZip = eval("document.GSCART." + arrTag[0] + "_Zip") ; }

                         if (!checkZip(thisZip.value)){
                             thisZip.focus() ;
                             thisZip.select() ;
                             return ;
                            }
                        }

                     document.GSCART.submit() ;
                     break ;

                default:
                     document.GSCART.submit() ;
                     break ;
                }
         }

function setZip(thisTag){

// ------------------------------------------------------------------------------------------------
// First unbundle the incoming tag from the form "<Bill|Ship|Recip>_States_x"
// ------------------------------------------------------------------------------------------------

         arrTag = thisTag.split("_")

// ------------------------------------------------------------------------------------------------
// If the tag is a "Bill" tag, we must take a look at the shipping side of life to see if the buyer
// has entered shipping detail. If they have, abandon this function because a change to the billing
// zip code should have no effect on the customer's need to recalculate shipping costs.
// ------------------------------------------------------------------------------------------------

         if (arrTag[0] == "Bill"){
             //var shipState = eval("document.GSCART.Ship_States_" + arrTag[2]) ;
             //var stateIdx = shipState.selectedIndex ;
             //if (stateIdx != 0){ return ; }
            }

// ------------------------------------------------------------------------------------------------
// So the Shipping state has now been chosen, hence the buyer may have calculated their shipping
// costs. So we can now proceed to mark the page with values that will prevent the buyer from
// moving to the next stage of checkout without first calculating shipping.
// ------------------------------------------------------------------------------------------------

         var stateTag = eval("document.GSCART." + thisTag) ;
         var stateIdx = stateTag.selectedIndex ;

         pickState = stateTag[stateIdx].value ;

// ------------------------------------------------------------------------------------------------
// We know there has been a change to the Shipping zip code, but we can ignore this change if the
// buyer has chosen "International", Hawaii, Alaska or US Territories as their state. If this is
// true, we can abandon this function because USPS does not care about these zip/post codes.
// ------------------------------------------------------------------------------------------------

         //ignoreStates = "AK,AS,GU,HI,MH,MP,NT,PR,PW,VI,YT" ;

         //if (ignoreStates.indexOf(pickState) < 0){ return ; }

         document.GSCART.KeyVal.value = thisTag ;
         document.GSCART.ItmVal.value = pickState ;
         document.GSCART.TagName.value = thisTag ;
         document.GSCART.Action.value = "STATE" ;
         }

// -->