var slide;
var SlideArea = function(){};
SlideArea.prototype = {
	intervalTime:5,
	currentIdx:null,
	init:function(){
		//参照の取得と変数の設定
		this.containerElem = $("#topMainStage");
		this.listElems = $("ul>li", this.containerElem);
		this.listLength = this.listElems.length;
		//フレームを設定
		var frameElem = $("<div id='topMainStageFrame'></div>");
		this.containerElem.append(frameElem);
		//IE6対応		
		if (typeof document.documentElement.style.maxHeight == "undefined") {
			DD_belatedPNG.fix("#topMainStageFrame");
		}
		//タイマー処理の設定
		this.nInterval = setInterval(function(){
			slide.nextPic();
		}, this.intervalTime * 1000);
		//一枚目の写真を表示
		this.nextPic();
	},
	nextPic:function(){
		//次に表示するインデックス番号を決定
		var nextIdx = (this.currentIdx == null) ? 0:((this.currentIdx + 1) % this.listLength);
		//画像群の表示・非表示
		this.listElems.each(function(idx){
			if(idx == nextIdx){
				$(this).fadeIn();
			}else{
				$(this).fadeOut();
			}
		});
		//変数の更新
		this.currentIdx = nextIdx;
		nextIdx = null;
	}
}

//初期化メソッドの実行
$(document).ready(function(){
	slide = new SlideArea();
	slide.init();
});
