/***MT---song****
*************AJAX*************
******************************
*******Compatible IE And Mozilla********
**/
function ajax()
{
    this.div=null;
    this.aobj=null;
    try 
    {
        var xhr = new XMLHttpRequest();
    }
    catch (e)
    {
        var a = ['MSXML2.XMLHTTP.5.0', 'MSXML2.XMLHTTP.4.0',
    'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP', 'MICROSOFT.XMLHTTP.1.0',
    'MICROSOFT.XMLHTTP.1', 'MICROSOFT.XMLHTTP'];
        for (var i = 0; i < a.length; i++) 
        {
            try 
            {
                var xhr = new ActiveXObject(a[i]);
                break;
            }
            catch (e) 
            {
            }
        }
    }
    if (xhr)
    {
        this.aobj=xhr;
    }
    else
    {
        this.aobj=null;
    }
}
ajax.prototype.showObjCellInfo=function(strMsg)
{
    try
    {
        if(this.div!=null && this.div!="undefined")
        {
            this.div.style.display=strMsg.trim()==""?"none":"block";
            this.div.innerHTML=strMsg;
        }
    }
    catch(err){}
}
ajax.prototype.Post=function(data,url,odiv)
{
    try
    {
        if(typeof(odiv)=="string")
        {
            this.div=document.getElementById(odiv);
        }
        else
        {
            this.div=odiv;
        }
        var objC=this;
        this.aobj.open("POST", url, true);
        this.aobj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	    this.aobj.onreadystatechange = function(){objC.ProcessReqChange(objC);};
        this.aobj.send(data);
    }
    catch(err)
    {
        this.showObjCellInfo("Errors:"+err.message);
    }
}
ajax.prototype.Get=function(data,url,odiv)
{ 
    try
    {
        if(typeof(odiv)=="string")
        {
            this.div=document.getElementById(odiv);
        }
        else
        {
            this.div=odiv;
        }
        var objC=this;
        this.aobj.open("GET", url, true);
        this.aobj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	    this.aobj.onreadystatechange = function(){objC.ProcessReqChange(objC);};
        this.aobj.send(data);
    }
    catch(err)
    {
        this.showObjCellInfo("Errors:"+err.message);
    }
}
ajax.prototype.initAdminPage=function()
{
	initAdminPage();
}
ajax.prototype.ProcessReqChange=function(obj)
{
    try
	{
		if (obj.aobj.readyState == 4 && obj.aobj.status == 200 )
		{
		    var sr=unescape(obj.aobj.responseText);
			if(sr=="fail")
			{
				//obj.showObjCellInfo("数据处理失败！请保证您的网络连接畅通或者有足够的权限进行相关的数据操作；否则，请及时与管理员联系,谢谢!");
				//obj.showObjCellInfo("Data processing failed! Please ensure that your network connection or have unimpeded access to the data related to operation; Otherwise, timely and administrator, thank you!");
				obj.showObjCellInfo("Data or connection problems! Please ensure that your network connection is active and you have connection to the internet. thank you!");
			}
			else
			{
				try
				{
				    obj.showObjCellInfo("");
					//goExecute(sr);
					//alert(sr);
					sr   =   sr.replace(/[\r\n]/g,   "<br>");
					eval(sr);
					try{document.documentElement.scrollTop=0;}catch(exb){}
				}
				catch(er)
				{
					obj.showObjCellInfo("Eval Error:"+er.message);
				}
			}
		}
		else if(obj.aobj.readyState == 0)
		{
		    //UNINITIALIZED
		    //The object has been created, but not initialized (the open method has not been called).
			//alert("获得数据遇到问题！\n请保证您的网络连接畅通；否则，请及时与管理员联系,谢谢!:\n");
			//obj.showObjCellInfo("数据发送失败!");
			obj.showObjCellInfo("Data sent failure!");
		}
		else if(obj.aobj.readyState == 1)
		{
		    //LOADING
		    //The object has been created, but the send method has not been called.
			//obj.showObjCellInfo("请等待数据发送!");
			obj.showObjCellInfo("Please wait, data loading!");
		}
		else if(obj.aobj.readyState == 2)
		{
		    //LOADED
		    //The send method has been called, but the status and headers are not yet available.
			//obj.showObjCellInfo("数据已经发送,请等待处理结果!");
			//obj.showObjCellInfo("Data has been sent, please wait for the results!");
			obj.showObjCellInfo("Please wait, data loading!..");
		}
		else if(obj.aobj.readyState == 3)
		{
		    //INTERACTIVE
		    //Some data has been received. Calling the responseBody and responseText properties at this state to obtain partial results will return an error, because status and response headers are not fully available.
			//obj.showObjCellInfo("数据接收中,请等待处理结果!");
			//obj.showObjCellInfo("Data reception, please wait for the results!");
			obj.showObjCellInfo("Please wait, data loading!....");
		}
		else if(obj.aobj.readyState==4 && obj.aobj.status!=200)
		{
		    //obj.showObjCellInfo("接收数据遇到问题！请保证您的网络连接畅通；否则，请及时与管理员联系,谢谢!");
			//obj.showObjCellInfo("Receiving data problems! Please ensure that your network connection debris; Otherwise, timely and administrator, thank you!");
			obj.showObjCellInfo("Data or connection problems! Please ensure that your network connection is active and you have connection to the internet. thank you!");
		}
    }
    catch(err)
    {
        //alert(err.message);
        obj.showObjCellInfo("Errors:"+err.message);
    }
}
