var slideshowCounter = 0;
var slideshowCount = 0;
var slideshowFx;

var slideshowInterval;
var slideshowTime = 5000;
	
function slideshowGallery()
{
	slideshowCounter = 0;
	var itemWidth = 377;
	if ( $('slideshow') == null ) return;
	
	var list = $$("#slideshow .slideshowImage")
		
	slideshowFx = new Fx.Scroll('slideshow', {transition: Fx.Transitions.Cubic.easeInOut});
	
	slideshowCount = list.length;
	
	$('slideshowContent').setStyle('width',slideshowCount*itemWidth);
	initInterval();
}

function slideshowPrev()
{
	slideshowCounter--;
	if ( slideshowCounter < 0 )
	{
		slideshowCounter = slideshowCount-1;
	}

	slideshowFx.toElement('item'+slideshowCounter);
}

function slideshowNext()
{
	slideshowCounter++;
	if ( slideshowCount == slideshowCounter )
	{
		slideshowCounter = 0;
	}

	slideshowFx.toElement('item'+slideshowCounter);
}

function initInterval(){
	if( !isNaN(slideshowInterval) ) clearInterval( slideshowInterval );
	slideshowInterval = setInterval( slideshowIntervalShow, slideshowTime );
}

function slideshowIntervalShow(){
	slideshowNext()
}
