	
	
	
	// showItems() - displays shopping basket in a table
	function showItems() {
		index = document.cookie.indexOf("translogicbasket");
		
		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;
		myCartlist = "";
		document.writeln('<TABLE width=99% border=0 cellpadding=0 cellspacing=0 bordercolor=#01A1B1>');
		document.writeln('<TR><TD width=300><font face=Arial size=><b>Item</b></TD><TD><font face=Arial size=2><b>Qty</b></TD><TD align=right><font face=Arial size=2><b>Cost Each</b></TD><td align=right><font face=Arial size=2><b>Total</b><TD align=center><font face=Arial size=2><b>Remove</b></TD></TR>');
		
		
		
		
		itemlist = 0;
		for (var i = 0; i <= fulllist.length; i++) {
			if (fulllist.substring(i,i+1) == '[') {
				itemstart = i+1;
			} else if (fulllist.substring(i,i+1) == ']') {
				itemend = i;
				thequantity = fulllist.substring(itemstart, itemend);
				itemtotal = 0;
				itemtotal = (eval(theprice*thequantity));
				temptotal = itemtotal * 100;
				totprice = totprice + itemtotal;
				itemlist=itemlist+1;
				
				
//MAKE SURE DELIVERY CANT BE DELETED
				
var instr = theitem.indexOf("Delivery")

if ( instr > 0)
{
//document.write ("yes")
//DelBut = '';
DelBut = '<a href="javascript:removeItem('+itemlist+')"><font face=Arial size=2>Remove</font>';

}
else
{
//document.write ("no")
DelBut = '<a href="javascript:removeItem('+itemlist+')"><font face=Arial size=2>Remove</font>';
}
				
		//MyList = MyList + thequantity + ' x ' + theitem + ', ';
		myCartlist = myCartlist + '<tr><td width=300 style=\'border: 1px solid #aaaaaa\'><font face=Arial size=2><B>'+theitem+'</B></td><td align=center style=\'border: 1px solid #aaaaaa\'><font face=Arial size=2>'+thequantity+'</td><td align=right style=\'border: 1px solid #aaaaaa\'><font face=Arial size=2>'+theprice+'</td><td align=right style=\'border: 1px solid #aaaaaa\'><font face=Arial size=2>'+alterError(itemtotal)+'</td></tr>'



document.writeln('<tr><td width=300 style=\'border: 1px solid #aaaaaa\'><font face=Arial size=2><B>'+theitem+'</B></td><td align=center style=\'border: 1px solid #aaaaaa\'><font face=Arial size=2>'+thequantity+'</td><td align=right style=\'border: 1px solid #aaaaaa\'><font face=Arial size=2>'+theprice+'</td><td align=right style=\'border: 1px solid #aaaaaa\'><font face=Arial size=2>'+alterError(itemtotal)+'</td><td style=\'border: 1px solid #000000\' align=center>' +DelBut +'</td></tr>');
			
			
			
			
			} else if (fulllist.substring(i,i+1) == ',') {
				theitem = fulllist.substring(itemstart, i);
				itemstart = i+1;
				
			} else if (fulllist.substring(i,i+1) == '*') {
			theweight = fulllist.substring(itemstart, i);
			itemstart = i+1;

				
			} else if (fulllist.substring(i,i+1) == '#') {
				theprice = fulllist.substring(itemstart, i);
				itemstart = i+1;
				
				
				
			}
		}
	

		
		
		document.writeln('<tr><td colspan=3 valign=top><b><font face=Arial size=2 Color=#000000>Total (RRP)</b><font face=Arial size=2><br>Note: Payment is not taken until time of dispatch</font></p></td><td align=right><font size=2 face=Arial color=#000000><B>£'+alterError(totprice)+'<br><font color=#000000></B><font face=Arial style="font-size: 8pt">*Excludes UK VAT where<br> applicable, US and Non European countries are UK VAT free</font></td></tr>');
		document.writeln('<tr><td colspan=3></td></tr>');
		document.writeln('</TABLE>');
		
		
document.writeln('<input type=\"hidden\" name=\"cartdata\" size=\"20\" value=\"'+escape('<TABLE width=\"99%\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\" bordercolor=\"#01A1B1\">\n<TR>\n<TD width=\"300\"><font face=\"Arial\" size=\"2\"><b>Item</b>\n</TD>\n<TD>\n<font face=\"Arial\" size=\"2>\"<b>Qty</b>\n</TD>\n<TD align=\"right\">\n<font face=\"Arial\" size=\"2\"><b>Cost Each</b>\n</TD><td align=\"right\"><font face=\"Arial\" size=\"2\">\n<b>Total</b>\n</TR>' +myCartlist  +'<tr><td valign=\"top\" colspan=\"3\"><b><font face=\"Arial\" size=\"2\" Color=\"#000000\">Total (RRP)</b><font face=\"Arial\" size=\"2\"><br>Note: Payment is not taken until time of dispatch</font>\n</td>\n<td align=\"right\">\n<font size=\"2\" face=\"Arial\" color=\"#000000\"><B>£'+alterError(totprice)+'<br><font color=\"#000000\"></B><font face=\"Arial\" style=\"font-size: 8pt\">*Excludes UK VAT where applicable</font><br><font face=\"Arial\" style=\"font-size: 8pt\">US and Non European countries are UK VAT free</font>\n</td>\n</tr>\n</TABLE>')+'\"');
		
		

		
		

	}





















	// CountItems() - displays how many items in basket
	function CountItems() {
		index = document.cookie.indexOf("translogicbasket");
		
		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;


		itemlist = 0;
		for (var i = 0; i <= fulllist.length; i++) {
			if (fulllist.substring(i,i+1) == '[') {
				itemstart = i+1;
			} else if (fulllist.substring(i,i+1) == ']') {
				itemend = i;
				thequantity = fulllist.substring(itemstart, itemend);
				itemtotal = 0;
				itemtotal = (eval(theprice*thequantity));
				temptotal = itemtotal * 100;
				totprice = totprice + itemtotal;
				itemlist=itemlist+1;
				
				

			
			
			
			} else if (fulllist.substring(i,i+1) == ',') {
				theitem = fulllist.substring(itemstart, i);
				itemstart = i+1;
				
			} else if (fulllist.substring(i,i+1) == '*') {
			theweight = fulllist.substring(itemstart, i);
			itemstart = i+1;

				
			} else if (fulllist.substring(i,i+1) == '#') {
				theprice = fulllist.substring(itemstart, i);
				itemstart = i+1;
				
				
				
			}
		}
	

		
		
		document.writeln('<img border=0 src=images/black_shopping.gif><font face=Arial size=1><b>£'+alterError(totprice)+'</font>');
		//document.writeln('<input  type="hidden" name="item_name" value="'+MyList+'"');
	
	}
















	// Remove an item from the list
	function removeItem(itemno) {
		newItemList = null;
		itemlist = 0;
		for (var i = 0; i <= fulllist.length; i++) {
			if (fulllist.substring(i,i+1) == '[') {
				itemstart = i+1;
			
			} else if (fulllist.substring(i,i+1) == ']') {
				itemend = i;
				theitem = fulllist.substring(itemstart, itemend);
				itemlist=itemlist+1;
				if (itemlist != itemno) {
					newItemList = newItemList+'['+fulllist.substring(itemstart, itemend)+']';
				}
			}
		}
		index = document.cookie.indexOf("translogicbasket");
		document.cookie="translogicbasket="+newItemList;
		//location = "basket.asp";
		location.reload(true);
	}

	
	
	
	
	// clearBasket() - removes all items from the basket
	function clearBasket() {
		if (confirm('Are you sure you wish to clear the basket')) {
			index = document.cookie.indexOf("translogicbasket");
			document.cookie="translogicbasket=.";
			parent.frames[0].location = "basket.asp";
		}
	}






	// alterError - fixes a rounding bug in Netscape 2
	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 shooping basket
	function buyItem(newItem, newWeight, newPrice, newQuantity) {
		if (newQuantity <= 0) {
			rc = alert('The quantity entered is incorrect');
			return false;
		}
		if (confirm('Add '+newQuantity+' x '+newItem+' at £'+newPrice+'. to your ordered items.\r\n""')) {		
		
		

		
			index = document.cookie.indexOf("translogicbasket");
			countbegin = (document.cookie.indexOf("=", index) + 1);
        		countend = document.cookie.indexOf(";", index);
	        	if (countend == -1) {
        	    		countend = document.cookie.length;
        		}
	                document.cookie="translogicbasket="+document.cookie.substring(countbegin, countend)+"["+newItem+","+newWeight+"*"+newPrice+"#"+newQuantity+"]";
	              
				//window.location = "basket.asp";
				location.reload(true);


	               
		}
		return true;
		
	}

	// resetShoppingBasket - resets to shopping basket to empty
	function resetShoppingBasket() {
		index = document.cookie.indexOf("translogicbasket");
		document.cookie="translogicbasket=.";
		
		
		
		}
		
		
		
		
		
		
		
	// SecretlyBuyItem
	function SecretlyBuyItem(newItem, newWeight, newPrice, newQuantity) {
		if (newQuantity <= 0) {
			rc = alert('The quantity entered is incorrect');
			return false;
		}
		
			index = document.cookie.indexOf("translogicbasket");
			countbegin = (document.cookie.indexOf("=", index) + 1);
        		countend = document.cookie.indexOf(";", index);
	        	if (countend == -1) {
        	    		countend = document.cookie.length;
        		}
	                document.cookie="translogicbasket="+document.cookie.substring(countbegin, countend)+"["+newItem+","+newWeight+"*"+newPrice+"#"+newQuantity+"]";
	              

		return true;
		
	}





// Validation Script

function Validate() {

varcookie = document.cookie;
varcookie = varcookie.indexOf("Delivery")

if ( varcookie > 0){

document.revieworder.submit();


} else {

alert('There was no delivery chosen, you will now be given the opportunity to choose the right delivery depending on your location');
window.location = "basket.asp";
return false;

}



//if ( document.checkoutform.personal_email.value = 'null'){
//alert('No email address filled in');
//}

//alert(document.checkoutform.personal_email.value);



}