/******************************************************************************/
// Embedded Popups

function showpopbox(sName,offsetX,offsetY,sLink) {
	// fix burn through
	fixBurnThru(true);

	// get the position of the associated link
	if ((sLink == null) || (sLink == "")) { sLink = sName+'_link'; }

	if (document.getElementById(sLink) != null) {
		var xPos = findPos(document.getElementById(sLink),'x');
		var yPos = findPos(document.getElementById(sLink),'y');
		// pad the position so the link will not be covered
		xPos = xPos + 5;
		yPos = yPos + 13;
	} else {
		// if there's no link to attach to, put the popup under the nav
		var xPos = 100;
		var yPos = 150;
	}
	// move elements if needed
	if (!isNaN(offsetX)) { xPos = xPos + offsetX; }
	if (!isNaN(offsetY)) { yPos = yPos + offsetY; }
	// open the embedded popup
	document.getElementById(sName).style.display = 'block';
	document.getElementById(sName).style.left = xPos + "px";
	document.getElementById(sName).style.top = yPos + "px";
	return;
}
function showinlinepopbox(sName) {
	// fix burn through
    fixBurnThru(true);
	// opens the inline popups
	document.getElementById(sName).style.display = 'block';
	return;
}
function hidepopbox(sName) {
	// Closes the popups
	document.getElementById(sName).style.display = 'none';
	// fix burn through
    fixBurnThru(false);
	return;
}
// finds the position of the click to place the popup
function findPos(obj,axis) {
	var cur = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			if (axis == 'x') { cur += obj.offsetLeft }
			else { cur += obj.offsetTop }
			obj = obj.offsetParent;
		}
	} else {
		if ((axis == 'x') && (obj.x)) { cur += obj.x; }
		if ((axis == 'y') && (obj.y)) { cur += obj.y; }
	}
	return cur;
}
// fix the burnthrough on select elements in IE, ns6 and 7 do not have burn-through
// this script is duplicated in menu_settings.js as "fixBurn" for external sites (RNT, Unopi, etc)
function fixBurnThru(isHidden) {
	// only run for IE 6 or lower
	if (document.all && (navigator.userAgent.indexOf("MSIE 7") == -1)) {
		var rows = document.getElementsByTagName('select');
		for( var i = 0, row; row = rows[i]; i++ ) {
			if (isHidden) {
				row.style.visibility = "hidden";
			} else {
				row.style.visibility = "visible";
			}
		}
	}
	return;
}