var mlXmlHttp;

function mlGetXmlHttpObject() {
	var xmlHttp = null;

	// Firefox, Opera 8.0+, Safari
	try {
		xmlHttp = new XMLHttpRequest();

	// Internet Explorer
	} catch(e) {
		try {
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(e) {
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}

	return xmlHttp;
}

function mlChange(wpurl, args, loading) {

	mlXmlHttp = mlGetXmlHttpObject();
	if (mlXmlHttp == null) {
		alert ("Oop! Browser does not support HTTP Request.")
		return;
	}

	var url = wpurl;
	url += "?action=ml_ajax";
	url += "&args=" + args;

	mlXmlHttp.onreadystatechange = function(){runMlChange(loading)};
	mlXmlHttp.open("GET", url, true);
	mlXmlHttp.send(null);
}

function runMlChange(loading) {
	var navigator = document.getElementById("ml_nav");
	var parent = navigator.parentNode;

	if (mlXmlHttp.readyState < 4) {
		document.body.style.cursor = 'wait';
		navigator.innerHTML = (loading == undefined) ? "Loading..." : loading + "...";

	} else if (mlXmlHttp.readyState == 4 || mlXmlHttp.readyState=="complete") {
		parent.innerHTML = mlXmlHttp.responseText;
		document.body.style.cursor = 'auto';
	}
}
