//slideshow toolbar button script

function ssbutton(action)
{
//First identify href location

var locn = window.location.href;
var prot = window.location.protocol;
var host = window.location.host;
var path = window.location.pathname;
var actiondesc = "Action : " + action;

//Break down href into variables
if (locn.search(/slideshow.asp/)!= '-1')
{   
    var strVariables = locn.slice(locn.indexOf('?'))
    var strDir = strVariables.slice(strVariables.indexOf('dir'),strVariables.indexOf('&'))
    strDir = strDir.slice(strDir.indexOf('=')+1)
    var strTimer = strVariables.slice(strVariables.indexOf('timer'),strVariables.indexOf('&',strVariables.indexOf('timer')))
    strTimer = strTimer.slice(strTimer.indexOf('=')+1)
    var intTimer = Number(strTimer)
    var strSlide = strVariables.slice(strVariables.indexOf('slide'),strVariables.indexOf('&',strVariables.indexOf('slide')))
    strSlide = strSlide.slice(strSlide.indexOf('=')+1)
    var intSlide = Number(strSlide)
    var strOrig = strVariables.slice(strVariables.indexOf('orig'))
    strOrig = strOrig.slice(strOrig.indexOf('=')+1)
    }
else
{
    var intTimer = document.forms.bar.txtTimer.value
    var intSlide = 1
    }
switch(action)
{
	//select button pressed
	case 'b' :
		if (intSlide != 1)
		{
		    intSlide = intSlide - 1
		    var strRef = path + '?dir=' + strDir + '&slide=' + intSlide + '&timer=' + intTimer + '&orig=' + strOrig;
		}
		else
		{
		if (strOrig.toLowerCase() != 'archive.asp')
		{
		    var strRef = '/'+strOrig;
		}
		else
		{
		    var strRef = '/' + strOrig + '?dir=' + strDir;
		}}
	break;
	case 'f' :
		intSlide = intSlide + 1;
		var strRef = path + '?dir=' + strDir + '&slide=' + intSlide + '&timer=' + intTimer + '&orig=' + strOrig;
	break;
	case 'g' :
		strOrig=path;
		strOrig=strOrig.slice(strOrig.indexOf('/')+1)
		var strVariables = locn.slice(locn.indexOf('?'))
		var strDir = strVariables.slice(strVariables.indexOf('dir'))
	    strDir = strDir.slice(strDir.indexOf('=')+1)
		var strRef = '/slideshow.asp?dir=' + strDir + '&slide=' + intSlide + '&timer=' + intTimer + '&orig=' + strOrig;
	break;
	case 's' :
		if (strOrig.toLowerCase() != 'archive.asp')
		{
		    var strRef = '/' + strOrig;
		}
		else
		{
		    var strRef = '/' + strOrig + '?dir=' + strDir;
		}
	break;
	case 'r':
		intTimer = document.forms.bar.txtTimer.value;
		var strRef = path + '?dir=' + strDir + '&slide=' + intSlide + '&timer=' + intTimer + '&orig=' + strOrig;
	break;
	default :
		//alert('Button not recognised.');
	break;
}

//Compile new href
strNewRef = prot + '//' + host + strRef

//Divert browser to new location
//window.location=strNewRef
window.location=strRef
}

function ssback()
{
ssbutton('b')
}

function ssforward()
{
ssbutton('f')
}

function ssstart()
{
ssbutton('g')
}

function ssstop()
{
ssbutton('s')
}

function ssreset()
{
ssbutton('r')
}
