var MyAjax=function()
{
	
	//創建xmlhttprequest對像
	this.CreateAjax = function()
	{
		if (window.XMLHttpRequest) 
		{	
			return new XMLHttpRequest();
		} 
		else if (window.ActiveXObject)
		{
		return new ActiveXObject("Microsoft.XMLHTTP");
		}
		else
		{
			return false;
		}
	}
	
	this.Ajax = this.CreateAjax();
	this.onload = function()
		{
			if (this.Ajax.readyState==4)
			{
				if (this.Ajax.status==200)
				{
					this.action(this.Ajax.responseText,this.Ajax.responseXML);//調用ACTION，傳遞TEXT 和XML
				}
			}
		}
	this.action = function(Rtext,Rxml){};//可繼承的執行函數
	this.method = "GET";//傳送方法,默認為GET
	this.url = "";//傳送的URL
	this.Parms = new Array();//參數數組
	this.ParmsAdd = function(name,value)//添加參數
	{
		this.Parms.push(name+"="+value);
	}
	this.open = function()//準備發送請求
	{
		var oAjax = this;
		//alert(oAjax);
		this.Ajax.open(this.method,this.Parms.length>0 ? this.url + "?" + this.Parms.join("&") : this.url,true);
		this.Ajax.setRequestHeader("If-Modified-Since","0");//防止緩存問題
		this.Ajax.onreadystatechange = function(){oAjax.onload.call(oAjax);}//狀態變化，調用	
	}
	this.send = function(){
		
		this.Ajax.send(null);
		
		}//發送請求
	this.abort = function()//取消請求
	{
		this.Ajax.abort();
	}
	
}
