/*-----------------------------------------------*/
/*------------ INIZIALIZZO OGGETTO --------------*/
/*-----------------------------------------------*/

var xmlHttp;

function createXMLHttpRequest(){

	if (window.XMLHttpRequest) {
	   xmlHttp = new XMLHttpRequest();
	} else if (window.ActiveXObject) { // IE
	   xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
	   alert('Impossibile continuare: il tuo browser non supporta XMLHttpRequest');
	}

}
/*-----------------------------------------------*/
/*-----------------------------------------------*/
/*-----------------------------------------------*/


/*-----------------------------------------------*/
/*------------ IMMAGINE PRELOAD -----------------*/
/*-----------------------------------------------*/

Immagine_Preload = ""
/*Immagine_Preload = Immagine_Preload + "<center><img style='"
Immagine_Preload = Immagine_Preload + "margin-top:15px;"
Immagine_Preload = Immagine_Preload + "'"
Immagine_Preload = Immagine_Preload + "src='ICONE/loading/2.gif'"
Immagine_Preload = Immagine_Preload + "></center>"*/
Immagine_Preload = Immagine_Preload + "<center><span style='FONT-SIZE: 9px;COLOR: #000000;	FONT-FAMILY: Trebuchet MS, Verdana ;'>loading ...</span></center>"

/*-----------------------------------------------*/
/*-----------------------------------------------*/
/*-----------------------------------------------*/




/*-----------------------------------------------*/
/*------------ CARICAMENTO MENU -----------------*/
/*-----------------------------------------------*/

function CaricaMenu(
					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
){

		createXMLHttpRequest();

		document.title = TitoloPaginaNew;

		document.getElementById("id_pagina_controllo").value = Id_Pagina;
		document.getElementById("id_pagina_controllo_2").value = Id_Pagina_2;
		document.getElementById("id_pagina_controllo_3").value = Id_Pagina_3;
		document.getElementById("id_pagina_controllo_4").value = Id_Pagina_4;

		var Id_Categoria = "";
		var Id_Categoria_2 = "";
		var Id_Categoria_3 = "";
		var Id_Categoria_4 = "";
		var Id_Prodotto = "";

		if (document.getElementById("id_categoria") !=null) {
			document.getElementById("id_categoria").value = Id_Categoria;
			document.getElementById("id_categoria_2").value = Id_Categoria_2;
			document.getElementById("id_categoria_3").value = Id_Categoria_3;
			document.getElementById("id_categoria_4").value = Id_Categoria_4;
			document.getElementById("id_prodotto").value = Id_Prodotto;
		}

		document.getElementById("id_news").value = Id_News;
		document.getElementById("id_categoria_news").value = Id_Categoria_News;
		
		document.getElementById("Lingua").value = Lang;
		
		xmlHttp.onreadystatechange = handleStateChangeMenu;
		xmlHttp.open("GET", "menu.asp"+UrlPagina, true);
		xmlHttp.send(null);
}

function handleStateChangeMenu(){

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 il menu di navigazione ....</center>"
Messaggio = Messaggio + "  </td></tr>"
Messaggio = Messaggio + "</table>"

		if (xmlHttp.readyState==4){

			if (xmlHttp.status == 200){
				document.getElementById("Menu_1").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
				}
	
				CaricaPagina(
					  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("Menu_1").innerHTML = Messaggio;
			}
		
		}else{
				
			document.getElementById("Menu_1").innerHTML = Immagine_Preload
			
		}


}
/*-----------------------------------------------*/
/*-----------------------------------------------*/
/*-----------------------------------------------*/





/*----------------------------------------------------------------------*/
/*------------ CARICAMENTO MENU PER CAMBIAMENTO LINGUA -----------------*/
/*----------------------------------------------------------------------*/

function CaricaMenuCambioLingua(
					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
){

		createXMLHttpRequest();

		document.title = TitoloPaginaNew;
		
		document.getElementById("id_pagina_controllo").value = Id_Pagina;
		document.getElementById("id_pagina_controllo_2").value = Id_Pagina_2;
		document.getElementById("id_pagina_controllo_3").value = Id_Pagina_3;
		document.getElementById("id_pagina_controllo_4").value = Id_Pagina_4;

		document.getElementById("id_news").value = Id_News;
		document.getElementById("id_categoria_news").value = Id_Categoria_News;
		
		document.getElementById("Lingua").value = Lang;
		
		xmlHttp.onreadystatechange = handleStateChangeMenuCambioLingua;
		xmlHttp.open("GET", "menu.asp"+UrlPagina, true);
		xmlHttp.send(null);
}

function handleStateChangeMenuCambioLingua(){

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 il menu di navigazione ....</center>"
Messaggio = Messaggio + "  </td></tr>"
Messaggio = Messaggio + "</table>"

		if (xmlHttp.readyState==4){

			if (xmlHttp.status == 200){
				document.getElementById("Menu_1").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
				}
				
				CaricaPagina(
					  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("Menu_1").innerHTML = Messaggio;
			}
		
		}else{
			
			document.getElementById("Menu_1").innerHTML = Immagine_Preload

		}


}
/*-----------------------------------------------*/
/*-----------------------------------------------*/
/*-----------------------------------------------*/




/*-----------------------------------------------*/
/*------------ CARICAMENTO PAGINA ---------------*/
/*-----------------------------------------------*/

function CaricaPagina(
					  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
					  ){

	createXMLHttpRequest();

//	alert(Id_News + " - " + Id_Categoria_News);

	document.title = TitoloPaginaNew;
	document.getElementById("id_pagina_controllo").value = Id_Pagina;
	document.getElementById("id_pagina_controllo_2").value = Id_Pagina_2;
	document.getElementById("id_pagina_controllo_3").value = Id_Pagina_3;
	document.getElementById("id_pagina_controllo_4").value = Id_Pagina_4;

	document.getElementById("id_news").value = Id_News;
	document.getElementById("id_categoria_news").value = Id_Categoria_News;


	document.getElementById("Lingua").value = Lang;

	xmlHttp.onreadystatechange = handleStateChange;
	xmlHttp.open("GET", "content.asp"+UrlPagina, true);
	xmlHttp.send(null);

}

function handleStateChange(){

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;

				//---------------------------------------------------------------
				// --- QUANDO FINISCO DI CARICARE LA PAGINA ALLORA CARICO LE FOTO
				//---------------------------------------------------------------

					if (document.getElementById("Immagini_Pagina_Ajax") != null){
						
						var Id_Immagine_Ajax;
						
						Larghezza = document.getElementById("larghezza_immagine").value;
						Altezza = document.getElementById("altezza_immagine").value;

						if (document.getElementById("id_pagina_controllo").value != '') {
							Id_Padre = document.getElementById("id_pagina_controllo").value;
							Tabella_Padre = "Pagine";
						}

						if (document.getElementById("id_pagina_controllo_2").value != '') {
							Id_Padre = document.getElementById("id_pagina_controllo_2").value;
							Tabella_Padre = "Pagine_2";
						}

						if (document.getElementById("id_pagina_controllo_3").value != '') {
							Id_Padre = document.getElementById("id_pagina_controllo_3").value;
							Tabella_Padre = "Pagine_2";
						}

						if (document.getElementById("id_pagina_controllo_4").value != '') {
							Id_Padre = document.getElementById("id_pagina_controllo_4").value;
							Tabella_Padre = "Pagine_2";
						}
												
						Tipo_File_Ajax = document.getElementById("tipo_file_ajax").value;
						
						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;

						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
		
						TitoloPaginaNew = document.title;
						Lang = document.getElementById("Lingua").value;

				//------------------------------------------------------------------------------------------
				// --- QUANDO FINISCO DI CARICARE IL MENU ALLORA CARICO IL BOX IN ALTO A DX DELLE NEWSLETTER
				//------------------------------------------------------------------------------------------

				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;
				}

						CaricaIscrizioneNewsletter(
							  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
						);

				//------------------------------------------------------------------------------------------
				//------------------------------------------------------------------------------------------
				//------------------------------------------------------------------------------------------

						CaricaImmagini(
									Id_Pagina,
									Id_Pagina_2,
									Id_Pagina_3,
									Id_Pagina_4,
									Lang,
									UrlPagina,
									TitoloPaginaNew,
									Larghezza,
									Altezza,
									Tipo_File_Ajax,
									Tabella_Padre,
									Id_Padre,
									Id_Immagine_Ajax
									);
					}
				//---------------------------------------------------------------
				//---------------------------------------------------------------
				//---------------------------------------------------------------


			}else{	

				// INTERCETTO ERRORE E VISUALIZZO
				handleErrFullPage(xmlHttp.responseText);
				//-------------------------------
				
				document.getElementById("Contenuto_Pagina").innerHTML = Messaggio;
			}
		
		}else{
				document.getElementById("Contenuto_Pagina").innerHTML = Immagine_Preload
		}

}

/*-----------------------------------------------*/
/*-----------------------------------------------*/
/*-----------------------------------------------*/



/*-------------------------------------------------------------------*/
/*------------ CARICAMENTO BOX ISCRIZIONE NEWSLETTER ----------------*/
/*-------------------------------------------------------------------*/

function CaricaIscrizioneNewsletter(
					  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
					  ){

	createXMLHttpRequest();

	document.title = TitoloPaginaNew;
	document.getElementById("id_pagina_controllo").value = Id_Pagina;
	document.getElementById("id_pagina_controllo_2").value = Id_Pagina_2;
	document.getElementById("id_pagina_controllo_3").value = Id_Pagina_3;
	document.getElementById("id_pagina_controllo_4").value = Id_Pagina_4;

	document.getElementById("id_news").value = Id_News;
	document.getElementById("id_categoria_news").value = Id_Categoria_News;


	document.getElementById("Lingua").value = Lang;

	xmlHttp.onreadystatechange = handleStateChangeBoxNewsletter;
	xmlHttp.open("GET", "top_newsletter.asp"+UrlPagina, true);
	xmlHttp.send(null);

}

function handleStateChangeBoxNewsletter(){

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("Top_Newsletter").innerHTML = xmlHttp.responseText;

			}else{	

				// INTERCETTO ERRORE E VISUALIZZO
				handleErrFullPage(xmlHttp.responseText);
				//-------------------------------
				
				document.getElementById("Top_Newsletter").innerHTML = Messaggio;
			}
		
		}else{
				document.getElementById("Top_Newsletter").innerHTML = Immagine_Preload
		}

}
/*-----------------------------------------------*/
/*-----------------------------------------------*/
/*-----------------------------------------------*/


/*--------------------------------------------------------------*/
/*------------ CARICAMENTO PAGINA SENZA IMMAGINI ---------------*/
/*--------------------------------------------------------------*/

function 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
					  ){

	createXMLHttpRequest();

//alert(UrlPagina);

	document.title = TitoloPaginaNew;
	document.getElementById("id_pagina_controllo").value = Id_Pagina;
	document.getElementById("id_pagina_controllo_2").value = Id_Pagina_2;
	document.getElementById("id_pagina_controllo_3").value = Id_Pagina_3;
	document.getElementById("id_pagina_controllo_4").value = Id_Pagina_4;

	document.getElementById("id_news").value = Id_News;
	document.getElementById("id_categoria_news").value = Id_Categoria_News;


	document.getElementById("Lingua").value = Lang;

	xmlHttp.onreadystatechange = handleStateChangeNoImage;
	xmlHttp.open("GET", "content.asp"+UrlPagina, true);
	xmlHttp.send(null);

}

function handleStateChangeNoImage(){

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;

			}else{	

				// INTERCETTO ERRORE E VISUALIZZO
				handleErrFullPage(xmlHttp.responseText);
				//-------------------------------
				
				document.getElementById("Contenuto_Pagina").innerHTML = Messaggio;
			}
		
		}else{
				document.getElementById("Contenuto_Pagina").innerHTML = Immagine_Preload
		}

}

/*-----------------------------------------------*/
/*-----------------------------------------------*/
/*-----------------------------------------------*/









/*--------------------------------------------------------*/
/*------------ CARICAMENTO IMMAGINI PAGINA ---------------*/
/*--------------------------------------------------------*/

function CaricaImmagini(
						Id_Pagina,
						Id_Pagina_2,
						Id_Pagina_3,
						Id_Pagina_4,
						Lang,
						UrlPagina,
						TitoloPaginaNew,
						Larghezza,
						Altezza,
						Tipo_File_Ajax,
						Tabella_Padre,
						Id_Padre,
						Id_Immagine_Ajax
						){

if (Larghezza==''){
	Larghezza = document.getElementById("larghezza_immagine").value;
}

if (Altezza==''){
	Altezza = document.getElementById("altezza_immagine").value;
}


		Immagine = "";
		Immagine = Immagine + "<iframe "
		Immagine = Immagine + "src='immagini.asp?id_padre="+Id_Padre+"&Tabella_Padre="+Tabella_Padre+"&Larghezza="+Larghezza+"&Altezza="+Altezza+"&Tipo_File_Ajax="+Tipo_File_Ajax+"&Id_Immagine_Ajax="+Id_Immagine_Ajax+"' "
		Immagine = Immagine + "width='"+Larghezza+"' Height='"+Altezza+"' "
		Immagine = Immagine + "scrolling='no' frameborder='0'>"
		Immagine = Immagine + "</iframe>"
	
		document.getElementById("Immagini_Pagina_Ajax").innerHTML = Immagine

}

/*-----------------------------------------------*/
/*-----------------------------------------------*/
/*-----------------------------------------------*/

/*-----------------------------------------------*/
/*------------ MOTORE DI RICERCA ----------------*/
/*-----------------------------------------------*/

function Cerca(UrlPagina){

if (document.getElementById("cerca").value == ''   ){
	alert("Inserire chiave di ricerca !");
	document.getElementById("cerca").focus();
	return false;
}

	var postData = "cerca="+document.getElementById("cerca").value;	
	postData = postData.replace(/ /g,"%20");

	document.getElementById("cerca").value = "";

	xmlHttp.open("POST", "content.asp"+UrlPagina, true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", postData.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.onreadystatechange = handleStateChange;
	xmlHttp.send(postData);

}

/*-----------------------------------------------*/
/*-----------------------------------------------*/
/*-----------------------------------------------*/

/*--------------------------------------------------------*/
/*------------ CARICAMENTO IMMAGINI PAGINA ---------------*/
/*--------------------------------------------------------*/

function CambiaImmagine(
						Elemento,
						Immagine_New,
						Id_Immagine
						){

document.getElementById(Elemento).src = Immagine_New;

	Div_Zoom = ""
	Div_Zoom = Div_Zoom + "<img "
	Div_Zoom = Div_Zoom + "style=cursor:pointer;margin-top:10px;margin-right:10px; "
	Div_Zoom = Div_Zoom + "src=BANNER/zoom.jpg "
	Div_Zoom = Div_Zoom + " onClick=\""
	Div_Zoom = Div_Zoom + "document.getElementById(\'Foto_"+Id_Immagine+"\').style.display = \'block\'"
	Div_Zoom = Div_Zoom + " \">"

document.getElementById("Zoom_Immagine_Photogallery").innerHTML = Div_Zoom
}

/*-----------------------------------------------*/
/*-----------------------------------------------*/
/*-----------------------------------------------*/

/*-----------------------------------------------*/
/*------------ SELEZIONE LINGUA -----------------*/
/*-----------------------------------------------*/

function Seleziona_Lingua(Lingua) {

	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_Categoria_News = document.getElementById("id_pagina_controllo_3").value;
	Id_News = document.getElementById("id_pagina_controllo_4").value;

	UrlPagina = "?id_pagina="+document.getElementById("id_pagina_controllo").value+"&Lang="+Lingua
	UrlPagina = UrlPagina + "&id_pagina_2="+document.getElementById("id_pagina_controllo_2").value
	UrlPagina = UrlPagina + "&id_pagina_3="+document.getElementById("id_pagina_controllo_3").value
	UrlPagina = UrlPagina + "&id_pagina_4="+document.getElementById("id_pagina_controllo_4").value
	UrlPagina = UrlPagina + "&id_categoria="+document.getElementById("id_categoria").value
	UrlPagina = UrlPagina + "&id_categoria_2="+document.getElementById("id_categoria_2").value
	UrlPagina = UrlPagina + "&id_categoria_3="+document.getElementById("id_categoria_3").value
	UrlPagina = UrlPagina + "&id_categoria_4="+document.getElementById("id_categoria_4").value
	UrlPagina = UrlPagina + "&id_prodotto="+document.getElementById("id_prodotto").value
	UrlPagina = UrlPagina + "&id_categoria_news="+document.getElementById("id_categoria_news").value
	UrlPagina = UrlPagina + "&id_news="+document.getElementById("id_news").value

	TitoloPaginaNew = document.title;

	document.title = TitoloPaginaNew;
	document.getElementById("id_pagina_controllo").value = Id_Pagina;
	document.getElementById("Lingua").value = Lingua;

	CaricaMenuCambioLingua(
	Id_Pagina,
	Id_Pagina_2,
	Id_Pagina_3,
	Id_Pagina_4,
	Lingua,
	UrlPagina,
	document.getElementById("id_categoria").value,
	document.getElementById("id_categoria_2").value,
	document.getElementById("id_categoria_3").value,
	document.getElementById("id_categoria_4").value,
	document.getElementById("id_prodotto").value,
	TitoloPaginaNew,
	Id_News,
	Id_Categoria_News
	);


} 

/*-----------------------------------------------*/
/*-----------------------------------------------*/




/*-----------------------------------------------*/
/*------------ ISCRIZIONE NEWSLETTER ------------*/
/*-----------------------------------------------*/

function Check_Iscrivi_Newsletter(UrlPagina){

f = document.forms.form4;
b = document.form4;

if (f.email.value == ''   ){
	alert("Inserire indirizzo email !");
	f.email.focus();
	return false;
}

		if (f.email.value != ''   ){		   
			   var i=new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
			   if(!i.test(f.email.value)) {
			   alert("L'indirizzo email inserito non e' valido !");
			   f.email.focus();
			   return false;
			}
		}

	if (document.getElementById("radiobutton_iscriviti").checked == true){
		radiobutton = 'iscriviti';
	}else{
		radiobutton = 'cancellati';
	}

//------------------------------------------------
//------------------------------------------------
//------------------------------------------------

if (document.getElementById("lista_email")!=null){
	
	// CONTROLLO SE LA LOGIN SELEZIONATA ESISTE GIA'
	d = document.getElementById("lista_email").value.split(",");

	var agree_email=false;
	var j;
	for(j=-1;j<d.length-1;j++){
		if (d[j]==document.getElementById("email").value){
			agree_email=true;
		}
	}

}

//------------------------------------------------
//------------------------------------------------
//------------------------------------------------

	var postData = ""
	postData = postData + "nome="+document.getElementById("nome").value
	postData = postData +"&cognome="+document.getElementById("cognome").value
	postData = postData +"&email="+document.getElementById("email").value
	postData = postData +"&id_categoria="+document.getElementById("id_categoria_email").value
	postData = postData +"&radiobutton="+radiobutton

	postData = postData.replace(/ /g,"%20");
	
	if (radiobutton=='iscriviti') {
	
			if (agree_email==true) {
				alert("Indirizzo email inserito gia' presente !");
				document.getElementById("email").value="";
				document.getElementById("email").focus();
			}else{
				xmlHttp.open("POST", "content.asp"+UrlPagina, true);
				xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
				xmlHttp.setRequestHeader("Content-length", postData.length);
				xmlHttp.setRequestHeader("Connection", "close");
				xmlHttp.onreadystatechange = handleStateChange;
				xmlHttp.send(postData);
			}
	
	}
	
	
	
	
	
	
	if (radiobutton=='cancellati') {
	
			if (agree_email==false) {
				alert("Indirizzo email non presente nella mailling list !");
				document.getElementById("email").value="";
				document.getElementById("email").focus();
			}else{
				xmlHttp.open("POST", "content.asp"+UrlPagina, true);
				xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
				xmlHttp.setRequestHeader("Content-length", postData.length);
				xmlHttp.setRequestHeader("Connection", "close");
				xmlHttp.onreadystatechange = handleStateChange;
				xmlHttp.send(postData);
			}
	
	}
	
}

/*-----------------------------------------------*/
/*-----------------------------------------------*/
/*-----------------------------------------------*/


/*-----------------------------------------------*/
/*------------ ISCRIZIONE NEWSLETTER ------------*/
/*-----------------------------------------------*/

function Check_Richiesta(UrlPagina){

f = document.forms.form44;
b = document.form44;

if (f.nome.value == ''   ){
	alert("Inserire il nome !");
	f.nome.focus();
	return false;
}

if (f.cognome.value == ''   ){
	alert("Inserire il cognome !");
	f.cognome.focus();
	return false;
}

if (f.email.value == ''   ){
	alert("Inserire indirizzo email !");
	f.email.focus();
	return false;
}

		if (f.email.value != ''   ){		   
			   var i=new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
			   if(!i.test(f.email.value)) {
			   alert("L'indirizzo email inserito non e' valido !");
			   f.email.focus();
			   return false;
			}
		}

if (f.data_arrivo.value == ''   ){
	alert("Inserire la data di arrivo !");
	f.data_arrivo.focus();
	return false;
}

if (f.data_partenza.value == ''   ){
	alert("Inserire la data di partenza !");
	f.data_partenza.focus();
	return false;
}

	postData = "data_richiesta="+document.getElementById("data_richiesta").value
	postData = postData + "&nome="+document.getElementById("nome").value
	postData = postData + "&cognome="+document.getElementById("cognome").value
	postData = postData + "&email="+document.getElementById("email").value
	postData = postData + "&telefono="+document.getElementById("telefono").value
	postData = postData + "&struttura="+document.getElementById("struttura").value
	postData = postData + "&data_arrivo="+document.getElementById("data_arrivo").value
	postData = postData + "&data_partenza="+document.getElementById("data_partenza").value
	postData = postData + "&struttura="+document.getElementById("struttura").value
	postData = postData + "&richiesta="+document.getElementById("richiesta").value

	postData = postData.replace(/ /g,"%20");

	xmlHttp.open("POST", "content.asp"+UrlPagina, true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", postData.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.onreadystatechange = handleStateChange;
	xmlHttp.send(postData);

}

/*-----------------------------------------------*/
/*-----------------------------------------------*/
/*-----------------------------------------------*/


/*-----------------------------------------------*/
/*------------ CHECK GUESTBOOK ------------------*/
/*-----------------------------------------------*/

function Check_Guestbook(UrlPagina){

f = document.forms.form4;
b = document.form4;

if (f.email.value == ''   ){
	alert("Inserire indirizzo email !");
	f.email.focus();
	return false;
}

		if (f.email.value != ''   ){		   
			   var i=new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
			   if(!i.test(f.email.value)) {
			   alert("L'indirizzo email inserito non e' valido !");
			   f.email.focus();
			   return false;
			}
		}

if (f.nome.value == ''   ){
	alert("Inserire il nome !");
	f.nome.focus();
	return false;
}

if (f.cognome.value == ''   ){
	alert("Inserire il cognome !");
	f.cognome.focus();
	return false;
}

if (f.messaggio.value == ''   ){
	alert("Inserire il messaggio !");
	f.messaggio.focus();
	return false;
}

	var postData = "nome="+document.getElementById("nome").value+"&cognome="+document.getElementById("cognome").value+"&email="+document.getElementById("email").value+"&messaggio="+document.getElementById("messaggio").value+"&conferma=1"

	postData = "nome="+document.getElementById("nome").value
	postData = postData +"&cognome="+document.getElementById("cognome").value
	postData = postData +"&email="+document.getElementById("email").value
	postData = postData +"&messaggio="+document.getElementById("messaggio").value
	postData = postData +"&conferma=1"
	postData = postData.replace(/ /g,"%20");

	xmlHttp.open("POST", "content.asp"+UrlPagina, true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", postData.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.onreadystatechange = handleStateChange;
	xmlHttp.send(postData);

}

/*-----------------------------------------------*/
/*-----------------------------------------------*/
/*-----------------------------------------------*/









/*-----------------------------------------------*/
/*---- CONTROLLO MODULO SEMPLIFICATO ------------*/
/*-----------------------------------------------*/

function Check_Send_Modulo_1(UrlPagina){

f = document.forms.form4;
b = document.form4;

if (f.nome.value == ''   ){
	alert("Inserire il nome !");
	f.nome.focus();
	return false;
}

if (f.cognome.value == ''   ){
	alert("Inserire il cognome !");
	f.cognome.focus();
	return false;
}

if (f.email.value == ''   ){
	alert("Inserire indirizzo email !");
	f.email.focus();
	return false;
}

		if (f.email.value != ''   ){		   
			   var i=new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
			   if(!i.test(f.email.value)) {
			   alert("L'indirizzo email inserito non e' valido !");
			   f.email.focus();
			   return false;
			}
		}


	postData = "data="+document.getElementById("data").value
	postData = postData + "&nome="+document.getElementById("nome").value
	postData = postData + "&cognome="+document.getElementById("cognome").value
	postData = postData + "&societa="+document.getElementById("societa").value
	postData = postData + "&ruolo="+document.getElementById("ruolo").value
	postData = postData + "&telefono="+document.getElementById("telefono").value
	postData = postData + "&fax="+document.getElementById("fax").value
	postData = postData + "&email="+document.getElementById("email").value
	postData = postData + "&richiesta="+document.getElementById("richiesta").value
	postData = postData.replace(/ /g,"%20");

	xmlHttp.open("POST", "content.asp"+UrlPagina, true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", postData.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.onreadystatechange = handleStateChange;
	xmlHttp.send(postData);

}

/*-----------------------------------------------*/
/*-----------------------------------------------*/
/*-----------------------------------------------*/







/*-----------------------------------------------*/
/*- CONTROLLO MODULO SEMPLIFICATO COMPLESSO -----*/
/*-----------------------------------------------*/

function Check_Send_Modulo_2(UrlPagina){

f = document.forms.form4;
b = document.form4;

if (f.nome.value == ''   ){
	alert("Inserire il nome !");
	f.nome.focus();
	return false;
}

if (f.cognome.value == ''   ){
	alert("Inserire il cognome !");
	f.cognome.focus();
	return false;
}

if (f.email.value == ''   ){
	alert("Inserire indirizzo email !");
	f.email.focus();
	return false;
}

		if (f.email.value != ''   ){		   
			   var i=new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
			   if(!i.test(f.email.value)) {
			   alert("L'indirizzo email inserito non e' valido !");
			   f.email.focus();
			   return false;
			}
		}

	postData = "data="+document.getElementById("data").value
	postData = postData + "&nome="+document.getElementById("nome").value
	postData = postData + "&cognome="+document.getElementById("cognome").value
	postData = postData + "&societa="+document.getElementById("societa").value
	postData = postData + "&indirizzo="+document.getElementById("indirizzo").value
	postData = postData + "&citta="+document.getElementById("citta").value
	postData = postData + "&cap="+document.getElementById("cap").value
	postData = postData + "&provincia="+document.getElementById("provincia").value
	postData = postData + "&nazione="+document.getElementById("nazione").value
	postData = postData + "&telefono="+document.getElementById("telefono").value
	postData = postData + "&fax="+document.getElementById("fax").value
	postData = postData + "&email="+document.getElementById("email").value
	postData = postData + "&richiesta="+document.getElementById("richiesta").value
	postData = postData.replace(/ /g,"%20");

	xmlHttp.open("POST", "content.asp"+UrlPagina, true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", postData.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.onreadystatechange = handleStateChange;
	xmlHttp.send(postData);

}

/*-----------------------------------------------*/
/*-----------------------------------------------*/
/*-----------------------------------------------*/




/*-----------------------------------------------*/
/*---- CAMBIO ETICHETTA MOTORE DI RICERCA -------*/
/*-----------------------------------------------*/

function Cambia_Etichetta(Lingua) {

switch (Lingua) 

		{ 

			case "_1" : 
			document.getElementById("Etichetta_Cerca").innerHTML = "<strong>CERCA DOCUMENTO</strong>" 
			break; 
	
			case "_2" : 
			document.getElementById("Etichetta_Cerca").innerHTML = "<strong>SEARCH DOCUMENT</strong>" 
			break; 
	
			case "_3" :
			document.getElementById("Etichetta_Cerca").innerHTML = "<strong>RECHERCHE DOCUMENT</strong>"
			break; 

		}
}

/*-----------------------------------------------*/
/*-----------------------------------------------*/
/*-----------------------------------------------*/



/*-----------------------------------------------*/
/*--- GESTIONE E VISUALIZZAZIONE ERRORI ---------*/
/*-----------------------------------------------*/

function handleErrFullPage(strIn) {	

        var errorWin;

        // Create new window and display error
        try {
			errorWin = window.open('', 'errorWin');
			errorWin.document.body.innerHTML = strIn;
        }
        // If pop-up gets blocked, inform user
        catch(e) {
			alert(strIn);
		}

}

/*-----------------------------------------------*/
/*-----------------------------------------------*/
/*-----------------------------------------------*/
