function getCartItem(nIndex)
	{
	var act_cart= getCookie("CART_CONTENT")
	var sTemp =(act_cart != null) ? sTemp=act_cart.split("\t"):0;
	return (sTemp.length > 0) ? sTemp[nIndex] : 0;
	}
function win()
	{
	var sMsg = window.open("paycash1.htm","","height = 507, width = 400, left = 378, top = 40");
	}
function GotoAnchor(sAnchor)
	{
	window.location.hash = sAnchor;
	}

function stripCost(string){
	var prc = string;
	var cost = 0;
	prc = prc.replace(/&#44;/g,"");
	prc = prc.replace(/&#46;/g,".");
	prc = prc.replace(/&#163;|&#36;/g,"£");
	var pbits = prc.match(/(£\d+\.\d\d)/); 
	if ( pbits != null )
	 {
	 cost =  pbits[1].replace(/£/,"") - 0;
	 }
	return cost;
}
function incVatCalc(thestring){
	var cost = stripCost(thestring);
	if ( cost == 0 )
	{
		cost="<b> TBA</b>";
	}
	return cost;
}
function exVatCalc(thestr){
	var cost = stripCost(thestr);
	cost = (cost/1.15).toFixed(2);
	if ( cost == 0 )
	{
		cost="<b> TBA</b>";
	}
	return cost;
}
function productShippingMessage(the){
	var cost = stripCost(the);
	var msg = "";
	if ( cost >= 20.00 )
	{
		msg="<a href=\"javascript:ShowPopUp('Glossary%5fMYF%5fFreeDelivery%2ehtml',380,480);\">FREE Delivery on this Product</a>";
	}
	return msg;
}
function cartShipMsg(){
	var strings=getCartItem(1);
	var cost = stripCost(strings);
	if (!strings || cost==0){
		return "<div align=\"center\"><b>Spend £10.00 or more for<br>Free Economy Shipping</b></div>";
	}
	var msg="";
	var cl;
	{
		if (cost >= 30){cl = 2.99}
		else if (cost >= 20){cl = 3.99}
		else if (cost >= 10){cl = 4.99}
		else {cl = 5.99}
	}
	if ( cost >= 12 )
	{
		msg="<div align=\"center\">Express Courier available<br>on this order - only £"+cl+"<br><img src=\"shim.gif\" width=\"1\" height=\"6\" alt=\"\" /><br><b>FREE Economy Shipping<br>on this Order</b></div>";
	} else
	{
		var spend = ((12 + 0.35) - cost).toFixed(2);
		msg="<div align=\"center\">Express Courier available<br>on this order - only £"+cl+"<br><img src=\"shim.gif\" width=\"1\" height=\"6\" alt=\"\" /><br><b>Spend £"+spend+" more to get<br>FREE Economy Shipping</b></div>";
	}
	return msg;
}
function StockLevels(pItem){
	var strIDs = 'Stock Message: '
	{
		if (pItem == 5000){strIDs = '<b>In Stock</b>'}
		else if(pItem == 1000){strIDs = '<b>2/3 Days</b>'}
		else if(pItem == 500){strIDs = '<b>5/7 Days</b>'}
		else if(pItem == 100){strIDs = '<b>PRE-ORDER</b><br>(see <a href=\"javascript:ShowPopUp(\'Glossary%5fPreOrder%2ehtml\',380,480);\"><font color="red"><b>note</b></font></a>)'}
		else if(pItem == 0){strIDs = '<font color=red><b>No stock</b></font>'}
		else if(pItem == -100){strIDs = '<b>DUE SOON</b><br>(see <a href=\"javascript:ShowPopUp(\'Glossary%5fDueSoon%2ehtml\',380,480);\"><font color="red"><b>note</b></font></a>)'}
		else if(pItem <= -9900){strIDs = '<font color=red><b>DISCONTINUED</b></font>'}
		else{strIDs = '<font color=red><b>No stock</b></font>'}
	}
	return strIDs
}
function StockLevelsImage(pItem){
	var strIDs = 'Stock Image: '
	{
		if (pItem == 5000){strIDs = '<img src="icon_20_green.gif">'}
		else if(pItem == 1000){strIDs = '<img src="icon_20_yellow.gif">'}
		else if(pItem == 500){strIDs = '<img src="icon_20_yellow.gif">'}
		else if(pItem == 100){strIDs = '<img src="icon_20_yellow.gif">'}
		else if(pItem == 0){strIDs = '<img src="icon_20_red.gif">'}
		else if(pItem == -100){strIDs = '<img src="icon_20_red.gif">'}
		else if(pItem == -9999){strIDs = '<img src="icon_20_red.gif">'}
		else{strIDs = '<img src="icon_20_red.gif">'}
	}
	return strIDs
}
function randomStrap(){
	var r = Math.random();
	var x = Math.round(r*8)+1;
	var a=['X',												
		'The Sharpest Tool In The Box',		
		'A Bright Light In A Web Of Darkness',		
		'Sharper Than The Average Tool',			
		'Cutting Edge Stuff',		
		'Blindingly Bright Beams',
		'Mind Your Fingers, Sharp Stuff About',
		'Dont Look Into The Light',
		'Lighting The Way',
		'Join The Illumination Generation'];			/*9*/	
	return a[x];
}
function getFullCart(){

var tableOpen="<table width='100%'>";
var itemLine="<tr><td valign='top'>VAR:QUANTITYx </td><td><a href='VAR:LINK'>VAR:TITLE...</a></td><td align='right' valign='top'>VAR:PRICE</td></tr>"
var shippingLine="<tr><td colspan='2'>Economy Shipping</td><td align='right'>VAR:SHIPPING</td></tr>"
var vatLine="<tr><td colspan='2'>VAT</td><td align='right'>VAR:VAT</td></tr>"
var discountLine="<tr><td colspan='2'>Discounts</td><td align='right'>VAR:DISCOUNT</td></tr>"
var surchargeLine="<tr><td colspan='2'>Surcharges</td><td align='right'>VAR:SURCHARGE</td></tr>"
var totalLine="</table><table width='100%'><tr><td><b>Total</b></td><td align='right'><b>VAR:TOTAL</b></td></tr>"
var tableClose="</table>"
var emptyLine="<div align=center><b>Your cart is empty</b></div>";

var cookie=getCartItem(4);

if (!cookie){
	return emptyLine;
	}
var re=new Array();
var match=new Array();
var total=0;
var str;
re[1]=/cur=([^&]*)&!/g;
re[2]=/&!(.*)/g;
re[3]=/ss=(.*)cur=/i;
re[4]=/tx=(.*)sh=/i;
re[5]=/sh=(.*)ss=/i;
for (i=1;i<re.length;i++){
	match[i]=re[i].exec(cookie);
	match[i]=match[i][1];
	}
lines=match[2].split("&!");
store=new Array();
re[0]=/^(\d*)x/;
re[1]=/x([^>]*)>/;
re[2]=/>([^>]*)>/;
re[3]=/>([^>]*)$/;
str=tableOpen;
for (i=0;i<lines.length;i++){
	for (j=0;j<re.length-2;j++){
		detail=lines[i].match(re[j]);
		store[j]=detail[1];
		}
	str+=itemLine.replace("VAR:QUANTITY",store[0]).replace("VAR:LINK",match[3]+"?PRODREF="+store[1]+"&NOLOGIN=1").replace("VAR:TITLE",store[2]).replace("VAR:PRICE",match[1]+((store[3]*1).toFixed(2)));
	total+=(store[3]*1);
	}
if (match[5] > 0){
	str+=shippingLine.replace("VAR:SHIPPING",match[1]+(match[5]/100).toFixed(2));
	total=total+=(match[5]/100);
	}
if (match[4] > 0){
	str+=vatLine.replace("VAR:VAT",match[1]+(match[4]/100).toFixed(2));
	total=total+=(match[4]/100);
	}
gTotal=getCartItem(1);
var r=/&#(\d*);/gi;
var m=new Array();
var f=new Array();
while((m = r.exec(gTotal))!=null){
	f[f.length]=m[1];
	}
for (i=0;i<f.length;i++){
	gTotal=gTotal.replace("&#"+f[i]+";","");
	}
total=total.toFixed(2);
gTotal=(gTotal/100).toFixed(2);
if (total>gTotal){
	str=str+=discountLine.replace("VAR:DISCOUNT","-"+match[1]+(total-gTotal).toFixed(2));
	}
else if (total<gTotal){
	str=str+=surchargeLine.replace("VAR:SURCHARGE",match[1]+(gTotal-total).toFixed(2));
	}
str+=totalLine.replace("VAR:TOTAL",match[1]+(gTotal));
str+=tableClose;
return str;
}