// Base JS Library for inclusion in all scripted web pages
var isNav, isIE, intervalID, intervalID2
var coll = ""
var styleObj = ""
if (parseInt(navigator.appVersion) >= 4)
{
	if (navigator.appName == "Netscape")
	{
		isNav = true
	}
	else
	{
		isIE = true
		coll = "all."
		styleObj = ".style"
	}
}

// Convert object name string or object reference
// into a valid reference
function getObject(obj)
{
	var theObj
	if (typeof obj == "string")
	{
		theObj = eval("document." + coll + obj + styleObj)
	}
	else
	{
		theObj = obj
	}
	return theObj
}

// Utility function returns height of object in pixels
function getObjHeight(obj)
{
	var theObj = getObject(obj)
	if (isNav)
	{
		return theObj.clip.height
	}
	else
	{
		return theObj.clientHeight
	}
}

// Utility function returns width of object in pixels
function getObjWidth(obj)
{
	var theObj = getObject(obj)
	if (isNav)
	{
		return theObj.clip.width
	}
	else
	{
		return theObj.clientWidth
	}
}

// Utility function returns the x coordinate of a positionable object
function getObjLeft(obj)
{
	var theObj = getObject(obj)
	if (isNav)
	{
		return theObj.left
	}
	else
	{
		return theObj.pixelLeft
	}
}

// Utility function returns the y coordinate of a positionable object
function getObjTop(obj)
{
	var theObj = getObject(obj)
	if (isNav)
	{
		return theObj.top
	}
	else
	{
		return theObj.pixelTop
	}
}

// Utility function returns the available content width space in browser window
function getInsideWindowWidth()
{
	if (isNav)
	{
		return window.innerWidth
	}
	else
	{
		return document.body.clientWidth
	}
}

// Utility function returns the available content height space in browser window
function getInsideWindowHeight()
{
	if (isNav)
	{
		return window.innerHeight
	}
	else
	{
		return document.body.clientHeight
	}
}

// Utility function to set the visibility of an object to visible
function show(obj)
{
	var theObj = getObject(obj)
	theObj.visibility = "visible"
}

// Utility function to set the visibility of an object to hidden
function hide(obj)
{
	var theObj = getObject(obj)
	theObj.visibility = "hidden"
}

// Utility function to positionan element at a specific x,y location
function shiftTo(obj, x, y)
{
	var theObj = getObject(obj)
	if (isNav)
	{
		theObj.moveTo(x,y)
	}
	else
	{
		theObj.pixelLeft = x
		theObj.pixelTop = y
	}
}

// Utility function to move an object by x and/or y pixels
function shiftBy(obj, deltaX, deltaY)
{
	var theObj = getObject(obj)
	if (isNav)
	{
		theObj.moveBy(deltaX,deltaY)
	}
	else
	{
		theObj.pixelLeft += deltaX
		theObj.pixelTop += deltaY
	}
}

// Setting the background colour of an object
function setBGColor(obj, color)
{
	var theObj = getObject(obj)
	if (isNav)
	{
		theObj.bgcolor = color
	}
	else
	{
		theObj.backgroundcolor = color
	}
}

// Function to glide the nav bar things in from the right
function glideBars()
{
	var obj1 = eval("document." + coll + "bar1" + styleObj)
	var obj2 = eval("document." + coll + "bar2" + styleObj)
	var obj3 = eval("document." + coll + "bar3" + styleObj)

    shiftTo(obj1, getInsideWindowWidth(), 200)
    shiftTo(obj2, getInsideWindowWidth(), 270)
    shiftTo(obj3, getInsideWindowWidth(), 340)

    show(obj1)
    show(obj2)
    show(obj3)

    glideTo()
}

function glideTo()
{
	var obj1 = eval("document." + coll + "bar1" + styleObj)
	var obj2 = eval("document." + coll + "bar2" + styleObj)
	var obj3 = eval("document." + coll + "bar3" + styleObj)

    shiftBy(obj1, -5, 0)
    shiftBy(obj2, -5, 0)
    shiftBy(obj3, -5, 0)

    var a = getObjLeft(obj1)
    if (a<=150)
    {
        clearTimeout(intervalID)
    } else {
        intervalID = setTimeout("glideTo()", 0)
    }
}

function glideOff()
{
	var obj1 = eval("document." + coll + "bar1" + styleObj)
	var obj2 = eval("document." + coll + "bar2" + styleObj)
	var obj3 = eval("document." + coll + "bar3" + styleObj)

	shiftBy(obj1, -5, 0)
	shiftBy(obj2, -5, 0)
	shiftBy(obj3, -5, 0)

	var a = getObjRight(obj1)
	if (a<=0)
	{
		hide(obj1)
		hide(obj2)
		hide(obj3)
		clearTimeout(intervalID2)
	} else {
		intervalID2 = setTimeout("glideOff()", 0)
	}
}
	
function setStatus(msg)
{
	window.status = msg
	return true
}

function scrollUp()
{
	if (currPage != 1)
	{
		var nextPage = ("pg" + (currPage - 1))
		var currStr = ("pg" + currPage)

		hide(currStr)
		show(nextPage)

		currPage -= 1
	}
}

function scrollDown()
{
	if (currPage != noPages)
	{
		var nextPage = ("pg" + (currPage + 1))
		var currStr = ("pg" + (currPage))

		hide(currStr)
		show(nextPage)

		currPage += 1
	}
}

function quickPage(newPg)
{
	if ((newPg <= noPages) && (newPg >= 1))
	{
		var nextPage = ("pg" + newPg)
		var currStr = ("pg" + (currPage))

		hide(currStr)
		show(nextPage)

		currPage = newPg
	}
}

// End of library code (for now!)

