/*
0: id          1 :time        2 :flag        3 :state       4 :score       5 :content     6:userid
7:username     8: zoneroot    9 :zonecity    10:zonename    11:userflag    12:upfilename  13:upfileurl
*/

/* 页面标题 */
if (document.title.substring(0,5)!='手机论坛群'){
	top.document.title = document.title;
}



/* 开新窗 */
function openwin(openurl,openwidth,openheight) {
	window.open(openurl,'younetalert','width='+openwidth+',height='+openheight+',top=100,left=100,toolbar=no,location=no,directories=no,menubar=no,scrollbars=no,resizable=no,status=no');
}

/* 搜索表单检查 */
function srh_chk(itm){
	if (itm.search_word.value == '') {
		itm.search_word.focus();
		alert('请输入查询关键词！');
		return false;
	}else{
		return true;
	}
}

/** 
 * 公告列表 
 * key=>公告id
 * val0 公告标题
 * val1 公告url
 * val2 是否有公告内容
 * val3 公告颜色
 * val4 公告字号
 * val5 公告滚动否
*/
function bull(b,bp,bt,p,t){
	for (key in b){
		if ((bp[key][p]||bp[key][0]) && (bt[key][t]||bt[key][0])){
//		if ( (bp[key][p]==1||bt[key][t]==1) || (bp[key][0]==1&&bt[key][0]==1) ){
			b1 = b[key];
			//颜色，字体
			style = " style='color:"+b1[3]+"; font-size:"+b1[4]+";'";
			out = '';
			//有链接或内容
			if (b1[1]!=''||b1[2]==1){
				out += "<a href='"+(b1[1]!=''?b1[1]:'bullview.php?id='+key)+"' target='_blank'"+style+">"+b1[0]+"</a><br>";
			//只有标题
			}else {
				out += "<span"+style+">"+b1[0]+"</span><br>";
			}
			//滚动
			if (b1[5]==1){
				out = "<marquee  scrollamount=4 scrolldelay=25 width=100% onmouseover='this.stop();' onmouseout='this.start();'>"+out+"</marquee>";
			}

			document.write(out);
		}
	}
}

/* 用户名，社区*/    
function lu(t1){
	tmp = '';
	
	if(t1[6]==0) {
		tmp+='<font color=blue>'+t1[7]+'</font> ';
	}else {
		tmp+='<a target="_blank" href="'+(t1[6]!=0?'http://user.younet.com/detail.php?id='+t1[6]:'#')+'" class="f14">'+t1[7]+'</a> ';
	}
	if (t1[10]=='yy') {
		tmp+="<a href='http://player.younet.com/club/yy_intro.php' target=_blank class=silver><img src='http://forum.younet.com/pics/wappost.gif' alt='手机发帖' border='0'></a>";
	}else if (t1[11]==9){
		tmp+='<font color="#666666">('+t1[10]+')</font>';
	//试飞标志  
	}else if(t1[6]==0) {
		tmp+='';
	}else {
		tmp+='<a class="silver" target="_blank" href="http://community.younet.com/main.php?BoardID='+t1[8]+'&AreaID='+t1[9]+'" class="f14">('+t1[10]+'社区'+')</a> ';
	}

	return tmp;
}
/* 发贴时间 */
function lt(t1){
	return '<font color="#ffaf60">'+t1[1]+'</font>';
}
/* 帖子内容*/
function lc(t1,i,cut,rootid){
	t1[5] = t1[5].replace(/\\n/ig,'\n');
	tmp = '';
	/* 最后编辑正则 */
	reg = /<div style=\"[^\"]+\">　　用户 .+ 编辑了此帖子。<\/div>$/ig;
	/* 截取最后编辑代码 */
	endfix = t1[5].match(reg);
	if (endfix==null){
		endfix = '';
	}else{
		endfix = endfix[0];
	}
	t1[5] = t1[5].substring(0,t1[5].length-endfix.length);
	/* 高亮搜索关键词 */
	if (search_page){
		/* 内容搜索 */
		if (search_type=='content'){
			reg = 'reg = /('+search_word.replace(/ /ig,'|')+')/ig';
			eval(reg);
			t1[5]=t1[5].replace(reg,' <font color=red>$1</font> ');
		/* 发贴用户搜索 */
		}else if(search_type=='username'){
			if (t1[7]==search_word){
				t1[5] = '<font color=red>'+t1[5]+'</font>';
			}
		/* 发贴时间 */
		}else if(search_type=='date'){
			if (t1[1].substring(0,10)==search_word){
				t1[5] = '<font color=red>'+t1[5]+'</font>';
			}
		}
	}
	/* 帖子超长截短 */
	if (cut>0&&t1[5].length>cut){
		t1[5] = t1[5].substring(0,cut)+endfix+(endfix.length>0?'':'<br>')+'　　<a href="files/'+rootid+'p'+current_page+current_type+'.html" class="red">更多请进……</a>';
	}else{
		t1[5] = t1[5]+endfix;
	}
	/* 内容生成 */
	if (i==0){
		tmp+='  <B>[主题]：</B>'+t1[5].replace(/\n/ig,'<br>\n').substring(2);
	}else{
		tmp+=t1[5].replace(/\n/ig,'<br>\n');
	}
	tmp = '<font class="f14">'+tmp+'</font>';
	return tmp;
}

/* 操作按钮 */
function lb(t1,rootid,rly,flw,edit,flt,pic,mark){
	tmp = '<div style="position:absolute;"><div style="position:relative;left:'+(t1[0]==rootid&&flt?'310':'270')+'px;top:-3px;">';
	/* 回帖 */
	if (rly){
		tmp+=(t1[0]==rootid?'<a href="http://forum.younet.com/reply_mob.php?id='+rootid+'&page='+current_page+'" style="color:#85BC25;text-decoration: underline;">回帖</a>':'　　');
		tmp+='　　';
	}
	/* 图片 */
	if (pic){
		tmp+='<a href="http://forum.younet.com/upload/'+t1[1].substring(0,10)+'/'+t1[12]+'" style="color:red;" target=_blank>图片</a>';
		tmp+='　　';
	}
	/* 编辑 */
	tmp+=edit?'<a href="/edit.php?id='+t1[0]+'&page='+current_page+'" style="color:#85BC25;text-decoration: underline;">编辑</a>　':'';
	/* 回收 */
	tmp+=current_admin?'<input type="checkbox" name="rcy['+t1[0]+']" align="absmiddle" value="'+t1[0]+'"><font color=red>回收</font>　':'';
	/* 得奖 */
	if (flw&&t1[4]>0){
		for (fi=0; fi<t1[4]; fi++){
			tmp+='<img src="'+current_base+'forum.younet.com/pics/flower1.gif" width="12" height="12" alt="" align="absmiddle">\n';
		}
	}
	if (mark==1){
			tmp+='<img src="'+current_base+'forum.younet.com/pics/ques.gif" alt="" align="absmiddle">\n';
	}else if(mark==2) {
			tmp+='<img src="'+current_base+'forum.younet.com/pics/smile.gif" alt="" align="absmiddle">\n';
	}
	tmp+='</div></div>';
	return tmp;
}
/* 查看帖子 */
function lv(t){
	for (vi=0;vi<t.length ; vi++){
		t1 = t[vi].split('\n');
		if (vi==0){
			rootid = t1[0];
		}
		tmp = '';
		tmp+='<tr height="23">';
		tmp+='<td width="500" class="l20">'+lb(t1,rootid,false,false,true,false,t1[12]!=0?true:false,t1[14])+'　'+lu(t1)+' '+lt(t1)+'</td>';
		tmp+='<td bgcolor="#F9F9F9" width="20" height="18" align="right"><input type="checkbox" name="wg[]" value='+t1[0]+'></td>';

		tmp+="</tr>";
		tmp+='<tr><td colspan="2" class="l20">'+lc(t1,vi,0,rootid)+'<hr size="1" color="#E1E1E1" /></td></tr>';
		document.write(tmp);
	}
}

/* 帖子列表 */
function ll(t) {
	if (t.length>0){
		document.write('<hr width=100% size=1 color=#E0E0E0 align="left">');
	}
	for (li=0;li<t.length ; li++) {
		tmp = '';
		t1 = t[li].split('\n');
		if (li>0){
			tmp+='<ul>';
		}else{
			rootid = t1[0];
		}
		tmp+='<li>'+lb(t1,rootid,true,true,false,true,t1[12]!=0?true:false,t1[14])+lu(t1)+' '+lt(t1)+'</li>';
		tmp+='<div style="word-break:break-all;word-wrap :break-word;">'+lc(t1,1,content_cut,rootid)+'</div>';
		if (li>0){
			tmp+='</ul>';
		}
		
		document.write(tmp);
	}

}
/* 违规贴 */
function wg() {
	var chk = false;
	itm = document.wgt.elements;
	for(i=0;i<itm.length;i++){
		if(itm[i].name=='wg[]'&& itm[i].checked){
			return true;
			break;
		}
	}
	alert('请选择违规贴!');
	return false;
}

/* 发贴检查 */
var sub_state = false;
function sub_chk() {
	if (sub_state == true) {
		alert("您已经提交了请求……");
		return false;
	}else {
		with (document.post){
			if (content.value == '') {
				alert('请您填写帖子内容！');
				content.focus();
				return false;
			}else{
				submit_forum.disabled = true;
				sub_state = true;
				return true;
			}
		}
	}
}

/* 帖子编辑检查 */
function edit_chk(itm){
	if (sub_state == true) {
		alert("您已经提交了请求……");
		return false;
	}else if (itm.content.value==''){
		alert('请您填写帖子内容！');
		itm.content.focus();
		return false;
	}else{
		itm.submit_forum.disabled = true;
		sub_state = true;
		return true;
	}
}

/* 快捷键发贴 */
function key_down() {
	if (((window.event.altKey)&&(window.event.keyCode==83))||((window.event.ctrlKey)&&(window.event.keyCode==13))){
		with (document.post){
			if(content.value==''){
				content.focus();
			}else if (sub_state == true) {
				alert("您已经提交了请求……");
				return false;
			}else{
				sub_state = true;
				submit_forum.disabled = true;
				submit();
				return true;
			}
		}
	}
	if(event.keyCode==27) {
		event.keyCode=0;
		event.returnValue=false;
	}
}

/* 定位至发言框 */
function post(){
	with (document.post){
		submit_forum.focus();
		content.focus();
	}
}

/* 参数配置默认值 */
function conf_def() {
	document.conf.elements[2].checked = true;
	document.conf.elements[4].checked = true;
	document.conf.elements[10].checked = true;
}
function conf_chk() {
	return true;
}
