
var Very = {
	start: function() {
		if(!$('topBody')) return;
		this.links = [], this.sbCount = [];
		
		// 今月の画像ディレクトリ
		//--------------------------------------
		var directory = 201004;
		
		
		// ムービー画像の枚数(表紙画像除く)
		//--------------------------------------
		this.count = 3;
		
		
		// ビューワー画像の枚数 [ファイル数, 接頭句]
		//--------------------------------------
		this.sbCount[0] = [5, 'new'];
		
		
		// 次号予告の枚数 [ファイル数, 接頭句]
		//--------------------------------------
		this.sbCount[1] = [1, 'next'];
		
		
		// 表紙画像ファイル名
		//--------------------------------------
		this.topimg = "201004/topcover.jpg";
		
		
		// 定期購読リンク先
		//--------------------------------------
		this.links[0] = "https://www.kobunsha.com/shelf/form/subscription/";
		
		
		// バックナンバーリンク先
		//--------------------------------------
		this.links[1] = "http://www.kobunsha.com/shelf/magazine/backnumber?seriesid=102003";
		
		
		// リンクボタンの始点位置[x,y]
		//--------------------------------------
		var pos = $('link_chase').getStyles('left', 'top');
		this.position = { x:pos.left, y:pos.top };
		
		
		// ディレクトリパス
		//--------------------------------------
		var path = location.href.replace('index.html', '').replace(location.hash, ''); 
		this.sitepath = path.replace('#', '');
		this.imgpath = this.sitepath+'top_img/'+directory+'/';
		
		
		// 代替コンテンツ指定
		//--------------------------------------
		if(Browser.Engine.trident4) {
			this.noscript = $$('noscript')[0].innerHTML;
		} else if(Browser.Engine.gecko) {
			this.noscript = $$('noscript')[0].firstChild.nodeValue;
		} else {
			this.noscript = '<img src="'+this.sitepath+'top_img/'+this.topimg+'" />';
		}
		$$('noscript').destroy();
		
		Killer.init();
	}
};



var Killer={init:function(){this.step=0;this.killer=$("jscontent");this.overlay=new Element("div",{id:"fx_overlay"});this.fx=new Fx.Tween(this.overlay,{duration:750,transition:"quad:in",link:"chain",onComplete:this.next.bind(this)});this.linkDiv=new Element("div",{id:"fx_links","class":"fx_vanish",styles:{left:Very.position.x,top:Very.position.y}});[new Element("div",{id:"fx_linkNew"}),new Element("div",{id:"fx_linkNext"}),new Element("a",{id:"fx_linkBuy",target:"_blank",href:Very.links[0]}),new Element("a",{id:"fx_linkNumber",target:"_blank",href:Very.links[1]})].each(function(D,C){D.set({styles:{"margin-top":-15,opacity:0},morph:{duration:450},events:{mouseenter:function(){D.addClass("hover")},mouseleave:function(){D.removeClass("hover")}}});D.inject(this.linkDiv)},this);this.linkDiv.inject(this.killer);var B=[];for(i=0;i<Very.count;i++){var A=i+1;B[i]=Very.imgpath+A+".jpg"}B.push(Very.sitepath+"top_img/"+Very.topimg);this.imgs=new Asset.images(B,{onComplete:this.image.bind(this)});this.timeout=this.err.delay(5000,this)},err:function(){this.killer.setStyle("opacity",0);this.killer.innerHTML=Very.noscript;this.killer.fade("in");$clear(this.timeout)},image:function(){$clear(this.timeout);this.imgs.each(function(A){A.inject(this.killer,"top").set("class","fx_vanish fx_imgs")},this);this.loader()},loader:function(){var A=$("killerLoader").set("tween",{onComplete:this.set.bind(this,A)});A.fade("out")},set:function(A){this.overlay.inject(this.linkDiv,"before");this.imgs[0].removeClass("fx_vanish");A.destroy();this.fade="out";this.fx.start("opacity",0)},start:function(A){this.fade=A?"in":"out";this.fx.start("opacity",A)},next:function(){if(this.fade=="out"){this.step++;if(this.step==this.imgs.length){this.step==0;$clear(this.timer);this.appearLink();return }this.timer=this.start.delay(1200,this,1)}else{if(!this.imgs[this.step]){return }this.imgs[this.step].removeClass("fx_vanish");this.imgs[this.step-1].addClass("fx_vanish");this.start(0)}},appearLink:function(){var A=0;this.linkDiv.getChildren().each(function(B){var C=B.get("morph");C.start.delay(A,C,{"margin-top":0,opacity:1});A+=150},this);this.linkDiv.removeClass("fx_vanish")}};window.addEvent("domready",Very.start.bind(Very));