//Funzioni Js chevengo richiamate in varie pagine del sito 
   
 

var statoSottocat = 0;	
var statoCat = 0;
var oldCategoria = 0;
var oldSettore=0;


  function OpenImage(ID)
		{
			window.open("Immagini.php?Codice="+ID,"_blank","width=680,height=480,left=200,top=300,scrollbars=yes" );
		}


  function OpenImageVar(ID,Var)
		{
			window.open("Immagini_Var.php?Codice="+ID+"&Variante="+Var,"_blank","width=700,height=540,left=200,top=300,scrollbars=yes" );
		}

  function isNull(val) { return (val == null); }

  function openSite(sito){
	window.open(sito,'_blank');
}
  //Che crea il file di esportazione catalogo
  function checkEnter(e) 
	{
		if(!e) var e = window.event;

		if (e.keyCode) code = e.keyCode;
		else if (e.which) code = e.which;
		
		if(code==13) {
			LoadArticoliRicerca();

		}

	}

  function AggiornaArchivio() {
	
	 jsNameFile = document.getElementById("txtFile").value
	 jsNameFile = jsNameFile.substr( (jsNameFile.length-3) ,jsNameFile.length)
	 jsNameFile = jsNameFile.toLowerCase()
			if ( (jsNameFile != "zip") && (jsNameFile != "ZIP") ) {
					alert("E' possibile allegare dei file solo con formato zip!")
					return;
			}
			else {
		var xmlHttp;
		var timeout = null;
		var IDCarrello=document.getElementById("IDCarrello").value;
		
		try {
		  // Firefox, Opera 8.0+, Safari
		  xmlHttp = new XMLHttpRequest();
		} catch (e) {
		  // Internet Explorer
		  try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		  } catch (e) {
			try {
			  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
			  alert("Your browser does not support AJAX!");
			}
		  }
		}
		xmlHttp.onreadystatechange = function() {
		  articoli = document.getElementById("Articoli")
		  intestazione = document.getElementById("Intestazione")
		  
		  intestazione.innerHTML="<P><B>ESPORTAZIONE</B></P>";
		  
		  if(xmlHttp.readyState == 4) {
			articoli.innerHTML = xmlHttp.responseText;
			clearTimeout(timeout);
		  }
		  else{
			articoli.innerHTML ="<img src='Images/loader.gif'>";
			if (timeout == null) {      
				function timeoutFunc() {         
				xmlHttp.abort();         
				articoli.innerHTML = "Timeout...";      
				} 
				
				timeout = setTimeout( timeoutFunc, 20*1000 );       
					 
			}
			
			
		  }
		}
		jsNameFile = document.getElementById("txtFile").value;
		cmdline = "ReadArchivio.php"
		xmlHttp.open("POST", cmdline, true);
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlHttp.send("IDCarrello="+ IDCarrello + "&txtFile=" + jsNameFile );
	}
  }	
	
  function ImportaCatalogo() {
	
    var xmlHttp;
	var timeout = null;
	var IDCarrello=document.getElementById("IDCarrello").value;
	
	try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
	xmlHttp.onreadystatechange = function() {
      articoli = document.getElementById("Articoli")
	  intestazione = document.getElementById("Intestazione")
	  
	  intestazione.innerHTML="<P><B>IMPORTAZIONE</B></P>";
	  
	  if(xmlHttp.readyState == 4) {
        articoli.innerHTML = xmlHttp.responseText;
		
		clearTimeout(timeout);
      }
	  else{
		articoli.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			articoli.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 20*1000 );       
			     
		}
		
		
	  }
    }
    cmdline = "ImportaArchivio.php"
    xmlHttp.open("POST", cmdline, true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlHttp.send("IDCarrello="+ IDCarrello );
	
  }

  function ExportaCatalogo() {
	
    var xmlHttp;
	var timeout = null;
	var IDCarrello=document.getElementById("IDCarrello").value;
	
	try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
	xmlHttp.onreadystatechange = function() {
      articoli = document.getElementById("Articoli")
	  intestazione = document.getElementById("Intestazione")
	  
	  intestazione.innerHTML="<P><B>ESPORTAZIONE</B></P>";
	  
	  if(xmlHttp.readyState == 4) {
        articoli.innerHTML = xmlHttp.responseText;
		LoadMenu();
		clearTimeout(timeout);
      }
	  else{
		articoli.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			articoli.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 20*1000 );       
			     
		}
		
		
	  }
    }
    cmdline = "EsportaArchivio.php"
    xmlHttp.open("POST", cmdline, true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlHttp.send("IDCarrello="+ IDCarrello );
	
  }

  //Funzione che aggiorna la quantità di articoli presenti nel carrello
  function LoadArticoliCarrello() {
	
    var xmlHttp;
	var timeout = null;
	var IDCarrello=document.getElementById("IDCarrello").value;
	//alert(IDCarrello);
	try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
    xmlHttp.onreadystatechange = function() {
      carrello = document.getElementById("articolicarrello")
	  if(xmlHttp.readyState == 4) {
        carrello.innerHTML = xmlHttp.responseText;
		clearTimeout(timeout);
      }
	  else{
		  if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			carrello.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 20*1000 );       
			     
		}
		
		
	  }
    }
    cmdline = "carrello.php"
    xmlHttp.open("POST", cmdline, true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlHttp.send("IDCarrello="+ IDCarrello );
	
  }

  //Funzione che: 1) verifica se le quantità degli articoli sono corrette, 2) Verifica se i valori inseriti sono numerici
  function verificaTotale(qtMin){
	var controllo = true;
	if (isNaN(document.getElementById("txtTagliaTot").value) == true) {
		if (document.getElementById("txtTagliaTot").value ==''){
			alert ("Il totale richiesto è inferiore al quantitativo minimo per l'ordine");
			controllo = false;
		}
		else{
			alert ("Il totale richiesto deve essere numerico");
			controllo = false;
		}
	}
	else if (Number(document.getElementById("txtTagliaTot").value) < Number(qtMin) ) 
	{alert ("Il totale richiesto è inferiore al quantitativo minimo per l'ordine");
	controllo = false;
	}
	if (controllo ==true)LoadOrdineFase2('','','','','');
}
	
	//Funzione che: 1) verifica se le quantità degli articoli sono corrette, 2) Verifica se i valori inseriti sono numerici
  function verificaTotale_Catalogo(){
	var controllo = true;
	if (isNaN(document.getElementById("txtTagliaTot").value) == true) {
		if (document.getElementById("txtTagliaTot").value ==''){
			alert ("Il totale richiesto è inferiore al quantitativo minimo per l'ordine");
			controllo = false;
		}
		else{
			alert ("Il totale richiesto deve essere numerico");
			controllo = false;
		}
	}
	else if (Number(document.getElementById("txtTagliaTot").value) == 0 ) 
	{alert ("Il totale richiesto è inferiore al quantitativo minimo per l'ordine");
	controllo = false;
	}
	if (controllo ==true)LoadOrdineFase2_Catalogo('','');
}

  //Funzione che: 1)calcola il totale delle quantità relativea alle taglie 2) Verifica se i valori inseriti sono numerici edin casocontrario licolora in rosso
  function VerificaPers(Count){

	
		var verifica = 0
		if (Count ==1){
			i=Count;
			qt = new String(document.getElementById("txtNPers"+i).value);
			document.getElementById("txtNPers"+i).value = qt.replace(",",".");
			if (isNaN(document.getElementById("txtNPers"+i).value) == false) {
				document.getElementById("txtNPers"+i).style.color = "#000000";
				verifica = 1
			}
			else{
				document.getElementById("txtNPers"+i).style.color = "#DD0000";
			}
			
			
		}
		else{
			for (i=1; i<=Count; i++) {
				
				qt = new String(document.getElementById("txtNPers"+i).value);
				document.getElementById("txtNPers"+i).value = qt.replace(",",".");
				if (isNaN(document.getElementById("txtNPers"+i).value) == false) {
					document.getElementById("txtNPers"+i).style.color = "#000000";
					verifica = verifica + 1
				}
				else{
					document.getElementById("txtNPers"+i).style.color = "#DD0000";
				}
				
			  
			}
		}	
		/*alert (Count);
		alert (verifica);*/
		if (verifica == Count){
			return true
		}
		else return false
	
 }

  //Funzione che: 1)calcola il totale delle quantità relativea alle taglie 2) Verifica se i valori inseriti sono numerici edin casocontrario licolora in rosso
  function calcolaTotalePz(ID,Count){
		/*alert ("txtTagliaC"+ID);
		alert (document.getElementById("txtTagliaC"+ID).value);*/
		var tot = 0;
		var add = 0;
		if (Count ==1){
			i=Count;
			add = 0;
			qt = new String(document.getElementById("txtTagliaC"+i).value);
			document.getElementById("txtTagliaC"+i).value = qt.replace(",",".");
			if (isNaN(document.getElementById("txtTagliaC"+i).value) == false) {
				add = Number(document.getElementById("txtTagliaC"+i).value);
				document.getElementById("txtTagliaC"+i).style.color = "#000000";
			}
			else{
				document.getElementById("txtTagliaC"+i).style.color = "#DD0000";
			}
			
			tot = Number(tot) + Number(add);
			if ((tot == 0) || (isNaN(tot) == true)) tot ='';
			
			document.getElementById("txtTagliaTot").value = tot;
		}
		else{
		for (i=1; i<=Count; i++) {
			add = 0;
			qt = new String(document.getElementById("txtTagliaC"+i).value);
			document.getElementById("txtTagliaC"+i).value = qt.replace(",",".");
			if (isNaN(document.getElementById("txtTagliaC"+i).value) == false) {
				add = Number(document.getElementById("txtTagliaC"+i).value);
				document.getElementById("txtTagliaC"+i).style.color = "#000000";
			}
			else{
				document.getElementById("txtTagliaC"+i).style.color = "#DD0000";
			}
			
			tot = Number(tot) + Number(add);
			if ((tot == 0) || (isNaN(tot) == true)) tot ='';
			
			document.getElementById("txtTagliaTot").value = tot;
		  
		}
		}	
	
 }	
 
  //Funzione che: Verifica se i valori (per articoli senza taglie) inseriti sono numerici ed in casocontrario li colora in rosso
  function TotalePz(){
	
		if (isNaN(document.getElementById("txtTagliaTot").value) == false) {
			
			document.getElementById("txtTagliaTot").style.color = "#000000";
		}
		else{
			document.getElementById("txtTagliaTot").style.color = "#DD0000";
		}
}
 
  //Funzione che rende invisibile il "loading" dopo il caricamente dell'articolo/i
  function chiudi(){

  document.getElementById("loading").style.visibility = "hidden";}			
  
  //Funzione che carica le sottocategori dopo laselezione di una categoria
  function LoadSottocategorie(categoria) {
    var xmlHttp;
	var timeout = null;
    //categoria = document.getElementById("selCat")
    try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
	if (oldCategoria != categoria) {
		chiudiCat(oldCategoria);
	oldCategoria = categoria;
	}
	
	
    xmlHttp.onreadystatechange = function() {
	impianti_area = document.getElementById("SubCat"+categoria)
      if(xmlHttp.readyState == 4) {
        
        impianti_area.innerHTML = xmlHttp.responseText;
		clearTimeout(timeout);
      }
	  else{
		impianti_area.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			impianti_area.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 20*1000 );       
			     
		}
		
		
	  }
	  
    }
	
	
    cmdline = "sottocategorie.php?IDCategoria=" + categoria + "&stato=" + statoSottocat
    xmlHttp.open("GET", cmdline, true);
    xmlHttp.send(null);
	
	if (statoSottocat == 0){
	 statoSottocat = 1 ;
	}
	else{
	 statoSottocat = 0 ;
	}
	
  }
  
 //Funzione che chiude il sottomenu' di una categoria 
  function chiudiCat(oldCategoria){
  var xmlHttp;
	
    try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
  
	if (oldCategoria != 0){
		
		statoSottocat = 1 ;
		xmlHttp.onreadystatechange = function() {
		  if(xmlHttp.readyState == 4) {
			impianti_area = document.getElementById("SubCat"+oldCategoria)
			impianti_area.innerHTML = xmlHttp.responseText;
		  }
		}
		cmdline = "sottocategorie.php?stato=" + statoSottocat
		xmlHttp.open("GET", cmdline, true);
		xmlHttp.send(null);
		//alert(oldCategoria);
		statoSottocat = 0 ;
	}
  
  }

  //Funzione che carica le categori dopo la selezione di un settore
  function LoadCategorie(settore) {
    var xmlHttp;
	var timeout = null;
    //categoria = document.getElementById("selCat")
    try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
	if (oldSettore != settore) {
		chiudiSettore(oldSettore);
		oldSettore=settore;
	}
    xmlHttp.onreadystatechange = function() {
	categorie = document.getElementById("Settore"+settore)
      if(xmlHttp.readyState == 4) {
         categorie.innerHTML = xmlHttp.responseText;
		clearTimeout(timeout);
      }
	  else{
		categorie.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			categorie.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 20*1000 );       
			     
		}
		
		
	  }
    }
    cmdline = "categorie.php?IDSettore=" + settore + "&stato=" + statoCat 
    xmlHttp.open("GET", cmdline, true);
    xmlHttp.send(null);
	if (statoCat == 0){
	 statoCat = 1 ;
	}
	else{
	 statoCat = 0 ;
	}
  }
  
  //Funzione che il sottomenu' di un settore
  function chiudiSettore(oldSettore){
  var xmlHttp;
	
    //categoria = document.getElementById("selCat")
    try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
  
	if (oldSettore != 0){
		
		statoCat = 1 ;
		xmlHttp.onreadystatechange = function() {
		  if(xmlHttp.readyState == 4) {
			categorie = document.getElementById("Settore"+oldSettore)
			categorie.innerHTML = xmlHttp.responseText;
		  }
		}
		cmdline = "categorie.php?stato=" + statoCat
		xmlHttp.open("GET", cmdline, true);
		xmlHttp.send(null);
		//alert(oldSettore);
		statoCat = 0 ;
	}
  
  }
 
  //Funzione che carica gli articoli relativi aduna selezione del menù laterale
  function LoadArticoli(categoria,linea,descrizione) {
    var arrivo=document.getElementById("arrivo").value;
	var IDCarrello=document.getElementById("IDCarrello").value;
	
	var xmlHttp;
	var timeout = null;
    //categoria = document.getElementById("selCat")
    try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
    xmlHttp.onreadystatechange = function() {
      articoli = document.getElementById("Articoli")
	  intestazione = document.getElementById("Intestazione")
	  if (descrizione != '') intestazione.innerHTML="<P><B>ARTICOLI - " + descrizione + " </B></P>";
	  if(xmlHttp.readyState == 4) {
        articoli.innerHTML = xmlHttp.responseText;
		clearTimeout(timeout);
		//LoadMenu();
		document.getElementById("txtRicerca").value = '';
      }
	  else{
		articoli.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			articoli.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 20*1000 );       
			     
		}
		
		
	  }
    }
    cmdline = "articoli.php?IDCategoria=" + categoria + "&IDLinea=" + linea 
    xmlHttp.open("POST", cmdline, true);
    xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");	
    xmlHttp.send("arrivo="+ arrivo + "&IDCarrello=" + IDCarrello + "&Selezione=P");
	
  }
  
  //Funzione che carica gli articoli relativi aduna selezione del menù laterale
  function LoadArticoliCatalogo(categoria,linea,descrizione) {
    var arrivo=document.getElementById("arrivo").value;
	var IDCarrello=document.getElementById("IDCarrello").value;
	
	var xmlHttp;
	var timeout = null;
    //categoria = document.getElementById("selCat")
    try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
    xmlHttp.onreadystatechange = function() {
      articoli = document.getElementById("Articoli")
	  intestazione = document.getElementById("Intestazione")
	  intestazione.innerHTML="<P><B>ARTICOLI - " + descrizione + " </B></P>";
	  if(xmlHttp.readyState == 4) {
        articoli.innerHTML = xmlHttp.responseText;
		clearTimeout(timeout);
		//LoadMenu();
		document.getElementById("txtRicerca").value = '';
      }
	  else{
		articoli.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			articoli.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 20*1000 );       
			     
		}
		
		
	  }
    }
    cmdline = "articoli.php?IDCategoria=" + categoria + "&IDLinea=" + linea 
    xmlHttp.open("POST", cmdline, true);
    xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");	
    xmlHttp.send("arrivo="+ arrivo + "&IDCarrello=" + IDCarrello + "&Selezione=C" );
	
  }
  
  function LoadGalleria(Categoria) {
    var arrivo=document.getElementById("arrivo").value;
	var IDCarrello=document.getElementById("IDCarrello").value;
	var xmlHttp;
	var timeout = null;
	var cat = Categoria;
	Categoria = cat.replace("'","''");
    //categoria = document.getElementById("selCat")
    try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
    xmlHttp.onreadystatechange = function() {
      articoli = document.getElementById("Articoli")
	  intestazione = document.getElementById("Intestazione")
	  intestazione.innerHTML="<P><B>GALLERIA LAVORI</B></P>";
	  if(xmlHttp.readyState == 4) {
        articoli.innerHTML = xmlHttp.responseText;
		clearTimeout(timeout);
		LoadMenuGalleria();
      }
	  else{
		articoli.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			articoli.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 20*1000 );       
			     
		}
		
		
	  }
    }
    cmdline = "galleria.php?";
    xmlHttp.open("POST", cmdline, true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlHttp.send("arrivo="+ arrivo + "&IDCarrello=" + IDCarrello + "&Categoria=" +Categoria);
	
  }
  
  function LoadMenuGalleria() {
    var UID = "" // document.getElementById("IDAgent").value;
	var arrivo=document.getElementById("arrivo").value;
	var IDCarrello=document.getElementById("IDCarrello").value;
	var xmlHttp;
	var timeout = null;
	
    //categoria = document.getElementById("selCat")
    try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
    xmlHttp.onreadystatechange = function() {
      articoli = document.getElementById("menu")
	   if(xmlHttp.readyState == 4) {
        articoli.innerHTML = xmlHttp.responseText;
		clearTimeout(timeout);
      }
	  else{
		articoli.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			articoli.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 20*1000 );       
			     
		}
		
		
	  }
    }
    cmdline = "menuGalleria.php?";
    xmlHttp.open("POST", cmdline, true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlHttp.send("arrivo="+ arrivo + "&IDCarrello=" + IDCarrello+ "&UID=" + UID);
	
  }
  
  function LoadMenu() {
    var UID = "" // ""//document.getElementById("IDAgent").value;
	var arrivo=document.getElementById("arrivo").value;
	var IDCarrello=document.getElementById("IDCarrello").value;
	var xmlHttp;
	var timeout = null;
	
    //categoria = document.getElementById("selCat")
    try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
    xmlHttp.onreadystatechange = function() {
      articoli = document.getElementById("menu")
	   if(xmlHttp.readyState == 4) {
        articoli.innerHTML = xmlHttp.responseText;
		clearTimeout(timeout);
		
      }
	  else{
		articoli.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			articoli.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 20*1000 );       
			     
		}
		
		
	  }
    }
    cmdline = "menu.php?";
    xmlHttp.open("POST", cmdline, true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlHttp.send("arrivo="+ arrivo + "&IDCarrello=" + IDCarrello + "&UID=" + UID);
	
  }
  
  //Funzione che carica gli ultimi 9 articoli inseriti nel db tornado alla pagina iniziale
  function LoadIndexArticoli() {
   
	var arrivo=document.getElementById("arrivo").value;
	var IDCarrello=document.getElementById("IDCarrello").value;
	var xmlHttp;
	var timeout = null;
	
    //categoria = document.getElementById("selCat")
    try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
    xmlHttp.onreadystatechange = function() {
      articoli = document.getElementById("Articoli")
	  intestazione = document.getElementById("Intestazione")
	  intestazione.innerHTML="<P><B>ARTICOLI</B></P>";
	  if(xmlHttp.readyState == 4) {
        articoli.innerHTML = xmlHttp.responseText;
		clearTimeout(timeout);
		//LoadMenu();
		}
	  else{
		articoli.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			articoli.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 20*1000 );       
			     
		}
		
		
	  }
    }
    cmdline = "articoli.php?";
    xmlHttp.open("POST", cmdline, true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlHttp.send("arrivo="+ arrivo + "&IDCarrello=" + IDCarrello);
	
  }
  
  //Funzione che carica il dettaglio di un articolo
  function LoadDettaglioArticoli(articolo,categoria,linea,settore,descrizione) {
    var arrivo=document.getElementById("arrivo").value;
	var IDCarrello=document.getElementById("IDCarrello").value;
	var xmlHttp;
	var timeout = null;
    //categoria = document.getElementById("selCat")
    try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
    xmlHttp.onreadystatechange = function() {
      articoli = document.getElementById("Articoli")
	  intestazione = document.getElementById("Intestazione")
	  intestazione.innerHTML="<P><B>DETTAGLIO ARTICOLO</B></P>";
	  if(xmlHttp.readyState == 4) {
        articoli.innerHTML = xmlHttp.responseText;
		clearTimeout(timeout);
      }
	  else{
		articoli.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			articoli.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 20*1000 );       
			     
		}
		
		
	  }
    }
    cmdline = "dettaglioarticoli.php?IDArticolo=" + articolo +"&IDCategoria=" + categoria + "&IDLinea=" + linea + "&IDSettore=" +settore + "&Descrizione=" +descrizione 
    xmlHttp.open("POST", cmdline, true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlHttp.send("arrivo="+ arrivo + "&IDCarrello=" + IDCarrello);
	
  }
  
  //Funzione che carica la pagina di inserimento dati (quantità,colore,etc...) dell'articoloselezionato
  function LoadOrdineFase1(articolo,categoria,sottocategoria,settore,descrizione) {
    var arrivo=document.getElementById("arrivo").value;
	
	var IDCarrello=document.getElementById("IDCarrello").value;
	var xmlHttp;
	var timeout = null;
	
    //categoria = document.getElementById("selCat")
    try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
    xmlHttp.onreadystatechange = function() {
      articoli = document.getElementById("Articoli")
	  intestazione = document.getElementById("Intestazione")
	  intestazione.innerHTML="<P><B>DETTAGLIO ARTICOLO</B></P>";
	  if(xmlHttp.readyState == 4) {
        articoli.innerHTML = xmlHttp.responseText;
		clearTimeout(timeout);
      }
	  else{
		articoli.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			articoli.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 20*1000 );       
			     
		}
		
		
	  }
    }
    cmdline = "ordinefase1.php?IDArticolo=" + articolo 
    xmlHttp.open("POST", cmdline, true);
    xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("arrivo="+arrivo+ "&IDCarrello=" + IDCarrello +"&IDCategoria=" + categoria + "&IDSottocategoria=" + sottocategoria + "&IDSettore=" +settore + "&Descrizione=" +descrizione );

  }
  
  //Funzione che carica la pagina di inserimento dati (quantità,colore,etc...) dell'articoloselezionato
  function LoadOrdineFase1_Catalogo(articolo,categoria,linea,descrizione) {
    var arrivo=document.getElementById("arrivo").value;
	var ricerca=document.getElementById("txtRicerca").value;
	var IDCarrello=document.getElementById("IDCarrello").value;
	var xmlHttp;
	var timeout = null;
	
    //categoria = document.getElementById("selCat")
    try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
    xmlHttp.onreadystatechange = function() {
      articoli = document.getElementById("Articoli")
	  intestazione = document.getElementById("Intestazione")
	  intestazione.innerHTML="<P><B>DETTAGLIO ARTICOLO</B></P>";
	  if(xmlHttp.readyState == 4) {
        articoli.innerHTML = xmlHttp.responseText;
		clearTimeout(timeout);
      }
	  else{
		articoli.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			articoli.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 20*1000 );       
			     
		}
		
		
	  }
    }
    cmdline = "ordinefase1_catalogo.php?IDArticolo=" + articolo 
    xmlHttp.open("POST", cmdline, true);
    xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("arrivo="+arrivo+ "&IDCarrello=" + IDCarrello +"&IDCategoria=" + categoria + "&IDLinea=" + linea + "&Descrizione=" +descrizione + "&Ricerca=" +ricerca);

  }
  
  //Funzione che carica il dettaglio dei costi relativi all'articolo inserito nel carrello
  function LoadOrdineFase2(articolo1,logob) {
    var UID = "" // document.getElementById("IDAgent").value;	
	var categoria = document.getElementById("IDCategoria").value;
	var sottocategoria = document.getElementById("IDSottocategoria").value;
	var settore = document.getElementById("IDSettore").value;
	var descrizione = document.getElementById("Descrizione").value;
	
	var arrivo=document.getElementById("arrivo").value;
	var tipoProd=document.getElementById("misura").value;
	var TotArt=document.getElementById("txtTagliaTot").value;
	var TotTaglie=document.getElementById("totTaglie").value;
	var TotColori=document.getElementById("totColori").value;
	var note=document.getElementById("txtNote").value;
	var articolo = document.getElementById("IDArticolo").value;
	var IDCarrello=document.getElementById("IDCarrello").value;
	var strQtTaglie ='';
	var coloreSel = '';
	var logo ;
	var prezzo =0;
	
	if (tipoProd=='Y'){
		prezzo= document.getElementById("ImpoF1").value;
	}else{	
	if ((Number(TotArt) >= Number(document.getElementById("QtF1").value)) && (Number(TotArt) < Number(document.getElementById("QtF2").value))) prezzo= document.getElementById("ImpoF1").value;
	if ((Number(TotArt) >= Number(document.getElementById("QtF2").value)) && (Number(TotArt) < Number(document.getElementById("QtF3").value))) prezzo= document.getElementById("ImpoF2").value;
	if (Number(TotArt) >= Number(document.getElementById("QtF3").value)) prezzo= document.getElementById("ImpoF3").value;
	}
	/* recupere le quantità per taglia */
	for (i=1; i<=TotTaglie; i++) {
		var qt = 0;
		if (document.getElementById("txtTagliaC"+i).value != '') qt = document.getElementById("txtTagliaC"+i).value;
		strQtTaglie = strQtTaglie + "&"+document.getElementById("txtTagliaC"+i).name + "=" + qt;
	} 
	/* fine recupero */
	if (TotTaglie == 0)strQtTaglie = "&IDTaglia=0";
	/* recupere il colore selezionato */
	var controllo = false;
	for(var i=1; i<=TotColori; i++) { 
	  if(document.getElementById("rbColore"+i).checked) { 
		controllo = true;
		coloreSel = document.getElementById("rbColore"+i).value;
		break; 
	  }
	}
	
	if(!controllo) { // se non c'è una scelta avviso
	  alert("Deve essere selezionato almeno un colore.");
	  return false;
	}
	/* fine recupero */

	/* recuperoscelta logo */
	if(document.getElementById("rbLogoN").checked) {
		logo = 'N';
	}
	else logo = 'Y';	
	/* fine recupero */ 
	
	var xmlHttp;
	var timeout = null;
    //categoria = document.getElementById("selCat")
    try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
    xmlHttp.onreadystatechange = function() {
      articoli = document.getElementById("Articoli")
	  intestazione = document.getElementById("Intestazione")
	  intestazione.innerHTML="<P><B>DETTAGLIO ARTICOLO</B></P>";
	  if(xmlHttp.readyState == 4) {
        articoli.innerHTML = xmlHttp.responseText;
		LoadArticoliCarrello();
		
		clearTimeout(timeout);
      }
	  else{
		articoli.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			articoli.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 20*1000 );       
			     
		}
		
		
	  }
    }
	
	
	if (logo=='N') {
		cmdline = "ordinefase2.php?IDArticolo=" + articolo 
	}else{	
		cmdline = "tipopersonalizzazione.php?IDArticolo=" + articolo 
	}
	xmlHttp.open("POST", cmdline, true);
    xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("UID="+UID+"&arrivo="+arrivo+"&totArt=" + TotArt+"&colore=" + coloreSel + strQtTaglie + "&logo=" +logo + "&prezzo=" + prezzo + "&note=" + note + "&IDCarrello=" + IDCarrello +"&IDCategoria=" + categoria + "&IDSottocategoria=" + sottocategoria + "&IDSettore=" +settore + "&Descrizione=" +descrizione );
	
  }
  
  function LoadOrdineFase2_Catalogo(articolo1,logob) {
    var UID = "" // document.getElementById("IDAgent").value;	
	var categoria = document.getElementById("IDCategoria").value;
	var linea = document.getElementById("IDLinea").value;
	var settore = document.getElementById("IDSettore").value;
	var descrizione = document.getElementById("Descrizione").value;
	
	var arrivo=document.getElementById("arrivo").value;
	var tipoProd=document.getElementById("misura").value;
	var TotArt=document.getElementById("txtTagliaTot").value;
	var TotTaglie=document.getElementById("totTaglie").value;
	var TotColori=document.getElementById("totColori");
	var note=document.getElementById("txtNote").value;
	var articolo = document.getElementById("IDArticolo").value;
	var IDCarrello=document.getElementById("IDCarrello").value;
	var strQtTaglie ='';
	var coloreSel = '';
	var logo ;
	var prezzo =0;
	
		
	/* recupere le quantità per taglia */
	for (i=1; i<=TotTaglie; i++) {
		var qt = 0;
		if (document.getElementById("txtTagliaC"+i).value != '') qt = document.getElementById("txtTagliaC"+i).value;
		strQtTaglie = strQtTaglie + "&"+document.getElementById("txtTagliaC"+i).name + "=" + qt;
	} 
	
	/* fine recupero */
	if (TotTaglie == 0)strQtTaglie = "&IDTaglia=0";
	/* recupere il colore selezionato */
	var controllo = false;
	if (TotColori != null) {
		TotColori = document.getElementById("totColori").value;
	
		for(var i=1; i<=TotColori; i++) { 
		  if(document.getElementById("rbColore"+i).checked) { 
			controllo = true;
			coloreSel = document.getElementById("rbColore"+i).value;
			break; 
		  }
		}
	}
	else {
		coloreSel = 6;
		controllo = true;	
	}
	if(!controllo) { // se non c'è una scelta avviso
	  alert("Deve essere selezionato almeno un colore.");
	  return false;
	}
	/* fine recupero */

	var xmlHttp;
	var timeout = null;
    //categoria = document.getElementById("selCat")
    try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
    xmlHttp.onreadystatechange = function() {
      articoli = document.getElementById("Articoli")
	  intestazione = document.getElementById("Intestazione")
	  intestazione.innerHTML="<P><B>DETTAGLIO ARTICOLO</B></P>";
	  if(xmlHttp.readyState == 4) {
        articoli.innerHTML = xmlHttp.responseText;
		LoadArticoliCarrello();
		LoadCarrello();
		clearTimeout(timeout);
      }
	  else{
		articoli.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			articoli.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 20*1000 );       
			     
		}
		
		
	  }
    }
	
	
	cmdline = "ordinefase2_Catalogo.php?IDArticolo=" + articolo 
	xmlHttp.open("POST", cmdline, true);
    xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("UID="+UID+"&arrivo="+arrivo+"&totArt=" + TotArt + "&colore=" + coloreSel + strQtTaglie + "&logo=" +logo + "&prezzo=" + prezzo + "&note=" + note + "&IDCarrello=" + IDCarrello +"&IDCategoria=" + categoria + "&IDLinea=" + linea + "&IDSettore=" +settore + "&Descrizione=" +descrizione );
	
  }
    
  //Funzione che carica il dettaglio dei costi relativi all'articolo inserito nel carrello
  function LoadOrdineFase2Pers() {
    var categoria = document.getElementById("IDCategoria").value;
	var sottocategoria = document.getElementById("IDSottocategoria").value;
	var settore = document.getElementById("IDSettore").value;
	var descrizione = document.getElementById("Descrizione").value;
	var arrivo=document.getElementById("arrivo").value;
	var savedet = document.getElementById("savedet").value;
	var articolo = document.getElementById("IDArticolo").value;
	var IDCarrello=document.getElementById("IDCarrello").value;
	
	var xmlHttp;
	var timeout = null;
	
    //categoria = document.getElementById("selCat")
    try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
	
    xmlHttp.onreadystatechange = function() {
      articoli = document.getElementById("Articoli")
	  intestazione = document.getElementById("Intestazione")
	  intestazione.innerHTML="<P><B>DETTAGLIO ARTICOLO</B></P>";
	  
	  if(xmlHttp.readyState == 4) {
        articoli.innerHTML = xmlHttp.responseText;
		//LoadArticoliCarrello();
		clearTimeout(timeout);
      }
	  else{
		articoli.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			articoli.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 20*1000 );       
			     
		}
		
		
	  }
    }
	
	
	
	cmdline = "tipopersonalizzazione.php?IDArticolo=" + articolo 
	
	xmlHttp.open("POST", cmdline, true);
    xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("arrivo="+arrivo + "&IDCarrello=" + IDCarrello +"&IDCategoria=" + categoria + "&IDSottocategoria=" + sottocategoria + "&IDSettore=" +settore + "&Descrizione=" +descrizione+"&savedet=" +savedet );
	
  }
     
  //Funzione che inserisce un capione nelcarrello carica il dettaglio dei costi relativi all'articolo 
  function LoadOrdinaCampione() {
    var categoria = "";//document.getElementById("IDCategoria").value;
	var sottocategoria = "";//document.getElementById("IDSottocategoria").value;
	var settore = "";//document.getElementById("IDSettore").value;
	var descrizione = document.getElementById("Descrizione").value;
	var arrivo="campione";
	var TotArt=1;
	var TotTaglie=1;
	var TotColori=0;
	var note = "";
	var UID = "" // document.getElementById("IDAgent").value;
	var articolo = document.getElementById("IDArticolo").value;
	var IDCarrello=document.getElementById("IDCarrello").value;
	var prezzo =0;
	var xmlHttp;
	var timeout = null;
    try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
    xmlHttp.onreadystatechange = function() {
      articoli = document.getElementById("Articoli")
	  intestazione = document.getElementById("Intestazione")
	  intestazione.innerHTML="<P><B>DETTAGLIO ARTICOLO</B></P>";
	  if(xmlHttp.readyState == 4) {
        articoli.innerHTML = xmlHttp.responseText;
		LoadArticoliCarrello();
		clearTimeout(timeout);
      }
	  else{
		articoli.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			articoli.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 20*1000 );       
			     
		}
		
		
	  }
    }
	
	
	
	cmdline = "ordinefase2.php?IDArticolo=" + articolo 
	
	xmlHttp.open("POST", cmdline, true);
    xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("UID=" + UID + "&arrivo="+arrivo+"&totArt=" + TotArt + "&note=" + note + "&IDCarrello=" + IDCarrello+"&IDCategoria=" + categoria + "&IDSottocategoria=" + sottocategoria + "&IDSettore=" +settore + "&Descrizione=" +descrizione );
	
  }
    
  //Funzione che carica la pagina di scelta personalizzazione dell'articolo inserito nel carrello
  function LoadOrdinePersonalizza() {
	var articolo = document.getElementById("IDArticolo").value;
	 var categoria = document.getElementById("IDCategoria").value;
	var sottocategoria = document.getElementById("IDSottocategoria").value;
	var settore = document.getElementById("IDSettore").value;
	var descrizione = document.getElementById("Descrizione").value;
	var categoria;
	var sottocategoria; 
	var settore;
	var descrizione;
    var arrivo=document.getElementById("arrivo").value;
	//var totPos=document.getElementById("totPosizioni").value;
	var totPers=document.getElementById("totPers").value;
	var IDCarrello=document.getElementById("IDCarrello").value;
	var strPosStampe ='';
	var strPersStampe = '';
	var savedet=document.getElementById("savedet").value;
	//alert(totPers);
	/* recupere le posizioni di stampa */
	var controllo = false
	if 	(arrivo != 'fase2pers'){
		savedet='Y';
		for (i=1; i<=totPers; i++) {
			
			if (document.getElementById("chkPersStampa"+i).checked) {
				strPersStampe = strPersStampe + "&"+document.getElementById("chkPersStampa"+i).name + "=1";
				//alert(i);
				//alert(document.getElementById("chkPersStampa"+i).name);
				controllo = true;	
			}else strPersStampe = strPersStampe + "&"+document.getElementById("chkPersStampa"+i).name + "=0";
		}	
	}else {
		controllo = true;
		savedet ='N';
	}
		/* fine recupero */
		if(!controllo) { // se non c'è una scelta avviso
		  alert("Deve essere selezionato almeno una tecnica di personalizzazione stampa.");
		  
		}
		
		
	else{	
	var xmlHttp;
	var timeout = null;
    //categoria = document.getElementById("selCat")
    try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
    xmlHttp.onreadystatechange = function() {
      articoli = document.getElementById("Articoli")
	  intestazione = document.getElementById("Intestazione")
	  intestazione.innerHTML="<P><B>DETTAGLIO PERSONALIZZAZIONE</B></P>";
	  if(xmlHttp.readyState == 4) {
        articoli.innerHTML = xmlHttp.responseText;
		clearTimeout(timeout);
      }
	  else{
		articoli.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			articoli.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 20*1000 );       
			     
		}
		
		
	  }
    }
	
	cmdline = "dettagliopersonalizzazione.php?IDArticolo=" + articolo 
	xmlHttp.open("POST", cmdline, true);
    xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("arrivo="+ arrivo + strPersStampe + "&IDCarrello=" + IDCarrello+"&IDCategoria=" + categoria + "&IDSottocategoria=" + sottocategoria + "&IDSettore=" +settore + "&Descrizione=" +descrizione +"&savedet=" +savedet);
	}
  }
  
  //Funzione che carica la pagina di scelta dettaglio della/e personalizzazione/i dell'articolo inserito nel carrello
  function LoadOrdinePersonalizzaDettagli() {
		var articolo = document.getElementById("IDArticolo").value;
		var UID = "" // document.getElementById("IDAgent").value;
		var arrivo=document.getElementById("arrivo").value;
		//var totPos=document.getElementById("totPosizioni").value;
		var totPers=document.getElementById("totPers").value;
		var IDCarrello=document.getElementById("IDCarrello").value;
		var strNDisegni ='';
		var strDettDisegni = '';
		var strNotePers = '';
		var strLogo = '';
		var strNPers = '';
		 var categoria = document.getElementById("IDCategoria").value;
		var sottocategoria = document.getElementById("IDSottocategoria").value;
		var settore = document.getElementById("IDSettore").value;
		var descrizione = document.getElementById("Descrizione").value;	
		var FlagMisura = document.getElementById("FlagMisura").value;	
		/* recupere le posizioni di stampa */
		var controllo = false;
		var descr = 0
		//alert (totPers);
			for (i=1; i<=totPers; i++) {
				if 	(document.getElementById("txtNDisegni"+i).value != ""){
					strNDisegni = strNDisegni + "&"+document.getElementById("txtNDisegni"+i).name + "=" + document.getElementById("txtNDisegni"+i).value;
				}
				if 	((document.getElementById("txtDescrizioneDisegni"+i).value != "") && (document.getElementById("txtDescrizionePers"+i).value != "")){
					strDettDisegni = strDettDisegni + "&"+document.getElementById("txtDescrizioneDisegni"+i).name + "=" + document.getElementById("txtDescrizioneDisegni"+i).value;	
					strNotePers = strNotePers + "&"+document.getElementById("txtDescrizionePers"+i).name + "=" + document.getElementById("txtDescrizionePers"+i).value;	
					descr = descr + 1;
				}
				
				strNPers = strNPers + "&"+document.getElementById("txtNPers"+i).name + "=" + document.getElementById("txtNPers"+i).value;	
				
			}	
			if (descr==totPers) controllo = true;
			/* fine recupero */
		if (VerificaPers(totPers) == false){
			alert("Devono essere configurate quantità numeriche.");
		}
		else{ 
			if((!controllo)&&(FlagMisura!='Y')) { // se non c'è una scelta avviso
			  alert("Devono essere configurate tutte le descrizioni.");
			}
			else{
			
				var xmlHttp;
				var timeout = null;
				//categoria = document.getElementById("selCat")
				try {
				  // Firefox, Opera 8.0+, Safari
				  xmlHttp = new XMLHttpRequest();
				} catch (e) {
				  // Internet Explorer
				  try {
					xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
				  } catch (e) {
					try {
					  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
					} catch (e) {
					  alert("Your browser does not support AJAX!");
					}
				  }
				}
				xmlHttp.onreadystatechange = function() {
				  articoli = document.getElementById("Articoli")
				  intestazione = document.getElementById("Intestazione")
				  intestazione.innerHTML="<P><B>RIEPILOGO</B></P>";
				  if(xmlHttp.readyState == 4) {
					articoli.innerHTML = xmlHttp.responseText;
					clearTimeout(timeout);
				  }
				  else{
					articoli.innerHTML ="<img src='Images/loader.gif'>";
					if (timeout == null) {      
						function timeoutFunc() {         
						xmlHttp.abort();         
						articoli.innerHTML = "Timeout...";      
						} 
						
						timeout = setTimeout( timeoutFunc, 20*1000 );       
							 
					}
					
					
					}
				}
			//alert(strNColori + strDettColori + strNote + strNPers);
			cmdline = "ordinefase2pers.php?IDArticolo=" + articolo 
			xmlHttp.open("POST", cmdline, true);
			xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			xmlHttp.send("UID="+UID+"&arrivo="+ arrivo + strNDisegni + strDettDisegni + strNotePers + strLogo + strNPers + "&IDCarrello=" + IDCarrello+"&IDCategoria=" + categoria + "&IDSottocategoria=" + sottocategoria + "&IDSettore=" +settore + "&Descrizione=" +descrizione );
			
		}
	}	
  }
   
  function LoadOrdinePersonalizzaDettagliGuadagno() {
		
		var articolo = document.getElementById("IDArticolo").value;
		var arrivo=document.getElementById("arrivo").value;
		var IDCarrello=document.getElementById("IDCarrello").value;
		var strNDisegni ='';
		var strDettDisegni = '';
		var strNotePers = '';
		var strLogo = '';
		var strNPers = '';
		var categoria = document.getElementById("IDCategoria").value;
		var sottocategoria = '';
		var settore = '';
		var descrizione = document.getElementById("Descrizione").value;	
		var savedet = document.getElementById("savedet").value;	
		/* recupere le posizioni di stampa */
		var controllo = false;
		var descr = 0
		//alert (totPers);
		
			
			var xmlHttp;
			var timeout = null;
			//categoria = document.getElementById("selCat")
			try {
			  // Firefox, Opera 8.0+, Safari
			  xmlHttp = new XMLHttpRequest();
			} catch (e) {
			  // Internet Explorer
			  try {
				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			  } catch (e) {
				try {
				  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {
				  alert("Your browser does not support AJAX!");
				}
			  }
			}
			xmlHttp.onreadystatechange = function() {
			  articoli = document.getElementById("Articoli")
			  intestazione = document.getElementById("Intestazione")
			  intestazione.innerHTML="<P><B>GUADAGNO</B></P>";
			  if(xmlHttp.readyState == 4) {
				articoli.innerHTML = xmlHttp.responseText;
				clearTimeout(timeout);
			  }
			  else{
				articoli.innerHTML ="<img src='Images/loader.gif'>";
				if (timeout == null) {      
					function timeoutFunc() {         
					xmlHttp.abort();         
					articoli.innerHTML = "Timeout...";      
					} 
					
					timeout = setTimeout( timeoutFunc, 20*1000 );       
						 
				}
				
				
				}
			}
		//alert(strNColori + strDettColori + strNote + strNPers);
		cmdline = "ordinefase2persguadagno.php?IDArticolo=" + articolo 
		xmlHttp.open("POST", cmdline, true);
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlHttp.send("savedet="+savedet+"&arrivo="+ arrivo + "&IDCarrello=" + IDCarrello+"&IDCategoria=" + categoria + "&IDSottocategoria=" + sottocategoria + "&IDSettore=" +settore + "&Descrizione=" +descrizione );
		
	}
   
  //Funzione che carica la pagina di vusualizzazione carrello carrello
  function LoadCarrello() {
	
	var categoria;
	var sottocategoria; 
	var settore;
	var descrizione;
    var arrivo=document.getElementById("arrivo").value;
	var IDCarrello=document.getElementById("IDCarrello").value;
	var UID = "" // document.getElementById("IDAgent").value;	
		
	var xmlHttp;
	var timeout = null;
    //categoria = document.getElementById("selCat")
    try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
    xmlHttp.onreadystatechange = function() {
      articoli = document.getElementById("Articoli")
	  intestazione = document.getElementById("Intestazione")
	  intestazione.innerHTML="<P><B>CARRELLO</B></P>";
	  if(xmlHttp.readyState == 4) {
        articoli.innerHTML = xmlHttp.responseText;
		clearTimeout(timeout);
		//LoadMenu();
      }
	  else{
		articoli.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			articoli.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 20*1000 );       
			     
		}
		
		
	  }
    }
	
	cmdline = "visualizzacarrello.php?IDCategoria=" + categoria + "&IDSottocategoria=" + sottocategoria + "&IDSettore=" +settore + "&Descrizione=" +descrizione 
	xmlHttp.open("POST", cmdline, true);
    xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("UID=" + UID + "&arrivo="+ arrivo + "&IDCarrello=" + IDCarrello);

  }
	
  function LoadCompletaOrdine() {
	
	var categoria;
	var sottocategoria; 
	var settore;
	var descrizione;
    var arrivo=document.getElementById("arrivo").value;
	var IDCarrello=document.getElementById("IDCarrello").value;
	var IDCliente=document.getElementById("IDCliente").value;
	var TipologiaOrd=document.getElementById("TipologiaOrd").value;
	
	//var pwd=document.getElementById("txtpwdreg").value;
	//alert ("Login ="+login);
	//alert ("Pwd ="+pwd );
	//LoadLoginRegistrazione(login,pwd);
	var IDLogin=document.getElementById("IDLogin").value;	
	var timeout = null;
	
    //categoria = document.getElementById("selCat")
    try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
    xmlHttp.onreadystatechange = function() {
      articoli = document.getElementById("Articoli")
	  intestazione = document.getElementById("Intestazione")
	  if (TipologiaOrd == 'ORD'){
		intestazione.innerHTML="<P><B>RIEPILOGO ORDINE</B></P>";
	  }else{
		intestazione.innerHTML="<P><B>RIEPILOGO PREVENTIVO</B></P>";
	  }
	 if(xmlHttp.readyState == 4) {
        articoli.innerHTML = xmlHttp.responseText;
		clearTimeout(timeout);
      }
	  else{
		articoli.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			articoli.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 20*1000 );       
			     
		}
		
		
	  }
    }
	
	cmdline = "visualizzaordine.php" 
	xmlHttp.open("POST", cmdline, true);
    xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("arrivo="+ arrivo + "&IDCarrello=" + IDCarrello + "&IDCliente=" +IDCliente +"&TipologiaOrd="+TipologiaOrd);

  }
    
  //Funzione che un articolo inserito nel carrello
  function LoadElimina(articolo,taglia,colore) {
	
	var categoria;
	var sottocategoria; 
	var settore;
	var descrizione;
    var arrivo=document.getElementById("arrivo").value;
	var IDCarrello=document.getElementById("IDCarrello").value;
	var controllo = confirm ("Sei sicuro di voler eliminare l'articolo ?");
	if (controllo){	
	
	var xmlHttp;
	var timeout = null;
    //categoria = document.getElementById("selCat")
    try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
    xmlHttp.onreadystatechange = function() {
      articoli = document.getElementById("Articoli")
	  intestazione = document.getElementById("Intestazione")
	  intestazione.innerHTML="<P><B>CARRELLO</B></P>";
	  if(xmlHttp.readyState == 4) {
        articoli.innerHTML = xmlHttp.responseText;
		LoadArticoliCarrello();
		clearTimeout(timeout);
      }
	  else{
		articoli.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			articoli.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 20*1000 );       
			     
		}
		
		
	  }
    }
	
	cmdline = "visualizzacarrello.php?IDArticolo=" + articolo + "&IDTaglia=" + taglia+ "&IDColore=" + colore+ "&IDCategoria=" + categoria + "&IDSottocategoria=" + sottocategoria + "&IDSettore=" +settore + "&Descrizione=" +descrizione 
	xmlHttp.open("POST", cmdline, true);
    xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("arrivo="+ arrivo + "&IDCarrello=" + IDCarrello);
	
	
	}
  }
  
  //Funzione che carica gli articoli alla chiave di ricerca inserita
  function LoadArticoliRicerca() {
    var xmlHttp;
	var timeout = null;
	var descr = document.getElementById("txtRicerca").value
	var arrivo=document.getElementById("arrivo").value;
	var IDCarrello='';
	if (arrivo=='mail'){
		IDCarrello = document.getElementById("IDCarrelloOld").value;
	}
	else{
		IDCarrello = document.getElementById("IDCarrello").value;
	}
    //categoria = document.getElementById("selCat")
    try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
	  
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
    xmlHttp.onreadystatechange = function() {
      articoli = document.getElementById("Articoli")
	  intestazione = document.getElementById("Intestazione")
	  intestazione.innerHTML="<P><B>ARTICOLI</B></P>";
	  if(xmlHttp.readyState == 4) {
        articoli.innerHTML = xmlHttp.responseText;
		clearTimeout(timeout);
      }
	  else{
		articoli.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			articoli.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 20*1000 );       
			     
		}
		
		
	  }
    }
	if (descr!= '')
    cmdline = "articoli.php?Descrizione=" +descr;
    else
	cmdline = "articoli_index.php?"; 
	xmlHttp.open("POST", cmdline, true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlHttp.send("arrivo="+ arrivo +"&IDCarrello=" + IDCarrello);
	
  }
  
  function LoadChiSiamo() {
    var xmlHttp;
	var timeout = null;
	var IDCarrello=document.getElementById("IDCarrello").value;
	
    try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
    xmlHttp.onreadystatechange = function() {
      chisiamo = document.getElementById("Articoli")
	  intestazione = document.getElementById("Intestazione")
	  intestazione.innerHTML="<P><B>CHI SIAMO</B></P>";
	  if(xmlHttp.readyState == 4) {
        chisiamo.innerHTML = xmlHttp.responseText;
		clearTimeout(timeout);
      }
	  else{
		chisiamo.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			chisiamo.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 20*1000 );       
			     
		}
		
		
	  }
    }
    cmdline = "chisiamo.php"
    xmlHttp.open("POST", cmdline, true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlHttp.send("IDCarrello=" + IDCarrello);
	
  }
  
  function LoadContattaci() {
    var xmlHttp;
	var timeout = null;
	var IDCarrello=document.getElementById("IDCarrello").value;
	
    try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
    xmlHttp.onreadystatechange = function() {
      chisiamo = document.getElementById("Articoli")
	  intestazione = document.getElementById("Intestazione")
	  intestazione.innerHTML="<P><B>CONTATTI</B></P>";
	  if(xmlHttp.readyState == 4) {
        chisiamo.innerHTML = xmlHttp.responseText;
		initialize();
		clearTimeout(timeout);
      }
	  else{
		chisiamo.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			chisiamo.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 20*1000 );       
			     
		}
		
		
	  }
    }
    cmdline = "contattaci.php"
    xmlHttp.open("POST", cmdline, true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlHttp.send("IDCarrello=" + IDCarrello);
	
  }
  
  function LoadClienti(page,ricN,ricT) {
    var xmlHttp;
	var timeout = null;
	var IDCarrello=document.getElementById("IDCarrello").value;
	try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
    xmlHttp.onreadystatechange = function() {
      clienti = document.getElementById("Articoli")
	  intestazione = document.getElementById("Intestazione")
	  intestazione.innerHTML="<P><B>CLIENTI</B></P>";
	  if(xmlHttp.readyState == 4) {
        clienti.innerHTML = xmlHttp.responseText;
		clearTimeout(timeout);
		LoadMenu();
      }
	  else{
		clienti.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			clienti.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 20*1000 );       
			     
		}
		
		
	  }
    }
    cmdline = "clienti.php"
    xmlHttp.open("POST", cmdline, true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlHttp.send("IDCarrello=" + IDCarrello + "&page="+page+ "&RicN=" + ricN + "&RicT=" +ricT);
	
  }
  
  function LoadOrdini(tipo,page,ricC,ricD,ricN) {
	
	var categoria;
	var sottocategoria; 
	var settore;
	var descrizione;
    var arrivo=document.getElementById("arrivo").value;
	var IDCarrello=document.getElementById("IDCarrello").value;
	
	var IDLogin=document.getElementById("IDLogin").value;	
	var timeout = null;
	
    //categoria = document.getElementById("selCat")
    try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
    xmlHttp.onreadystatechange = function() {
      articoli = document.getElementById("Articoli")
	  intestazione = document.getElementById("Intestazione")
	  if (tipo == 'ORD'){
	  intestazione.innerHTML="<P><B>ELENCO ORDINI</B></P>";
	  }else{
	  intestazione.innerHTML="<P><B>ELENCO PREVENTIVI</B></P>";
	  }
	  if(xmlHttp.readyState == 4) {
        articoli.innerHTML = xmlHttp.responseText;
		clearTimeout(timeout);
		LoadMenu();
      }
	  else{
		articoli.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			articoli.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 20*1000 );       
			     
		}
		
		
	  }
    }
	
	cmdline = "ordini.php" 
	xmlHttp.open("POST", cmdline, true);
    xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("arrivo="+ arrivo + "&IDCarrello=" + IDCarrello + "&TipologiaOrd="+tipo+ "&page="+page+ "&RicCod=" + ricC + "&RicDesc=" +ricD+ "&RicN="+ricN);
  }  
  
  function RicaricaPageOrd()
		{
			var IDOrd = document.frmData.IDOrdine.value
			var Data = document.frmData.DataOrdine.value
			var Nomi = document.frmData.Nominativo.value
			var Tipo = document.frmData.TipologiaOrd.value
			
			LoadOrdini(Tipo,'',IDOrd,Data,Nomi);
		}		
  function RicaricaPageCli()
		{
			var Tipo = document.frmData.cmbStato.value
			var Nomi = document.frmData.Nominativo.value
			LoadClienti('',Nomi,Tipo);
		}		
  function checkEnter(e) 
		{
			if(!e) var e = window.event;

			if (e.keyCode) code = e.keyCode;
			else if (e.which) code = e.which;
			
			if(code==13) {
				LoadArticoliRicerca();

			}

		}
  
  function apri(IDOrdine,TipoOrd){
		if (TipoOrd=='ORD')	window.open('ordini/Ordine_'+ IDOrdine + '.pdf','_new','location=no,menubar=no,resizable=yes');	
		if (TipoOrd=='PRE')	window.open('ordini/Preventivo_'+ IDOrdine + '.pdf','_new','location=no,menubar=no,resizable=yes');			
	}
  
  //Funzione che verifica se l'utente è loggato
  function LoadVerificaLogin(mail,pwd) {
    var xmlHttp;
	var timeout = null;
	var IDCarrello=document.getElementById("IDCarrello").value;
	var IDLogin=document.getElementById("IDLogin").value;
	var nominativo=document.getElementById("NominativoCli").value;
	var pagamento=document.getElementById("Pagamento").value;
    try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
    xmlHttp.onreadystatechange = function() {
      login = document.getElementById("Articoli")
	  intestazione = document.getElementById("Intestazione")
	  if (IDLogin == ""){
	  intestazione.innerHTML="<P><B>LOGIN</B></P>";
	  }
	  else if(IDCarrello!=''){
		intestazione.innerHTML="<P><B>COMPLETA L'ORDINE</B></P>";
	   }else if (pagamento != '') {
		intestazione.innerHTML="<P><B>ORDINE</B></P>";
	   }else intestazione.innerHTML="<P><B>ARTICOLI</B></P>";
	  if(xmlHttp.readyState == 4) {
        login.innerHTML = xmlHttp.responseText;
		clearTimeout(timeout);
		//LoadBenvenuto(nominativo);
		//alert(pagamento);
		if (pagamento != '') {LoadPagamento()}
	  }
	  else{
		login.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			login.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 20*1000 );       
			     
		}
		
		
	  }
    }
	if (IDLogin == ""){
    cmdline = "verificalogin.php";
    }
	else if(IDCarrello!=''){cmdline = "visualizzaordine.php";}
	else cmdline = "articoli.php";
	xmlHttp.open("POST", cmdline, true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlHttp.send("IDCarrello=" + IDCarrello + "&IDCliente=" + IDLogin);
	
  }
   
  function LoadDesableNewsLetter() {
	    var xmlHttp;
		var timeout = null;
		var IDContatto=document.getElementById("IDContatto").value;
		var Flag=document.getElementById("desableNL").value;
		var IDLogin = "";	
	    try {
	      // Firefox, Opera 8.0+, Safari
	      xmlHttp = new XMLHttpRequest();
	    } catch (e) {
	      // Internet Explorer
	      try {
	        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	      } catch (e) {
	        try {
	          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	        } catch (e) {
	          alert("Your browser does not support AJAX!");
	        }
	      }
	    }
	    xmlHttp.onreadystatechange = function() {
	      login = document.getElementById("Articoli")
		  intestazione = document.getElementById("Intestazione")
		  /*if (IDLogin == ""){
		  intestazione.innerHTML="<P><B>LOGIN</B></P>";
		  }
		  else */intestazione.innerHTML="<P><B>DISABILITA NEWSLETTER </B></P>";
		  if(xmlHttp.readyState == 4) {
	        login.innerHTML = xmlHttp.responseText;
			
			clearTimeout(timeout);
	      }
		  else{
			login.innerHTML ="<img src='Images/loader.gif'>";
		    if (timeout == null) {      
				function timeoutFunc() {         
				xmlHttp.abort();         
				login.innerHTML = "Timeout...";      
				} 
				
				timeout = setTimeout( timeoutFunc, 20*1000 );       
				     
			}
			
			
		  }
	    }
		cmdline = "desable.php";
		xmlHttp.open("POST", cmdline, true);
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		if(Flag != ""){
	    xmlHttp.send("IDContatto=" + IDContatto);
		}
		
	  }
  
  function LoadRegistra(tipo) {
    var xmlHttp;
	var timeout = null;
	var IDCarrello=document.getElementById("IDCarrello").value;
	var IDAcconto=document.getElementById("IDACC").value;
	var IDMail =document.getElementById("IDMail").value; 
	var IDNewsLetter=document.getElementById("IDNewsLetter").value;
	var IDContatto=document.getElementById("IDContatto").value;
	
	var IDLogin = "";	
    try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
    xmlHttp.onreadystatechange = function() {
      login = document.getElementById("Articoli")
	  intestazione = document.getElementById("Intestazione")
	  /*if (IDLogin == ""){
	  intestazione.innerHTML="<P><B>LOGIN</B></P>";
	  }
	  else */intestazione.innerHTML="<P><B>REGISTRAZIONE</B></P>";
	  if(xmlHttp.readyState == 4) {
        login.innerHTML = xmlHttp.responseText;
		LoadArticoliCarrello();
		clearTimeout(timeout);
      }
	  else{
		login.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			login.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 20*1000 );       
			     
		}
		
		
	  }
    }
	cmdline = "registrazione.php";
	xmlHttp.open("POST", cmdline, true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	if(IDNewsLetter != ""){
		xmlHttp.send("IDCarrello=" + IDCarrello + "&TipologiaOrd=" + tipo + "&IDNEWS=" + IDNewsLetter +"&IDCon="+ IDContatto +"&IDMail="+ IDMail);
	}else{
    xmlHttp.send("IDCarrello=" + IDCarrello + "&TipologiaOrd=" + tipo + "&IDACC=" + IDAcconto);
	}
	
  }
    
  function LoadModifica() {
    var xmlHttp;
	var timeout = null;
	var IDCarrello=document.getElementById("IDCarrello").value;
	var IDLogin=document.getElementById("IDLogin").value;	
	var nominativo=document.getElementById("NominativoCli").value;	

    try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
    xmlHttp.onreadystatechange = function() {
      login = document.getElementById("Articoli")
	  intestazione = document.getElementById("Intestazione")
	  intestazione.innerHTML="<P><B>DATI PERSONALI</B></P>";
	  if(xmlHttp.readyState == 4) {
        login.innerHTML = xmlHttp.responseText;
		clearTimeout(timeout);
		 }
	  else{
		login.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			login.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 20*1000 );       
			     
		}
		
		
	  }
    }
	cmdline = "modificaregistrazione.php";
	xmlHttp.open("POST", cmdline, true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlHttp.send("IDCarrello=" + IDCarrello + "&IDLogin=" + IDLogin );
	
  }	
	
  //Funzione che verifica se la login inserita è corretta
  function LoadLogin() {
    var xmlHttp;
	var timeout = null;
	var txtlogin="";
	var txtpwd="";
	var IDCarrello = document.getElementById("IDCarrello").value;
		txtlogin=document.getElementById("txtlogin").value;
		txtpwd=document.getElementById("txtpwd").value;
		document.getElementById("txtlogin").value = '';
		document.getElementById("txtpwd").value ='';
		
    try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
    xmlHttp.onreadystatechange = function() {
      login = document.getElementById("loginutente")
	  utente= document.getElementById("DatiPersonali")
	  lavora= document.getElementById("Lavora")
	  franchising= document.getElementById("Franchising")
	  if(xmlHttp.readyState == 4) {
        login.innerHTML = xmlHttp.responseText;
		if (document.getElementById("IDLogin").value != ''){ 
		utente.innerHTML ='<a href="javascript:LoadModifica();"><B>DATI</B></a>';
		lavora.innerHTML ='';
		franchising.innerHTML ='';
		nominativo = document.getElementById("NominativoCli").value ;
		alert ("Benvenuto "+nominativo+" in Sportlanditalia.com - Area Riservata");
		if (document.getElementById("Area").value == 'Agente'){
			LoadAreaAgente();
			}
		}
		else alert("Dati di Login Errati!");
		clearTimeout(timeout);
      }
	  else{
		login.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			login.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 20*1000 );       
			     
		}
		
		
	  }
    }
    cmdline = "login.php"
    xmlHttp.open("POST", cmdline, true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlHttp.send("IDCarrello=" + IDCarrello+"&login="+ txtlogin + "&pwd=" + txtpwd);
	
  }
 
  function LoadRecuperaLogin() {
    var xmlHttp;
	var timeout = null;
	var txtlogin="";
	var txtpwd="";
	var IDCarrello = document.getElementById("IDCarrello").value;
	var txtlogin=document.getElementById("txtlogin").value;
	if ((txtlogin == '') || (txtlogin == 'email')){
		alert("Deve essere inserito l'inidirizzo email utilizzato per la registrazione.");
	}
	else{
		try {
		  // Firefox, Opera 8.0+, Safari
		  xmlHttp = new XMLHttpRequest();
		} catch (e) {
		  // Internet Explorer
		  try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		  } catch (e) {
			try {
			  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
			  alert("Your browser does not support AJAX!");
			}
		  }
		}
		xmlHttp.onreadystatechange = function() {
		  articoli = document.getElementById("Articoli")
		  intestazione = document.getElementById("Intestazione")
		  intestazione.innerHTML="<P><B>DATI PERSONALI</B></P>";
		  if(xmlHttp.readyState == 4) {
			articoli.innerHTML = xmlHttp.responseText;
			clearTimeout(timeout);
		  }
		  else{
			articoli.innerHTML ="<img src='Images/loader.gif'>";
			if (timeout == null) {      
				function timeoutFunc() {         
				xmlHttp.abort();         
				login.innerHTML = "Timeout...";      
				} 
				
				timeout = setTimeout( timeoutFunc, 20*1000 );       
					 
			}
			
			
		  }
		}
		cmdline = "recuperalogin.php"
		xmlHttp.open("POST", cmdline, true);
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlHttp.send("IDCarrello=" + IDCarrello+"&Email="+ txtlogin );
	}
  } 	
 
  function LoadBenvenuto(nominativo){
	var xmlHttp;
	var timeout = null;
	try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
    xmlHttp.onreadystatechange = function() {
      login = document.getElementById("loggato")
	  if(xmlHttp.readyState == 4) {
        login.innerHTML = xmlHttp.responseText;
		clearTimeout(timeout);
      }
	  else{
		login.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			login.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 20*1000 );       
			     
		}
		
		
	  }
    }
    cmdline = "logineffettuato.php"
    xmlHttp.open("POST", cmdline, true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlHttp.send("nominativo="+ nominativo );
	
 
 }
 
  function LoadLogout() {
    var xmlHttp;
	var timeout = null;
	var IDCarrello = document.getElementById("IDCarrello").value;	
	var arrivo = document.getElementById("arrivo").value;	
    try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
    xmlHttp.onreadystatechange = function() {
      login = document.getElementById("loginutente")
	  dati= document.getElementById("DatiPersonali")
	  lavora= document.getElementById("Lavora")
	  franchising= document.getElementById("Franchising")
	  if(xmlHttp.readyState == 4) {
        login.innerHTML = xmlHttp.responseText;
		dati.innerHTML ='<a href="javascript:LoadChiSiamo()"><B>CHI SIAMO</B></a>';
		lavora.innerHTML = '<a href="javascript:LoadLavoraConNoi() "><B>LAVORA CON NOI</B></a>';
		franchising.innerHTML = '<a href="javascript:LoadFranchising()"><B>FRANCHISING</B>';
		if (arrivo != 'cancellaregistrazione' )LoadIndexArticoli();
	  }
	  else{
		login.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			//login.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 20*1000 );       
			     
		}
		
		
	  }
    }
    cmdline = "login.php"
    xmlHttp.open("POST", cmdline, true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlHttp.send("IDCarrello=" + IDCarrello);
	
  }
 
  function LoadAreaAgente(){
	document.frmData.action = "AreaRiservata/index.php";
	document.frmData.target = "_self";
	document.frmData.submit();
 }
 
  function LoadLoginRegistrazione(mail,pwd) {
    var xmlHttp;
	var timeout = null;
	var txtlogin;
	var txtpwd;
	var IDCarrello = document.getElementById("IDCarrello").value;
	if (mail == ''){
		txtlogin=document.getElementById("txtloginord").value;
		txtpwd=document.getElementById("txtpwdord").value;
	}else
	{
		txtlogin=mail;
		txtpwd=pwd;
	}
	
	try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
    xmlHttp.onreadystatechange = function() {
      login = document.getElementById("loginutente")
	  if(xmlHttp.readyState == 4) {
        login.innerHTML = xmlHttp.responseText;
		LoadVerificaLogin();
		if (document.getElementById("IDLogin").value == ''){ 
		alert("Utente non riconosciuto. Registrarsi o verificare i dati inseriti!");}
		clearTimeout(timeout);
      }
	  else{
		login.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			login.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 20*1000 );       
			     
		}
		
		
	  }
    }
    cmdline = "login.php"
    xmlHttp.open("POST", cmdline, true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlHttp.send("login="+ txtlogin + "&pwd=" + txtpwd + "&IDCarrello=" + IDCarrello);
	
  }

  function ReloadLogin(mail,pwd) {
    var xmlHttp;
	var timeout = null;
	var txtlogin;
	var txtpwd;
	var IDCarrello = document.getElementById("IDCarrello").value;
	if (mail == ''){
		txtlogin=document.getElementById("txtloginord").value;
		txtpwd=document.getElementById("txtpwdord").value;
	}else
	{
		txtlogin=mail;
		txtpwd=pwd;
	}
	
	try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
    xmlHttp.onreadystatechange = function() {
      login = document.getElementById("loginutente")
	  utente= document.getElementById("DatiPersonali")
	  lavora= document.getElementById("Lavora")
	  franchising= document.getElementById("Franchising")
	   if(xmlHttp.readyState == 4) {
        login.innerHTML = xmlHttp.responseText;
		utente.innerHTML ='<a href="javascript:LoadModifica();"><B>DATI</B></a>';
		lavora.innerHTML ='';
		franchising.innerHTML ='';
		clearTimeout(timeout);
      }
	  else{
		login.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			login.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 20*1000 );       
			     
		}
		
		
	  }
    }
    cmdline = "login.php"
    xmlHttp.open("POST", cmdline, true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlHttp.send("login="+ txtlogin + "&pwd=" + txtpwd + "&IDCarrello=" + IDCarrello);
	
  }
  
  function verificaDatiRegistrazione(){
 var timeout = null;
	var nome = "";
	var cognome = "";
	var indirizzo = "";
	var mail = "";
	var telefono = "";
	var cap = "";
	var prov = "";
	var nazione = "";
	var IDnazione = "";
	var tipologia = "";
	var citta = "";
	var iva = "";
	var cf = "";
	var azienda = "";
	var nominativo = "";
	var pwd = "";
	var confpwd = "";
	var spedizione ="";
	var IDCarrello = document.getElementById("IDCarrello").value;
	var arrivo = document.getElementById("arrivo").value;
	
	
	
	if(document.getElementById("rbSelezioneP").checked) {
		
		 //campi Privato 
		tipologia = 'P';
		if (document.getElementById("Nome").value != ''){
			nome = document.getElementById("Nome").value;
		}else{
			alert("Deve essere inserito il Nome.");
			return ;
		}
		/*if (document.getElementById("Cognome").value !=''){
			cognome = document.getElementById("Cognome").value;
		}else{
			alert("Deve essere inserito il Cognome.");
			return ;
		}*/
		if (document.getElementById("Indirizzo").value!= '' ){
			indirizzo = document.getElementById("Indirizzo").value;
		}else{
			alert("Deve essere inserito l'Indirizzo.");
			return ;
		}
		
		if (document.getElementById("IndirizzoSped").value!= '' ){
			indirizzo = document.getElementById("IndirizzoSped").value;
		}else{
			alert("Deve essere inserito l'Indirizzo dispedizione.");
			return ;
		}
		
		if (document.getElementById("cap").value != ''){
			cap = document.getElementById("cap").value;
		}else{
			alert("Deve essere inserito il Cap.");
			return ;
		}
		
		if (document.getElementById("Citta").value != ''){
			citta = document.getElementById("Citta").value;
		}else{
			alert("Deve essere inserita la Citta.");
			return ;
		}
		
		if (document.getElementById("Provincia").value != ''){
			prov = document.getElementById("Provincia").value;
		}else{
			alert("Deve essere inserita la Provincia.");
			return ;
		}
		
		if (document.getElementById("Nazione").value != ''){
			nazione = document.getElementById("Nazione").value;
			
		}else{
			alert("Deve essere inserita la Nazione.");
			return ;
		}
		
		if (document.getElementById("Cf").value != ''){
			nazione = document.getElementById("Cf").value;
		}else{
			alert("Deve essere inserito il codice fiscale.");
			return ;
		}
		
		if (document.getElementById("Mail").value != ''){
			mail = document.getElementById("Mail").value;
		}else{
			alert("Deve essere inserito l'indirizzo Email.");
			return ;
		}
		
		if (document.getElementById("Telefono").value != ''){
			telefono = document.getElementById("Telefono").value;
		}else{
			alert("Deve essere inserito il numero di Telefono.");
			return ;
		}
		
		 
	}
	if(document.getElementById("rbSelezioneA").checked) {
		 //Abilito i campi Azienda e disabilito i campi Privato
		tipologia = 'P'; 
		if (document.getElementById("Azienda").value!= '' ){
			azienda = document.getElementById("Azienda").value;
		}else{	
			alert("Deve essere inserito il nome dell'Azienda.");
			return ;
		}
		
		if (document.getElementById("Nominativo").value!= '' ){
			nominativo = document.getElementById("Nominativo").value;
		}else{	
			alert("Deve essere inserito il Nominativo.");
			return ;
		}
				
		if (document.getElementById("Aindirizzo").value!= '' ){
			indirizzo = document.getElementById("Aindirizzo").value;
		}else{
			alert("Deve essere inserito l'Indirizzo.");
			return ;
		}
		
		if (document.getElementById("AindirizzoSped").value!= '' ){
			indirizzo = document.getElementById("AindirizzoSped").value;
		}else{
			alert("Deve essere inserito l'indirizzo di spedizione.");
			return ;
		}
		
		if (document.getElementById("Acap").value != ''){
			cap = document.getElementById("Acap").value;
		}else{
			alert("Deve essere inserito il Cap.");
			return ;
		}
		
		if (document.getElementById("Acitta").value != ''){
			citta = document.getElementById("Acitta").value;
		}else{
			alert("Deve essere inserito la Citta.");
			return ;
		}
		
		if (document.getElementById("Aprovincia").value != ''){
			prov = document.getElementById("Aprovincia").value;
		}else{
			alert("Deve essere inserito la Provincia.");
			return ;
		}
		
		if (document.getElementById("Anazione").value != ''){
			nazione = document.getElementById("Anazione").value;
		}else{
			alert("Deve essere inserito la Nazione.");
			return ;
		}
		
		if (document.getElementById("iva").value != ''){
			iva = document.getElementById("iva").value;
		}else{
			alert("Deve essere inserito il numero di P.Iva.");
			return ;
		}
		
		if (document.getElementById("Amail").value != ''){
			mail = document.getElementById("Amail").value;
		}else{
			alert("Deve essere inserito l'indirizzo Email.");
			return ;
		}
		
		if (document.getElementById("Atelefono").value != ''){
			telefono = document.getElementById("Atelefono").value;
		}else{
			alert("Deve essere inserito il numero di Telefono.");
			return ;
		}
				
	}
	
	if (document.getElementById("Password").value != ''){
		pwd = document.getElementById("Password").value;
	}else{
		alert("Deve essere inserita la Password.");
		return ;
	}	
	
	if (document.getElementById("Password").value != document.getElementById("confermaPassword").value){
	
		alert("Le password inserite non corrispondono.");
		return ;
	}	
	
	if (!document.getElementById("ckCondizioni").checked){
		alert("Bisogna accettare le condizioni di vendita per registrarsi.");
		return ;
	}
	if (arrivo == 'modificaregistrazione') {
		modificaLogin();
	}
	else registraLogin();
 
 }
  
  function registraLogin() {
    var xmlHttp;
	var timeout = null;
	var nome = "";
	var cognome = "";
	var indirizzo = "";
	var mail = "";
	var telefono = "";
	var cap = "";
	var prov = "";
	var nazione = "";
	var tipologia = "";
	var citta = "";
	var iva = "";
	var cf = "";
	var azienda = "";
	var nominativo = "";
	var spedizione = "";
	var pwd = document.getElementById("Password").value;
	var IDCarrello = document.getElementById("IDCarrello").value;
	var TipologiaOrd = 'ORD';
	var arrivo = document.getElementById("arrivo").value;
	var nominativo = document.getElementById("NominativoCli").value;
	if(document.getElementById("rbSelezioneP").checked) {
		
		 //campi Privato 
		tipologia = 'P';
		nome = document.getElementById("Nome").value;
		cognome = document.getElementById("Cognome").value;
		indirizzo = document.getElementById("Indirizzo").value;
		spedizione = document.getElementById("IndirizzoSped").value;
		cap = document.getElementById("cap").value;
		citta = document.getElementById("Citta").value;
		prov = document.getElementById("Provincia").value;
		nazione = document.getElementById("Nazione").value;
		mail = document.getElementById("Mail").value;
		cf= document.getElementById("Cf").value;
		telefono = document.getElementById("Telefono").value;
		 
	}
	if(document.getElementById("rbSelezioneA").checked) {
		 //Abilito i campi Azienda e disabilito i campi Privato
		tipologia = 'A'; 
		azienda = document.getElementById("Azienda").value;
		nominativo = document.getElementById("Nominativo").value;
		indirizzo = document.getElementById("Aindirizzo").value;
		spedizione = document.getElementById("AindirizzoSped").value;
		cap = document.getElementById("Acap").value;
		citta = document.getElementById("Acitta").value;
		nazione = document.getElementById("Anazione").value;
		prov = document.getElementById("Aprovincia").value;
		iva = document.getElementById("iva").value;
		mail = document.getElementById("Amail").value;
		telefono = document.getElementById("Atelefono").value;
	}
	
	
    try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
    xmlHttp.onreadystatechange = function() {
      articoli = document.getElementById("Articoli")
	  if(xmlHttp.readyState == 4) {
        articoli.innerHTML = xmlHttp.responseText;
		
	if (document.getElementById("esitoRegistrazione").value == 'KO'){
		alert("Indirizzo Email già utilizzato. Selezionare il tasto 'RECUPERA PASSWORD' e vi sarà inoltrata via Email.");
		LoadVerificaLogin();
	}
	else{
    	LoadLoginRegistrazione(mail,pwd);
		
	}	
	clearTimeout(timeout);
      }
	  else{
		articoli.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			articoli.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 20*1000 );       
			     
		}
		
		
	  }
    }
	//alert("arrivo="+arrivo+"&IDCarrello="+IDCarrello+"pwd="+pwd+"&nome="+nome+"&cognome="+cognome+"&indirizzo="+indirizzo+"&mail="+mail+"&telefono="+telefono+"&cap="+cap+"&prov="+prov+"&nazione="+nazione+"&tipologia="+tipologia+"&citta="+citta+"&iva="+iva+"&azienda="+azienda+"&nominativo="+nominativo);
    cmdline = "registrautente.php"
    xmlHttp.open("POST", cmdline, true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlHttp.send("arrivo="+arrivo+"&IDCarrello="+IDCarrello+"&TipologiaOrd="+TipologiaOrd+"&nome="+nome+"&cognome="+cognome+"&indirizzo="+indirizzo+"&spedizione="+spedizione+"&mail="+mail+"&pwd="+pwd+"&telefono="+telefono+"&cap="+cap+"&prov="+prov+"&nazione="+nazione+"&tipologia="+tipologia+"&citta="+citta+"&iva="+iva+"&cf="+cf+"&azienda="+azienda+"&nominativo="+nominativo);
	
  }
  
  function modificaLogin() {
    var xmlHttp;
	var timeout = null;
	var nome = "";
	var cognome = "";
	var indirizzo = "";
	var mail = "";
	var telefono = "";
	var cap = "";
	var prov = "";
	var nazione = "";
	var tipologia = "";
	var citta = "";
	var iva = "";
	var cf = "";
	var azienda = "";
	var nominativo = "";
	var spedizione = "";
	var pwd = document.getElementById("Password").value;
	var IDCarrello = document.getElementById("IDCarrello").value;
	var IDCliente = document.getElementById("IDCliente").value;
	var TipologiaOrd = 'ORD';
	var arrivo = document.getElementById("arrivo").value;
	var nominativo = document.getElementById("NominativoCli").value;
	if(document.getElementById("rbSelezioneP").checked) {
		
		 //campi Privato 
		tipologia = 'P';
		nome = document.getElementById("Nome").value;
		cognome = document.getElementById("Cognome").value;
		indirizzo = document.getElementById("Indirizzo").value;
		spedizione = document.getElementById("IndirizzoSped").value;
		cap = document.getElementById("cap").value;
		citta = document.getElementById("Citta").value;
		prov = document.getElementById("Provincia").value;
		nazione = document.getElementById("Nazione").value;
		mail = document.getElementById("Mail").value;
		cf= document.getElementById("Cf").value;
		telefono = document.getElementById("Telefono").value;
		 
	}
	if(document.getElementById("rbSelezioneA").checked) {
		 //Abilito i campi Azienda e disabilito i campi Privato
		tipologia = 'A'; 
		azienda = document.getElementById("Azienda").value;
		nominativo = document.getElementById("Nominativo").value;
		indirizzo = document.getElementById("Aindirizzo").value;
		spedizione = document.getElementById("AindirizzoSped").value;
		cap = document.getElementById("Acap").value;
		citta = document.getElementById("Acitta").value;
		nazione = document.getElementById("Anazione").value;
		prov = document.getElementById("Aprovincia").value;
		iva = document.getElementById("iva").value;
		mail = document.getElementById("Amail").value;
		telefono = document.getElementById("Atelefono").value;
	}
	
	
    try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
    xmlHttp.onreadystatechange = function() {
      articoli = document.getElementById("Articoli")
	  if(xmlHttp.readyState == 4) {
        articoli.innerHTML = xmlHttp.responseText;
		if (document.getElementById("esitoRegistrazione").value == 'KO'){
			alert("Indirizzo Email già utilizzato per un altro utente.");
			LoadModifica();
		}else registrazioneeffettuata('MOD') ;
		clearTimeout(timeout);
      }
	  else{
		articoli.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			articoli.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 20*1000 );       
			     
		}
		
		
	  }
    }
	//alert("arrivo="+arrivo+"&IDCarrello="+IDCarrello+"pwd="+pwd+"&nome="+nome+"&cognome="+cognome+"&indirizzo="+indirizzo+"&mail="+mail+"&telefono="+telefono+"&cap="+cap+"&prov="+prov+"&nazione="+nazione+"&tipologia="+tipologia+"&citta="+citta+"&iva="+iva+"&azienda="+azienda+"&nominativo="+nominativo);
    cmdline = "registrautente.php"
    xmlHttp.open("POST", cmdline, true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlHttp.send("arrivo="+arrivo+"&IDCliente="+IDCliente+"&IDCarrello="+IDCarrello+"&TipologiaOrd="+TipologiaOrd+"&nome="+nome+"&cognome="+cognome+"&indirizzo="+indirizzo+"&spedizione="+spedizione+"&mail="+mail+"&pwd="+pwd+"&telefono="+telefono+"&cap="+cap+"&prov="+prov+"&nazione="+nazione+"&tipologia="+tipologia+"&citta="+citta+"&iva="+iva+"&cf="+cf+"&azienda="+azienda+"&nominativo="+nominativo);
	
  }
  
  function cancellaIscrizione() {
    var xmlHttp;
	var timeout = null;
	var IDCarrello = document.getElementById("IDCarrello").value;
	var IDCliente = document.getElementById("IDCliente").value;
	var TipologiaOrd = 'ORD';
	var arrivo = document.getElementById("arrivo").value;
	var answer = confirm ("Sei sicuro di voler cancellare la tua iscrizione ?")
	if (answer){
		
		try {
		  // Firefox, Opera 8.0+, Safari
		  xmlHttp = new XMLHttpRequest();
		} catch (e) {
		  // Internet Explorer
		  try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		  } catch (e) {
			try {
			  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
			  alert("Your browser does not support AJAX!");
			}
		  }
		}
		xmlHttp.onreadystatechange = function() {
		  articoli = document.getElementById("Articoli")
		  if(xmlHttp.readyState == 4) {
			articoli.innerHTML = xmlHttp.responseText;
			LoadLogout();
			clearTimeout(timeout);
		  }
		  else{
			articoli.innerHTML ="<img src='Images/loader.gif'>";
			if (timeout == null) {      
				function timeoutFunc() {         
				xmlHttp.abort();         
				articoli.innerHTML = "Timeout...";      
				} 
				
				timeout = setTimeout( timeoutFunc, 20*1000 );       
					 
			}
			
			
		  }
		}
		cmdline = "cancellaregistrazione.php"
		xmlHttp.open("POST", cmdline, true);
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlHttp.send("arrivo="+arrivo+"&IDCliente="+IDCliente+"&IDCarrello="+IDCarrello+"&TipologiaOrd="+TipologiaOrd);
		}
  }
  
  function registrazioneeffettuata(sezione) {
    var xmlHttp;
	var timeout = null;
	var IDCarrello=document.getElementById("IDCarrello").value;
	
    try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
    xmlHttp.onreadystatechange = function() {
      chisiamo = document.getElementById("Articoli")
	  if(xmlHttp.readyState == 4) {
        chisiamo.innerHTML = xmlHttp.responseText;
		clearTimeout(timeout);
      }
	  else{
		chisiamo.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			chisiamo.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 10*1000 );       
			     
		}
		
		
	  }
    }
    if (sezione != 'MOD'){
		cmdline = "registrazioneEffettuata.php"
    }
	else cmdline = "modificaEffettuata.php"
	
	xmlHttp.open("POST", cmdline, true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlHttp.send("IDCarrello=" + IDCarrello);
	
  } 	
  
  function ckSelezione(){


 if(document.getElementById("rbSelezioneP").checked) {
 //Abilito i campi Privato 

 document.getElementById("Nome").disabled = false;
 document.getElementById("Nome").style.background = '#ffffff';
 document.getElementById("Cognome").disabled = false;
 document.getElementById("Cognome").style.background = '#ffffff';
 document.getElementById("Indirizzo").disabled = false;
 document.getElementById("Indirizzo").style.background = '#ffffff';
 document.getElementById("IndirizzoSped").disabled = false;
 document.getElementById("IndirizzoSped").style.background = '#ffffff';
 document.getElementById("Mail").disabled = false;
 document.getElementById("Mail").style.background = '#ffffff';
 document.getElementById("Cf").disabled = false;
 document.getElementById("CF").style.background = '#ffffff';
 document.getElementById("Telefono").disabled = false;
 document.getElementById("Telefono").style.background = '#ffffff';
 document.getElementById("cap").disabled = false;
 document.getElementById("cap").style.background = '#ffffff';
 document.getElementById("Citta").disabled = false;
 document.getElementById("Citta").style.background = '#ffffff';
 document.getElementById("Provincia").disabled = false;
 document.getElementById("Provincia").style.background = '#ffffff';
 document.getElementById("Nazione").disabled = false;
 document.getElementById("Nazione").style.background = '#ffffff';
 
 
 //Disabilito i campi Azienda
 document.getElementById("Azienda").disabled = true;
 document.getElementById("Azienda").style.background = '#dddddd';
 document.getElementById("Nominativo").disabled = true;
 document.getElementById("Nominativo").style.background = '#dddddd';
 document.getElementById("Aindirizzo").disabled = true;
 document.getElementById("Aindirizzo").style.background = '#dddddd';
 document.getElementById("AindirizzoSped").disabled = true;
 document.getElementById("AindirizzoSped").style.background = '#dddddd';
 document.getElementById("Acap").disabled = true;
 document.getElementById("Acap").style.background = '#dddddd';
 document.getElementById("Acitta").disabled = true;
 document.getElementById("Acitta").style.background = '#dddddd';
 document.getElementById("Anazione").disabled = true;
 document.getElementById("Anazione").style.background = '#dddddd';
 document.getElementById("Aprovincia").disabled = true;
 document.getElementById("Aprovincia").style.background = '#dddddd';
 document.getElementById("iva").disabled = true;
 document.getElementById("iva").style.background = '#dddddd';
 document.getElementById("Amail").disabled = true;
 document.getElementById("Amail").style.background = '#dddddd';
 document.getElementById("Atelefono").disabled = true;
 document.getElementById("Atelefono").style.background = '#dddddd';
 }
 if(document.getElementById("rbSelezioneA").checked) {
 //Abilito i campi Azienda e disabilito i campi Privato
 
 document.getElementById("Azienda").disabled = false;
 document.getElementById("Azienda").style.background = '#ffffff';
 document.getElementById("Nominativo").disabled = false;
 document.getElementById("Nominativo").style.background = '#ffffff';
 document.getElementById("Aindirizzo").disabled = false;
 document.getElementById("Aindirizzo").style.background = '#ffffff';
 document.getElementById("AindirizzoSped").disabled = false;
 document.getElementById("AindirizzoSped").style.background = '#ffffff';
 document.getElementById("Acap").disabled = false;
 document.getElementById("Acap").style.background = '#ffffff';
 document.getElementById("Acitta").disabled = false;
 document.getElementById("Acitta").style.background = '#ffffff';
 document.getElementById("Anazione").disabled = false;
 document.getElementById("Anazione").style.background = '#ffffff';
 document.getElementById("Aprovincia").disabled = false;
 document.getElementById("Aprovincia").style.background = '#ffffff';
 document.getElementById("iva").disabled = false;
 document.getElementById("iva").style.background = '#ffffff';
 document.getElementById("Amail").disabled = false;
 document.getElementById("Amail").style.background = '#ffffff';
 document.getElementById("Atelefono").disabled = false;
 document.getElementById("Atelefono").style.background = '#ffffff';
 
 
 document.getElementById("Nome").disabled = true;
 document.getElementById("Nome").style.background = '#dddddd';
 document.getElementById("Cognome").disabled = true;
 document.getElementById("Cognome").style.background = '#dddddd';
 document.getElementById("Indirizzo").disabled = true;
 document.getElementById("Indirizzo").style.background = '#dddddd';
 document.getElementById("IndirizzoSped").disabled = true;
 document.getElementById("IndirizzoSped").style.background = '#dddddd';
 document.getElementById("Mail").disabled = true;
 document.getElementById("Mail").style.background = '#dddddd';
 document.getElementById("Telefono").disabled = true;
 document.getElementById("Telefono").style.background = '#dddddd';
 document.getElementById("cap").disabled = true;
 document.getElementById("cap").style.background = '#dddddd';
 document.getElementById("Citta").disabled = true;
 document.getElementById("Citta").style.background = '#dddddd';
 document.getElementById("Provincia").disabled = true;
 document.getElementById("Provincia").style.background = '#dddddd';
 document.getElementById("Nazione").disabled = true;
 document.getElementById("Nazione").style.background = '#dddddd';
 document.getElementById("Cf").disabled = true;
 document.getElementById("CF").style.background = '#dddddd';
 }
}

  function registraOrdine(){
var IDCarrello = document.getElementById("IDCarrello").value;
var TipologiaOrd = 'ORD';
var IDCliente = document.getElementById("IDCliente").value;
var TipologiaPagamento = document.getElementById("selPayment").value;
	if(TipologiaPagamento == ''){alert('Modalità di pagamento mancante'); return;}
var xmlHttp;
	var timeout = null;
    //categoria = document.getElementById("selCat")
    try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
    xmlHttp.onreadystatechange = function() {
      articoli = document.getElementById("Articoli")
	  intestazione = document.getElementById("Intestazione")
	  if (TipologiaOrd == 'ORD'){
	  intestazione.innerHTML="<P><B>ORDINE</B></P>";
	  }else{
	  intestazione.innerHTML="<P><B>PREVENTIVO</B></P>";
	  }
	  if(xmlHttp.readyState == 4) {
        articoli.innerHTML = xmlHttp.responseText;
		LoadArticoliCarrello();
		if ((TipologiaPagamento == 6)||(TipologiaPagamento==7)){
			Pagamento(TipologiaPagamento);
		}
		clearTimeout(timeout);
      }
	  else{
		articoli.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			articoli.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 20*1000 );       
			     
		}
		
		
	  }
    }
	
	cmdline = "registraordine.php" 
	xmlHttp.open("POST", cmdline, true);
    xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("IDCarrello=" + IDCarrello+ "&IDCliente=" + IDCliente +"&TipologiaOrd="+TipologiaOrd+"&TipologiaPagamento="+TipologiaPagamento);

}

  function apriOrdPDF(tipo){
var IDOrdine = document.getElementById("IDOrdine").value;
if (tipo=='ORD'){
 window.open('ordini/Ordine_'+IDOrdine+'.pdf','_new','location=no,menubar=no,resizable=yes'); 
}else{
window.open('ordini/Preventivo_'+IDOrdine+'.pdf','_new','location=no,menubar=no,resizable=yes'); 
} 
} 

  function LoadChiSiamo() {
    var xmlHttp;
	var timeout = null;
	var IDCarrello=document.getElementById("IDCarrello").value;
	
    try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
    xmlHttp.onreadystatechange = function() {
      chisiamo = document.getElementById("Articoli")
	  intestazione = document.getElementById("Intestazione")
	  intestazione.innerHTML="<P><B>CHI SIAMO</B></P>";
	  if(xmlHttp.readyState == 4) {
        chisiamo.innerHTML = xmlHttp.responseText;
		clearTimeout(timeout);
      }
	  else{
		chisiamo.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			chisiamo.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 10*1000 );       
			     
		}
		
		
	  }
    }
    cmdline = "chisiamo.php"
    xmlHttp.open("POST", cmdline, true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlHttp.send("IDCarrello=" + IDCarrello);
	
  } 	

  function LoadPersonalizzato() {
    var xmlHttp;
	var timeout = null;
	var IDCarrello=document.getElementById("IDCarrello").value;
	
    try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
    xmlHttp.onreadystatechange = function() {
      chisiamo = document.getElementById("Articoli")
	  intestazione = document.getElementById("Intestazione")
	  intestazione.innerHTML="<P><B>PERSONALIZZATO</B></P>";
	  if(xmlHttp.readyState == 4) {
        chisiamo.innerHTML = xmlHttp.responseText;
		clearTimeout(timeout);
      }
	  else{
		chisiamo.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			chisiamo.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 10*1000 );       
			     
		}
		
		
	  }
    }
    cmdline = "personalizzato.php"
    xmlHttp.open("POST", cmdline, true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlHttp.send("IDCarrello=" + IDCarrello);
	
  }
  
  function LoadLavoraConNoi() {
    var xmlHttp;
	var timeout = null;
	var IDCarrello=document.getElementById("IDCarrello").value;
	
    try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
    xmlHttp.onreadystatechange = function() {
      chisiamo = document.getElementById("Articoli")
	  intestazione = document.getElementById("Intestazione")
	  intestazione.innerHTML="<P><B>LAVORA CON NOI</B></P>";
	  if(xmlHttp.readyState == 4) {
        chisiamo.innerHTML = xmlHttp.responseText;
		clearTimeout(timeout);
      }
	  else{
		chisiamo.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			chisiamo.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 10*1000 );       
			     
		}
		
		
	  }
    }
    cmdline = "lavoraconnoi.php"
    xmlHttp.open("POST", cmdline, true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlHttp.send("IDCarrello=" + IDCarrello);
	
  }

  function LoadFranchising() {
    var xmlHttp;
	var timeout = null;
	var IDCarrello=document.getElementById("IDCarrello").value;
	
    try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
    xmlHttp.onreadystatechange = function() {
      chisiamo = document.getElementById("Articoli")
	  intestazione = document.getElementById("Intestazione")
	  intestazione.innerHTML="<P><B>FRANCHISING</B></P>";
	  if(xmlHttp.readyState == 4) {
        chisiamo.innerHTML = xmlHttp.responseText;
		clearTimeout(timeout);
      }
	  else{
		chisiamo.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			chisiamo.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 10*1000 );       
			     
		}
		
		
	  }
    }
    cmdline = "franchising.php"
    xmlHttp.open("POST", cmdline, true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlHttp.send("IDCarrello=" + IDCarrello);
	
  }

  function LoadFaq() {
    var xmlHttp;
	var timeout = null;
	var IDCarrello=document.getElementById("IDCarrello").value;
	
    try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
    xmlHttp.onreadystatechange = function() {
      chisiamo = document.getElementById("Articoli")
	  intestazione = document.getElementById("Intestazione")
	  intestazione.innerHTML="<P><B>FAQ</B></P>";
	  if(xmlHttp.readyState == 4) {
        chisiamo.innerHTML = xmlHttp.responseText;
		clearTimeout(timeout);
      }
	  else{
		chisiamo.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			chisiamo.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 10*1000 );       
			     
		}
		
		
	  }
    }
    cmdline = "faq.php"
    xmlHttp.open("POST", cmdline, true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlHttp.send("IDCarrello=" + IDCarrello);
	
  }
  function LoadFiltriCataloghi(){
	   var xmlHttp;
		var timeout = null;
		var IDCarrello=document.getElementById("IDCarrello").value;
		
		
	    try {
	      // Firefox, Opera 8.0+, Safari
	      xmlHttp = new XMLHttpRequest();
	    } catch (e) {
	      // Internet Explorer
	      try {
	        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	      } catch (e) {
	        try {
	          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	        } catch (e) {
	          alert("Your browser does not support AJAX!");
	        }
	      }
	    }
	    xmlHttp.onreadystatechange = function() {
	      chisiamo = document.getElementById("Articoli")
		  intestazione = document.getElementById("Intestazione")
		  intestazione.innerHTML="<P><B>CATALOGHI</B></P>";
		  if(xmlHttp.readyState == 4) {
	        chisiamo.innerHTML = xmlHttp.responseText;
			clearTimeout(timeout);
	      }
		  else{
			chisiamo.innerHTML ="<img src='Images/loader.gif'>";
		    if (timeout == null) {      
				function timeoutFunc() {         
				xmlHttp.abort();         
				chisiamo.innerHTML = "Timeout...";      
				} 
				
				timeout = setTimeout( timeoutFunc, 10*1000 );       
				     
			}
			
			
		  }
		  LoadCataloghi(1);
	    }
	    cmdline = "Cataloghi.php"
	    xmlHttp.open("POST", cmdline, true);
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	    xmlHttp.send("IDCarrello=" + IDCarrello);
	   
	  }
  
  function LoadCataloghi(page){
	var xmlHttp;
	var timeout = null;
	if(document.frmSearch){
		var txtCatalogo = document.frmSearch.txtDescrizione.value;
	
		try {
	      // Firefox, Opera 8.0+, Safari
	      xmlHttp = new XMLHttpRequest();
	    } catch (e) {
	      // Internet Explorer
	      try {
	        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	      } catch (e) {
	        try {
	          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	        } catch (e) {
	          alert("Your browser does not support AJAX!");
	        }
	      }
	    }
	    xmlHttp.onreadystatechange = function() {
	      chisiamo = document.getElementById("listaCat")
		 
		  if(xmlHttp.readyState == 4) {
	        chisiamo.innerHTML = xmlHttp.responseText;
			clearTimeout(timeout);
	      }
		  else{
			chisiamo.innerHTML ="<img src='Images/loader.gif'>";
		    if (timeout == null) {      
				function timeoutFunc() {         
				xmlHttp.abort();         
				chisiamo.innerHTML = "Timeout...";      
				} 
				
				timeout = setTimeout( timeoutFunc, 10*1000 );       
				     
			}
			
			
		  }
	    }
	    cmdline = "listCataloghi.php"
	    xmlHttp.open("POST", cmdline, true);
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	    xmlHttp.send("Page="+page+"&Desc="+txtCatalogo);
		}    
	}
  
  function LoadOfferte() {
    var xmlHttp;
	var timeout = null;
	var IDCarrello=document.getElementById("IDCarrello").value;
	
    try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
    xmlHttp.onreadystatechange = function() {
      chisiamo = document.getElementById("Articoli")
	  intestazione = document.getElementById("Intestazione")
	  intestazione.innerHTML="<P><B>OFFERTE</B></P>";
	  if(xmlHttp.readyState == 4) {
        chisiamo.innerHTML = xmlHttp.responseText;
		clearTimeout(timeout);
      }
	  else{
		chisiamo.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			chisiamo.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 10*1000 );       
			     
		}
		
		
	  }
    }
    cmdline = "offerte.php"
    xmlHttp.open("POST", cmdline, true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlHttp.send("IDCarrello=" + IDCarrello);
	
  }
  
  function LoadModuloPreventivo() {
    var xmlHttp;
	var timeout = null;
	var IDCarrello=document.getElementById("IDCarrello").value;
	
    try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
    xmlHttp.onreadystatechange = function() {
      chisiamo = document.getElementById("Articoli")
	  intestazione = document.getElementById("Intestazione")
	  intestazione.innerHTML="<P><B>RICHIESTA PREVENTIVO</B></P>";
	  if(xmlHttp.readyState == 4) {
        chisiamo.innerHTML = xmlHttp.responseText;
		clearTimeout(timeout);
      }
	  else{
		chisiamo.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			chisiamo.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 10*1000 );       
			     
		}
		
		
	  }
    }
    cmdline = "modulo.php"
    xmlHttp.open("POST", cmdline, true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlHttp.send("IDCarrello=" + IDCarrello);
	
  }
  
  function SendMail() {
    var xmlHttp;
	var timeout = null;
	var IDCarrello=document.getElementById("IDCarrello").value;
	var Nominativo = document.getElementById("txtNominativo").value;
	var Societa = document.getElementById("txtSocieta").value;
	var Telefono = document.getElementById("txtTelefono").value;
	var Email = document.getElementById("txtEmail").value;
	var Richiesta = document.getElementById("txtRichiesta").value;
	var Settore = document.getElementById("selSettore").value;
	var Image = document.frmImage.Image.value;
	
	if (Image.substr(Image.length -3,3) != 'pdf' && Image.substr(Image.length -3,3) != 'peg' && Image.substr(Image.length -3,3) != 'jpg' && Image.substr(Image.length -3,3) != 'png' && Image.substr(Image.length -3,3) != 'gif' ){
		alert("I document inviabili via email possono essere solo pdf o immagini");
		return false;
	}
	var FlagNewsLetter = "";
	if(document.getElementById("chkNewsPers").checked) {
		FlagNewsLetter = 'Y';
	}else{
		FlagNewsLetter = 'N';
	}
	
	if ((Nominativo=="") || (Societa=="") || (Telefono=="") || (Email=="") || (Richiesta=="") || (Settore==""))
	{
		alert("Inserire i dati di richiesta preventivo. Grazie");
		return false;
	}
	
	
	$('#frmImage').submit();
	$('#Articoli').html("<img src='Images/loader.gif'>");
   /* try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
    xmlHttp.onreadystatechange = function() {
      MailRichiesta = document.getElementById("Articoli")
	  if(xmlHttp.readyState == 4) {
        MailRichiesta.innerHTML = xmlHttp.responseText;
		clearTimeout(timeout);
      }
	  else{
		MailRichiesta.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			MailRichiesta.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 10*1000 );       
			     
		}
		
		
	  }
    }
    cmdline = "sendmail.php"
    xmlHttp.open("POST", cmdline, true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("IDCarrello=" + IDCarrello + "&Nominativo=" + Nominativo + "&Societa=" + Societa + "&Telefono=" + Telefono + "&Email=" + Email + "&Richiesta=" + Richiesta + "&Settore=" + Settore + "&FlagNewsLetter=" + FlagNewsLetter+"&Image="+Image );
  */
  }
  
  function ResizeImage(ID){
		
	   	window.open('ZoomImage.php?IDProd='+ ID ,'_blank','width=650,height=490,left=200,top=150,toolbar=no, location=no,status=yes,menubar=no,scrollbars=no,resizable=no,Zoom Foto);');
	}
  
  function Pagamento (ID){
	if (ID == 6 ){
	var tid=document.getElementById("tid").value;
	window.open('https://www.monetaonline.it:443/MPI2/gateway/payment/payment.jsp?PaymentID='+tid ,'_self');
   }else if(ID == 7 ){
	var IDOrdine = document.getElementById("IDOrdine").value;
	var Totale = document.getElementById("Totale").value;
	cmdline = "paypal.php" ;
	window.open('paypal.php?IDOrdine='+IDOrdine+"&Totale="+Totale ,'_self');
	}
   }
   
  function LoadIndex (){
	 var esito = document.getElementById("Pagamento").value;
	 var promozione = document.getElementById("Promozione").value;
	 var acconto = document.getElementById("IDACC").value;
	 var IDContatto = document.getElementById("IDContatto").value;
	 var DesableNL = document.getElementById("desableNL").value;
	 
	 
	 if (DesableNL == '1'){
		 LoadDesableNewsLetter();
		 }
	 var newsletter = document.getElementById("news").value;
	 if (newsletter == 'DEL'){
		LoadDeleteNewsLetter();
	 }
	 else if ((esito == 'KO') || (esito == 'OK')){	
		var mail = document.getElementById("email").value;
		var pwd = document.getElementById("pwd").value;
		ReloadLogin(mail,pwd);
		LoadPagamento();
	    document.getElementById("Pagamento").value	= "";
	 }
	 else if (promozione != '') {
		LoadPromozioni(promozione)
	 }else if (acconto != '' || IDContatto != ''){
		LoadRegistra('ORD');
	 }
	 else LoadArticoli('','','');	
  }  
   
  function LoadPagamento(){
	var esito = document.getElementById("Pagamento").value;
	
	var xmlHttp;
	var timeout = null;
    //categoria = document.getElementById("selCat")
    try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
    xmlHttp.onreadystatechange = function() {
      articoli = document.getElementById("Articoli")
	  intestazione = document.getElementById("Intestazione")
	  intestazione.innerHTML="<P><B>ORDINE</B></P>";
	  if(xmlHttp.readyState == 4) {
        articoli.innerHTML = xmlHttp.responseText;
		clearTimeout(timeout);
      }
	  else{
		articoli.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			articoli.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 20*1000 );       
			     
		}
		
		
	  }
    }
	
	cmdline = "pagamento.php" ;
	xmlHttp.open("POST", cmdline, true);
    xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("Esito="+esito);
	
}


function LoadPromozioni(sezione){
	var xmlHttp;
	var timeout = null;
    var IDCarrello=document.getElementById("IDCarrello").value;
    try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
    xmlHttp.onreadystatechange = function() {
      articoli = document.getElementById("Articoli")
	  intestazione = document.getElementById("Intestazione")
	  intestazione.innerHTML="<P><B>PROMOZIONE - " + sezione + "</B></P>";
	  if(xmlHttp.readyState == 4) {
        articoli.innerHTML = xmlHttp.responseText;
		clearTimeout(timeout);
      }
	  else{
		articoli.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			articoli.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 20*1000 );       
			     
		}
		
		
	  }
    }
	if (sezione == "a")	cmdline = "promozioneA.php" ;
	if (sezione == "b")	cmdline = "promozioneB.php" ;
	if (sezione == "c")	cmdline = "promozioneC.php" ;
	if (sezione == "d")	cmdline = "promozioneD.php" ;
	if (sezione == "e")	cmdline = "promozioneE.php" ;
	
	xmlHttp.open("POST", cmdline, true);
    xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("IDCarrello=" + IDCarrello);
	
}

function LoadDeleteNewsLetter(){
	var xmlHttp;
	var timeout = null;
	 var IDContatto = document.getElementById("IDCon").value;
	   if(IDContatto == ""){
	var mail = document.getElementById("news_email").value;
    var IDCarrello=document.getElementById("IDCarrello").value;
	   }
    try {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    } catch (e) {
      // Internet Explorer
      try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          alert("Your browser does not support AJAX!");
        }
      }
    }
    xmlHttp.onreadystatechange = function() {
      articoli = document.getElementById("Articoli")
	  intestazione = document.getElementById("Intestazione")
	  intestazione.innerHTML="<P><B>NEWSLETTER</B></P>";
	  if(xmlHttp.readyState == 4) {
        articoli.innerHTML = xmlHttp.responseText;
		clearTimeout(timeout);
      }
	  else{
		articoli.innerHTML ="<img src='Images/loader.gif'>";
	    if (timeout == null) {      
			function timeoutFunc() {         
			xmlHttp.abort();         
			articoli.innerHTML = "Timeout...";      
			} 
			
			timeout = setTimeout( timeoutFunc, 20*1000 );       
			     
		}
		
		
	  }
    }
	cmdline = "cancellanewsletter.php" ;
	xmlHttp.open("POST", cmdline, true);
    xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    if(IDContatto != ""){
    	xmlHttp.send("IDContatto=" + IDContatto);
    }else{
	xmlHttp.send("IDCarrello=" + IDCarrello + "&Email=" + mail);
    }
}

function svuota(valore){
	if ((document.getElementById(valore).value == 'email') || (document.getElementById(valore).value == 'password')) document.getElementById(valore).value = '';
		
}
