//=====================================================================||
//               NOP Design JavaScript Shopping Cart                   ||
//                                                                     ||
// For more information on SmartSystems, or how NOPDesign can help you ||
// Please visit us on the WWW at http://www.nopdesign.com              ||
//                                                                     ||
// Javascript portions of this shopping cart software are available as ||
// freeware from NOP Design.  You must keep this comment unchanged in  ||
// your code.  For more information contact FreeCart@NopDesign.com.    ||
//                                                                     ||
// JavaScript Shop Module, V.4.4.0                                     ||
//=====================================================================||
//---------------------------------------------------------------------||
//                       Global Options                                ||
//                      ----------------                               ||
// Shopping Cart Options, you can modify these options to change the   ||
// the way the cart functions.                                         ||
//                                                                     ||
// Language Packs                                                      ||
// ==============                                                      ||
// You may include any language pack before nopcart.js in your HTML    ||
// pages to change the language.  Simply include a language pack with  ||
// a script src BEFORE the <SCRIPT SRC="nopcart.js">... line.          ||
//  For example: <SCRIPT SRC="language-en.js"></SCRIPT>                ||
//                                                                     ||
// Options For Everyone:                                               ||
// =====================                                               ||
// * MonetarySymbol: string, the symbol which represents dollars/euro, ||
//   in your locale.                                                   ||
// * DisplayNotice: true/false, controls whether the user is provided  ||
//   with a popup letting them know their product is added to the cart ||
// * DisplayShippingColumn: true/false, controls whether the managecart||
//   and checkout pages display shipping cost column.                  ||
// * DisplayShippingRow: true/false, controls whether the managecart   ||
//   and checkout pages display shipping cost total row.               ||
// * DisplayTaxRow: true/false, controls whether the managecart        ||
//   and checkout pages display tax cost total row.                    ||
// * TaxRate: number, your area's current tax rate, ie: if your tax    ||
//   rate was 7.5%, you would set TaxRate = 0.075                      ||
// * TaxByRegion: true/false, when set to true, the user is prompted   ||
//   with TaxablePrompt to determine if they should be charged tax.    ||
//   In the USA, this is useful to charge tax to those people who live ||
//   in a particular state, but no one else.                           ||
// * TaxPrompt: string, popup message if user has not selected either  ||
//   taxable or nontaxable when TaxByRegion is set to true.            ||
// * TaxablePrompt: string, the message the user is prompted with to   ||
//   select if they are taxable.  If TaxByRegion is set to false, this ||
//   has no effect. Example: 'Arizona Residents'                       ||
// * NonTaxablePrompt: string, same as above, but the choice for non-  ||
//   taxable people.  Example: 'Other States'                          ||
// * MinimumOrder: number, the minium dollar amount that must be       ||
//   purchased before a user is allowed to checkout.  Set to 0.00      ||
//   to disable.                                                       ||
// * MinimumOrderPrompt: string, Message to prompt users with when     ||
//   they have not met the minimum order amount.                       ||
//                                                                     ||
// Payment Processor Options:                                          ||
// ==========================                                          ||
// * PaymentProcessor: string, the two digit payment processor code    ||
//   for support payment processor gateways.  Setting this field to    ||
//   anything other than an empty string will override your OutputItem ||
//   settings -- so please be careful when receiving any form data.    ||
//   Support payment processor gateways are:                           ||
//    * Authorize.net (an)                                             ||
//    * Worldpay      (wp)                                             ||
//    * LinkPoint     (lp)
//                                                                     ||
// Options For Programmers:                                            ||
// ========================                                            ||
// * OutputItem<..>: string, the name of the pair value passed at      ||
//   checkouttime.  Change these only if you are connecting to a CGI   ||
//   script and need other field names, or are using a secure service  ||
//   that requires specific field names.                               ||
// * AppendItemNumToOutput: true/false, if set to true, the number of  ||
//   each ordered item will be appended to the output string.  For     ||
//   example if OutputItemId is 'ID_' and this is set to true, the     ||
//   output field name will be 'ID_1', 'ID_2' ... for each item.       ||
// * HiddenFieldsToCheckout: true/false, if set to true, hidden fields ||
//   for the cart items will be passed TO the checkout page, from the  ||
//   ManageCart page.  This is set to true for CGI/PHP/Script based    ||
//   checkout pages, but should be left false if you are using an      ||
//   HTML/Javascript Checkout Page. Hidden fields will ALWAYS be       ||
//   passed FROM the checkout page to the Checkout CGI/PHP/ASP/Script  ||
//---------------------------------------------------------------------||
//Options for Everyone:
MonetarySymbol = '£';
DisplayNotice = false;
DisplayShippingColumn = false;
DisplayShippingRow = false;
DisplayTaxRow = true;
TaxRate = 0.2;
TaxByRegion = false;
TaxPrompt = 'For tax purposes, please select if you are an Arizona resident before continuing';
TaxablePrompt = 'Arizona Residents';
NonTaxablePrompt = 'Other States';
MinimumOrder = 0.00;
MinimumOrderPrompt = 'Your order is below our minimum order, please order more before checking out.';

//Payment Processor Options:
PaymentProcessor = '';

//Options for Programmers:
OutputItemId = 'ID_';
OutputItemQuantity = 'QUANTITY_';
OutputItemPrice = 'PRICE_';
OutputItemName = 'NAME_';
OutputItemShipping = 'SHIPPING_';
OutputItemAddtlInfo = 'ADDTLINFO_';
OutputOrderSubtotal = 'SUBTOTAL';
OutputOrderDiscountValue = 'DISCOUNTVALUE';
OutputOrderDiscountPercent = 'DISCOUNTPERCENT';
OutputOrderShipping = 'SHIPPING';
OutputOrderTax = 'TAX';
OutputOrderTotal = 'TOTAL';
OutputDeliverySurcharge = 'DELIVERYSURCHARGE';
AppendItemNumToOutput = true;
HiddenFieldsToCheckout = false;
strUNIT = "";

//=====================================================================||
//---------------------------------------------------------------------||
//    YOU DO NOT NEED TO MAKE ANY MODIFICATIONS BELOW THIS LINE        ||
//---------------------------------------------------------------------||
//=====================================================================||

//---------------------------------------------------------------------||
//                      Language Strings                               ||
//                     ------------------                              ||
// These strings will not be used unless you have not included a       ||
// language pack already.  You should NOT modify these, but instead    ||
// modify the strings in language-**.js where ** is the language pack  ||
// you are using.                                                      ||
//---------------------------------------------------------------------||
if (!bLanguageDefined) {
    strSorry = "I'm Sorry, your cart is full, please proceed to checkout.";
    strAdded = " added to your shopping cart.";
    strRemove = "Click 'Ok' to remove this product from your shopping cart.";
    strILabel = "Product Id";
    strDLabel = "Product Name/Description";
    strQLabel = "Quantity";
    strPLabel = "Price";
    strSLabel = "Shipping";
    strRLabel = "Remove From Cart";
    strRButton = "Remove";
    strSUB = "SUBTOTAL";
    strSHIP = "SHIPPING";
    strTAX = "TAX";
    strTOT = "TOTAL";
    strErrQty = "Invalid Quantity.";
    strNewQty = 'Please enter new quantity:';
    bLanguageDefined = true;
}






//---------------------------------------------------------------------||
// FUNCTION:    CKquantity                                             ||
// PARAMETERS:  Quantity to                                            ||
// RETURNS:     Quantity as a number, and possible alert               ||
// PURPOSE:     Make sure quantity is represented as a number          ||
//---------------------------------------------------------------------||


function CKquantity(checkString) {
    var strNewQuantity = "";

    for (i = 0; i < checkString.length; i++) {
        ch = checkString.substring(i, i + 1);
        if ((ch >= "0" && ch <= "9") || (ch == '.')) strNewQuantity += ch;
    }

    if (strNewQuantity.length < 1) strNewQuantity = "1";
    return (strNewQuantity);
}




//---------------------------------------------------------------------||
// FUNCTION:    ResetDatabase                                     
// PARAMETERS:  n/a                                      		
// RETURNS:     n/a              									
// PURPOSE:     Initiates all 20 cookies             
//---------------------------------------------------------------------||


function ResetDatabase() {
    for (i = 1; i <= 20; i++) {
        strNewOrder = "Order." + i;
        SetCookie(strNewOrder, " ", null, "/");
    }
}




//---------------------------------------------------------------------||
// FUNCTION:    ReadDatabase                                     
// PARAMETERS:  n/a                                      		
// RETURNS:     text list of entire 20 cookies              									
// PURPOSE:     Creates text list from database             
//---------------------------------------------------------------------||


function ReadDatabase() {
    databaseWhole = "";
    for (i = 1; i <= 20; i++) {
        NewOrder = "Order." + i;
        if (GetCookie(NewOrder) != null) {
            databaseWhole += GetCookie(NewOrder);
        }
    }
    return (databaseWhole);
}




//---------------------------------------------------------------------||
// FUNCTION:    WriteDatabase                                     
// PARAMETERS:  n/a                                      		
// RETURNS:     n/a              									
// PURPOSE:     n/a           
//---------------------------------------------------------------------||


function WriteDatabase(iNumberOrdered, databaseArray) {
    //alert ("iNumberOrdered "+iNumberOrdered);
    //alert ("databaseArray "+databaseArray);
    cookieData = "";
    for (i = 0; i <= iNumberOrdered * 6 - 1; i++) {
        cookieData += databaseArray[i] + "|";
    }
    //alert("DATABASE CONTAINS "+cookieData);
    for (i = 1; i <= 20; i++) {
        strNewOrder = "Order." + i;
        SetCookie("NumberOrdered", iNumberOrdered, null, "/");
        SetCookie(strNewOrder, cookieData.substring((i - 1) * 2000, (i - 1) * 2000 + 2000), null, "/");
    }
    //alert("DATABASE READ BACK IN "+ReadDatabase());
}



//---------------------------------------------------------------------||
// FUNCTION:    AddToCart                                              ||
// PARAMETERS:  Form Object                                            ||
// RETURNS:     Cookie to user's browser, with prompt                  ||
// PURPOSE:     Adds a product to the user's shopping cart             ||
//---------------------------------------------------------------------||


function AddToCart(thisForm, priceNum) {
    var iNumberOrdered = 0;
    var bAlreadyInCart = false;
    var notice = "";
    iNumberOrdered = GetCookie("NumberOrdered");

    if (iNumberOrdered == null) {
        iNumberOrdered = 0;
    }
    if (iNumberOrdered == 0) {
        ResetDatabase();
    }

    if (thisForm.ID_NUM == null) strID_NUM = "";
    else strID_NUM = thisForm.ID_NUM.value;

    if (thisForm.NAME == null) strNAME = "";
    else strNAME = thisForm.NAME.value;

    if (thisForm.ADDITIONALINFO == null) {
        strADDTLINFO = "";
    } else {
        strADDTLINFO = thisForm.ADDITIONALINFO[thisForm.ADDITIONALINFO.selectedIndex].value;
        strADDTLINFO = " - " + strADDTLINFO;
    }

    if (thisForm.SUBCODE != null) {
        myString = thisForm.SUBCODE[thisForm.SUBCODE.selectedIndex].value;
        myArray = myString.split("|");
        subCodeText = myArray[0];
        subCodeText = subCodeText.replace('"', "&quot;");
        priceNum = rws(myArray[1]);
        soldIn = rws(myArray[2]);
        strADDTLINFO = subCodeText + strADDTLINFO;
    }

    qtyEach = 0;
    qtyPack = 0;
    qtyCase = 0;
    if (thisForm.EACHQUANTITY) {
        if (thisForm.EACHQUANTITY == null) {
            thisForm.EACHQUANTITY.value = "0";
        }
        qtyEach = parseFloat(thisForm.EACHQUANTITY.value);
    }

    if (thisForm.PACKQUANTITY) {
        if (thisForm.PACKQUANTITY == null) {
            thisForm.PACKQUANTITY.value = "0";
        }
        qtyPack = parseFloat(thisForm.PACKQUANTITY.value);
    }

    if (thisForm.CASEQUANTITY) {
        if (thisForm.CASEQUANTITY == null) {
            thisForm.CASEQUANTITY.value = "0";
        }
        qtyCase = parseFloat(thisForm.CASEQUANTITY.value);
    }

    var quantitySum = 0;
    var namePackQty = 0;

    if (document.getElementById("piecesPack" + priceNum)) {
        piecesPerPack = rws(document.getElementById("piecesPack" + priceNum).innerHTML);
    } else {
        piecesPerPack = "1";
    }

    if (document.getElementById("packsCase" + priceNum)) {
        packsPerCase = rws(document.getElementById("packsCase" + priceNum).innerHTML);
    } else {
        packsPerCase = "1";
    }

    strNAMENoWhiteSpace = rws(strNAME);
    strNAMENumberStart = "";
    for (inc = 1; inc < 5; inc++) {
        if (isNaN(strNAMENoWhiteSpace.substring(inc - 1, inc)) == false) {
            strNAMENumberStart += strNAMENoWhiteSpace.substring(inc - 1, inc);
        } else {
            break;
        }
    }
    strNAMENumberStart = rws(strNAMENumberStart);

    if (soldIn == "c") {
        namePacked = "Case of";
        if (document.getElementById("priceCase" + priceNum)) {
            strPRICE = document.getElementById("priceCase" + priceNum).innerHTML; //strUNIT = "pack";
            if (rws(strPRICE) == "TBA") {
                alert("Sorry, unable to add item(s) to order - Out of Stock");
                return
            };
            if (strNAMENumberStart == "") {
                namePackQty = piecesPerPack;
            } else {
                if (strNAMENumberStart == piecesPerPack) {
                    namePackQty = ""
                }
                if (strNAMENumberStart != piecesPerPack) {
                    namePackQty = piecesPerPack + " - ";
                }
            }
            nameCaseQty = packsPerCase;
            quantitySum += qtyCase;
        } else {
            strPRICE = "9999";
        };
        if (namePackQty > 1) {
            strNAME = namePacked + " " + nameCaseQty + " Packs of " + namePackQty + " " + strNAME;
        } else {
            strNAME = namePacked + " " + nameCaseQty + " Packs of " + strNAME;
        }
        //document.write("here is.."+strNAME);
    }

    if (soldIn == "p" || soldIn == "pc") {
        namePacked = "Pack of";
        if (document.getElementById("pricePack" + priceNum)) {
            strPRICE = document.getElementById("pricePack" + priceNum).innerHTML; //strUNIT = "pack";
            if (rws(strPRICE) == "TBA") {
                alert("Sorry, unable to add item(s) to order - Out of Stock");
                return
            };
            if (strNAMENumberStart == "") {
                namePackQty = piecesPerPack;
            } else {
                if (strNAMENumberStart == piecesPerPack) {
                    namePackQty = ""
                }
                if (strNAMENumberStart != piecesPerPack) {
                    namePackQty = piecesPerPack + " - ";
                }
            }
            quantitySum += qtyPack;
            quantitySum += qtyCase * packsPerCase;
        } else {
            strPRICE = "9999";
        };
        if (piecesPerPack > 1) {
            strNAME = namePacked + " " + namePackQty + " " + strNAME;
        }
        //document.write("here is.."+strNAME);
    }

    if (soldIn == "e" || soldIn == "ep" || soldIn == "epc") {
        namePacked = "";
        namePackQty = "";
        if (document.getElementById("priceEach" + priceNum)) {
            strPRICE = document.getElementById("priceEach" + priceNum).innerHTML; //strUNIT = "pack";
            if (rws(strPRICE) == "TBA") {
                alert("Sorry, unable to add item(s) to order - Out of Stock");
                return
            };
            quantitySum += qtyEach;
            quantitySum += qtyPack * piecesPerPack;
            quantitySum += qtyCase * packsPerCase * piecesPerPack;
        } else {
            strPRICE = "9999";
        };
    }

    myArray = strPRICE.split("£");
    discountedPrice = myArray[1];
    if (discountedPrice) {
        strPRICE = discountedPrice;
    }

    strQUANTITY = quantitySum;

    if (thisForm.SHIPPING == null) strSHIPPING = "0.00";
    else strSHIPPING = thisForm.SHIPPING.value;


    //Is this product already in the cart?  If so, increment quantity instead of adding another.
    database = ReadDatabase();
    databaseArray = database.split("|", iNumberOrdered * 6);

    for (i = 1; i <= iNumberOrdered; i++) {

        if (
        databaseArray[0 + ((i - 1) * 6)] == strID_NUM && databaseArray[2 + ((i - 1) * 6)] == strPRICE && databaseArray[3 + ((i - 1) * 6)] == strNAME && databaseArray[5 + ((i - 1) * 6)] == strADDTLINFO) {

            bAlreadyInCart = true;
            alert("Extra Item(s) added to Order");
            databaseArray[1 + ((i - 1) * 6)] = (parseInt(strQUANTITY) + parseInt(databaseArray[1 + ((i - 1) * 6)])); // ADJUSTS QTY IN DATABASE
            WriteDatabase(iNumberOrdered, databaseArray);
            break;
        }
    }

    if (!bAlreadyInCart) {
        limit = itemLimit();
        if (iNumberOrdered >= limit) {
            confirm("Unable to add further item(s). The order form is full.\nPlease proceed to confirm your order.");
        } else {
            iNumberOrdered++;
            alert("Item(s) added to Order");
            databaseArray[0 + ((iNumberOrdered - 1) * 6)] = strID_NUM;
            databaseArray[1 + ((iNumberOrdered - 1) * 6)] = strQUANTITY;
            databaseArray[2 + ((iNumberOrdered - 1) * 6)] = strPRICE;
            databaseArray[3 + ((iNumberOrdered - 1) * 6)] = strNAME;
            databaseArray[4 + ((iNumberOrdered - 1) * 6)] = strSHIPPING;
            databaseArray[5 + ((iNumberOrdered - 1) * 6)] = strADDTLINFO;
            WriteDatabase(iNumberOrdered, databaseArray);
        }
    }
}


//---------------------------------------------------------------------||
// FUNCTION:    getCookieVal                                           ||
// PARAMETERS:  offset                                                 ||
// RETURNS:     URL unescaped Cookie Value                             ||
// PURPOSE:     Get a specific value from a cookie                     ||
//---------------------------------------------------------------------||


function getCookieVal(offset) {
    var endstr = document.cookie.indexOf(";", offset);

    if (endstr == -1) endstr = document.cookie.length;
    return (unescape(document.cookie.substring(offset, endstr)));
}


//---------------------------------------------------------------------||
// FUNCTION:    FixCookieDate                                          ||
// PARAMETERS:  date                                                   ||
// RETURNS:     date                                                   ||
// PURPOSE:     Fixes cookie date, stores back in date                 ||
//---------------------------------------------------------------------||


function FixCookieDate(date) {
    var base = new Date(0);
    var skew = base.getTime();

    date.setTime(date.getTime() - skew);
}


//---------------------------------------------------------------------||
// FUNCTION:    GetCookie                                              ||
// PARAMETERS:  Name                                                   ||
// RETURNS:     Value in Cookie                                        ||
// PURPOSE:     Retrieves cookie from users browser                    ||
//---------------------------------------------------------------------||


function GetCookie(name) {
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;

    while (i < clen) {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg) return (getCookieVal(j));
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break;
    }

    return (null);
}


//---------------------------------------------------------------------||
// FUNCTION:    SetCookie                                              ||
// PARAMETERS:  name, value, expiration date, path, domain, security   ||
// RETURNS:     Null                                                   ||
// PURPOSE:     Stores a cookie in the users browser                   ||
//---------------------------------------------------------------------||


function SetCookie(name, value, expires, path, domain, secure) {

    var expires = new Date();
    expires.setTime(expires.getTime() + (100 * 365 * 24 * 60 * 60 * 1000));

    document.cookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");
}



//---------------------------------------------------------------------||
// FUNCTION:    DeleteCookie                                           ||
// PARAMETERS:  Cookie name, path, domain                              ||
// RETURNS:     null                                                   ||
// PURPOSE:     Removes a cookie from users browser.                   ||
//---------------------------------------------------------------------||


function DeleteCookie(name, path, domain) {
    if (GetCookie(name)) {
        document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}



//---------------------------------------------------------------------||
// FUNCTION:    MoneyFormat                                            ||
// PARAMETERS:  Number to be formatted                                 ||
// RETURNS:     Formatted Number                                       ||
// PURPOSE:     Reformats Dollar Amount to #.## format                 ||
//---------------------------------------------------------------------||


function moneyFormat(input) {
    var dollars = Math.floor(input);
    var tmp = new String(input);

    for (var decimalAt = 0; decimalAt < tmp.length; decimalAt++) {
        if (tmp.charAt(decimalAt) == ".") break;
    }

    var cents = "" + Math.round(input * 100);
    cents = cents.substring(cents.length - 2, cents.length)
    dollars += ((tmp.charAt(decimalAt + 2) == "9") && (cents == "00")) ? 1 : 0;

    if (cents == "0") cents = "00";

    return (dollars + "." + cents);
}


//---------------------------------------------------------------------||
// FUNCTION:    RemoveFromCart                                         ||
// PARAMETERS:  Order Number to Remove                                 ||
// RETURNS:     Null                                                   ||
// PURPOSE:     Removes an item from a users shopping cart             ||
//---------------------------------------------------------------------||


function RemoveFromCart(RemOrder) {
    if (confirm(strRemove)) {
        iNumberOrdered = GetCookie("NumberOrdered");
        database = ReadDatabase();
        databaseArray = database.split("|", iNumberOrdered * 6);
        databaseArray[0 + ((RemOrder - 1) * 6)] = "";
        databaseArray[1 + ((RemOrder - 1) * 6)] = "";
        databaseArray[2 + ((RemOrder - 1) * 6)] = "";
        databaseArray[3 + ((RemOrder - 1) * 6)] = "";
        databaseArray[4 + ((RemOrder - 1) * 6)] = "";
        databaseArray[5 + ((RemOrder - 1) * 6)] = "";
        databaseArray.splice(RemOrder * 6 - 6, 6)
        WriteDatabase(iNumberOrdered - 1, databaseArray);
        SetCookie("NumberOrdered", iNumberOrdered - 1, null, "/");
        location.href = location.href;
    }
}

function RemoveAllFromCart() {
    NumberOrdered = GetCookie("NumberOrdered");
    for (i = 0; i < NumberOrdered; i++) {
        NewOrder = "Order." + i;
        DeleteCookie(NewOrder, "/");
    }
    SetCookie("NumberOrdered", 0, null, "/");
}

function ChooseRemoveAllFromCart() {
    if (confirm(strRemoveAll)) {
        RemoveAllFromCart();
        //window.location.reload();
    }
}




//---------------------------------------------------------------------||
// FUNCTION:    ChangeQuantity                                         ||
// PARAMETERS:  Order Number to Change Quantity                        ||
// RETURNS:     Null                                                   ||
// PURPOSE:     Changes quantity of an item in the shopping cart       ||
//---------------------------------------------------------------------||


function ChangeQuantity(OrderItem, NewQuantity) {
    if (isNaN(NewQuantity)) {
        alert(strErrQty);
    } else {
        iNumberOrdered = GetCookie("NumberOrdered");
        if (iNumberOrdered == null) {
            iNumberOrdered = 0;
        }
        database = ReadDatabase();
        databaseArray = database.split("|", iNumberOrdered * 6);
        databaseArray[1 + ((OrderItem - 1) * 6)] = NewQuantity;
        WriteDatabase(iNumberOrdered, databaseArray);
        location.href = location.href;
    }
}


//---------------------------------------------------------------------||
// FUNCTION:    GetFromCart                                            ||
// PARAMETERS:  Null                                                   ||
// RETURNS:     Product Table Written to Document                      ||
// PURPOSE:     Draws current cart product table on HTML page          ||
//              **DEPRECATED FUNCTION, USE ManageCart or Checkout**    ||
//---------------------------------------------------------------------||


function GetFromCart(fShipping) {
    ManageCart();
}


//---------------------------------------------------------------------||
// FUNCTION:    RadioChecked                                           ||
// PARAMETERS:  Radio button to check                                  ||
// RETURNS:     True if a radio has been checked                       ||
// PURPOSE:     Form fillin validation                                 ||
//---------------------------------------------------------------------||


function RadioChecked(radiobutton) {
    var bChecked = false;
    var rlen = radiobutton.length;
    for (i = 0; i < rlen; i++) {
        if (radiobutton[i].checked) bChecked = true;
    }
    return bChecked;
}


//---------------------------------------------------------------------||
// FUNCTION:    QueryString                                            ||
// PARAMETERS:  Key to read                                            ||
// RETURNS:     value of key                                           ||
// PURPOSE:     Read data passed in via GET mode                       ||
//---------------------------------------------------------------------||
QueryString.keys = new Array();
QueryString.values = new Array();

function QueryString(key) {
    var value = null;
    for (var i = 0; i < QueryString.keys.length; i++) {
        if (QueryString.keys[i] == key) {
            value = QueryString.values[i];
            break;
        }
    }
    return value;
}

//---------------------------------------------------------------------||
// FUNCTION:    QueryString_Parse                                      ||
// PARAMETERS:  (URL string)                                           ||
// RETURNS:     null                                                   ||
// PURPOSE:     Parses query string data, must be called before Q.S.   ||
//---------------------------------------------------------------------||


function QueryString_Parse() {
    var query = window.location.search.substring(1);
    var pairs = query.split("&");
    for (var i = 0; i < pairs.length; i++) {
        var pos = pairs[i].indexOf('=');
        if (pos >= 0) {
            var argname = pairs[i].substring(0, pos);
            var value = pairs[i].substring(pos + 1);
            QueryString.keys[QueryString.keys.length] = argname;
            QueryString.values[QueryString.values.length] = value;
        }
    }
}


//---------------------------------------------------------------------||
// FUNCTION:    ManageCart                                             ||
// PARAMETERS:  Null                                                   ||
// RETURNS:     Product Table Written to Document                      ||
// PURPOSE:     Draws current cart product table on HTML page          ||
//---------------------------------------------------------------------||


function ManageCart(minimumOrderValueStandard,minimumOrderValueRepAqua,minimumOrderValueCap,deliverySurchargeAmount) {
    var promoCodeObject = checkPassword(readPromoCodeCookie()); //promoCodeObject[1]=discountPercentage.
    var promotionCodeDiscountValue = 0;
    var freeCarriageQualifyPercentage = 0;
    var deliverySurchargeToPay = 0;
    var repAquaGoodsTotalPrice = 0;
    var capGoodsTotalPrice = 0;
    var standardGoodsTotalPrice = 0;
    var iNumberOrdered = 0; //Number of products ordered
    var fTotal = 0; //Total cost of order
    var fTax = 0; //Tax amount
    var fShipping = 0; //Shipping amount
    var strOutput = ""; //String to be written to page
    var bDisplay = true; //Whether to write string to the page (here for programmers)
    iNumberOrdered = GetCookie("NumberOrdered");
    if (iNumberOrdered == null) iNumberOrdered = 0;
    if (bDisplay) strOutput = "<TABLE CLASS='nopcart' width=570px><TR>" + "<TD CLASS='nopheader'><B>" + strILabel + "</B></TD>" + "<TD CLASS='nopheader' width=400px><B>" + strDLabel + "</B></TD>" + "<TD CLASS='nopheader' align='center'><B>" + strQLabel + "</B></TD>" + "<TD CLASS='nopheader' align='center'><B>" + strPLabel + "</B></TD>" + (DisplayShippingColumn ? "<TD CLASS='nopheader' align='center'><B>" + strSLabel + "</B></TD>" : "") + "<TD CLASS='nopheader' align='center'><B>" + strTLabel + "</B></TD>" + "<TD CLASS='nopheader' align='center'><B>" + strRLabel + "</B></TD></TR>";
    if (iNumberOrdered == 0) {
        strOutput += "<TR><TD COLSPAN=6 CLASS='nopentry'><CENTER><BR><B>Your order form is empty</B><BR><BR></CENTER></TD></TR>";
    }
    database = ReadDatabase();
    databaseArray = database.split("|", iNumberOrdered * 6);
    for (i = 1; i <= iNumberOrdered; i++) {
        nameAll = rws(databaseArray[0 + ((i - 1) * 6)]);
        nameStartsWithTwoLetters = nameAll.substring(0, 2);
        if (nameStartsWithTwoLetters == "AQ" || nameStartsWithTwoLetters == "FP" || nameStartsWithTwoLetters == "CP" || nameStartsWithTwoLetters == "LC") {
            repAquaGoodsTotalPrice += (parseInt(databaseArray[1 + ((i - 1) * 6)]) * parseFloat(databaseArray[2 + ((i - 1) * 6)]));
        } else if ((parseInt(nameAll) >= 6794 && parseInt(nameAll) <= 6826) || parseInt(nameAll) == 6839 || parseInt(nameAll) == 6840) {
            capGoodsTotalPrice += (parseInt(databaseArray[1 + ((i - 1) * 6)]) * parseFloat(databaseArray[2 + ((i - 1) * 6)]));
        } else {
            standardGoodsTotalPrice += (parseInt(databaseArray[1 + ((i - 1) * 6)]) * parseFloat(databaseArray[2 + ((i - 1) * 6)]));
        }
        fTotal += (parseInt(databaseArray[1 + ((i - 1) * 6)]) * parseFloat(databaseArray[2 + ((i - 1) * 6)]));
        fShipping += (parseInt(databaseArray[1 + ((i - 1) * 6)]) * parseFloat(databaseArray[4 + ((i - 1) * 6)]));
        if (i == iNumberOrdered) {
            promotionCodeDiscountValue = (fTotal * promoCodeObject[1] / 100);
            minimumOrderValueStandard = minimumOrderValueStandard * (1 / (1 - promoCodeObject[1] / 100));
			minimumOrderValueRepAqua = minimumOrderValueRepAqua * (1 / (1 - promoCodeObject[1] / 100));
			minimumOrderValueCap = minimumOrderValueCap * (1 / (1 - promoCodeObject[1] / 100));
            freeCarriageQualifyPercentage = capGoodsTotalPrice / minimumOrderValueCap + repAquaGoodsTotalPrice / minimumOrderValueRepAqua + standardGoodsTotalPrice / minimumOrderValueStandard;
            if (freeCarriageQualifyPercentage < 1) {
                deliverySurchargeToPay = deliverySurchargeAmount
            }
            if (freeCarriageQualifyPercentage >= 1) {
                deliverySurchargeToPay = 0
            }
		fTax = ((fTotal - promotionCodeDiscountValue + deliverySurchargeToPay) * TaxRate);
        }
        if (bDisplay) {
            strOutput += "<TR><TD CLASS='nopentry'>" + databaseArray[0 + ((i - 1) * 6)] + "</TD>";
            if (databaseArray[5 + ((i - 1) * 6)] == "") strOutput += "<TD CLASS='nopentry'>" + databaseArray[3 + ((i - 1) * 6)] + "</TD>";
            else strOutput += "<TD CLASS='nopentry'>" + databaseArray[3 + ((i - 1) * 6)] + databaseArray[5 + ((i - 1) * 6)] + "</TD>";

            strOutput += "<TD CLASS='nopentry'  align ='center'><INPUT TYPE=TEXT NAME=Q SIZE=2 VALUE='" + databaseArray[1 + ((i - 1) * 6)] + "' onChange='ChangeQuantity(" + i + ", this.value);window.location.reload();'></TD>";
            strOutput += "<TD CLASS='nopentry' align='right'>" + MonetarySymbol + moneyFormat(databaseArray[2 + ((i - 1) * 6)]) + strUNIT + "</TD>";
            strOutput += "<TD CLASS='nopentry' align='right'>" + MonetarySymbol + moneyFormat(databaseArray[1 + ((i - 1) * 6)] * databaseArray[2 + ((i - 1) * 6)]) + "</TD>";
            if (DisplayShippingColumn) {
                if (parseFloat(databaseArray[4 + ((i - 1) * 6)]) > 0) strOutput += "<TD CLASS='nopentry' align='right'>" + MonetarySymbol + moneyFormat(databaseArray[4 + ((i - 1) * 6)]) + strUNIT + "</TD>";
                else strOutput += "<TD CLASS='nopentry'>N/A</TD>";
            }
            strOutput += "<TD CLASS='nopentry' ALIGN=CENTER><input type=checkbox value='" + strRButton + "' onClick='RemoveFromCart(" + i + "); window.location.reload();' class='nopbutton'></TD></TR>";
        }
        if (AppendItemNumToOutput) {
            strFooter = i;
        } else {
            strFooter = "";
        }
    }
    if (bDisplay) {
        strOutput += "<TR><TD CLASS='noptotal' COLSPAN=4><B>" + strSUB + "</B></TD>";
        strOutput += "<TD CLASS='noptotal' COLSPAN=1 align='right'><B>" + MonetarySymbol + moneyFormat(fTotal) + "</B></TD>";
        strOutput += "<TD CLASS='noptotal'></TD>";
        strOutput += "</TR>";
        //////////////////////////	 NEW DISCOUNT ROW 	  
        if (promoCodeObject[1] > 0) {
            strOutput += "<TR><TD CLASS='noptotal' COLSPAN=4><B>DISCOUNT </B>(" + promoCodeObject[1] + "%)</TD>";
            strOutput += "<TD CLASS='noptotal' COLSPAN=1 align='right'><B>-" + MonetarySymbol + moneyFormat(promotionCodeDiscountValue) + "</B></TD>";
            strOutput += "<TD CLASS='noptotal'></TD>";
            strOutput += "</TR>";
        }
        //////////////////////////	 NEW DELIVERY SURCHARGE ROW  
        if (minimumOrderValueStandard != 0) {
            if (freeCarriageQualifyPercentage < 1) {
                if (iNumberOrdered > 0) {
                    strOutput += "<TR><TD CLASS='noptotal' COLSPAN=4><B>CARRIAGE</B> - Spend " + Math.ceil(100 - (freeCarriageQualifyPercentage * 100)) + "% more for free delivery.</TD>";
                } else {
                    strOutput += "<TR><TD CLASS='noptotal' COLSPAN=4><B>CARRIAGE</B></TD>";
                }
            } else {
                strOutput += "<TR><TD CLASS='noptotal' COLSPAN=4><B>CARRIAGE</B> - Qualified for free delivery.</TD>";
            }
            strOutput += "<TD CLASS='noptotal' COLSPAN=1 align='right'><B>" + MonetarySymbol + moneyFormat(deliverySurchargeToPay) + "</B></TD>";
            strOutput += "<TD CLASS='noptotal'></TD>";
            strOutput += "</TR>";
        }
        SetCookie("deliverySurcharge", deliverySurchargeToPay, null, "/");
		
        strOutput += "<TR><TD CLASS='noptotal' COLSPAN=4><B>VAT</B></TD>";
        strOutput += "<TD CLASS='noptotal' COLSPAN=1 align='right'><B>" + MonetarySymbol + moneyFormat(fTax) + "</B></TD>";
        strOutput += "<TD CLASS='noptotal'></TD>";
        strOutput += "</TR>";
        strOutput += "<TR><TD CLASS='noptotal' COLSPAN=4><B>TOTAL</B></TD>";
        strOutput += "<TD CLASS='noptotal' COLSPAN=1 align='right'><B>" + MonetarySymbol + moneyFormat((fTotal - promotionCodeDiscountValue + fShipping + fTax + deliverySurchargeToPay)) + "</B></TD>";
        strOutput += "<TD CLASS='noptotal'></TD></TR>";
        strOutput += "<TR><TD CLASS='noptotal' COLSPAN=2 align='left'>Promo Code: <INPUT TYPE=TEXT NAME=PROMO SIZE=13 VALUE='" + readPromoCodeCookie() + "' onChange='setPromoCodeCookie(this.value);window.location.reload();'/>&nbsp;&nbsp;" + promoCodeObject[0] + "<input type='button' align='right' value='Enter' onClick='window.location.reload();'/></TD><TD CLASS='noptotal' COLSPAN=2 align='right'><input type='button' value='Clear Form' onClick='ChooseRemoveAllFromCart(); window.location.reload();'/></TD><TD CLASS='noptotal' COLSPAN=2 align='right'><input type='button' value='Re-Calculate' /></TD></TR>";
        strOutput += "</TABLE>";
		
        limit = itemLimit();
        if (i > limit) {
            strOutput += "<BR /><B>The Order is full (" + limit + " items max).</B><BR />Please press the &quot;Continue&quot; button below to proceed.<BR />If you would like to purchase more items, simply confirm this order and then start another."
        }
    }
    g_TotalCost = (fTotal - promotionCodeDiscountValue + fShipping + fTax + deliverySurchargeToPay);
    document.write(strOutput);
    document.close();
}

//---------------------------------------------------------------------||
// FUNCTION:    ValidateCart                                           ||
// PARAMETERS:  Form to validate                                       ||
// RETURNS:     true/false                                             ||
// PURPOSE:     Validates the managecart form                          ||
//---------------------------------------------------------------------||
var g_TotalCost = 0;

function ValidateCart(theForm) {
    if (TaxByRegion) {
        if (!RadioChecked(eval("theForm." + OutputOrderTax))) {
            alert(TaxPrompt);
            return false;
        }
    }

    if (MinimumOrder >= 0.01) {
        if (g_TotalCost < MinimumOrder) {
            alert(MinimumOrderPrompt);
            return false;
        }
    }

    return true;
}

//---------------------------------------------------------------------||
// FUNCTION:    CheckoutCart                                           ||
// PARAMETERS:  Null                                                   ||
// RETURNS:     Product Table Written to Document                      ||
// PURPOSE:     Draws current cart product table on HTML page for      ||
//              checkout.                                              ||
//---------------------------------------------------------------------||


function CheckoutCart(minimumOrderValueStandard,minimumOrderValueRepAqua,minimumOrderValueCap,deliverySurchargeAmount) {
    var promoCodeObject = checkPassword(readPromoCodeCookie()); //promoCodeObject[1]=discountPercentage.
    var promotionCodeDiscountValue = 0;
    var freeCarriageQualifyPercentage = 0;
    var deliverySurchargeToPay = 0;
    var repAquaGoodsTotalPrice = 0;
    var capGoodsTotalPrice = 0;
    var standardGoodsTotalPrice = 0;
    var iNumberOrdered = 0; //Number of products ordered
    var fTotal = 0; //Total cost of order
    var fTax = 0; //Tax amount
    var fShipping = 0; //Shipping amount
    var strOutput = ""; //String to be written to page
    var bDisplay = true; //Whether to write string to the page (here for programmers)
    iNumberOrdered = GetCookie("NumberOrdered");
    if (iNumberOrdered == null) iNumberOrdered = 0;
    if (bDisplay) strOutput = "<TABLE CLASS='nopcart' width=570px><TR>" + "<TD CLASS='nopheader'><B>" + strILabel + "</B></TD>" + "<TD CLASS='nopheader' width=400px><B>" + strDLabel + "</B></TD>" + "<TD CLASS='nopheader' align='center'><B>" + strQLabel + "</B></TD>" + "<TD CLASS='nopheader' align='center'><B>" + strPLabel + "</B></TD>" + (DisplayShippingColumn ? "<TD CLASS='nopheader' align='center'><B>" + strSLabel + "</B></TD>" : "") + "<TD CLASS='nopheader' align='center'><B>" + strTLabel + "</B></TD></TR>";
    if (iNumberOrdered == 0) {
        strOutput += "<TR><TD COLSPAN=6 CLASS='nopentry'><CENTER><BR><B>Your order form is empty</B><BR><BR></CENTER></TD></TR>";
    }
    database = ReadDatabase();
    databaseArray = database.split("|", iNumberOrdered * 6);
    for (i = 1; i <= iNumberOrdered; i++) {
        nameAll = rws(databaseArray[0 + ((i - 1) * 6)]);
        nameStartsWithTwoLetters = nameAll.substring(0, 2);
        if (nameStartsWithTwoLetters == "AQ" || nameStartsWithTwoLetters == "FP" || nameStartsWithTwoLetters == "CP" || nameStartsWithTwoLetters == "LC") {
            repAquaGoodsTotalPrice += (parseInt(databaseArray[1 + ((i - 1) * 6)]) * parseFloat(databaseArray[2 + ((i - 1) * 6)]));
        } else if ((parseInt(nameAll) >= 6794 && parseInt(nameAll) <= 6826) || parseInt(nameAll) == 6839 || parseInt(nameAll) == 6840) {
            capGoodsTotalPrice += (parseInt(databaseArray[1 + ((i - 1) * 6)]) * parseFloat(databaseArray[2 + ((i - 1) * 6)]));
        } else {
            standardGoodsTotalPrice += (parseInt(databaseArray[1 + ((i - 1) * 6)]) * parseFloat(databaseArray[2 + ((i - 1) * 6)]));
        }
        fTotal += (parseInt(databaseArray[1 + ((i - 1) * 6)]) * parseFloat(databaseArray[2 + ((i - 1) * 6)]));
        fShipping += (parseInt(databaseArray[1 + ((i - 1) * 6)]) * parseFloat(databaseArray[4 + ((i - 1) * 6)]));
        if (i == iNumberOrdered) {
            promotionCodeDiscountValue = (fTotal * promoCodeObject[1] / 100);
            minimumOrderValueStandard = minimumOrderValueStandard * (1 / (1 - promoCodeObject[1] / 100));
			minimumOrderValueRepAqua = minimumOrderValueRepAqua * (1 / (1 - promoCodeObject[1] / 100));
			minimumOrderValueCap = minimumOrderValueCap * (1 / (1 - promoCodeObject[1] / 100));
            freeCarriageQualifyPercentage = capGoodsTotalPrice / minimumOrderValueCap + repAquaGoodsTotalPrice / minimumOrderValueRepAqua + standardGoodsTotalPrice / minimumOrderValueStandard;
            if (freeCarriageQualifyPercentage < 1) {
                deliverySurchargeToPay = deliverySurchargeAmount
            }
            if (freeCarriageQualifyPercentage >= 1) {
                deliverySurchargeToPay = 0
            }
		fTax = ((fTotal - promotionCodeDiscountValue + deliverySurchargeToPay) * TaxRate);
        }
        if (bDisplay) {
            strOutput += "<TR><TD CLASS='nopentry2'>" + databaseArray[0 + ((i - 1) * 6)] + "</TD>";
            if (databaseArray[5 + ((i - 1) * 6)] == "") strOutput += "<TD CLASS='nopentry2'>" + databaseArray[3 + ((i - 1) * 6)] + "</TD>";
            else strOutput += "<TD CLASS='nopentry2'>" + databaseArray[3 + ((i - 1) * 6)] + databaseArray[5 + ((i - 1) * 6)] + "</TD>";

            strOutput += "<TD CLASS='nopentry2'  align ='center'>" + databaseArray[1 + ((i - 1) * 6)] + "</TD>";
            strOutput += "<TD CLASS='nopentry2' align='right'>" + MonetarySymbol + moneyFormat(databaseArray[2 + ((i - 1) * 6)]) + strUNIT + "</TD>";
            strOutput += "<TD CLASS='nopentry2' align='right'>" + MonetarySymbol + moneyFormat(databaseArray[1 + ((i - 1) * 6)] * databaseArray[2 + ((i - 1) * 6)]) + "</TD>";
            if (DisplayShippingColumn) {
                if (parseFloat(databaseArray[4 + ((i - 1) * 6)]) > 0) strOutput += "<TD CLASS='nopentry2' align='right'>" + MonetarySymbol + moneyFormat(databaseArray[4 + ((i - 1) * 6)]) + strUNIT + "</TD>";
                else strOutput += "<TD CLASS='nopentry2'>N/A</TD>";
            }
        }
        if (AppendItemNumToOutput) {
            strFooter = i;
        } else {
            strFooter = "";
        }
            strOutput += "<input type=hidden name='" + OutputItemId + strFooter + "' value='" + databaseArray[0 + ((i - 1) * 6)] + "'>";
            strOutput += "<input type=hidden name='" + OutputItemQuantity + strFooter + "' value='" + databaseArray[1 + ((i - 1) * 6)] + "'>";
            strOutput += "<input type=hidden name='" + OutputItemPrice + strFooter + "' value='" + databaseArray[2 + ((i - 1) * 6)] + "'>";
            strOutput += "<input type=hidden name='" + OutputItemName + strFooter + "' value='" + databaseArray[3 + ((i - 1) * 6)] + "'>";
            strOutput += "<input type=hidden name='" + OutputItemShipping + strFooter + "' value='" + databaseArray[4 + ((i - 1) * 6)] + "'>";
            strOutput += "<input type=hidden name='" + OutputItemAddtlInfo + strFooter + "' value='" + databaseArray[5 + ((i - 1) * 6)] + "'>";
    }
	   		strOutput += "<input type=hidden name='" + OutputDeliverySurcharge + "' value='" + moneyFormat(parseInt(GetCookie("deliverySurcharge"))) + "'>";
    if (bDisplay) {
        strOutput += "<TR><TD CLASS='noptotal' COLSPAN=4><B>" + strSUB + "</B></TD>";
        strOutput += "<TD CLASS='noptotal' COLSPAN=1 align='right'><B>" + MonetarySymbol + moneyFormat(fTotal) + "</B></TD>";
        strOutput += "</TR>";
        //////////////////////////	 NEW DISCOUNT ROW 	  
        if (promoCodeObject[1] > 0) {
            strOutput += "<TR><TD CLASS='noptotal' COLSPAN=4><B>DISCOUNT </B>(" + promoCodeObject[1] + "%)</TD>";
            strOutput += "<TD CLASS='noptotal' COLSPAN=1 align='right'><B>-" + MonetarySymbol + moneyFormat(promotionCodeDiscountValue) + "</B></TD>";
            strOutput += "</TR>";
        }
        //////////////////////////	 NEW DELIVERY SURCHARGE ROW  
        if (GetCookie("deliverySurcharge") > 0) {
            strOutput += "<TR><TD CLASS='noptotal' COLSPAN=4><B>CARRIAGE</B></TD>";
            strOutput += "<TD CLASS='noptotal' COLSPAN=1 align='right'><B>" + MonetarySymbol + moneyFormat(parseInt(GetCookie("deliverySurcharge"))) + "</B></TD>";
            strOutput += "</TR>";
        }
		
        strOutput += "<TR><TD CLASS='noptotal' COLSPAN=4><B>VAT</B></TD>";
        strOutput += "<TD CLASS='noptotal' COLSPAN=1 align='right'><B>" + MonetarySymbol + moneyFormat(fTax) + "</B></TD>";
        strOutput += "</TR>";
        strOutput += "<TR><TD CLASS='noptotal' COLSPAN=4><B>TOTAL</B></TD>";
        strOutput += "<TD CLASS='noptotal' COLSPAN=1 align='right'><B>" + MonetarySymbol + moneyFormat((fTotal - promotionCodeDiscountValue + fShipping + fTax + deliverySurchargeToPay)) + "</B></TD>";
        strOutput += "</TABLE>";
		strOutput += "<input type=hidden name='" + OutputOrderSubtotal + "' value='" + MonetarySymbol + moneyFormat(fTotal) + "'>";
		strOutput += "<input type=hidden name='" + OutputOrderDiscountValue + "' value='" + moneyFormat(promotionCodeDiscountValue) + "'>";
		strOutput += "<input type=hidden name='" + OutputOrderDiscountPercent + "' value='" + promoCodeObject[1] + "'>";
		strOutput += "<input type=hidden name='" + OutputOrderShipping + "' value='" + MonetarySymbol + moneyFormat(fShipping) + "'>";
		strOutput += "<input type=hidden name='" + OutputOrderTax + "'      value='" + MonetarySymbol + moneyFormat(fTax) + "'>";
		strOutput += "<input type=hidden name='" + OutputOrderTotal + "'    value='" + MonetarySymbol + moneyFormat((fTotal - promotionCodeDiscountValue + fShipping + fTax + parseInt(GetCookie("deliverySurcharge")))) + "'>";     
    }
    document.write(strOutput);
    document.close();
}




function CheckForm(theform) {
    var bMissingFields = false;
    var strFields = "";

    if (theform.b_first.value == '') {
        bMissingFields = true;
        strFields += "     Customer Info: First Name\n";
    }
    if (theform.b_last.value == '') {
        bMissingFields = true;
        strFields += "     Customer Info: Last Name\n";
    }
    if (theform.b_name.value == '') {
        bMissingFields = true;
        strFields += "     Customer Info: Company Name\n";
    }
    if (theform.b_addr.value == '') {
        bMissingFields = true;
        strFields += "     Customer Info: Address\n";
    }
    if (theform.b_city.value == '') {
        bMissingFields = true;
        strFields += "     Customer Info: City\n";
    }
    if (theform.b_state.value == '') {
        bMissingFields = true;
        strFields += "     Customer Info: County\n";
    }
    if (theform.b_zip.value == '') {
        bMissingFields = true;
        strFields += "     Customer Info: Post Code\n";
    }
    if (theform.b_phone.value == '') {
        bMissingFields = true;
        strFields += "     Customer Info: Phone\n";
    }
    if (theform.b_email.value == '') {
        bMissingFields = true;
        strFields += "     Customer Info: Email\n";
    }

    if (bMissingFields) {
        alert("I'm sorry, but you must provide the following field(s) before continuing:\n" + strFields);
        return false;
    }

    return true;
}

//=====================================================================||
//               END NOP Design SmartPost Shopping Cart                ||
//=====================================================================||




function itemLimit2() {
/*if (browser_type == " Netscape" && (browser_version >= 4)) {
	document.write("<link rel='stylesheet' href='mozilla.css' type='text/css'>");
}else if (browser_type == " Microsoft Internet Explorer" && (browser_version >= 4)) {
	document.write("<link rel='stylesheet' href='ie.css' type='text/css'>");
}*/
    browser_version = parseInt(navigator.appVersion);
    browser_type = navigator.appName;
    //if(browser == "NOT MSIE"){limit=15};
    //if(browser == "MSIE 8.0"){limit=100};
    //if(browser == "MSIE BUT NOT 8.0"){limit=38};
    document.write("browser version=" + browser_version);
    document.write("browser type=" + browser_type);
    return limit;
}




function getInternetExplorerVersion() {
    var rv = -1; // Return value assumes failure.    
    if (navigator.appName == 'Microsoft Internet Explorer') {
        var ua = navigator.userAgent;
        var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
        if (re.exec(ua) != null) {
            rv = parseFloat(RegExp.$1);
        }
    }
    return rv;
}

function getBrowser() {
    var browser = "NOT MSIE";
    var ver = getInternetExplorerVersion();
    if (ver > -1) {
        if (ver == 8.0) {
            browser = "MSIE 8.0"
        } else {
            browser = "MSIE BUT NOT 8.0";
        }
    }
    return browser;
}

function itemLimit() {
    browser = getBrowser();
    if (browser == "NOT MSIE") {
        limit = 15
    };
    if (browser == "MSIE 8.0") {
        limit = 100
    };
    if (browser == "MSIE BUT NOT 8.0") {
        limit = 38
    };
    return limit;
}
