function bulktop2(bulkhigh)
{
    var bulklow = bulkhigh - 1;
    document.write(bulklow);
}

function tonybasket(x) 
{
    t = eval("document." + x + ".quantity");
    failed = false;
    if (isNaN(t.value)) {
        alert("Please enter a valid number in quantity2");
        t.value = 11;
        t.focus();
        failed = true;

    } else {
        if (t.value < 0) {
            alert("Quantity cannot be less than zero2");
            t.value = 22;
            t.focus();
            failed = true;
        }
    }

    if (failed) {
        document['navigation'].quanttest.value = 'nogo';
    }
    else
    {
        eval("document." + x + ".submit()");
    }
}



function testpackagingstoreLaunch() {}

function dosubmitjg()
{  
   document ["compare"].action = 'http://localhost/code/addtoordermultiple.asp?fromprodsumlistmultiform=yes'
   document ["compare"].submit()
}

function searchJG() {
    var searchTerm = document.getElementById("st").value;
    window.location = "/Findcustom.asp?st=" + searchTerm + "&tid=330";
}


function gocartCatapult(useGoogleCheckout) {
    if (document['navigation']) {
        if (document['navigation'].zoneid) {
            xzval = document['navigation'].zoneid.value;
            if (xzval == -1) {
                alert("Please select a delivery area");
                return;
            }
            if (xzval == "") {
                alert("Please select a delivery area");
                return;
            }
        }
        if (document['navigation'].classid) {
            xzval = document['navigation'].classid.value;
            if (xzval == -1) {
                alert("Please select a delivery upgrade first");
                return;
            }
        }
        if (document['navigation']['emptycart']) {
            alert("Your shopping basket is currently empty");
            return;
        }
        if (allowordernow) {
            var classIDselect = "";
            classIDlen = document['navigation'].classid.length;
            if (document['navigation'].classid.length == undefined) {
                classIDselect = document['navigation'].classid.value;
            } else {
                for (i = 0; i < classIDlen; i++) {
                    if (document['navigation'].classid[i].checked) {
                        classIDselect = document['navigation'].classid[i].value;
                    }
                }
            }
            if (classIDselect == "") {
                alert("Please select a delivery class");
                return;
            }
            document['navigation'].action = "alsobuy.asp?zoneid=" + document['navigation'].zoneid.value + "&classid=" + classIDselect;
            document['navigation'].submit();
        }
    }
}



function bulkperunit(price1, quant1) {
    if ((quant1 !== 0) && (!isNaN(quant1))) {
        var priceless1 = price1.replace(/£/, "");
        priceless1 = priceless1.replace(/&#163;/, "");
        priceless1 = priceless1.replace(/,/, "");
        var iprice = Math.round(priceless1 / quant1 * 100) / 100;
        if (iprice > 0) {
            if (quant1 > 1) {
                document.write(iprice.toFixed(2));
            }
        }
    }
}

function minipakrfreeroll() {
    var minirolls = new Array();
    minirolls[0] = document.getElementById('FreeRoll1').value;
    minirolls[1] = document.getElementById('FreeRoll2').value;
    if (minirolls[0] === 'DC' || minirolls[0] === 'QL' || minirolls[0] === 'QS' || minirolls[0] === 'ST' || minirolls[0] === 'EZ') {
        if (minirolls[1] === 'DC' || minirolls[1] === 'QL' || minirolls[1] === 'QS' || minirolls[1] === 'ST' || minirolls[1] === 'EZ') {
            minirolls.sort();
            var minipakrurl = '/code/AddToOrder.asp?partno=MINIPAKR-FREE-' + minirolls[0] + '-' + minirolls[1];
            window.location.href = (minipakrurl);
        } else {
            alert('Please select a 2nd free roll');
            document.getElementById('FreeRoll2').focus();
        }
    } else {
        alert('Please select a 1st free roll');
        document.getElementById('FreeRoll1').focus();
    }
}

function minipbundlefreeroll() {
    var minirolls = new Array();
    minirolls[0] = document.getElementById('FreeRoll1').value;
    minirolls[1] = document.getElementById('FreeRoll2').value;
    if (minirolls[0] === 'DC' || minirolls[0] === 'QL' || minirolls[0] === 'QS' || minirolls[0] === 'ST' || minirolls[0] === 'EZ') {
        if (minirolls[1] === 'DC' || minirolls[1] === 'QL' || minirolls[1] === 'QS' || minirolls[1] === 'ST' || minirolls[1] === 'EZ') {
            minirolls.sort();
            var minipakrurl = '/code/AddToOrder.asp?partno=MINIP-BUNDLE-' + minirolls[0] + '-' + minirolls[1];
            window.location.href = (minipakrurl);
        } else {
            alert('Please select a 2nd free roll');
            document.getElementById('FreeRoll2').focus();
        }
    } else {
        alert('Please select a 1st free roll');
        document.getElementById('FreeRoll1').focus();
    }
}

function testalso() {
    if (document['navigation']) {
        if (allowordernow) {
            document['navigation'].action = "Alsobuy.asp";
            document['navigation'].submit();
        }
    }
}

function clearDefault(el) {
    if (el.defaultValue == el.value) {
        el.value = "";
    }
}

function submitAlsoBuy(itemCount) {
    if (itemCount > 0) {
        // alert(itemCount)
        var quantity = 0;
        for (i = 1; i <= itemCount; i = i + 1) {
            quantity = quantity + Number(document.getElementById("q" + i).value);
        }
        //alert(quantity);
        if (quantity > 0) {
            document["AlsoBuyOffer"].submit();
        } else {
            alert("Please enter a number.");
            return;
        }
    }
}

function bulkpermeter(price1, quant1) {
    if ((quant1 !== 0) && (!isNaN(quant1))) {
        var priceless1 = price1.replace(/£/, "");
        priceless1 = price1.replace(/&#163;/, "");
        var iprice = Math.round(priceless1 / quant1 * 100);
        if (iprice > 0) {
            if (quant1 > 1) {
                document.write("<span class='priceperroll'><br>" + iprice.toFixed(0) + "p per m</span>");
            }
        }
    }
}

function bulksinglep0(price1, quant1) {
    if ((quant1 !== 0) && (!isNaN(quant1))) {
        var priceless1 = price1.replace(/£/, "");
        priceless1 = price1.replace(/&#163;/, "");
        var iprice = Math.round(priceless1 / quant1 * 100);
        if (iprice > 0) {
            if (quant1 > 1) {
                document.write("<span class='priceperroll'><br>" + iprice.toFixed(0) + "p each</span>");
            }
        }
    }
}

function bulksinglep(price1, quant1) {
    if ((quant1 !== 0) && (!isNaN(quant1))) {
        var priceless1 = price1.replace(/£/, "");
        priceless1 = price1.replace(/&#163;/, "");
        var iprice = Math.round(priceless1 / quant1 * 1000) / 10;
        if (iprice > 0) {
            if (quant1 > 1) {
                document.write("<span class='priceperroll'><br>" + iprice.toFixed(1) + "p each</span>");
            }
        }
    }
}

function bulktop(bulkhigh) {
    var bulklow = bulkhigh - 1;
    document.write(" to " + bulklow + "<br>packs");
}

function bulktopunit(bulkhigh) {
    var bulklow = bulkhigh - 1;
    document.write(" to " + bulklow);
}

function bulksingle5Plain(price1, quant1) {
    if ((quant1 !== 0) && (!isNaN(quant1))) {
        var priceless1 = price1.replace(/£/, "");
        priceless1 = price1.replace(/&#163;/, "");
        var iprice = Math.round(priceless1 / quant1 * 100) / 100;
        if (iprice > 0) {
            if (quant1 > 1) {
                document.write("£" + iprice.toFixed(2) + " each");
            }
        }
    }
}

function bulksingle5(price1, quant1) {
    if ((quant1 !== 0) && (!isNaN(quant1))) {
        var priceless1 = price1.replace(/£/, "");
        priceless1 = price1.replace(/&#163;/, "");
        var iprice = Math.round(priceless1 / quant1 * 100) / 100;
        if (iprice > 0) {
            if (quant1 > 1) {
                document.write("<span class='priceperroll'><br>£" + iprice.toFixed(2) + " each</span>");
            }
        }
    }
}

function bulksingleplainperroll(price1, quant1) {
    if ((quant1 !== 0) && (!isNaN(quant1))) {
        var priceless1 = price1.replace(/£/, "");
        priceless1 = price1.replace(/&#163;/, "");
        var iprice = Math.round(priceless1 / quant1 * 100) / 100;
        if (iprice > 0) {
            if (quant1 > 1) {
                document.write("£" + iprice.toFixed(2) + " Per Roll<br>");
            }
        }
    }
}

function bulksingleplainperkg(price1, quant1) {
    if ((quant1 !== 0) && (!isNaN(quant1))) {
        var priceless1 = price1.replace(/£/, "");
        priceless1 = price1.replace(/&#163;/, "");
        var iprice = Math.round(priceless1 / quant1 * 100) / 100;
        if (iprice > 0) {
            if (quant1 > 1) {
                document.write("<br>£" + iprice.toFixed(2) + " Per Kg");
            }
        }
    }
}

function bulksingle3(price1, quant1) {
    if ((quant1 !== 0) && (!isNaN(quant1))) {
        var priceless1 = price1.replace(/£/, "");
        priceless1 = price1.replace(/&#163;/, "");
        var iprice = Math.round(priceless1 / quant1 * 100) / 100;
        if (iprice > 0) {
            document.write("<br>£" + iprice.toFixed(2));
        }
    }
}

function vizboxes() {
    document.getElementById("cont").style.height = "120px";
}

function flipboxes(act) {
    if (act == "show") {
        document.getElementById("more").style.visibility = "hidden";
        document.getElementById("cont").style.height = "auto";
    } else {
        document.getElementById("more").style.visibility = "visible";
        document.getElementById("cont").style.height = "120px";
    }
}

function viz() {
    document.getElementById("cont").style.height = "160px";
}

function flip(act) {
    if (act == "show") {
        document.getElementById("more").style.visibility = "hidden";
        document.getElementById("cont").style.height = "auto";
    } else {
        document.getElementById("more").style.visibility = "visible";
        document.getElementById("cont").style.height = "160px";
    }
} /*****************************/
/* forgotten password submit */
/*****************************/

function passworddosubmit() {
    if (document.forgottenpassword.email.value == "") {
        alert("Please Enter Your Email Address this must be the address you Registered with initialy");
        document.forgottenpassword.email.focus();
        return;
    }
    document.forgottenpassword.submit();
} /* creditaccounts validation */

function validate_checkbox() {
    var checkbox1 = document.getElementById('criteria1');
    var checkbox2 = document.getElementById('criteria2');
    var checkbox3 = document.getElementById('criteria3');
    var checkbox4 = document.getElementById('criteria4');
    var checkbox6 = document.getElementById('criteria6');
    if ((!checkbox1.checked) || (!checkbox2.checked) || (!checkbox3.checked) || (!checkbox4.checked) || (!checkbox6.checked)) {
        alert("To proceed, you must agree by ticking every criteria.");
        return false;
    } else {
        return true;
    }
} /* end creditaccounts validation */

function GifSwap(sImgName, sImgFile) {
    document.images[sImgName].src = sImgFile;
}

function MM_openBrWindow(theURL, winName) { //v2.0
    window.open(theURL, winName, "width=650,height=650,left=1,top=1,resizable,scrollbars=yes,status=1");
}

function CertificateSubmit() {
    var CertString = document.certform.certificatecode.value.toUpperCase();
    document.certform.couponcode.value = document.certform.certificatecode.value;
    if (CertString.indexOf("V-") == -1) {
        document.certform.action = "code/coupon.asp";
    } else {
        document.certform.action = "code/certificate.asp";
    }
    document.certform.submit();
}

function gocartnologgedin() {
    if (document['navigation']) {
        if (document['navigation'].zoneid) {
            xzval = document['navigation'].zoneid.value;
            if (xzval == -1) {
                alert("Please select a delivery area first");
                return;
            }
        }
        if (document['navigation']['emptycart']) {
            alert("No items in basket");
            return;
        }
        if (allowordernow) {
            document['navigation'].action = "Alsobuy.asp"; /* document ['navigation'].action = "custreg.asp?action=login&fromcart=yes"; */
            document['navigation'].submit();
        }
    }
}

