var i = 1;

var int = 0;

var list = 3;

var time = 6000;



$(document).ready(function(){



	// メイン画像切り替え（タイマー）

	var int = setInterval("doFade(i)",time);



	// 画像光（画像ホバー）

	$("#keyVisualImage").hover(function(){

		$(this).fadeTo(300,0.5);

		$(this).fadeTo(600,1);

		clearInterval(int);

		i =1;

	},function(){

		int = setInterval("doFade(i)",time);

	});



	// ステージからマウスアウト

	$("#keyVisual").hover(function(){



	},function(){

		$("#targetMc").fadeOut("slow",function() {

			$(this).attr("src","images/slideshow/pic2.jpg");

			$(this).fadeIn("slow");

		});

	});



	// ボタン画像切り替え（ボタンホバー）

	$("img.on").hover(function(){

			$(this).attr("src", $(this).attr("src")

				.replace(/^(.+)(\.[a-z]+)$/, "$1_on$2"));

			clearInterval(int);

			i =1;

		},function(){

			$(this).attr("src", $(this).attr("src")

				.replace(/^(.+)_on(\.[a-z]+)$/, "$1$2"));

			int = setInterval("doFade(i)",time);

	});



	// メイン画像切り替え（ボタンホバー）

	$("#keyVisualNavi li").hover(

		function(){
			var src = 'images/slideshow/' + $(this).attr("id") + '.jpg';

			$("#targetMc").fadeTo(10,0.7,function(){
				$(this).attr("src",src);
				$(this).fadeTo(400,1);
			});

			var link = $(this).attr("href");
			$("#keyVisualImage a").attr("href", link);
		}
		,
		function(){}
	);


});



// メイン画像切り替え（タイマー）

function doFade() {



	var str = new String();

	str += "images/slideshow/pic";

	str += i;

	str += ".jpg";



	$("#targetMc").fadeOut("slow",function() {

		$(this).attr("src",str);

		$(this).fadeIn("slow");

	});



	if (i >= list) {

		clearInterval(int);

		i =1;

	}else{

		i++

	}



}



function preload(arrayOfImages) {

	$(arrayOfImages).each(function(){

		$('<img/>')[0].src = this;

	});

}



preload([
				 
	'images/slideshow/pic00.jpg',
	
	'images/slideshow/pic1.jpg',

	'images/slideshow/pic2.jpg',

	'images/slideshow/pic3.jpg'



]);





