/******************************************************
DHTML SCRIPTS MODULE

This module contains cross-browser compatible scripts for
manipulating DHTML layers.
******************************************************/

function getObjectStyle(obj) {
	return (typeof obj=="string")? eval(doc + obj + ns6mod + sty):obj;
}

function getObjectNoStyle(obj) {
	return (typeof obj=="string")? eval(doc + obj + ns6mod):obj;
}

function positionAt(obj, x, y) {
	var Ob = getObjectStyle(obj);
	if (browser=="NN") {
		Ob.moveTo(x,y);
	} else if (browser=="NS6") {
		Ob.left = x + "px";
		Ob.top = y + "px";
	} else {
		Ob.pixelLeft = x;
		Ob.pixelTop = y;
	}
}

function setSize(obj, x, y) {
	var Ob = getObjectStyle(obj);
	if (browser=="NN") {
		Ob.resizeTo(x,y);
	} else if (browser=="NS6") {
		Ob.width = x;
		Ob.height = y;
	} else {
		Ob.posWidth=x;
		Ob.posHeight=y;
	}
}

function shiftBy(obj, dX, dY) {
	var Ob = getObjectStyle(obj);
	if (browser=="NN") {
		Ob.moveBy(dX,dY);
	} else if (browser=="NS6") {
		Ob.left = parseInt(Ob.left) + dX + "px";
		Ob.top = parseInt(Ob.top) + dY + "px";
	} else {
		Ob.pixelLeft += dX;
		Ob.pixelTop += dY;
	}
}

function setZIndex(obj, z) {
	getObjectStyle(obj).zIndex = z;
}

function show(obj) {
	getObjectStyle(obj).visibility = "visible";
}

function hide(obj) {
	getObjectStyle(obj).visibility = "hidden";
}

function getLeft(obj) {
	var Ob = getObjectStyle(obj);
	return (browser=="IE")?Ob.pixelLeft:parseInt(Ob.left);	// NN & NS6 same
}

function getTop(obj) {
	var Ob = getObjectStyle(obj);
	return (browser=="IE")?Ob.pixelTop:parseInt(Ob.top);	// NN & NS6 same
}

function getWidth(obj) {
	var Ob = null;
	if (browser=="IE") {
		Ob = getObjectNoStyle(obj);
		return Ob.offsetWidth; 
	} else if (browser=="NN") {
		Ob = getObjectStyle(obj);
		return Ob.right;
	} else if (browser=="NS6") {
		// Ob = getObjectStyle(obj);
		// return parseInt(Ob.width);
		Ob = getObjectNoStyle(obj);
		return Ob.clientWidth;
	}
}

function getHeight(obj) {
	var Ob = null;
	if (browser=="IE") {
		Ob = getObjectNoStyle(obj);
		return Ob.offsetHeight;
	} else if (browser=="NN") {
		Ob = getObjectStyle(obj);
		return Ob.clip.bottom;
	} else if (browser=="NS6") {
		Ob = getObjectStyle(obj);
		return parseInt(Ob.height);
	}
}

function setClip(obj,t,r,b,l) {
	var Ob = getObjectStyle(obj);
	
	if (browser=="NN") {
		Ob.clip.top=t;
		Ob.clip.right=r;
		Ob.clip.bottom=b;
		Ob.clip.left=l;
	} else {
		Ob.clip="rect("+t+"px "+r+"px "+b+"px "+l+"px)";
	}
}

function isVisible(obj) {
	var Ob = getObjectStyle(obj);
	return (browser=="IE")?(Ob.visibility=="visible"):(Ob.visibility=="show");
}

function winWidth() {
	return (browser=="IE")? document.body.clientWidth:window.innerWidth;
}

function winHeight() {
	return (browser=="IE")? document.body.clientHeight:window.innerHeight;
}

function scrollDistance() {
	return (browser=="IE")? document.body.scrollTop:window.pageYOffset;
}

function getCursorX(e) {
	return (browser=="IE")?window.event.clientX:e.pageX;
}

function getCursorY(e) {
	return (browser=="IE")?window.event.clientY:e.pageY;
}

function setBorder(obj,bStr) {
	// ie only for now
	var Ob = getObjectStyle(obj);
	Ob.border = bStr;
}

function setBGColor(obj,c) {
	// ie only for now
	var Ob = getObjectStyle(obj);
	Ob.backgroundColor = c;
}

function setBGImage(obj,i) {
	// ie only for now
	var Ob = getObjectStyle(obj);
	Ob.backgroundImage = "url(" + i + ")";
}

function setTextColor(obj,c){
	// ie 4+, NN 7+
	var Ob = getObjectStyle(obj);
	Ob.cssText = "color:" + c;
}

function setTextWeight(obj,w) {
	// ie 4+ NN 7+
	var Ob = getObjectStyle(obj);
	Ob.fontWeight = w;
}

function setTextDecoration(obj,d){
	// ie 4+, NN 7+
	var Ob = getObjectStyle(obj);
	Ob.textDecoration = d;
}

function writeLayer(obj,data) {
	var Ob = getObjectNoStyle(obj);
	if (browser=="NN") {
			Ob.document.open();
			Ob.document.write(data);
			Ob.document.close();
	} else if ((browser=="IE")||(browser=="NS6")) {
			Ob.innerHTML = data;
	}
}

function loadLayer(obj,src) {
	if (browser=="NN") {
		var Ob = getObjectNoStyle(obj);
		Ob.src = src;
	} else if (browser=="IE") {
		src = "<IFRAME SRC='" + src + "' SCROLLING='no' WIDTH='" + getWidth(obj) + "' HEIGHT='" + getHeight(obj)  + "' BORDER='0' FRAMEBORDER='0' FRAMESPACING='0'></IFRAME>";
		writeLayer(obj,src);
	} else if (browser=="NS6") {
		src = "<IFRAME SRC='" + src + "' SCROLLING='no' WIDTH='" + getWidth(obj) + "' HEIGHT='" + getHeight(obj)  + "' BORDER='0' FRAMEBORDER='0' FRAMESPACING='0'></IFRAME>";
		writeLayer(obj,src);
	}
}
