// 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
 };
}


// TOPフューチャー
GENDAIns.util.featureAction = function(event){
 GENDAIns.util.featureAction.currentIndex = (GENDAIns.util.featureAction.currentIndex == 9)?1:GENDAIns.util.featureAction.currentIndex+1;
 var p = GENDAIns.util.featureAction.position;
 var c = GENDAIns.util.featureAction.currentIndex;
//alert(c);
 for(var i=1;i<=9;i++){
  if (c==i) {
   new Effect.Morph($('feature-icon'+i),{
    style:'left:' + p[9]['left'] + 'px; top:' + p[9]['top']+'px',
    duration:0.8
   });
  } else {
   new Effect.Morph($('feature-icon'+i),{
    style:'width:90px;height:90px;opacity:1.0;left:' + p[(i>c)?(i-c):i+(9-c)]['left'] + 'px; top:' + p[(i>c)?(i-c):i+(9-c)]['top']+'px',
    beforeStart:function(effect){effect.element.style.visibility = 'visible';},
    duration:0.8
   });
  }
 }
};

GENDAIns.util.headlineAction = function(event){
  var idx = GENDAIns.util.headlineAction.currentIndex;
  var nextIdx = (idx==3)?1:GENDAIns.util.headlineAction.currentIndex+1;
  GENDAIns.util.headlineAction.currentIndex = nextIdx;
  
  new Effect.Fade($('feature-img'+idx));
  new Effect.Appear($('feature-img'+nextIdx));
};

Event.observe(window,'load',function(e){
 (function(){

  // TOPフューチャー
  if ($('top-feature') != undefined){
   var fa = GENDAIns.util.featureAction;
   fa.position = [];
   fa.currentIndex = 9;
   for(var i=1;i<=9;i++){
    var icon = $('feature-icon'+i);
    fa.position[i] = {'left':icon.offsetLeft,'top':icon.offsetTop};
   }
   fa.task = new PeriodicalExecuter(fa,4);
   
   $$('.feature-summary').each(function(o){o.setOpacity(0.8);});
   var ha = GENDAIns.util.headlineAction;
   ha.currentIndex = 1;
   new Effect.Appear($('feature-img'+ha.currentIndex));
   ha.task = new PeriodicalExecuter(ha,4);
  }
  
  //} else {
   // 記事以外の共通モジュール
  //}
 })(); 
},true);

