	/**
	*	名称:SAjax 异步请求
	*   author:chen.xiaojing
	*   date:2009-11-03
	*   使用方法：
	*  
	*   参数说明
	*		url：访问地址
	*		data: 检测标识
	*		success:成功后的方法；
	*		onerror: 失败后的方法。可选；
	*		interval: 测试间隔。可选；
	*		testcount: 测试次数。可选；
	*		catched: 是否有缓存。可选；
	*		new SAjax(url,CheckFlag,success,onerror,interval,testcount,catched);
	*
	*	示例:
	*	1、new SAjax(url, "data",function (){dowork2();},function (){error_deal();});
	*	2、new SAjax(url, "data",function (){dowork();});
	*/

	var SAjax_TimeHander = new Array();
	function  SAjax(url,CheckFlag,success,onerror,interval,testcount,catched){
		this.success =	success;		
		this.CheckFlag = CheckFlag;
		this.url = url;
		this.onError = onerror;
		this.interval = (typeof(interval)=="number")?interval:300;
		this.testcount = (typeof(testcount)=="number")?testcount:25;
		this.getdata = _getContent;
		this.catched = (typeof(catched)=="boolean")?catched:false;
		this.getdata();
		
	}
	function _getContent(){
		if(this.CheckFlag == "") alert("检测值为空");
		if(this.url == "") alert("url为空"); 
		var timerId = SAjax_TimeHander.length;
		var scriptid = "script_"+timerId; 
		var script = document.createElement("script"); 
			script.type ="text/javascript";
			script.id =scriptid;
			script.src= this.url;
		if(!this.catched){
			var clear = "var s ; "+this.CheckFlag + " =s;"; 
			eval(clear);
		}
		document.getElementsByTagName("head")[0].appendChild(script);
		if ( eval("  typeof("+this.CheckFlag+") == \"undefined\" ")){
			SAjax_TimeHander[timerId] = new Array();
		    SAjax_TimeHander[timerId][0] = 
			window.setInterval("SAjax_stop('"+timerId+"','"+this.CheckFlag+"','"+this.testcount+"','"+scriptid+"')", this.interval);
			SAjax_TimeHander[timerId][1] = 0; 
			SAjax_TimeHander[timerId][2] = this;
		}else{
			this.success();
		}
	}
	function SAjax_stop(timerId,CheckFlag,testcount,scriptid){ 
		if (eval("  typeof("+CheckFlag+") == \"undefined\" ") == false)
		{	
			window.clearInterval(SAjax_TimeHander[timerId][0]);
			if(typeof(SAjax_TimeHander[timerId][2].success) == "function")
				SAjax_TimeHander[timerId][2].success(); 
			var script = document.getElementById(scriptid);
			script.parentNode.removeChild(script); 
		}else{
			SAjax_TimeHander[timerId][1]++;
			if (SAjax_TimeHander[timerId][1] >testcount){
				window.clearInterval(SAjax_TimeHander[timerId][0]);
				SAjax_TimeHander[timerId][1] = 0;
				SAjax_error(timerId); 				
				var script = document.getElementById(scriptid);
				script.parentNode.removeChild(script); 
			}
		}
	}
	function SAjax_error( timerId){
		if(typeof(SAjax_TimeHander[timerId][2].onError) == "function")
			SAjax_TimeHander[timerId][2].onError();
	}

