if (document.cookie.indexOf("Referrer") == -1) { document.cookie = "Browser=" + detectBrowser(); document.cookie = "LandingPage=" + document.location.href; if (!document.referrer){ document.cookie = "Referrer=None"; } else { document.cookie = "Referrer=" + document.referrer; } document.cookie = "TheBasket=."; document.cookie = "Postage=none"; } // Browser detection /////////////////////////////////////////////////////////////////////////////////////////////////// function checkIt(string, detect) { place = detect.indexOf(string) + 1; thestring = string; return place; } function detectBrowser() { var detect = navigator.userAgent.toLowerCase(); var OS,browser,total,thestring; var version = 0; if (checkIt('konqueror', detect)) { browser = "Konqueror"; OS = "Linux"; thestring = 'konqueror'; } else if (checkIt('safari', detect)) { browser = "Safari"; thestring = 'safari'; } else if (checkIt('omniweb', detect)) { browser = "OmniWeb"; thestring = 'omniweb'; } else if (checkIt('opera', detect)) { browser = "Opera"; thestring = 'opera'; } else if (checkIt('webtv', detect)) { browser = "WebTV"; thestring = 'webtv'; } else if (checkIt('icab', detect)) { browser = "iCab"; thestring = 'icab'; } else if (checkIt('msie', detect)) { browser = "Internet Explorer"; thestring = 'msie'; } else if (!checkIt('compatible', detect)) { browser = "Netscape Navigator" version = detect.charAt(8); thestring = 'compatible'; } else browser = "An unknown browser"; if (!version) version = detect.charAt(place + thestring.length); if (!OS) { if (checkIt('linux', detect)) OS = "Linux"; else if (checkIt('x11', detect)) OS = "Unix"; else if (checkIt('mac', detect)) OS = "Mac" else if (checkIt('win', detect)) OS = "Windows" else OS = "an unknown operating system"; } return(browser + ' ' + version + ' on ' + OS); } // alterError - fixes a rounding bug in Netscape 4 ///////////////////////////////////////////////////////////////////// function alterError(value) { if (value<=0.99) { newPounds = '0'; } else { newPounds = parseInt(value); } newPence = parseInt((value+.0008 - newPounds)* 100); if (eval(newPence) <= 9) newPence='0'+newPence; newString = newPounds + '.' + newPence; return (newString); } // buyItem - adds an item to the shopping basket /////////////////////////////////////////////////////////////////////// function buyItem(newProductID, newItem, newVariant, newPrice, newDelivery, newQuantity, newStock) { index = document.cookie.indexOf("TheBasket"); countbegin = (document.cookie.indexOf("=", index) + 1); countend = document.cookie.indexOf(";", index); if (countend == -1) { countend = document.cookie.length; } fulllist = document.cookie.substring(countbegin, countend); alreadyOrdered = false; itemlist = 0; for (var i = 0; i <= fulllist.length; i++) { if (fulllist.substring(i,i+1) == '[') { itemstart = i+1; thisitem = 1; } else if (fulllist.substring(i,i+1) == ']') { itemend = i; thestocklevel = fulllist.substring(itemstart, itemend); itemlist=itemlist+1; } else if (fulllist.substring(i,i+1) == '|') { if (thisitem==1) theitem = fulllist.substring(itemstart, i); if (thisitem==2) { theproductid = fulllist.substring(itemstart, i); if (theproductid == newProductID) { alreadyOrdered = true; } } if (thisitem==3) theprice = fulllist.substring(itemstart, i); if (thisitem==4) thedelivery = fulllist.substring(itemstart, i); if (thisitem==5) thequantity = fulllist.substring(itemstart, i); thisitem++; itemstart=i+1; } } if (alreadyOrdered) { rc = alert('You have already ordered that product!\n\nIf you want to change the quantity, please\nclick \'edit shopping cart\'.'); } else if (newQuantity <= 0) { rc = alert('The quantity entered is incorrect.'); } else if (newQuantity > newStock) { if (newStock == 0) { alertText = 'We\'re afraid that this item is currently out of stock.'; } else if (newStock == 1) { alertText = 'There is only 1 item in stock.\nPlease revise your order.'; } else { alertText = 'There are only ' + newStock + ' items in stock.\nPlease revise your order.'; } rc = alert(alertText); } else { if (newVariant == '') { itemDescription = newItem; } else { itemDescription = newItem + ' ' + '(' + newVariant + ')'; } //index = document.cookie.indexOf("TheBasket"); //countbegin = (document.cookie.indexOf("=", index) + 1); countbegin = (document.cookie.indexOf("TheBasket=") + 10); //countend = document.cookie.indexOf(";", index); countend = document.cookie.indexOf(";", countbegin); if (countend == -1) { countend = document.cookie.length; } document.cookie="TheBasket="+document.cookie.substring(countbegin, countend)+"["+itemDescription+"|"+newProductID+"|"+newPrice+"|"+newDelivery+"|"+newQuantity+"|"+newStock+"]"; window.location.href = window.location.href; } } // showItems() - displays shopping basket in a table /////////////////////////////////////////////////////////////////// function showItems() { index = document.cookie.indexOf("TheBasket"); countbegin = (document.cookie.indexOf("=", index) + 1); countend = document.cookie.indexOf(";", index); if (countend == -1) { countend = document.cookie.length; } fulllist = document.cookie.substring(countbegin, countend); totprice = 0; document.writeln('