	// 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=5 cellspacing=0 bordercolor=#808080>');
		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 color=#ff0000>Remove</font>';

}
else
{
//document.write ("no")
DelBut = '<a href="javascript:removeItem('+itemlist+')"><font face=Arial size=2 color=#ff0000>Remove</font>';
}
				
		//MyList = MyList + thequantity + ' x ' + theitem + ', ';
		myCartlist = myCartlist + '<tr><td width=300 style=\'border: 1px solid #808080\'><font face=Arial size=2><B>'+theitem+'</B></td><td align=center style=\'border: 1px solid #808080\'><font face=Arial size=2>'+thequantity+'</td><td align=right style=\'border: 1px solid #808080\'><font face=Arial size=2>\xA3'+theprice+'</td><td align=right valign=top style=\'border: 1px solid #808080\'><font face=Arial size=2>\xA3'+alterError(itemtotal)+'</td></tr>'



document.writeln('<tr><td width=300 style=\'border: 1px solid #808080\'><font face=Arial size=2><B>'+theitem+'</B></td><td align=center style=\'border: 1px solid #808080\'><font face=Arial size=2>'+thequantity+'</td><td align=right style=\'border: 1px solid #808080\'><font face=Arial size=2>\xA3'+theprice+'</td><td align=right valign=top style=\'border: 1px solid #808080\'><font face=Arial size=2>\xA3'+alterError(itemtotal)+'</td><td style=\'border: 1px solid #808080\' 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=#aeaeae>Product Cost (Excluding UK VAT & Shipping | US and Non EEC countries are UK VAT free.)</b><font face=Arial size=2	 color=ff0000><br><br></td><td valign=top align=right><font size=2 face=Arial color=#aeaeae><B>\xA3'+alterError(totprice)+'<br><font color=#aeaeae></B><font face=Arial color=#ff0000 style="font-size: 8pt"></font></td></tr>');
		document.writeln('<tr><td colspan=3></td></tr>');
		document.writeln('</TABLE>');
		
		



varDataBox = '<input type=\"hidden\" name=\"cartdata\" size=\"20\" value=\"<TABLE width=1024 border=0 cellpadding=5 cellspacing=0 bordercolor=#808080><TR><TD width=300><font face=Arial size=2><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></TR>' +myCartlist  +'<tr><td valign=top colspan=3><b><font face=Arial size=2 Color=#000000>Product Cost (Excluding UK VAT & Shipping | US and Non EEC countries are UK VAT free.)</b><font face=Arial size=2 color=ff0000><br><br>NOTE TO CUSTOMER: Your chosen dealer will contact you for payment and delivery details soon, we thank you for your order. <BR>If you do not hear from your chosen dealer within 24 hours please contact Translogic Systems Ltd +44 (0)1202 622259</font></td><td  valign=top align=right><font size=2 face=Arial color=#000000><B>\xA3'+alterError(totprice)+'<br><font color=#aeaeae></B><font face=Arial color=#ff0000 style=\'font-size: 8pt\'></font><font color=#ff0000 face=Arial style=\'font-size: 8pt\'></font></td></tr></TABLE>\"';
varDataBox = varDataBox.replace("£", "&pound;")
document.writeln(varDataBox)
		
		

		
		

	}





















	// 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>\xA3'+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";
		}
	}

	function endCheckout() {
			index = document.cookie.indexOf("translogicbasket");
			document.cookie="translogicbasket=.";
	}



	// 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 \xA3'+newPrice+'. to your ordered items')) {		
		
		

		
			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);



}




		//CHECK IF THE CARTS NOT EMPTY AND MAKE ORDER BUTTON ILUMINATE
		
		
		
			var voflashingOn = 'no';	
			
			function showViewOrder() {
				
				if (voflashingOn = 'no') {
					
					$('#vorder').cycle({ 
						fx:    'fade', 
						speed:100,
						timeout: 1,
						speedIn:400,
						speedOut:400
						});
					
						var voflashingOn = 'yes';	
										
				}
					
			}		















		function IsNumeric(strString)
		   //  check for valid numeric strings	
		   {
		   var strValidChars = "0123456789.-";
		   var strChar;
		   var blnResult = true;
		
		   if (strString.length == 0) return false;
		
		   //  test strString consists of valid characters listed above
		   for (i = 0; i < strString.length && blnResult == true; i++)
			  {
			  strChar = strString.charAt(i);
			  if (strValidChars.indexOf(strChar) == -1)
				 {
				 blnResult = false;
				 }
			  }
		   return blnResult;
		   }

		cntindex = document.cookie.indexOf("translogicbasket");
		
		
		cntcountbegin = (document.cookie.indexOf("=", cntindex) + 1);
        cntcountend = document.cookie.indexOf(";", cntindex);

		if (cntcountend == -1) {
        	cntcountend = document.cookie.length;
        }
		
		var cntfulllist;
		cntfulllist = document.cookie.substring(cntcountbegin, cntcountend);
		cntfulllist = cntfulllist.replace(/\./gi, "");
		
		
		cntfulllist = cntfulllist.indexOf("["); 
			
		if (cntfulllist > 0) {
			showViewOrder();
		}


		function viewandproceed() {
			
			
				if (cntfulllist > 0) {

				document.location.href="view-and-proceed.asp";
				
				} else {
					
				alert("Your basket is currently empty, please add some items to your basket first.");	
					
				}
			
		}


