function DialogInit ( Opener, OpenerID, Title, Url, WindowHeight, WindowWidth, Resizable, Properties, DialogType ) {
	var o = new Object;
	o.Title = Title;

	var queryStringPrefix;
	if (Url.indexOf("?")==-1)
		queryStringPrefix = "?";
	else
		queryStringPrefix = "&";
		
	var returnValue;
	switch (DialogType)
	{
		case "Modal":
			returnValue = window.showModalDialog(Url + queryStringPrefix + "__Properties=" + Properties, o, "dialogHeight:" + WindowHeight + "; dialogWidth:" + WindowWidth + "; status:off; center:on; help:off; resizable:" + Resizable + ";");
			break;
		case "Modeless":
			returnValue = window.showModelessDialog(Url + queryStringPrefix + "__Properties=" + Properties, o, "dialogHeight:" + WindowHeight + "; dialogWidth:" + WindowWidth + "; status:off; center:on; help:off; resizable:" + Resizable + ";");
			break;
		default:
			returnValue = window.showModalDialog(Url + queryStringPrefix + "__Properties=" + Properties, o, "dialogHeight:" + WindowHeight + "; dialogWidth:" + WindowWidth + "; status:off; center:on; help:off; resizable:" + Resizable + ";");
			break;
	}
	if (DialogType == "Modal")
	{
		try
		{
			if (returnValue != null)
			{
				document.getElementById("__OutputData").value = returnValue.OutputData;
				document.getElementById("__CausePostBack").value = returnValue.CausePostBack;
				document.getElementById("__OpenerID").value = OpenerID;

				if (Opener != null)
				{
					Opener.OutputData = returnValue.OutputData;
				}
				return (returnValue.CausePostBack == "True");
			}
			else
			{
				return false;
			}
		}
		catch (ex)
		{
			window.status = '(' +  ex.message + ')';
			return false;
		}
	}
	else
	{
		return false;
	}
}

function WireClientSideEvent(control, event, functionToAttach)
{
	var ctrl;
	if (typeof(control) != "undefined")
	{
		ctrl = control;
	}
	else
	{
		ctrl = document.getElementById(control);
	}

	if (typeof(ctrl) != "undefined")
	{
		if ( typeof( ctrl.addEventListener ) != "undefined" ) {
				ctrl.addEventListener(event, functionToAttach, false);
			} 
		else if ( typeof ( ctrl.attachEvent ) != "undefined" ) 
		{
			ctrl.attachEvent(event, functionToAttach);
		} 
		else 
		{
			ctrl[event] = functionToAttach;
		}
	}
}
