// Initialise some variables
res=""
image_display = 0 //indicates if the main image has been displayed - needed for a FF quirk
timeout = 10 // This is the default slide show time-out.  
slideshow = 0  // Is the slideshow running?
pause = 0 // Has the slideshow been run and is not paused
left_margin = 250 // the width of the margin with the navigation controls and the category tree
top_margin = 40 // CAUTION:  if you modify this, you may need to do further editing of the style sheet.  The height of the heading for full-sized image pages.

floatimage="yes" // these settings in the preset file control whether images etc move down to stay on the screen when the page is scrolled down to see a long category tree
floatheading="yes"
floatnavigationcontrols="yes"
rememberscroll="no"

scroll_width_fudge = 0
if (self.innerHeight) scroll_width_fudge = 20 // in some situations this makes allowance for the fact that non IE browsers measure the inner window width and height including the scroll bars
// For reference:  FF scrollbars=21px; 
// IE horiz scrollbars=21px; vert = 17px in full screen mode

scrollamount = 0 // how far the screen has scrolled
scrollpercent = 0 // how far the screen has scrolled as a percent of the available scroll distance
jumps = 4 // The number of jumps when moving images because the screen has scrolled
millisecs = 4	 //the time between jumps

// Read the screen resolution
screenwidth = screen.width;
screenheight = screen.height;
totalheight = screen.height // an initial estimate of the available height


// Read the window parameters.  
function set_dimensions() 
{
	if (self.innerHeight) // all except Explorer
	{
		windowwidth = self.innerWidth;
		windowheight = self.innerHeight;
		browser = "ns"
	}
	else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
	{
		windowwidth = document.documentElement.clientWidth;
		windowheight = document.documentElement.clientHeight;
		browser = "ie"
	}
	else if (document.body) // other Explorers
	{
		windowwidth = document.body.clientWidth;
		windowheight = document.body.clientHeight;
		browser = "ie"
	}

	totalheight = document.documentElement.scrollHeight ? document.documentElement.scrollHeight : document.height // The total height of the html document
	if (totalheight < windowheight) totalheight=windowheight;  // we want to avoid a situation where the document height is defined as less than the window height
	totalwidth = document.documentElement.scrollWidth ? document.documentElement.scrollWidth : document.width // The total width of the html document
	if (totalwidth < windowwidth) totalwidth=windowwidth;  // we want to avoid a situation where the document width is defined as less than the window width

	// Short version if needed
	// windowwidth = self.innerWidth? self.innerWidth : document.documentElement.clientWidth? document.documentElement.clientWidth : document.body.clientWidth;
	// windowheight = self.innerHeight? self.innerHeight : document.documentElement.clientHeight? document.documentElement.clientHeight : document.body.clientHeight;

	setTimeout("set_dimensions()", 10);
}
//set_dimensions()


// From the page's URL, read inherited resolution, whether the slideshow is running,
// and if it is read timeout and pause, and validate the timeout as a numerical value
url = String(window.location)
i = url.indexOf("?")
thispage = url.substring(0, i)
if (i > 0)
{
	// Read resolution parameter, if it can't be recognised, it will get set optimally later
	res = url.substr(i+1,1) 
	if ((res != "s") && (res != "m") && (res != "l") && (res != "x"))
	{
		res = ""
	}

	// Test if the slideshow is not running
	l = url.indexOf("~") 
	if ((l > 0))
	{
		slideshow = 0
		pause = 0
		// If it is not running, the current timeout is between "res" and "~"
		timeout = parseFloat(url.substring(i+2,l)) 
		if (isNaN(timeout) == 1)
		{
			timeout = 7
		}
	}
	// Test if the slideshow is paused, and therefore running
	j = url.indexOf("+") 
	if ((j > 0))
	{
		slideshow = 1
		pause = 1
		// If it is paused, the timeout is between "res" and "+"
		timeout = parseFloat(url.substring(i+2,j)) 
		if (isNaN(timeout) == 1)
		{
			timeout = 6
		}
	}
	m = url.length
	// Test if the slideshow is running and not paused
	if ((j == -1) && (l == -1) && (m > i+2))
	{
		slideshow = 1
		timeout = parseFloat(url.substring(i+2))
		if (isNaN(timeout) == 1)
		{
			timeout = 6
		}
	}
}


// Set the optimal image resolution if it was absent from the URL
if (res == "")
{
	if (screenheight < 763)
	{
		res = "s"
	}
	if ((screenheight >= 763) && (screenheight < 1021))
	{
		res = "m"
	}
	if ((screenheight >= 1021) && (screenheight < 1195))
	{
		res = "l"
	}
	if (screenheight >= 1195)
	{
		res = "x"
	}
}


//  Let's be really really careful and set a default resolution.  This should NOT be needed.
if (res == "")
{
	res = "m"
}



