/*
'/*
'// ------------------------------------------------------------------------ //
'// Project Name       : 旅程网                                         //
'// Program Name       : Manage                                           //
'// Copyright          : COPYRIGHT (C) 2004 - 2005 BY 868E.COM        //
'// Version            : 2.0                                                 //
'// Author             : 祁文广                               //
'//                                                                          //
'// Date        By            Description                                    //
'// ---------   ------------- -----------------------------------------------//
'// 2006/01/06  祁文广        AJAX类		                     //
'// ------------------------------------------------------------------------ //
*/
function Js_Ajax()
{
	this.PostUrl; ///AJAX提交的文件地址
	this.Treat; ///参数返回后的处理过程
	this.Method="GET";///参数提交方式
	this.Async=true;///是否启用异步处理

	
	this.GetXmlHttpRequest=function()
	{
		var req;
		if (window.XMLHttpRequest) 
		{ // Mozilla, Safari,...
            req = new XMLHttpRequest();
            if (req.overrideMimeType) {
                req.overrideMimeType('text/xml');
            }
        } else if (window.ActiveXObject) { // IE
			/*try {
                req = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    req = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }*/
			var msxmls = ["MSXML3", "MSXML2", "Microsoft"];
			var returnObj
	
			for (var i=0; i < msxmls.length; i++) 
			{
				try 
				{
					req = new ActiveXObject(msxmls[i] + ".XMLHTTP");
					break;
				}
				catch (ex)
				{
					if (i==2)
					{						
						alert("JS_CLASS:ERROR:创建" + msxmls[i] + ".XMLHTTP" + "控件失败!");
					}
				}
			}
        }

		if (!req) 
		{
			alert("JS_CLASS:ERROR:组件创建失败")
			return false;
		}
		return req;
	}
	
	
	this.SendRequest=function(url, params, HttpMethod)
	{
		if (!HttpMethod)
		{
   			 HttpMethod = "POST";
  		 }
		 var Obj=this.GetXmlHttpRequest();
		 var s=this.processChech(Obj,this.Treat)
		 Obj.onreadystatechange = s

		 if(HttpMethod=="POST")
		 {
				Obj.open(HttpMethod,url,this.Async);
				Obj.setRequestHeader("Method", "POST " + url + " HTTP/1.1");
				Obj.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
				Obj.send(params);
		}
		else
		{
				Obj.open(HttpMethod,url,this.Async);
				//Obj.setRequestHeader("Method", "GET " + this.targetURI + " HTTP/1.1");
				Obj.send(params);
		}
		delete Obj;
		delete s;
	}
	
	this.Creat=function()
	{
		this.SendRequest(this.PostUrl,null,this.Method);		
	}
	
	this.processChech=function(mobject,f)
	{
		return function()
		{		

		  if (mobject.readyState == 4) 
			{				
			
				var state=mobject.status;
				if (state==404)
				{
					alert("JS_CLASS:ERROR:请求页面不存在");
					return false;					
				}
				else if(state<200)
				{
					alert("JS_CLASS:ERROR:客户端错误:"+state.statusText);
					return false;
				}
				else if(state==200)
				{
					f(mobject.responseText);
					//return false;		
				}
			}
			
		}
		
	}
}
 

