
var web_dir="../";
var web_dir_common="common/";
var web_dir_support="support/";
var web_dir_ubb="images/ubb/";
var web_dir_img="images/small/";
var web_dir_em="images/icon/";
var web_dir_editor="common/editor/";
var post_now_frm="frm_post";
var post_now_topic="";
var post_now_remark="";
var post_now_minlen=1;
var post_now_maxlen=12;

var cfg_em=new Array();
cfg_em[0]=new Array('t','更多EM贴图…','0','<font class=gray>关闭贴图</font>');
cfg_em[1]=new Array('em','em/','16','小EM贴图');
cfg_em[2]=new Array('emb','emb/','13','大EM贴图');
cfg_em[3]=new Array('emq','emq/','80','QQ系列');
cfg_em[4]=new Array('emm','emm/','67','MSN系列');
cfg_em[5]=new Array('emc','emc/','25','COOL系列');

function post_load(strfrm,strtopic,strremark,strminlen,strmaxlen,strispreview,strisubb)
{
  if (strfrm!=null) post_now_frm=strfrm;
  if (strtopic!=null) post_now_topic=strtopic;
  if (strremark!=null) post_now_remark=strremark;
  if (strminlen!=null) post_now_minlen=strminlen;
  if (strmaxlen!=null) post_now_maxlen=strmaxlen;
  if (strispreview==1)
  {
    document.write("<form name=frm_preview action=\""+web_dir+web_dir_support+"preview.asp\" method=post target=\"win_preview\">");
    document.write("<input type=hidden name=p_code value=\"1\">");
    document.write("<input type=hidden name=p_topic value=\"\">");
    document.write("<input type=hidden name=p_mod value=\"1\">");
    document.write("<input type=hidden name=p_remark value=\"\">");
    document.write("</form>");
  }
  if (strisubb==1)
  {
    ubb_interface(post_now_frm,post_now_remark,web_dir+web_dir_ubb);
  }
}

function post_value(strer)
{
  if (strer!="")
  {
    if (strer=="_remark") strer=post_now_remark;
    if (strer=="_topic") strer=post_now_topic;
    return eval("document."+post_now_frm+"."+strer+".value;");
  }
}

function post_focus(strer)
{
  if (strer!="")
  {
    if (strer=="_remark") strer=post_now_remark;
    if (strer=="_topic") strer=post_now_topic;
    return eval("document."+post_now_frm+"."+strer+".focus();");
  }
}

function post_color_box(strinput,strcolor)
{
  var tmpid="tbl_color_"+strinput;
  if (strcolor=="" || strcolor==null) strcolor="000000";
  document.write("<table border=0 cellspacing=0 cellpadding=0>");
  document.write("<tr>");
  document.write("<td width=20 align=center>");
  document.write("<table id="+tmpid+" border=0 cellspacing=0 cellpadding=0 bgcolor=#"+strcolor+">");
  document.write("<tr><td onClick=\"javascript:post_slect_color('"+strinput+"','"+tmpid+"');\"><img border=0 src=\""+web_dir+web_dir_editor+"images/color_box.gif\" width=18 height=17></td></tr>");
  document.write("</table>");
  document.write("</td>");
  document.write("<td width=3></td>");
  document.write("<td><a href='javascript:;' onClick=\"javascript:post_slect_color('"+strinput+"','"+tmpid+"');\">选取颜色</a></td>");
  document.write("</tr>");
  document.write("</table>");
}

function post_slect_color(strinput,strtable)
{
  var tmpcolor=window.showModalDialog(""+web_dir+web_dir_editor+"win_select_color.asp","s","dialogWidth=300px;dialogHeight=295px;status=0");
  if (tmpcolor && tmpcolor!="")
  {
    if (strtable!="" && strtable != null)
    {
      eval("document.all."+strtable+".bgColor=tmpcolor;");	//window.document.all.item("bordercolor").bgColor=tmpcolor;
    }
    if (tmpcolor.length==7) { tmpcolor=tmpcolor.substr(1,tmpcolor.length); }
    eval("document."+post_now_frm+"."+strinput+".value=tmpcolor;");
  }
}

//<input type=test name=tim value='2003-5-19' size=12 maxlength=10 readonly>
//<input type=button class=btns name=btn_select_tim value="选择" onclick="javascript:post_select_time(tim);">
function post_select_time(strobj,strtype)
{
  var showx=event.screenX-event.offsetX-14;
  var showy=event.screenY-event.offsetY-168;
  var retval=window.showModalDialog(web_dir+web_dir_editor+"win_select_time.asp?data_tim="+strobj.value+"&data_type="+strtype,"","dialogWidth:197px; dialogHeight:235px; dialogLeft:"+showx+"px; dialogTop:"+showy+"px; status:no; directories:yes;scrollbars:no;Resizable=no;");
  if( retval!=null ) { strobj.value=retval; }
}

function post_textarea_caption(strcaption,strremark)
{
  
  if (strremark!="") strremark="<br><br>"+strremark;
  document.write("<table border=0 cellspacing=0 cellpadding=0 height=\"100%\"><tr><td valign=top>"+strcaption+"<br><br>最少"+post_now_minlen+"字节<br>最多"+post_now_maxlen+"千字节<br>[<a href=\"javascript:;\" onclick=\"javascript:post_check_length();\">字数检查</a>]"+strremark+"</td></tr></table>");
}

function post_textarea(strcols,strrows,strvalue,strremark)
{
  if (strcols==0) strcols=80;
  if (strremark=='' || strremark==null) strremark=post_now_remark;
  document.write("<table border=0 cellspacing=0 cellpadding=0>");
  document.write("<tr>");
  document.write("<td><textarea class=txtarea name="+strremark+" cols="+strcols+" rows="+strrows+" onkeydown=\"javascript:post_quicksubmit();\">"+strvalue+"</textarea></td>");
  document.write("<td width=5></td>");
  document.write("<td valign=bottom><a href='javascript:;' onclick=\"javascript:post_textarea_resize('-','" + strremark + "');\"><img src='"+web_dir+web_dir_img+"resize_minus.gif' border=0></a><br><a href='javascript:;' onclick=\"javascript:post_textarea_resize('+','" + strremark + "');\"><img src='"+web_dir+web_dir_img+"resize_plus.gif' border=0></a></td>");
  document.write("</tr>");
  document.write("</table>");
}

function post_textarea_resize(strt,strremark)
{
  if (strremark=='' || strremark==null) strremark=post_now_remark;
  var tmpnum=5;
  if (strt=='-') { tmpnum=-5; }
  var tmpobj=eval("document."+post_now_frm+"."+strremark);
  if (parseInt(tmpobj.rows)+tmpnum>=3) { tmpobj.rows = parseInt(tmpobj.rows) + tmpnum; }
  if (tmpnum>0) { tmpobj.width="90%"; }
}

//用于用户发表
function textarea_resize(strremark,strt,strform)
{
  if (strremark=='' || strremark==null) return;
  if (strform=='' || strform==null) strform='frm_input';
  var tmpnum=5;
  if (strt=='-') { tmpnum=-5; }
  var tmpobj=eval("document."+strform+"."+strremark);
  if (parseInt(tmpobj.rows)+tmpnum>=3) { tmpobj.rows = parseInt(tmpobj.rows) + tmpnum; }
  if (tmpnum>0) { tmpobj.width="90%"; }
}

function post_check()
{
  return true;
}

function post_check_length()
{
  if (post_now_maxlen == 0) return;
  var postchars=eval("document."+post_now_frm+"."+post_now_remark+".value.length;");
  var post_1="您输入的贴子内容已经超过系统允许的最大值！\n请删减部分贴子内容！";
  var message="系统允许："+post_now_maxlen+"KB（约"+post_now_maxlen*1024+"个字符）";
  if (post_now_maxlen*1024>=postchars)
  {
    var postc=post_now_maxlen*1024-postchars;
    post_1="您还可以输入："+postc+"个字符（约"+Math.round(postc/1024)+"KB）";
  }
  alert("您输入的贴子内容的统计信息如下：\n\n当前长度："+postchars+"个字符（约"+Math.round(postchars/1024)+"KB）\n"+message+"\n"+post_1);
}

function post_em_insert(emvar,em_frm,em_word)
{
  var obj_tmp=eval("document."+post_now_frm+"."+post_now_remark);
  obj_tmp.value+=emvar;
  obj_tmp.focus();
}

function post_em_check(strt)
{
  if (strt=="t")
  {
    tmpobj=get_id("div_em");
    tmpdisplay=tmpobj.style.display;
    tmpdisplay=(tmpdisplay=="none")?"":"none";
    tmpobj.style.display=tmpdisplay;
    tmpobj=get_id("div_em_menu");
    tmpobj.style.display=tmpdisplay;
    if (tmpdisplay!="none")
    {
      for (var j=1;j<cfg_em.length;j++)
      {
        for (i=1;i<=cfg_em[j][2];i++)
        {
          MM_preloadImages(web_dir+web_dir_em+cfg_em[j][1]+i+".gif");
        }
      }
    }
    tmpdisplay=(tmpdisplay=="none")?"":"none";
    tmpobj=get_id("div_em_nav");
    tmpobj.style.display=tmpdisplay;
  }
  tmpobj=get_id("div_em_body");
  var tmpnum=0,i=0;
  var tmpem="",tmpdir="";
  for (i=1;i<cfg_em.length;i++)
  {
    if (strt==cfg_em[i][0])
    {
      tmpem=cfg_em[i][0];
      tmpdir=cfg_em[i][1];
      tmpnum=cfg_em[i][2];
      break;
    }
  }
  if (tmpem=="")
  {
    tmpem=cfg_em[1][0];
    tmpdir=cfg_em[1][1];
    tmpnum=cfg_em[1][2];
  }
  //tmpobj.innerHTML="";
  var temp1="";
  for (i=1;i<=tmpnum;i++)
  {
    temp1+="<img src='"+web_dir+web_dir_em+tmpdir+i+".gif' border=0 align=absMiddle onclick=\"javascript:post_em_insert('["+tmpem+i+"]');\" style=\"CURSOR: hand;\">&nbsp;";
  }
  tmpobj.innerHTML=temp1;
}

function post_em(strnum)
{
  if (strnum<1) strnum=cfg_em[1][2];
  var temp1="";
  var i=0;
  for(i=1;i<=strnum;i++)
  {
    temp1+="<img src='"+web_dir+web_dir_em+cfg_em[1][1]+i+".gif' border=0 align=absMiddle onclick=\"javascript:post_em_insert('["+cfg_em[1][0]+i+"]');\" style=\"CURSOR: hand;\">&nbsp;";
  }
  var tmpstr="<table border=0 cellpadding=2 cellspacing=0 class=tbl>";
  tmpstr+="<tr valign=top style=\"display:true;\" id=div_em_nav><td>"+temp1+"&nbsp;<img border=0 src='"+web_dir+web_dir_em+"ico.gif' align=absMiddle> <a href='javascript:;' onclick=\"javascript:post_em_check('t');\">"+cfg_em[0][1]+"</a></td></tr>";
  tmpstr+="<tr style=\"display:none;\" id=div_em>";
  tmpstr+="<td id=div_em_body class=tb></td>";
  tmpstr+="</tr>";
  tmpstr+="<tr style=\"display:none;\" id=div_em_menu>";
  tmpstr+="<td>";
  tmpstr+="  <table border=0><tr>";
  for (i=1;i<cfg_em.length;i++)
  {
    tmpstr+="  <td><img border=0 src='"+web_dir+web_dir_em+"ico.gif' align=absMiddle> <a href='javascript:;' onclick=\"javascript:post_em_check('"+cfg_em[i][0]+"');\">"+cfg_em[i][3]+"</a>&nbsp;</td>";
  }
  tmpstr+="  <td><img border=0 src='"+web_dir+web_dir_em+"ico.gif' align=absMiddle> <a href='javascript:;' onclick=\"javascript:post_em_check('t');\">"+cfg_em[0][3]+"</a></td></tr>";
  tmpstr+="  </table>";
  tmpstr+="</td>";
  tmpstr+="</tr>";
  tmpstr+="</table>";
  //return tmpstr;
  document.write(tmpstr);
  return true;
}

function post_icon(strnum,strn,strinput)
{
  if (strinput=="" || strinput==null) strinput="icon";
  var temp1="";
  for(var i=0; i<strnum; i++)
  {
    temp1+="&nbsp;<img border=0 src='"+web_dir+web_dir_em+""+i+".gif'><input type=radio name="+strinput+" value='"+i+"'";
    if (strn==i) { temp1+=" checked"; }
    temp1+=">";
  }
  //return temp1;
  document.write(temp1);
}

function post_preview(strcode)
{
  if (strcode==null) strcode=1;
  eval("document.frm_preview.p_remark.value=document."+post_now_frm+"."+post_now_remark+".value");
  eval("document.frm_preview.p_code.value="+strcode);
  open_win('about:blank','win_preview',600,525,'yes');
  document.frm_preview.submit();
}

function post_quicksubmit()
{
  if ((event.keyCode==13 && event.ctrlKey) || (event.keyCode==83 && event.altKey))
  {
    post_oncesubmit();
    eval("document."+post_now_frm+".submit();");
  }
}

function post_oncesubmit()
{
  if (eval("document."+post_now_frm+"._sbt")) eval("document."+post_now_frm+"._sbt.disabled=true;");
  if (eval("document."+post_now_frm+"._rst")) eval("document."+post_now_frm+"._rst.disabled=true;");
  /*
  var theform=eval("document."+post_now_frm);
  for (var i=0;i<theform.length;i++)
  {
    var tempobj=theform.elements[i];
    if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset") { tempobj.disabled=true; }
  }
  */
}
