function ajax_ini() {
	var xmlhttp = false;
	if (window.XMLHttpRequest) {
		//Mozilla
		xmlhttp = new XMLHttpRequest();
		if(xmlhttp.overrideMimeType) {
			xmlhttp.overrideMimeType('text/xml');
		}
	} else {
		//IE
		try {
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (oc) {}
		}
	}

	if (!xmlhttp) {
		return false;
	} else {
		return xmlhttp;
	}
}


function ajax_run(scripturl, args) {
	
	xmlhttp = ajax_ini();

	if(!xmlhttp) {
		return false;
	}

	xmlhttp.open("GET", scripturl, true);

	if(args) {
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4) {
				// everything is good, the response is received
				var data = unescape(xmlhttp.responseText);
				args[0](args, data);
			} else {
				// still not ready
				var data = 'Waiting ...';
				args[0](args, data);
				return;
			}
		}
	}
	xmlhttp.send(null);
	delete xmlhttp;
}

