function createAjaxObj(){
	var httprequest=false
	if (window.XMLHttpRequest){ // if Mozilla, Safari etc
		httprequest=new XMLHttpRequest()
		if (httprequest.overrideMimeType)
			httprequest.overrideMimeType('text/xml')
	}else if (window.ActiveXObject){ // if IE
		try {
			httprequest=new ActiveXObject("Msxml2.XMLHTTP");
		}catch (e){
			try{
				httprequest=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e){
				alert(e.toString());
			}
		}
	}
	return httprequest
}

var MyAjax=new Object()
MyAjax.Obj=createAjaxObj();
MyAjax.addrandomnumber=1 //Set to 1 or 0. See documentation.

MyAjax.Gets=function(url, parameters, callbackfunction){
  MyAjax.Obj=createAjaxObj(); //recreate ajax object to defeat cache problem in IE
	if (MyAjax.addrandomnumber==1) //Further defeat caching problem in IE?
		var parameters=parameters+"&ajaxcachebust="+new Date().getTime()
	if (this.Obj){
		this.Obj.onreadystatechange=function(){eval(callbackfunction)}
		this.Obj.open('GET', url+"?"+parameters, true)
		this.Obj.send(null)
	}
}

MyAjax.Posts=function(url, parameters, divid){
	Ajax.Obj=createAjaxObj() //recreate ajax object to defeat cache problem in IE
	if (this.Obj){
		if (typeof filetype!='undefined')
			this.filetype=filetype
		this.Obj.onreadystatechange = callbackfunc;
		this.Obj.open('POST', url, true);
		this.Obj.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		this.Obj.setRequestHeader("Content-length", parameters.length);
		this.Obj.setRequestHeader("Connection", "close");
		this.Obj.send(parameters);
	}
}
/*
function Response(divid){
	var myajax=Ajax.Obj
	if (myajax.readyState == 4){ //if request of file completed
		if (myajax.status==200 || window.location.href.indexOf("http")==-1){ //if request was successful or running script locally
			$(divid).innerHTML = myajax.responseText;
		}
	}else{
		$(divid).innerHTML = '<font family=""><img src="images/loading.gif" border="0" align="middle">Đang cập nhật ...</font>';
	}
}
*/
/*
function $() {
  var elements = new Array();
  for (var i = 0; i < arguments.length; i++) {
    var element = arguments[i];
    if (typeof element == 'string')
      element = document.getElementById(element);
    if (arguments.length == 1)
      return element;
    elements.push(element);
  }
  return elements;
}
*/