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);
	}

	function showItems() {
                var tablerowcolor = '#66a6e5';
		index = document.cookie.indexOf("RCAcarrinho");
		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 width="700" CELLPADDING="3">');
		document.writeln('<TR BGCOLOR="#F9F9F9"><TD><font face=arial size=1 color=#696969 style=text-decoration:none;>PRODUTO</TD><TD align="center"><font face=arial size=1 color=#696969 style=text-decoration:none;>QUANTIDADE</TD><TD align="center"><font face=arial size=1 color=#696969 style=text-decoration:none;>VALOR POR UNIDADE</TD><td align="center"><font face=arial size=1 color=#696969 style=text-decoration:none;>VALOR TOTAL</td></TR>');
                document.writeln('<TR BGCOLOR="#FFFFFF">');

		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="#FFFFFF"> <td><font face=arial size=1 color=#696969 style=text-decoration:none;>'+theitem+'</FONT></td>');
				document.writeln('<td align=right><font face=arial size=1 color=#696969 style=text-decoration:none;>'+thequantity+'</FONT></td><td align=right><font face=arial size=1 color=#696969 style=text-decoration:none;>'+theprice+'</FONT></td><td align=right><font face=arial size=1 color=#696969 style=text-decoration:none;>'+alterError(itemtotal)+'</FONT></td></tr>');
				document.writeln('<INPUT TYPE="hidden" NAME="item'+itemlist+'" VALUE="'+theitem+'" SIZE="40">');
				document.writeln('<INPUT TYPE="hidden" NAME="quantidade'+itemlist+'" VALUE="'+thequantity+'" SIZE="30">');
				document.writeln('<INPUT TYPE="hidden" NAME="preço de'+itemlist+'" VALUE="'+theprice+'" SIZE="30">');
 				document.writeln('<INPUT TYPE="hidden" NAME="total de'+itemlist+'" VALUE="'+alterError(itemtotal)+'" SIZE="30">');

                                if (tablerowcolor == '#66a6e5') {
                                  tablerowcolor = "#66a6e5";
                                } else {
                                  tablerowcolor = "#66a6e5";
                                }

			} 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="#000000"></TR>');
		document.writeln('<tr BGCOLOR="#FFFFFF"><td colspan=3><font face=arial size=1 color=#696969 style=text-decoration:none;>O VALOR TOTAL DAS COMPRAS É ...:</FONT></b></td><td align=right><font face=arial size=1 color=#696969 style=text-decoration:none;>€ '+alterError(totprice)+'</FONT></b></td></tr>');
		document.writeln('<INPUT TYPE="hidden" NAME="Total gasto" VALUE="'+alterError(totprice)+'" SIZE="40">');
		document.writeln('</TABLE>');

	}
