function amg_MsgBox(oParams, iType, iWidth, iHeight, sTitle, sMessage, sSubtitle, iPrompt, sPrompt, vPrompt, sCallerMdlName) {
	if (!oParams) var oParams=new Array();
	if (!iType) var iType=0;
	if (!iWidth) var iWidth=320; if (!iHeight) var iHeight=240;
	if (!sTitle) var sTitle=""; if (!sSubtitle) var sSubtitle=""; if (!sMessage) sMessage="";
	if (!iPrompt) var iPrompt=0; if (!sPrompt) var sPrompt=""; if (!vPrompt) var vPrompt=0;
	if (!sCallerMdlName) var sCallerMdlName="";
	/*
	iType - mbmode
	sTitle - mbtitle
	sSubtitle - mbsubtitle
	iPrompt - mbpromptmode
	sPrompt - mbpromptstr
	vPrompt - mbpromptval
	*/
	var sSrc="/webdirector/shell/msgbox.php";
	sSrc+="?mbmode="+iType;
	sSrc+="&mbtitle="+(sTitle);//escape
	sSrc+="&mbmessage="+(sMessage);//escape
	sSrc+="&mbsubtitle="+(sSubtitle);//escape
	sSrc+="&mbpromptmode="+iPrompt;
	sSrc+="&mbpromptstr="+(sPrompt);//escape
	sSrc+="&mbpromptval="+(vPrompt);//escape
	sSrc+="&caller="+(sCallerMdlName);//escape
	return amg_ModalDialog(sSrc, iWidth, iHeight, oParams, 0, 0, 0);
}
function amg_ModalDialog(sSrc, iWidth, iHeight, sWinName, iXOffset, bModeless, sResizable) {
	if (!sResizable) sResizable="No";
	if (!iXOffset) iXOffset=0; iXOffset=parseInt(iXOffset);
	if (!sWinName) var sWinName=null;
	iWidth=parseInt(iWidth);
	iHeight=parseInt(iHeight);
	var sw=screen.availWidth; var sh=screen.availHeight;
	if ((iWidth+20)>sw) iWidth=sw-20;
	if ((iHeight+24)>sh) iHeight=sh-24;
	var ww=iWidth+20; var wh=iHeight+24;
	var wx=(sw-ww)/2; if (wx<0) wx=0;
	var wy=(sh-wh)/2; if (wy<0) wy=0;
	wx+=iXOffset;
	// ================================
	var sWinParams="dialogHeight: "+wh+"px; dialogWidth: "+ww+"px; dialogTop: px; dialogLeft: px; edge: Raised; center: Yes; help: Yes; resizable: "+sResizable+"; status: Yes;";
	if (bModeless) {
		try {
			var vDialogReturn=window.showModelessDialog(sSrc, sWinName, sWinParams);
		} catch (theError) {
			var arrError=wd_ErrCodes(theError.number);
			if (arrError[0]===5 && arrError[1]===7) {
				alert(WD_MSG_NEEDPOPUP);
			}
			var vDialogReturn=false;
		}
	} else {
		try {
			var vDialogReturn=window.showModalDialog(sSrc, sWinName, sWinParams);
		} catch (theError) {
			var arrError=wd_ErrCodes(theError.number);
			if (arrError[0]===5 && arrError[1]===7) {
				alert(WD_MSG_NEEDPOPUP);
			}
			var vDialogReturn=false;
		}
	}
	if (!vDialogReturn) vDialogReturn=false;
	return vDialogReturn;
}

var arrWdModalWins=new Array();
function amg_ModalWin(sSrc, iWidth, iHeight, sWinName, iXOffset, bForceSizes, sCharset, bTheater) {
	if (!bTheater) {
		var sTheater='no';
	} else {
		var sTheater='yes';
	}
	var sWinKey=sWinName;
	if (!iXOffset) iXOffset=0; iXOffset=parseInt(iXOffset);
	if (!sWinName) var sWinName=null;
	iWidth=parseInt(iWidth);
	iHeight=parseInt(iHeight);
	var sw=screen.availWidth; var sh=screen.availHeight;
	if ((iWidth+20)>sw) iWidth=sw-20;
	if ((iHeight+24)>sh) iHeight=sh-24;
	var ww=iWidth+20; var wh=iHeight+24;
	// ====
	if (!bForceSizes) {
		var sResize="no";
		if (ww>900) {
			ww=900; sResize="yes";
		}
		if (wh>690) {
			wh=690; sResize="yes";
		}
	} else if (bForceSizes===2) {
		var sResize="yes";
	} else {
		var sResize="no";
	}
	// ====
	var wx=(sw-ww)/2; if (wx<0) wx=0;
	var wy=(sh-wh)/2; if (wy<0) wy=0;
	wx+=iXOffset;
	// ================================
	var sFlusher=""; while (sFlusher.length<12) sFlusher+="&nbsp;";
	// ================================
	if (sWinName) sWinName=sWinName.replace(/-/gi, "_");
	if (arrWdModalWins[sWinKey]) {
		try {arrWdModalWins[sWinKey].close();} catch (theError) {void(0);}
	}
	var bOpenedOk=true;
	var sExtntn=sSrc.substr(sSrc.lastIndexOf(".")).toUpperCase();
	try {
		//if (sExtntn==".GIF"||sExtntn==".PNG"||sExtntn==".JPG"||sExtntn==".GPEG"||sExtntn==".BMP"||sExtntn==".SWF"||sSrc.indexOf("transimg.php?")!=-1||sExtntn==".WDABOUT"||sExtntn==".WDPERFORMANCE") {
			var bu=window.open("about:blank", sWinName, "left="+wx+",top="+wy+",width="+ww+",height="+wh+",location=no,menubar=no,resizable="+sResize+",status=yes,titlebar=yes,toolbar=no,scrollbars="+sResize+",channelmode=no,fullscreen=no");
		//} else {
		//	var bu=window.open(sSrc, sWinName, "left="+wx+",top="+wy+",width="+ww+",height="+wh+",location=no,menubar=no,resizable="+sResize+",status=yes,titlebar=yes,toolbar=no,scrollbars="+sResize+",channelmode=no,fullscreen=no");
		//}
		if (bu===null) alert(WD_MSG_NEEDPOPUP);
	} catch (theError) {
		var arrError=wd_ErrCodes(theError.number);
		if (arrError[0]===5 && arrError[1]===7) {
			alert(WD_MSG_NEEDPOPUP);
		} else {
			alert("err1: "+theError.description);
		}
		bOpenedOk=false;
	}
	if (bu && bOpenedOk) {
		bu.focus();
		if (sSrc!="about:blank") {
			//var sExtntn=sSrc.substr(sSrc.lastIndexOf(".")).toUpperCase();
			if (sExtntn==".GIF"||sExtntn==".PNG"||sExtntn==".JPG"||sExtntn==".GPEG"||sExtntn==".BMP"||sExtntn==".SWF"||sSrc.indexOf("transimg.php?")!=-1) {
				bu.document.open();
				bu.document.write("<HTML><HEAD><TITLE>&nbsp;"+"site image viewer"+sFlusher+"</TITLE></HEAD><BODY LEFTMARGIN=\"10\" TOPMARGIN=\"10\" MARGINWIDTH=\"10\" MARGINHEIGHT=\"10\" SCROLL='"+sResize+"' ONSELECTSTART='return false;' ONSELECT='return false;' ONCONTEXTMENU='//return false;' ONCLICK='self.close();' ONBLUR='self.close();'>");
				if (sExtntn==".SWF") {
					bu.document.write("<OBJECT classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" WIDTH=\""+iWidth+"\" HEIGHT=\""+iHeight+"\">");
						bu.document.write("<PARAM NAME=\"movie\" VALUE=\""+sSrc+"\">");
						bu.document.write("<PARAM NAME=\"loop\" VALUE=\"false\">");
						bu.document.write("<PARAM NAME=\"quality\" VALUE=\"medium\">");
						//bu.document.write("<PARAM NAME=\"scale\" VALUE=\"noborder\">");
						bu.document.write("<PARAM NAME=\"bgcolor\" VALUE=\"#FFFFFF\">");
						bu.document.write("<PARAM NAME=\"wmode\" value=\"transparent\">");
						bu.document.write("<EMBED src=\""+sSrc+"\" loop=false quality=medium bgcolor=#FFFFFF TYPE=\"application/x-shockwave-flash\" PLUGINSPAGE=\"http://www.macromedia.com/go/getflashplayer\"></EMBED>");
					bu.document.write("</OBJECT>");
					bu.document.write("<DIV STYLE=\"position:absolute;left:10px;top:10px;z-index:99;\">");
						bu.document.write("<IMG SRC=\"http://"+WD_HOST+'/webdirector/images/empty.gif'+"\" WIDTH=\""+iWidth+"\" HEIGHT=\""+iWidth+"\" BORDER=\"0\">");
					bu.document.write("</DIV>");
				} else {
					bu.document.write("<IMG SRC='"+sSrc+"' BORDER='0'>");
				}
				bu.document.write("</BODY></HTML>");
				//bu.document.write("<SCRIPT LANGUAGE=\"JavaScript\">alert('"+sSrc+"');</SCRIPT>");
				bu.document.close();
			} else if (sExtntn==".WDABOUT") {
				sSrc=sSrc.substr(0, sSrc.length-8); // 8 = .WDABOUT
				bu.document.open();
				bu.document.write("<HTML><HEAD><META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset="+sCharset+"\"><SCRIPT LANGUAGE='JavaScript' SRC='/webdirector/js/proto.js'></SCRIPT><SCRIPT LANGUAGE='JavaScript' SRC='/webdirector/js/main.js'></SCRIPT><TITLE>&nbsp;"+"info"+"&nbsp;</TITLE><LINK REL='stylesheet' TYPE='text/css' HREF='/webdirector/css/style.css'><STYLE>\r\nBODY, TABLE {\r\nfont-size: 12px;\r\nfont-family: monospace;\r\ncursor: default;\r\n}\r\n</STYLE></HEAD><BODY SCROLL='"+sResize+"' ONSELECTSTART='return amg_SelectCanc();' ONSELECT='return amg_SelectCanc();' ONCONTEXTMENU='return amg_SelectCanc();' ONCLICK='//self.close();' ONBLUR='//self.close();' STYLE=\"padding:4px;margin:0px;background-color:buttonface;color:buttontext;border-style:outset;border-width:1px;border-color:buttonface;\">"+sSrc.replace(/\\\"/gi, "'")+"</BODY></HTML>");
				bu.document.close();
				bu.title=" info ";
			} else if (sExtntn==".WDPERFORMANCE") {
				sSrc=sSrc.substr(0, sSrc.length-14); // 14 = .WDPERFORMANCE
				bu.document.open();
				bu.document.write("<"+"?xml version=\"1.0\" encoding=\""+sCharset+"\" ?"+">"+"<"+"?xml-stylesheet type=\"text/xsl\" href=\""+"/webdirector/shell/wdperformance.xsl.php"+"?seed="+wd_TimeUTC()+"&chrst="+sCharset+"&ext=.xsl\" version=\"1.0\" ?"+">"+"<WDPERFORMANCE>"+sSrc.replace(/\\\"/gi, "'")+"</WDPERFORMANCE>");
				bu.document.close();
			} else {
				try {
					bu.document.location.href=sSrc;	
				} catch (theError) {
					alert("err2: "+theError.description);
				}
			}
		}
		bu.focus();
	}
	if (bu && sWinKey) arrWdModalWins[sWinKey]=bu;
	return false;
}
function amg_DelConfirm(sFormName) {
	var theF=document.forms[sFormName];
	if (theF) {
		var bDelMarks=0;
		for (i=0;i<theF.elements.length;i++) {
			var theEl=theF.elements[i];
			var sElName=theEl.name;
			if (sElName.substring(0, 6)=="todel["&&theEl.checked) {
				bDelMarks=1;
				break;
			}
		}
		if (bDelMarks) {
			return confirm(WD_MSG_DELCONFIRM);
		} else {
			return true;
		}
	} else {
		return true;
	}
}
function wd_ShowDbgTimetracing(sCharset) {
	var theDiv=document.getElementById('WDBG_TIMETRACING');
	if (theDiv) {
		amg_ModalWin(theDiv.innerHTML+".WDABOUT", 600, 320, 'WDBG_TIMETRACING', 0, 2, sCharset, 0);
	}
}