﻿/*
XMLHTTP同步和异步取数据类
编码者         fj
建立日期       2009-12-12
最后修改者     fj
最后修改日期   2009-12-12
*/
function XMLHTTPHelper(requestType,requestUrl,params,syncallback){
	
//	params = FilterParams(params,["'"],["''"]);
//	params = params.replace(new RegExp('%2527',"gm"),'%27');
//	alert(unescape(params));
	params += "&syslogID="+syslogID;
	var chkUrl = requestUrl + params;
	if(Browser.IE)
	{
	this.xh = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else
	{
	if(window.XMLHttpRequest)
	{
	this.xh = new XMLHttpRequest();
	}
	}
	
	this.GetResult = function(){
		return this.xh.responseText
	}
	this.GetReadyState = function(){
		return this.xh.readyState
	}
	this.GetStatus = function(){
		if(this.xh.status==200)
		{
		var _se=this.GetResult();
		switch(_se){
		case "SystemError:SessionTimeOut":window.location.href=V9_Domain;return 0;
		default:return 200;
		}
		}
		else
		return this.xh.status;
	}
	this.OnReadyStateChange = eval(syncallback)
	if(syncallback!=null){
		this.xh.onreadystatechange = this.OnReadyStateChange;
	}
	//
	this.RequestDataIsSyn = function(){
		switch(requestType.toLocaleLowerCase()){
			case "get":
				this.xh.open(requestType,chkUrl,true);
				this.xh.send();
			break;
			case "post":
				this.xh.open(requestType,requestUrl,true);
				this.xh.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
				this.xh.send(params);
			break;
		}
	}
	this.RequestData = function(){
		switch(requestType.toLocaleLowerCase()){
			case "get":
				this.xh.open(requestType,chkUrl,false);
				this.xh.send();
			break;
			case "post":
				this.xh.open(requestType,requestUrl,false);
				this.xh.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
				this.xh.send(params);
			break;
		}
		return this.GetResult()
	}
}

var FilterParams=function(params,arr1,arr2)
{
var arr_Old=arr1;
var arr_New=arr2;
for(var i=0;i<arr_Old.length;i++)
if(params.indexOf(escape(arr_Old[i]))!=-1)
{params=params.replace(new RegExp(escape(arr_Old[i]),"gm"),escape(arr_New[i]));}
return params;
}