// JavaScript Document
//检查是否为空
function check_null(outstr,text)
{
	if(text.value==""){
		alert(outstr+"不可以为空！");
		text.focus();
		return true;
	}
	return false;
}

//检查是否为特殊字符(',<,%,>,\)
function check_pec(outstr,text)
{
	var tmpvalue=text.value.replace(/ /g,"").replace(/　/g,"");
	text.value=tmpvalue;
	var i,j,patten;
	patten="'=＝｀～＋+<>%'\"\\☆￥#◎·“”¨！§№※→←↑↓ˇ〈〉＃$^&￥％＊《》『』〖〗【】⊙○◇◆□△▲●★☆■♀◆◥◤◣Ψ※→№←㊣∑⌒ξζω□∮〓※▓∏卐√∩¤々♀♂∞ㄨ≡↘↙＆◎Ю┼┏ ┓田┃▎○╪┗┛∴①②③④⑤⑥⑦⑧";
	for (i=0;i<tmpvalue.length;i++)
	{
		j=patten.indexOf(tmpvalue.charAt(i));
		if (j!=-1){
			alert(outstr+"中含有非法字符！");
			text.focus();
			return true;
		}
	}
	return false;
}

//检查文本框
function check_text(outstr,text){
	if(check_null(outstr,text)){return true;}
	if(check_pec(outstr,text)){return true;}
	return false;
}

//检查是否为不允许字符
function audit_string(patten,text,outstr){
	myRe=eval("/"+patten+"/g");
	myArray = myRe.exec(text);
	if(myArray!=null){
		alert(outstr+"中不能含'"+myArray[0]+"'字符！");
		return false;
	}
	return true;
}
function check_string(outstr,text){
	var tmpvalue=text.value.replace(/ /g,"").replace(/　/g,"");
	text.value=tmpvalue;
	if(audit_string('情色',tmpvalue,outstr)==false){return true;}
	if(audit_string('激情',tmpvalue,outstr)==false){return true;}
	if(audit_string('成人',tmpvalue,outstr)==false){return true;}
	if(audit_string('性爱',tmpvalue,outstr)==false){return true;}
	if(audit_string('性交',tmpvalue,outstr)==false){return true;}
	if(audit_string('小电影',tmpvalue,outstr)==false){return true;}
	if(audit_string('裸体',tmpvalue,outstr)==false){return true;}
	if(audit_string('一夜情',tmpvalue,outstr)==false){return true;}
	if(audit_string('色情',tmpvalue,outstr)==false){return true;}
	if(audit_string('A片',tmpvalue,outstr)==false){return true;}
	if(audit_string('强奸',tmpvalue,outstr)==false){return true;}
	if(audit_string('高潮',tmpvalue,outstr)==false){return true;}
	if(audit_string('美女',tmpvalue,outstr)==false){return true;}
	if(audit_string('偷窥',tmpvalue,outstr)==false){return true;}
	if(audit_string('偷拍',tmpvalue,outstr)==false){return true;}
	if(audit_string('三级',tmpvalue,outstr)==false){return true;}
	if(audit_string('3级',tmpvalue,outstr)==false){return true;}
	if(audit_string('美眉',tmpvalue,outstr)==false){return true;}
	if(audit_string('走光',tmpvalue,outstr)==false){return true;}
	return false;
}

//检查特殊文本框
function check_conn(outstr,text){
	if(check_null(outstr,text)){return true;}
	if(check_pec(outstr,text)){return true;}
	if(check_string(outstr,text)){return true;}
	return false;
}

////验证Email
function check_email(email){
	if(check_null("E-mail",email)){return true;}	
	var pattern = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/; 
	flag = pattern.test(email.value);
	if(email.value==""){
  		alert("请填写您的E-mail地址！");
		email.focus();
  		return true;
	}
	if(!flag) 
	{ 
　　		alert("请输入正确的E-mail地址！"); 
		email.focus();
　　		return true; 
	}
	return false;
}

//验证网站地址
function check_weburl(text){
	var pattern = /^(http:\/\/)+([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/; 
	flag = pattern.test(text.value);
	if(!flag){
		alert("请输入正确的网站域名！");
		text.focus();
		return true;
	}
	var tmpvalue=text.value.replace(/http:\/\//g,"");
	var i,j,strTemp;
	strTemp="\/\\";
	for (i=0;i<tmpvalue.length;i++)
	{
		j=strTemp.indexOf(tmpvalue.charAt(i));
		if (j!=-1){
			alert("网站域不接受站点内单独页面的地址！");
			text.focus();
			return true;
		}
	}
	return false;
}

//验证密码
function check_psdlen(passwd){
  if(passwd.value.length < 6 || passwd.value.length > 20){
  	alert("密码长度必须为6-20位！");
	passwd.focus();
  	return true;
  }
  return false;
}

function check_psd(passwd,passwd1){
  if(passwd.value=="" || passwd1.value=="" || (passwd.value!=passwd1.value)){
  	alert("您输入的密码验证与密码不一致！");
	passwd1.focus();
  	return true;
  }
  if(check_psdlen(passwd)){return true;}
  return false;
}



//show
function trackmouse(evt){
	if((currIDb!=null) && (currIDs!=null)){
		var x=(IE5)? event.clientX+document.body.scrollLeft : evt.pageX;
		var y=(IE5)? event.clientY+document.body.scrollTop : evt.pageY;
		currIDb.style.left=x+xoff+'px';
		currIDs.style.left=x+xoff+10+'px';
		currIDb.style.top=y+yoff+'px';
		currIDs.style.top=y+yoff+10+'px';
		return false;
	}
}

function stopdrag(){
	currIDb=null;
	currIDs=null;
	NS6bugfix();
}

function grab_id(evt){
	xoff=parseInt(this.IDb.style.left)-((IE5)? event.clientX+document.body.scrollLeft : evt.pageX);
	yoff=parseInt(this.IDb.style.top)-((IE5)? event.clientY+document.body.scrollTop : evt.pageY);
	currIDb=this.IDb;
	currIDs=this.IDs;
}

function NS6bugfix(){
	if(!IE5){
	self.resizeBy(0,1);
	self.resizeBy(0,-1);
	}
}

function incrzindex(){
	zctr=zctr+2;
	this.subb.style.zIndex=zctr;
	this.subs.style.zIndex=zctr-1;
}

function createPopup(id, title, width, height, x , y , isdraggable, boxcolor, barcolor, shadowcolor, text, textcolor, textptsize, textfamily ){
	if(W3C){
		zctr+=2;
		totz=zctr;
		var txt='';
		txt+='<div id="'+id+'_s" style="position:absolute; left:'+(x+10)+'px; top:'+(y+10)+'px; width:'+width+'px; height:'+height+'px; background-color:'+shadowcolor+'; filter:alpha(opacity=50); visibility:visible">&nbsp;</div>';
		txt+='<div id="'+id+'_b" style="border:outset '+barcolor+' 2px; position:absolute; left:'+x+'px; top:'+y+'px; width:'+width+'px; overflow:hidden; height:'+height+'px; background-color:'+boxcolor+'; visibility:visible">';
		txt+='<div style="width:'+width+'px; height:16px; background-color:'+barcolor+'; padding:0px; border:1px"><table cellpadding="0" cellspacing="0" border="0" width="'+(IE5? width-4 : width)+'"><tr><td width="'+(width-20)+'"><div id="'+id+'_h" style="width:'+(width-20)+'px; height:14px; font: size 9px; sans-serif; color:'+textcolor+'">&nbsp;'+title+'</div></td><td align="right"><a onmousedown="document.getElementById(\''+id+'_s\').style.display=\'none\'; document.getElementById(\''+id+'_b\').style.display=\'none\';return false"><img src="images/closeb.gif" border="0" height="15" width="15"></a></td></tr></table></div>';
		txt+='<div id="'+id+'_ov" width:'+width+'px; style="margin:2px; color:'+textcolor+'; font:'+textptsize+'pt '+textfamily+';">'+text+'</div></div>';
		document.write(txt);
		this.IDh=document.getElementById(id+'_h');
		this.IDh.IDb=document.getElementById(id+'_b');
		this.IDh.IDs=document.getElementById(id+'_s');
		this.IDh.IDb.subs=this.IDh.IDs;
		this.IDh.IDb.subb=this.IDh.IDb;
		this.IDh.IDb.IDov=document.getElementById(id+'_ov');
		if(IE5){
			this.IDh.IDb.IDov.style.width=width-6;
			this.IDh.IDb.IDov.style.height=height-22;
			this.IDh.IDb.IDov.style.scrollbarBaseColor=boxcolor;
			this.IDh.IDb.IDov.style.overflow="auto";
		}else{
			this.IDh.IDs.style.MozOpacity=.5;
		}
		this.IDh.IDb.onmousedown=incrzindex;
		if(isdraggable){
			this.IDh.onmousedown=grab_id;
			this.IDh.onmouseup=stopdrag;
		}
	}
}

function GetCookieVal(offset){ //获得Cookie解码后的值 
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

function SetCookie(name, value){ //设定Cookie值
	var expdate = new Date();
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	var path = (argc > 3) ? argv[3] : null;
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;
	if(expires!=null) expdate.setTime(expdate.getTime() + ( expires * 1000 ));
	document.cookie = name + "=" + escape (value) +((expires == null) ? "" : ("; expires="+ expdate.toGMTString()))+((path == null) ? "" : ("; path=" + path)) +((domain == null) ? "" : ("; domain=" + domain))+((secure == true) ? "; secure" : "");
}

function DelCookie(name){//删除Cookie
	var exp = new Date();
	exp.setTime (exp.getTime() - 1);
	var cval = GetCookie (name);
	document.cookie = name + "=" + cval + "; expires="+ exp.toGMTString();
}

function GetCookie(name) { //获得Cookie的原始值
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen)
	{
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg)
		return GetCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return null;
}