var s_amg_CurrBgposbox=""; //
var o_amg_TimerBgposbox=null; //

function amg_SetBgposBox(oToEl) {
	if (!oToEl) var oToEl=event.srcElement;
	if (oToEl && oToEl.id && oToEl.id.substr(0,1)=="%") {
		if (s_amg_CurrBgposbox) {
			var sBgposCode=oToEl.id;
			var sBgposValue=sBgposCode.substr(0, (sBgposCode.length-1)).substr(2);
			if (sBgposValue.length) {
				var oCurrBgposBox=document.getElementById(s_amg_CurrBgposbox+"_code");
				if (oCurrBgposBox) {
					oCurrBgposBox.value=sBgposValue;
					//oCurrBgposBox.innerHTML=sBgposValue;
					//var oHiddBox=document.getElementById(s_amg_CurrBgposbox+"_code");
					//if (oHiddBox) oHiddBox.value=sBgposCode;
					amg_HideBgposBox();
				}
			}
		}
	}
}

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

function amg_HiddBgposBox() {
	var oToEl=event.toElement;
	if (!oToEl) {
		amg_HideBgposBox();
	} 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_HideBgposBox();
			}
		} else {
			amg_HideBgposBox();
		}
	}
}

function amg_HideBgposBox() {
	s_amg_CurrBgposbox="";
	var theBgposCtrl=document.getElementById("amg_poptab_bgposStd");
	if (theBgposCtrl) {
		theBgposCtrl.style.left=-1000;
		theBgposCtrl.style.top=-1000;
		theBgposCtrl.style.visibility="hidden";
	}
}

function amg_ShowBgposBox(sBoxId) {
	var theBgposCtrl=document.getElementById("amg_poptab_bgposStd");
	var theBox=document.getElementById(sBoxId+"_code");
	if (theBgposCtrl && theBox) {
		s_amg_CurrBgposbox=sBoxId;
		window.clearTimeout(o_amg_TimerBgposbox);
		o_amg_TimerBgposbox=null;
		o_amg_TimerBgposbox=window.setTimeout("amg_HideBgposBox()", 1500);
		theBgposCtrl.style.left=absLeft(theBox);
		theBgposCtrl.style.top=absTop(theBox);//+theBox.offsetHeight;
		if ((parseInt(theBgposCtrl.style.top)+theBgposCtrl.offsetHeight)>document.body.clientHeight+document.body.scrollTop) {
			theBgposCtrl.style.top=absTop(theBox)+theBox.offsetHeight-theBgposCtrl.offsetHeight;
		}
		while (parseInt(theBgposCtrl.style.top)<0) {
			theBgposCtrl.style.top=parseInt(theBgposCtrl.style.top)+8;
		}
		theBgposCtrl.style.visibility="visible";
	}
}