// Namespace
if(typeof(GENDAIns)=='undefined'){
 var GENDAIns={
  util:{},      // Other Utility Function
  cls:{},       // Class
  show:{},      // Element show Function
  mv:{},        // Element move Function
  cb:{},        // Callback Function
  eom:null      // End Mark
 };
}

// シンプルタブグループ
GENDAIns.cls.simpleTabGroup = Class.create(ISMEDIAns.cls.tabGroup,{
 initialize: function($super,options){
  $super(options);
  this.activeClass = this.options['activeClass'] || 'active';
  this.inactiveClass = this.options['inactiveClass'] || 'inactive';
  // ナビゲーション背景情報
  this.naviContainer = this.options['naviContainer'] || 'navi-menu';
  this.activating = function(){
   for (var i=1; i<=this.count; i++){
    if (i==this.activeid) {
     $(this.tab + i ).className = this.activeClass;
    } else {
     $(this.tab + i ).className = this.inactiveClass;
    }
   }
  };
 },
 eom:null
});

// TOPフューチャー
GENDAIns.util.featureAction = function(event){
 GENDAIns.util.featureAction.currentIndex = (GENDAIns.util.featureAction.currentIndex == 7)?1:GENDAIns.util.featureAction.currentIndex+1;
 var p = GENDAIns.util.featureAction.position;
 var c = GENDAIns.util.featureAction.currentIndex;
 for(var i=1;i<=7;i++){
  if (c==i) {
   new Effect.Morph($('f-icon'+i),{
    style:'width:342px;height:430px;opacity:0.0;left:' + p[7]['left'] + 'px; top:' + p[7]['top']+'px',
    afterFinish:function(effect){effect.element.style.visibility = 'hidden';},
    duration:0.8
   });
   new Effect.Morph($('f-img'+i),{
    style:'left:0px;top:0px;width:342px;height:430px;opacity:1.0;',
    beforeStart:function(effect){
     effect.element.style.width = '138px';
     effect.element.style.height = '136px';
     effect.element.style.top = '0px';
     effect.element.style.top = '0px';
     effect.element.setOpacity(0.4);
    },
    duration:0.8
   });
  } else {
   new Effect.Morph($('f-icon'+i),{
    style:'width:140px;height:136px;opacity:1.0;left:' + p[(i>c)?(i-c):i+(7-c)]['left'] + 'px; top:' + p[(i>c)?(i-c):i+(7-c)]['top']+'px',
    beforeStart:function(effect){effect.element.style.visibility = 'visible';},
    duration:0.8
   });
   new Effect.Morph($('f-img'+i),{
    style:'left:400px;top:172px;width:140px;height:136px;opacity:0.0;',
    duration:0.8
   });
  }
 }
};

//ブックマーク
function BMdelicious(_url,_title){ISMEDIAns.util.bm.delicious(_url,_title);}
function BMdigg(_url,_title){ISMEDIAns.util.bm.digg(_url,_title);}
function BMhatena(_url,_title){ISMEDIAns.util.bm.hatena(_url,_title);}
function BMnewsing(_url,_title){ISMEDIAns.util.bm.newsing(_url,_title);}
function BMyahoo(_url,_title){ISMEDIAns.util.bm.yahoo(_url,_title);}
function BMgoo(_url,_title){ISMEDIAns.util.bm.goo(_url,_title);}
function BMlivedoor(_url,_title){ISMEDIAns.util.bm.livedoor(_url,_title);}
function BMfurl(_url,_title){ISMEDIAns.util.bm.furl(_url,_title);}
function BMstumbleupon(_url,_title){ISMEDIAns.util.bm.stumbleupon(_url,_title);}
function BMgoogle(){ISMEDIAns.util.bm.google();}
function BMgoogleR(){ISMEDIAns.util.bm.googleR();}
function BMfriendfeed(_url,_title){ISMEDIAns.util.bm.friendfeed(_url,_title);}
function BMmixi(_url,_key){ISMEDIAns.util.bm.mixi(_url,_key);}
//スタイルシート切り替えと印刷用ページ
function setActiveStyleSheet(title){ISMEDIAns.util.setFontStyleSheet(title);}
function printWindow(url,w,h){ISMEDIAns.util.openWindow(url,w,h);}

Event.observe(window,'load',function(e){
 (function(){

  // TOPフューチャー
  if ($('top-feature') != undefined){
   var fa = GENDAIns.util.featureAction;
   fa.position = [];
   fa.currentIndex = 7;
   $$('.f-summary').each(function(o){o.setOpacity(0.8);});
   $('f-icon7').setOpacity(0.0);
   for(var i=1;i<=7;i++){
    var icon = $('f-icon'+i);
    fa.position[i] = {'left':icon.offsetLeft,'top':icon.offsetTop};
   }
   fa.task = new PeriodicalExecuter(fa,4);
   Event.observe('featuer-controler','click',function(ev){
    if (fa.task != null){
     fa.task.stop();
     fa.task = null;
     Event.element(ev).src = '/common/images/v1/top/top-feature-start.gif';
     Event.element(ev).alt = 'start';
    } else {
     fa();
     fa.task = new PeriodicalExecuter(fa,4);
     Event.element(ev).src = '/common/images/v1/top/top-feature-stop.gif';
     Event.element(ev).alt = 'stop';
    }
   },false);
  }

  // TOP Author
  if ($('main-column-authorlists') != undefined){
   // 名前空間参照設定(lib.jsが前提)
   var C = ISMEDIAns.cls;   // クラス定義参照
   GENDAIns.util.topSpace = {};    // 変数定義場所名前空間
   var S = GENDAIns.util.topSpace; // 名前空間参照設定

   // 著者リスト動作設定
   S.authorList = $('main-column-authorlists').getElementsByTagName('li');        // 著者リスト取得
   S.authorListCount = S.authorList.length;       // 著者定義数
   S.authorShowListCount = 0;     // 画面表示著者数

   // 著者詳細表示関数(_o:著者エレメント,_i:著者エレメントインデックス)
   S.authorDetailShow = function(_o,_i){
    var a = (_o == null) ? S.authorList[_i] : _o;
    var d = $('authorlist-latestcolumn'); // 著者詳細表示エレメント
    var s = a.getElementsByClassName('author-latest-article')[0]; // 著者リスト内の詳細内容エレメント
    d.innerHTML = s.innerHTML;
   };
   for(var i=0;i<S.authorListCount;i++){
    // スタイル指定による画面表示数取得
    if (S.authorList[i].style.display=='block') {
     S.authorShowListCount += 1;
    }
    // 著者画像マウスオーバ時イベント
    Event.observe(S.authorList[i],'mouseover',function(e){S.authorDetailShow(this);},true);
   }
   S.authorTopIndex = 0;  // 先頭著者インデックス
   S.authorDetailShow(null,S.authorTopIndex);     // 初期表示
   // 移動ボタン動作設定
   // Nextボタン
   Event.observe('authorlist-next-id','click',function(e){
    // インクリメント(先頭著者インデックス変更)
    (S.authorTopIndex < (S.authorListCount - S.authorShowListCount )) ? S.authorTopIndex++ : null;
    // 表示著者変更
    for(var i=0;i<S.authorListCount;i++){
     S.authorList[i].style.display = (( i<S.authorTopIndex )||( i>(S.authorTopIndex + S.authorShowListCount -1) ))? 'none': 'block';
    }
    S.authorDetailShow(null,S.authorTopIndex);
    Event.stop(e);
   },true);
   // Prevボタン
   Event.observe('authorlist-prev-id','click',function(e){
    // デクリメント(先頭著者インデックス変更)
    (S.authorTopIndex>0) ? S.authorTopIndex--:null;
    // 表示著者変更
    for(var i=0;i<S.authorListCount;i++){
     S.authorList[i].style.display = (( i<S.authorTopIndex )||( i>(S.authorTopIndex + S.authorShowListCount -1) ))? 'none': 'block';
    }
    S.authorDetailShow(null,S.authorTopIndex);
    Event.stop(e);
   },true);
  }

  //if (location.href.match(/articles/) ) {
   ISMEDIAns.util.initFontStyle();
   var C = ISMEDIAns.cls;



   // サイト共通ナビゲーションタブ切替
   if ($('sitenavi-menu1') != undefined){
    var c = $$('#sitenavi-menu > ul > li').size();
    ISMEDIAns.util.test = new C.tabGrouping({
     tab:'sitenavi-menu',
     detailsuffix:'-box',
     count:c,
     useDetailOver:true,
     sensitivity:300,
  	 activating:function(){
  	  for(var i=1;i<=this.count;i++){
  	   $(this.tab+i).className = 'normal';
  	  }
  	  $(this.tab+this.activeid).className = 'reverse';
      new Effect.BlindDown(this.tab+this.activeid+this.detailsuffix,{duration:0.3,
       beforeStartInternal:function(effect){
        effect.element.style.display = 'none';
       }
      });
  	 },
  	 inactivating:function(){
  	  if ( this.beforeid !=0) {
  	  $(this.tab+this.beforeid).className = 'normal';
      new Effect.BlindUp(this.tab+this.beforeid+this.detailsuffix,{duration:0.3,
       beforeStartInternal:function(effect){
        effect.element.style.display = 'block';
       }
      });
      }
  	 }
    });
   }

  // サブコンテンツのタブ切替
  if ($('SCtab1') != undefined){
   new ISMEDIAns.cls.simpleTabGrouping({
    tab:'SCtab',
    detail:'SC',
    count:2,
    activeid:2,
    bgImagePathPrefix:'http://gendai.ismedia.jp/common/images/v1/common/SCtab',
    bgImagePathJoint:'-'
   });
  }

  // YoutubeEMBED
  try{if( $('youtube') != undefined){
   var moviesrc = $('youtube').innerHTML;
   var flashvars = {};
   var params = {wmode :'transparent',allowfullscreen :'true',allowscriptaccess :'always'};
   var attributes = {hl:'ja',fs:'1'};
   swfobject.embedSWF(moviesrc,'youtube','425', '344', '8','http://www.ismedia.jp/common/js/lib/expressInstall.swf',flashvars,params,attributes);
  }}catch(err){}

  //} else {
   // 記事以外の共通モジュール
  //}
 })(); 
},true)

