// JavaScript Document
var currentslide=1;
var intplaypause=0;
var captions=new Array();
var interval = 2000;
var frame;
var currenttab = 'before';

function timedCount()
{
	if(currentslide<5)
	{
		changeslide(currentslide+1);
	}
	else
	{
		changeslide(1);
	}
	t=setTimeout("timedCount()",interval);
}

function changetab(tab)
{
    document.getElementById('selectedtab').id=currenttab;
    currenttab = tab;
    document.getElementById(currenttab).id='selectedtab';
    if(frame==null)
    {
        frame = document.getElementById("beforeframe");
    }
    frame.setAttribute("style","display:none");
    switch(tab)
    {
        case 'before':
            frame = document.getElementById('beforeframe');
            break;
        case 'during':
            frame = document.getElementById('duringframe');
            break;
        case 'after':
            frame = document.getElementById('afterframe');
            break;
    }
    frame.setAttribute("style","display:block");
}

function changeimage(currentslide,x)
{
	document.getElementById('slideshowimage'+currentslide.toString()).id='slideshowimage'+x.toString();
}

function changeslide(x)
{
	//change image
	changeimage(currentslide,x);
	
	//change selection
	deselectitem(currentslide);
	selectitem(x);
}


function selectitem(x)
{
	currentslide=x;
	document.getElementById('slide'+x.toString()).id='selected';
	document.getElementById('hiwbni'+x.toString()).id='hiwbni'+x.toString()+'selected';
}

function deselectitem(x)
{
    document.getElementById('selected').id ='slide'+x.toString();
    document.getElementById('hiwbni'+x.toString()+'selected').id='hiwbni'+x.toString();
}

function playpause()
{
	//if paused
	if(intplaypause==0)
	{
		play();
	}
	else
	{
		pause();
	}
}

function play()
{
	//change text of play pause
	document.getElementById('playpause').innerHTML="<strong>ll</strong> Pause";
	//change variable
	intplaypause = 1;
	//start ticker
	timedCount();
}

function pause()
{
	//change text of play pause
	document.getElementById('playpause').innerHTML="► Play";
	//change variable
	intplaypause = 0;
	//stop ticker
	clearTimeout(t);
}

function startslideshowonload()
{
	//wait interval and start the slideshow
	setTimeout("playpause()",interval);
}
