// JavaScripts for Christine Pritchard's web pages
//
//-----------------------------------------------------
// History
//
// V0.1  Created 8/10/2004 (Peter Froome)
// The first version of these JavaScripts
//
//------------------------------------------------------

// Photo scrolling functions

function scrollPrevPic()
{	var curpic = picNumber
	if ( picNumber > 0 )
	{	picNumber = picNumber - 1
	}
	else
	{	picNumber = picList.length - 1
	}
	var thisp = picList[curpic]
	var nextp = picList[picNumber]
	var nextppath = picPaths[picNumber]
	nextPic("photoimg", thisp, nextp, nextppath)
}

function scrollNextPic()
{	var curpic = picNumber
	if ( picNumber < (picList.length - 1) )
	{	picNumber = picNumber + 1
	}
	else
	{	picNumber = 0
	}
	var thisp = picList[curpic]
	var nextp = picList[picNumber]
	var nextppath = picPaths[picNumber]
	nextPic("photoimg", thisp, nextp, nextppath)
}

function nextPic(firstp, thisp, nextp, nextppath)
{	var melem
	var melemcap
	var melem1cap
	var thispcap = thisp + "cap"
	var nextpcap = nextp + "cap"
	if ( document.getElementById )
	{	melemcap = document.getElementById(thispcap)
		melem1cap = document.getElementById(nextpcap)
	}
	else if ( document.all )
	{	var subs = "document.all." + thispcap
		melemcap  = eval(subs)
		subs = "document.all." + nextpcap
		melem1cap  = eval(subs)
	}
	melemcap.style.visibility="hidden"
	melem1cap.style.visibility="visible"
	flipImage(firstp, nextppath)
}

// Image swapping function

function flipImage(name, url)
{
    if ( document.images )
    {   document.images[name].src = url
    }
}

// Initialisation

function loadActions(mainmenu, sidemenu)
{	var melem
	var newclass = "sidemenusel"
	if ( sidemenu != "" )
	{	if (document.getElementById)
		{	melem = document.getElementById(sidemenu)
			melem.setAttribute("class",newclass)		// Mozilla
			melem.setAttribute("className",newclass)	// IE5
		}
		else if (document.all)
		{	var subs = "document.all." + sidemenu
			melem = eval(subs)
			melem.className = newclass
		}
	}
	newclass = "topmenusel"
	if ( mainmenu != "" )
	{	if (document.getElementById)
		{	melem = document.getElementById(mainmenu)
			melem.setAttribute("class",newclass)		// Mozilla
			melem.setAttribute("className",newclass)	// IE5
		}
		else if (document.all)
		{	var subs = "document.all." + mainmenu
			melem = eval(subs)
			melem.className = newclass
		}
	}
}

