var slideShow =
{
	init: function ()
	{
		this.setList();
		
		if (this.countList > '0')
		{
			this.actualIndex = this.countList - '1';
			this.showItem(this.actualIndex, true);
			
			if (this.countList > '1')
			{
				this.setTimer();
			}
		}
	},
	setList: function ()
	{
		this.list = new Array();
		
		$('#hp_slideshow div.panel').each
		(
			function (index)
			{
				var page_id = $(this).attr('id').substr('1');
				slideShow.list[index] =
				{
					index: index,
					page_id: page_id,
					title: $(this).find('h2').html(),
					anotation: $(this).find('p').html(),
					url: $('#f' + page_id).find('a').attr('href'),
					thumb: $(this).find('img').attr('src'),
					img: $('#f' + page_id).find('a').find('img').attr('src')
				};
				
				$(this).hover
				(
					function ()
					{
						slideShow.showItem(index);
						clearTimeout(slideShow.timer);
						//slideShow.timer = setTimeout('slideShow.showNextItem();', '3000');
					},
					function ()
					{
						slideShow.timer = setTimeout('slideShow.showNextItem();', '3000');
					}
				);
				/*
				$(this).bind
				(
					'click',
					function()
					{
						slideShow.showItem(index);
					}
				);
				*/
			}
		);
		
		this.countList = this.list.length;
	},
	showItem: function (index, start)
	{
		if (this.actualIndex != index || start == true)
		{
			$('#hp_slideshow .panel').removeClass('showing');
			$('#hp_slideshow .image_info .title').html(this.list[index].title);
			$('#hp_slideshow .image_info .anotation').html(this.list[index].anotation);
			$('#hp_slideshow .filmstrip img.show').fadeOut().removeClass('show');
			$('#f' + this.list[index].page_id + ' img').fadeIn().addClass('show');
			$('#p' + this.list[index].page_id).addClass('showing');
			
			this.actualIndex = index;
		}
	},
	showNextItem: function ()
	{
		var index = this.actualIndex - '1';
		if (index < '0')
		{
			index = this.countList - '1';
		}
		
		this.showItem(index, true);
		
		this.timer = setTimeout('slideShow.showNextItem();', '3000');
	},
	setTimer: function ()
	{
		this.timer = setTimeout('slideShow.showNextItem();', '3000');
	}
}

$(document).ready
(
	function ()
	{
		slideShow.init();
		/*
		$('.panel_pos .panel a').hover
		(
			function ()
			{
				
			}
		);
		*/
	}
);
