
/*-----------------------------------------------*/
/*------------ 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');
	}

}
/*-----------------------------------------------*/
/*-----------------------------------------------*/
/*-----------------------------------------------*/

/*-----------------------------------------------*/
/*------------ DETTAGLIO NEGOZIO ----------------*/
/*-----------------------------------------------*/

function DettaglioNegozio(UrlPagina){
		/* SCORRO FINO ALL'INIZIO DEL DOCUMENTO */
		window.scrollTo(0,0);
		createXMLHttpRequest();
			
		if (document.getElementById("PopUp_0")!=null){
			var ElementoImmagine = document.getElementById("PopUp_0");
			ElementoImmagine.style.display = "none";
			ElementoImmagine.style.display = "block";
			ElementoImmagine.focus();
		}

		if (document.getElementById("PopUp_1")!=null){

			var ElementoImmagine = document.getElementById("PopUp_1");
			ElementoImmagine.style.display = "none";
			ElementoImmagine.style.display = "block";
			ElementoImmagine.focus();
			
			xmlHttp.onreadystatechange = handleStateChangeDetNegozio;
			xmlHttp.open("GET", "negozio.asp"+UrlPagina, true);
			xmlHttp.send(null);
			
		}

}

function handleStateChangeDetNegozio(){

Messaggio = "";
Messaggio = Messaggio + ""

Caricamento = "";
Caricamento = Caricamento + ""

		if (xmlHttp.readyState==4){

			if (xmlHttp.status == 200){
				
				document.getElementById("PopUp_1").innerHTML = xmlHttp.responseText;
				
			}else{

				// INTERCETTO ERRORE E VISUALIZZO
				handleErrFullPage(xmlHttp.responseText);
				//-------------------------------
				
				document.getElementById("PopUp_1").innerHTML = Messaggio;
				
			}
		
		}else{
			document.getElementById("PopUp_1").innerHTML = Caricamento
		}


}

function ChiudiPopUp(){

		if (document.getElementById("PopUp_0")!=null){
			var ElementoImmagine = document.getElementById("PopUp_0");
			ElementoImmagine.style.display = "none";
		}

		if (document.getElementById("PopUp_1")!=null){
			var ElementoImmagine = document.getElementById("PopUp_1");
			ElementoImmagine.style.display = "none";
		}

}
/*-----------------------------------------------*/
/*-----------------------------------------------*/
/*-----------------------------------------------*/

/*-----------------------------------------------*/
/*--- 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);
		}

}

/*-----------------------------------------------*/
/*-----------------------------------------------*/
/*-----------------------------------------------*/
