var startSlideShow = function(imgs)
{
	$('.prodBox').data('imgs', imgs);
	$('#prodIMG').everyTime(5000, 'slideshow', nextImg);
}//startSlideShow

var swapImages = function(i)
{
	$('#prodIMG').stopTime('slideshow');

	var $new = $('#prodIMG').clone(true);

	var imgs = $('.prodBox').data('imgs');
	$img = imgs[i];

	if($img == undefined)
	{
		alert(i);
		return;
	}//if !img

	$new.attr('src', $img.attr('src'));

	$new.attr('index', i);
	$new.css('z-index', 0);

	$('#prodIMG').after($new);
	$('#prodIMG').fadeOut(500, afterImageSwap);
	$('#prodIMG').attr('id', 'die');
}//selectImage

var afterImageSwap = function()
{
	$(this).remove();

	$('#prodIMG').css('z-index', 50);

	var imgs = $('.prodBox').data('imgs');
	$img = imgs[Number($('#prodIMG').attr('index'))];

	$('#prodLink').attr('href', $img.attr('url'));
	$('#prodIMG').everyTime(5000, 'slideshow', nextImg);
}//afterImageSwap

var prevImg = function ()
{
	var i = Number($('#prodIMG').attr('index')) - 1;
	var imgs = $('.prodBox').data('imgs');
	if(imgs[i] == undefined)i = imgs.length - 1;

	swapImages(i);
}//prevImg

var nextImg = function ()
{
	var i = Number($('#prodIMG').attr('index')) + 1;
	var imgs = $('.prodBox').data('imgs');
	if(imgs[i] == undefined)i = 0;

	swapImages(i);
}//nextImg