function wd_AddMacrosToAreaCnt(sFormName, sTAreaName, sMacrosName) {
	var theTA=document.forms[sFormName].elements[sTAreaName];
	var theSel=document.selection;
	if (theTA) {
		theTA.focus();
		var theRange=null;
		if (theSel) theRange=theSel.createRange();
		if (theRange) {
			var sToPaste="%"+sMacrosName+"%";
			theRange.text=sToPaste;
		}
	}
}
function wd_AddFoo1ToAreaCnt(sFormName, sTAreaName, sMdlName, sMacrosName, sTreeElsTypes) {
	if (!sTreeElsTypes) var sTreeElsTypes=0;
	var theTA=document.forms[sFormName].elements[sTAreaName];
	var theSel=document.selection;
	if (theTA) {
		theTA.focus();
		var theRange=null;
		if (theSel) theRange=theSel.createRange();
		if (theRange) {
			var arrPreParams=new Array();
			arrPreParams[0]=sMdlName;
			arrPreParams[1]=sTreeElsTypes;
			var sUserInput=amg_ModalDialog("/webdirector/shell/setmainitem.php"+"?treetype="+sTreeElsTypes+"&mdl="+sMdlName+"&field="+""+"&actor="+"", 360, 520, arrPreParams, 0);
			if (sUserInput) {
				var sToPaste="["+sMacrosName.toUpperCase()+" "+sUserInput+"]";
				theRange.text=sToPaste;
			}
		}
	}
}
function wd_AddCatalogToAreaCnt(sFormName, sTAreaName) {
	var theTA=document.forms[sFormName].elements[sTAreaName];
	var theSel=document.selection;
	if (theTA) {
		theTA.focus();
		var theRange=null;
		if (theSel) theRange=theSel.createRange();
		if (theRange) {
			var sWinName='wd_cataloger';
			var sUserInput=amg_ModalDialog('/webdirector/mdl_content/shell/setcatalogtbl.php?sid=root', 360, 560, sWinName, -96);
			if (sUserInput) {
				var arrParams=sUserInput.split("+++");
				sParam1=arrParams[0];
				sParam2=arrParams[1];
				if (sParam1.length) {
					var arrParam1=sParam1.split("%%%");
					var arrParam2=sParam2.split("/");
					var sColumnSID=arrParam1[0];
					var sTplSID=arrParam1[1];
					var sCurrSID=arrParam1[2];
					var iNeedReverse=parseInt(arrParam2[0]);
					var iNeedLimit=parseInt(arrParam2[1]);
					var iQuantLimit=parseInt(arrParam2[2]);
					if (!iQuantLimit) iQuantLimit=0;
					var sToPaste="[CATALOG";
					if (sColumnSID.length) {
						if (sColumnSID!=sCurrSID||sTplSID.length||(iNeedLimit&&iQuantLimit)||iNeedReverse) {
							sToPaste+=(" "+sColumnSID);
							if (sTplSID.length&&(sTplSID!=sCurrSID||(iNeedLimit&&iQuantLimit)||iNeedReverse)) {
								sToPaste+=(" "+sTplSID);
								if ((iNeedLimit&&iQuantLimit)||iNeedReverse) sToPaste+=(" "+iQuantLimit);
								if (iNeedReverse) sToPaste+=" reverse";
							}
						}
					}
					sToPaste+="]";
					//
					theRange.text=sToPaste;
				}
			}
		}
	}
}