
var xhr;

function calendarUpdate(cMonth, cYear, cLang, cURL){

	if (window.XMLHttpRequest) {
		xhr = new XMLHttpRequest();
	}
	else {
		xhr = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	p_url = cURL+'?cMonth='+cMonth+'&cYear='+cYear+'&cLang='+cLang;
	// document.getElementById('debug').innerHTML = p_url;
	xhr.open("GET",p_url);
	
	try {
		xhr.onreadystatechange = calendarReadyStateChange;			
		xhr.send(null);		//su questa istruzione, selezionando l'ultima voce
	}
	catch (err) {
		//alert("errore 1");
	}
}

function calendarReadyStateChange() {
	if (xhr.readyState == 4) {
		if (xhr.status == 200 || xhr.status == 0) {
			//alert(xhr.responseText);
			testoHTML = xhr.responseText;
					
			//Update HTML into the DIV
			document.getElementById('calendar').innerHTML = testoHTML;		
		}
	}
}
