﻿var AjaxNoteCaterina;

function OggettoAjaxN()
{
	var oggetto = null;

	// informazioni sul nome del browser
	var browserUtente = navigator.userAgent.toUpperCase();

	// browser standard con supporto nativo
	// non importa il tipo di browser
	if(typeof(XMLHttpRequest) === "function" || typeof(XMLHttpRequest) === "object")
		oggetto = new XMLHttpRequest();

	// browser Internet Explorer
	// è necessario filtrare la versione 4
	else if(window.ActiveXObject && browserUtente.indexOf("MSIE 4") < 0)
	{
	// la versione 6 di IE ha un nome differente
	// per il tipo di oggetto ActiveX
	if(browserUtente.indexOf("MSIE 5") < 0)
		oggetto = new ActiveXObject("Msxml2.XMLHTTP");
	// le versioni 5 e 5.5 invece sfruttano lo stesso nome
	else
		oggetto = new ActiveXObject("Microsoft.XMLHTTP");
	}

 	return oggetto;
}

function VediDettaglioNota(codice, titolo, e)
{
	AjaxNoteCaterina = OggettoAjaxN();
	
	if(AjaxNoteCaterina != null)
	{
		var oggetto = document.getElementById("divZoomNota");
		if(oggetto != null)
		{
			oggetto.style.top = document.body.scrollTop + e.clientY - 182;
			oggetto.style.left = e.clientX - 210;
			oggetto.style.display = "block";
			oggetto.innerHTML = "<p align=center class=Normale><img src=\"/Immagini/loading.gif\"><br><b>Caricamento note...</b></p>";
			var url="/Personaggi/LettereCaterina/Note_Ajax.aspx";
			var postData = "cod=" + codice
			    + "&tit=" + titolo
				+ "&sid=" + Math.random();

			AjaxNoteCaterina.onreadystatechange = Risposta_NotaCaterina;
			AjaxNoteCaterina.open("GET", url + "?" + postData, true);
			var iVersione = -1;
            var iBrowser = navigator.userAgent.toUpperCase().indexOf("MSIE");
            if(iBrowser != -1)
            {
                iVersione = parseInt(navigator.userAgent.substr(iBrowser + 5, 1));
            }

            if(!(iBrowser != -1 && iVersione < 7))
            {
                AjaxNoteCaterina.setRequestHeader("Connection", "close");
            }
			
			AjaxNoteCaterina.send(postData);
		}
	}
	else
	{
		// Ajax non supportato
		alert("Questo browser non supporta Ajax.");
	}
}

function ChiudiNotaCaterina()
{
	var oggetto = document.getElementById("divZoomNota");
	if(oggetto != null)
	{
		oggetto.style.display = "none";
	}
}

function Risposta_NotaCaterina() 
{ 
	if (AjaxNoteCaterina.readyState==4 || AjaxNoteCaterina.readyState=="complete")
	{ 
		if(AjaxNoteCaterina.status==200)
			document.getElementById("divZoomNota").innerHTML = AjaxNoteCaterina.responseText; 
	} 
}


