﻿/*  peakmanager_page list controll  */
//list item数
var len = 0; 
// 表示イメージ
var $target;
// 切り替え時間
var deray = 4000;

// タイマーの有効フラグ
var timers = true;

var index = 0; //表示index

$(document).ready(function(){ 
	
	// listのアイテムの非表示
	len = $("#list_item li").length;
	var i = 0;
	if( len > 1 ) {
		while ($("#list_item li")[i])
		{
			$( "#list_item li:eq(" + i + ")" ).hide();
			i++;
		}
		// ローテーションの開始
		$target = $( "#list_item li:eq(" + index + ")" );
		$target.fadeIn( "normal" );
		
		// タイマーの起動
		setTimer();
	} else {
		$("#list_item li:eq(0)").show();
	}
});

function setRotation()
{
	var _index = index;
	index ++;
	if( index >= len ) index = 0;
	
	var $hide_target = $target;
	$target = $( "#list_item li:eq(" + index + ")" );
	
	$hide_target.fadeOut("normal", function()
		{
			$target.fadeIn( "normal" );
		});
}

// timerのセット
function setTimer()
{
	$.timer(4000, function (timer) {
		if( !timers ) 
		{
			timer.stop();
		}
		else
		{	
			setRotation();
			timer.reset(4000);
		}
	});
}
