/*-----------------------------------------------*/
/*------------ CARRELLO DELLA SPESA -------------*/
/*-----------------------------------------------*/

function EvidenziaCarrello(elemento){

// EVIDENZIO IL DIV DEL CARRELLO DELLA SPESA

new Element.hide(elemento);
new Effect.Appear(elemento);

// -----------------------------------------

}

function ApriPopUpMessaggio(elemento,id_prodotto){

Messaggio = "";

//if (document.getElementById("qta_"+id_prodotto+"_agg").value > 1) {
//	Messaggio = Messaggio + "Sono stati aggiunti al carrello n° <strong>"+document.getElementById("qta_"+id_prodotto+"_agg").value+"</strong> articoli.<br>"
//}else{
	Messaggio = Messaggio + "<center>E' stata aggiunta una richiesta alla lista.</center>"
//}

//Messaggio = Messaggio + "Codice articolo aggiunto <strong>"+document.getElementById("cod_"+id_prodotto+"_agg").value+"</strong>"

document.getElementById(elemento).innerHTML = Messaggio;

// EVIDENZIO IL DIV DEL MESSAGGIO DEL CARRELLO DELLA SPESA
//new Effect.Appear(elemento);
document.getElementById(elemento).style.display = "block";
// -------------------------------------------------------
//setTimeout("new Effect.Fade("+elemento+");",5000);

	if ( document.getElementById(elemento) != null ) {
		setTimeout("document.getElementById('"+elemento+"').style.display = 'none';",3000);
	}

	if ( document.getElementById("qta_"+id_prodotto+"_agg") != null ) {
		setTimeout("document.getElementById('qta_"+id_prodotto+"_agg').value = '1';",3000);
	}

}

function GestioneCarrello(id_prodotto,azione){

createXMLHttpRequest();

//	if (document.getElementById("id_utente_accesso") != null){

//			if (document.getElementById("id_utente_accesso").value != ''){
								
											if (azione == 'aggiungi'){
																								
												quantita_selezionata_agg = document.getElementById("qta_"+id_prodotto+"_agg").value;
												id_misura_selezionata = document.getElementById("id_misura_"+id_prodotto).value;

												if (quantita_selezionata_agg == ''){
													alert("Inserire la quantita' !");
													document.getElementById("qta_"+id_prodotto+"_agg").focus();
													return false;
												}	
										
												if (!IsNumber(quantita_selezionata_agg)){
													alert("La quantita' non e' corretta!");
													document.getElementById("qta_"+id_prodotto+"_agg").focus();
													return false;
												}
							
												if (quantita_selezionata_agg < 0){
													alert("La quantita' deve essere maggiore di 0!");
													document.getElementById("qta_"+id_prodotto+"_agg").focus();
													return false;
												}


												// **************************************
												// ** PERSONALIZZAZIONE DEL 18/07/2007 **
												// **************************************
												
												if (document.getElementById("id_utente_accesso").value == ''){
													document.getElementById("DivInfoOpaco").style.display = 'block';
													document.getElementById("DivInfo").style.display = 'block';
												}else{
													
														
													xmlHttp.onreadystatechange = handleStateChangeCarrello;
													xmlHttp.open("GET", "carrello.asp?id_utente="+document.getElementById("id_utente_accesso").value+"&id_prodotto="+id_prodotto+"&quantita="+quantita_selezionata_agg+"&id_misura="+id_misura_selezionata+"&azione="+azione, true);
													xmlHttp.send(null);
													
												}
												
												// **************************************
												// **************************************
												// **************************************



											}
											
											
											if (azione == 'cancella'){
											
												quantita_selezionata_rem = document.getElementById("qta_"+id_prodotto+"_rem").value;
												id_misura_selezionata = document.getElementById("id_misura_"+id_prodotto).value;

												var agree=confirm('Eliminare la richiesta ?');
												
													if (agree == true){
										
														xmlHttp.onreadystatechange = handleStateChangeCarrello;
//														xmlHttp.open("GET", "carrello.asp?id_utente_carrello="+document.getElementById("id_utente_accesso").value+"&id_prodotto="+id_prodotto+"&quantita="+quantita_selezionata_rem+"&id_misura="+id_misura_selezionata+"&azione="+azione, true);
														xmlHttp.open("GET", "carrello.asp?id_utente="+document.getElementById("id_utente_accesso").value+"&id_prodotto="+id_prodotto+"&quantita="+quantita_selezionata_rem+"&id_misura="+id_misura_selezionata+"&azione="+azione, true);
														xmlHttp.send(null);
														
													}
											
											}
											
											if (azione == 'ricalcola'){
							
												quantita_selezionata_nuova = document.getElementById("qta_"+id_prodotto+"_nuova").value;
												id_misura_selezionata = document.getElementById("id_misura_"+id_prodotto).value;

												if ( document.getElementById("id_misura_"+id_prodotto+"_old") != null ) {
													id_misura_selezionata_vecchia = document.getElementById("id_misura_"+id_prodotto+"_old").value;
												}
							
													if (quantita_selezionata_nuova == ''){
														alert("Inserire la quantita' !");
														document.getElementById("qta_"+id_prodotto+"_nuova").focus();
														return false;
													}	
											
													if (!IsNumber(quantita_selezionata_nuova)){
														alert("La quantita' non e' corretta!");
														document.getElementById("qta_"+id_prodotto+"_nuova").focus();
														return false;
													}
							
													if (quantita_selezionata_nuova < 0){
														alert("La quantita' deve essere maggiore di 0!");
														document.getElementById("qta_"+id_prodotto+"_nuova").focus();
														return false;
													}

//													alert(id_misura_selezionata);							

														xmlHttp.onreadystatechange = handleStateChangeCarrello;
//														xmlHttp.open("GET", "carrello.asp?id_utente_carrello="+document.getElementById("id_utente_accesso").value+"&id_prodotto="+id_prodotto+"&quantita="+quantita_selezionata_nuova+"&id_misura_nuova="+id_misura_selezionata+"&id_misura_vecchia="+id_misura_selezionata_vecchia+"&azione="+azione, true);
														xmlHttp.open("GET", "carrello.asp?id_utente="+document.getElementById("id_utente_accesso").value+"&id_prodotto="+id_prodotto+"&quantita="+quantita_selezionata_nuova+"&id_misura_nuova="+id_misura_selezionata+"&id_misura_vecchia="+id_misura_selezionata_vecchia+"&azione="+azione, true);
														xmlHttp.send(null);
											
											}
											
											if (azione == 'svuota'){
												
												var agree=confirm('Attenzione, tutte le richieste avanzate andranno cancellate.\nEffettuare logout ?');

													if (agree == true){

															if ( document.getElementById("id_utente_accesso") != null ) {
																document.getElementById("id_utente_accesso").value = '';
															}
														
														xmlHttp.onreadystatechange = handleStateChangeCarrelloSvuota;
//														xmlHttp.open("GET", "carrello.asp?id_utente_carrello="+document.getElementById("id_utente_accesso").value+"&azione="+azione+"&logout=1", true);
														xmlHttp.open("GET", "carrello.asp?id_utente="+document.getElementById("id_utente_accesso").value+"&azione="+azione+"&logout=1", true);
														xmlHttp.send(null);

													}
											
											}
				
/*			}else{

					var ElementoNascosto = document.getElementById("Effettuare_Login_0");
					ElementoNascosto.style.display = "block";
					
					var ElementoNascosto = document.getElementById("Effettuare_Login");
					ElementoNascosto.style.display = "block";
	
					xmlHttp.onreadystatechange = handleStateChangeLogoutPopUp;
					xmlHttp.open("GET", "login2.asp"+UrlPagina, true);
					xmlHttp.send(null);
	
					if (document.getElementById("qta_"+id_prodotto+"_agg") !=null) {
						document.getElementById("qta_"+id_prodotto+"_agg").value = '';
					}

				}
				
	}else{

				var ElementoNascosto = document.getElementById("Effettuare_Login_0");
				ElementoNascosto.style.display = "block";
				
				var ElementoNascosto = document.getElementById("Effettuare_Login");
				ElementoNascosto.style.display = "block";

				xmlHttp.onreadystatechange = handleStateChangeLogoutPopUp;
				xmlHttp.open("GET", "login2.asp"+UrlPagina, true);
				xmlHttp.send(null);

				if (document.getElementById("qta_"+id_prodotto+"_agg") !=null) {
					document.getElementById("qta_"+id_prodotto+"_agg").value = '';
				}

	}*/
}


function Chiudi_Pop_Up(){
	var ElementoNascosto = document.getElementById("Effettuare_Login_0");
	ElementoNascosto.style.display = "none";
	
	var ElementoNascosto = document.getElementById("Effettuare_Login");
	ElementoNascosto.style.display = "none";
}

// CASO IN CUI IL CREDITO E' INSUFFICIENTE
function Conferma_Ordine_Frase(){

	alert("Impossibile proseguire !\nSaldo punti insufficiente.");

}

//CASO IN CUI SVUOTO IL CARRELLO SENZA EFFETTUARE IL LOGOUT
function Svuota_Carrello(){

createXMLHttpRequest();

var agree=confirm("Eliminare tutti gli articoli dal carrello ?");

	if (agree == true){
		xmlHttp.onreadystatechange = handleStateChangeCarrelloSvuota2;
		xmlHttp.open("GET", "carrello.asp?id_utente_carrello="+document.getElementById("id_utente_accesso").value+"&azione=svuota", true);
		xmlHttp.send(null);
		
	}
	
}

//VISUALIZZA CONTENUTO CARRELLO
function Visualizza_Carrello_Aggiornato(){

createXMLHttpRequest();

	xmlHttp.onreadystatechange = handleStateChangeCarrelloAggiornato;
	xmlHttp.open("GET", "carrello.asp?azione=svuota", true);
	xmlHttp.send(null);

}


//VISUALIZZA CONTENUTO CARRELLO PER UTENTE CHE ACQUISTA NON LOGGATO
function Visualizza_Carrello_Aggiornato_No_Loggato(){

createXMLHttpRequest();

	xmlHttp.onreadystatechange = handleStateChangeCarrelloAggiornato_No_Loggato;
	xmlHttp.open("GET", "carrello.asp?azione=svuota", true);
	xmlHttp.send(null);

}

//COMPLETA ORDINE
function Completa_Ordine(){

createXMLHttpRequest();

var agree=confirm("Procedere con l' ordine ?");

	if (agree == true){

		CaricaPaginaNoImage("id_pagina_riepilogo_ordine");

	}

}

// GESTIONE ORDINE
// 1° utente registrato
// 2° utente anonimo (salvo i dati dell'ordine nella testata e non in tabella utenti e destinazioni)
// 3° utente che si registra al termine dell' ordine

function Tipologia_Operazione_Ordine(UrlPagina){

createXMLHttpRequest();

var agree=confirm("Inviare la richiesta ?");

	if (agree == true){

		if (document.getElementById("id_utente_accesso") != null){
			
			if (document.getElementById("id_utente_accesso").value == ''){

				var	postData = ""
				postData = postData + "note_carrello="+document.getElementById("note_carrello").value;
				postData = postData + "&modalita_pagamento="+document.getElementById("modalita_pagamento").value;
							
				postData = postData.replace(/ /g,"%20");

				xmlHttp.open("POST", "carrello.asp"+UrlPagina, true);
				xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
				xmlHttp.setRequestHeader("Content-length", postData.length);
				xmlHttp.setRequestHeader("Connection", "close");
				xmlHttp.onreadystatechange = handleStateChangeOperazioneOrdine;
				xmlHttp.send(postData);
				
			}else{
				
				var	postData = "id_utente="+document.getElementById("id_utente_accesso").value;

				postData = postData.replace(/ /g,"%20");

				xmlHttp.open("POST", "ordini.asp"+UrlPagina, true);
				xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
				xmlHttp.setRequestHeader("Content-length", postData.length);
				xmlHttp.setRequestHeader("Connection", "close");
				xmlHttp.onreadystatechange = handleStateChangeCaricaOrdine;
				xmlHttp.send(postData);
				
			}

		}


	}

}



function handleStateChangeOperazioneOrdine(){

Messaggio = "";
Messaggio = Messaggio + "<table border='0' cellpadding='0' cellspacing='0' style='width:100%; FONT-SIZE: 11px;COLOR: #000000; FONT-FAMILY: Trebuchet MS, Verdana;'>"
Messaggio = Messaggio + "  <tr><td>"
Messaggio = Messaggio + "<center>Impossibile caricare la pagina richiesta ....</center>"
Messaggio = Messaggio + "  </td></tr>"
Messaggio = Messaggio + "</table>"

Caricamento = "";
Caricamento = Caricamento + "<table border='0' cellpadding='0' cellspacing='0' style='width:100%; FONT-SIZE: 11px;COLOR: #000000; FONT-FAMILY: Trebuchet MS, Verdana;'>"
Caricamento = Caricamento + "  <tr><td>"
Caricamento = Caricamento + "<center>loading ...</center>"
Caricamento = Caricamento + "  </td></tr>"
Caricamento = Caricamento + "</table>"


		// if xmlHttp shows "loaded"
		if (xmlHttp.readyState == 4){

			if (xmlHttp.status == 200){				

				document.getElementById("Contenuto_Pagina").innerHTML = xmlHttp.responseText;

				if (document.getElementById("Step")!=null){
					Visualizza_Carrello_Aggiornato_No_Loggato();
				}

			}else{	

				// INTERCETTO ERRORE E VISUALIZZO
				handleErrFullPage(xmlHttp.responseText);
				//-------------------------------
				
				document.getElementById("Contenuto_Pagina").innerHTML = Messaggio;
			}
		
		}else{
				document.getElementById("Contenuto_Pagina").innerHTML = Caricamento
		}

}

//CONCLUSIONE ORDINE
function Conferma_Ordine(UrlPagina){

createXMLHttpRequest();

var agree=confirm("Procedere con l' ordine ?");

	if (agree == true){

		if (document.getElementById("id_utente_accesso") != null){

			var	postData = ""
	
			xmlHttp.open("POST", "ordini.asp"+UrlPagina, true);
			xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			xmlHttp.setRequestHeader("Content-length", postData.length);
			xmlHttp.setRequestHeader("Connection", "close");
			xmlHttp.onreadystatechange = handleStateChangeCaricaOrdine;
			xmlHttp.send(postData);

		}


	}

}

function Ricarica(Elemento){
	alert(Elemento);	
}

function handleStateChangeCarrello(){

Messaggio = "";
Messaggio = Messaggio + "<table border='0' cellpadding='0' cellspacing='0' style='width:100%; FONT-SIZE: 11px;COLOR: #000000; FONT-FAMILY: Trebuchet MS, Verdana;'>"
Messaggio = Messaggio + "  <tr><td  style='padding-top:25px;'>"
Messaggio = Messaggio + "<center>Impossibile caricare lista prodotti ....</center>"
Messaggio = Messaggio + "  </td></tr>"
Messaggio = Messaggio + "</table>"

Caricamento = "";
Caricamento = Caricamento + "<table border='0' cellpadding='0' cellspacing='0' style='width:100%; FONT-SIZE: 11px;COLOR: #000000; FONT-FAMILY: Trebuchet MS, Verdana;'>"
Caricamento = Caricamento + "  <tr><td>"
Caricamento = Caricamento + "<center>loading products ...</center>"
Caricamento = Caricamento + "  </td></tr>"
Caricamento = Caricamento + "</table>"


		// if xmlHttp shows "loaded"
		if (xmlHttp.readyState == 4){

			if (xmlHttp.status == 200){				

				document.getElementById("Contenuto_Pagina").innerHTML = xmlHttp.responseText;


				//---------------------------------------------------------------
				// --- QUANDO FINISCO DI CARICARE IL MENU ALLORA CARICO LA PAGINA
				//---------------------------------------------------------------
				Id_Pagina = document.getElementById("id_pagina_riepilogo_ordine").value;
				Id_Pagina_2 = document.getElementById("id_pagina_controllo_2").value;
				Id_Pagina_3 = document.getElementById("id_pagina_controllo_3").value;
				Id_Pagina_4 = document.getElementById("id_pagina_controllo_4").value;
				Id_News = document.getElementById("id_news").value;
				Id_Categoria_News = document.getElementById("id_categoria_news").value;
				
				TitoloPaginaNew = document.getElementById("titolo_pagina_logout").value;
				Lang = document.getElementById("Lingua").value;

				var Id_Categoria = "";
				var Id_Categoria_2 = "";
				var Id_Categoria_3 = "";
				var Id_Categoria_4 = "";
				var Id_Prodotto = "";

				if (document.getElementById("id_categoria") !=null) {
					Id_Categoria = document.getElementById("id_categoria").value;
					Id_Categoria_2 = document.getElementById("id_categoria_2").value;
					Id_Categoria_3 = document.getElementById("id_categoria_3").value;
					Id_Categoria_4 = document.getElementById("id_categoria_4").value;
					Id_Prodotto = document.getElementById("id_prodotto").value;
				}

				UrlPagina = ""
				UrlPagina = UrlPagina + "?id_pagina="+Id_Pagina
				UrlPagina = UrlPagina + "&id_pagina_2="+Id_Pagina_2
				UrlPagina = UrlPagina + "&id_pagina_3="+Id_Pagina_3
				UrlPagina = UrlPagina + "&id_pagina_4="+Id_Pagina_4
				UrlPagina = UrlPagina + "&Lang="+Lang+"&id_email="+document.getElementById("id_email").value
				UrlPagina = UrlPagina + "&id_categoria="+Id_Categoria
				UrlPagina = UrlPagina + "&id_categoria_2="+Id_Categoria_2
				UrlPagina = UrlPagina + "&id_categoria_3="+Id_Categoria_3
				UrlPagina = UrlPagina + "&id_categoria_4="+Id_Categoria_4
				UrlPagina = UrlPagina + "&id_prodotto="+Id_Prodotto
				UrlPagina = UrlPagina + "&id_categoria_news="+Id_Categoria_News
				UrlPagina = UrlPagina + "&id_news="+Id_News


				if (document.getElementById("tabella_origine") !=null) {
					UrlPagina = UrlPagina + "&tabella_origine="+document.getElementById("tabella_origine").value
				}
	
				CaricaPaginaNoImageEvidenziaStep_3(
					  Id_Pagina,
					  Id_Pagina_2,
					  Id_Pagina_3,
					  Id_Pagina_4,
					  Lang,
					  UrlPagina,
					  Id_Categoria,
					  Id_Categoria_2,
					  Id_Categoria_3,
					  Id_Categoria_4,
					  Id_Prodotto,
					  TitoloPaginaNew,
					  Id_News,
					  Id_Categoria_News
				);
				
				//---------------------------------------------------------------
				//---------------------------------------------------------------
				//---------------------------------------------------------------
				
			}else{	

				// INTERCETTO ERRORE E VISUALIZZO
				handleErrFullPage(xmlHttp.responseText);
				//-------------------------------

				if (document.getElementById("Contenuto_Pagina") != null){
					document.getElementById("Contenuto_Pagina").innerHTML = Messaggio;
				}

			}
		
		}else{
			
				if (document.getElementById("Contenuto_Pagina") != null){
					document.getElementById("Contenuto_Pagina").innerHTML = Caricamento
				}
			
		}

}


function handleStateChangeCarrelloSvuota(){

Messaggio = "";
Messaggio = Messaggio + "<table border='0' cellpadding='0' cellspacing='0' style='width:100%; FONT-SIZE: 11px;COLOR: #000000; FONT-FAMILY: Trebuchet MS, Verdana;'>"
Messaggio = Messaggio + "  <tr><td  style='padding-top:25px;'>"
Messaggio = Messaggio + "<center>Impossibile caricare lista prodotti ....</center>"
Messaggio = Messaggio + "  </td></tr>"
Messaggio = Messaggio + "</table>"

Caricamento = "";
Caricamento = Caricamento + "<table border='0' cellpadding='0' cellspacing='0' style='width:100%; FONT-SIZE: 11px;COLOR: #000000; FONT-FAMILY: Trebuchet MS, Verdana;'>"
Caricamento = Caricamento + "  <tr><td>"
Caricamento = Caricamento + "<center>loading products ...</center>"
Caricamento = Caricamento + "  </td></tr>"
Caricamento = Caricamento + "</table>"


		// if xmlHttp shows "loaded"
		if (xmlHttp.readyState == 4){

			if (xmlHttp.status == 200){
				
				if (document.getElementById("Step_3_Sel") != null ) {
					document.getElementById("Step_3_Sel").innerHTML = xmlHttp.responseText;
				}
				
				Check_Logout();

			}else{	

				// INTERCETTO ERRORE E VISUALIZZO
				handleErrFullPage(xmlHttp.responseText);
				//-------------------------------
								
				if (document.getElementById("Step_3_Sel") != null ) {
					document.getElementById("Step_3_Sel").innerHTML = Messaggio;
				}
				
			}
		
		}else{
			
				if (document.getElementById("Step_3_Sel") != null ) {
					document.getElementById("Step_3_Sel").innerHTML = Caricamento;
				}
				
		}

}

function handleStateChangeCarrelloSvuota2(){

Messaggio = "";
Messaggio = Messaggio + "<table border='0' cellpadding='0' cellspacing='0' style='width:100%; FONT-SIZE: 11px;COLOR: #000000; FONT-FAMILY: Trebuchet MS, Verdana;'>"
Messaggio = Messaggio + "  <tr><td  style='padding-top:25px;'>"
Messaggio = Messaggio + "<center>Impossibile caricare lista prodotti ....</center>"
Messaggio = Messaggio + "  </td></tr>"
Messaggio = Messaggio + "</table>"

Caricamento = "";
Caricamento = Caricamento + "<table border='0' cellpadding='0' cellspacing='0' style='width:100%; FONT-SIZE: 11px;COLOR: #000000; FONT-FAMILY: Trebuchet MS, Verdana;'>"
Caricamento = Caricamento + "  <tr><td>"
Caricamento = Caricamento + "<center>loading products ...</center>"
Caricamento = Caricamento + "  </td></tr>"
Caricamento = Caricamento + "</table>"


		// if xmlHttp shows "loaded"
		if (xmlHttp.readyState == 4){

			if (xmlHttp.status == 200){
				
				document.getElementById("Step_3_Sel").innerHTML = xmlHttp.responseText;

					// CASO IN CUI SONO NELLA PAGINA DI RIEPILOGO DELL'ORDINE E CANCELLO UN ARTICOLO
					// RICARICO LA PAGINA STESSA CON LA QUANTITA DELLA RIGA AGGIORNATA
/*					if (document.getElementById("ControlloPaginaRiepilogo")!=null){
						CaricaPaginaNoImage("id_pagina_riepilogo_ordine");
					}*/


				//---------------------------------------------------------------
				// --- QUANDO FINISCO DI CARICARE IL MENU ALLORA CARICO LA PAGINA
				//---------------------------------------------------------------
				Id_Pagina = document.getElementById("id_pagina_riepilogo_ordine").value;
				Id_Pagina_2 = document.getElementById("id_pagina_controllo_2").value;
				Id_Pagina_3 = document.getElementById("id_pagina_controllo_3").value;
				Id_Pagina_4 = document.getElementById("id_pagina_controllo_4").value;
				Id_News = document.getElementById("id_news").value;
				Id_Categoria_News = document.getElementById("id_categoria_news").value;
				
				TitoloPaginaNew = document.getElementById("titolo_pagina_logout").value;
				Lang = document.getElementById("Lingua").value;

				var Id_Categoria = "";
				var Id_Categoria_2 = "";
				var Id_Categoria_3 = "";
				var Id_Categoria_4 = "";
				var Id_Prodotto = "";

				if (document.getElementById("id_categoria") !=null) {
					Id_Categoria = document.getElementById("id_categoria").value;
					Id_Categoria_2 = document.getElementById("id_categoria_2").value;
					Id_Categoria_3 = document.getElementById("id_categoria_3").value;
					Id_Categoria_4 = document.getElementById("id_categoria_4").value;
					Id_Prodotto = document.getElementById("id_prodotto").value;
				}

				UrlPagina = ""
				UrlPagina = UrlPagina + "?id_pagina="+Id_Pagina
				UrlPagina = UrlPagina + "&id_pagina_2="+Id_Pagina_2
				UrlPagina = UrlPagina + "&id_pagina_3="+Id_Pagina_3
				UrlPagina = UrlPagina + "&id_pagina_4="+Id_Pagina_4
				UrlPagina = UrlPagina + "&Lang="+Lang+"&id_email="+document.getElementById("id_email").value
				UrlPagina = UrlPagina + "&id_categoria="+Id_Categoria
				UrlPagina = UrlPagina + "&id_categoria_2="+Id_Categoria_2
				UrlPagina = UrlPagina + "&id_categoria_3="+Id_Categoria_3
				UrlPagina = UrlPagina + "&id_categoria_4="+Id_Categoria_4
				UrlPagina = UrlPagina + "&id_prodotto="+Id_Prodotto
				UrlPagina = UrlPagina + "&id_categoria_news="+Id_Categoria_News
				UrlPagina = UrlPagina + "&id_news="+Id_News


				if (document.getElementById("tabella_origine") !=null) {
					UrlPagina = UrlPagina + "&tabella_origine="+document.getElementById("tabella_origine").value
				}


//				alert(UrlPagina);

	
				CaricaPaginaNoImage(
					  Id_Pagina,
					  Id_Pagina_2,
					  Id_Pagina_3,
					  Id_Pagina_4,
					  Lang,
					  UrlPagina,
					  Id_Categoria,
					  Id_Categoria_2,
					  Id_Categoria_3,
					  Id_Categoria_4,
					  Id_Prodotto,
					  TitoloPaginaNew,
					  Id_News,
					  Id_Categoria_News
				);
				
				//---------------------------------------------------------------
				//---------------------------------------------------------------
				//---------------------------------------------------------------


			}else{	

				// INTERCETTO ERRORE E VISUALIZZO
				handleErrFullPage(xmlHttp.responseText);
				//-------------------------------
				
				document.getElementById("Step_3_Sel").innerHTML = Messaggio;
			}
		
		}else{

				document.getElementById("Step_3_Sel").innerHTML = Caricamento
				
		}

}

function handleStateChangeCarrelloAggiornato_No_Loggato(){

Messaggio = "";
Messaggio = Messaggio + "<table border='0' cellpadding='0' cellspacing='0' style='width:100%; FONT-SIZE: 11px;COLOR: #000000; FONT-FAMILY: Trebuchet MS, Verdana;'>"
Messaggio = Messaggio + "  <tr><td  style='padding-top:25px;'>"
Messaggio = Messaggio + "<center>Impossibile caricare lista prodotti ....</center>"
Messaggio = Messaggio + "  </td></tr>"
Messaggio = Messaggio + "</table>"

Caricamento = "";
Caricamento = Caricamento + "<table border='0' cellpadding='0' cellspacing='0' style='width:100%; FONT-SIZE: 11px;COLOR: #000000; FONT-FAMILY: Trebuchet MS, Verdana;'>"
Caricamento = Caricamento + "  <tr><td>"
Caricamento = Caricamento + "<center>loading products ...</center>"
Caricamento = Caricamento + "  </td></tr>"
Caricamento = Caricamento + "</table>"


		// if xmlHttp shows "loaded"
		if (xmlHttp.readyState == 4){

			if (xmlHttp.status == 200){
				
				document.getElementById("Step_3_Sel").innerHTML = xmlHttp.responseText;

				//---------------------------------------------------------------
				// --- QUANDO FINISCO DI CARICARE IL MENU ALLORA CARICO LA PAGINA
				//---------------------------------------------------------------
				Id_Pagina = document.getElementById("id_pagina_controllo").value;
				Id_Pagina_2 = document.getElementById("id_pagina_controllo_2").value;
				Id_Pagina_3 = document.getElementById("id_pagina_controllo_3").value;
				Id_Pagina_4 = document.getElementById("id_pagina_controllo_4").value;
				Id_News = document.getElementById("id_news").value;
				Id_Categoria_News = document.getElementById("id_categoria_news").value;
				
				TitoloPaginaNew = document.title;
				Lang = document.getElementById("Lingua").value;

				var Id_Categoria = "";
				var Id_Categoria_2 = "";
				var Id_Categoria_3 = "";
				var Id_Categoria_4 = "";
				var Id_Prodotto = "";

				if (document.getElementById("id_categoria") !=null) {
					Id_Categoria = document.getElementById("id_categoria").value;
					Id_Categoria_2 = document.getElementById("id_categoria_2").value;
					Id_Categoria_3 = document.getElementById("id_categoria_3").value;
					Id_Categoria_4 = document.getElementById("id_categoria_4").value;
					Id_Prodotto = document.getElementById("id_prodotto").value;
				}

				UrlPagina = ""
				UrlPagina = UrlPagina + "?id_pagina="+Id_Pagina
				UrlPagina = UrlPagina + "&id_pagina_2="+Id_Pagina_2
				UrlPagina = UrlPagina + "&id_pagina_3="+Id_Pagina_3
				UrlPagina = UrlPagina + "&id_pagina_4="+Id_Pagina_4
				UrlPagina = UrlPagina + "&Lang="+Lang+"&id_email="+document.getElementById("id_email").value
				UrlPagina = UrlPagina + "&id_categoria="+Id_Categoria
				UrlPagina = UrlPagina + "&id_categoria_2="+Id_Categoria_2
				UrlPagina = UrlPagina + "&id_categoria_3="+Id_Categoria_3
				UrlPagina = UrlPagina + "&id_categoria_4="+Id_Categoria_4
				UrlPagina = UrlPagina + "&id_prodotto="+Id_Prodotto
				UrlPagina = UrlPagina + "&id_categoria_news="+Id_Categoria_News
				UrlPagina = UrlPagina + "&id_news="+Id_News


				if (document.getElementById("tabella_origine") !=null) {
					UrlPagina = UrlPagina + "&tabella_origine="+document.getElementById("tabella_origine").value
				}
	
				CaricaMenu_2_NoImage_No_Pagina(
					  Id_Pagina,
					  Id_Pagina_2,
					  Id_Pagina_3,
					  Id_Pagina_4,
					  Lang,
					  UrlPagina,
					  Id_Categoria,
					  Id_Categoria_2,
					  Id_Categoria_3,
					  Id_Categoria_4,
					  Id_Prodotto,
					  TitoloPaginaNew,
					  Id_News,
					  Id_Categoria_News
				);

				
				//---------------------------------------------------------------
				//---------------------------------------------------------------
				//---------------------------------------------------------------

			}else{	

				// INTERCETTO ERRORE E VISUALIZZO
				handleErrFullPage(xmlHttp.responseText);
				//-------------------------------
				
				document.getElementById("Step_3_Sel").innerHTML = Messaggio;
			}
		
		}else{

				document.getElementById("Step_3_Sel").innerHTML = Caricamento
				
		}

}

function handleStateChangeCarrelloAggiornato(){

Messaggio = "";
Messaggio = Messaggio + "<table border='0' cellpadding='0' cellspacing='0' style='width:100%; FONT-SIZE: 11px;COLOR: #000000; FONT-FAMILY: Trebuchet MS, Verdana;'>"
Messaggio = Messaggio + "  <tr><td  style='padding-top:25px;'>"
Messaggio = Messaggio + "<center>Impossibile caricare lista prodotti ....</center>"
Messaggio = Messaggio + "  </td></tr>"
Messaggio = Messaggio + "</table>"

Caricamento = "";
Caricamento = Caricamento + "<table border='0' cellpadding='0' cellspacing='0' style='width:100%; FONT-SIZE: 11px;COLOR: #000000; FONT-FAMILY: Trebuchet MS, Verdana;'>"
Caricamento = Caricamento + "  <tr><td>"
Caricamento = Caricamento + "<center>loading products ...</center>"
Caricamento = Caricamento + "  </td></tr>"
Caricamento = Caricamento + "</table>"


		// if xmlHttp shows "loaded"
		if (xmlHttp.readyState == 4){

			if (xmlHttp.status == 200){
				
				document.getElementById("Contenuto_Pagina").innerHTML = xmlHttp.responseText;


				//---------------------------------------------------------------
				// --- QUANDO FINISCO DI CARICARE IL MENU ALLORA CARICO LA PAGINA
				//---------------------------------------------------------------
				Id_Pagina = document.getElementById("id_pagina_riepilogo_ordine").value;
				Id_Pagina_2 = document.getElementById("id_pagina_controllo_2").value;
				Id_Pagina_3 = document.getElementById("id_pagina_controllo_3").value;
				Id_Pagina_4 = document.getElementById("id_pagina_controllo_4").value;
				Id_News = document.getElementById("id_news").value;
				Id_Categoria_News = document.getElementById("id_categoria_news").value;
				
				TitoloPaginaNew = document.getElementById("titolo_pagina_logout").value;
				Lang = document.getElementById("Lingua").value;

				var Id_Categoria = "";
				var Id_Categoria_2 = "";
				var Id_Categoria_3 = "";
				var Id_Categoria_4 = "";
				var Id_Prodotto = "";

				if (document.getElementById("id_categoria") !=null) {
					Id_Categoria = document.getElementById("id_categoria").value;
					Id_Categoria_2 = document.getElementById("id_categoria_2").value;
					Id_Categoria_3 = document.getElementById("id_categoria_3").value;
					Id_Categoria_4 = document.getElementById("id_categoria_4").value;
					Id_Prodotto = document.getElementById("id_prodotto").value;
				}

				UrlPagina = ""
				UrlPagina = UrlPagina + "?id_pagina="+Id_Pagina
				UrlPagina = UrlPagina + "&id_pagina_2="+Id_Pagina_2
				UrlPagina = UrlPagina + "&id_pagina_3="+Id_Pagina_3
				UrlPagina = UrlPagina + "&id_pagina_4="+Id_Pagina_4
				UrlPagina = UrlPagina + "&Lang="+Lang+"&id_email="+document.getElementById("id_email").value
				UrlPagina = UrlPagina + "&id_categoria="+Id_Categoria
				UrlPagina = UrlPagina + "&id_categoria_2="+Id_Categoria_2
				UrlPagina = UrlPagina + "&id_categoria_3="+Id_Categoria_3
				UrlPagina = UrlPagina + "&id_categoria_4="+Id_Categoria_4
				UrlPagina = UrlPagina + "&id_prodotto="+Id_Prodotto
				UrlPagina = UrlPagina + "&id_categoria_news="+Id_Categoria_News
				UrlPagina = UrlPagina + "&id_news="+Id_News


				if (document.getElementById("tabella_origine") !=null) {
					UrlPagina = UrlPagina + "&tabella_origine="+document.getElementById("tabella_origine").value
				}


//				alert(UrlPagina);

	
				CaricaPaginaNoImageEvidenziaStep_3_Ordine_Concluso(
					  Id_Pagina,
					  Id_Pagina_2,
					  Id_Pagina_3,
					  Id_Pagina_4,
					  Lang,
					  UrlPagina,
					  Id_Categoria,
					  Id_Categoria_2,
					  Id_Categoria_3,
					  Id_Categoria_4,
					  Id_Prodotto,
					  TitoloPaginaNew,
					  Id_News,
					  Id_Categoria_News
				);
				
				//---------------------------------------------------------------
				//---------------------------------------------------------------
				//---------------------------------------------------------------
				
			}else{	

				// INTERCETTO ERRORE E VISUALIZZO
				handleErrFullPage(xmlHttp.responseText);
				//-------------------------------
				
				document.getElementById("Contenuto_Pagina").innerHTML = Messaggio;
			}
		
		}else{

				document.getElementById("Contenuto_Pagina").innerHTML = Caricamento
				
		}

}

function handleStateChangeCaricaOrdine(){

Messaggio = "";
Messaggio = Messaggio + "<table border='0' cellpadding='0' cellspacing='0' style='width:100%; FONT-SIZE: 11px;COLOR: #000000; FONT-FAMILY: Trebuchet MS, Verdana;'>"
Messaggio = Messaggio + "  <tr><td>"
Messaggio = Messaggio + "<center>Impossibile caricare la pagina richiesta ....</center>"
Messaggio = Messaggio + "  </td></tr>"
Messaggio = Messaggio + "</table>"

Caricamento = "";
Caricamento = Caricamento + "<table border='0' cellpadding='0' cellspacing='0' style='width:100%; FONT-SIZE: 11px;COLOR: #000000; FONT-FAMILY: Trebuchet MS, Verdana;'>"
Caricamento = Caricamento + "  <tr><td>"
Caricamento = Caricamento + "<center>loading ...</center>"
Caricamento = Caricamento + "  </td></tr>"
Caricamento = Caricamento + "</table>"


		// if xmlHttp shows "loaded"
		if (xmlHttp.readyState == 4){

			if (xmlHttp.status == 200){
				
				document.getElementById("Contenuto_Pagina").innerHTML = xmlHttp.responseText;

				//---------------------------------------------------------------
				// --- QUANDO FINISCO DI CARICARE IL MENU ALLORA CARICO LA PAGINA
				//---------------------------------------------------------------
				Id_Pagina = document.getElementById("id_pagina_riepilogo_ordine").value;
				Id_Pagina_2 = document.getElementById("id_pagina_controllo_2").value;
				Id_Pagina_3 = document.getElementById("id_pagina_controllo_3").value;
				Id_Pagina_4 = document.getElementById("id_pagina_controllo_4").value;
				Id_News = document.getElementById("id_news").value;
				Id_Categoria_News = document.getElementById("id_categoria_news").value;
				
				TitoloPaginaNew = document.getElementById("titolo_pagina_logout").value;
				Lang = document.getElementById("Lingua").value;

				var Id_Categoria = "";
				var Id_Categoria_2 = "";
				var Id_Categoria_3 = "";
				var Id_Categoria_4 = "";
				var Id_Prodotto = "";

				if (document.getElementById("id_categoria") !=null) {
					Id_Categoria = document.getElementById("id_categoria").value;
					Id_Categoria_2 = document.getElementById("id_categoria_2").value;
					Id_Categoria_3 = document.getElementById("id_categoria_3").value;
					Id_Categoria_4 = document.getElementById("id_categoria_4").value;
					Id_Prodotto = document.getElementById("id_prodotto").value;
				}

				UrlPagina = ""
				UrlPagina = UrlPagina + "?id_pagina="+Id_Pagina
				UrlPagina = UrlPagina + "&id_pagina_2="+Id_Pagina_2
				UrlPagina = UrlPagina + "&id_pagina_3="+Id_Pagina_3
				UrlPagina = UrlPagina + "&id_pagina_4="+Id_Pagina_4
				UrlPagina = UrlPagina + "&Lang="+Lang+"&id_email="+document.getElementById("id_email").value
				UrlPagina = UrlPagina + "&id_categoria="+Id_Categoria
				UrlPagina = UrlPagina + "&id_categoria_2="+Id_Categoria_2
				UrlPagina = UrlPagina + "&id_categoria_3="+Id_Categoria_3
				UrlPagina = UrlPagina + "&id_categoria_4="+Id_Categoria_4
				UrlPagina = UrlPagina + "&id_prodotto="+Id_Prodotto
				UrlPagina = UrlPagina + "&id_categoria_news="+Id_Categoria_News
				UrlPagina = UrlPagina + "&id_news="+Id_News


				if (document.getElementById("tabella_origine") !=null) {
					UrlPagina = UrlPagina + "&tabella_origine="+document.getElementById("tabella_origine").value
				}


//				alert(UrlPagina);

	
				CaricaPaginaNoImageEvidenziaStep_3_Ordine_Concluso(
					  Id_Pagina,
					  Id_Pagina_2,
					  Id_Pagina_3,
					  Id_Pagina_4,
					  Lang,
					  UrlPagina,
					  Id_Categoria,
					  Id_Categoria_2,
					  Id_Categoria_3,
					  Id_Categoria_4,
					  Id_Prodotto,
					  TitoloPaginaNew,
					  Id_News,
					  Id_Categoria_News
				);
				
				//---------------------------------------------------------------
				//---------------------------------------------------------------
				//---------------------------------------------------------------
				
				Visualizza_Carrello_Aggiornato();

			}else{	

				// INTERCETTO ERRORE E VISUALIZZO
				handleErrFullPage(xmlHttp.responseText);
				//-------------------------------
				
				document.getElementById("Contenuto_Pagina").innerHTML = Messaggio;
			}
		
		}else{
				document.getElementById("Contenuto_Pagina").innerHTML = Caricamento
		}

}

function handleStateChangeLogoutPopUp(){

Messaggio = "";
Messaggio = Messaggio + "<table border='0' cellpadding='0' cellspacing='0' style='width:100%; FONT-SIZE: 11px;COLOR: #000000; FONT-FAMILY: Trebuchet MS, Verdana;'>"
Messaggio = Messaggio + "  <tr><td>"
Messaggio = Messaggio + "<center>Impossibile caricare la pagina richiesta ....</center>"
Messaggio = Messaggio + "  </td></tr>"
Messaggio = Messaggio + "</table>"

Caricamento = "";
Caricamento = Caricamento + "<table border='0' cellpadding='0' cellspacing='0' style='margin-top:8px; width:100%; FONT-SIZE: 11px;COLOR: #000000; FONT-FAMILY: Trebuchet MS, Verdana;'>"
Caricamento = Caricamento + "  <tr><td>"
Caricamento = Caricamento + "<center>loading ...</center>"
Caricamento = Caricamento + "  </td></tr>"
Caricamento = Caricamento + "</table>"


		// if xmlHttp shows "loaded"
		if (xmlHttp.readyState == 4){

			if (xmlHttp.status == 200){				

				document.getElementById("Effettuare_Login").innerHTML = xmlHttp.responseText;

			}else{	

				// INTERCETTO ERRORE E VISUALIZZO
				handleErrFullPage(xmlHttp.responseText);
				//-------------------------------
				
				document.getElementById("Effettuare_Login").innerHTML = Messaggio;
			}
		
		}else{
				document.getElementById("Effettuare_Login").innerHTML = Caricamento
		}

}


function handleStateChangeNoImagePreventivi(){

Messaggio = "";
Messaggio = Messaggio + "<table border='0' cellpadding='0' cellspacing='0' style='width:100%; height:100%; FONT-SIZE: 11px;COLOR: #000000; FONT-FAMILY: Trebuchet MS, Verdana;'>"
Messaggio = Messaggio + "  <tr><td  style='padding-top:25px;'>"
Messaggio = Messaggio + "<center>Impossibile caricare la pagina richiesta ....</center>"
Messaggio = Messaggio + "  </td></tr>"
Messaggio = Messaggio + "</table>"


		// if xmlHttp shows "loaded"
		if (xmlHttp.readyState == 4){

			if (xmlHttp.status == 200){				
			
				document.getElementById("Contenuto_Pagina").innerHTML = xmlHttp.responseText;

					VisualizzaStep('Step_2_Sel');
					EvidenziaStep('Step_2');

			}else{	

				// INTERCETTO ERRORE E VISUALIZZO
				handleErrFullPage(xmlHttp.responseText);
				//-------------------------------
				
				document.getElementById("Contenuto_Pagina").innerHTML = Messaggio;
			}
		
		}else{
				document.getElementById("Contenuto_Pagina").innerHTML = Immagine_Preload;
		}

}
/*-----------------------------------------------*/
/*-----------------------------------------------*/
/*-----------------------------------------------*/

function IsNumber(num)
{
   var i = 0;
   var letter;

   while (i < num.length)
   {
      letter = num.charAt(i);

      if ((letter == '0') || (letter == '1') || (letter == '2') ||
          (letter == '3') || (letter == '4') || (letter == '5') ||
          (letter == '6') || (letter == '7') || (letter == '8') ||
          (letter == '9') || (letter == '+') || (letter == '.') ||
          (letter == '/') || (letter == ',') || (letter == ' '))
      {
         i++;
      }
      else
      {
         return false;
      }
   }

   return true;
}
