window.onload = initAll;

var xhr = false;	


function initAll() {
	
	var opt = document.getElementById("menu_option");
	
	getNew();
	
	opt.onchange = getNew; 
}

function getNew(){

	var mark ="menu/" + document.getElementById("menu_option").value;

	if (window.XMLHttpRequest) {
		xhr = new XMLHttpRequest();
	}
	else {
		if (window.ActiveXObject) {
			try {
				xhr = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) { }
		}
	}

	if (xhr) {
		xhr.onreadystatechange = showContents;
		xhr.open("GET", mark, true);
		xhr.send(null);
	}
	else {
		alert("Sorry, but I couldn't create an XMLHttpRequest");
	}
	return false;
}

function showContents(){
	if (xhr.readyState == 4) {
		if (xhr.status == 200) {
			var outMsg = xhr.responseText;
		}
		else {
			var outMsg = "There was a problem with the request " + xhr.status;
		}
		
		var wel_message = document.getElementById("wel_message");
		wel_message.innerHTML = outMsg;
	}
}