/*
 * gt.js
 * 
 * auther: TURBINE INTERACTIVE
 */

$(function(){
/******************************************************
* 
* 背景画像
*
*******************************************************/
	var length = $("#dHomeImage ul li").length;
	var interval = 5000;	// 5秒
	
	// ● オーバー時
	$("#dKeyPager a").hover(function () {
		var this_a =  $(this);
		fSlideshow(this_a);
		
		// 自動スライド ストップ
		$(document).stopTime("slideshow");

	}, function () {
		// 自動スライド
		$(document).everyTime(interval, "slideshow" ,fSlideshowInit);
	});
	
	// 自動スライド
	$(document).everyTime(interval, "slideshow" ,fSlideshowInit);
	$("#dHomeImage li").hide();
	$("#dHomeImage li.active").show();
	
	function fSlideshowInit () {
		var this_a = $("#dKeyPager .active");
		var this_num = $("#dKeyPager a").index(this_a);
		
		var next_num = ( length > (this_num+1)  )? ++this_num : 0;
		var this_a = $("#dKeyPager a:eq("+ next_num +")");
		fSlideshow(this_a);
	}
	function fSlideshow (this_a) {
		var width = 740 // 画像の横幅
		
		var num = parseInt( this_a.attr("title") ) - 1;
		var px = "-" + (num * width);

		$("#dHomeImage li.active").stop(true,true).fadeOut().removeClass("active");
		$("#dHomeImage li:eq("+ num +")").stop(true,true).fadeIn().addClass("active");
		
		// ●の色変え
		$("#dKeyPager a").removeClass("active")
		this_a.addClass("active");
	}
	
/******************************************************
* 
* バナーエリアカルーセル
*
*******************************************************/
	$('#ulBnr').carouFredSel({
		items				: 4,
		direction			: "left",
		next: '#dNext',
		prev: '#dPrev',
		scroll : {
			items			: 1,
			effect			: "easeOutBounce",
			duration		: 1000,	// スクロールするスピード						
			pauseOnHover	: true
		},	
		auto : {
			pauseDuration   : 2000, // スクロールの間隔時間
			pauseOnHover    : true
		}				
	});
	
/******************************************************
* 
* 新着情報スクロール	
*
*******************************************************/
	var settings = {
		showArrows:true, 
		scrollbarWidth: 15,
		scrollbarOnLeft:false
	};
	$('#dNewsMain').jScrollPane(settings);
	
});
	
