// JavaScript Document
function resize(y){
alert(y);
document.getElementById('page').style.height = y;
}

function selection(id){
	document.getElementById('selection').value = id;
	loadPage(id);
}

XMLrequest = new createXMLHttp();

function createXMLHttp(){
	if(typeof XMLHttpRequest != "undefined"){
		return newXMLHttpRequest();             //both the browser is Mozilla and Opera or Safari a object will be created and returned
	} else if (window.ActiveXObject) {          //if browser is IE all the version of ActiveX controll will be tested, then 
		var aVersion = ["MSXML3.XMLHttp",       //if the object will be instanced the method return it.
						"MSXML2.XMLHttp.6.0",
						"MSXML2.XMLHttp.5.0",
						"MSXML2.XMLHttp.4.0",
						"MSXML2.XMLHttp.3.0",
						"MSXML2.XMLHttp",
						"Microsoft.XMLHttp"
						];
		for(var i = 0;i < aVersion.length; i++){
			try{
				var oXmlHttp = new ActiveXObject(aVersion[i]);
				return oXmlHttp;
			}
			catch (oError){ 
				//Do Nothing
			}
		}
	}
}

function loadPage(sender){ 

    var contentRequest = encodeURIComponent(document.getElementById('selection').name)
						+"="
						+encodeURIComponent(document.getElementById('selection').value);
	if(!XMLrequest){
		XMLrequest = new createXMLHttp();
	}
	else if (XMLrequest.readyState!=0){
		XMLrequest.abort();
	}
	XMLrequest.open("post","menu.php",true);
	XMLrequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	
	XMLrequest.onreadystatechange = getResponse;
	alert(contentRequest);
	XMLrequest.send(contentRequest);
}

function getResponse(){
alert("ciao");
	if(XMLrequest.readyState == 4){
		if(XMLrequest.status == 200) {
			document.getElementById('contentPage').innerHTML=XMLrequest.responseText;
		}
		else{
			alert("Errore: :"+ XMLrequest.statusText);
		}
	}

}
