// JavaScript Document

var x,y,mX,mY,aH,aW,tH,tW;
var Act,ActId;
var bz=0;
document.onmousedown=function(){
	Act=event.srcElement;
	ActId=Act.id.toLowerCase();
	if(ActId.indexOf("moveimg")!=-1){
		x=parseInt(event.offsetX,10);
		y=parseInt(event.offsetY,10);
		aH=getHeight(Act);
		aW=getWidth(Act);
		bz=1;
		//alert(aW);
	}
}
document.onmousemove=function(){
	if(bz==1){
		mX=parseInt(event.offsetX,10);
		mY=parseInt(event.offsetY,10);
		tW=aW+mX-x;
		tH=aH+mY-y;
		if (tW>20){Act.width=tW;}
		if (tH>20){Act.height=tH;}
	}
}
document.onmouseup=function(){
	bz=0;
}

document.onclick=function(){
if (popbox) popbox.style.display="none";
}
rnd.today=new Date(); 
rnd.seed=rnd.today.getTime(); 
function rnd() { rnd.seed = (rnd.seed*9301+49297) % 233280;return rnd.seed/(233280.0);}
function rand(number) {return Math.ceil(rnd()*number);}


//获得鼠标指针的X坐标（相对于页面）
function getPointerX(){var x = getLeft(event.srcElement)+event.offsetX;return x;}
//获得鼠标指针的Y坐标（相对于页面）
function getPointerY(){var y = getTop(event.srcElement)+event.offsetY;return y;}
//获得对象的Y坐标（相对于页面）
function getTop(e){var t=e.offsetTop;while(e=e.offsetParent){t+=e.offsetTop;}return t;}
//获得对象的X坐标（相对于页面）
function getLeft(e){var l=e.offsetLeft;while(e=e.offsetParent){l+=e.offsetLeft;}return l;}
//获得对象的高度
function getHeight(e){var t=e.offsetHeight;return t;}
//获得对象的宽度
function getWidth(e){var t=e.offsetWidth;return t;}

//展开—隐藏论坛分类
function listMode(inId,inImg){
	var obj=eval("window.list_"+inId);
	if(inImg.src.indexOf("listhidden")!=-1){
		inImg.title="展开此分类";
		inImg.src="images/listshow.gif";
		obj.style.display="none";
	}else{
		inImg.title="收折此分类";
		inImg.src="images/listhidden.gif";
		obj.style.display="";
	}
}
//显示菜单，当前菜单ID，菜单类型
function showbbspop(inId,inType){
	var popCode;
	var popX,popY;
	if (inId==0&&inType==""){	return;}
	else{
		if (inType!="menupop"){
			popCode=getPop(inType);
		}else{
			popCode=getPop(inId);
		}
		popX=getLeft(event.srcElement)+10;
		popY=getTop(event.srcElement)+20;
		popbox.innerHTML='<layer bgcolor="#E6E6E6" width="165" onmouseover="clearhidpop()" onmouseout="delayhidpop()">'+popCode+'</layer>';
		popbox.style.left=popX;
		popbox.style.top=popY;
		popbox.style.display="";
	}
}
//隐藏菜单
function hidpop(){
	if (window.popbox)
		popbox.style.display="none";
}

function delayhidpop(){
		delayhide=setTimeout("hidpop()",500)
}
function clearhidpop(){if (window.delayhide){	clearTimeout(delayhide);}}
//菜单读取
function getPop(inVal){
	var readerr="<DIV class=\"popitem\"><a>读取错误</a> </DIV>";
	var objPop=eval("window.pop_"+inVal);
	if(objPop){return objPop.innerHTML;}
	else{return readerr;}
}
//检查用户登陆信息
function checkLogin(){
	var reg=/\d{4}/ig;
	if (formLogin.userName.value==""){
		alert("登陆名称不能为空!");
		formLogin.userName.focus();
		return false;
		}
	if (formLogin.password.value==""){
		alert("用户密码不能为空!");
		formLogin.password.focus();
		return false;
	}
	if (formLogin.chknum.value=="" || !reg.test(formLogin.chknum.value)){
		alert("请输入正确的验证码!");
		formLogin.chknum.focus();
		return false;
	}
}

//读取在线用户名单
function showUserLists(){
	window.userListBox.style.display='';
	window.hidframe.location='readonlineuser.asp';
}
//上传文件
function addannex(){
	var num=postform.upnum.value;
	if (num==""){num=1}
	num=parseInt(num,10);
	if (num<maxupfile){
		var last=eval("postform.annex"+num);
		if (last.value==""){alert("一次只能上传一个文件!");}
		else{
		num++;
		window.upfilebox.innerHTML+="<div><input name=\"annex\" type=\"text\" class=\"DIVinpu\" id=\"annex"+num+"\" size=\"35\"/></div>\n";
		fileframe.location="user_upfile.asp?formname=postform&textname=annex"+num+"&s="+bbsstyle;
		postform.upnum.value=num;
		}
	}else{
		alert("最多仅允许上传"+maxupfile+"个附件!");
	}
}
//发贴特殊功能
//review        回复贴
//integ         积分贴
//popedom       权限贴
//pass          密码贴
function bbsVIP(cmd){
	var reVal;
	reVal=null;
	switch(cmd){
		case "review" :
			reVal="[REVIEW]<p>在这里输入需要回复的内容</p>[/REVIEW]";
			break;
		case "integ" :
			reVal = prompt("请输入查看本贴内容需要达到的积分数", "0");
			reVal=parseInt(reVal,10);
			if (!isNaN(reVal)){reVal="[INTEG="+reVal+"]<p>&nbsp;</p>[/INTEG]"}
			else{reVal="";alert("您的输入有误!")}
			break;
		case "popedom" :
			reVal = prompt("请输入查看本贴内容需要达到的会员等级(每等级权限相差10)", "0");
			reVal=parseInt(reVal,10);
			if (!isNaN(reVal)){reVal="[POPE="+reVal+"]<p>&nbsp;</p>[/POPE]"}
			else{reVal="";alert("您的输入有误!")}
			break;
		case "pass" :
			reVal = prompt("请输入查看本贴内容需要的密码(请不要使用特殊符号)", "");
			var reg=/\s|\"|'|\[|\]|\(|\)/ig
			if (reVal!=null&&reVal!=""&&!reg.test(reVal)){reVal="[PASS="+reVal+"]<p>&nbsp;</p>[/PASS]"}
			else{reVal="";alert("您输入的密码无效!")}
			break;
	}
	postform.eTxt.value+=reVal;
	postform.eTxt.focus();
}
//查看投票用户
function showvote(path){
	window.open(path,"newWindow","height=400,width=300,top=200,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no, status=no");
	return false;
}


//论坛回复引用

function quote(intype,inId){
	var uname,utime,ucont;
	var qtime,qname,qcont;
	var qData;
	if (intype == 0 ){
		uname=eval("window.n_m_"+inId);
		utime=eval("window.t_m_"+inId);
		ucont=eval("window.c_m_"+inId);
	}else{
		uname=eval("window.n_r_"+inId);
		utime=eval("window.t_r_"+inId);
		ucont=eval("window.c_r_"+inId);
	}
	qtime=utime.innerHTML;
	qname=uname.innerHTML;
	qcont=ucont.innerHTML;
	qcont=qcont.replace(/<[^>]*>/ig,"");
	if (qcont.length>100){qcont=qcont.substr(0,100);}
	qData="<DIV style='border:1px dotted #FF9900; background:#FFFFE6;width:70%;text-align:center;margin-left:10px;height:70px;'>";
	qData+="<DIV style='text-align:left;padding-left:30px;border-bottom:1px dotted #f90;font-weight:bold;color:999;margin-left:5px;margin-right:5px;'>以下引用由<u style='color:#000;'>"+qname+"</u>于"+qtime+"的发言：</DIV>";
	qData+="<DIV style='text-align:left;padding-left:10px;'>"+qcont+"</DIV>";
	qData+="</DIV>";
	if (rebox.eTxt){
		rebox.eTxt.value+=qData;
		rebox.eTxt.focus();
	}
}
	
//提交帖子检查
function checkAdd(inKey){
	if (postform.title.value.replace(/\s/g,"")==""){
		alert("请输入主题!");
		postform.title.focus();
		return;
	}
	if (inKey=="vote"){
		if(postform.invtxt.value.replace(/\s|\n/ig,"")==""){
			alert("投票选项不能为空");
			postform.invtxt.focus();
			return;
		}
	}
	if(postform.eTxt.value.replace(/\s/g,"").length<5){
		alert("您输入的内容太短,不能提交.")
		postform.eTxt.focus();
		return;
	}
	var tit=postform.title.value;
	var cont=postform.eTxt.value;
	tit=tit.replace("<","&lt;");
	tit=tit.replace(">","&gt;");
	postform.title.value=tit;
	cont=cont.replace(/on(load|unload|click|dbclick|mouseover|mousedown|mouseup|focus|blur|keypress|keydown|keyup)=/ig," ");
	cont=cont.replace(/<script/ig,"<!--script");
	cont=cont.replace(/<\/script>/ig,"script-->");
	postform.contents.value=postform.eTxt.value;
	postform.submit()
}
//发表回复
function postreview(){
	if(rebox.eTxt.value.replace(/\s/g,"").length<5){
		alert("您输入的内容太短,不能提交.")
		rebox.eTxt.focus();
		return;
	}
	var cont=rebox.eTxt.value;
	cont=cont.replace(/on(load|unload|click|dbclick|mouseover|mousedown|mouseup|focus|blur|keypress|keydown|keyup)=/ig," ");
	cont=cont.replace(/<script/ig,"<!--script");
	cont=cont.replace(/<\/script>/ig,"script-->");
	rebox.contents.value=rebox.eTxt.value;
	rebox.submit()
}
//编辑回复
function postreviewedit(){
	if(postform.eTxt.value.replace(/\s/g,"").length<5){
		alert("您输入的内容太短,不能提交.")
		postform.eTxt.focus();
		return;
	}
	var cont=postform.eTxt.value;
	cont=cont.replace(/on(load|unload|click|dbclick|mouseover|mousedown|mouseup|focus|blur|keypress|keydown|keyup)=/ig," ");
	cont=cont.replace(/<script/ig,"<!--script");
	cont=cont.replace(/<\/script>/ig,"script-->");
	postform.contents.value=postform.eTxt.value;
	postform.submit()
}
//设置字体
function setFont()
{
  var arr = showModalDialog("editor/fontstyle.htm",null, "dialogWidth:350px;dialogHeight:200px;status:0;help:0;scroll:0");
  if (arr != null){
     postform.tstyle.value=arr;
     demostyle.innerHTML="<span "+arr+">标题样式ABCabc</span>";
  }
}
//****************************************************************
//功能：判断参数Str是不是数字
//参数：字符串
//返回值：是数字返回true，否则返回false
//****************************************************************
function isNumber(Str){  
	var reg=/\s/g;
	if(Str+""=="")
		return false;
	Str=Str.replace(reg,"");
	if(Str=="")
	{
		return false;
	}
	if(isNaN(Str))
	{
		return false;
	}
	else
	{
		var temp=parseInt(Str);
		if(temp<0)
			return false;
		else
			return true;
	}
}
//全选
function SelectAll(theForm)
{
	var theObjName=event.srcElement.name;
	var theObj=event.srcElement;
	var turn;
	if (theObj.checked){turn=true;}else{turn=false;}
	var length=theForm.elements[theObjName].length;
	var i;
	if(length+""=="undefined")
	{
		theForm.elements[theObjName].checked=turn;
	}
	else
	{
		for(i=0;i<length;i++)
		{
			theForm.elements[theObjName][i].checked=turn;
		}
	}	
}

