function ajaxLoad(method,URL,data,displayId){

var ajax =null;
var nonewait = data.indexOf("div=nonewait");

if(window.ActiveXObject){
ajax= new ActiveXObject("Microsoft.XMLHTTP");
}else if(window.XMLHttpRequest){
ajax=new XMLHttpRequest();
}else{
	alert("Don't run Ajax!");
	return;
}
method = method.toLowerCase();
URL += "?ajax=" + (new Date()).getTime();
if(method.toLowerCase() == "get"){
URL += "&" + data;
data = null;
}
ajax.open(method,URL);
if(method.toLowerCase() == "post"){
ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
}
ajax.onreadystatechange = function (){
	if(ajax.readystate ==4 && ajax.status == 200){
		var ctype = ajax.getResponseHeader("Content-Type");
		ctype = ctype.toLowerCase();
		ajaxCallback(ctype,displayId ,ajax.responseText);
		delete ajax;
		ajax=null;
	}else{
		if(nonewait != 0){
		ajaxCallwait(displayId );
	}}
}
ajax.send(data);
}

function ajaxCallback(contentType,displayId,responseText){
if(contentType.match("text/javascript")){
eval(responseText);
}else{
 document.getElementById(displayId).innerHTML = responseText;
}}

function ajaxCallwait(displayId ){
document.getElementById(displayId).innerHTML= "<div width='100' align='center'><BR><img src=\"images/loading.gif\" alt=\"Loading...\"/><br /><font size=\"2\" color=\"#006600\" face=\"MS Sans Serif\">รอก่อนนะ... <" + "/" + "font> <" + "/" + "div>";
}