/*
 * First created by Jiongtao Huang, Jan 2011.
 * Last modified by Jiongtao Huang, May 2011.
 */

function show_forum(){
 u_up_stat='u_6';
 u_1_init_stat=0;
 u_2_init_stat=0;
 u_3_init_stat=0;
 u_4_init_stat=0;
 u_5_init_stat=0;
 u_6_init_stat=0;
 var uri='';
 if (lang_stat=='jp') {uri='2011_forum/top_jp.html'+'?t='+$id();}
 if (lang_stat=='cn') {uri='2011_forum/top_cn.html'+'?t='+$id();}
 if (lang_stat=='en') {uri='2011_forum/top_en.html'+'?t='+$id();}
 var method='get';
 var post='';
 sendAjaxReq(uri,method,post,true,parse_forum_res,false);
};

function parse_forum_res(ajxRes){
 var enjoy_html=ajxRes.responseText;
 if(pos_contents==null) { pos_contents=$('pos_contents'); }
 pos_contents.innerHTML=ajxRes.responseText;
};

function init_forum(){
 if(u_6_init_stat==0){
  var poem_title=$('poem_title');
  var poem_body=$('poem_body');
  var poem_auth=$('poem_auth');
  var i_5=$('i_5');
  var i_5_cvr=$('i_5_cvr');
  if(!_op){
   setOpa(poem_title,0.75);
   setOpa(poem_body,0.75);
   setOpa(poem_auth,0.75);
  }
  i_5_cvr.onmouseover=function(){
   i_5.src='../../2011_forum/img/i_5_on.png';
   setOpa(i_5,0.98);
  };
  i_5_cvr.onmouseout=function(){
   i_5.src='../../2011_forum/img/i_5_of.png';
   setOpa(i_5,0.55);
  };
  get_bbs_imgs();
  get_bbs_txts();
  u_6_init_stat=1;
  return true;
 } else {
  return false;
 }
};

function get_bbs_txts(){
 var uri="2011_forum/get_txt_list.net"+"?t="+$id();
 var method="get";
 var post='';
 sendAjaxReq(uri,method,post,true,set_bbs_txts,false);
};

function set_bbs_txts(res){
 var txts=res.responseText.split('<::>');
 var out='';
 for (var i=0; i<15; i++) {
  var cell=txts[i].split('::');
  out+=cell[1]+'-'+cell[2]+':'+cell[5]+'<br/>';
 }
 var s_09=$('s_09');
 s_09.innerHTML=out;
};

function get_bbs_imgs(){
 var uri="2011_forum/get_img_list.net"+"?t="+$id();
 var method="get";
 var post='';
 sendAjaxReq(uri,method,post,true,set_bbs_imgs,false);
};

var img_w=new Array();
var img_h=new Array();
var img_x=new Array();
var img_y=new Array();

function set_bbs_imgs(res){
 var path='../../2011_forum/pic_old';
 var imgs=res.responseText.split(',');
 for (var i=0; i<imgs.length; i++) {
  var img_info=imgs[i].split(':');
  img_w[i]=img_info[1];
  img_h[i]=img_info[2];
  var img_a=img_w[i]/img_h[i];
  if( img_w[i]>img_h[i] ){
   img_w[i]=100;
   img_h[i]=parseInt(img_w[i]/img_a);
   img_x[i]=0;
   img_y[i]=parseInt((100-img_h[i])*0.5)+1;
  } else if ( img_w[i]<img_h[i] ) {
   img_h[i]=100;
   img_w[i]=parseInt(img_h[i]*img_a);
   img_x[i]=parseInt((100-img_w[i])*0.5);
   img_y[i]=0;
  } else {
   img_w[i]=100;
   img_h[i]=100;
   img_x[i]=0;
   img_y[i]=0;
  }
  img_uri[i]=path+'/'+img_info[0];
 }

 var img_01=$('img_01');
 var img_02=$('img_02');
 var img_03=$('img_03');
 var img_04=$('img_04');
 var img_05=$('img_05');
 var img_06=$('img_06');
 var img_07=$('img_07');
 var img_10=$('img_10');
 var img_11=$('img_11');
 var img_12=$('img_12');

 img_01.src=img_uri[imgs.length-1];
 img_01.style.width=img_w[imgs.length-1]+'px';
 img_01.style.height=img_h[imgs.length-1]+'px';
 img_01.style.left=img_x[imgs.length-1]+'px';
 img_01.style.top=img_y[imgs.length-1]+'px';

 img_02.src=img_uri[imgs.length-2];
 img_02.style.width=img_w[imgs.length-2]+'px';
 img_02.style.height=img_h[imgs.length-2]+'px';
 img_02.style.left=img_x[imgs.length-2]+'px';
 img_02.style.top=img_y[imgs.length-2]+'px';

 img_03.src=img_uri[imgs.length-3];
 img_03.style.width=img_w[imgs.length-3]+'px';
 img_03.style.height=img_h[imgs.length-3]+'px';
 img_03.style.left=img_x[imgs.length-3]+'px';
 img_03.style.top=img_y[imgs.length-3]+'px';

 img_04.src=img_uri[imgs.length-4];
 img_04.style.width=img_w[imgs.length-4]+'px';
 img_04.style.height=img_h[imgs.length-4]+'px';
 img_04.style.left=img_x[imgs.length-4]+'px';
 img_04.style.top=img_y[imgs.length-4]+'px';

 img_05.src=img_uri[imgs.length-5];
 img_05.style.width=img_w[imgs.length-5]+'px';
 img_05.style.height=img_h[imgs.length-5]+'px';
 img_05.style.left=img_x[imgs.length-5]+'px';
 img_05.style.top=img_y[imgs.length-5]+'px';

 img_06.src=img_uri[imgs.length-6];
 img_06.style.width=img_w[imgs.length-6]+'px';
 img_06.style.height=img_h[imgs.length-6]+'px';
 img_06.style.left=img_x[imgs.length-6]+'px';
 img_06.style.top=img_y[imgs.length-6]+'px';

 img_07.src=img_uri[imgs.length-7];
 img_07.style.width=img_w[imgs.length-7]+'px';
 img_07.style.height=img_h[imgs.length-7]+'px';
 img_07.style.left=img_x[imgs.length-7]+'px';
 img_07.style.top=img_y[imgs.length-7]+'px';

 img_10.src=img_uri[imgs.length-10];
 img_10.style.width=img_w[imgs.length-10]+'px';
 img_10.style.height=img_h[imgs.length-10]+'px';
 img_10.style.left=img_x[imgs.length-10]+'px';
 img_10.style.top=img_y[imgs.length-10]+'px';

 img_11.src=img_uri[imgs.length-11];
 img_11.style.width=img_w[imgs.length-11]+'px';
 img_11.style.height=img_h[imgs.length-11]+'px';
 img_11.style.left=img_x[imgs.length-11]+'px';
 img_11.style.top=img_y[imgs.length-11]+'px';

 img_12.src=img_uri[imgs.length-12];
 img_12.style.width=img_w[imgs.length-12]+'px';
 img_12.style.height=img_h[imgs.length-12]+'px';
 img_12.style.left=img_x[imgs.length-12]+'px';
 img_12.style.top=img_y[imgs.length-12]+'px';

 var v_01=$('v_01');
 var v_02=$('v_02');
 var v_03=$('v_03');
 var v_04=$('v_04');
 var v_05=$('v_05');
 var v_06=$('v_06');
 var v_07=$('v_07');
 var v_10=$('v_10');
 var v_11=$('v_11');
 var v_12=$('v_12');

 if(_ie){
  v_01.style.backgroundColor='#001';
  v_02.style.backgroundColor='#001';
  v_03.style.backgroundColor='#001';
  v_04.style.backgroundColor='#001';
  v_05.style.backgroundColor='#001';
  v_06.style.backgroundColor='#001';
  v_07.style.backgroundColor='#001';
  v_10.style.backgroundColor='#001';
  v_11.style.backgroundColor='#001';
  v_12.style.backgroundColor='#001';

  setOpa(v_01,0);
  setOpa(v_02,0);
  setOpa(v_03,0);
  setOpa(v_04,0);
  setOpa(v_05,0);
  setOpa(v_06,0);
  setOpa(v_07,0);
  setOpa(v_10,0);
  setOpa(v_11,0);
  setOpa(v_12,0);
 }

 v_01.onmouseover=function(){setOpa(img_01,1.0);};
 v_02.onmouseover=function(){setOpa(img_02,1.0);};
 v_03.onmouseover=function(){setOpa(img_03,1.0);};
 v_04.onmouseover=function(){setOpa(img_04,1.0);};
 v_05.onmouseover=function(){setOpa(img_05,1.0);};
 v_06.onmouseover=function(){setOpa(img_06,1.0);};
 v_07.onmouseover=function(){setOpa(img_07,1.0);};
 v_10.onmouseover=function(){setOpa(img_10,1.0);};
 v_11.onmouseover=function(){setOpa(img_11,1.0);};
 v_12.onmouseover=function(){setOpa(img_12,1.0);};

 v_01.onmouseout=function(){setOpa(img_01,0.62);};
 v_02.onmouseout=function(){setOpa(img_02,0.62);};
 v_03.onmouseout=function(){setOpa(img_03,0.62);};
 v_04.onmouseout=function(){setOpa(img_04,0.62);};
 v_05.onmouseout=function(){setOpa(img_05,0.62);};
 v_06.onmouseout=function(){setOpa(img_06,0.62);};
 v_07.onmouseout=function(){setOpa(img_07,0.62);};
 v_10.onmouseout=function(){setOpa(img_10,0.62);};
 v_11.onmouseout=function(){setOpa(img_11,0.62);};
 v_12.onmouseout=function(){setOpa(img_12,0.62);};

};

