	// 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);
	}

	// showItems () - creates a table of items in the basket and
	// creates the start of a form which sets information for
	// basket items.
	function showItems() {
		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;
		document.writeln('<FORM action="http://www.emicakes.com.sg/cgi-bin/BFormMail.pl" method="post" onSubmit="return checkData()">');
		document.writeln('<input type="hidden" name="recipient" value="sales@emicakes.com.sg,emicakes@rocketmail.com">');
		document.writeln('<input type="hidden" name="subject" value="Customer Order">');
		document.writeln('<input type="hidden" name="redirect" value="http://www.emicakes.com.sg/cart/order_process.htm">');
		document.writeln('<input type="hidden" name="courtesy_reply" value="yes">');
		document.writeln('<input type="hidden" name="courtesy_our_email" value="sales@emicakes.com.sg">');
		document.writeln('<input type="hidden" name="courtesy_our_url" value="http://www.emicakes.com.sg">');
		document.writeln('<input type="hidden" name="courtesy_reply_texta" value="Dear Sir/Madam,\n\nWe are pleased to confirm receipt of your online order and it is receiving attention. \nIf you had placed an online order a further confirmation will be dispatched by email within the next 24 hours. \nOnline orders received after office hours on Saturday, Sundays and on the eve of/and Public Holidays will be \nattended to on the next working day. \n\nIF YOU HAVE NOT RECEIVED any confirmation email/phone and get an ORDER NUMBER (6 digit), please contact Mariezel immediately \nat 6749 6782 to get a confirmation.\n\nORDER IS NOT CONFIRMED (no charges transacted) until the order number has been given to you">');
		document.writeln('<input type="hidden" name="courtesy_reply_textb" value="">');
		document.writeln('<input type="hidden" name="courtesy_who_we_are" value="Mariezel C. Balili">');
		document.writeln('<input type="hidden" name="courtesy_who_we_are2" value="Customer Relations Sales Executive\nTel: 6749 6782 \nMon-Sat 8am-5pm \nSkype: sales-emi\nMSN: sales-emi@hotmail.com">');
		document.writeln('<TABLE border="1" cellspacing="0" cellpadding="0" COLS=4>');
		document.writeln('<TR><TD><b>Item</b></TD><TD><b>Quantity</b></TD><TD><b>Cost Each</b></TD><td><b>Total Cost</b></td><TD><b>Action</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;
document.writeln('<tr><td>'+theitem+'</td><td align=right>'+thequantity+'</td><td align=right>'+theprice+'</td><td align=right>'+alterError(itemtotal)+'</td><td><a href="javascript:removeItem('+itemlist+')">Remove</a></td></tr>');
                document.writeln('<INPUT TYPE="hidden" NAME="item'+itemlist+'" VALUE="'+theitem+'" SIZE="40">');
 				document.writeln('<INPUT TYPE="hidden" NAME="quantity'+itemlist+'" VALUE="'+thequantity+'" SIZE="40">');
				document.writeln('<INPUT TYPE="hidden" NAME="price each'+itemlist+'" VALUE="'+theprice+'" SIZE="40">');
				document.writeln('<INPUT TYPE="hidden" NAME="total cost'+itemlist+'" VALUE="'+alterError(itemtotal)+'" SIZE="40">');
			} else if (fulllist.substring(i,i+1) == ',') {
				theitem = 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><b>Total</b></td><td align=right>'+alterError(totprice)+'</td></tr>');
		document.writeln('<INPUT TYPE="hidden" NAME="Goods_Total" VALUE="'+alterError(totprice)+'" SIZE="40">');
		document.writeln('</TABLE>');

	}
	function removeItem(itemno) {
		if (confirm('Clear this item?')) {
		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("TheBasket");
		document.cookie="TheBasket="+newItemList;
		document.location = "bbuy.htm";
		}// end confirm delete
	}
