/**
 * @version 2.0
 * @author panlianghu
 * @copyright 2008 vekcn.com
 */

function getXmlhttp(){
	
	var request = false;
	if(window.XMLHttpRequest) {

		request = new XMLHttpRequest();
		if(request.overrideMimeType) {
			request.overrideMimeType('text/xml');
		}
	} else if(window.ActiveXObject) {
		var versions = ['Microsoft.XMLHTTP', 'MSXML.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.7.0', 'Msxml2.XMLHTTP.6.0', 'Msxml2.XMLHTTP.5.0', 'Msxml2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP'];
		for(var i=0; i<versions.length && !request; i++) {

			try {
				request = new ActiveXObject(versions[i]);
				if(request) {
					return request;
				}
			} catch(e) {
				disPlayError(e.message);
			}
		}
	}
	return request;
}

function disPlayError(message)
{
        alert(message);
}

function postajax(url,requestUri,funcName,method){

	if(typeof method == "undefined"){
		var method = true;
	}
	var xhttp=getXmlhttp();
	xhttp.open("POST",url,method);
	xhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xhttp.send(requestUri);
	xhttp.onreadystatechange=function(){
		if(xhttp.readyState==4 && (xhttp.status==200 || window.location.href.indexOf("http")==-1)){
			eval(funcName)(xhttp.responseText);
		}
	}
}

function getajax(url,funcName,method){

	if(typeof method == "undefined"){
		var method = true;
	}
	var xhttp=getXmlhttp();
	xhttp.open("GET",url,method);
	xhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xhttp.send(null);
	xhttp.onreadystatechange=function(){
		if(xhttp.readyState==4 && (xhttp.status==200 || window.location.href.indexOf("http")==-1)){
			eval(funcName)(xhttp.responseText);
		}
	}
}