﻿$(function(){

	/*CSVデータの取得（リンク先）*/
	$.get("./top/data/data.csv", null,
	function(data){
		jQuery.each(data.split("\r\n"),
		function(i,val){
			split2 = val.split(",");
			$(".effect1#"+split2[0]).parent().attr("href", split2[1]);	
			if(i==0){
				$("#img").parent().attr("href", split2[1]);	
			}
		})
	});
	/* */

	/*初期hover時画像表示*/	
	$("#1").attr({
		"src": "./top/img/demo_bar1_over.jpg"
	});

	//自動画像切替タイマーの開始
	var interval = 2300;
	var i = 2;
	var timer = $.timer(interval, function(timer){

		$(".effect1#" + i).hover();
		if (i == 5) {
			i = 1;
		}
		else {
			i = i + 1;
		}
	});

	$(".effect1").hover(function(){
		timer.stop();		//自動画像切替の停止

		/*hover時画像の取り消し*/	
		$(".effect1").each(function(i, s){
			$(this).attr({
				"src": "./top/img/demo_bar" + (i+1) + ".jpg"
			});
		});

		/*hover時画像表示*/	
		$(this).attr({
			"src": "./top/img/demo_bar" + this.id + "_over.jpg"
		});

		/*ステージ上に画像表示*/
		$("#img").attr({
			"src": "./top/img/demo" + this.id + ".jpg"
		});

		/*URLの切替*/
		$("#img").parent().attr("href", $(this).parent().attr("href"));

		$("#img").hide();
		$("#img").fadeIn(500);
	}, function(){

		timer.reset(interval);
	});
});
