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

<!-- remove when preferences API is in place -->
<SCRIPT LANGUAGE="JavaScript" SRC="../../Toolbars/siteSettings_TEMP.js"></SCRIPT>

<SCRIPT LANGUAGE="javascript">
<!--
//--------------- LOCALIZEABLE GLOBALS---------------

var HEADINGS = new Array("Normal"); // we will populate this at runtime

//--------------- END LOCALIZEABLE   ---------------

// Nonlocalizable globals.
var gHeadingTags = new Array("p", "h1", "h2", "h3", "h4", "h5", "h6");

function showIf(){
	var show = true;
	if (!getShowHeadings() && !getShowStyles()){ // replace with real API function!
		show = false;
	}else if (!getShowHeadings() && dw.cssStylePalette.getStyles().length == 0){
		show = false;
}
    if (CCWorkspaceManager.getManager(dw.getDocumentDOM()).IsCurrentPageXML()) return false;
		    
	return show;
}

function receiveArguments()
{
	var dom = dw.getDocumentDOM();
	var isBlogSite = CCWorkspaceManager.getManager(dw.getDocumentDOM()).isBlogSite(); 
	var styleName = arguments[0];
	
    if (styleName == HEADINGS[0]){
        if (!isBlogSite)
        	dom.removeCSSStyle();
		if (dom.getTextFormat() != '')
			dom.setTextFormat('p');
	}else if (styleName == HEADINGS[1]){
	    if (!isBlogSite)
	    	dom.removeCSSStyle();
		dom.setTextFormat('h1');
	}else if (styleName == HEADINGS[2]){
	    if(!isBlogSite)
		    dom.removeCSSStyle();
		dom.setTextFormat('h2');
	}else if (styleName == HEADINGS[3]){
	    if (!isBlogSite)
	        dom.removeCSSStyle();
		dom.setTextFormat('h3');
	}else if (styleName == HEADINGS[4]){
	    if (!isBlogSite)
		    dom.removeCSSStyle();
		dom.setTextFormat('h4');
	}else if (styleName == HEADINGS[5]){
	    if (!isBlogSite)
	        dom.removeCSSStyle();
		dom.setTextFormat('h5');
	}else if (styleName == HEADINGS[6]){
	    if (!isBlogSite)
	    	dom.removeCSSStyle();
		dom.setTextFormat('h6');
	}else if (styleName == "MM_RenameStyle"){
		dw.cssStylePalette.renameStyle();
	}else if (styleName == "MM_DeleteStyle"){
		dw.cssStylePalette.deleteStyle();
	}else if (styleName[0] == '-'){
		return; // don't do anything for the spacers
	}else{
		dom.applyCSSStyle('',styleName);
	}
}

function canAcceptCommand()
{
    if (dw.isPreviewMode())
        return false;
        
	var retVal = ((dw.getFocus() == 'document' && dw.getDocumentDOM().getFocus() == 'body') || dw.getFocus() == 'textView' || dw.getFocus() == 'html') && dw.getDocumentDOM() && dw.getDocumentDOM().getParseMode() == 'html' && (getShowHeadings() || getShowStyles());

	if (retVal)
	{
		var dom = dw.getDocumentDOM();
		if (dom) {

		    if (CCWorkspaceManager.getManager(dw.getDocumentDOM()).IsCurrentPageXML()) return false;
		    
			if (!isSelectionTextuallyModifiable(dom))
			{
				retVal = false;
			}
			
			// if the selection is an image, however, return true.
			var selection = dom.getSelection();
			if (selection && selection[0] != selection[1])
			{
				var node = dom.offsetsToNode(selection[0], selection[1]);
				if (node && node.tagName)
				{
					var tag = node.tagName;
					if (tag == 'IMG')
					{
						retVal = true;
					}
				}
			}
			if( dom.isHotSpotSelected() )
				retVal = false;	
		}
		else
		{
			retVal = false;
		}
	}

	return retVal;
}

function isCommandChecked(){
	return (getCurrentValue() == arguments[0]);		
}

// 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 getDynamicContent(itemID){
	var showHeadings = getShowHeadings(); // Call function or read property to determine pref setting
	var showStyles = getShowStyles(); // Call function or read property to determine pref setting
	var dwCSS = new Array();
	var cssStyles = null;

	if (showStyles){
		dwCSS = dw.cssStylePalette.getStyles();
	}

	if (showHeadings){
		// have to add the localized HEADINGS strings
		if(HEADINGS.length == 1)
		{
			HEADINGS.push(dw.loadString("heading/h1"));
			HEADINGS.push(dw.loadString("heading/h2"));
			HEADINGS.push(dw.loadString("heading/h3"));
			HEADINGS.push(dw.loadString("heading/h4"));
			HEADINGS.push(dw.loadString("heading/h5"));
			HEADINGS.push(dw.loadString("heading/h6"));
		}
		// Skip the "Normal" style--we'll do that below.
		for (var p=1; p < HEADINGS.length; p++){
		    if (dw.cssStylePalette.isHeadingStyleAllowed(HEADINGS[p]))
		        dwCSS.push(HEADINGS[p]);
		}
	}

	// Always add the "Normal" style at the top, even if HTML styles are off.
	// This is the standard way for users to clear out their CSS styles.
	dwCSS.unshift(HEADINGS[0]);

	if (dwCSS.length > 0){
		var i = 0;
		cssStyles = new Array();
		for (i=0; i<dwCSS.length; i++)
		{
			//filter out styles that begin with mmhide (lets designers hide some styles)
			if (dwCSS[i].toLowerCase().indexOf("mmhide") != 0) {
					cssStyles.push("" + dwCSS[i] + ";id='" + dwCSS[i] + "'"); // each item needs an ID
			}
		}
	}

	// Tack on the Manage Styles menu item
	cssStyles.push("------------------");
	cssStyles.push(new String(dw.loadString("style/rename") + ";id='MM_RenameStyle'"));
	cssStyles.push(new String(dw.loadString("style/delete") + ";id='MM_DeleteStyle'"));

	return cssStyles;
}

function getCurrentValue(){
	if (!dw.getDocumentDOM())
		return "";

	var textFormat = dw.getDocumentDOM().getTextFormat();
	if (textFormat == "*")
		return "";
	if (getShowStyles())
	{
		// If a style is specified, show it.
		var textStyle = dw.cssStylePalette.getSelectedStyle();
    //if style is * or style starts with mmhide, don't show it
		if (textStyle == "*" || textStyle.toLowerCase().indexOf("mmhide") == 0)
			return "";
		if (textStyle != "")
			return textStyle;
	}

 
	// If we didn't get a CSS style, show the HTML paragraph style.
	if (getShowHeadings())
	{
		// If we have a heading tag, return the menu id for that tag.
		var i;
		for (i = 0; i < gHeadingTags.length; i++)
		{
			if (textFormat == gHeadingTags[i])
			{
			    if (dw.cssStylePalette.isHeadingStyleAllowed(HEADINGS[i]))
			        return HEADINGS[i];
			    else
			        break;
			}
		}
	}

	// Show "Normal" by default.
	return HEADINGS[0];
}
// -->   
		</SCRIPT>
	</HEAD>
	<BODY>
	</BODY>
</HTML>
