/*
v 1.53, 
Made by Mattias Henell, Large Medium AB, mhenell@largemedium.com
*/

//Get correct layer reference depending on browser (-åsa)
if (isNAV4) {
coll = "layers['"
styleObj = "']"
}
if (isNAV6) {
coll = "getElementById('"
styleObj = "').style"
}
if (isOPERA) {
coll = "all."
styleObj = ".style"
}
if (isIE) {
coll = "all."
styleObj = ".style"
}

//Convert Object name String or object reference into a valid object reference
function getObject(obj, nestedLayer){
	var theObj
	if (typeof obj == "string") {
		 if(nestedLayer && isNAV4) {
		 		theObj = eval("document.layers."+nestedLayer+".document."+obj)
			}
		 else {
			theObj = eval("document." + coll +obj +styleObj);
		}
	   }
	else {
		theObj = obj
		}
	return theObj
}

//positioning an object at a specific pixel coordinate
function shiftTo(obj, x, y, nestedLayer) {
	nestedLayer = nestedLayer
	var theObj = getObject(obj, nestedLayer)
	theObj.left = x;
	theObj.top = y;
}

//Moving an object by x and / or y pixels
function shiftBy(obj, deltaX, deltaY, nestedLayer) {
	nestedLayer = nestedLayer
	var theObj = getObject(obj, nestedLayer)
	deltaX = parseInt(deltaX) + parseInt(getObjectLeft(obj))
	deltaY = parseInt(deltaY) + parseInt(getObjectTop(obj))
	theObj.left = deltaX
	theObj.top = deltaY
}

//Setting the z-order of an object
function setZIndex(obj, zOrder, nestedLayer){
	nestedLayer = nestedLayer
	var theObj = getObject(obj, nestedLayer)
	theObj.zIndex = zOrder
}

//setting the visibility of an object
function setVisibility(obj, vBility, nestedLayer) {
	nestedLayer = nestedLayer
	var theObj = getObject(obj, nestedLayer)
	theObj.visibility = vBility
}

//Retrieving the x-cordinate of a positionable object
function getObjectLeft(obj, nestedLayer) {
	nestedLayer = nestedLayer
	var theObj = getObject(obj, nestedLayer)
	return parseInt(theObj.left)
}

//Retrieving the y-cordinate of a positioable object
function getObjectTop(obj, nestedLayer){
	nestedLayer= nestedLayer
	var theObj = getObject(obj, nestedLayer)
	return parseInt(theObj.top)
}

//Changing content of a layer
function reWriteLayer(obj, contentString, nestedLayer){
	if (isNAV6) document.getElementById(obj).innerHTML = contentString
	else if (isIE) document.all[obj].innerHTML=contentString
	else if(isNAV4) {
			theObj = getObject(obj,nestedLayer)
			theObj.document.open();
			theObj.document.write(contentString);
			theObj.document.close();
	}
	else if (isOPERA) return false
}

//clipping a layer
function clipLayer(obj, lengthTop, lenghtRight, lengthBottom, lengthLeft, nestedLayer){
	nestedLayer = nestedLayer
	var theObj = getObject(obj)
	
	if(!isNAV4) {
		var clipString = "rect(" +lengthTop +"," +lenghtRight +"," +lengthBottom +","+ lengthLeft +")"
		theObj.clip = clipString;
		}
	else {
		theObj.clip.top = lengthTop
		theObj.clip.right = lenghtRight
		theObj.clip.bottom = lengthBottom
		theObj.clip.left = lengthLeft
	}
}

//Changing a picture within a layer
function setImage(obj,imgName,imgSrc, nestedLayer) {
	nestedLayer = nestedLayer
	obj = obj
	if (isNAV4 && obj=="") {
		document.imgName.src = imgSrc
	}
	else if (isNAV4 && obj!="") {
		var myObj = getObject(obj, nestedLayer)
		myObj.document.images[imgName].src = imgSrc
	}
	else document.images[imgName].src=imgSrc
}

//changing background color in a div
function changeBgColor(obj, color, nestedLayer) {
		obj = getObject(obj,nestedLayer)
		alert(obj);
		if(isNAV4) {
			obj.document.bgColor = color
			}
		
		else {
			obj.backgroundColor = color
		}
}

