
 function MakeTen(expr,decimal){
	var str="" + Math.round(eval(expr) * Math.pow(10,decimal))
	while (str.length <= decimal){
	   str = "0" + str
	}
	var decpoint = str.length - decimal
	return str.substring(0,decpoint) + "." + str.substring(decpoint,str.length);
}

function MakeTwo(expr){
	return "£" + MakeTen(expr,2)
}       

 function buyItem(newItem, newPrice, newQuantity, newOption) {
                 if (newPrice<= 0) {
                        rc = alert('Cost options first');
                        return false;
                }
                if (newQuantity <= 0) {
                        rc = alert('Zero is not a quantity.');
                        return false;
                }
                if (newOption == 9)  {
                    newOption ='';
                    var pos = newPrice.indexOf("k");
                    newItem = newItem + ' - ' + newPrice.substring(0,pos+1);
                    newPrice = newPrice.substring(pos+1,newPrice.length);
                     }
                if (newQuantity >= 0) {
                        index = document.cookie.indexOf("MyCart");
                        countbegin = (document.cookie.indexOf("=", index) + 1);
                        countend = document.cookie.indexOf(";", index);
                        if (countend == -1) {
                                countend = document.cookie.length;
			                        }
                        document.cookie="MyCart="+document.cookie.substring(countbegin, countend)+"["+newItem+","+newPrice+"^"+newOption+"~"+newQuantity+"]";
                }
                return true;
        }
	 function resetShoppingCart() {
                index = document.cookie.indexOf("MyCart");
                document.cookie="MyCart=.";
        }


