var _slides;
var _duration = 7500;
var _all_slides = [];
var _autoplay = true;
var _current;
var z_index = 0;
function initSlideshow()
{
	if(document.getElementById('gallery'))
	{
		_current = 0;
		_all_slides = $("#gallery li");
		_slides = _all_slides.length;
		if(_slides>1)
		{
			_all_slides.css({"position": "absolute", "top": 30, "left": 31, "opacity": 0, "z-index": 0});
			$(_all_slides[0]).css({"opacity": 1, "z-index": 1});

			setTimeout('rotate(' + 0 +')', _duration);
		}
	}
}
function rotate(_index)
{
	if(_autoplay)
	{
		$(_all_slides[_index]).animate({"opacity": 0});
		if(_index==_slides-1)
			_index=-1;

		$(_all_slides[++_index]).css({"z-index": ++z_index});			
		$(_all_slides[_index]).animate({"opacity": 1});
		
		_current = _index;
		setTimeout('rotate(' + _index + ')', _duration);
	}
}

function initProductSlider()
{
	if(document.getElementById('big-image'))
	{
		var slides;
		var current = 0;
		var all_slides = $("#big-image li");
		slides = all_slides.length;
		all_slides.css({"position": "absolute", "top": 23, "left": 19, "opacity": 0});
		$(all_slides[0]).css({"opacity": 1});
		all_slides[0].parentNode.style.height = all_slides[0].clientHeight + 49 + "px";

		var all_thumbs = $('#thumbnails li');
		$(all_thumbs).each(function(el)
		{
			$(all_thumbs)[el].href = 'javascript:;';
			$(all_thumbs[el]).click(function()
			{
				if(el!=current)
				{
					$(all_slides[current]).fadeTo("slow", 0);
					$(all_slides[el]).fadeTo("slow", 1);
					$(all_slides[el]).parent().animate({height: all_slides[el].clientHeight + 49 + "px"}, { duration: 200, queue:false });
					current = el;
				}
			});
		});
	}
}

if (window.addEventListener)
{
	window.addEventListener("load", initSlideshow, false);
	window.addEventListener("load", initProductSlider, false);
}
else if (window.attachEvent)
{
	window.attachEvent("onload", initSlideshow);
	window.attachEvent("onload", initProductSlider);
}