function openDialog(url, title, width, height, dlgArguments, modal, parentWnd)
{
	if(width==null)
		width = (screen.width-(screen.height*0.1)).toString() + "px";
	if(height==null)
		height = (screen.height-(screen.height*0.1)).toString() + "px";

	if(parentWnd==null)
		parentWnd = this;
	var style = "dialogHeight: "+height+"; dialogWidth: "+width+"; edge: Raised; center: Yes; help: No; resizable: Yes; status: No";
	var p = (typeof(__CMS_WEBAPP_PATH)=="undefined") ? "/MCMS/" : __CMS_WEBAPP_PATH;
		
	var url = p + "CMS/WAE/PostbackDlgHelper.aspx?DlgTitle="+title+" - IT Hit MCMS WAE&Url="+url;
	if(!modal)
		return parentWnd.showModelessDialog(url, dlgArguments, style);
	else
		return parentWnd.showModalDialog(url, dlgArguments, style);
}
function navigateWindow(url)
{
	if( (window.isFloating!=null) && (window.isFloating()==true) )
	{
		window.dialogArguments.frames("SelectFrameset").document.frames("Preview").navigate(url); // workspace
		return;
	}
	
	if(top.frames["SelectFrameset"]!=null)
		top.frames("SelectFrameset").document.frames("Preview").navigate(url); // workspace
	else
	{
		if(window.__CMS_PostbackForm!=null)
			window.location = url;
		else
			window.open(url);
	}
}
function onWSresult(funcCallBack)
{
	if(event.result.error)
	{
		alert("ERROR. Failed to process object.\n\n" + 
		"Error code: " + event.result.errorDetail.code + "\n\n" +
		event.result.errorDetail.string);
	}
	else
	{
		if(funcCallBack!=null)
			funcCallBack();
	}
}
function createConnectedPage(postingID, channelID)
{
	var height = screen.height-screen.height*0.15;
	var width = height*1.5;
	
	var url;
	if(channelID==null)
		url = IDS_FRAMEWORK_NEW_VIRTUAL_PATH+"/Dialogs/PageCreationWizard/ChannelsBrowse/ChannelsBrowse.aspx?NRMODE=Unpublished&NRNODEGUID={"+postingID+"}&ConnectedPage={"+postingID+"}"
	else
		url = IDS_FRAMEWORK_NEW_VIRTUAL_PATH+"/Dialogs/PageCreationWizard/TemplateBrowse/ConnectedTemplateBrowse.aspx?NRMODE=Unpublished&FRAMELESS=true&NRNODEGUID={"+postingID+"}&ConnectedPage={"+postingID+"}&DestinationChannel={"+channelID+"}&FreshTree=True";
		
	openDialog(url, "MCMS", width+"px", height+"px", navigateWindow, false);
}
