var pe;
var SLIDE_DELAY = 2; //Seconds

if(document.getElementById && document.getElementsByTagName)
{
	Event.observe(window, 'load', init, false);
}

function init()
{
  setupSlideshowDisplay()
}

function setupSlideshowDisplay()
{
  Event.observe($('modalDialogOpener'), 'click', displaySlideshow, false);
  Event.observe($('pageDisabler'), 'click', hideSlideshow, false);
  Event.observe($('modalDialogCloser'), 'click', hideSlideshow, false);
}

function displaySlideshow(e)
{	
  showModal();
  pe = new PeriodicalExecuter(runSlideshow, SLIDE_DELAY);
			
  Event.stop(e);
  return false;
}

function hideSlideshow(e)
{
	pe.stop();
	hideModal();
	
	Event.stop(e);
	return false;
}

function runSlideshow()
{ 
  this.curImg = this.curImg >= 0 && this.curImg < alblum.length - 1 ? this.curImg + 1 : 0;
  $('slideshow').src = alblum[this.curImg];
}
