/*-----------------------------------------------*/
/*------------ 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 src='ICONE/loading/5.gif' style='vertical-align:middle;'></center>"

/*-----------------------------------------------*/
/*-----------------------------------------------*/
/*-----------------------------------------------*/


/*-----------------------------------------------*/
/*------------ ZOOM IMMAGINE --------------------*/
/*-----------------------------------------------*/

function Zoom(
				id_immagine,
				larghezza,
				altezza
){

		createXMLHttpRequest();

		if (document.getElementById("Zoom")!=null){
			
			var ElementoImmagine = document.getElementById("Zoom");
			ElementoImmagine.style.display = "none";
			ElementoImmagine.style.display = "block";
			
			ElementoImmagine.style.width = larghezza+"px";
			
			ElementoImmagine.style.height = parseInt(parseInt(altezza)+ 23)+"px";

			ElementoImmagine.style.marginTop = -(parseInt(altezza/2))+"px";
			ElementoImmagine.style.marginLeft = -(parseInt(larghezza/2))+"px";

			ElementoImmagine.style.left = "50%";
			ElementoImmagine.style.top = "50%";

			
		}

		UrlImmagine = ""
		UrlImmagine = UrlImmagine + "zoom.asp?id="+id_immagine+"&larghezza="+larghezza+"&altezza="+altezza

		xmlHttp.onreadystatechange = handleStateChangeZoom;
		xmlHttp.open("GET", UrlImmagine, true);
		xmlHttp.send(null);

}

function handleStateChangeZoom(){

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 elemento ....</center>"
Messaggio = Messaggio + "  </td></tr>"
Messaggio = Messaggio + "</table>"

		if (xmlHttp.readyState==4){

			if (xmlHttp.status == 200){
				
				document.getElementById("Zoom").innerHTML = xmlHttp.responseText;
				document.getElementById("Zoom").focus();
				return false;
				
			}else{

				// INTERCETTO ERRORE E VISUALIZZO
				handleErrFullPage(xmlHttp.responseText);
				//-------------------------------
				
				document.getElementById("Zoom").innerHTML = Messaggio;
			}
		
		}else{
			
			document.getElementById("Zoom").innerHTML = Immagine_Preload
			
		}


}
/*-----------------------------------------------*/
/*-----------------------------------------------*/
/*-----------------------------------------------*/


/*-----------------------------------------------*/
/*------------ ZOOM IMMAGINE --------------------*/
/*-----------------------------------------------*/

function ImmagineStanza(id_padre,tabella_padre){

		createXMLHttpRequest();

		UrlImmagine = ""
		UrlImmagine = UrlImmagine + "immaginestanza.asp?id_padre="+id_padre+"&tabella_padre="+tabella_padre

		xmlHttp.onreadystatechange = handleStateChangeImmagineStanza;
		xmlHttp.open("GET", UrlImmagine, true);
		xmlHttp.send(null);

}

function handleStateChangeImmagineStanza(){

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 elemento ....</center>"
Messaggio = Messaggio + "  </td></tr>"
Messaggio = Messaggio + "</table>"

		if (xmlHttp.readyState==4){

			if (xmlHttp.status == 200){
				
				document.getElementById("Foto_Stanza").innerHTML = xmlHttp.responseText;

			}else{

				// INTERCETTO ERRORE E VISUALIZZO
				handleErrFullPage(xmlHttp.responseText);
				//-------------------------------
				
				document.getElementById("Foto_Stanza").innerHTML = Messaggio;
			}
		
		}else{
			
			document.getElementById("Foto_Stanza").innerHTML = Immagine_Preload
			
		}


}
/*-----------------------------------------------*/
/*-----------------------------------------------*/
/*-----------------------------------------------*/



/*-----------------------------------------------*/
/*--- 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);
		}

}

/*-----------------------------------------------*/
/*-----------------------------------------------*/
/*-----------------------------------------------*/