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

var clock_id='';
var uyunet_cvr=null;
var uyunet_title=null;
var uyunet_title_cvr=null;
var u_1=null;
var u_2=null;
var u_3=null;
var u_4=null;
var u_5=null;
var u_6=null;
var pos_contents=null;
var b_box=null;
var u_up_stat='';
var u_1_init_stat=0;
var u_2_init_stat=0;
var u_3_init_stat=0;
var u_4_init_stat=0;
var u_5_init_stat=0;
var u_6_init_stat=0;
var b_box_stat=0;
var login=null;
var u_en=new Array();

function open_login(){
 if(login==null){
  login=$_('div');
  var w=300;
  var h=180;
  var x=parseInt(0.5*(_winW()-w));
  var y=parseInt(0.5*(_winH()-h));
  var b='solid 0px #ccf';
  setObjSty(login,'p=absolute','w='+w,'h='+h,'x='+x,'y='+y,'bgc=#005','z=10','b='+b);
  setOpa(login,0.85);
  _().appendChild(login);
  var uid=$_('input');
  var pwd=$_('input');
  var u_w=200;
  var u_h=16;
  var u_x=50;
  var u_y=66;
  var p_y=92;
  var u_b='solid 1px #0f0';
  uid.setAttribute('type','text');
  pwd.setAttribute('type','password');
  setObjSty(uid,'p=absolute','w='+u_w,'h='+u_h,'x='+u_x,'y='+u_y,'b='+u_b,'bgc=#005','fgc=#ff0');
  setObjSty(pwd,'p=absolute','w='+u_w,'h='+u_h,'x='+u_x,'y='+p_y,'b='+u_b,'bgc=#005','fgc=#ff0');
  uid.style.fontSize=15+'px';
  pwd.style.fontSize=15+'px';
  uid.style.fontFamily='alial';
  pwd.style.fontFamily='alial';
  uid.style.textAlign='center';
  pwd.style.textAlign='center';
  uid.style.fontWeight='bold';
  pwd.style.fontWeight='bold';
  login.appendChild(uid);
  login.appendChild(pwd);
  var cls=$_('div');
  var cls_img=$_('img');
  setObjSty(cls,'p=absolute','w=30','h=30','x=270','y=0','c=pointer');
  cls_img.setAttribute('src','2010_img/_xc.gif');
  setObjSty(cls_img,'p=absolute','w=9','h=9','x=21','y=0','c=pointer');
  cls.appendChild(cls_img);
  login.appendChild(cls);
  cls.onclick=function(){
   _().removeChild(login);
   login=null;
  }
  login.onclick=function(){popObj(this)};
  popObj(login);
 }
};

function dec(n){
 if(n<10) {n='0'+n;}
 return n;
};

function show_time(){
 var d=new Date();
 var year=d.getFullYear();
 var mon=d.getMonth()+1;
 var day=d.getDate();
 var wd=d.getDay();
 var hh=d.getHours();
 var mm=d.getMinutes();
 var ss=d.getSeconds();
 mon=dec(mon);
 day=dec(day);
 hh=dec(hh);
 mm=dec(mm);
 ss=dec(ss);
 var week=new Array('Sun','Mon','Tus','Wed','Thr','Fri','Sat');
 var str=year+'/'+mon+'/'+day+'&nbsp;('+week[wd]+')&nbsp;'+hh+':'+mm+':'+ss;
 var u_t_1=$('u_t_1');
 u_t_1.innerHTML=str;
};

function change_body_position(){
 var uyuBody=$('uyuBody');
 var w=_winW();
 var h=_winH();
 var x=parseInt(0.5*(w-W));
 var y=parseInt(0.5*(h-H));
 if (x<=25) {x=25;}
 if (y<=25) {y=25;}
 setObjSty(uyuBody,'x='+x,'y='+y);
 if(login!=null){
  var l_x=parseInt(0.5*(w-parseInt(login.style.width)));
  var l_y=parseInt(0.5*(h-parseInt(login.style.height)));
  setObjSty(login,'x='+l_x,'y='+l_y);
 }
};

function startup(){
 // setting layout.
 var uyuBody=$('uyuBody');
 var x=parseInt(0.5*(_winW()-W));
 var y=parseInt(0.5*(_winH()-H));
 if (x<=25) {x=25;}
 if (y<=25) {y=25;}
 setObjSty(uyuBody,'x='+x,'y='+y);
 // setting service clock.
 clock_id=setInterval("show_time()",1000);
 // setting whatsnew events.
 add_whatsnew_c_imgs_boxes();
 set_whatsnew_c_imgs();
 // setting slide show.
 img_play('up');
 // setting whatsnew items.
 init_whatsnew_item();
 get_whatsnew_items();
 set_whatsnew_items();
 // setting whatsnew pr images.
 set_whatsnew_prs();
 // setting toolbar control.
 uyunet_title_cvr=$('uyunet_title_cvr');
 uyunet_title_cvr.onclick=exec_uyunet_title;
 u_1=$('u_1');
 u_1.onclick=exec_u_1;
 u_2=$('u_2');
 u_2.onclick=exec_u_2;
 u_3=$('u_3');
 u_3.onclick=exec_u_3;
 u_4=$('u_4');
 u_4.onclick=exec_u_4;
 u_5=$('u_5');
 u_5.onclick=exec_u_5;
 u_6=$('u_6');
 u_6.onclick=exec_u_6;
 u_en[0]=$('u_1_en');
 u_en[1]=$('u_2_en');
 u_en[2]=$('u_3_en');
 u_en[3]=$('u_4_en');
 u_en[4]=$('u_5_en');
 u_en[5]=$('u_6_en');

 u_1.onmouseover=change_bgc_on;
 u_1.onmouseout=change_bgc_off;
 u_2.onmouseover=change_bgc_on;
 u_2.onmouseout=change_bgc_off;
 u_3.onmouseover=change_bgc_on;
 u_3.onmouseout=change_bgc_off;
 u_4.onmouseover=change_bgc_on;
 u_4.onmouseout=change_bgc_off;
 u_5.onmouseover=change_bgc_on;
 u_5.onmouseout=change_bgc_off;
 u_6.onmouseover=change_bgc_on;
 u_6.onmouseout=change_bgc_off;
 // disable contextmenu.
 //-document.oncontextmenu=function(){return false;}
 if(_ie||_op){
  uyunet_cvr=$('uyunet_cvr');
  uyunet_title_cvr=$('uyunet_title_cvr');
  uyunet_cvr.style.backgroundColor='#ffd700';
  uyunet_title_cvr.style.backgroundColor='#ffd700';
  setOpa(uyunet_cvr,0);
  setOpa(uyunet_title_cvr,0);
 }
 // ajasting lang object position.
 aja_lang();
 // show recommended browsers.
 var browsers=$('browsers');
 browsers.onclick=browsers_box;
 // setting language events.
 set_lang_events();
 // setting whatsnew_img events.
 set_whatsnew_img_evt();
 // setting membership, registration, login events.
 set_members_3events();
 // setting recommended browsers.
 set_recommended_browsers();
 // setting founder.
 set_founder();
};

function set_founder(){
 var founder=$('founder');
 founder.innerHTML="=== 創設者について ===";
 founder.onclick=function(){
  debug('創設者紹介<br/>now underconstruction,<br/>double click to exit.');
 };
};

function set_recommended_browsers(){
 var browsers=$('browsers');
 browsers.innerHTML='----- 推薦ブラウザ -----';
};

function set_members_3events(){
 var ulogin_1=null;
 var ulogin_2=null;
 var ulogin_3=null;
 ulogin_1=$('ulogin_1');
 ulogin_2=$('ulogin_2');
 ulogin_3=$('ulogin_3');
 ulogin_1.onmouseover=function(){this.style.color='#55f';};
 ulogin_2.onmouseover=function(){this.style.color='#55f';};
 ulogin_3.onmouseover=function(){this.style.color='#55f';};
 ulogin_1.onmouseout=function(){this.style.color='#f55';};
 ulogin_2.onmouseout=function(){this.style.color='#f55';};
 ulogin_3.onmouseout=function(){this.style.color='#f55';};
 ulogin_1.onclick=function(){open_member_event(lang_stat,1);};
 ulogin_2.onclick=function(){open_member_event(lang_stat,2);};
 ulogin_3.onclick=function(){open_member_event(lang_stat,3);};
};

function open_member_event(l,x){
 if(x==1){ debug(l+'<br/>入会案内<br/>now underconstruction,<br/>double click to exit.'); return true;}
 if(x==2){ debug(l+'<br/>会員登録<br/>now underconstruction,<br/>double click to exit.'); return true;}
 if(x==3){ debug(l+'<br/>会員認証<br/>now underconstruction,<br/>double click to exit.'); return true;}
};

var cn=null;
var jp=null;
var en=null;
var lang_stat='';

function set_lang_events(){
 cn=$('cn');
 jp=$('jp');
 en=$('en');
 lang_stat='jp';
 jp.style.color='#f0a';
 jp.onmouseover=function(){};
 jp.onmouseout=function(){};
 jp.onclick=function(){};
 cn.style.color='#05a';
 cn.onmouseover=function(){this.style.color='#f0a';};
 cn.onmouseout=function(){this.style.color='#05a';};
 cn.onclick=change_lang;
 en.style.color='#05a';
 en.onmouseover=function(){this.style.color='#f0a';};
 en.onmouseout=function(){this.style.color='#05a';};
 en.onclick=change_lang;
 lang_stat='jp';
};

function change_lang(){
 var id=this.id;
 lang_stat=id;
 var u_1_1=$('u_1_1');
 var u_2_1=$('u_2_1');
 var u_3_1=$('u_3_1');
 var u_4_1=$('u_4_1');
 var u_5_1=$('u_5_1');
 var u_6_1=$('u_6_1');
 var ulogin_1=$('ulogin_1');
 var ulogin_2=$('ulogin_2');
 var ulogin_3=$('ulogin_3');
 var browsers=$('browsers');
 var founder=$('founder');
 if(id=='cn'){
  u_1_1.style.fontFamily='MS UI Gothic';
  u_2_1.style.fontFamily='MS UI Gothic';
  u_3_1.style.fontFamily='MS UI Gothic';
  u_4_1.style.fontFamily='MS UI Gothic';
  u_5_1.style.fontFamily='MS UI Gothic';
  u_6_1.style.fontFamily='MS UI Gothic';
  u_1_1.innerHTML='貝圖鑒';
  u_2_1.innerHTML='貝遊樂';
  u_3_1.innerHTML='貝百科';
  u_4_1.innerHTML='貝友人';
  u_5_1.innerHTML='貝賣買';
  u_6_1.innerHTML='貝論壇';
  ulogin_1.innerHTML='入會簡介';
  ulogin_2.innerHTML='註冊帳號';
  ulogin_3.innerHTML='會員登録';
  browsers.innerHTML='----- 推薦閲覧器 -----';
  if(founder!=null){founder.innerHTML='=== 創始人簡介 ===';}
  cn.style.color='#f0a';
  cn.onmouseover=function(){};
  cn.onmouseout=function(){};
  cn.onclick=function(){};
  jp.style.color='#05a';
  jp.onmouseover=function(){this.style.color='#f0a';};
  jp.onmouseout=function(){this.style.color='#05a';};
  jp.onclick=change_lang;
  en.style.color='#05a';
  en.onmouseover=function(){this.style.color='#f0a';};
  en.onmouseout=function(){this.style.color='#05a';};
  en.onclick=change_lang;
  if(u_up_stat=='u_1'){show_illust();}
  if(u_up_stat=='u_2'){show_enjoy();}
  if(u_up_stat=='u_3'){show_purch();}
  if(u_up_stat=='u_4'){show_links();}
  if(u_up_stat=='u_5'){show_encyc();}
  if(u_up_stat=='u_6'){show_forum();}
 }
 if(id=='jp'){
  u_1_1.style.fontFamily='MS UI Gothic';
  u_2_1.style.fontFamily='MS UI Gothic';
  u_3_1.style.fontFamily='MS UI Gothic';
  u_4_1.style.fontFamily='MS UI Gothic';
  u_5_1.style.fontFamily='MS UI Gothic';
  u_6_1.style.fontFamily='MS UI Gothic';
  u_1_1.innerHTML='貝図鑑';
  u_2_1.innerHTML='貝遊楽';
  u_3_1.innerHTML='貝百科';
  u_4_1.innerHTML='貝仲間';
  u_5_1.innerHTML='貝売買';
  u_6_1.innerHTML='貝談議';
  ulogin_1.innerHTML='入会案内';
  ulogin_2.innerHTML='会員登録';
  ulogin_3.innerHTML='会員認証';
  browsers.innerHTML='----- 推薦ブラウザ -----';
  if(founder!=null){founder.innerHTML='=== 創設者について ===';}
  jp.style.color='#f0a';
  jp.onmouseover=function(){};
  jp.onmouseout=function(){};
  jp.onclick=function(){};
  cn.style.color='#05a';
  cn.onmouseover=function(){this.style.color='#f0a';};
  cn.onmouseout=function(){this.style.color='#05a';};
  cn.onclick=change_lang;
  en.style.color='#05a';
  en.onmouseover=function(){this.style.color='#f0a';};
  en.onmouseout=function(){this.style.color='#05a';};
  en.onclick=change_lang;
  if(u_up_stat=='u_1'){show_illust();}
  if(u_up_stat=='u_2'){show_enjoy();}
  if(u_up_stat=='u_3'){show_purch();}
  if(u_up_stat=='u_4'){show_links();}
  if(u_up_stat=='u_5'){show_encyc();}
  if(u_up_stat=='u_6'){show_forum();}
 }
 if(id=='en'){
  u_1_1.style.fontFamily='alial';
  u_2_1.style.fontFamily='alial';
  u_3_1.style.fontFamily='alial';
  u_4_1.style.fontFamily='alial';
  u_5_1.style.fontFamily='alial';
  u_6_1.style.fontFamily='alial';
  u_1_1.innerHTML='&nbsp;Icong.';
  u_2_1.innerHTML='&nbsp;Enjoy.';
  u_3_1.innerHTML='Encyc.';
  u_4_1.innerHTML='&nbsp;Frien.';
  u_5_1.innerHTML='&nbsp;Purch.';
  u_6_1.innerHTML='Forum.';
  ulogin_1.innerHTML='Membership';
  ulogin_2.innerHTML='Registration';
  ulogin_3.innerHTML='Member Login';
  browsers.innerHTML='----- Recommned Browsers -----';
  if(founder!=null){founder.innerHTML='=== About Founder ===';}
  en.style.color='#f0a';
  en.onmouseover=function(){};
  en.onmouseout=function(){};
  en.onclick=function(){};
  cn.style.color='#05a';
  cn.onmouseover=function(){this.style.color='#f0a';};
  cn.onmouseout=function(){this.style.color='#05a';};
  cn.onclick=change_lang;
  jp.style.color='#05a';
  jp.onmouseover=function(){this.style.color='#f0a';};
  jp.onmouseout=function(){this.style.color='#05a';};
  jp.onclick=change_lang;
  if(u_up_stat=='u_1'){show_illust();}
  if(u_up_stat=='u_2'){show_enjoy();}
  if(u_up_stat=='u_3'){show_purch();}
  if(u_up_stat=='u_4'){show_links();}
  if(u_up_stat=='u_5'){show_encyc();}
  if(u_up_stat=='u_6'){show_forum();}
 }
};

function browsers_box(){
 var uri="2011_browsers.html"+"?t="+$id();
 var method='get';
 var post='';
 sendAjaxReq(uri,method,post,true,show_browsers_box,false);
};

function show_browsers_box(res){
 if(res.responseText!=null){
  b_box=$('b_box');
  if(b_box==null){
   b_box=$_('div');
   b_box.setAttribute('id','b_box');
   var w=502;
   var h=433;
   var x=parseInt($('uyuBody').style.left)+148;
   var y=parseInt($('uyuBody').style.top)+72;
   setObjSty(b_box,'p=absolute','w='+w,'h='+h,'x='+x,'y='+y,'bgc=#008','b=dotted 1px #0f0');
   //-setOpa(b_box,0.5);
   _().appendChild(b_box);
   b_box.innerHTML=res.responseText;
   var b_cls=$_('img');
   b_cls.setAttribute('src','2010_img/cancel.png');
   setObjSty(b_cls,'p=absolute','w=16','h=16','y=-8','x='+parseInt(w-8),'c=pointer');
   //-b_cls.setAttribute('src','2010_img/cd-record.png');
   //-setObjSty(b_cls,'p=absolute','w=20','h=20','y=-10','x='+parseInt(w-10),'c=pointer');
   b_box.appendChild(b_cls);
   b_box_stat=1;
   b_cls.onclick=function(){
    _().removeChild(b_box);
    b_box_stat=0;
    };
   var b_title=$('b_title');
   //-b_title.onmouseover=dragInit;
   //-b_title.onmousedown=dragStart;
   b_box.onmouseover=dragInit;
   b_box.onmousedown=dragStart;
   return true;
  } else {
   return false;
  }
 }
};

function change_bgc_on(){
 var this_bgc=this.style.backgroundColor;
 if(!((this_bgc=='rgb(255, 215, 0)')||(this_bgc=='#ffd700')))
 {this.style.backgroundColor='#0df';}
 if(lang_stat=='en'){
  var str_id=this.id.split('_');
  var child_id=str_id[0]+'_'+str_id[1]+'_1';
  u_en[str_id[1]-1].style.display='block';
 }
};

function change_bgc_off(){
 var this_bgc=this.style.backgroundColor;
 if(!((this_bgc=='rgb(255, 215, 0)')||(this_bgc=='#ffd700')))
 {this.style.backgroundColor='#3f5';}
 if(lang_stat=='en'){
  var str_id=this.id.split('_');
  var child_id=str_id[0]+'_'+str_id[1]+'_1';
  u_en[str_id[1]-1].style.display='none';
 }
};

function clear_contents(){
 // reset slide show counter on top page.
 pos_contents=$('pos_contents');
 if (slide_id!='') {
  clearInterval(slide_id);
  slide_id='';
  c=0;
  //-c=0-【画像スライドを初期状態からカウントする場合】
 }
 pos_contents.innerHTML='';
 // clear recommended browsers show window.
 if (b_box_stat==1) {
  b_box.innerHTML='';
  _().removeChild(b_box);
  b_box_stat=0;
 }
};

function exec_uyunet_title(){
 clear_contents();
 enjoy_init_stat=0;
 illust_init_stat=0;
 show_whatsnew();
 set_btn(uyunet_title_cvr);
};

function exec_u_1(){
 clear_contents();
 enjoy_init_stat=0;
 show_illust();
 set_btn(u_1);
};

function exec_u_2(){
 clear_contents();
 illust_init_stat=0;
 show_enjoy();
 set_btn(u_2);
};

function exec_u_3(){
 clear_contents();
 enjoy_init_stat=0;
 illust_init_stat=0;
 show_encyc();
 set_btn(u_3);
};

function exec_u_4(){
 clear_contents();
 enjoy_init_stat=0;
 illust_init_stat=0;
 show_links();
 set_btn(u_4);
};

function exec_u_5(){
 clear_contents();
 enjoy_init_stat=0;
 illust_init_stat=0;
 show_purch();
 set_btn(u_5);
};

function exec_u_6(){
 clear_contents();
 enjoy_init_stat=0;
 illust_init_stat=0;
 show_forum();
 set_btn(u_6);
};

function set_btn(btn){
 if(btn.id=='u_1'){
  u_1.style.backgroundColor='#ffd700';
  u_2.style.backgroundColor='#3f5';
  u_3.style.backgroundColor='#3f5';
  u_4.style.backgroundColor='#3f5';
  u_5.style.backgroundColor='#3f5';
  u_6.style.backgroundColor='#3f5';
 }
 if(btn.id=='u_2'){
  u_1.style.backgroundColor='#3f5';
  u_2.style.backgroundColor='#ffd700';
  u_3.style.backgroundColor='#3f5';
  u_4.style.backgroundColor='#3f5';
  u_5.style.backgroundColor='#3f5';
  u_6.style.backgroundColor='#3f5';
 }
 if(btn.id=='u_3'){
  u_1.style.backgroundColor='#3f5';
  u_2.style.backgroundColor='#3f5';
  u_3.style.backgroundColor='#ffd700';
  u_4.style.backgroundColor='#3f5';
  u_5.style.backgroundColor='#3f5';
  u_6.style.backgroundColor='#3f5';
 }
 if(btn.id=='u_4'){
  u_1.style.backgroundColor='#3f5';
  u_2.style.backgroundColor='#3f5';
  u_3.style.backgroundColor='#3f5';
  u_4.style.backgroundColor='#ffd700';
  u_5.style.backgroundColor='#3f5';
  u_6.style.backgroundColor='#3f5';
 }
 if(btn.id=='u_5'){
  u_1.style.backgroundColor='#3f5';
  u_2.style.backgroundColor='#3f5';
  u_3.style.backgroundColor='#3f5';
  u_4.style.backgroundColor='#3f5';
  u_5.style.backgroundColor='#ffd700';
  u_6.style.backgroundColor='#3f5';
 }
 if(btn.id=='u_6'){
  u_1.style.backgroundColor='#3f5';
  u_2.style.backgroundColor='#3f5';
  u_3.style.backgroundColor='#3f5';
  u_4.style.backgroundColor='#3f5';
  u_5.style.backgroundColor='#3f5';
  u_6.style.backgroundColor='#ffd700';
 }
 if(btn.id=='uyunet_title_cvr'){
  u_1.style.backgroundColor='#3f5';
  u_2.style.backgroundColor='#3f5';
  u_3.style.backgroundColor='#3f5';
  u_4.style.backgroundColor='#3f5';
  u_5.style.backgroundColor='#3f5';
  u_6.style.backgroundColor='#3f5';
 }
};

function aja_lang(){
 var lang=$('pos_lang');
 if(_ie||_op||_go||_sf){
  lang.style.paddingTop=1+'px';
  lang.style.paddingBottom=0+'px';
 } else {
  lang.style.paddingTop=0+'px';
  lang.style.paddingBottom=1+'px';
 }
};


