function onLoad() { var biscuit = document.cookie; biscuit = biscuit.substring(biscuit.indexOf("currency"),biscuit.length); if (biscuit.indexOf(";") != -1) biscuit = biscuit.substring(0,biscuit.indexOf(";")); if (biscuit.indexOf("currency") == -1) document.cookie = "currency=GBP; path=/; expires=Thu, 01-Jan-2070 00:00:01 GMT;"; return; if (biscuit.indexOf("GBP") != -1) document.currencyForm.currency.options[0].selected = true; else if (biscuit.indexOf("USD") != -1) document.currencyForm.currency.options[1].selected = true; else if (biscuit.indexOf("EUR") != -1) document.currencyForm.currency.options[2].selected = true; else if (biscuit.indexOf("JPY") != -1) document.currencyForm.currency.options[3].selected = true; else if (biscuit.indexOf("AUD") != -1) document.currencyForm.currency.options[4].selected = true; else if (biscuit.indexOf("CAD") != -1) document.currencyForm.currency.options[5].selected = true; } function setCurrency() { var currency = "GBP"; var currencyCookie = "currency=" + escape(currency) + "; path=/; expires=Thu, 01-Jan-2070 00:00:01 GMT;"; document.cookie = currencyCookie; window.location.reload(true); } function change(id) { var products = getProducts(); id = id+""; if (products[id] == undefined) products[id] = 0; var select = document.getElementById(id+"_quantity"); products[id] = parseInt(products[id]) + parseInt(select.selectedIndex + 1); setCookie(products); window.location.href= window.location.href + "#basket"; window.location.reload(true); } function add(id) { var products = getProducts(); id = id+""; if (products[id] == undefined) products[id] = 0; products[id] = parseInt(products[id]) +1; setCookie(products); var textbox = document.getElementById("qty_"+id); textbox.value = products[id]; } function removeOne(id) { var products = getProducts(); id = id+""; if (products[id] == undefined) products[id] = 0; if (products[id] > 0) products[id] = parseInt(products[id]) -1; setCookie(products); var textbox = document.getElementById("qty_"+id); textbox.value = products[id]; } function getProducts() { var biscuit = document.cookie; var index = biscuit.indexOf("products="); var cartItems = new Array(); if (index == -1) //if there are no products return empty array return cartItems; biscuit = unescape(biscuit.substring(index+9,biscuit.length)); //grab the end of the product string if (biscuit.indexOf(";") != -1) biscuit = biscuit.substring(0,biscuit.indexOf(";")); var cartPairs = biscuit.split(" "); for ( var count=0; count < cartPairs.length; count++ ) { var itemCodeAndCount = cartPairs[count].split(":"); var key = itemCodeAndCount[0]+"" cartItems[ key ] = itemCodeAndCount[1]; } return cartItems; } function setCookie (itemsArray) { var cartPairs = new Array(); var i=0; //join array into an array of code:quantity for ( var keyIndex in itemsArray ) if (itemsArray[keyIndex]) cartPairs[i++] = ( keyIndex + ":" + itemsArray[keyIndex] ); var cartCookieValue = cartPairs.join(" "); document.cookie = "products=" + escape(cartCookieValue) + "; path=/;"; } function setupOptions(view, number, orderBy, order) { if (view != '') setOption(document.optionsForm.view, view); else document.optionsForm.view.options[0].selected = true; if (number != '') setOption(document.optionsForm.number, number); else document.optionsForm.number.options[4].selected = true; if (orderBy != '') setOption(document.optionsForm.orderBy, orderBy); else document.optionsForm.orderBy.options[1].selected = true; if (order != '') setOption(document.optionsForm.order, order); else document.optionsForm.order.options[0].selected = true; } function setPage(num, id) { //document.products["pageBox"].options[num].selected = true; document.getElementsByName("pageBox"+id)[0].options[num].selected = true; //document.getElementsByName("pageBox")[1].options[num].selected = true; } function setOption(op, value) { for (i = 0; i < op.length ; i++) { if (op.options[i].value == value) { op.options[i].selected = true; } } } function delCookie (name) { document.cookie = name + "=" + "; expires=Thu, 01-Jan-1970 00:00:01 GMT" + "; path=/"; } function clearOrder() { delCookie("products"); document.location.href = "index.php"; } function addbookmark() { if (document.all) { window.external.AddFavorite("http://www.abbeyessentials.co.uk/",""); } } function submitForm() { var country = document.order.country; if (document.order.first_name.value == "" || document.order.address1.value == "" || document.order.city.value == "" || document.order.state.value == "" || document.order.zip.value == "" || document.order.last_name.value == "" || document.order.tel.value == "" || country[country.selectedIndex].value =="NA" || document.order.email.value.indexOf("@") == -1) { document.forms['order'].setAttribute('action','checkout.php'); } //alert(document.forms['order'].action); document.forms['order'].submit(); } function openWin(file) { var newWindow = ''; file = file.toLowerCase(); file = file.trim(); if (file.substr(file.length -1, 1) == " ") { file = file.substr(0,file.length -1); } file = "info/"+file+".html"; newWindow = window.open(file,'mapWin',"resizable=yes,scrollbars=yes,width=600,height=400"); newWindow.focus(); } function updateCountry() { var country = document.order.country; var postage = 0.00; var subTotal = document.order.elements["subTotal"].value; var currency = document.order.currencySymbol.value; if (country[country.selectedIndex].id == "0") postage = document.order.elements["UKPostalCost"].value; else if (country[country.selectedIndex].id == "1") postage = document.order.elements["europePostalCost"].value; else if (country[country.selectedIndex].id == "2") postage = document.order.elements["internationalPostalCost"].value; else return; postage = postage * document.order.currencyRate.value; document.getElementById("postage").value = postage.toFixed(2); document.getElementById("handling_cart").value = postage.toFixed(2); subTotal = parseFloat(subTotal); var vat = subTotal * 0.175; document.getElementById("vat").value = vat.toFixed(2); document.getElementById("tax_cart").value = vat.toFixed(2); var total = subTotal + vat + postage; document.getElementById("total").value = total.toFixed(2) ; } String.prototype.trim = function() { a = this.replace(/^\s+/, ''); return a.replace(/\s+$/, ''); }; function updateBasket() { var products = getProducts(); for (var i = 0; document.products[i].name != "add"; i++) { var id = parseInt(document.products[i].name) + 0; var qty = parseInt(document.products[i].value) + 0; if (products[id]) products[id] = parseInt(products[id]) + qty; else products[id] = qty; if (products[id] < 0) products[id] = 0; } setCookie(products); } function remove(id) { var products = getProducts(); products[id] = 0; setCookie(products); window.location.reload(true); } window.addEventListener?window.addEventListener("load",so_init,false):window.attachEvent("onload",so_init); var d=document, imgs = new Array(), zInterval = null, current=0, pause=false; function so_init() { if(!d.getElementById || !d.createElement)return; // DON'T FORGET TO GRAB THIS FILE AND PLACE IT ON YOUR SERVER IN THE SAME DIRECTORY AS THE JAVASCRIPT! // http://slayeroffice.com/code/imageCrossFade/xfade2.css css = d.createElement("link"); css.setAttribute("href","style/xfade2.css"); css.setAttribute("rel","stylesheet"); css.setAttribute("type","text/css"); d.getElementsByTagName("head")[0].appendChild(css); imgs = d.getElementById("imageContainer").getElementsByTagName("img"); for(i=1;i< imgs.length;i++) imgs[i].xOpacity = 0; imgs[0].style.display = "block"; imgs[0].xOpacity = .99; setTimeout(so_xfade,4000); } function so_xfade() { cOpacity = imgs[current].xOpacity; nIndex = imgs[current+1]?current+1:0; nOpacity = imgs[nIndex].xOpacity; cOpacity-=.01; nOpacity+=.01; imgs[nIndex].style.display = "block"; imgs[current].xOpacity = cOpacity; imgs[nIndex].xOpacity = nOpacity; setOpacity(imgs[current]); setOpacity(imgs[nIndex]); if(cOpacity<=0) { imgs[current].style.display = "none"; current = nIndex; setTimeout(so_xfade,4000); } else { setTimeout(so_xfade,40); } function setOpacity(obj) { if(obj.xOpacity>.99) { obj.xOpacity = .99; return; } obj.style.opacity = obj.xOpacity; obj.style.MozOpacity = obj.xOpacity; obj.style.filter = "alpha(opacity=" + (obj.xOpacity*100) + ")"; } }