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('<FORM NAME="updateform">');
	//document.writeln('<div align="center">');
	//document.writeln('<TABLE WIDTH=100% 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><TD>&nbsp;</TD></TR>');
    //document.writeln('<TR BGCOLOR="F8F8F8"><TD colspan="5"><HR></TD></TR>');
	document.writeln('<form method="POST" name="updateform">');
	document.writeln('<div align="center">');
	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('<td width="20%" height="25" bgcolor="#F9DF78">');
	document.writeln('<p align="center"><b><font face="Tahoma" size="2">Action</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('<td width="20%" 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) == '[') 
		{
			itemstart = i+1;
			thisitem = 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 valign="top"BGCOLOR="'+tablerowcolor+'"><td><FONT FACE="Tahoma" SIZE="2">'+theitem+'</FONT></td>');
            //document.write('<td valign="top" align="right"><INPUT TYPE=TEXT NAME="quant'+itemlist+'" VALUE="'+thequantity+'" SIZE=3></td>
            //<td valign="top" align="right"><FONT FACE="Tahoma" SIZE="2">'+theprice+'</FONT></td>
            //<td valign="top" align="right"><FONT FACE="Tahoma" SIZE="2">'+geterror(itemtotal)+'</FONT></td>
            //<td  align="center" valign="top"><a href="javascript:deleteItem('+itemlist+')"><FONT FACE="Tahoma" SIZE="2">Delete</FONT></a>
            //&nbsp;<a href="javascript:changeItem('+itemlist+',document.updateform.quant'+itemlist+'.value)"><FONT FACE="Tahoma" SIZE="2">Update</FONT></a></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('<td width="20%" height="25" bgcolor="'+tablerowcolor+'"><a href="javascript:deleteItem('+itemlist+')">');
			document.write('<p align="center"><font face="Tahoma" size="2">Delete</font></a></td>');
			document.write('</tr>');
			
            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="FCFCFC"><TD colspan="5"><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">$ '+geterror(totprice)+'</FONT></b></td><td>&nbsp;</td></tr>');
	//document.writeln('</TABLE>');
	//document.writeln('</div>');
	//document.writeln('</FORM>');
	document.writeln('<tr>');
	document.writeln('<td width="80%" bgcolor="#F9DF78">&nbsp;</td>');
	document.writeln('<td width="20%" bgcolor="#F9DF78">&nbsp;</td>');
	document.writeln('</tr>');
	document.writeln('</table>');
	document.writeln('</div>');
	document.writeln('</form>');
}

function changeItem(itemno, newquant) 
{
	newItemList = null;
	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;
			itemlist=itemlist+1;
			if (itemlist != itemno) 
			{
				newItemList = newItemList+'['+fulllist.substring(fullstart, itemend)+']';
			} 
			else 
			{
				newItemList = newItemList + '['+theitem+'|'+theprice+'|'+newquant+']';
			}
		} 
		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;
		}
	}
    index = document.cookie.indexOf("eCart");
    document.cookie="eCart="+newItemList;
    self.location = "enquiry_cart.shtml";
}

function deleteItem(itemno) 
{
	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("eCart");
    document.cookie="eCart="+newItemList;
    self.location = "enquiry_cart.shtml";
}

function emptyCart() 
{
	if (confirm('Confirm to remove all items?')) 
	{
    	index = document.cookie.indexOf("eCart");
        document.cookie="eCart=.";
        self.location = "enquiry_cart.shtml";
	}
}

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

