

//显示顶部的导航登录条
showheader();
try
{
	Tx_MainBarInit("100%");//顶部登录条
}
catch(err){}
document.write("<div style='height:8px;'></div>");

function TxBBS_Active(srcObj)
{
	srcObj.className = "active";
}
function TxBBS_NotActive(srcObj)
{
	srcObj.className = "notactive";
}
function TxBBS_Jiangli(srcObj,postID,type)
{
	//alert(postID);
	document.getElementById("hiddendiv").innerHTML = "<iframe width=0 height=0 src='Admin/JiangLi.aspx?PostID="+postID+"&ThreadID=" + ThreadID + "&type=" + type + "' ></iframe>";
	srcObj.className = "active";
	srcObj.onclick = null;
	srcObj.onmouseleave = null;
	srcObj.onmouseenter = null;
}

function TxBBS_ShowPostAds()//显示帖子间的文字广告
{
	try
	{
		var flooradi = 0;
		var FloorPostAdList = document.getElementsByTagName("span");
		for(var i=0;i<FloorPostAdList.length;i++)
		{
			if(FloorPostAdList[i].id =="floorpostad")
			{
				FloorPostAdList[i].innerHTML = FloorPostAdHTML[flooradi];
				flooradi++;
				if(flooradi>FloorPostAdHTML.length-1)
				{
					flooradi = 0;
				}
			}
		}
	}
	catch(err){}
}

function TxBBS_CopyToClipBoard()
{
   var clipBoardContent=""; 
   clipBoardContent+=document.title;
   clipBoardContent+="\r\n"+document.location.href;
   window.clipboardData.setData("Text",clipBoardContent);
   alert("你已复制链接及标题，请粘贴到QQ/MSN等发给好友!");
}
  
function TxBBS_QoutePost(quotestr)//引用帖子
{
	document.getElementById('Content').value = document.getElementById('Content').value +"[quuott]"+quotestr+"[/quuott]\r\n";
}
//显示使用道具列表
function ShowProp(tId,event)
{
	var tableobj = document.getElementById(tId);
	tableobj.style.left = event.clientX;
	tableobj.style.top = event.clientY + document.body.scrollTop;
}
function CloseProp(tId)
{
	var tableobj = document.getElementById(tId);
	tableobj.style.left = -1000;
	tableobj.style.top = -1000;
}
function TxBBS_ShowPermission()//根据cookie中的权限显示不同的内容
{
	//广告
	//var MyContent = document.getElementById("Content");
	//MyContent.parentNode.innerHTML = "<table border=0 cellpadding=0 cellspacing=0><tr><td><textarea name='Content' id='Content' style='width:500px;height:178px;' rows=12 wrap=VIRTUAL ONSELECT='this.pos=document.selection.createRange();TxBBS_SumTextLength(this);' onCLICK='this.pos=document.selection.createRange();' onKEYUP='this.pos=document.selection.createRange();TxBBS_SumTextLength(this);' ONLOAD='this.pos=document.selection.createRange();' onchange='TxBBS_SumTextLength(this)' title='Ctrl+Enter直接提交发帖'></textarea></td><td align='_top'></td></table>";
	//回帖按钮旁广告
	//var MyTextLength = document.getElementById("textlength");
	//MyTextLength.parentNode.innerHTML = "<input id='submitpost' name='Submit' type='submit' value='回复' style='width:80px;color:#ff0000'> 字数<input id='textlength' type='text' value='0' style='width:40px;'><br>";
	var MyContentMsg = document.getElementById("ContentMsg");
	if(MyContentMsg != null)
	{
		//深水区帖子提示
		/*
		if(ForumID == 71)
		{
		
			MyContentMsg.className = "WarningMsg";
			MyContentMsg.style.display = "block";
			MyContentMsg.innerHTML += "在深水区发帖必须获得白名单身份认证。在军事、历史、社会论坛获得原创、精华、优秀发言奖励即获得白名单身份认证。";
			
		}
		if((PostAttachment & 32) == 32)//博客帖
		{
			MyContentMsg.className = "WarningMsg";
			MyContentMsg.style.display = "block";
			MyContentMsg.innerHTML += "本帖是楼主的博客帖，除版主之外，楼主也将有权删除你的回复帖。";
		}
		if((PostAttachment & 16) == 16)//公社帖
		{
			MyContentMsg.className = "WarningMsg";
			MyContentMsg.style.display = "block";
			MyContentMsg.innerHTML += "本帖是公社帖，除版主之外，公社管理员也将有权删除你的回复帖。";
		}
		*/
	}
	
	//如果是登录用户
	var userid = TxBBS_CurrentUserID();
	//alert(userid);
	if(userid>0)
	{
		document.getElementById("replyspan").style.display = "block";
		document.getElementById("nologinspan").style.display = "none";
	}
	else
	{
		document.getElementById("replyspan").style.display = "block";
		document.getElementById("nologinspan").style.display = "block";
		document.getElementById("submitpost").value = "请先登录";
		document.getElementById("submitpost").disabled = true;
	}
	if(islocked==1)
	{
		document.getElementById("replyspan").style.display = "none";
		document.getElementById("nologinspan").style.display = "none";
		document.getElementById("noreplyspan").style.display = "block";
	}
	//如果是管理员
	var isheader = TxBBS_IsHeader();
	
	//设置相关链接
	var TopPostID = 0;
	var DivList = document.getElementsByTagName("div");
	var firstFloor = true; //判断是否为第一楼 wangzhe add at 2007-2-28
	for(var i=0;i<DivList.length;i++)
	{							
		if(DivList[i].id.indexOf("topbutton")>-1)//如果是topinfo
		{
			var arrtempid = DivList[i].id.substring(10,DivList[i].id.length).split("_");
			//var nowuserid = arrtempid[1];
			var nowpostid = arrtempid[0];//这实际上是threadid
			//DivList[i].innerHTML = "";
		}
		else if(DivList[i].id.indexOf("bodyinfo")>-1)//如果是bodyinfo
		{
			var arrtempid = DivList[i].id.substring(9,DivList[i].id.length).split("_");
			var nowuserid = arrtempid[1];
			var nowpostid = arrtempid[0];
			var htmls = "";
			if(isheader)
			{
				 htmls += "<img title='优秀发帖奖励20分' style='cursor:hand;' src='images/jiangli.gif' height=30 width=60 class='notactive' onmouseenter='TxBBS_Active(this)' onmouseleave='TxBBS_NotActive(this)' onclick='TxBBS_Jiangli(this,"+nowpostid+",1)'><!--&nbsp;&nbsp;&nbsp;<img title='灌水扣10分' style='cursor:hand;' src='images/koufen.gif' height=30 width=60 class='notactive' onmouseenter='TxBBS_Active(this)' onmouseleave='TxBBS_NotActive(this)' onclick='TxBBS_Jiangli(this,"+nowpostid+",2)'>-->";
			}	
			
			if(firstFloor)//第一楼
			{
				htmls += "&nbsp;&nbsp;&nbsp;<img title='无需回复即可将帖子提前' style='cursor:hand;' src='images/onestick.gif' height=30 width=60 class='notactive' onmouseenter='TxBBS_Active(this)' onmouseleave='TxBBS_NotActive(this)' onclick='OneStick("+ ThreadID + "," + nowpostid +")'>";
				firstFloor = false;
			}
			//wangzhe add for shop prop
			/*var oPropHtml = "<TABLE id='ID"+nowpostid+"' style='z-index:100000;top:-1000;left:-1000;border:1px solid gray;font-size:12px;background-color:#Efefef;position:absolute;text-align:center;color:#a00000;' cellSpacing='0' cellPadding='0' width='300' border='0' onclick=\"this.style.display='';\"><TR><TD colspan='4' style='border-bottom:1px solid gray;'>使用道具</TD></TR><TR><TD style='border-bottom:1px solid gray;padding:1px;width:69px;'><a href='http://booktest.laweach.com/UseSubjectProp.aspx?threadid="+ ThreadID +"'>标题迷彩</a></TD><TD style='border-bottom:1px solid gray;padding:1px;border-left:1px solid gray;width:69px;'><a href='http://booktest.laweach.com/UseStickyProp.aspx?threadid="+ThreadID+"'>救生圈</a></TD><TD style='border-bottom:1px solid gray;border-left:1px solid gray;padding:1px;'><a href='http://booktest.laweach.com/UseIpProp.aspx?postid="+nowpostid+"'>红外仪</a></TD><TD style='border-bottom:1px solid gray;border-left:1px solid gray;padding:1px;width:69px;'><a href='http://booktest.laweach.com/UseAnonymousProp.aspx?postid="+nowpostid+"'>隐形衣</a></TD></TR><TR><TD style='border-bottom:1px solid gray;padding:1px;width:69px;'><a href='http://booktest.laweach.com/UseSuspendProp.aspx?threadid="+ThreadID+"'>悬浮符</a></TD><TD style='border-bottom:1px solid gray;border-left:1px solid gray;padding:1px;width:69px;'><a href='http://booktest.laweach.com/UseCancelStickyProp.aspx?threadid="+ThreadID+"'>弓弩</a></TD><TD style='border-bottom:1px solid gray;border-left:1px solid gray;padding:1px;width:69px;'><a href='http://booktest.laweach.com/UseSexProp.aspx?userId="+nowuserid+"'>变性符</a></TD><TD style='border-bottom:1px solid gray;border-left:1px solid gray;padding:1px;width:69px;'><a href='http://booktest.laweach.com/UseSignProp.aspx?userId="+nowuserid+"'>魔力墨水</a></TD></TR><TR><TD style='border-bottom:1px solid gray;padding:1px;width:69px;'><a href='http://booktest.laweach.com/UseFaceProp.aspx?userId="+nowuserid+"'>偷天换日符</a></TD><TD style='border-bottom:1px solid gray;border-left:1px solid gray;padding:1px;width:69px;'><a href='http://booktest.laweach.com/UseJailProp.aspx?userId="+nowuserid+"'>特赦令</a></TD><TD style='border-bottom:1px solid gray;border-left:1px solid gray;padding:1px;width:69px;'><a href='http://booktest.laweach.com/UseFlakJacketProp.aspx?userId="+nowuserid+"'>防弹衣</a></TD><TD style='border-bottom:1px solid gray;border-left:1px solid gray;padding:1px;width:69px;'><a href='http://booktest.laweach.com/UseTxShieldProp.aspx?userId="+nowuserid+"'>法易盾</a></TD></TR><TR><TD style='border-right:1px solid gray;padding:1px;width:69px;'><a href='http://booktest.laweach.com/UsePassportProp.aspx?userId="+nowuserid+"'>特种通行证</a></TD><TD></TD><TD></TD><TD style='border-left:1px solid gray;padding:1px;width:69px;'><a href=\"javascript:CloseProp('ID"+ nowpostid +"')\">关闭</a></TD></TR></TABLE>";
	
			document.write(oPropHtml);*/
			//htmls += "   <a style=\"cursor:hand;color:red;font-weight:bold;\" onclick=\"ShowProp('ID"+ nowpostid +"',event)\">使用道具</a>";
			//htmls += "<img src='images/useProp.gif' style='cursor:hand;height:30px;width:60px;border:0px;margin-left:20px;' onclick=\"ShowProp('ID"+ nowpostid +"',event)\" title='使用道具'>";
			DivList[i].innerHTML = htmls;
		}
		else if(DivList[i].id.indexOf("rightinfo")>-1)//如果是rightinfo
		{
			var arrtempid = DivList[i].id.substring(10,DivList[i].id.length).split("_");
			var nowuserid = arrtempid[1];
			var nowpostid = arrtempid[0];
			var htmls = "";
			/*htmls = "<br><a href='http://group.laweach.com/MyGroups.aspx?UserID="+nowuserid+"' target='_blank' title='我的公社' style='text-decoration: none;'><span class='bbs_blog'>我的公社</span></a>";
			htmls = htmls + "&nbsp;&nbsp;<a href='http://i.laweach.com/MyBlog.aspx?UserID="+nowuserid+"' target='_blank' title='我的博客' style='text-decoration: none;'><span class='bbs_blog'>我的博客</span></a><br>";
			htmls = htmls + "<a href='http://game.laweach.com/Horse/MyHorse.aspx?UserID="+nowuserid+"' target='_blank' title='我的赛马'><img border='0' src='http://game.laweach.com/Horse/images/h"+(nowuserid%31+1)+".gif'></a>";*/
			if(TopPostID == 0)
			{
				TopPostID = nowpostid;
			}
			var hf366=Math.random();
			if(hf366<0.1 || TopPostID == nowpostid)
			{
				//htmls += "<br><a href='http://bbs.laweach.com/post2_1822_1.html' target='_blank'><img src='http://bbs.laweach.com/ad/lawyerweb.jpg' width='150' height='280' border=0></a>";
				htmls += "<br><iframe src='http://ask.148365.com/ControlIndex/PostGoldAD.aspx' width='168' height='900' frameborder='0' marginwidth='0' marginheight='0' hspace='0' vspace='0' scrolling='no'></iframe>";			
			}
			DivList[i].innerHTML = htmls;
		}
		//else if(DivList[i].id.indexOf("topinfo")>-1)//如果是topinfo   *******************************注释军号
		//{
		//	var arrtempid = DivList[i].id.substring(8,DivList[i].id.length).split("_");
		//	var nowuserid = arrtempid[1];
		//	var nowpostid = arrtempid[0];
		//	var htmls = "<a title='加为好友' href=\"http://group.laweach.com/Friends/AddContact.aspx?userid=" + nowuserid + "\" target=_blank>军号:"+nowuserid+".tiexue</a>";
		//	DivList[i].innerHTML = htmls;
		//}
	}
	
	
	var AdminPanelList = document.getElementsByTagName("span");
	//alert(AdminPanelList.length);
	for(var i=0;i<AdminPanelList.length;i++)
	{
		if(AdminPanelList[i].id.indexOf("adminpanel")>-1 && isheader)
		{
			var nowpostid = AdminPanelList[i].id.substring(11,AdminPanelList[i].id.length);
			//alert(nowpostid);
			var htmls = "<a href=Admin/RewardsSalary.aspx?postid="+nowpostid+"&threadid="+ThreadID+" target=_blank>加分</a> <a href=Admin/PunishmentSalary.aspx?postid="+nowpostid+"&threadid="+ThreadID+" target=_blank>扣分</a> ";
			if(postparam[nowpostid.toString()][0]==0)
			{
				htmls += "<a href=Admin/OriginalPost.aspx?postid="+nowpostid+"&threadid="+ThreadID+" target=_blank>原创</a> ";
			}
			else
			{
				htmls += "<a href=Admin/CancelOriginalPost.aspx?postid="+nowpostid+"&threadid="+ThreadID+" target=_blank>取消原创</a> ";
			}
			if(postparam[nowpostid.toString()][1]==0)
			{
				htmls += "<a href=Admin/ValuePost.aspx?postid="+nowpostid+"&threadid="+ThreadID+" target=_blank>精华</a> ";
			}
			else
			{
				htmls += "<a href=Admin/CancelValuePost.aspx?postid="+nowpostid+"&threadid="+ThreadID+" target=_blank>取消精华</a> ";
			}
			htmls += "<a href=Admin/DeletePost.aspx?postid="+nowpostid+"&threadid="+ThreadID+" target=_blank>删除</a> <a href=Admin/JailUser.aspx?postid="+nowpostid+"&threadid="+ThreadID+" target=_blank>禁言</a> <a href=PostLog.aspx?postid="+nowpostid+"&threadid="+ThreadID+" target=_blank>日志</a> <a href=Admin/SearchPostInfo.aspx?postid="+nowpostid+"&threadid="+ThreadID+" target=_blank>IP</a> <a href=Admin/WarningUser.aspx?postid="+nowpostid+" target=_blank>警告</a>";
			AdminPanelList[i].innerHTML = htmls;
		}
		if(AdminPanelList[i].id.indexOf("admintopicpanel")>-1 && isheader)
		{
			var nowpostid = AdminPanelList[i].id.substring(16,AdminPanelList[i].id.length);
			var htmls = "<a href=Admin/StickePost.aspx?postid="+nowpostid+"&threadid="+ThreadID+" target=_blank>固顶</a> <a href=Admin/CancelStickePost.aspx?postid="+nowpostid+"&threadid="+ThreadID+" target=_blank>解固</a> ";
			if(islocked==0)
			{
				htmls += "<a href=Admin/LockPost.aspx?postid="+nowpostid+"&threadid="+ThreadID+" target=_blank>锁定</a> ";
			}
			else
			{
				htmls += "<a href=Admin/CancelLockPost.aspx?postid="+nowpostid+"&threadid="+ThreadID+" target=_blank>解锁</a> ";
			}
			if(isvouch==0)
			{
				htmls += "<a href=Admin/VouchPost.aspx?postid="+nowpostid+"&threadid="+ThreadID+" target=_blank>推荐</a> ";
			}
			else
			{
				htmls += "<a href=Admin/CancelVouchPost.aspx?postid="+nowpostid+"&threadid="+ThreadID+" target=_blank>解推</a> ";
			}
			htmls += "<a href=Admin/MovePost.aspx?postid="+nowpostid+"&threadid="+ThreadID+" target=_blank>移动</a> <a href=Admin/MovePostDirectory.aspx?postid="+nowpostid+"&threadid="+ThreadID+" target=_blank>修改精华目录</a> <a href=Admin/NailPost.aspx?postid="+nowpostid+"&threadid="+ThreadID+" target=_blank>定位</a> <a href=Admin/DeletePost.aspx?postid="+nowpostid+"&threadid="+ThreadID+" target=_blank>删除</a> <a href=http://cms.laweach.com/article_add.aspx?postid="+nowpostid+"&threadid="+ThreadID+" target=_blank>收录</a> <a href=Admin/CorrectPost.aspx target=_blank>纠错</a> <a href='Admin/onestick.aspx?threadid="+ThreadID+"&postid="+nowpostid+"' target=_blank>顶一下</a>";
			AdminPanelList[i].innerHTML = htmls;
		}
		if(AdminPanelList[i].id.indexOf("userpanel")>-1 && userid>0)
		{
			var arrtempid = AdminPanelList[i].id.substring(10,AdminPanelList[i].id.length).split("_");
			var nowuserid = arrtempid[1];
			var nowpostid = arrtempid[0];
			//alert(nowuserid);
			if(nowuserid == userid)
			{
				AdminPanelList[i].innerHTML = "<a href=editpost.aspx?postid="+nowpostid+"&threadid="+ThreadID+" target=_blank >编辑</a> <a href=FinishPrisePost.aspx?postid="+nowpostid+"&threadid="+ThreadID+" target=_blank >结帖</a> ";
			}
			else if(isheader)
			{
				AdminPanelList[i].innerHTML = "<a href=editpost.aspx?postid="+nowpostid+"&threadid="+ThreadID+" target=_blank >编辑</a> <a href=FinishPrisePost.aspx?postid="+nowpostid+"&threadid="+ThreadID+" target=_blank >结帖</a>  ";
			}
		}
	}
}
function TxBBS_ShowReply()
{
	document.getElementById("replyspan").style.display = "block";
	document.getElementById("nologinspan").style.display = "none";
	document.getElementById("TempACheck").checked = true;
	document.getElementById("submitpost").value = "回复";
	document.getElementById("submitpost").disabled = false;
}
function TxBBS_SumTextLength(Obj)
{
	document.getElementById('textlength').value = document.getElementById('Content').value.length;
}
var ischeck;
function Checkpostdata()
{
	Checkdata();
	if (ischeck==false)
	{
		return false;
	}
	else
	{
		document.getElementById("submitpost").disabled = true;
		TxBBS_CopyToClipboard(document.getElementById('Content').value);
	}
}
function Checkdata()
{
	//document.getElementById("PostSubject").innerHTML="";
	//document.getElementById("constr").innerHTML="";
	ischeck=true;
	if (document.getElementById("PostSubject").value.length==0)
	{
		alert("您忘记填写标题");
		ischeck=false
	}
	if (document.getElementById("PostSubject").value.length>24)
	{
		alert("标题长度不能大于24");
		ischeck=false
	}
	if (document.getElementById('Content').value.length==0)
	{
		alert(" 请填写帖子内容");
		ischeck=false
	}
	else if (document.getElementById('Content').value.length>15000)
	{
		alert(" 帖子内容长度不能大于15000,您已经输入了"+document.getElementById('Content').value.length+"个字</font>");
		ischeck=false
	}
	if (ischeck==false)
	{
		document.getElementById('postform').Submit.disabled=false;
		//document.postform.Submit2.disabled=false;
	}
}

function SetNormalPostVouch()
{
	var vtable = document.getElementById("voutab");
	//var img1 = document.getElementById("img1");
	//var img2 = document.getElementById("img2");
	var vdiv1 = document.getElementById("voudiv1");
	var vdiv2 = document.getElementById("voudiv2");
	voutab.style.width = (window.screen.width-20)*0.97;
	//var imgw;
	//var imgh;
	//alert("1");
	try
	{
		var divobj = document.getElementsByTagName("div");
		//alert("2");
		var wid = 0;
		if (window.screen.width >= 1280)
		{
			wid = 300;
			vdiv1.style.cssText = "padding-left:10px;float:left";
			vdiv2.style.cssText = "padding-right:12px;float:right";
		}
		else if (window.screen.width >= 1024)
		{
			wid = 226;
			vdiv1.style.cssText = "padding-left:0px;float:left";
			vdiv2.style.cssText = "padding-right:2px;float:right";
		}
		else if (window.screen.width >= 800)
		{
			wid = 155;
			vdiv1.style.cssText = "padding-left:0px;float:left";
			vdiv2.style.cssText = "padding-right:2px;float:right";
		}
		
		for (var i = 0;i < divobj.length;i++)
		{
			if (divobj[i].id.indexOf("divvouch") > -1)
			{
				divobj[i].style.width = wid+"px";
			}
		}
		vdiv1.style.width = "123px";
		vdiv2.style.width = "123px";
		//alert("3");
		/*
		img1.width = imgw;
		img1.height = imgh;
		img2.width = imgw;
		img2.height = imgh;
		*/
		//alert(img1.width);
		//alert(img1.height);
		if (wid == 0)
		{
			vtable.style.display = "none";
		}
	}
	catch(err)
	{
		vtable.style.display = "none";
	}
}

//顶一下
function OneStick(tId,pId)
{
	if(window.confirm("此操作耗费10个劳动点，是否继续？"))
	{
//alert(document.oneStick)
		document.oneStick.action = "OneStick.aspx?threadid=" + tId + "&PostID=" + pId;
		document.oneStick.submit();
	}
}

//转正
var haveTrans = false;
function Trans(pId)
{
	if(window.confirm("确认将此帖转正？"))
	{
		//if(!haveTrans)
		//{
			haveTrans = true;
			document.TransPlus.action = "TransPlus.aspx?PostID=" + pId;
			document.TransPlus.submit();
		//}
	}
}
