	function openHelp(){var o=document.getElementById("Help");o.style.display=="none"?o.style.display="block":o.style.display="none";}
	function TitleonClick(o){if (o.value==document.getElementById("DefaultTitleValue").innerText){o.value="";}}
	function TitleonBlur(o){if (o.value==""){o.value=document.getElementById("DefaultTitleValue").innerText;}}
	function Tabs(o){
		document.getElementById("Login").style.display="none";
		document.getElementById("Reg").style.display="none";
		document.getElementById(o).style.display="";
		document.getElementById("aLogin").className="Tab";
		document.getElementById("aReg").className="Tab";
		document.getElementById("a"+o).className="Tabs";
		}
	var IsSubmitMail=0;
	function FormSaveCheck(o){
		var Tips=document.getElementById("NoteTips");
		Tips.innerHTML="正在操作..."
		if((o.Title.value=="")&&(o.Content.value=="")){Tips.innerHTML="标题和内容必须填写其中一个...";IsSubmitMail=0;return false;}
		if((o.UserID.value=="")&&(IsSubmitMail==0)){Tips.innerHTML="用户名/ID 必须输入...";IsSubmitMail=0;return false;}
		IsSubmitMail=0;
	}
	function submitMailClick(){
		var o=document.getElementById("SaveForm");
		reg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,64}){1,2})$/;
		if((reg.test(o.Title.value))&&(o.UserID.value=="")){IsSubmitMail=1;}
	}
	var tempReg="1";
	function RegFormCheck(o){
		var Tips=document.getElementById("RegTips");
		if(tempReg==0){Tips.innerHTML="该用户名已被注册，请重新选择";;return false;}
		document.getElementById("Reg").getElementsByTagName("span")[0].innerHTML="*";
		var UserName=o.UserName.value;
		var Password=o.Password.value;
		var RePassword=o.RePassword.value;
		Tips.innerHTML="正在检测...<br />";
		if((UserName.length<4)||(UserName.length>20)){Tips.innerHTML="用户名为4-20位，字母或数字";return false;}
		var reg = /^[a-zA-Z]{1}([a-zA-Z0-9]){3,19}$/;
		if(reg.test(UserName)==false){Tips.innerHTML="用户名为字母或数字，且字母开头";return false;}
		if(Password.length<4){Tips.innerHTML="登录密码至少五位字符..."; return false;}
		if(Password!==RePassword){Tips.innerHTML="两次密码输入不一致..."; return false;}
		reg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,64}){1,2})$/;
		if(reg.test(o.Email.value)==false){Tips.innerHTML="电子邮箱地址格式不正确..."; return false;}
	}
	function ChangeFormCheck(o){
		var Tips=document.getElementById("ChangeTips");
		var Password=o.Password.value;
		Tips.innerHTML="正在检测...<br />";
		if((Password.length<4)&&(Password.length>0)){Tips.innerHTML="登录密码至少五位字符..."; return false;}
		reg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,64}){1,2})$/;
		if(reg.test(o.Email.value)==false){Tips.innerHTML="电子邮箱地址格式不正确..."; return false;}
	}
	function RegUserCheck(){
		var UserNameIsRight=0;
		var UserName=document.getElementById("Reg").getElementsByTagName("input")[0].value;
		var Tips=document.getElementById("RegTips");
		if((UserName.length<4)||(UserName.length>20)){Tips.innerHTML="用户名为4-20位，字母或数字";;}
		if (UserNameIsRight==0){var reg = /^[a-zA-Z]{1}([a-zA-Z0-9]){3,19}$/;
		if(reg.test(UserName)==false){Tips.innerHTML="用户名为字母或数字，且字母开头";UserNameIsRight=1;}}
		if (UserNameIsRight==0){
			var Reg=document.getElementById("Reg").getElementsByTagName("span")[0];
			var ajax=new AJAXRequest;
			var sRnd=Math.floor(Math.random()*100000)+1;
			ajax.get("?Action=RegCheck&UserName=" + UserName + "&Rnd="+sRnd,
				function(obj) { 
					var s=obj.responseText;
					if(s=="yes"){
						Reg.innerHTML="√";
						Tips.innerHTML="恭喜你，该用户名可以注册<br />";
						tempReg="1";
					}else{
						Reg.innerHTML="×";
						Tips.innerHTML="<strong>很遗憾，该用户名已被注册</strong><br />";
						tempReg="0";
					}
				}
			);
		}
	}
	function CtrlEnter(){
		if ((event.keyCode==13)&&(event.ctrlKey)){document.getElementById("submitSave").click();}
		if ((event.keyCode==13)&&(event.shiftKey)){document.getElementById("submitMail").click();}
	}
	function DelAlert(){
		if (!confirm("确定执行该操作吗？\n\n该操作可能无法挽回...")){return false;}
	}
	function setPlayerHeight(v){
		var o=document.getElementById("PaPaPlayer");
		o.style.height=(o.offsetHeight+v) + "px";
	}
//=========================AJAX======================
function AJAXRequest() {
	var xmlObj = false;
	var CBfunc,ObjSelf;
	ObjSelf=this;
	try { xmlObj=new XMLHttpRequest; }
	catch(e) {
		try { xmlObj=new ActiveXObject("MSXML2.XMLHTTP"); }
		catch(e2) {
			try { xmlObj=new ActiveXObject("Microsoft.XMLHTTP"); }
			catch(e3) { xmlObj=false; }
		}
	}
	if (!xmlObj) return false;
	if(arguments[0]) this.url=arguments[0]; else this.url="";
	if(arguments[1]) this.callback=arguments[1]; else this.callback=function(obj){return};
	if(arguments[2]) this.content=arguments[2]; else this.content="";
	if(arguments[3]) this.method=arguments[3]; else this.method="POST";
	if(arguments[4]) this.async=arguments[4]; else this.async=true;
	this.send=function() {
		var purl,pcbf,pc,pm,pa;
		if(arguments[0]) purl=arguments[0]; else purl=this.url;
		if(arguments[1]) pc=arguments[1]; else pc=this.content;
		if(arguments[2]) pcbf=arguments[2]; else pcbf=this.callback;
		if(arguments[3]) pm=arguments[3]; else pm=this.method;
		if(arguments[4]) pa=arguments[4]; else pa=this.async;
		if(!pm||!purl||!pa) return false;
		xmlObj.open (pm, purl, pa);
		if(pm=="POST") xmlObj.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		xmlObj.onreadystatechange=function() {
			if(xmlObj.readyState==4) {
				if(xmlObj.status==200) {
					pcbf(xmlObj);
				}
				else {
					pcbf(null);
				}
			}
		}
		if(pm=="POST")
			xmlObj.send(pc);
		else
			xmlObj.send("");
	}
	this.get=function() {
		var purl,pcbf;
		if(arguments[0]) purl=arguments[0]; else purl=this.url;
		if(arguments[1]) pcbf=arguments[1]; else pcbf=this.callback;
		if(!purl&&!pcbf) return false;
		this.send(purl,"",pcbf,"GET",true);
	}
	this.post=function() {
		var fo,pcbf,purl,pc,pm;
		if(arguments[0]) fo=arguments[0]; else return false;
		if(arguments[1]) pcbf=arguments[1]; else pcbf=this.callback;
		if(arguments[2])
			purl=arguments[2];
		else if(fo.action)
			purl=fo.action;
		else
			purl=this.url;
		if(arguments[3])
			pm=arguments[3];
		else if(fo.method)
			pm=fo.method.toLowerCase();
		else
			pm="post";
		if(!pcbf&&!purl) return false;
		pc=this.formToStr(fo);
		if(!pc) return false;
		if(pm) {
			if(pm=="post")
				this.send(purl,pc,pcbf,"POST",true);
			else
				if(purl.indexOf("?")>0)
					this.send(purl+"&"+pc,"",pcbf,"GET",true);
				else
					this.send(purl+"?"+pc,"",pcbf,"GET",true);
		}
		else
			this.send(purl,pc,pcbf,"POST",true);
	}
	this.formToStr=function(fc) {
		var i,query_string="",and="";
		for(i=0;i<fc.length;i++) {
			e=fc[i];
			if (e.name!='') {
				if (e.type=='select-one') {
					element_value=e.options[e.selectedIndex].value;
				}
				else if (e.type=='checkbox' || e.type=='radio') {
					if (e.checked==false) {
						continue;	
					}
					element_value=e.value;
				}
				else {
					element_value=e.value;
				}
				element_value=encodeURIComponent(element_value);
				query_string+=and+e.name+'='+element_value;
				and="&";
			}
		}
		return query_string;
	}
}