function initSlideshowControls()
{
	timeLength = 8;
	elNavDirection = $$("div#zone2 div.multimediaData p.navDirection")[0];

	if(elNavDirection)
	{
		var slideshowPlayPause = new Element('a', { 'id': 'slideshowPlayPause' });
		var pauseText = "Pause";
		var playText = "Play";
		if(!SLpaused)
		{
			slideshowPlayPause.update(pauseText);
			slideshowPlayPause.toggleClassName("btn" + playText);
		}
		else
		{
			slideshowPlayPause.update(playText);
			slideshowPlayPause.toggleClassName("btn" + pauseText);
		}
		
		elNavDirection.insert({'after':slideshowPlayPause});
	}
	
	if(relocationUrl && slideshowPlayPause)
	{
		perEx = null;
		
		if(!SLpaused)
		{
			perEx = new PeriodicalExecuter(function(pe)
			{
				SCslideAdvance(relocationUrl);
			}
			, timeLength);
		}
		
		Event.observe(slideshowPlayPause, 'click', function()
		{
			if(perEx)
			{
				perEx.stop();
				perEx = null;
				slideshowPlayPause.update(playText);
				slideshowPlayPause.toggleClassName("btn" + playText);
			}
			
			else
			{
				perEx = new PeriodicalExecuter(function(pe)
				{
					SCslideAdvance(relocationUrl);
				}
				, timeLength);
				slideshowPlayPause.update(pauseText);
				slideshowPlayPause.toggleClassName("btn" + pauseText);
			}
		});
		
		$$("input, textarea, select, option, button").each(function(inputEl)
		{
			Event.observe(inputEl, 'focus', function()
			{
				if(perEx)
				{
					perEx.stop();
					perEx = null;
					slideshowPlayPause.update(playText);
					slideshowPlayPause.toggleClassName("btn" + playText);
				}
			});
		});
	
	}
}

function SCslideAdvance(relocationUrl)
{
	window.location = relocationUrl;
}

Event.observe(window, 'load', function() { initSlideshowControls(); });
