<!--
	
	<<1-java_valuta>>

	function CheckAvail(artn, newCode) {
		code1234 = "?";
		for (n=1; n<5; n++) {
			optname = "op" + n + artn;
			opcode = "";
			nok = Esiste(optname);
			if (nok == true) {
				opcode = CartOptionsCode(optname);
			}
			code1234 = code1234 + opcode + "?";
		}
		imagename = "dispimg" + artn;
		if (document.images[imagename]) {
			document.images[imagename].src="dispimg.php" + "?a=" + escape(newCode) + "&b=" + escape(code1234);
		}
	}

	function Acquista(artn, artid, newCode, newItem, newPrice, newIva, newPeso, l, scq1, imp1, scq2, imp2, artlink) {
		
		opt = new Array('','','','','');
		option = new Array('','','','','');
		opcode = new Array('','','','','');
		opid = new Array('','','','','');

		newQuantity = 1;
		thecode = newCode;
		nok = Esiste('qt' + artn);
		if (nok == true) {		
			newQuantity = document.itemsform.elements['qt' + artn].value;
			if (isNaN(newQuantity)) {
				newQuantity=0;
			}
		}

		newQuantity=Math.floor(newQuantity);

		for (n=1; n<5; n++) {
			opt[n] = "op" + n + artn;
			nok = Esiste(opt[n]);
			if (nok != true) {
				opt[n] = ""
			}
			option[n]=CartOptionsText(opt[n]);
			opcode[n]=CartOptionsCode(opt[n]);
			opid[n]=CartOptionsId(opt[n]);
			
			nCar = option[n].length;
			if (nCar > 1) {
				UltimiCar = option[n].substring(nCar-2,nCar);
				if (UltimiCar == ' *') {
					option[n] = option[n].substring(0, nCar-2);
				}
			}

		}
		
		code1234 = "?";
		for (n=1; n<5; n++) {
			code1234 = code1234 + opcode[n] + "?";
		}
		option1234=' ('+option[1];
		if (option[2] != '') {
			option1234 = option1234 + ' ' + option[2];
		}
		if (option[3] != '') {
			option1234 = option1234 + ' ' + option[3];
		}
		if (option[4] != '') {
			option1234 = option1234 + ' ' + option[3];
		}

		option1234 = option1234 + ')';
		if (option[1]=='' && option[2]=='' && option[3]=='') {
			option1234='';
		}

		priceDiff= CartOptionsPrice(opt[1], opt[2], opt[3], opt[4]);
		pesoDiff= CartOptionsWeight(opt[1], opt[2], opt[3], opt[4]);
		newPrice = Math.round(newPrice * 1000 + priceDiff *1000) / 1000;
		if (newPrice < 0) {
			newPrice=0;
		}
		newPriceIva = 0;
		if (<<1-java_ivacompresa>> == 0) {
			newPriceIva = newPrice * newIva;
		}
		newPeso = (newPeso * 1  + pesoDiff * 1);
		if (newPeso < 0) {
			newPeso=0;
		}
		if (newQuantity <= 0) {
			rc = alert("<<4-acquista_errore_quantita>>");
		} else {
			//if (confirm("<<4-acquista_conferma1>>" + " " +newQuantity+" x "+newItem+option1234+" " + "<<4-acquista_conferma2>>")) {
				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;
	        		}
				acqid = artid+"."+opid[1]+"."+opid[2]+"."+opid[3]+"."+opid[4];
				dato = document.cookie.substring(countbegin,countend);
				npos = -1;
				if (index > -1) {
					npos = dato.indexOf("!" + escape(acqid) + "!|", index);
					if (npos > -1) {
						nleft = dato.indexOf("!|", npos +1) +2 ;
						nright = dato.indexOf("]", nleft);
						oldQuantity = unescape(dato.substring(nleft,nright));
						newq = newQuantity * 1 + oldQuantity * 1;
						dato=dato.substring(0,nleft)+escape(newq)+dato.substring(nright,dato.length);
					}
				}
				if (npos < 0) {
					dato = dato + "[" + escape(newItem) + "|";
					dato = dato + escape(thecode) + "|";
					dato = dato + escape(artid) + "|";
					dato = dato + escape(option[1]) + "|";
					dato = dato + escape(option[2]) + "|";
					dato = dato + escape(option[3]) + "|";
					dato = dato + escape(option[4]) + "|";
					dato = dato + escape(newPeso) + "|";
					dato = dato + escape(newPrice) + "|";
					dato = dato + escape(newPriceIva) + "|";
					dato = dato + escape(code1234) + "|";
					dato = dato + escape(scq1) + "|";
					dato = dato + escape(imp1) + "|";
					dato = dato + escape(scq2) + "|";
					dato = dato + escape(imp2) + "|";
					dato = dato + escape(artlink) + "|";
					dato = dato + escape(newIva) + "|";
					dato = dato + "!" + escape(acqid) + "!|";
					dato = dato + escape(newQuantity) + "]";
				}
				document.cookie= nc + "=" + dato;
				self.location = "cart.htm";
			//}

		}
		
	}


	function CartOptionsText(nome) {
		seltext = "";
		if (nome != '') {
			nok = Esiste(nome);
			if (nok == true) {
				selnum = document.itemsform.elements[nome].selectedIndex ;
				if (selnum > -1) {
					selpart = document.itemsform.elements[nome].options[selnum].value;
					sep=selpart.indexOf("|");
					len = selpart.length;
					testofin = selpart.substring(sep+1,len);
					seltext=testofin;
				}
			}
		}
		return seltext;
	}

	function CartOptionsCode(nome) {
		seltext = "";
		if (nome != '') {
			nok = Esiste(nome);
			if (nok == true) {
				selnum = document.itemsform.elements[nome].selectedIndex ;
				if (selnum > -1) {
					selpart = document.itemsform.elements[nome].options[selnum].value;
					sep1=selpart.indexOf("#");
					sep2=selpart.indexOf("|");
					testofin = selpart.substring(sep1+1,sep2);
					seltext=testofin;
				}
			}
		}
		return seltext;
	}

	function CartOptionsId(nome) {
		selnum = -1;
		if (nome != '') {
			nok = Esiste(nome);
			if (nok == true) {
				selnum = document.itemsform.elements[nome].selectedIndex ;
			}
		}
		return selnum;
	}

	
	function CartOptionsPrice(nome1, nome2, nome3, nome4) {

		nome = new Array ('',nome1,nome2,nome3,nome4);

		selprice = 0;
		
		for (n=1; n<5;n++) {
		
			if (nome[n] != '') {
				nok = Esiste(nome[n]);
				if (nok == true) {
					selnum = document.itemsform.elements[nome[n]].selectedIndex ;
					if (selnum > -1) {
						selpart = document.itemsform.elements[nome[n]].options[selnum].value;
						sep1=-1;
						sep2=selpart.indexOf("=");
						testofin = selpart.substring(sep1+1,sep2);
						selprice = selprice + testofin * 1;
					}
				}
			}
		}

		return selprice;
	}


	function CartOptionsWeight(nome1, nome2, nome3, nome4) {

		nome = new Array ('',nome1,nome2,nome3,nome4);

		selweight = 0;
		
		for (n=1; n<5;n++) {
		
			if (nome[n] != '') {
				nok = Esiste(nome[n]);
				if (nok == true) {
					selnum = document.itemsform.elements[nome[n]].selectedIndex;
					if (selnum > -1) {
						selpart = document.itemsform.elements[nome[n]].options[selnum].value;
						sep1=selpart.indexOf("=");
						sep2=selpart.indexOf("#");
						testofin = selpart.substring(sep1+1,sep2);
						selweight = selweight + testofin * 1;
					}
				}
			}
		}
		return selweight;
	}

	
	function Esiste(nome) {
		maxel = document.itemsform.length;
		for (nel=0; nel<maxel; nel++) {
			if (document.itemsform.elements[nel].name == nome) {
				return true;
			}
		}
		return false;
	}

//-->