<!--

	<<1-java_valuta>>
	
	nc = "eDenter_basket";
			
	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(l) {
                var sfondocarrello = '<<1-colore2>>';
		var dImg = new Array("","");
		dImg[0] = '<img src="edis_disp0.gif" alt="<<4-non_disponibile>>">';
		dImg[1] = '<img src="edis_disp1.gif" alt="<<4-disponibile>>">';
		nc = "eDenter_basket" + l;
                index = document.cookie.indexOf(nc);
		countbegin = (document.cookie.indexOf("=", index) + 1);
        	countend = document.cookie.indexOf(";", index);
        	if (countend == -1) {
            		countend = document.cookie.length;
        	}
		if (index == -1) {
			countbegin = 0;
			countend = 0;
		}
		fulllist = document.cookie.substring(countbegin, countend);
		index = document.cookie.indexOf("eDenter_disp");
		countbegin = (document.cookie.indexOf("=", index) + 1);
        	countend = document.cookie.indexOf(";", index);
        	if (countend == -1) {
            		countend = document.cookie.length;
        	}
		if (index == -1) {
			countbegin = 0;
			countend = 0;
		}
		available = document.cookie.substring(countbegin, countend);
		totprice = 0;
		totiva = 0;
		impsconto = 0;
		impscontoiva = 0;
		document.writeln('<FORM NAME="updateform">');
		document.writeln('<div align="left">');
		document.writeln('<TABLE WIDTH=100% BORDER=0 CELLPADDING="2">');
		document.writeln('<TR BGCOLOR="<<1-colore1>>"><TD><b><FONT COLOR="<<1-colore0>>" FACE="Arial,Helvetica" SIZE=-1>'+"<<4-carrello_articolo>>"+'</FONT></b></TD><TD><b><FONT COLOR="<<1-colore0>>" FACE="Arial,Helvetica" SIZE=-1>'+"<<4-carrello_varianti>>"+'</FONT></b></TD><TD align="right"><b><FONT COLOR="<<1-colore0>>" FACE="Arial,Helvetica" SIZE=-1>'+"<<4-carrello_quantita>>"+'</FONT></b></TD><TD align="right"><b><FONT COLOR="<<1-colore0>>" FACE="Arial,Helvetica" SIZE=-1>'+"<<4-carrello_prezzo_unitario>>"+'</FONT></b></TD><td align="right"><b><FONT COLOR="<<1-colore0>>" FACE="Arial,Helvetica" SIZE=-1>'+"<<4-carrello_prezzo_totale>>"+'</FONT></b></TD><TD align="center" colspan="2"><b><FONT COLOR="<<1-colore0>>" FACE="Arial,Helvetica" SIZE=-1>' + "<<4-articolo_disponibilita>>" + '</FONT></b></TD></TR>');
		itemlist = 0;
		for (var i = 0; i <= fulllist.length; i++) {
			if (fulllist.substring(i,i+1) == '[') {
				itemstart = i+1;
				thisitem = 1;
				thisavail = available.substring(itemlist, itemlist +1);
				if (thisavail == "") {
					availimg=0;
				} else {
					availimg=parseInt(available.substring(itemlist, itemlist +1));
				}
			} else if (fulllist.substring(i,i+1) == ']') {
				itemend = i;
				thequantity = unescape(fulllist.substring(itemstart, itemend));
				if (thequantity * 1 >= scq2 && scq2 > -1) {
					theprice = theprice * imp2;
					ivaitem = ivaitem * imp2;
				} else if (thequantity * 1 >= scq1 && scq1 > -1) {
					theprice = theprice * imp1;
					ivaitem = ivaitem * imp1;
				}
				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="<<1-colore0>>" FACE="Arial,Helvetica" SIZE=-1><a href="' + artlink + '">' + thecode + ' ' +theitem+'</a></FONT></td>');
				option1234 = '';
				if (option1 != '') {
					option1234 = option1;
				}
				if (option2 != '') {
					if (option1234 != '') {
						option1234 = option1234 + '<BR>';
					}
					option1234=option1234 + option2;
				}
				if (option3 != '') {
					if (option1234 != '') {
						option1234 = option1234 + '<BR>';
					}
					option1234=option1234 + option3;
				}
				if (option4 != '') {
					if (option1234 != '') {
						option1234 = option1234 + '<BR>';
					}
					option1234=option1234 + option4;
				}
				document.write('<td><FONT COLOR="<<1-colore0>>" FACE="Arial,Helvetica" SIZE=-1>'+option1234 +'</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="<<1-colore0>>" FACE="Arial,Helvetica" SIZE=-1>'+alterError(eval(theprice))+'</FONT></td><td valign="top" align="right"><FONT COLOR="<<1-colore0>>" FACE="Arial,Helvetica" SIZE=-1>'+alterError(itemtotal)+'</FONT></td><td align="center" valign="top">' + dImg[availimg] + '</td><td  align="center" valign="top"><a href="javascript:EliminaArt('+itemlist+')" onMouseOver="window.status=\'\'; return true"><FONT COLOR="<<1-colore0>>" FACE="Arial,Helvetica" SIZE=-1>'+"<<4-carrello_elimina>>"+'</FONT></a><BR><a href="javascript:ModificaArt('+itemlist+',document.updateform.quant'+itemlist+'.value)" onMouseOver="window.status=\'\'; return true"><FONT COLOR="<<1-colore0>>" FACE="Arial,Helvetica" SIZE=-1>'+"<<4-carrello_aggiorna>>"+'</FONT></a></td></tr>');

                                if (sfondocarrello == '<<1-colore2>>') {
                                  sfondocarrello = '<<1-colore3>>';
                                } else {
                                  sfondocarrello = '<<1-colore2>>';
                                }



			} else if (fulllist.substring(i,i+1) == '|') {
				if (thisitem==1) theitem = unescape(fulllist.substring(itemstart, i));
				if (thisitem==2) thecode = unescape(fulllist.substring(itemstart, i));
				if (thisitem==3) artid = unescape(fulllist.substring(itemstart, i));
				if (thisitem==4) option1 = unescape(fulllist.substring(itemstart, i));
				if (thisitem==5) option2 = unescape(fulllist.substring(itemstart, i));
				if (thisitem==6) option3 = unescape(fulllist.substring(itemstart, i));
				if (thisitem==7) option4 = unescape(fulllist.substring(itemstart, i));
				if (thisitem==8) pesoitem = unescape(fulllist.substring(itemstart, i));
				if (thisitem==9) theprice = unescape(fulllist.substring(itemstart, i));
				if (thisitem==10) ivaitem = unescape(fulllist.substring(itemstart, i));
				if (thisitem==11) codeitem= unescape(fulllist.substring(itemstart, i));
				if (thisitem==12) scq1 = unescape(fulllist.substring(itemstart, i));
				if (thisitem==13) imp1 = unescape(fulllist.substring(itemstart, i));
				if (thisitem==14) scq2 = unescape(fulllist.substring(itemstart, i));
				if (thisitem==15) imp2 = unescape(fulllist.substring(itemstart, i));
				if (thisitem==16) artlink = unescape(fulllist.substring(itemstart, i));
				if (thisitem==17) alq = unescape(fulllist.substring(itemstart, i));
				if (thisitem==18) acqid = unescape(fulllist.substring(itemstart +1, i -1));
				thisitem++;
				itemstart=i+1;
			}
		}

		if (itemlist==0) {
			document.writeln('<TR BGCOLOR="<<1-colore2>>"><TD colspan="7"><FONT COLOR="<<1-colore0>>" FACE="Arial,Helvetica" SIZE=-1>'+"<<4-carrello_vuoto>>"+'</FONT></TD></TR>');
		}

		document.writeln('<tr BGCOLOR="<<1-colore1>>"><td colspan=4><b><FONT COLOR="<<1-colore0>>" FACE="Arial,Helvetica" SIZE=-1>'+"<<4-carrello_totale_ordine>>"+'</FONT></b></td><td align=right nowrap><b><FONT COLOR="<<1-colore0>>" FACE="Arial,Helvetica" SIZE=-1>'+valuta+alterError(totprice)+'</FONT></b></td><td  colspan="2">&nbsp;</td></tr>');

		scp = 1;
		if (scl > 0) {
			scp = 1 - scl;
			scp = Math.round(scp * 100) / 100;
		} else if (totprice * 1 > scimp[l] && scperc[l] * 1 < 1) {
			scp = scperc[l];
		}
		if (scp < 1) {
			newtotprice = totprice * scp;
			impsconto = totprice - newtotprice;
			totprice = newtotprice;
			newtotiva = totiva * scp;
			impscontoiva = totiva - newtotiva;
			totiva = newtotiva;
			
			document.writeln('<tr BGCOLOR="<<1-colore2>>"><td colspan=4><FONT COLOR="<<1-colore0>>" FACE="Arial,Helvetica" SIZE=-1>'+"<<4-sconto>>"+'</FONT></td><td align=right nowrap><FONT COLOR="<<1-colore0>>" FACE="Arial,Helvetica" SIZE=-1>'+ '-' +alterError(impsconto)+'</FONT></td><td colspan="2">&nbsp;</td></tr>');

			document.writeln('<tr BGCOLOR="<<1-colore1>>"><td colspan=4><b><FONT COLOR="<<1-colore0>>" FACE="Arial,Helvetica" SIZE=-1>'+"<<4-carrello_totale_scontato>>"+'</FONT></b></td><td align=right nowrap><b><FONT COLOR="<<1-colore0>>" FACE="Arial,Helvetica" SIZE=-1>'+valuta+alterError(totprice)+'</FONT></b></td><td colspan="2">&nbsp;</td></tr>');

		}

		if (<<1-java_ivacompresa>> == 0) {
			document.writeln('<tr BGCOLOR="<<1-colore1>>"><td colspan=4><b><FONT COLOR="<<1-colore0>>" FACE="Arial,Helvetica" SIZE=-1>'+"<<4-carrello_iva>>"+'</FONT></b></td><td align=right nowrap><b><FONT COLOR="<<1-colore0>>" FACE="Arial,Helvetica" SIZE=-1>'+valuta+alterError(totiva)+'</FONT></b></td><td colspan="2">&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("<<4-acquista_errore_quantita>>");
		} 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 + "[" + escape(theitem) + "|";
						newItemList = newItemList + escape(thecode) + "|";
						newItemList = newItemList + escape(artid) + "|";
						newItemList = newItemList + escape(option1) + "|";
						newItemList = newItemList + escape(option2) + "|";
						newItemList = newItemList + escape(option3) + "|";
						newItemList = newItemList + escape(option4) + "|";
						newItemList = newItemList + escape(pesoitem) + "|";
						newItemList = newItemList + escape(theprice) + "|";
						newItemList = newItemList + escape(ivaitem) + "|";
						newItemList = newItemList + escape(codeitem) + "|";
						newItemList = newItemList + escape(scq1) + "|";
						newItemList = newItemList + escape(imp1) + "|";
						newItemList = newItemList + escape(scq2) + "|";
						newItemList = newItemList + escape(imp2) + "|";
						newItemList = newItemList + escape(artlink) + "|"
						newItemList = newItemList + escape(alq) + "|";
						newItemList = newItemList + "!" + escape(acqid) + "!|";
						newItemList = newItemList + escape(newquant) + "]";
					}
				} else if (fulllist.substring(i,i+1) == '|') {
					if (thisitem==1) theitem = unescape(fulllist.substring(itemstart, i));
					if (thisitem==2) thecode = unescape(fulllist.substring(itemstart, i));
					if (thisitem==3) artid = unescape(fulllist.substring(itemstart, i));
					if (thisitem==4) option1 = unescape(fulllist.substring(itemstart, i));
					if (thisitem==5) option2 = unescape(fulllist.substring(itemstart, i));
					if (thisitem==6) option3 = unescape(fulllist.substring(itemstart, i));
					if (thisitem==7) option4 = unescape(fulllist.substring(itemstart, i));
					if (thisitem==8) pesoitem = unescape(fulllist.substring(itemstart, i));
					if (thisitem==9) theprice = unescape(fulllist.substring(itemstart, i));
					if (thisitem==10) ivaitem = unescape(fulllist.substring(itemstart, i));
					if (thisitem==11) codeitem= unescape(fulllist.substring(itemstart, i));
					if (thisitem==12) scq1 = unescape(fulllist.substring(itemstart, i));
					if (thisitem==13) imp1 = unescape(fulllist.substring(itemstart, i));
					if (thisitem==14) scq2 = unescape(fulllist.substring(itemstart, i));
					if (thisitem==15) imp2 = unescape(fulllist.substring(itemstart, i));
					if (thisitem==16) artlink = unescape(fulllist.substring(itemstart, i));
					if (thisitem==17) alq = unescape(fulllist.substring(itemstart, i));
					if (thisitem==18) acqid = unescape(fulllist.substring(itemstart +1, i -1));
					thisitem++;
					itemstart=i+1;
				}
			}
			index = document.cookie.indexOf(nc);
			document.cookie=nc + "="+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(nc);
		document.cookie= nc + "="+newItemList;
		self.location = "cart.htm";
	}

	function SvuotaCarrello() {
		if (confirm("<<4-carrello_conferma_svuota>>")) {
			index = document.cookie.indexOf(nc);
			document.cookie= nc + "=.";
			self.location = "cart.htm";
		}
	}
//-->