// JavaScript Document

var ie=document.all

function closeHelp() {
		document.getElementById("pop").style.visibility = "hidden";
		showElement( 'SELECT' );
}

function popHelp(obj, txt) {
		var popupLayer = "pop";
		var popupLayerTxtObj = "poptxt";
		var popupLayerText = txt;
		//setLyr(document.getElementById(obj),popupLayer);
		setLyr(obj,popupLayer);
		document.getElementById(popupLayerTxtObj).innerHTML = popupLayerText;
		hideElement( 'SELECT', document.getElementById("pop") );
		document.getElementById("pop").style.visibility = "visible";
}

function setLyr(obj,lyr) {
		var newX = findPosX(obj);
		var newY = findPosY(obj);
		var x = new getObj(lyr);
		//x.style.top = (4 + obj.offsetHeight + newY) + 'px';
		//x.style.left = (5 + obj.offsetWidth + newX) + 'px';
		x.style.top = (21 + newY) + 'px';
		x.style.left = (-350 + newX) + 'px';
}

function findPosX(obj) {
		var curleft = 0;
		if (obj.offsetParent) {
			while (obj.offsetParent) {
				curleft += obj.offsetLeft
				obj = obj.offsetParent;
			}
		}
		else if (obj.x)
		curleft += obj.x;
		return curleft;
}

function findPosY(obj) {
		var curtop = 0;
		var printstring = '';
		if (obj.offsetParent) {
			while (obj.offsetParent) {
				curtop += obj.offsetTop
				obj = obj.offsetParent;
			}
		}
		else if (obj.y)
		curtop += obj.y;
		curtop -= 20;
		return curtop;
}


function getObj(name) {
		if (document.getElementById) {
			this.obj = document.getElementById(name);
			this.style = document.getElementById(name).style;
		}
		else if (document.all) {
			this.obj = document.all[name];
			this.style = document.all[name].style;
		}
		else if (document.layers) {
			if (document.layers[name]) {
				this.obj = document.layers[name];
				this.style = document.layers[name];
			}
			else {
				this.obj = eval("document." + name + ".testP.layers[name];");
				this.style = eval("document." + name + ".testP.layers[name];");
			}
		}
}

// hides <select> and <applet> objects (for IE only)
function hideElement( elmID, overDiv ){
	if( ie ){
		for( i = 0; i < document.all.tags( elmID ).length; i++ ){
  			obj = document.all.tags( elmID )[i];
  			if( !obj || !obj.offsetParent ){
    				continue;
  			}
			  // Find the element's offsetTop and offsetLeft relative to the BODY tag.
			  objLeft   = obj.offsetLeft;
			  objTop    = obj.offsetTop;
			  objParent = obj.offsetParent;
			  //alert (overDiv.offsetTop);
			  while( objParent.tagName.toUpperCase() != "BODY" )
			  {
			    objLeft  += objParent.offsetLeft;
			    objTop   += objParent.offsetTop;
			    objParent = objParent.offsetParent;
			  }
			  objHeight = obj.offsetHeight;
			  objWidth = obj.offsetWidth;

			  if(( overDiv.offsetLeft + overDiv.offsetWidth ) <= objLeft );
			  else if(( overDiv.offsetTop + overDiv.offsetHeight ) <= objTop );
	/* CHANGE for nested TDs*/
			  else if( overDiv.offsetTop >= ( objTop + objHeight + obj.height ));
	/* END CHANGE */
			  else if( overDiv.offsetLeft >= ( objLeft + objWidth ));
			  else
			  {
					if (objTop > (overDiv.offsetTop - 3)) { /* CHANGE by Lloyd Jacob Lopez to unhide objects above the popup*/
						obj.style.visibility = "hidden";
			  		} /* END CHANGE */
			  }
		}
	}
}
     
//unhides <select> and <applet> objects (for IE only)
function showElement( elmID ){
	if( ie ){
		for( i = 0; i < document.all.tags( elmID ).length; i++ ){
  			obj = document.all.tags( elmID )[i];
			if( !obj || !obj.offsetParent ){
    				continue;
			}
			obj.style.visibility = "";
		}
	}
}