
//************************************************
// ajax general GET method
//************************************************
// params:
// url = the url with parameters, like: "script.php?name=xy&gender=1"
// callback = name of the callback process as string, like: "employeList"
function axGet(url,callback){
	var url = url + "&rnd="+Math.random(1000);
	if (typeof XMLHttpRequest != "undefined") {
	   req = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
	   req = new ActiveXObject("Microsoft.XMLHTTP");
	}
	req.open("GET", url, true);
	req.onreadystatechange = function (){axCallback(callback)};
	req.send(null);	
}


//************************************************
// ajax general POST method
//************************************************
// params:
// url = the url with parameters, like: "script.php?name=xy&gender=1"
// callback = name of the callback process as string, like: "employeList"
// data = variables and values list like: "name=Cserep Virag&location=Budapest"
function axPost(url,callback,data){
	var url = url + "&rnd="+Math.random(1000);
	if (typeof XMLHttpRequest != "undefined") {
	   req = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
	   req = new ActiveXObject("Microsoft.XMLHTTP");
	}
	req.open("POST", url, true);
	req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

	req.onreadystatechange = function (){axCallback(callback)};
	req.send(data);	
}


// callback function for general GET method
// when the AJAX loaded the content, call this function
function axCallback(callback){
	 if (req.readyState == 4) {
        if (req.status == 200) {
			// generate callback call...
			// return with req result object with
			//	- responseText
			//	- responseXML
			var str = callback +"(req)";
			eval(str);
	     }
	 }
}
