// JavaScript Document

<!-- TARGET BLANK

var wCarrello;
var x=1;

function apri(uri,nome,mnbar,tlbar,lcbar,drbar,stbar,scbar,rsz,wdt,hgt) {
	wCarrello = window.open(uri,nome,"menubar=" + mnbar + ",toolbar=" + tlbar + ",location=" + lcbar + ",directories=" + drbar + ",status=" + stbar + ",scrollbars=" + scbar + ",resizable=" + rsz + ",width=" + wdt + ",height=" + hgt);
	
	var dtOggi = new Date()
  	var dtExpires = new Date()
  	dtExpires.setTime(dtOggi.getTime() + 24 * 1 * 3600000)
 	document.cookie = "nomeFiglio=" + escape(wCarrello) +"; expires=" + dtExpires.toGMTString();
}

function aggiorna(questo) {
	opener.document.location=questo;
	
}

function invia(index) {
	if(index==1){
		//Aggiornamento carrello
		document.forms['aggiornaCarrello'].action = "upCarrello.php";
	}
	if(index==2){
		//Stampa del pdf
		document.forms['aggiornaCarrello'].target = "blank";
		document.forms['aggiornaCarrello'].action = "stampaCarrello.php";
	}
	if(index==3){
		//Aggiornamento carrello
		document.forms['aggiornaCarrello'].action = "invioOrdine.php";
	}
	if(index==4){
		//Salvataggio carrello
		document.forms['aggiornaCarrello'].action = "salvaOrdine.php";
	}
	document.forms['aggiornaCarrello'].submit();
	
}

function aggiornaCarrello(questo) {
	var asCookies = document.cookie.split("; ");
	
	// ciclo su tutti i cookies
  	for (var iCnt = 0; iCnt < asCookies.length; iCnt++)
  	{
    	// leggo singolo cookie "Nome = Valore"
    	var asCookie = asCookies[iCnt].split("=");
    	//alert(asCookie[0]);
    	if ("nomeFiglio" == asCookie[0]) { 
      		//return (unescape(asCookie[1]));
      		nomeFiglio = asCookie[1];
      		nomefiglio.document.location=questo;
      		//alert(asCookie[1]);
    	}
  	}
	
	return;
	
}

function buildSelect(x) { //alert(x) ; //return

	if (x == "1") { 
  		option0 = new Option("Nessun Modello",0)
  		option1 = new Option("Nessuna Versione",0)
  		// write them
  		//alert(document.form1.model_id);
		if (document.form1.model_id){
			document.form1.model_id.options.length = 0;
			document.form1.model_id.options[0] = option0;
		}
	    if (document.form1.version_id){
		    document.form1.version_id.options.length = 0;
		    document.form1.version_id.options[0] = option1;
	    }
	   
	    document.form1.submit();
	    return;
	}

	if (x == "2") { 
  		option1 = new Option("Nessuna Versione",0)
  
	  	if (document.form1.version_id){
		  	document.form1.version_id.options.length = 0;
		  	document.form1.version_id.options[0] = option1;
	  	}
 	 	document.form1.submit();
  		return;
 	}
 
}

//-->