// ---------- 画像切り替え ----------
var imageLength = 0;
var now = 0;
var pre = 0;
var count = 0;
var countFlg;
var countAll = 0;
var timer;
var fadeSpeed = 1200;
jQuery(function($){
	
	//画像の枚数取得
	imageLength = $("#contents-top #mainvisual div").length;
	
	//初期画像表示
	var startNum = 0;
	now = startNum;
	$("#contents-top #mainvisual div").eq(now).fadeIn(fadeSpeed);
	
	//タイマー開始
	timer = setInterval("setTimer()",4000);
	
});

function setTimer(){
	
	countAll++;
	
	if(countAll < imageLength){
		pre = now;
		if(countFlg){
			count++;
		}else{
			count = now+1;
		}
		now = count % imageLength;
		changeImage();
		countFlg = true;
	}else{
		clearInterval(timer);
	}
	
	
}

function changeImage(){
	
	$("#contents-top #mainvisual div").eq(now).css("z-index", 50+countAll);
	$("#contents-top #mainvisual div").eq(now).fadeIn(fadeSpeed,
		function(){
			$("#contents-top #mainvisual div").eq(pre).css("display", "none");
		}
	);
	
}


var tgtblk = 'mainvisual';
var tgtswf = '/swf/top_724_398.swf';

function setMainSwf() {
	var so=new SWFObject(tgtswf, 'topmain', '724', '398', '9', '#ffffff');
	so.addParam('menu', 'false');
	so.addParam('allowScriptAccess','sameDomain');
	so.write(tgtblk);
}



/*	==============================================
			処理実行
	==============================================	*/
jQuery(function($){

	setMainSwf();

});





