// handles the differences between three differnt DOMs

// need to figure out a way to handle an object in each DOM
// so it can be manipulated by other functions
function getObject(obj) {
	var theObj
	if (document.layers) {
		if (typeof obj == "string") {
			return document.layers[obj]
		} else {
			return obj
		}
	}
	if (document.all) {
		if (typeof obj == "string") {
			return document.all(obj).style
		} else {
			return obj.style
		}
	}
	if (document.getElementById) {
		if (typeof obj == "string") {
			return document.getElementById(obj).style
		} else {
			return obj.style
		}
	}
	return null
}

// this part handles the moving of objects. It is assumed that the coordinates 
// of the top-left corner of the objects are known as they have to be passed 
// here (as well as the id)
function shiftTo(obj, x, y) {
	var theObj = getObject(obj)
	if (theObj.moveTo) {
		theObj.moveTo(x,y)
	} else if (typeof theObj.left != "undefined") {
		theObj.left = x
		theObj.top = y
	}
}

// this function is similar to moveTo, but it uses the distance moved rather than
// coordinates to determine the destination position (negative figures mean left or up 
// respectively)
function shiftBy(obj, deltaX, deltaY) {
	var theObj = getObject(obj)
	if (theObj.moveBy) {
		theObj.moveBy(deltaX,deltaY)
	} else if (typeof theObj.left != "undefined") {
		theObj.left = parseInt(theObj.left) + deltaX
		theObj.top = parseInt(theObj.top) + deltaY
	}
}

// this is setting the stacking order which is actually hadled in the same
// way for all three DOMs
function setZIndex(obj, zOrder) {
	var theObj = getObject(obj)
	theObj.zIndex = zOrder
}

// allows background colour of an object to be changed.
function setBGColor(obj, color) {
	var theObj = getObject(obj)
	if (theObj.bgColor) {
		theObj.bgColor = color
	} else if (typeof theObj.backgroundColor!="undefined") {
		theObj.backgroundColor = color
	}
}

// allows border width of an object to be changed.
function setBorderWidth(obj, width) {
	var theObj = getObject(obj)
	//don't think borderWidth exists...
	if (theObj.borderWidth) {
		theObj.borderWidth = width
	} else if (typeof theObj.borderWidth!="undefined") {
		theObj.borderWidth = width
	}
}


// make an object visible
function show(obj) {
	var theObj = getObject(obj)
	theObj.visibility = "visible"
}

// make object invisible
function hide(obj) {
	var theObj = getObject(obj)
	theObj.visibility = "hidden"
}

// working out the x coordinate of a given object
function getObjectLeft(obj) {
	var theObj = getObject(obj)
	return parseInt(theObj.left)
}

// working out the y coordinate of a given object
function getObjectTop(obj) {
	var theObj = getObject(obj)
	return parseInt(theObj.top)
}

// an extra thing to handle the status bar manipulation
function setStatus(msg) {
	window.status = msg

	if (window.setCursor) {
		if (msg.length > 0) {
			window.setCursor("pointer")
		} else {
			window.setCursor("default")
		}
	}
	return true
}