// ********************************************************************
// Copyright (C) 2001 Microsoft Corporation. All rights reserved.
//
//	IMPORTANT.  Please read the legal.txt file, located in the 
//	"<CMS Install Directory>\Server\httpexec\WBC\Internals" 
//	directory, governing the use of this internal file."
// ********************************************************************


/**
 *
 *	[Public] Retained for backwards compatibility with version 3.x
 *
 */ 
function WBC_launchTmplGallery( strURL )
{
	WBC_openWindowOnFocus(strURL, "NC_winChannelsBrowse", "width=640,height=480,scrollbars,resizable");
}	


/**
 *
 *	[Public] Event handler for "Preview a specific Page" link
 *
 *	@bFunctional [in] - whether the link should be functional. It will be false
 *				for the case of Previewing the WBC Authoring Mode UI.
 *
 *	@strURLPostingToPreview [in] - the URL of the Posting to be previewed. It
 *			may be different than the current navigation context Posting in
 *			the case that the Preview to be done is on a connected Posting.
 *
 */ 
function WBC_onAuthPreviewPostingWithURL( bFunctional, strURLPostingToPreview )
{
	if (bFunctional) 
	{
		var pFuncWin = WBC_getFuncWin( "WBC_previewAuthPostingWithURL", self );
		if (pFuncWin) 
		{
			pFuncWin.WBC_previewAuthPostingWithURL( strURLPostingToPreview );
		} 
		else 
		{
			alert( IDS_FUNCTION_NOT_FOUND );
		}
	}
}


/**
 *
 *	[Public] Retained for backward compatibility with version 3.x
 *				[new: WBC_onAuthPreviewPostingWithURL()]
 *
 *	@bFunctional [in] - whether the link should be functional. It will be false
 *				for the case of Previewing the WBC Authoring Mode UI.
 *
 */ 
function WBC_onAuthPreview( bFunctional )
{
	if ( bFunctional ) 
	{
		var pFuncWin = WBC_getFuncWin("WBC_previewAuthPosting", self);
		if ( pFuncWin ) 
		{
			pFuncWin.WBC_previewAuthPosting();
		}
		else 
		{
			alert( IDS_FUNCTION_NOT_FOUND );
		}
	}
}


/**
 *
 *	[Public] Event handler for "Save Page" link
 *
 *	@bFunctional [in] - whether the link should be functional. It will be false
 *				for the case of Previewing the WBC Authoring Mode UI.
 *
 *	@strSaveNewDlgURL [in] - the Save New Page dialog URL, in the case that the
 *				Posting being saved is a new Posting.
 *
 *	@strAction [in] - possible values ares: 
 *							{ IDS_ACTION_SAVE, IDS_ACTION_SAVEANDEXIT}
 *
 */ 
function WBC_onAuthSave( bFunctional, strSaveNewDlgURL, strAction )
{
	if ( bFunctional )
	{
		var pFuncWin;
		//	Turn off warning before leaving authoring form
		pFuncWin = WBC_getFuncWin("WBC_offWarningBeforeLeave", self);
		if (pFuncWin) 
		{
			pFuncWin.WBC_offWarningBeforeLeave();
		}				
		// non-empty strSaveNewDlgURL indicates the dialog URL to pop up
		// for saving this new Posting
		if (strSaveNewDlgURL != "") 
		{
			// pop up Save New Page dialog 
		 	WBC_openWindowOnFocus( strSaveNewDlgURL, IDS_WIN_NEWPAGESAVEDLG_NAME, IDS_WIN_NEWPAGESAVEDLG_FEATURES );
		}
		else 
		{
			// for exisitng Postings, invoke WBC_savePosting function in authoring form
			pFuncWin = WBC_getFuncWin("WBC_savePosting", self);
			if ( pFuncWin )
			{
				//	2nd parameter false mean not a new page
				pFuncWin.WBC_savePosting( strAction, false );
	
			}
			else 
			{
				alert( IDS_FUNCTION_NOT_FOUND );
			}
		}
	}
}


/**
 *
 *	[Public] Event handler for the "Cancel" or "Exit" link in WBC Authroing Mode
 *
 *	@bFunctional [in] - whether the link should be functional. It will be false
 *				for the case of Previewing the WBC Authoring Mode UI.
 *
 *	@strURLExitTo [in] - the URL to exit to.
 *
 */ 
function WBC_onAuthCancel( bFunctional, strURLExitTo ) 
{
	if ( bFunctional )
	{
		var pFuncWin;

		if (strURLExitTo != "")
		{
			window.top.location = strURLExitTo;
		}
	}
}

