var s_amg_CurrUStylebox=""; //
var o_amg_TimerUStylebox=null; //

function amg_SetUStyleBox(oToEl) {
	if (!oToEl) var oToEl=event.srcElement;
	if (oToEl&&oToEl.id&&oToEl.id.substr(0,1)=="%") {
		if (s_amg_CurrUStylebox) {
			var sUStyleCode=oToEl.id;
			var sUStyleNum=sUStyleCode.substr(0, (sUStyleCode.length-1)).substr(2);
			var sUStyleValue=sUStyleNum;
			if (sUStyleValue.length) {
				var oCurrUStyleBox=document.getElementById(s_amg_CurrUStylebox);
				if (oCurrUStyleBox) {
					//oCurrUStyleBox.value=sUStyleValue;
					oCurrUStyleBox.innerHTML=sUStyleValue.split(",")[0];
					var oHiddBox=document.getElementById(s_amg_CurrUStylebox+"_code");
					if (oHiddBox) oHiddBox.value=sUStyleCode;
					amg_HideUStyleBox();
				}
			}
		}
	}
}

function amg_FixUStyleBox() {
	if (o_amg_TimerUStylebox) window.clearTimeout(o_amg_TimerUStylebox);
	var oToEl=event.toElement;
	if (oToEl&&oToEl.id&&oToEl.id.substr(0,1)=="%") {
		var sUStyleCode=oToEl.id;
		var sUStyleNum=sUStyleCode.substr(0, (sUStyleCode.length-1)).substr(2);
		var sUStyleValue=sUStyleNum;
		//if (arrUStyleCodes[sUStyleCode]) {
		//	sUStyleValue=arrUStyleCodes[sUStyleCode];
		//}
	}
}

function amg_HiddUStyleBox() {
	var oToEl=event.toElement;
	if (!oToEl) {
		amg_HideUStyleBox();
	} 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_HideUStyleBox();
			}
		} else {
			amg_HideUStyleBox();
		}
	}
}

function amg_HideUStyleBox() {
	s_amg_CurrUStylebox="";
	var theUStyleCtrl=document.getElementById("amg_poptab_fontStd");
	if (theUStyleCtrl) {
		theUStyleCtrl.style.left=-1000;
		theUStyleCtrl.style.top=-1000;
		theUStyleCtrl.style.visibility="hidden";
		if (document.getElementById("amg_poptab_ftr")) document.getElementById("amg_poptab_ftr").innerHTML="";
	}
}

function amg_ShowUStyleBox(sBoxId) {
	var theUStyleCtrl=document.getElementById("amg_poptab_fontStd");
	var theBox=document.getElementById(sBoxId);
	if (theUStyleCtrl&&theBox) {
		s_amg_CurrUStylebox=sBoxId;
		window.clearTimeout(o_amg_TimerUStylebox);
		o_amg_TimerUStylebox=null;
		o_amg_TimerUStylebox=window.setTimeout("amg_HideUStyleBox()",1500);
		theUStyleCtrl.style.left=absLeft(theBox);
		theUStyleCtrl.style.top=absTop(theBox);//+theBox.offsetHeight;
		if ((parseInt(theUStyleCtrl.style.top)+theUStyleCtrl.offsetHeight)>document.body.clientHeight+document.body.scrollTop) {
			theUStyleCtrl.style.top=absTop(theBox)+theBox.offsetHeight-theUStyleCtrl.offsetHeight;
		}
		theUStyleCtrl.style.visibility="visible";
	}
}