
var timeAlpha = 1000;//クロスフェード時間
var time = 15000; //切り替えのタイミング

function slideNextSwitch() {
	
	var $active = $('#slideshow a.active');
	
	//activeクラスがデフォルトでどこにも着いていなかった場合の処理
    if ( $active.length == 0 ) $active = $('#slideshow a:last');


    var $next =  $active.next().length ? $active.next() : $('#slideshow a:first');

    $active.addClass('last-active');
	$next.css({opacity: 0.0}).addClass('active').animate({opacity: 1.0}, timeAlpha, function() {$active.removeClass('active last-active');});

}

function slidePrevSwitch() {
	
	var $active = $('#slideshow a.active');
	var $next =  $active.prev().length ? $active.prev() : $('#slideshow a:last');
	
    $active.addClass('last-active');
	$next.css({opacity: 0.0}).addClass('active').animate({opacity: 1.0}, timeAlpha, function() {$active.removeClass('active last-active');});

}

$(function() {

	var timerID = setInterval( "slideNextSwitch()", time );
	
	var $nextBtn = $("#xNextClick");
	var $prevBtn = $("#xPrevClick");
	
	//Nextボタン
	$nextBtn.click(function(){slideNextSwitch(); return false;});
	$nextBtn.hover(function(){clearInterval(timerID);},function () {timerID = setInterval("slideNextSwitch()", time); return false;});
	
	//Prevボタン
	$prevBtn.click(function(){slidePrevSwitch(); return false;});
	$prevBtn.hover(function(){clearInterval(timerID);},function () {timerID = setInterval("slideNextSwitch()", time); return false;});
	
});
