<html xmlns:MMString="http://www.macromedia.com/schemes/data/string/">
<HEAD>
<!-- Copyright 1999, 2000, 2001, 2002, 2003 Macromedia, Inc. All rights reserved. -->
<TITLE><MMString:loadString id="Menus/MM/CC_Edit/title" /></TITLE>
<SCRIPT LANGUAGE="javascript" SRC="../../Shared/MM/Scripts/CMN/string.js"></SCRIPT>
<SCRIPT LANGUAGE="javascript">

<!--
//--------------- LOCALIZEABLE GLOBALS---------------
var LABEL_Page = dw.loadString('Menus/MM/CC_Edit/LABEL_Page');
var LABEL_Image = dw.loadString('Menus/MM/CC_Edit/LABEL_Image');
var LABEL_Draft = dw.loadString('Menus/MM/CC_Edit/LABEL_Draft');
var LABEL_Blog = dw.loadString('Menus/MM/CC_Edit/LABEL_Blog');
var LABEL_BlogPage = dw.loadString('Menus/MM/CC_Edit/LABEL_BlogPage');
//--------------- END LOCALIZEABLE   ---------------
// -->

//This command should show one of the two edit menu options, depending on
//the selection. Here's the spec:
// default follows canprocesscommand rules
// if an image is selected display the edit image label

function receiveArguments()
{
	switch (selectionType())
	{
	    case "page":
	        {
	            if (CCWorkspaceManager.getManager(dw.getDocumentDOM()).canProcessEvent('openDraft')) {
	                CCWorkspaceManager.getManager(dw.getDocumentDOM()).processEvent('openDraft');
	            }
	            else {
	                if (ccwf.isCCWF()) {
	                    ccwf.doEditMenuItem(); 
	                }
	                else {
	                    dw.doEditActionMenuItem(); 
	                }
	            }
	            break;
	        }
		case "image":
		{
			dw.editImage();
			break;
		}
	}
} //receiveArguments

//Look at the selection, and return a string reporting the type. Possible
//return values are:
// "image"
// "page"

function selectionType()
{
	//Removing special case for image, 
	//since it has been added as a separate menu
	
	/*var dom = dw.getDocumentDOM ("document");
	var offsets = dom.getSelection ();
	var theSelection = dw.offsetsToNode (offsets[0], offsets[1]);

	if (theSelection.nodeType == Node.ELEMENT_NODE && theSelection.tagName == 'IMG')
	{
		return "image";
	}*/

	return "page";

} //selectionType

function canAcceptCommand(itemID)
{
	if (selectionType() == "page")
		return ( dw.isEditActionMenuItemEnabled() && (!ccwf.isCCWF() || (ccwf.isCCWF() && ccwf.isEditEnabled()))  && !CCWorkspaceManager.getManager(dw.getDocumentDOM()).isImageURL());

	return true;

}

// getDynamicContent returns the contents of a dynamically generated menu.
// returns an array of strings to be placed in the menu, with a unique
// identifier for each item separated from the menu string by a semicolon.
//
// return null from this routine to indicate that you are not adding any
// items to the menu

function setMenuText(itemID)
{
	dom = dw.getDocumentDOM();
	var result = new Array();

	switch (selectionType())
	{
		case "page":
		{
			if ( CCWorkspaceManager.getManager(dw.getDocumentDOM()).canProcessEvent('editWIP') )
				return (LABEL_Draft);
			else if ( CCWorkspaceManager.getManager(dw.getDocumentDOM()).isBlogSite() )
			{
			    if('pages' == CCWorkspaceManager.getManager(dw.getDocumentDOM()).getCurBlogEntryType())
			        return LABEL_BlogPage;
			    else
				    return (LABEL_Blog);
			}
            else
                return (LABEL_Page);
		}

		case "image":
		{
			return (LABEL_Image);
		}

		default:
		{
			if ( CCWorkspaceManager.getManager(dw.getDocumentDOM()).isBlogSite() )
			{
			    if('pages' == CCWorkspaceManager.getManager(dw.getDocumentDOM()).getCurBlogEntryType())
			        return LABEL_BlogPage;
			    else
				    return (LABEL_Blog);
			}
			return (LABEL_Page);
		}
	}

	return result;

} //getDynamicContent

</SCRIPT>
</HEAD>
<BODY>
</BODY>
</HTML>
