var s_amg_CurrBrdstylebox=""; //
var o_amg_TimerBrdstylebox=null; //

function amg_SetBrdstyleBox(oToEl) {
	if (!oToEl) var oToEl=event.srcElement;
	if (oToEl && oToEl.id && oToEl.id.substr(0,1)=="%") {
		if (s_amg_CurrBrdstylebox) {
			var sBrdstyleCode=oToEl.id;
			var sBrdstyleValue=sBrdstyleCode.substr(0, (sBrdstyleCode.length-1)).substr(2);
			if (sBrdstyleValue.length) {
				var oCurrBrdstyleBox=document.getElementById(s_amg_CurrBrdstylebox+"_code");
				if (oCurrBrdstyleBox) {
					oCurrBrdstyleBox.value=sBrdstyleValue;
					//oCurrBrdstyleBox.innerHTML=sBrdstyleValue;
					//var oHiddBox=document.getElementById(s_amg_CurrBrdstylebox+"_code");
					//if (oHiddBox) oHiddBox.value=sBrdstyleCode;
					amg_HideBrdstyleBox();
				}
			}
		}
	}
}

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

function amg_HiddBrdstyleBox() {
	var oToEl=event.toElement;
	if (!oToEl) {
		amg_HideBrdstyleBox();
	} 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_HideBrdstyleBox();
			}
		} else {
			amg_HideBrdstyleBox();
		}
	}
}

function amg_HideBrdstyleBox() {
	s_amg_CurrBrdstylebox="";
	var theBrdstyleCtrl=document.getElementById("amg_poptab_brdstlStd");
	if (theBrdstyleCtrl) {
		theBrdstyleCtrl.style.left=-1000;
		theBrdstyleCtrl.style.top=-1000;
		theBrdstyleCtrl.style.visibility="hidden";
	}
}

function amg_ShowBrdstyleBox(sBoxId) {
	var theBrdstyleCtrl=document.getElementById("amg_poptab_brdstlStd");
	var theBox=document.getElementById(sBoxId+"_code");
	if (theBrdstyleCtrl && theBox) {
		s_amg_CurrBrdstylebox=sBoxId;
		window.clearTimeout(o_amg_TimerBrdstylebox);
		o_amg_TimerBrdstylebox=null;
		o_amg_TimerBrdstylebox=window.setTimeout("amg_HideBrdstyleBox()", 1500);
		theBrdstyleCtrl.style.left=absLeft(theBox);
		theBrdstyleCtrl.style.top=absTop(theBox);//+theBox.offsetHeight;
		if ((parseInt(theBrdstyleCtrl.style.top)+theBrdstyleCtrl.offsetHeight)>document.body.clientHeight+document.body.scrollTop) {
			theBrdstyleCtrl.style.top=absTop(theBox)+theBox.offsetHeight-theBrdstyleCtrl.offsetHeight;
		}
		while (parseInt(theBrdstyleCtrl.style.top)<0) {
			theBrdstyleCtrl.style.top=parseInt(theBrdstyleCtrl.style.top)+8;
		}
		theBrdstyleCtrl.style.visibility="visible";
	}
}