var s_amg_CurrBgrptbox=""; //
var o_amg_TimerBgrptbox=null; //

function amg_SetBgrptBox(oToEl) {
	if (!oToEl) var oToEl=event.srcElement;
	if (oToEl && oToEl.id && oToEl.id.substr(0,1)=="%") {
		if (s_amg_CurrBgrptbox) {
			var sBgrptCode=oToEl.id;
			var sBgrptValue=sBgrptCode.substr(0, (sBgrptCode.length-1)).substr(2);
			if (sBgrptValue.length) {
				var oCurrBgrptBox=document.getElementById(s_amg_CurrBgrptbox+"_code");
				if (oCurrBgrptBox) {
					oCurrBgrptBox.value=sBgrptValue;
					//oCurrBgrptBox.innerHTML=sBgrptValue;
					//var oHiddBox=document.getElementById(s_amg_CurrBgrptbox+"_code");
					//if (oHiddBox) oHiddBox.value=sBgrptCode;
					amg_HideBgrptBox();
				}
			}
		}
	}
}

function amg_FixBgrptBox() {
	if (o_amg_TimerBgrptbox) window.clearTimeout(o_amg_TimerBgrptbox);
	var oToEl=event.toElement;
	if (oToEl && oToEl.id && oToEl.id.substr(0,1)=="%") {
		var sBgrptCode=oToEl.id;
		var sFFamilyValue=sBgrptCode.substr(0, (sBgrptCode.length-1)).substr(2);
	}
}

function amg_HiddBgrptBox() {
	var oToEl=event.toElement;
	if (!oToEl) {
		amg_HideBgrptBox();
	} else {
		var sToEl=oToEl.id;
		var sToElPar="";
		var oToElPar=oToEl.parentElement;
		if (oToElPar) sToElPar=oToElPar.id;
		if (sToEl || sToElPar) {
			if ((sToEl.substr(0,11)!="amg_poptab_")&&(sToElPar.substr(0,11)!="amg_poptab_")) {
				amg_HideBgrptBox();
			}
		} else {
			amg_HideBgrptBox();
		}
	}
}

function amg_HideBgrptBox() {
	s_amg_CurrBgrptbox="";
	var theBgrptCtrl=document.getElementById("amg_poptab_bgrptStd");
	if (theBgrptCtrl) {
		theBgrptCtrl.style.left=-1000;
		theBgrptCtrl.style.top=-1000;
		theBgrptCtrl.style.visibility="hidden";
	}
}

function amg_ShowBgrptBox(sBoxId) {
	var theBgrptCtrl=document.getElementById("amg_poptab_bgrptStd");
	var theBox=document.getElementById(sBoxId+"_code");
	if (theBgrptCtrl && theBox) {
		s_amg_CurrBgrptbox=sBoxId;
		window.clearTimeout(o_amg_TimerBgrptbox);
		o_amg_TimerBgrptbox=null;
		o_amg_TimerBgrptbox=window.setTimeout("amg_HideBgrptBox()", 1500);
		theBgrptCtrl.style.left=absLeft(theBox);
		theBgrptCtrl.style.top=absTop(theBox);//+theBox.offsetHeight;
		if ((parseInt(theBgrptCtrl.style.top)+theBgrptCtrl.offsetHeight)>document.body.clientHeight+document.body.scrollTop) {
			theBgrptCtrl.style.top=absTop(theBox)+theBox.offsetHeight-theBgrptCtrl.offsetHeight;
		}
		while (parseInt(theBgrptCtrl.style.top)<0) {
			theBgrptCtrl.style.top=parseInt(theBgrptCtrl.style.top)+8;
		}
		theBgrptCtrl.style.visibility="visible";
	}
}