<!--

	var valuta="Euro ";
var valuta2="L. ";
var exch= .000516457;
var SecVal= 0;
var sepmigl=".";
var sepdec=",";
var PutDec= 1;
var PutDec2= 0;

			
	function MettiPunti(prezzo) {
		var newprice='';
		var oldprice=prezzo+'s';
		var lung=oldprice.length-1;
		oldprice=oldprice.substring(0,lung);
		while (lung>3) {
			newprice=sepmigl+oldprice.substring(lung-3,lung)+newprice;
			oldprice=oldprice.substring(0,lung-3);
			lung=oldprice.length;  
		}
		newprice=oldprice+newprice;
		return (newprice);
	}
	
	function alterError(value) {
		if (PutDec !=0) {
			if (value<=0.99) {
				newPounds = '0';
			} else {
				newPounds = parseInt(value);
			}
			newPence = Math.round((value - newPounds)* 100);
			if (newPence == 100) {newPence =0; newPounds ++;}
			if (eval(newPence) <= 9) newPence='0'+newPence;
			newString = MettiPunti(newPounds);
			if (eval(newPence) != 0) {
				newString= newString + sepdec + newPence;
			}
			else {
				newString= newString + sepdec + '00';
			}
		}
		else {
			newPounds = Math.round(value);
			newString = MettiPunti(newPounds);
		}
		return (newString);
	}

function MostraCarrello() {
                var sfondocarrello = '#FFFFE7';
                index = document.cookie.indexOf("eDbasket");
		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;
		totiva = 0;
		document.writeln('<FORM NAME="updateform">');
		document.writeln('<div align="left">');
		document.writeln('<TABLE WIDTH=100% BORDER=0 CELLPADDING="2">');
		document.writeln('<TR BGCOLOR="#DEE7DE"><TD><b><FONT COLOR="#003399" FACE="Arial,Helvetica" SIZE=-1>'+"Articolo"+'</FONT></b></TD><TD><b><FONT COLOR="#003399" FACE="Arial,Helvetica" SIZE=-1>'+"Varianti"+'</FONT></b></TD><TD align="right"><b><FONT COLOR="#003399" FACE="Arial,Helvetica" SIZE=-1>'+"Quantità"+'</FONT></b></TD><TD align="right"><b><FONT COLOR="#003399" FACE="Arial,Helvetica" SIZE=-1>'+"Prezzo unitario"+'</FONT></b></TD><td align="right"><b><FONT COLOR="#003399" FACE="Arial,Helvetica" SIZE=-1>'+"Prezzo totale"+'</FONT></b></TD><TD>&nbsp;</TD></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));
				itemtotaliva = 0;
				itemtotaliva = (eval(ivaitem*thequantity));
				temptotal = itemtotal * 100;
				totprice = totprice + itemtotal;
				totiva = totiva + itemtotaliva;
				itemlist=itemlist+1;
				document.write('<tr valign="top"BGCOLOR="'+sfondocarrello+'"><td><FONT COLOR="#003399" FACE="Arial,Helvetica" SIZE=-1>'+theitem+'</FONT></td>');
				option123 = '';
				if (option1 != '') {
					option123 = '<sup>1</sup>&nbsp;' + option1;
				}
				if (option2 != '') {
					if (option123 != '') {
						option123 = option123 + '<BR>';
					}
					option123=option123 + '<sup>2</sup>&nbsp;' + option2;
				}
				if (option3 != '') {
					if (option123 != '') {
						option123 = option123 + '<BR>';
					}
					option123=option123 + '<sup>3</sup>&nbsp;' + option3;
				}
				document.write('<td><FONT COLOR="#003399" FACE="Arial,Helvetica" SIZE=-1>'+option123+'</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 COLOR="#003399" FACE="Arial,Helvetica" SIZE=-1>'+alterError(eval(theprice))+'</FONT></td><td valign="top" align="right"><FONT COLOR="#003399" FACE="Arial,Helvetica" SIZE=-1>'+alterError(itemtotal)+'</FONT></td><td  align="center" valign="top"><a href="javascript:EliminaArt('+itemlist+')" onMouseOver="window.status=\'\'; return true"><FONT COLOR="#003399" FACE="Arial,Helvetica" SIZE=-1>'+"Elimina"+'</FONT></a><BR><a href="javascript:ModificaArt('+itemlist+',document.updateform.quant'+itemlist+'.value)" onMouseOver="window.status=\'\'; return true"><FONT COLOR="#003399" FACE="Arial,Helvetica" SIZE=-1>'+"Aggiorna"+'</FONT></a></td></tr>');

                                if (sfondocarrello == '#FFFFE7') {
                                  sfondocarrello = '#FFFFFF';
                                } else {
                                  sfondocarrello = '#FFFFE7';
                                }



			} else if (fulllist.substring(i,i+1) == '|') {
				if (thisitem==1) theitem = fulllist.substring(itemstart, i);
				if (thisitem==2) option1 = fulllist.substring(itemstart, i);
				if (thisitem==3) option2 = fulllist.substring(itemstart, i);
				if (thisitem==4) option3 = fulllist.substring(itemstart, i);
				if (thisitem==5) pesoitem = fulllist.substring(itemstart, i);
				if (thisitem==6) theprice = fulllist.substring(itemstart, i);
				if (thisitem==7) ivaitem = fulllist.substring(itemstart, i);
				thisitem++;
				itemstart=i+1;
			}
		}

		if (itemlist==0) {
			document.writeln('<TR BGCOLOR="#FFFFE7"><TD colspan="6"><FONT COLOR="#003399" FACE="Arial,Helvetica" SIZE=-1>'+"(Il tuo carrello attualmente è vuoto)"+'</FONT></TD></TR>');
		}

		document.writeln('<tr BGCOLOR="#DEE7DE"><td colspan=4><b><FONT COLOR="#003399" FACE="Arial,Helvetica" SIZE=-1>'+"Totale Ordine"+'</FONT></b></td><td align=right nowrap><b><FONT COLOR="#003399" FACE="Arial,Helvetica" SIZE=-1>'+valuta+alterError(totprice)+'</FONT></b></td><td>&nbsp;</td></tr>');
		if (1 == 0) {
			document.writeln('<tr BGCOLOR="#DEE7DE"><td colspan=4><b><FONT COLOR="#003399" FACE="Arial,Helvetica" SIZE=-1>'+"IVA"+'</FONT></b></td><td align=right nowrap><b><FONT COLOR="#003399" FACE="Arial,Helvetica" SIZE=-1>'+valuta+alterError(totiva)+'</FONT></b></td><td>&nbsp;</td></tr>');
		}
		document.writeln('</TABLE><cr>');
		document.writeln('</div>');
		document.writeln('</FORM>');
	}
		
	function ModificaArt(itemno, newquant) {
		if (isNaN(newquant)) {
			newquant=0;
		}
		newquant=Math.floor(newquant);
		if (newquant <= 0) {
			rc = alert("Inserire una quantità corretta!");
		} else {
			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+'|'+option1+'|'+option2+'|'+option3+'|'+pesoitem+'|'+theprice+'|'+ivaitem+'|'+newquant+']';
					}
				} else if (fulllist.substring(i,i+1) == '|') {
					if (thisitem==1) theitem = fulllist.substring(itemstart, i);
					if (thisitem==2) option1 = fulllist.substring(itemstart, i);
					if (thisitem==3) option2 = fulllist.substring(itemstart, i);
					if (thisitem==4) option3 = fulllist.substring(itemstart, i);
					if (thisitem==5) pesoitem = fulllist.substring(itemstart, i);
					if (thisitem==6) theprice = fulllist.substring(itemstart, i);
					if (thisitem==7) ivaitem = fulllist.substring(itemstart, i);
					thisitem++;
					itemstart=i+1;
				}
			}
			index = document.cookie.indexOf("eDbasket");
			document.cookie="eDbasket="+newItemList;
			self.location = "cart.htm";
		}

	}

	function EliminaArt(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("eDbasket");
		document.cookie="eDbasket="+newItemList;
		self.location = "cart.htm";
	}

	function SvuotaCarrello() {
		if (confirm("Vuoi veramente rimuovere tutti gli articoli dal carrello?")) {
			index = document.cookie.indexOf("eDbasket");
			document.cookie="eDbasket=.";
			self.location = "cart.htm";
		}
	}
//-->
