try {
	if (!use_charset)
		var use_charset = 'ISO-8859-1';
}
catch( e ) { }

function ajax_request() {
	this.isIE               = false;
	this.xmlhandler         = null;
	this.error_string       = '';
	this.nocache						= true;
	this.do_request_functon = function() {}
}

ajax_request.prototype.xml_init = function() {
	try {
		this.xmlhandler = new XMLHttpRequest();
		this.ie        = false;
		return true;
	} catch(e) {
		try {
			this.xmlhandler = new ActiveXObject('Microsoft.XMLHTTP');
			this.ie        = true;
			return true;
		} catch(e) {
			this.ie        = true;
			return false;
		}
	}
}

ajax_request.prototype.process = function( url, type, post ) {
	type = type == "POST" ? "POST" : "GET";

	if (this.nocache == true  && type == 'GET')
		url = this.nocache_url( url );

	if (!this.xmlhandler)
		this.xml_init();

	if (!this.readystate_not_ready()) {
		this.xmlhandler.open(type, url, true);
		
		if (type == "GET")
			this.xmlhandler.send(null);
		else {
			if (typeof( this.xmlhandler.setRequestHeader ) != "undefined")
				this.xmlhandler.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=' + use_charset);
			this.xmlhandler.send(post);
		}

		if (this.xmlhandler.readyState == 4 && this.xmlhandler.status == 200)
			return true;
	}

	return false;
}

ajax_request.prototype.get_element_text_ns = function(prefix, local, parentElem, index) {
	var result = "";

	if ( prefix && this.isIE )
		result = parentElem.getElementsByTagName(prefix + ":" + local)[index];
	else
		result = parentElem.getElementsByTagName(local)[index];

	if (result) {
		if (result.childNodes.length > 1)
			return result.childNodes[1].nodeValue;
		else
			return result.firstChild.nodeValue;    		
	} else
		return "n/a";
}

ajax_request.prototype.nocache_url = function (url) {
	var sep    = ( -1 < url.indexOf("?") ) ? "&" : "?";
	var mydate = new Date();
	var newurl = url + sep + "__=" + mydate.getTime();
	return newurl;
}

ajax_request.prototype.format_for_post = function(arrayfields) {
	var str = '';
	
	try {
		for( var i in arrayfields)
			str += i + '=' + this.encodeurl(arrayfields[i]) + '&';
	} catch(e) { }

	return str;
}

ajax_request.prototype.encodeurl = function(url) {
	url = url.toString();
	var regcheck = url.match(/[\x90-\xFF]/g);
	
	if (regcheck) {
		for (var i = 0; i < i.length; i++)
			url = url.replace(regcheck[i], '%u00' + (regcheck[i].charCodeAt(0) & 0xFF).toString(16).toUpperCase());
	}

	return escape(url).replace(/\+/g, "%2B");
}

ajax_request.prototype.readystate_not_ready = function() {
	return (this.xmlhandler.readyState && (this.xmlhandler.readyState < 4) );
}

ajax_request.prototype.readystate_ready_and_ok = function() {
	return ( this.xmlhandler.readyState == 4 && this.xmlhandler.status == 200 ) ? true:false;
}

ajax_request.prototype.onreadystatechange = function(event) {
	if (!this.xmlhandler)
		this.xml_init();
	
	if ( typeof(event) == 'function' )
		this.xmlhandler.onreadystatechange = event;
}

/*
do_request_function = function() {
	if (!xmlobj.readystate_ready_and_ok())
		return;
	alert(xmlobj.xmlhandler.responseText);
}

var fields = new Array();
fields[field.name] = field.value;

var xmlobj = new ajax_request();
xmlobj.onreadystatechange(do_request_function);
xmlobj.process('file.php', 'POST', xmlobj.format_for_post(fields));
*/