// JavaScript Document

// XMLhttp object creation
function getHTTPObject() {
	var xmlhttp;
	/*@cc_on
	@if (@_jscript_version >= 5)
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp = false;
		}
	}
	@else
	xmlhttp = false;
	@end @*/
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp = false;
		}
	}
	return xmlhttp;
}

var xh = new Array;
var t = new Array;

// ajax constructor
var ajaxRequest = function() {
	this.send = ajaxRequest.send;
}

ajaxRequest.send = function(what, where, how, wait, progress, callback, lz, c){
	xh[c] = getHTTPObject();
	switch (how) {
		case "POST":
			if (progress != null) document.getElementById(progress).style.display = "inline";
			xh[c].open(how, where, wait);
			xh[c].setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=utf-8');
			xh[c].setRequestHeader("Content-length",what.length);
			//xh.setRequestHeader("Connection","close");
			if (wait == true) {
				xh[c].onreadystatechange = function() { showProgress(progress, callback, lz, c); }
			}
			xh[c].send(what);
			if (wait == false) {
				if (xh[c].readyState == 4) {
					if (progress != null) document.getElementById(progress).style.display = "none";
					return xh[c].responseText;
				}
			}
			break;
		case "GET":
			what = (what == null) ? "" : "?" + what;
			if (progress != null) document.getElementById(progress).style.display = "inline";
			xh[c].open(how, where + what, wait);
			if (wait == true) {
				xh[c].onreadystatechange = function(){ showProgress(progress, callback, lz, c); }
			}
			xh[c].send(null);
			if (wait == false) {
				if (xh[c].readyState == 4) {
					if (progress != null) document.getElementById(progress).style.display = "none";
					return xh[c].responseText;
				}
			}
			break;
		default:
			break;
	}
}

function showProgress(progress, callback, lz, c) {
	if (xh[c].readyState == 4) {
		if (progress != null) document.getElementById(progress).style.display = "none";
		self.clearTimeout(t[c]);
		callback(xh[c].responseText, lz);
		return;
	}
	t[c] = self.setTimeout("showProgress('" + progress + "', " + callback + ", '" + lz + "', '" + c + "')", 1);
}

function putContent(whatX, whereX){
	document.getElementById(whereX).innerHTML = whatX;
}