function displayItem() 
{
	var tablerowcolor = '#FFFFCC';
    index = document.cookie.indexOf("eCart");
	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('<TABLE BORDER=0 CELLPADDING="2">');
	//document.writeln('<TR BGCOLOR="#C0C0C0"><TD><b><FONT FACE="Tahoma" SIZE="2">Item</FONT></b></TD><TD align="right"><b><FONT FACE="Tahoma" SIZE="2">Quantity</FONT></b></TD><TD align="right"><b><FONT FACE="Tahoma" SIZE="2">Unit Price</FONT></b></TD><td align="right"><b><FONT FACE="Tahoma" SIZE="2">Cost</FONT></b></td></TR>');
    //document.writeln('<TR BGCOLOR="F8F8F8"><TD colspan="4"><HR></TD></TR>');
	document.writeln('<table border="0" width="50%" cellspacing="1" id="table1">');
	document.writeln('<tr>');
	document.writeln('<td width="80%" height="25" bgcolor="#F9DF78">');
	document.writeln('<p align="center"><b><font face="Tahoma" size="2">Item List</font></b></td>');
	document.writeln('</tr>');
	document.writeln('<tr>');
	document.writeln('<td width="80%" height="3" bgcolor="#FFFFFF">');
	document.writeln('<p align="center"><b><font face="Tahoma" size="2"></font></b></td>');
	document.writeln('</tr>');

	itemlist = 0;
	for (var i = 0; i <= fulllist.length; i++) 
	{
		if (fulllist.substring(i,i+1) == '[') 
		{
			thisitem = 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.write('<tr BGCOLOR="'+tablerowcolor+'"><td><FONT FACE="Tahoma" SIZE="2">'+theitem+'</FONT></td>');
            //document.writeln('<td align=right><FONT FACE="Tahoma" SIZE="2">'+thequantity+'</FONT></td>
            //<td align=right><FONT FACE="Tahoma" SIZE="2">'+theprice+'</FONT></td>
            //<td align=right><FONT FACE="Tahoma" SIZE="2">'+geterror(itemtotal)+'</FONT></td></tr>');
			document.write('<tr>');
			document.write('<td width="80%" height="25" bgcolor="'+tablerowcolor+'">');
			document.write('<p align="left"><font face="Tahoma" size="2">&nbsp;'+itemlist+'.&nbsp;'+theitem+'</font></td>');
			document.write('</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="'+geterror(itemtotal)+'" SIZE="40">');
			document.writeln('<input type="hidden" name="item'+itemlist+'" value="'+theitem+'" size="40">');
			document.writeln('<input type="hidden" name="totalitem" value="'+itemlist+'" size="10">');

			if (tablerowcolor == '#FFFFFF') 
            {
            	tablerowcolor = "#FFFFCC";
            }
            else 
            {
            	tablerowcolor = "#FFFFFF";
            }
		} 
		else if (fulllist.substring(i,i+1) == '|') 
		{
			if (thisitem==1) 
			{
				theitem = fulllist.substring(itemstart, i);
			}
			if (thisitem==2) 
			{
				theprice = fulllist.substring(itemstart, i);
			}
			thisitem++;
			itemstart=i+1;
		}
	}

    //document.writeln('<TR BGCOLOR="F8F8F8"><TD colspan="4"><HR></TD></TR>');
    //document.writeln('<tr BGCOLOR="#C0C0C0"><td colspan=3><b><FONT FACE="Tahoma" SIZE="2">Order Total</FONT></b></td><td align=right><b><FONT FACE="Tahoma" SIZE="2">S$'+geterror(totprice)+'</FONT></b></td></tr>');
    //document.writeln('<INPUT TYPE="hidden" NAME="Goods Total" VALUE="'+geterror(totprice)+'" SIZE="40">');
	//document.writeln('</TABLE>');
	document.writeln('<tr>');
	document.writeln('<td width="80%" height="25" bgcolor="#F9DF78">');
	document.writeln('<p align="left"><font face="Tahoma" size="2">&nbsp;Total Items = '+itemlist+'</font></td>');
	document.writeln('</tr>');
	document.writeln('</table>');
}

function geterror(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);
}
