var ModalDialog = new function()
{
	//public members
	this.maintainFocus = maintainFocus;
	this.show = show;
	this.getDialogWindow = getDialogWindow;
	//private members
	var dialogWindow;
	var dialogInterval;
	var dialog = new Object;
	dialog.callback = null;
	//
	//implementation in ALPHABETICAL order
	//
	function isInternetExplorer()
	{
		return (window.ActiveXObject != null); 
	}
	function getDialogWindow()
	{
		return dialogWindow;
	}	
	function maintainFocus()
	{
	  try
	  {
		if (dialogWindow.closed)
		 {
			window.onfocus = null;
			window.focus();
			if (dialog.callback>"")
			{
				eval(dialog.callback);       
			}
			return;
		 }		
		 dialogWindow.focus(); 
	  }
	  catch (e) 
	  {
	  	alert("ModalDialog.maintainFocus:" + (dialog.callback>""?"callback="+dialog.callback+":":"") + e);
	  }
	} 
	 function removeWatch()
	 {
		dialog.callback = null;
	 }
	 function show(url,callbackOnClose)
	 {
		if (-1 == url.indexOf("?"))
		{
			url += "?";
		}
		else
		{
			url += "&";
		}
		if (callbackOnClose>"" && -1 == callbackOnClose.indexOf("("))
		{
			callbackOnClose += "()";
		}
		if (window.showModalDialog)
		{
			showModalDialog(url,"","dialogHeight:600px;dialogWidth:800px;");
			if (callbackOnClose>"")
			{
				eval(callbackOnClose);       
			}
		}
		else
		{
			removeWatch();
			dialog.callback = callbackOnClose;
			var x = windowLeft();
			var y = windowTop();
			var w = 800; 
			var h = 600;
			var features="location=no,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=yes,titlebar=no"
						+ ",left=" + x
						+ ",top=" + y
						+ ",width=" + w
						+ ",height=" + h;
			dialogWindow=window.open(url,"",features);
			window.onfocus = ModalDialog.maintainFocus;
			dialogWindow.focus();
		} 
	 }
	function windowHeight(dft)
	{
		if (document.body.clientHeight)
			return document.body.clientHeight;
		if (document.documentElement.clientHeight)
			return document.documentElement.clientHeight;
		if (document.body.offsetHeight)
			return document.body.offsetHeight;
		if (window.innerHeight)
			return window.innerHeight;
		return dft;
	}
	function windowLeft()
	{
		if (window.screenLeft)
			return window.screenLeft;
		if (window.screenX)
			return window.screenX + 20;
		return 0;
	}
	function windowTop()
	{
		if (window.screenTop)
			return window.screenTop;
		if (window.screenY)
			return window.screenY + 30;
		return 0;
	}
	function windowWidth(dft)
	{
		if (document.body.clientWidth)
			return document.body.clientWidth;
		if (document.documentElement.clientWidth)
			return document.documentElement.clientWidth;
		if (document.body.cffsetWidth)
			return document.body.offsetWidth;
		if (window.innerWidth)
			return window.innerWidth;
		return dft;
	}
}
