var s_amg_CurrWSpacebox=""; //
var o_amg_TimerWSpacebox=null; //

function amg_SetWSpaceBox(oToEl) {
	if (!oToEl) var oToEl=event.srcElement;
	if (oToEl && oToEl.id && oToEl.id.substr(0,1)=="%") {
		if (s_amg_CurrWSpacebox) {
			var sWSpaceCode=oToEl.id;
			var sWSpaceValue=sWSpaceCode.substr(0, (sWSpaceCode.length-1)).substr(2);
			if (sWSpaceValue.length) {
				var oCurrWSpaceBox=document.getElementById(s_amg_CurrWSpacebox+"_code");
				if (oCurrWSpaceBox) {
					oCurrWSpaceBox.value=sWSpaceValue;
					amg_HideWSpaceBox();
				}
			}
		}
	}
}

function amg_FixWSpaceBox() {
	if (o_amg_TimerWSpacebox) window.clearTimeout(o_amg_TimerWSpacebox);
	var oToEl=event.toElement;
	if (oToEl && oToEl.id && oToEl.id.substr(0,1)=="%") {
		var sWSpaceCode=oToEl.id;
		var sWSpaceValue=sWSpaceCode.substr(0, (sWSpaceCode.length-1)).substr(2);
	}
}

function amg_HiddWSpaceBox() {
	var oToEl=event.toElement;
	if (!oToEl) {
		amg_HideWSpaceBox();
	} 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_HideWSpaceBox();
			}
		} else {
			amg_HideWSpaceBox();
		}
	}
}

function amg_HideWSpaceBox() {
	s_amg_CurrWSpacebox="";
	var theWSpaceCtrl=document.getElementById("amg_poptab_wspaceStd");
	if (theWSpaceCtrl) {
		theWSpaceCtrl.style.left=-1000;
		theWSpaceCtrl.style.top=-1000;
		theWSpaceCtrl.style.visibility="hidden";
	}
}

function amg_ShowWSpaceBox(sBoxId) {
	var theWSpaceCtrl=document.getElementById("amg_poptab_wspaceStd");
	var theBox=document.getElementById(sBoxId+"_code");
	if (theWSpaceCtrl && theBox) {
		s_amg_CurrWSpacebox=sBoxId;
		window.clearTimeout(o_amg_TimerWSpacebox);
		o_amg_TimerWSpacebox=null;
		o_amg_TimerWSpacebox=window.setTimeout("amg_HideWSpaceBox()", 1500);
		theWSpaceCtrl.style.left=absLeft(theBox);
		theWSpaceCtrl.style.top=absTop(theBox);//+theBox.offsetHeight;
		if ((parseInt(theWSpaceCtrl.style.top)+theWSpaceCtrl.offsetHeight)>document.body.clientHeight+document.body.scrollTop) {
			theWSpaceCtrl.style.top=absTop(theBox)+theBox.offsetHeight-theWSpaceCtrl.offsetHeight;
		}
		while (parseInt(theWSpaceCtrl.style.top)<0) {
			theWSpaceCtrl.style.top=parseInt(theWSpaceCtrl.style.top)+8;
		}
		theWSpaceCtrl.style.visibility="visible";
	}
}