function getObj(name) {
	if (name) {
		if (document.getElementById) {
			if (document.getElementById(name)) {
				this.obj = document.getElementById(name);
				this.style = document.getElementById(name).style;
			} else {
				
				return false;
			}
		} else if (document.all) {
			this.obj = document.all[name];
			this.style = document.all[name].style;
		} else if (document.layers) {
			this.obj = document.layers[name];
			this.style = document.layers[name];
		} else {
			// no matching object found.  Do not display an error, because this may be on purpose.
			return false;
		}
		return this;
	}
}

function getWindowWidth() {
	// how's this for a tangle of browser incompatibilities?
	if (document.body) {
		if ((typeof(document.body.clientWidth) != "undefined") && (document.body.clientWidth != 0)) {
			return document.body.clientWidth;
		} else {
			return window.innerWidth - 16;
		}
	} else {
		return window.innerWidth - 16;
	}
}

function getTop(myName) {
	var myObj = new getObj(myName);
	if (myObj.style.pixelTop) {
		return Number(myObj.style.pixelTop);
	} else {
		var testPx = myObj.style.top;
		if (typeof myObj.style.top == "string") {
			return Number(myObj.style.top.substring(0,myObj.style.top.indexOf("px")));
		} else {
			return Number(myObj.style.top);
		}
	}
}

function setTop(myName, i) {
	var myObj = new getObj(myName);
	if (myObj.style) {
		if (myObj.style.pixelTop) {
			myObj.style.pixelTop = i;
		} else {
			myObj.style.top = i;
		}
	} else {
		// error... invalid div?
	}
}

function setLeft(myName, i) {
	var myObj = new getObj(myName);
	if(myObj.style != null){
		if (myObj.style.pixelLeft) {
			myObj.style.pixelLeft = i;
		} else {
			myObj.style.left = i;
		}
	}
}

function showLayer(myName) {
	var myObj = new getObj(myName);
	if(myObj.style != null){
		myObj.style.visibility="visible";
		myObj.visibility="visible";
		myObj.style.display="inline";
	}
}

function hideLayer(myName) {
	var myObj = new getObj(myName);
	if(myObj.style != null){
		myObj.style.visibility="hidden";
		myObj.style.display="none";
	}
}

function setZindex(myName, newZindex) {
	var myObj = new getObj(myName);
	if (myObj) {
		if (myObj.style.zIndex) {
			myObj.style.zIndex = newZindex;
		} 
	}
}

var mouseX=0;
var mouseY=0;
function getMouseLoc(e) {
	if (window.Event) { // Navigator 4.0x
		mouseX = e.pageX;
		mouseY = e.pageY;
	} else { // IE, NS6
		mouseX = (window.event.clientX + document.body.scrollLeft);
		mouseY = (window.event.clientY + document.body.scrollTop);
	}
}
if (window.Event) {document.captureEvents(Event.MOUSEDOWN)}
document.onmousedown = getMouseLoc;


/* 
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
   Generic cookie scripts, reusable anywhere
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
*/

function getCookie(cookieName) {
	var myCookie = document.cookie;
	var prefix = cookieName + "=";
	var begin = myCookie.indexOf("; " + prefix);
	if (begin == -1) {
		begin = myCookie.indexOf(prefix);
		if (begin != 0) return null;
	} else {
		begin += 2;
	}
	
		
}


/* 
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
   Simplified browser sniffer. Growing more complex, though.
   
   Please avoid using this whenever possible: it's much better
   to do capability testing than version testing.  Currently, this is used for:
   - Drawer speed control (NS6 was way too slow)
   - Mouse location detection (IE5/Mac returns locations relative to the div, not the window)
   - Profile drawer (NS4 can't write profile data into the form)
   
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
*/

function BrowserIs () {
	var agt=navigator.userAgent.toLowerCase()
	this.agent = agt;

	this.ns    = ((agt.indexOf('mozilla')!=-1) && ((agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1)));
	this.ie    = (agt.indexOf("msie") != -1);
	this.opera = (agt.indexOf("opera") != -1);

	// Mozilla always claims to be version 5. Bastards. 
	// The "real" version number is tucked away at the end of the string.
	if (this.ns && (parseInt(navigator.appVersion) == 5)) {
	
		// not only that, but different versions seem to handle substring differently???
		var versionString = agt.substring(agt.indexOf('netscape')+9);
		if (versionString.indexOf('/') == -1) {
			this.major = parseInt(versionString);
			this.minor = parseFloat(versionString);
		} else {
			this.major = parseInt(versionString.substring(1));
			this.minor = parseFloat(versionString.substring(1));
		}
	} else {
		this.major = parseInt(navigator.appVersion);
		this.minor = parseFloat(navigator.appVersion);
	}

	this.win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) )
	this.mac    = (agt.indexOf("mac")!=-1)
}

var browserIs = new BrowserIs();

