/**//*
##  作者：夜无眠
##	QQ：27262681

此类用法示例
var a=new ajax();
function s(){
	a.send("a.php","a="+encodeURIComponent($("a").value),c,"GET");//GET为可选参数，默认值为POST
}
function c(msg){
	$("d").innerHTML=msg;
}
发送的值要用encodeURIComponent转义，变成URL专用编码！
*/
function fzz_ajax(){//参数为返回执行函数，this.reback为返回值
	this.timeout = 0;

	this.send=function (url,db,func,method){
		var callback=func;
		method=method?method:"POST";

		if(window.ActiveXObject){
			var http = new ActiveXObject("Microsoft.XMLHTTP");
		}else if(window.XMLHttpRequest){
			var http = new XMLHttpRequest();
		}

		var sf = this;//复制对象
		http.onreadystatechange=function () {
			sf.f(http,callback)
		}
		if(method=="GET"){
			url += url.indexOf('?') == -1 ? "?"+db : "&"+db;
			db=null;
		}
		http.open(method,url,true);
		http.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		http.send(db);
		if (sf.timeout > 0) {
			setTimeout(function () {http.abort();},sf.timeout);
		}
	}

	this.f=function (http,callback){
		if(http.readyState == 4){
			if(http.status == 200){
				var reback = http.responseText;
				callback(reback);
				http=null;//注销http实例
			}else {
				callback(false);
				http=null;//注销http实例
			}
		}
	}
}
function $(id){
	return document.getElementById(id);
}
function $name(name){
	return document.getElementsByName(name);
}
