// Namespace
if(typeof(WEDGEns)=='undefined'){
 var WEDGEns={
  util:{},      // Other Utility Function
  cls:{},       // Class
  show:{},      // Element show Function
  mv:{},        // Element move Function
  cb:{},        // Callback Function
  eom:null      // End Mark
 };
}
// Surfaceエレメント
WEDGEns.cls.surface = Class.create({
 task:null,
 initialize: function(element,options){
  this.element = element;
  this.options = options||{};
  this.delay = this.options['delay'] || 300;
  this.target = this.options['target'] || null;
  this.eventActive = this.active.bindAsEventListener(this);
  this.eventInActive = this.inactive.bindAsEventListener(this);
  Event.observe(this.element,'mouseover',this.eventActive,true);
  Event.observe(this.element,'mouseout',this.eventInActive,true);
 },
 active: function(event){
  try{this.task.cancel();}catch(e){}
  this.task = this.activate().later(this.delay)();
 },
 activate: function(){
  var _e = this;
  return function(){
   var o = $(_e.target);
   o.setOpacity(0.0);
   o.style.display = 'block';
   new Effect.Opacity(o,{from:0.0,to:0.9,duration:0.7});
  };
 }, 
 inactive: function(event){
  try{this.task.cancel();}catch(e){}
 },
 eom:null
});
//-------------------------------------------------------------------
// Welcome BOX Controle
//-------------------------------------------------------------------
function openWelcomeBox(_id){new Effect.Appear($(_id));}
function closeWelcomeBox(_id){$(_id).style.display='none';}
function showWelcomeBox(_name){
  if (readCookie(_name) == null) {
   var expires = '';
   var domain = '; domain=' + location.hostname;
   var date = new Date();
   date.setTime(date.getTime()+(365*24*60*60*1000));
   expires = '; expires=' + date.toGMTString();
   document.cookie = _name + '=1' + expires + domain + '; path=/';
   return true;
  } else {
   return false;
  }
}
//-------------------------------------------------------------------
// Article Flow
//-------------------------------------------------------------------
function ArticleFlow(_id,_i,_cc,_box){
 try{
  new MWProtoFlow($(_id),{
   startIndex: _i,
   captionColor: _cc,
   useBox: _box
  });
 }catch(e){}
}
//---------------------------------------------------------------------
//   for Book Page Cover
//---------------------------------------------------------------------
function fixedCoverBox() {
 var _top = document.documentElement.scrollTop || document.body.scrollTop || 0;
 var _left = document.documentElement.scrollLeft || document.body.scrollLeft || 0;
 var cb = $('cover-background');
 cb.style.top = _top + 'px';
 cb.style.left = _left + 'px';
}
function closeCoverBox() {
 if ($('cover-background') != undefined) { $('cover-background').style.display = 'none';}
 if ($('cover-container') != undefined) { $('cover-container').style.display = 'none';}
 if (Prototype.Browser.IE) {
  $$('select').each(function(a){a.style.visibility = 'visible';});
  Event.stopObserving(window,'scroll',fixedCoverBox);
 }
}
function createContainer() {
 var b = $$('body')[0];
 var cb = document.createElement('div');
 cb.style.display = 'none';
 cb.id = 'cover-background';

 var cn = document.createElement('div');
 cn.style.display = 'none';
 cn.id = 'cover-container';
 var html = '<div class="cover-container-closer" onclick="closeCoverBox();';
 cn.innerHTML = '<div class="container-closer" onclick="closeCoverBox();"></div><div id="cover-container-content" class="cover-container-content"></div>';
 b.appendChild(cb);
 b.appendChild(cn);
}
function openCoverBox(_target) {
 if ($('cover-background') == undefined) {createContainer();}
 var c = $$('body .' + _target)[0];
 var ccc = $('cover-container-content');
 ccc.innerHTML = c.innerHTML;
 var cb = $('cover-background');
 cb.style.display = 'none';
 var cc = $('cover-container');
 cc.style.display = 'none';
 if (Prototype.Browser.IE) {
  $$('select').each(function(a){a.style.visibility = 'hidden';});
  fixedCoverBox();
  Event.observe(window,'scroll',function(e){fixedCoverBox();},true);
 } else {
  cb.style.position = 'fixed';
  cc.style.position = 'fixed';
 }
 new Effect.Appear(cb,{
  from: 0.1,
  to: 0.7,
  duration: 0.5,
  afterFinishInternal:function(ef){
   new Effect.BlindDown(cc,{
    from: 0.0,
    to: 1.0,
    duration: 1.0
   });
  }
 });
}
//-------------------------------------------------------------------
// Block Slide
//-------------------------------------------------------------------
function BlockSlide(_id,obj){
 new Effect.toggle($(_id),'slide',{duration:0.3});
 // Case by Case Code ------------------------------------------------------------------
 //if ($(_id).visible()) {
   //obj.innerHTML = obj.innerHTML.replace(/を閉じる/,'を開く');
 //} else {
   //obj.innerHTML = obj.innerHTML.replace(/を開く/,'を閉じる');
 //}
 // ------------------------------------------------------------------------------------
}

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(){
  if (location.href.match(/articles/) ) {
   ISMEDIAns.util.initFontStyle();
   var C = ISMEDIAns.cls;

   // 記事用サイトナビゲーションタブ切替
   if ($('sitenavi-menu1') != undefined){
    new C.simpleTabGroup({
     tab:'sitenavi-menu',
     detailsuffix:'-box',
     activeid:0,
     count:6,
     bgImagePathPrefix:'http://wedge.ismedia.jp/common/images/v3/common/sitenavi-menu',
     bgImagePathJoint:'-',
     useContinue:true
    });
   }

   // 著者プロフィールタブ切替
   if ($('Dtab1') != undefined){
    new C.simpleTabGroup({
     tab:'Dtab',
     detailsuffix:'-box',
     count:2,
     bgImagePathPrefix:'http://wedge.ismedia.jp/common/images/v1/article/Dtab',
     bgImagePathJoint:'-'
    });
   }

   // 記事下
   Event.observe($$('#share a')[0],'click',function(e){
    if (this.hasClassName('current')) {
    } else {
     this.addClassName('current');
     $$('#latest a')[0].removeClassName('current');
     $('infinity-servicetool').appear();
     $('infinity-latest-all').fade();
    }
   },true);
   Event.observe($$('#latest a')[0],'click',function(e){
    if (this.hasClassName('current')) {
    } else {
     this.addClassName('current');
     $$('#share a')[0].removeClassName('current');
     $('infinity-servicetool').fade();
     $('infinity-latest-all').appear();
    }
   },true);

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

