<!--

// begin library.js

//------------------------------------------------------------
//------------------------------------------------------------
//------------------------------------------------------------
//  	--------------------------------
// 	library.js
//  	--------------------------------
//	(c) 1999,2000 Timothy Bartlett
//	tim@tikeba.com
//  	--------------------------------
//------------------------------------------------------------
//------------------------------------------------------------


browserVer = parseInt(navigator.appVersion);

//------------------------------------------------------------
// Image swapping functions
//------------------------------------------------------------

imgSwap = new Array();
	
function makeSwap(imgName, offSrc, onSrc)
{
	if (browserVer >= 4) {
		imgSwap[imgName + "OFF"] = new Image();
		imgSwap[imgName + "OFF"].src = offSrc;
		imgSwap[imgName + "ON"] = new Image();
		imgSwap[imgName + "ON"].src = onSrc;
	}
}
	
function swapImg(img, onOff)
{
	if (browserVer >= 4) {
		theObj = getContentObject(img);
		if ( onOff == "on" || onOff == "ON" || onOff == "On" ) {
			theObj.src = imgSwap[img.name + "ON"].src;
		} else {
			theObj.src = imgSwap[img.name + "OFF"].src;
		}
	}
}

// rollover functions (for more complex graphics changes)

function addRollover(imgName, rolloverName, src)
{
	if (browserVer >= 4) {
		imgSwap[imgName + rolloverName] = new Image();
		imgSwap[imgName + rolloverName].src = src;
	}
}

function rollover(imgName, rolloverName) {
	if (browserVer >= 4) {
			imgSwap[imgName].src = imgSwap[imgName + rolloverName].src;
	}
}



/* ***********************************************************
Following code from Example 4-5 (DHTMLapi.js)
"Dynamic HTML:The Definitive Reference"
by Danny Goodman
Published by O'Reilly & Associates  ISBN 1-56592-494-0
http://www.oreilly.com
Copyright 1998 Danny Goodman.  All Rights Reserved.
************************************************************ */


// Global variables
var isNav4, isIE4
var coll = ""
var styleObj = ""

if (parseInt(navigator.appVersion) >= 4) {
	if (navigator.appName == "Netscape") {
		isNav4 = true
	} else {
		isIE = true
		coll = "all."
		styleObj = ".style"
	}
}

// Convert object name string or object reference
// into a valid object reference
function getObject(obj) {

	var theObj
	if (typeof obj == "string") {
		theObj = eval("document." + coll + obj + styleObj)
	} else {
		theObj = obj
	}
	return theObj

}

// Convert object name into a valid object reference
// for the purpose of MSIE width and height properties
function getContentObject(obj) {

	var theObj
	if (typeof obj == "string") {
		theObj = eval("document." + coll + obj)
	} else {
		theObj = obj
	}
	return theObj

}

// Positioning an object at a specific pixel coordinate
function shiftTo(obj, x, y) {
	var theObj = getObject(obj)
	if (isNav4) {
		theObj.moveTo(x,y)
	} else {
		theObj.pixelLeft = x
		theObj.pixelTop = y
	}
}

// Moving an object by x and/or y pixels
function shiftBy(obj, deltaX, deltaY) {
	var theObj = getObject(obj)
	if (isNav4) {
		theObj.moveBy(deltaX, deltaY)
	} else {
		theObj.pixelLeft += deltaX
		theObj.pixelTop += deltaY
	}
}

// Setting the z-order of an object
function setZIndex(obj, zOrder) {
	var theObj = getObject(obj)
	theObj.zIndex = zOrder
}

// Setting the background color of an object
function setBGColor(obj, color) {
	var theObj = getObject(obj)
	if (isNav4) {
		theObj.bgColor = color
	} else {
		theObj.backgroundColor = color
	}
}

// Setting the visibility of an object to visible
function show(obj) {
	var theObj = getObject(obj)
	theObj.visibility = "visible"
}

// Setting the visibility of an object to hidden
function hide(obj) {
	var theObj = getObject(obj)
	theObj.visibility = "hidden"
}

// Retrieving the x coordinate of a positionable object
function getObjectLeft(obj)  {
	var theObj = getObject(obj)
	if (isNav4) {
		return theObj.left
	} else {
		return theObj.pixelLeft
	}
}

// Retrieving the y coordinate of a positionable object
function getObjectTop(obj)  {
	var theObj = getObject(obj)
	if (isNav4) {
		return theObj.top
	} else {
		return theObj.pixelTop
	}
}

// Utility function returns rendered height of object content in pixels
function getObjectHeight(obj) {
	var theObj = getContentObject(obj);
	if (isNav4) {
		return theObj.clip.height
	} else {
		return theObj.clientHeight
	}
}

// Utility function returns rendered width of object content in pixels
function getObjectWidth(obj) {
	var theObj = getContentObject(obj);
	if (isNav4) {
		return theObj.clip.width
	} else {
		return theObj.clientWidth
	}
}

// Utility function returns the available content width space in browser window
function getInsideWindowWidth() {
	if (isNav4) {
		return window.innerWidth
	} else {
		return document.body.clientWidth
	}
}

// Utility function returns the available content height space in browser window
function getInsideWindowHeight() {
	if (isNav4) {
		return window.innerHeight
	} else {
		return document.body.clientHeight
	}
}

// Utility function returns the available width of the document visible to the user
// if the document has been scrolled.
function getWindowVisibleLeft() {
	if (isNav4) {
		return window.pageXOffset
	} else {
		return document.body.scrollLeft
	}
}

// Utility function returns the available height of the document visible to the user
// if the document has been scrolled.
function getWindowVisibleTop() {
	if (isNav4) {
		return window.pageYOffset
	} else {
		return document.body.scrollTop
	}
}

// Utility function returns the available width of the document visible to the user
// if the document has been scrolled.
function getWindowVisibleWidth() {
	if (isNav4) {
		return window.innerWidth + window.pageXOffset
	} else {
		return document.body.clientWidth + getWindowVisibleLeft()
	}
}

// Utility function returns the available height of the document visible to the user
// if the document has been scrolled.
function getWindowVisibleHeight() {
	if (isNav4) {
		return window.innerHeight + window.pageYOffset
	} else {
		return document.body.clientHeight + getWindowVisibleTop()
	}
}

// Position an element in the current window or frame and make it visible.
function positionElement(objID, xPos, yPos, xOffset, yOffset) {

	var x;
	var y;

	switch (xPos) {
		case "left":
			x  = getWindowVisibleLeft();
			break;
		case "middle":
			x = Math.round(((getWindowVisibleWidth()-getWindowVisibleLeft())/2) - (getObjectWidth(objID)/2))
			break;
		case "right":
			x = getWindowVisibleWidth() - getObjectWidth(objID)
			break;
	}

	switch (yPos) {
		case "top":
			y = getWindowVisibleTop();
			break;
		case "middle":
			y = Math.round(((getWindowVisibleHeight()-getWindowVisibleTop())/2) - (getObjectHeight(objID)/2))
			break;
		case "bottom":
			y = getWindowVisibleHeight() - getObjectHeight(objID)
			break;
	}

	shiftTo(objID, x + xOffset, y + yOffset)
	show(objID)

}


// Center an element in the current window or frame and make it visible.

function centerElement(objID) {
	positionElement(objID, "middle", "middle", 0, 0)
}

// Position an element in relation to another element.  The element's left & top
// attributes will be set relative to the other element's left & top attributes.

function positionElementWith(objID, objDestID, xOffset, yOffset) {
	shiftTo(objID, getObjectLeft(objDestID) + xOffset, getObjectTop(objDestID) + yOffset)
	show(objID)
}

// Keep an element positioned in the current visible window area.

function keepElementPositioned(objID, xPos, yPos, xOffset, yOffset) {
	functionText = "positionElement('" + objID + "', '" + xPos + "', '" + yPos + "', " + xOffset + ", " + yOffset + ")"
	return setInterval(functionText,100);
}

// Keep an element positioned in relation to another element.

function keepElementWith(objID, objDestID, xOffset, yOffset) {
	functionText = "positionElementWith('" + objID + "', '" + objDestID + "', " + xOffset + ", " + yOffset + ")"
	return setInterval(functionText,100);
}

/* ***********************************************************
	End Example 4-5 (DHTMLapi.js)
*************************************************************/


/***************************************************************************

		Bounce Functions

***************************************************************************/

var bounceDeltaX = new Array();
var bounceDeltaY = new Array();
var bounceTimer = new Array();
var bounceInterval = 40;

function goBounce(objID) {

	bounceDeltaX[objID] = Math.round(Math.random() * 11) - 5;
	bounceDeltaY[objID] = Math.round(Math.random() * 11) - 5;
	bounceTimer[objID] = setInterval("bounceMove('" + objID + "')", bounceInterval);
}

function setBounceInterval(interval) {
	bounceInterval = interval;
}

function stopBounce(objID) {

	clearInterval(bounceTimer[objID]);
	
}

function bounceMove(objID) {

	var x = getObjectLeft(objID);
	var y = getObjectTop(objID);

	x += bounceDeltaX[objID];
	y += bounceDeltaY[objID];
	
	if ( (x<=getWindowVisibleLeft()) || ( (x + getObjectWidth(objID)) >= getWindowVisibleWidth()) ) {
		
		bounceDeltaX[objID] = -bounceDeltaX[objID];
		if (x<=getWindowVisibleLeft())
			x=getWindowVisibleLeft();
		else
			x = getWindowVisibleWidth() - getObjectWidth(objID);
		
	}
	
	if ( (y<=getWindowVisibleTop()) || ( (y + getObjectHeight(objID)) >= getWindowVisibleHeight()) ) {
		
		bounceDeltaY[objID] = -bounceDeltaY[objID];
		if (y<=getWindowVisibleTop())
			y=getWindowVisibleTop();
		else
			y = getWindowVisibleHeight() - getObjectHeight(objID);
		
	}
	
	shiftTo(objID, x, y);
	
}

//-->
