function AJAX(G)
{
	//1=undefined
	var K=[],S=this,L=AJAX.__pool__||(AJAX.__pool__=[]);
	(function(E)//初始化
			  {
				  var D=function(){};
				  E=E?E:{};
				  var C=["url","content","method","async","encode","timeout","ontimeout","onrequeststart","onrequestend","oncomplete","onexception"]
				  var A=["","","GET",true,I("GBK"),3600000,D,D,D,D,D]
				  var B=C.length;//=11
				  while(B--)
				  {
				  	S[C[B]]=_(E[C[B]],A[B]);
				  	//S["onexception"]=_(E["onexception"],"function(){}");
					//S["onexception"]="function(){}"
				  }
				  if(!N())
				  return false
			 })(G);
	function _(_,S)//(1)定义了就为(1)否则为(2)
	{
		return _!=undefined?_:S
	}
	function N()//返回AJAX的载入状态
	{
		var A,S=[window.XMLHttpRequest,"MSXML2.XMLHTTP","Microsoft.XMLHTTP"];
		///测试下对象 window.ActiveXObject是否有效，这个对象只在IE5.5以上的版本中有效。
		for(var B=0;B<L.length;B+=1)//1
		{
			if(L[B].readyState==0||L[B].readyState==4) return L[B];
		/*	if([object].readyState==0||[object].readyState==4)return L[B];
				IE的XML DOM拥有一个readyState值用来表示载入文件的状态：
				0——准备载入
				1——正在载入
				2——载入完成
				3——载入完成并可用，但有一部分数据也许不可用
				4——完全载入，完全可用。
		*/
		}
		for(B=0;B<S.length;B+=1)
		{
			try
			{
				A=(S[B]&&typeof(S[B])=="function"?new S[B]:new ActiveXObject(S[B]));
				break
			}
			catch(_)
			{
				A=false;continue
			}
		}
		if(!A)
		{
			throw"Cannot init XMLHttpRequest object!";
			return false
		}
		else
		{
			L[L.length]=A;
			return A
		}
	}
	function E(S)
	{
		return document.getElementById(S)
	}
	function C(S)
	{
		var _=S*1;
		return(isNaN(_)?0:_)
	}
	function D(S)
	{
		return(typeof(S)=="string"?(S=E(S))?S:false:S)
	}
	function F()//返回当前时间的数字形式
	{
		return((new Date)*1)
		//return((Sun Jul 4 08:42:00 UTC+0800 2010)*1)
		//return(1278203849781)
	}
	function M(S,_)
	{
		K[S+""]=_
	}
	function H(S)
	{
		return(K[S+""])
	}
	function J(_,S,B)
	{
		return(function A(C)
						  {
							  C=C.replace(/([^\u0080-\u00FF]+)/g,function(S0,S1)
																		  {
																			  return _(S1)
																			}
																			).replace(/([\u0080-\u00FF])/g,function(S0,S1)
																			{
																				return escape(S1).replace("%","%u00")
																			}
																			);
							  for(var E=0,D=S.length;E<D;E+=1)
							  C=C.replace(S[E],B[E]);
							  return(C)
						}
						)
	}
	function I(S)
	{
		if(S.toUpperCase()=="UTF-8")
		return(encodeURIComponent);
		else
		return(J(escape,[/\+/g],["%2B"]))
	}
	function O(A,B)
	{
		if(!A.nodeName)
		return;
		var _="|"+A.nodeName.toUpperCase()+"|";
		if("|INPUT|TEXTAREA|OPTION|".indexOf(_)>-1)
		A.value=B;
		else
		{
			try
			{
				A.innerHTML=B
			}
			catch(S){}
		}
	}
	function P(_)
	{
		if(typeof(_)=="function")
		return _;
		else
		{
			_=D(_);
			if(_)
			return(function(S)
							{
								O(_,S.responseText)
							}
							);
			else
			return S.oncomplete
		}
	}
	function B(_,A,S)//设置属性并返回一个数组。(1)数组为效验值。(2)数组为默认值。(3)数组为二级效验值。
	{
		//1=[object Object]		2='"","","function(){}","GET","true",'		3=',,函数,,,'
		var C=0,B=[];
		while(C<_.length)//6
		{
			B[C]=_[C]?(S[C]?S[C](_[C]):_[C]):A[C];
			//B[0]=_[0]?(S[0]?S[0](_[0]):_[0]):A[0];
			//B[0]=_[0]?(null?null(_[0]):_[0]):A[0];
			//B[0]=内容?(null?null(内容):内容):"";
			//B[0]=内容?内容:"";
			//B[0]=内容
			//B[0]="admin_gather.asp?action=proxy&result=true&charset=UTF-8&url=http%3A//hd.openv.com/inc_play-hdmovie_20100702_7228025.html"
			C+=1
		}
		while(C<A.length)//while(6<6)
		{
			B[C]=A[C];
			C+=1
		}
		return B
	}
	function A()
	{
		var E,C=false,K=N()
		//function N()//返回AJAX的载入状态
		var J=B(arguments,[S.url,S.content,S.oncomplete,S.method,S.async,null],[null,null,P,null,null,null])
		//J=B(arguments,["","","function(){}","GET","true",null],[null,null,函数,null,null,null])
		//function B(_,A,S)//设置属性并返回一个数组。(1)数组为效验值。(2)数组为默认值。(3)数组为二级效验值。
		var G=J[0],I=J[1],L=J[2],M=J[3],H=J[4],A=J[5]
		//G="admin_gather.asp?action=proxy&result=true&charset=UTF-8&url=http%3A//hd.openv.com/inc_play-hdmovie_20100702_7228025.html"
		//I=""	L=内容	M="GET"	H=true	A=null
		var O=M.toUpperCase()=="POST"?true:false;//false
		if(!G)//false
		{
			throw"url is null";
			return false
		}
		var _=
		{
			url:G,content:I,method:M,params:A
		};
		K.open(M,G,H);
		//M="GET"		//G="admin_gather.asp?action=proxy&result=true&charset=UTF-8&url=http%3A//hd.openv.com/inc_play-hdmovie_20100702_7228025.html&timestamp=1278203849781"
		//H=true
		S.onrequeststart(_);//在onrequeststart对象中定义(1)属性
		if(O)//false
		K.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		//setRequestHeader()向一个打开但未发送的请求设置或添加一个 HTTP 请求。
		//CONTENT-TYPE:application/x-www-form-urlencoded含义是表示客户端提交给服务器文本内容的编码方式 是URL编码，即除了标准字符外，每字节以双字节16进制前加个“%”表示

		K.setRequestHeader("X-Request-With","XMLHttpRequest");
		E=setTimeout(function()
							  {
								  C=true;
								  K.abort()
								},S.timeout);
		var D=function()
		{
			if(C)
			{
				S.ontimeout(_);
				S.onrequestend(_)
			}
			else if(K.readyState==4)
			{
				clearTimeout(E);
				_.status=K.status;
				try
				{
					if(K.status==200)
					L(K,A);
					else 
					S.onexception(_)
				}
				catch(B)
				{
					S.onexception(_)
				}
				S.onrequestend(_)
			}
		};
		K.onreadystatechange=D;
		if(O)
		K.send(I);
		else
		K.send("");
		if(H==false)
		D();
		return true
	}
	this.setcharset=function(_)
	{
		if(!S.encode)
		S.encode=I(_)
	};
	this.get=function(C,B,_)
	{
		/*	
		1="admin_gather.asp?action=proxy&result=true&charset=UTF-8&url=http%3A//hd.openv.com/inc_play-hdmovie_20100702_7228025.html"
		2="function (Q)
			{
				var txt=Q.responseText;//内容
				if(txt!="err" && txt!="ok")
				cache[url]=txt;//内容
				fun(Q);
			}"
		3=undefined
		*/
		return A(C,"",B,"GET",S.async,_)
		//5=true	6=undefined
	};
	this.update=function(H,J,_,D,E)
	{
		_=C(_);
		D=C(D);
		if(_<1)
		D=1;
		var B=function()
		{
			A(J,"",H,"GET",S.async,E)
		}
		var G=F()
		var I=function(S)
		{
			B();
			S--;
			if(S>0)
			M(G,setTimeout(function(){I(S)},_))
		};
		I(D);
		return G
	};
	this.stopupdate=function(S)
	{
		clearTimeout(H(S))
	};
	this.post=function(D,_,C,B)
	{
		return A(D,_,C,"POST",S.async,B)
	};
	this.postf=function(O,J,B)
	{
		var H=[],L,_,G,I,M
		var K=arguments.length,C=arguments;O=O?D(O):false;
		if(!O||O.nodeName!="FORM")
		return false;
		validfoo=O.getAttribute("onvalidate");
		validfoo=validfoo?(typeof(validfoo)=="string"?new Function(validfoo):validfoo):null;
		if(validfoo&&!validfoo())
		return false;
		var E=O.getAttribute("action"),N=O.getAttribute("method"),F=S.formToStr(O);
		if(F.length==0)
		return false;
		if(N.toUpperCase()=="POST")
		return A(E,F,J,"POST",true,B);
		else
		{
			E+=(E.indexOf("?")>-1?"&":"?")+F;
			return A(E,"",J,"GET",true,B)
		}
	};
	this.formToStr=function(C)
	{
		var B="",E="",_,A;
			for(var D=0;D<C.length;D+=1)
			{
				_=C[D];
				if(_.name!="")
				{
					switch(_.type)
					{
						case"select-one":
						if(_.selectedIndex>-1)
						A=_.options[_.selectedIndex].value;
						else 
						A="";
						break;
						case"checkbox":
						case"radio":
						if(_.checked==true)
						A=_.value;
						break;
						default:
						A=_.value
					}
				A=S.encode(A);B+=E+_.name+"="+A;E="&"
				}
			}
		return B
	}
}
//-------------------------------------------------------

function S(id)
{
	return document.getElementById(id)	
}

function textareasize(obj){
	if(obj.scrollHeight > 70){
		obj.style.height = obj.scrollHeight + 'px';
	}
}

function set(obj,value){
	obj.innerHTML = value
}

function view(id)
{//a="gMenuMap"
	S(id).style.display='inline'
	//inline  : CSS1  内联对象的默认值。将对象强制作为内联对象呈递，从对象中删除行 
}

function hide(id)//隐藏(a)
{
	S(id).style.display='none'		
}

function getScroll(){var t;if(document.documentElement&&document.documentElement.scrollTop){t=document.documentElement.scrollTop;}else if(document.body){t=document.body.scrollTop;}return(t);} 


function HtmlEncode(str)
{   
	 var s = "";
	 if(str.length == 0) return "";
	 s    =    str.replace(/&/g,"&amp;");
	 s    =    s.replace(/</g,"&lt;");
	 s    =    s.replace(/>/g,"&gt;");
	 s    =    s.replace(/ /g,"&nbsp;");
	 s    =    s.replace(/\'/g,"&#39;");
	 s    =    s.replace(/\"/g,"&quot;"); 
	 return   s;   
}  

function getElementsByName(tag,name){
    var rtArr=new Array();
    var el=document.getElementsByTagName(tag);
    for(var i=0;i<el.length;i++){
        if(el[i].name==name)
              rtArr.push(el[i]);
    }
    return rtArr;
}

function closeWin(){
	document.body.removeChild(S("bg")); 
	document.body.removeChild(S("msg"));
	if(S("searchtype"))S("searchtype").style.display="";
}

function openWindow(zindex,width,height,alpha){
	var iWidth = document.documentElement.scrollWidth; 
	var iHeight = document.documentElement.clientHeight; 
	var bgDiv = document.createElement("div");
	bgDiv.id="bg";
	bgDiv.style.cssText = "top:0;width:"+iWidth+"px;height:"+document.documentElement.scrollHeight+"px;filter:Alpha(Opacity="+alpha+");opacity:0.3;z-index:"+zindex+";";
	document.body.appendChild(bgDiv); 
	var msgDiv=document.createElement("div");
	msgDiv.id="msg";
	msgDiv.style.cssText ="z-index:"+(zindex+1)+";width:"+width+"px; height:"+(parseInt(height)-0+29+16)+"px;left:"+((iWidth-width-2)/2)+"px;top:"+(getScroll()+(height=="auto"?150:(iHeight>(parseInt(height)+29+2+16+30)?(iHeight-height-2-29-16-30)/2:0)))+"px";
	msgDiv.innerHTML="<div class='msgtitle'><div id='msgtitle'></div><img onclick='closeWin()' src='/"+sitePath+"pic/btn_close.gif' /></div><div id='msgbody' style='height:"+height+"px'></div>";
	document.body.appendChild(msgDiv);
}

function openWindow2(zindex,width,height,alpha){
	var iWidth = document.documentElement.scrollWidth; 
	var bgDiv = document.createElement("div");
	bgDiv.id="bg";
	bgDiv.style.cssText = "top:0;width:"+iWidth+"px;height:"+document.documentElement.scrollHeight+"px;filter:Alpha(Opacity="+alpha+");opacity:0.3;z-index:"+zindex+";";
	document.body.appendChild(bgDiv); 
	var msgDiv=document.createElement("div");
	msgDiv.id="msg";
	msgDiv.style.cssText ="position: absolute;z-index:"+(zindex+1)+";width:"+width+"px; height:"+(height=="auto"?height:(height+"px"))+";";
	document.body.appendChild(msgDiv);	
}

function selectTogg(){
	var selects=document.getElementsByTagName("select");
	for(var i=0;i<selects.length;i++){
		selects[i].style.display=(selects[i].style.display=="none"?"":"none");
	}
}
function checkInput(str,type){
	switch(type){
		case "mail":
			if(!/^([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/gi.test(str)){alert('邮箱填写错误');return false;}
			break;
		case "num" :
			if(isNaN(str)){alert('QQ填写错误');return false;}
			break;
	}
	return true;
}

function copyToClipboard(txt) {    
	if(window.clipboardData){    
		window.clipboardData.clearData();    
		window.clipboardData.setData("Text", txt);
		alert('复制成功！')
	}else{
		alert('请手动复制！')	
	}   
}
function   getUrlArgs()
{   
	return  location.pathname;
}
function setCookie(name, value, ihour) {
	var iH = ihour || 1;
	var exp = new Date;
	exp.setTime(exp.getTime() + iH * 60 * 60 * 1000);
	document.cookie = name + ("=" + escape(value) + ";expires=" + exp.toGMTString() + ";path=/;");
}

function getCookie(name) {
	var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
	if (arr != null) {
		return unescape(arr[2]);
	}
	return null;
}

