/* Generic functions used throughout the site */

function setClassByObj(obj, newClass) {
	obj.className = newClass;
}

function setClassById(objID, newClass) {
	if (isNS6 || isIE) {
		if (obj = document.getElementById(objID)) {
			obj.className = newClass;
		}
	}
}

function hideByObj(obj) {
	if (isNS6 || isIE) {
		obj.style.visibility = "hidden"
	}
}

function showByObj(id) {
	if (isNS6 || isIE) {
		obj.style.visibility = "visible"
	}
}

function showById(id) {
	if (isNS6 || isIE) {
		if (obj = document.getElementById(id)) {
			obj.style.visibility = "visible";
		}
	}
}

function hideById(id) {
	if (isNS6 || isIE) {
		if (obj = document.getElementById(id)) {
			obj.style.visibility = "hidden";
		}
	}
}

function moveLayer(id, x, y) {
	if (isIE || isNS6) {
		if (obj = document.getElementById(id)) {
			obj.style.left = x;
			obj.style.top = y;
		}
	}
}

function toggleDisplay(id){
	if (isNS6 || isIE) {
		if (obj = document.getElementById(id)) {
			if (obj.style.display == "") {
				obj.style.display = "none";
			}
			else {
				obj.style.display = "";
			}
		}
	}
}

function setDisplay(id, vis){
	if (isNS6 || isIE) {
		if (obj = document.getElementById(id)) {
			obj.style.display = vis;
		}
	}
}



// Determines an object's screen positin by looking at all of its parents positions
function findPosition(obj)
{
	var ret_obj = new Object;
	if ( obj.offsetParent )
	{
		for (var pos_x = 0, pos_y = 0; obj.offsetParent; obj = obj.offsetParent)
		{
			pos_x += obj.offsetLeft;
			pos_y += obj.offsetTop;
		}
		ret_obj.x = pos_x;
		ret_obj.y = pos_y;
		return ret_obj;
	}
	else
	{
		ret_obj.x = obj.x;
		ret_obj.y = obj.y;
		return ret_obj;
	}
}

// Opens the passed link in the current window
function openLink(dest, targetFrame) {
	if (targetFrame) 
		if (targetFrame == "newWindow") {
			window.open(dest,'newWindow')
		}
		else eval("parent."+targetFrame+".location = dest");
	else window.location = dest;
}


