function article_head(bsn, snA, sn, author, nickname, titles, order, gy, wtime, isbm, judge, dreason, userdata, isbp, chfont, media)
{
  document.write('<table width=760 border=0 cellspacing=0 cellpadding=0 align=center bgcolor="#FFFFFF">');
  document.write('<tr>');
  //document.write('<td background="http://pic.bahamut.com.tw/dline.gif" rowspan=3 width=1></td>');
  document.write('<td align=center>');
  document.write('<table id='+sn+' width="95%" border=0 cellpadding=0 cellspacing=1 bgcolor="#999999">');
  document.write('<tr>');
  document.write('<td bgcolor="#FFFFFF">');
  document.write('<table width="100%" border=0 cellpadding=2 cellspacing=1 bgcolor="#999999">');
  document.write('<tr> ');
  document.write('<td align="center" valign="middle" bgcolor="#868883"> <font color="#FFFFFF">作  者</font></td>');
  document.write('<td valign=middle bgcolor="#868883" align=center> ');
  document.write('<table width="100%" border=0 cellspacing=0 cellpadding=0>');
  document.write('<tr> ');
  document.write('<td height="19" align="left"> <font color="#FFFFFF" size="1">◆</font> <font color="#FFFFFF"> 第'+order+'篇 :'+titles+' </font></td>');
  document.write('<td width="49" valign="bottom"><strong> <font color="#FFCCCC">'+gy+'</font></strong><font color="#FFFFFF"> 人GP </font></td>' );
  document.write('<td width="48" align="right"><a href="javascript:gy( \''+snA+'\', \''+sn+'\', \''+author+'\', \''+nickname+'\' )" class="tool"><img src="http://pic.bahamut.com.tw/forum/push.gif" width="14" height="14" border="0" align="absmiddle">我推</a></td>');
  if( 1 == isbp ){
    document.write('<td width="3" valign="bottom">&nbsp;</td><td width="48"><a href="javascript:bpoint( \''+snA+'\', \''+sn+'\', \''+author+'\', \''+nickname+'\' )" class="tool"><img src="http://pic.bahamut.com.tw/forum/down.gif" width="14" height="14" border="0" align="absmiddle">你走</a></td>');
  }
  document.write( '<td width="3" valign="bottom">&nbsp;</td><td width="48"><a href="javascript:bookmark( \''+bsn+'\','+snA+','+sn+',\''+escape(titles)+'\')" class="tool"><img src="http://pic.bahamut.com.tw/home/but_icon2.gif" width="11" height="10" border="0" align="absmiddle">收藏</a></td>');
  document.write('</tr>');
  document.write('</table>');
  document.write('</td>');
  document.write('</tr>');
  document.write('<tr> ');
  document.write('<td width=120 height="330" rowspan=4 align=center valign=top bgcolor="#F1EFE7" class="t1">');

  //哈啦區左邊的個人資料
  forum_C_userdata(userdata);

  document.write('</td>');
  document.write('<td align="center" bgcolor="#F1EFE7"> ');
  document.write('<table width="99%" border="0" cellspacing="0" cellpadding="0">');
  document.write('<tr> ');
  document.write('<td> 發言日期: '+wtime+'</td>');
  document.write('<td align="right">');
  document.write('<table border="0"><tr><td><span class="t1">字級設定：</span><a href="javascript:chfontc(\''+chfont+'\', \'P1\')" class="pag">小</a><a href="javascript:chfontc(\''+chfont+'\', \'P2\')" class="pag">中</a><a href="javascript:chfontc(\''+chfont+'\', \'P3\')" class="pag">大</a>');
  if(media > 0){document.write('<a href="#" onclick="return forumShowAllMedia(this);" class="pag">開啟圖片</a>');}
  document.write('</td></tr></table>');
  document.write('</td>');
  document.write('</tr>');
  
  document.write('<tr>');
  document.write('<td  valign="top" colspan="2">');
  document.write('<table width="100%" border="0" cellspacing="1" cellpadding="1">');
  document.write('<tr align="center"> ');
  document.write('<td align="left"> ');
  //板主副板主
  if( 1 & isbm ){
    //document.write('<tr>');
    //document.write('<td  valign="top" colspan="3">');
    //document.write('<table width="100%" border="0" cellspacing="1" cellpadding="1">');
    //document.write('<tr align="center"> ');
    //document.write('<td align="left"> ');
    document.write('板主管理功能: ');
    document.write('<a href="javascript:del('+sn+')" class="button">刪除</a>');
    document.write('<a href="javascript:M('+sn+')" class="button">M文</a>');
    document.write('<a href="javascript:gather('+sn+')" class="button">收進精華區</a>');
    document.write('<input type="checkbox" name="jsn[]" value="'+sn+'">');
    //if( 'D' == judge ){document.write('<font color="#FF0000">'+dreason+'</font>');}
    //document.write('</td>');
    //document.write('</tr>');
    //document.write('</table>');
    //document.write('</td>');
    //document.write('</tr>');
  }
  //小板主
  else if(2 & isbm){
    document.write('板主管理功能: ');
    document.write('<a href="javascript:gather('+sn+')" class="button">收進精華區</a>');
    document.write('<input type="checkbox" name="jsn[]" value="'+sn+'">');
  }
  if( 'D' == judge ){document.write('<font color="#FF0000">'+dreason+'</font>');}
  document.write('</td>');
  document.write('</tr>');
  document.write('</table>');
  document.write('</td>');
  document.write('</tr>');

  document.write('</table>');
  document.write('</td>');
  document.write('</tr>');
  document.write('<tr> ');
  document.write('<td bgcolor="#FFFFFF" class="P2" valign=top>');
}

function article_end( bsn, snA, sn, author, loweruid, locked, sign, postable, mtime, hideip, page, userdata, commend )
{
  //簽名檔
  save = getCookie('ckFORUM_setting');
  save = save.charAt(15);

  if( sign != 0 && (3 == getCookie('ckSAVE') || 2 == save) ){
    a0 = author.charAt(0);
    a1 = author.charAt(1);
    document.write('<table width="100%" border="0" cellpadding="0" cellspacing="8">');
    document.write('<tr><td bgcolor="#CCCCCC"><img src="http://pic.bahamut.com.tw/spacer.gif" width=1 height=1></td></tr>');
    document.write('<tr><td bgcolor="#FFFFFF"><p><iframe width="570" height="125" frameborder="0" marginwidth=0 marginheight=0 scrolling=no src="http://avatar2.bahamut.com.tw/avataruserpic/'+a0+'/'+a1+'/'+author+'/H_WebSign_'+sign+'.html"></iframe></p></td></tr>');
    //document.write('<tr><td bgcolor="#FFFFFF"><p><iframe width="570" height="125" frameborder="0" marginwidth=0 marginheight=0 scrolling=no src="http://user.gamer.com.tw/websign/'+a0+'/'+a1+'/'+author+'/H_WebSign_'+sign+'.html"></iframe></p></td></tr>');
    document.write('<tr><td bgcolor="#CCCCCC"><img src="http://pic.bahamut.com.tw/spacer.gif" width=1 height=1></td></tr>');
    document.write('</table>');
  }
  
  document.write('</td>');
  document.write('</tr>');
  document.write('<tr>');
  document.write('<td align=center bgcolor="#F1EFE7" class="T5">');

  document.write(commend);

  document.write('<table width="99%" border=0 cellspacing=0 cellpadding=0>');
  document.write('<tr>');
  document.write('<td width="36%" align=left>');
  //編輯自己文章功能列(被鎖定的文章可自刪，但不可編輯 joseph:2005-06-14)
  if( loweruid == author.toLowerCase() && postable ){
    if('F' == locked) document.write('<a href="javascript:pmodify('+snA+', '+sn+', '+page+')" class="button">編輯本文</a>');
    document.write('<a href="javascript:pdel('+sn+')" class="button"> 刪除本文</a>');
  }

  c_ln = 'no';
  if( loweruid && 'guset' !== loweruid ){
    c_ln = 'yes';
  }
  //document.write('<a href="javascript:accuse_setDialog(1, \'' + c_ln + '\', ' + bsn + ', ' + sn + ')" class=button>檢舉</a>');
  document.write('<a href="javascript:accuse_setDialog(1, \'' + c_ln + '\', \'' + bsn + '\', ' + sn + ')" class="reply_btn" id="M' + sn + '" onmouseover="accuse_tips(' + sn + ', 1)" onmouseout="accuse_tips(' + sn + ', 2)"><img src="http://pic.bahamut.com.tw/forum/newinform.gif" width="15" height="15" border="0" align="absmiddle"> 檢舉</a>');

/*skype合作案結束(20070308 joseph)
  //設定是否顯示skype
  arr = userdata.split('##');
  uid = arr[0];
  uid2 = uid.toLowerCase();
  nick = arr[1];
  title = arr[2];
  career = arr[3];
  gold = arr[4];
  level = arr[5];
  gp = arr[6];
  exp = arr[7];
  honor = arr[8];
  skype = arr[9];
  
  if(skype != null && skype != ''){
    document.write('　<a href="skype:'+skype+'?call"><img src="http://pic.bahamut.com.tw/skype.gif" border=0></a>');
  }
*/

  document.write('</td>');

  if( 'F' == locked ){
    document.write('<td width="64%" align=right> &nbsp;&nbsp;&nbsp; <a href="javascript:reply('+snA+', '+sn+')" class=button>引言回覆</a></td>');
  }
  else{
    document.write('<td width="64%" align=right>&nbsp; </td>');
  }
  document.write('</tr>');
  document.write('</table>');
  document.write('<table width="99%" border=0 cellpadding=0 cellspacing=1>');
  document.write('<tr><td width="87%" height=9><font color="#999999">最後編輯日期:'+mtime+'<font size="1">◆</font> Origin: &lt;'+hideip+'&gt; </font></td></tr>');
  document.write('</table>');
  document.write('</td>');
  document.write('</tr>');
  document.write('</table></td>');
  document.write('</tr>');
  document.write('</table>');
  document.write('</td>');
  //document.write('<td background="http://pic.bahamut.com.tw/dline.gif" width=1></td>');
  document.write('</tr></table>');
}

function confirmLink( link )
{
  re = /^http:\/\/[^\.]+.gamer.com.tw/;
  if( link.match(re) ){
    window.open( link, "_blank", "menubar=1,status=1,location=1,scrollbars=1,resizable=1" );
  }
  else if( confirm( "您即將開啟下列連結，確定嗎?\n\n" + link +"\n\n(巴哈姆特提醒您，不明連結可能包含木馬程式)" ) )
  {
    window.open( link, "_blank", "menubar=1,status=1,location=1,scrollbars=1,resizable=1" );
  }
}

//顯示右邊區塊
function forum_C_userdata(userdata)
{
  arr = userdata.split('##');
  uid = arr[0];
  uid2 = uid.toLowerCase();
  nick = (arr[1])?arr[1]:'';
  title = (arr[2])?arr[2]:'';
  career = (arr[3])?arr[3]:'';
  gold = (arr[4])?arr[4]:'';
  level = (arr[5])?arr[5]:'';
  gp = (arr[6])?arr[6]:'';
  exp = (arr[7])?arr[7]:'';
  honor = (arr[8])?arr[8]:'';
  bp = (null == arr[9])? 0:arr[9]*-1;
  homeUpdate = (1 == arr[10])? '<a href="http://home.gamer.com.tw/'+uid+'" target="_blank"><img src="http://pic.bahamut.com.tw/home/home_on.gif" border=0></a>':'<a href="http://home.gamer.com.tw/'+uid+'" target="_blank"><img src="http://pic.bahamut.com.tw/home/home_off.gif" border=0></a>'; 
  
  //設定功勳顯示
  if(honor && honor.length > 0){
    honorTitle = honorData();
    honorarr = honor.split(',');  
    var honorsarr = new Array(6);
    for(i=0; i<honorarr.length; i++){
      //sss = honorarr[i];
      //hdata = sss.split('-');
      //hnum = hdata[0];
      hnum = honorarr[i];
      htitle = honorTitle[hnum][0];
      br = (2 == i)? '<br>':'';
      honorsarr[i] = (1 == honorTitle[hnum][1])? '<a href="http://avatar1.gamer.com.tw/switchhonor.php?uid='+uid+'&htype='+hnum+'" target="_blank"><img src="http://pic.bahamut.com.tw/avatar/honorpic/'+hnum+'.gif" title="'+htitle+'" border="0" align="absmiddle"></a>'+br:'<img src="http://pic.bahamut.com.tw/avatar/honorpic/'+hnum+'.gif" title="'+htitle+'" border="0" align="absmiddle">'+br;

    }
    
    honors = honorsarr.join("\n");
  }
  else{
    honors = '';
  }

  //設定左方avatar圖片路徑
  if('????' == career){//未加入勇者
    imgsrc = "http://avatar2.bahamut.com.tw/noface.png";
  }
  else{
    imgsrc = 'http://avatar2.bahamut.com.tw/avataruserpic/'+uid2.substr(0,1)+'/'+uid2.substr(1,1)+'/'+uid2+'/'+uid2+'.png';
    //imgsrc = "http://avatar2.bahamut.com.tw/noface.png";
  }
  
  document.write('<table width="100%" height="100%" border=0 align=center cellpadding=0 cellspacing=2 bgcolor="#F1EFE7">');
  //document.write('<tr> <td align=center height=20 valign=top><a href="http://home.gamer.com.tw/'+uid2+'" target="_blank">'+uid+'</a><span class="t1"><br>('+nick+')</span></td></tr>');
  document.write('<tr> <td align=center height=20 valign=top><a href="http://home.gamer.com.tw/'+uid+'" target="_blank">'+uid+'</a><span class="t1"><br>('+nick+')</span></td></tr>');
  //document.write('<tr><td align=center height=162 valign=top><a href="http://avatar1.gamer.com.tw/photogallery.php?author='+uid2+'" target="_top"><img src="'+imgsrc+'" width="110" height="160" border=0></a></td></tr>');
  //document.write('<tr><td align=center height=162 valign=top><a href="javascript:showdress(\''+uid2+'\')"><img src="'+imgsrc+'" width="110" height="160" border=0></a></td></tr>');
  document.write('<tr><td align=center height=162 valign=top><a href="http://home.gamer.com.tw/'+uid+'"><img src="'+imgsrc+'" width="110" height="160" border=0></a></td></tr>');
  document.write('<tr>');
  document.write('  <td align=left valign=top>');


  document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0">');
  document.write('  <tr> ');
  document.write('    <td colspan="3" align="center" valign="top" height=18>'+homeUpdate+'</td>');
  document.write('  </tr>');
  document.write('  <tr> ');
  document.write('    <td colspan="3"><span class="t1"><font color="#8c7e73">'+title+'</font></span></td>');
  document.write('  </tr>');
  document.write('  <tr> ');
  document.write('    <td width="31"><span class="t1">職業:</span></td>');
  document.write('    <td colspan="2" class="t1">'+career+'</td>');
  document.write('  </tr>');
  document.write('  <tr> ');
  document.write('    <td><span class="t1">巴幣:</span></td>');
  document.write('    <td colspan="2" class="t1">'+gold+' 枚</td>');
  document.write('  </tr>');
  document.write('  <tr> ');
  document.write('    <td class="t1">等級:</td>');
  document.write('    <td width="28" class="t1">'+level+'</td>');
  document.write('    <td width="46" class="t1">&nbsp;</td>');
  document.write('  </tr>');
  document.write('  <tr>');
  document.write('    <td class="t1">GP :</td>');
  document.write('    <td class="t1">'+gp+'</td>');
  document.write('    <td class="t1">BP : '+bp+'</td>');
  document.write('  </tr>');
  document.write('  <tr> ');
  document.write('    <td><span class="t1">EXP:</span></td>');
  document.write('    <td colspan="2"><table width="50" border="0" cellpadding="0" cellspacing="0" bgcolor="#333333">');
  document.write('        <tr> ');
  document.write('          <td width="78"><img src="http://pic.bahamut.com.tw/avatar/EXP_s.gif" width="'+exp+'" height="4"></td>');
  document.write('        </tr>');
  document.write('      </table></td>');
  document.write('  </tr>');
  document.write('  <tr> ');
  document.write('    <td><span class="t1">功勳</span>:</td>');
  document.write('    <td colspan="2">&nbsp;'+honors+'</td>');
  document.write('  </tr>');
  document.write('</table>');


  document.write('  </td>');
  document.write('</tr>');
  document.write('</table>');
}
function commend(bsn, Bboardsn){
  window.open('D.php?bsn='+bsn+'&snB='+Bboardsn,'','scrollbars=yes,width=735,height=570');
}

/* 20110610 function canceled
function chfontc(ss, bb){
  document.getElementById(ss).className=bb;
}*/


function forumShowAllMedia(o){
  if(!getCookie('BAHAID') && 'Y' == attachMediaLogin ){
    if(confirm('您需要先登入才能觀看喔')){
      o.href = "https://user.gamer.com.tw/login.php";
      return true;
    }
    else{
      o.href = "javascript:void(0)";
    }
    return false;
  }

  var img = $('[name=attachImgName]').get();
  if(img){
    var imgLength = img.length;
    for (i=0; i<imgLength; i++) {
      attachIMG(img[i], 'show');
    }
  }

  var movie = $('[name=attachMovieName]').get();
  if(movie){
    var movieLength = movie.length;
    for (i=0; i<movieLength; i++) {
      attachMOVIE(movie[i]);
    }
  }

  return false;
}

