function createAjaxObj(){
	var httprequest = false;
	if (window.XMLHttpRequest) {
		httprequest = new XMLHttpRequest();
		if (httprequest.overrideMimeType) httprequest.overrideMimeType('text/xml')
	} else 
		if (window.ActiveXObject) {
			try {
				httprequest = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try {
					httprequest = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {
				}
			}
		}
	
	return httprequest
};
function ajaxPackObj(){
	oThis = this;
	this.bExecuting = false;
	this.basedomain = "http://" + window.location.hostname;
	this.filetype = "txt";
	this.addrandomnumber = 1;
	this.ajaxobj = createAjaxObj();
	this.executed = function(){
		
		return !oThis.bExecuting;
	};
	this.getAjaxRequest = function(url, parameters, callbackfunc, filetype, oncallfunc){
		oThis.ajaxobj = createAjaxObj();
		if (oThis.addrandomnumber == 1) var parameters = parameters + "&ajaxcachebust=" + new Date().getTime();
		if (oThis.ajaxobj) {
			if (!oThis.bExecuting) {
				oThis.bExecuting = true;
				oThis.filetype = filetype;
				oThis.ajaxobj.onreadystatechange = function(){
					if (oThis.ajaxobj.readyState == 4) {
						oThis.bExecuting = false;
					}
					callbackfunc(oThis.ajaxobj);
				};
				if (oncallfunc) {
					oncallfunc();
				}
				var aUrl = url.split("?");
				url = aUrl[0] + "?";
				if (aUrl.length == 2) {
					if (aUrl[1].indexOf('ajax=Y') == -1) {
						url += "ajax=Y&"
					}
					url += aUrl[1];
				}
				oThis.ajaxobj.open('GET', url + parameters, true);
				oThis.ajaxobj.send(null);
			}
		}
	};
	
	this.postAjaxRequest = function(url, parameters, callbackfunc, filetype){
		oThis.ajaxobj = createAjaxObj();
		if (oThis.ajaxobj) {
			if (!oThis.bExecuting) {
				oThis.filetype = filetype;
				oThis.ajaxobj.onreadystatechange = function(){
					if (oThis.ajaxobj.readyState == 4) {
						oThis.bExecuting = false;
					}
					callbackfunc(oThis.ajaxobj);
				};
				oThis.ajaxobj.open('POST', url, true);
				oThis.ajaxobj.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
				oThis.ajaxobj.setRequestHeader("Content-length", parameters.length);
				oThis.ajaxobj.setRequestHeader("Connection", "close");
				oThis.ajaxobj.send(parameters);
			}
		}
	}
}
