﻿function abc(obj){
	obj.src='about:blank';obj.outerHTML='';
}
function g(o){
	return document.getElementById(o);
}
function gt(a,b){
	g(a).innerHTML = g(b).value;
}
function optionCat(opt,id){
	if(opt=="add"){
			window.location='CategoryAddPre.do?pId='+id;
	}else if(opt=="edi"){
			window.location='CategoryUpdatePre.do?id='+id;
	}else if(opt="del"){
		if(confirm('确定要删除该讨论版块？'))
			window.location='CategoryDelete.do?id='+id;
	}
}
function submitForm(){
	checkKey();
	document.getElementById("searchForm").submit();
}
function checkKey(){
	var key = document.getElementById("keyword");
	if(key.value=="输入要查询的主题词")
		key.value = "";
}
function changs(item,itemid,bcid){
	if(item=="top"){
		if(confirm("您真的要把该主题置顶吗？"))
		window.document.location="ArticleTop.do?id="+itemid;
	}else if(item=="untop"){
		if(confirm("您真的要取消该主题置顶吗？"))
		window.document.location="ArticleTop.do?id="+itemid;
	}else if(item=="best"){
		if(confirm("您真的要把该主题设为精华吗？"))
		window.document.location="ArticleBest.do?id="+itemid;
	}else if(item=="unbest"){
		if(confirm("您真的要把该主题设为普通吗？"))
		window.document.location="ArticleBest.do?id="+itemid;
	}else if(item=="lock"){
		if(confirm("您真的要把该主题锁定吗？"))
		window.document.location="ArticleLock.do?id="+itemid;
	}else if(item=="unlock"){
		if(confirm("您真的要把该主题解锁吗？"))
		window.document.location="ArticleUnLock.do?id="+itemid;
	}else if(item=="del"){
		if(confirm("您真的要删除吗"))
		window.document.location="ArticleDelete.do?id="+itemid;
	}else if(item=="edit"){
		//if(confirm("你真的要修改该贴吗？"))
		window.document.location="ArticleUpdatePre.do?id="+itemid;
	}
}
function addSort(str1,str2){
	var obj = document.getElementById(str1);
	obj.value = str2;
	submitForm();
}
//进入 资源选择页面
function selRes(url){
	window.open(url, 'addSelRes', 'directories=no,height=660,location=no,menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no,width=980');
}
//在父页面接收选择的IDs 追加到编辑器里
function receiveSelIds(values){
	var html = "";
	for(var i=0; i<values[0].length; i++){
		html += "<br /><a href='"+values[0][i]+"' target='_blank'>"+values[1][i]+"</a>";
	}
	html = getEditorHTMLContents() + html;
	SetEditorContents(html,'content');
}
function check(){
	var obj = this.blogCommentAddForm;
	var wordNumChk = document.getElementById('wordNumChk');
	wordNumChk.innerHTML = getEditorHTMLContents();
	obj.wordNumContent.value = wordNumChk.innerText;	
	if (getEditorHTMLContents()==""){
		window.alert("内容不能为空，请输入内容！");
		return false;
	}else{
		var str = obj.title.value.toLowerCase();
		var newStr = chkValue(str);
		if(newStr)
			obj.title.value = newStr;
		return true;
	}	
}
function chkValue(str){
	var reg = /\</g;
	var reg1 = /(.)*(\<script)(.)*/;
	var reg2 = /(.)*(\<javascript)(.)*/;
	var reg3 = /(.)*(\<iframe)(.)*/;
	var reg4 = /(.)*(\<\/script)(.)*/;
	var reg5 = /(.)*(\<\/javascript)(.)*/;
	var reg6 = /(.)*(\<\/iframe)(.)*/;
	
	if(reg.test(str) && (reg1.test(str)||reg2.test(str)||reg3.test(str)||reg4.test(str)||reg5.test(str)||reg6.test(str))){
		str = str.replace(reg,"&lt;");
		return str;
	}
	return null;
}

//获取焦点
function getFocus(obj){
	g(obj).focus();
}
//回复评论
var replyBoxID = 0;
function addReplyBox(num,id){
	g("toId").value = id;
	if(replyBoxID!=0 && replyBoxID!=num){
		g("replyBox"+replyBoxID).innerHTML = "";
	}
	replyBoxID = num;
	var html = "<div class=\"replycomment\" ><textarea id=\"replyContent"+num+"\" onkeydown=\"time2();\" class=\"inputbox\" style=\"width:550px;\" cols=\"50\" rows=\"5\" minlength=\"3\" title=\"请填写回复（3到255个字符）\"></textarea>";
	html += "<div class=\"replycomment_title\"><a onclick=\"submitReply('"+num+"')\">提交</a>&nbsp;&nbsp;";
	html += "<a onclick=\"closeReply('"+num+"')\">关闭</a></div></div>";
	g("replyBox"+num).innerHTML = html;
	getFocus("replyContent"+num);
}
function submitReply(num){
	var content = g("replyContent"+num).value;
	if(content.length<3){
		alert("回复不能小于3个字符");
		getFocus("replyContent"+num);
		return null;
	}
	var str = content.toLowerCase();
	var newStr = chkValue(str);
	if(newStr)
		content = newStr;
	g("replyTitle").value = "圈子评论回复";
	g("replyContent").value = content;
	g("replyForm").submit();
}
function closeReply(num){
	g("replyBox"+num).innerHTML = "";
	replyBoxID = 0;
}
function addQuote(name,num){
	var content = g("content_"+num).innerText;
	var html = "<div class=\"quote\" style=:\"margin:10px 5px; margin-top:10px; height:auto; background-color:#F1F6FC\">";
	html += "<div class=\"quote_t\" style=\"height:24px; padding:0 5px; margin-top:5px; line-height:24px; background-color:#DDE8F7\"><b>引用</b>&nbsp;&nbsp;"+name+"：</div>";
	html += "<div class=\"ctrlp\" style=\"height:auto; border:1px #DDE8F7 solid; border-width:0 1px 1px 1px; padding:5px; line-height:24px; background-color:#F1F6FC\">"+content+"</div>";
	html += "</div>";
	SetEditorContents(html,'content');
	getFocus('content___Frame');
}
var timeout=0;
var timeout2=0;
var timer;
var i=true;
var i2=true;
function time1(){
	if(i){
		clearInterval(timer);
		blogCommentAddForm.usedTime.value = "";
		timer = setInterval("timeout++;blogCommentAddForm.usedTime.value=''+(timeout)+'';",1000);
		i = false;
		i2 = true;
	}
}
function time2(){
	if(i2){
		clearInterval(timer);
		g('replyTime').value = "";
		timer = setInterval("timeout2++;g('replyTime').value=''+(timeout2)+'';",1000);
		i2 = false;
		i = true;
	}
}
