// JavaScript Document

function ajax(query, requestingid, post_array, func_to_call) {
	var request = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("MSXML2.XMLHTTP.3.0");
	request.open("POST", query, true); 
	request.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
	request.onreadystatechange = function() {
		if (request.readyState == 4 && request.status == 200) {
			if(requestingid != null && requestingid != '') {
				document.getElementById(requestingid).innerHTML = request.responseText;
				if(func_to_call != null) {
					func_to_call.call();
				}
			}
		} else {
		}
	};
	
	var post_string = "";
	if(post_array != null) {
		for(i in post_array) {
			post_string += i+"="+post_array[i]+"&";
		}
	}
	request.send(post_string);
}


