//Global variables

var isNav, isIE
var intervalIDArray = new Array(6)
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 object reference
function getObject(obj)
{
	var theObj
	if(typeof obj == "string")
	{
		theObj = eval("document." + coll + obj + styleObj)
	} else
	{
		theObj = obj
	}
	return theObj
}

//Positioning an object at a specific pixel cordinate
function shiftTo(obj, x, y)
{
	var theObj = getObject(obj)
	if(isNav)
	{
		theObj.moveTo(x,y)
	} else
	{
		theObj.pixelLeft = x
		theObj.pixelTop = y
	}
}

//Moving an object by x and/or by 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 z-order of an object
function setZIndex(obj, zOrder)
{
	var theObj = getObject(obj)
	theObj.zIndex = zOrder
}

//Setting the background colour of an object
function setBGColour(obj, colour)
{
	var theObj = getObject(obj)
	if(isNav)
	{
		theObj.bgColor = colour
	} else
	{
		theObj.backgroundColor = colour
	}
}

//Setting the visibility of an object to visible
function show(obj)
{
	var theObj = getObject(obj)
	theObj.visibility = "visible"
}

//Setting the visiblity of an object to hidden
function hide(obj)
{
	var theObj = getObject(obj)
	theObj.visibility = "hidden"
}

//Retrieving the x coordinate of a positionable object
function getObjLeft(obj)
{
	var theObj = getObject(obj)
	if(isNav)
	{
		return theObj.left
	} else
	{
		return theObj.pixelLeft
	}
}

//Retrieving the y coordinate of a positionable object
function getObjTop(obj)
{
	var theObj = getObject(obj)
	if(isNav)
	{
		return theObj.top
	} else
	{
		return theObj.pixelTop
	}
}

//Handling navigator window resizing
function handleResize()
{
	if((isNav) && (window.captureEvents(Event.RESIZE)))
	{
		alert("captured")
		window.onresize = location.reload()
		return false
	}
}
//This bit of code needs to go in the header section of the
//document.
//if(isNav)
	//{
		//window.captureEvents(Event.RESIZE)
		//window.onresize = handleResize()
	//}


//Utility function returns rendered height of object content in pixels
function getObjHeight(obj)
{
	if(isNav)
	{
		return obj.clip.height
	} else
	{
		return obj.clientHeight
	}
}

//Utility function returns rendered height of object content in pixels
function getObjWidth(obj)
{
	if(isNav)
	{
		return obj.clip.width
	} else
	{
		return obj.clientWidth
	}
}

//Utitlity function returns the available content width space in browser window
function getInsideWindowWidth()
{
	if(isNav)
	{
		return window.innerWidth
	} else
	{
		return document.body.clientWidth
	}
}

//Utitlity function returns the available content height space in browser window
function getInsideWindowHeight()
{
	if(isNav)
	{
		return window.innerHeight
	} else
	{
		return document.body.clientHeight
	}
}


//Error handling code
window.onerror = myOnError
msgArray = new Array()
urlArray = new Array()
lnoArray = new Array()

msgArray[0] = "Starting Message"
urlArray[0] = "Starting URL"
lnoArray[0] = "Starting Line Number"

function myOnError(msg, url, lno) 
{   
	msgArray[msgArray.length] = msg   
	urlArray[urlArray.length] = url   
	lnoArray[lnoArray.length] = lno   
	return true
}

function showErrors()
{
	var errorMessage, i
	
	errorMessage = ""
	
	for(i = 0; i< msgArray.length; i++)
	{
		errorMessage =  errorMessage + "Error " + (i+1) + " : \n"
		errorMessage =  errorMessage + "Message = " + msgArray[i] + "\n"
		errorMessage =  errorMessage + "URL = " + urlArray[i] + "\n"
		errorMessage =  errorMessage + "Line = " + lnoArray[i] + "\n\n"
		errorMessage =  errorMessage + "************************\n"
	}
	alert(errorMessage)
}

//************************************ END OF LIBRARY CODE
