function myAjax(){

	this.t_id = null;
	this.pos=0;
	this.dir=2;
	this.len=0;
	this.xhttp = null;
	this.xdom = null;
	this.rText='';


	this.keys = Array();
	this.values = Array();
	this.keyCount = -1;


	this.rkeys = Array();
	this.rvalues = Array();
	this.rkeyCount = -1;

	this.rtype = 'text';


	if(window.XMLHttpRequest){//IE7, Mozilla ,Firefox
		this.xhttp = new XMLHttpRequest();
	}else if(window.ActiveXObject){//IE6
		try { this.xhttp = new ActiveXObject("Msxml2.XMLHTTP");} catch (e) { }
		if (this.xhttp == null) try { this.xhttp = new ActiveXObject("Microsoft.XMLHTTP");} catch (e) { }
	}

	this.InitXDom = function(){
		var obj = null;
		if (typeof(DOMParser) != "undefined") { //
			var parser = new DOMParser();
			obj = parser.parseFromString(xmlText, "text/xml");
		} else { // IE
			try { obj = new ActiveXObject("MSXML2.DOMDocument");} catch (e) { }
			if (obj == null) try { obj = new ActiveXObject("Microsoft.XMLDOM"); } catch (e) { }
		}
		this.xdom = obj;
	};


	this.AddKey = function(skey,svalue){
		this.keyCount++;
		this.keys[this.keyCount] = skey;
		this.values[this.keyCount] = svalue;
	};


	this.AddHead = function(skey,svalue){
		this.rkeyCount++;
		this.rkeys[this.rkeyCount] = skey;
		this.rvalues[this.rkeyCount] = svalue;
	};


	this.ClearSet = function(){
		this.keyCount = -1;
		this.keys = Array();
		this.values = Array();
		this.rkeyCount = -1;
		this.rkeys = Array();
		this.rvalues = Array();
	};

	this.SendHead = function(){
		if(this.rkeyCount!=-1){
			for(;i<=this.rkeyCount;i++){
				this.xhttp.setRequestHeader(this.rkeys[i],this.rvalues[i]);
			}
		}if (this.rtype=='binary'){
			this.xhttp.setRequestHeader("Content-Type","multipart/form-data");
		}else{
			this.xhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		}
	};


	this.SendPost = function(purl){
		var pdata = "";
		var i=0;
		this.state = 0;
		if(purl.indexOf('?')==-1) purl = purl + '?';
		purl = purl + '&rand=' + Math.random();
		this.xhttp.open("POST", purl, true);
		this.SendHead();
		if(this.keyCount!=-1){ //post
			for(;i<=this.keyCount;i++){
				if(pdata=="") pdata = this.keys[i]+'='+this.values[i];
				else pdata += "&"+this.keys[i]+'='+this.values[i];
			}
		}
		// alert(pdata);
		this.xhttp.send(pdata);
	};


	this.SendGet = function(purl){
		try{
			var gkey = "";
			var i=0;
			this.state = 0;
			if(purl.indexOf('?')==-1) purl = purl + '?';
			if(this.keyCount!=-1){ //get
				for(;i<=this.keyCount;i++){

					if(gkey=="") gkey = this.keys[i]+'='+this.values[i];
					else gkey += "&"+this.keys[i]+'='+this.values[i];
				}
				purl = purl + '&' + gkey;
			}
			purl = purl + '&rand=' +  Math.random();
			this.xhttp.open("GET", purl, true);
			this.SendHead();
			this.xhttp.send();
		}catch(e){
			
		}
	};

	this.ToDo=function(Doing,Done,varDoing,varDone){
		var xhttp = this.xhttp;
		this.xhttp.onreadystatechange= function () {
			if(xhttp.readyState != 4){

				Doing(varDoing);
			}else if(xhttp.readyState == 4 && xhttp.status == 200){
				Done(xhttp,varDone);
			}
		}
	};

	this.delSelectValue=function(dGetObj,setValue){
		for(var d=0; d<dGetObj.options.length;d++){
			if(setValue==dGetObj.options[d].value){
				getDown(getObj,d);
				dGetObj.options.length --;
				ii--;
				//alert(dGetObj.options.length);
				return;
			}
		}
	}
	this.delSelect = function(dGetObj,n){
		var m = dGetObj.length;
		for(var i = n; i <= m; i++){
			dGetObj.remove(i);
		}
		return dGetObj.length;
	}
	this.buildSelect = function(id,arr){
		var alength = arr.length;
		var temp = new Array();
		$ID(id).options.length = 0 ;
		//var t = this.delSelect($ID(id),1);
		if(alength==0) return;
		for(var m=0;m<alength;m++){
			temp = arr[m].split(',');

			if(temp[1] == "" || temp[0] == "") continue;
			$ID(id).options[m] = new Option(temp[1],temp[0]);
		}

	}
	this.clearSelect=function(id){
		$ID(id).options.length=0;
	}
}
