<!--
taxfield='United Kingdom';
cookiesettings=' expires=Friday, 31-Dec-2010 08:00:00 GMT; path=/';

function buyItem(newItem,newPrice,newTaxable,newWeight,newAP,newQuantity) {
    if(isNaN(newQuantity)) {
        rc = alert('Quantity is not a number!');
	} else if(newQuantity<=0) {
        rc = alert('The quantity entered is incorrect');
    } else {
        if (confirm('Add '+newQuantity+' x '+newItem+' to basket? ')) {
            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);
             amended = false;
             newItemList=''; itemlist=0;
             for (var i=0;i<=fulllist.length;i++) {
                 if (fulllist.substring(i,i+1) == '[') {
                     thisitem=1;
                     itemstart=i+1;
                     fullstart=i+1;
                 } else if (fulllist.substring(i,i+1) == ']') {
                     itemend=i;
                     thequantity=fulllist.substring(itemstart,itemend);
                     itemlist++;
                     if (theItem==newItem ) {
                         amended=true;
                         tempquantity=eval(thequantity)+eval(newQuantity);
                         newItemList=newItemList+'['+theItem+'|'+thePrice+'|'+theTaxable+'|'+theWeight+'|'+newAP+'|'+tempquantity+']';
                     } else {
                         newItemList=newItemList+'['+theItem+'|'+thePrice+'|'+theTaxable+'|'+theWeight+'|'+theAP+'|'+thequantity+']';
                     }
                 } else if (fulllist.substring(i,i+1)=='|') {
                     if (thisitem==1) theItem=fulllist.substring(itemstart,i);
                     if (thisitem== 2) thePrice=fulllist.substring(itemstart,i);
                     if (thisitem== 3) theTaxable=fulllist.substring(itemstart,i);
                     if (thisitem== 4) theWeight=fulllist.substring(itemstart,i);
                     if (thisitem== 5) theAP=fulllist.substring(itemstart,i);
                     thisitem++;itemstart=i+1;
                 }
             }
             if (amended==false) {
                 newItemList=newItemList+'['+newItem+'|'+newPrice+'|'+newTaxable+'|'+newWeight+'|'+newAP+'|'+newQuantity+']'; }
             index = document.cookie.indexOf('TheBasket');
             document.cookie='TheBasket='+newItemList+'; expires=Friday, 31-Dec-2010 08:00:00 GMT';
        }
    }
}
	
function getTotal(formatted) {
	currency=1;
	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;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;
			thequantity=fulllist.substring(itemstart,itemend);
			totprice=totprice+(eval(theprice*thequantity));
			itemlist=itemlist+1;
		} else if (fulllist.substring(i,i+1)=='|') {
			if (thisitem== 2) theprice=fulllist.substring(itemstart,i);
			thisitem++; itemstart=i+1;
		}
	}
	if (formatted == 'pv')
		{ return presentValue(totprice); }
	else
		{ return totprice; }
}

function getNumItems() {
	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);
	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;
			itemlist=itemlist+1;
		} else if (fulllist.substring(i,i+1)=='|') {
			thisitem++; itemstart=i+1;
		}
	}
	return itemlist;
}

function presentValue(value) {
    if(value<=0.9999) {
        newPounds='0';
    } else {
        newPounds=parseInt(value);
    }
    dec='1';
    for (var i=1; i<=2;i++) {
        dec=dec+'0';
    }
    if (value>0) {
        newPence=Math.round((value+.000008 - newPounds)*(eval(dec)));
    } else {
        newPence=0;
    }
    compstring='9';
    for (var i=1; i <=2-1;i++) {
        if (eval(newPence) <= eval(compstring)) newPence='0'+newPence;
        compstring=compstring+'9';
    }
    if (2>0) {
        newString='£' + newPounds + '.' + newPence + '';
    } else {
        newString='£' + newPounds + '';
    }
    return (newString);
}

function clearBasketonPage() {
    if (confirm('Are you sure you wish to clear the basket?')) {
        index=document.cookie.indexOf('TheBasket');
        document.cookie='TheBasket=.';
    }
}

function sC(name,value) {
    document.cookie=name+'='+escape(value)+';'+cookiesettings;
} 

function gC(name) {
	value='';
	index=document.cookie.indexOf(name+'=');
    if (index == -1) { return ''; }
	countbegin=(document.cookie.indexOf('=',index)+1);
    countend=document.cookie.indexOf(';',index);
    if(countend==-1) { countend=document.cookie.length; }
	value = document.cookie.substring(countbegin,countend);
	return unescape(value);
} 
// -->

