#macro (contentIcon $content)
    #if ($content.type == "page")
    #if ($content.homePage)<img src="$req.contextPath/images/icons/home_16.gif" height="16" width="16" border="0" align="absmiddle" title="$webwork.htmlEncode($content.title) (Space Home Page)"/>
    #elseif ($remoteUser && $content.isRecentlyUpdatedFor($remoteUser))<img src="$req.contextPath/images/icons/new_16.gif" height="16" width="16" border="0" align="absmiddle" title="$webwork.htmlEncode($content.title) (Updated)"/>
    #else<img src="$req.contextPath/images/icons/docs_16.gif" height="16" width="16" border="0" align="absmiddle" title="$webwork.htmlEncode($content.title)"/>
    #end
    #elseif ($content.type == "comment")<img src="$req.contextPath/images/icons/comment_16.gif" height="16" width="16" border="0" align="absmiddle"/>
    #elseif ($content.type == "spacedesc")<img src="$req.contextPath/images/icons/web_16.gif" height="16" width="16" border="0" align="absmiddle" title="$webwork.htmlEncode($content.space.name)"/>
    #elseif ($content.type == "userinfo")<img src="$req.contextPath/images/icons/user_16.gif" height="16" width="16" border="0" align="absmiddle" title="User Profile: $webwork.htmlEncode($action.getUserFullName($content.username))"/>
    #elseif ($content.type == "blogpost")<img src="$req.contextPath/images/icons/blogentry_16.gif" height="16" width="16" border="0" align="absmiddle" title="User Profile: $webwork.htmlEncode($action.getUserFullName($content.username))"/>
    #elseif ($content.type == "trackback")<img src="$req.contextPath/images/icons/document_exchange.gif" height="16" width="16" border="0" align="absmiddle" title="$content.title"/>
    #elseif ($content.type == "mail")<img src="$req.contextPath/images/icons/mail_content_16.gif" height="16" width="16" border="0" align="absmiddle" title="$content.title"/>
    #elseif ($content.type == "attachment")
    #set ($attachment = $content)
    #parse ("/pages/includes/attachment_icon.vm")
    #end
#end

#macro (contentIcon $content $linkColor $linkHref $linkTitle)
    #if($content.type == "page")
    #if($content.homePage)<a $linkColor href="$linkHref" title="$linkTitle"><img src="$req.contextPath/images/icons/home_16.gif" height="16" width="16" border="0" align="absmiddle" title="$webwork.htmlEncode($content.title) (Space Home Page)"/></a>
    #elseif($remoteUser && $content.isRecentlyUpdatedFor($remoteUser))<a $linkColor href="$linkHref" title="$linkTitle"><img src="$req.contextPath/images/icons/new_16.gif" height="16" width="16" border="0" align="absmiddle" title="$webwork.htmlEncode($content.title) (Updated)"/></a>
    #else<a $linkColor href="$linkHref" title="$linkTitle"><img src="$req.contextPath/images/icons/docs_16.gif" height="16" width="16" border="0" align="absmiddle" title="$webwork.htmlEncode($content.title)"/></a>
    #end
    #elseif($content.type == "comment")<a $linkColor href="$linkHref" title="$linkTitle"><img src="$req.contextPath/images/icons/comment_16.gif" height="16" width="16" border="0" align="absmiddle"/></a>
    #elseif($content.type == "spacedesc")<a $linkColor href="$linkHref" title="$linkTitle"><img src="$req.contextPath/images/icons/web_16.gif" height="16" width="16" border="0" align="absmiddle" title="$webwork.htmlEncode($content.space.name)"/></a>
    #elseif($content.type == "userinfo")<a $linkColor href="$linkHref" title="$linkTitle"><img src="$req.contextPath/images/icons/user_16.gif" height="16" width="16" border="0" align="absmiddle" title="User Profile: $webwork.htmlEncode($action.getUserFullName($content.username))"/></a>
    #elseif($content.type == "blogpost")<a $linkColor href="$linkHref" title="$linkTitle"><img src="$req.contextPath/images/icons/blogentry_16.gif" height="16" width="16" border="0" align="absmiddle" title="User Profile: $webwork.htmlEncode($action.getUserFullName($content.username))"/></a>
    #elseif($content.type == "trackback")<a $linkColor href="$linkHref" title="$linkTitle"><img src="$req.contextPath/images/icons/document_exchange.gif" height="16" width="16" border="0" align="absmiddle" title="$content.title"/></a>
    #elseif($content.type == "mail")<a $linkColor href="$linkHref" title="$linkTitle"><img src="$req.contextPath/images/icons/mail_content_16.gif" height="16" width="16" border="0" align="absmiddle" title="$content.title"/></a>
    #elseif($content.type == "attachment")
    #set ($attachment = $content)
    #parse ("/pages/includes/attachment_icon.vm")
    #end
#end

#macro (typeIcon $type)
    #if ($type == "page")
        <img src="$req.contextPath/images/icons/docs_16.gif" height="16" width="16" border="0" align="absmiddle" />
    #elseif ($type == "comment")
        <img src="$req.contextPath/images/icons/comment_16.gif" height="16" width="16" border="0" align="absmiddle"/>
    #elseif ($type == "spacedesc")
        <img src="$req.contextPath/images/icons/web_16.gif" height="16" width="16" border="0" align="absmiddle" />
    #elseif ($type == "userinfo")
        <img src="$req.contextPath/images/icons/user_16.gif" height="16" width="16" border="0" align="absmiddle" />
    #elseif ($type == "blogpost")
        <img src="$req.contextPath/images/icons/blogentry_16.gif" height="16" width="16" border="0" align="absmiddle" />
    #elseif ($type == "attachment")
        <img src="$req.contextPath/images/icons/attachments/file.gif" height="16" width="16" border="0" align="absmiddle" />
    #elseif ($type == "mail")
        <img src="$req.contextPath/images/icons/mail_content_16.gif" height="16" width="16" border="0" align="absmiddle" />
    #end
#end

#macro (contentHref $content)
    <a href="$req.contextPath$content.urlPath">$webwork.htmlEncode($content.realTitle)</a>
#end

#macro (contentOther $content)
    #if ($content.type == "page" || $content.type == "blogpost")
        #if ($content.originalVersion)
            <span class="smalltext">v. $content.version ($content.originalVersion.space.name)</span>
        #else
            <span class="smalltext">($content.space.name)</span>
        #end
    #elseif ($content.type == "comment")
        <span class="smalltext">($content.page.space.name)</span>
    #elseif ($content.type == "spacedesc")
        <span class="smalltext">(Space Description)</span>
    #elseif ($content.type == "userinfo")
        <span class="smalltext">($content.username)</span>
    #elseif ($content.type == "attachment")
        <span class="smallfont">(<a href="$req.contextPath$content.downloadPath">download</a>)
    #end
#end

#macro (contentLink2 $content $showIcon $showSpace)
    #if ($showIcon) #contentIcon($content) #end
    #contentHref($content)
    #if ($showSpace) #contentOther($content) #end
#end

#macro (contentLink $content)
    #contentLink2($content true true)
#end

#macro (contentLinkWithAnchor $content $anchor)
    #contentIcon($content)
    <a #if ($textUtil.stringSet($anchor)) name="$anchor" #end href="$req.contextPath$content.urlPath">$webwork.htmlEncode($content.realTitle)</a>
#end

#macro (pageHierarchy $contentNode $name)
    <tr valign="middle">
        <td valign="top" width="10px">
            <input type="checkbox" name="$name" value="$contentNode.getPage().getId()" checked="checked" />
        </td>
        <td>
            <label class="label">
                #contentLink2($contentNode.getPage() true false)
            </label>
            #if( $contentNode.getChildren().size() > 0 )
                <table width="100%" border="0">
                    #foreach( $childNode in $contentNode.getChildren() )
                        #pageHierarchy($childNode $name)
                    #end
                </table>
            #end
        </td>
    </tr>
#end

#*
PARAMETERS:
request		- the http request
title		- the text of the link
url 		- the URI to link to
selected	- the nav item will be selected if this link matches request.getServletPath().startsWith(selected)
tooltip		- an optional phrase to be used as the tooltip for the navitem link.
*#
#macro( navitem $title $url $selected $tooltip $accessKey)
    ## only hide the javascript if it is IE or Mozilla (not netscape or Opera) - Fixes JRA-1427
    #if ($webReqUtils.isGoodBrowser($req) && $textUtils.noNull($req.getHeader("USER-AGENT")).indexOf("Opera") == -1)
        #set ($captureJavascript = true)
    #end

    #if ($req.servletPath.startsWith($selected))
        ## css hack as described here:  http://www.fo3nix.pwp.blueyonder.co.uk/tutorials/css/hacks/
        ## only good browsers recognise that 'return false' isn't killing the <a> tag.  So don't 'return false' in netscape 4
	    <td nowrap onClick="window.document.location='$url'" align=center valign=middle class="navItemOver">&nbsp;&nbsp;
    #else
        <td nowrap onClick="window.document.location='$url'" align=center valign=middle class="navItem" onMouseOver="this.className='navItemOver'" onMouseOut="this.className='navItem'">&nbsp;&nbsp;
    #end
        <a href="$url"
        #if ($tooltip) title="$tooltip"#end
        #if ($accessKey) accessKey="$accessKey" #end
        #if ($captureJavascript) onClick="return false" #end
        >$title</a> &nbsp;&nbsp;</td>
#end

#* this can only be used with page titles that are safe to append to a URL *#
#* must check existance of page before $permissionCheckDispatcher, otherwise dispatcher will throw an IllegalStatementException *#
#macro (includePage $spaceKey $pageTitle)
    #if ($generalUtil.isAllAscii($pageTitle))
        #if ($renderBean.pageExists($spaceKey, $pageTitle))
            #if ($permissionCheckDispatcher.isPermitted("/pages/viewpage.action?spaceKey=$spaceKey&title=$pageTitle"))
                $renderBean.render($spaceKey, $pageTitle)
            #else
                <span class="error"><span class="errorMessage">You do not have sufficient privileges to include this page.</span></span>
            #end
        #else
            <span class="error"><span class="errorMessage">Page not found</span></span>
        #end
    #else
        <span class="error"><span class="errorMessage">The <em>includePage</em> macro can only be used with ASCII titles. For other titles use the <em>includePageWithId</em> macro.</em></span></span>
    #end
#end

#macro (includePageWithId $pageId)
    #if ($renderBean.pageExists($pageId))
        #if ($permissionCheckDispatcher.isPermitted("/pages/viewpage.action?pageId=$pageId"))
            $renderBean.render($pageId)
        #else
            <span class="error"><span class="errorMessage">You do not have sufficient privileges to include this page.</span></span>
        #end
    #else
        <span class="error"><span class="errorMessage">Page not found</span></span>
    #end
#end

#*
Link to a user's profile page, given their username. If the username doesn't exist, "Anonymous" is printed
*#
#macro (usernameLink $username)
#if ($username != "")
    #if ($action.getUserFullName($username))<a href="$!req.contextPath/display/~$generalUtil.doubleUrlEncode($username)">$action.getUserFullName($username)</a>#else<a href="$!req.contextPath/display/~$generalUtil.doubleUrlEncode($username)">$username</a>#end
#else Anonymous#end
#end

#macro (usernameLinkWithCustomBaseUrl $username $baseurl)
    #if ($username != "")
        #if ($action.getUserFullName($username))<a href="$baseurl/display/~$generalUtil.doubleUrlEncode($username)">$action.getUserFullName($username)</a>#else<a href="$baseurl/display/~$generalUtil.doubleUrlEncode($username)">$username</a>#end
    #else Anonymous#end
#end

#macro (usernameLinkParentWindow $username)
    #if ($username)
        <a href="javascript:window.opener.location='$!req.contextPath/display/~$generalUtil.doubleUrlEncode($username)'; window.close();">$action.getUserFullName($username)</a>
    #else
        Anonymous
    #end
#end

#macro (emailUserLink $user $baseurl)
    #if ($user)
        <a href="$baseurl/display/~$generalUtil.doubleUrlEncode($user.name)">$generalUtil.htmlEncode($user.fullName)</a>
    #else
        Anonymous
    #end
#end

#macro (userNonLink $user)
#if($user && $user.name) $action.getUserFullName($user.name)#else Anonymous #end
#end

#macro (siteTitle)$settingsManager.globalSettings.siteTitle#end

#*
Prints the search result pagination info.
*#
#macro(pagination $paginationSupport $actionContext)
    #set ($previousIndexes = $paginationSupport.previousStartIndexes)
    #set ($nextIndexes = $paginationSupport.nextStartIndexes)

    <div class="centered">
        #if( $paginationSupport.items.size() > 0 )
            #set ($startIndex = $paginationSupport.startIndex + 1)
            #set ($endIndex = $paginationSupport.endIndex)
        #end

        #if( $previousIndexes || $nextIndexes )
            #set ($currentIndex = 0)

            #if( $previousIndexes )
                <a href="${actionContext}startIndex=$paginationSupport.previousIndex">&lt;&lt; Previous</a>
                #foreach( $index in $previousIndexes )
                    #set ($currentIndex = $currentIndex + 1)
                    #if ($velocityCount > $generalUtil.arraySize($previousIndexes) - 10)
                    |
                    <a href="${actionContext}startIndex=$index">
                    $currentIndex</a>
                    #end
                #end
                |
            #end

            #set ($currentIndex = $currentIndex + 1)
            <b>$currentIndex</b>

            #if( $nextIndexes )
                #foreach( $index in $nextIndexes )
                    #set ($currentIndex = $currentIndex + 1)
                    #if ($velocityCount < 10)
                    |
                    <a href="${actionContext}startIndex=$index">
                    $currentIndex</a>
                    #end
                #end
                |
                <a href="${actionContext}startIndex=$paginationSupport.nextIndex">Next &gt;&gt;</a>
            #end
            <span class="smalltext">(total: <b>$paginationSupport.total</b>)</span>
        #end
    </div>
#end

#*
Prints the search box (if Confluence is setup)
*#
#macro(searchbox)
    #if ($bootstrap.isSetupComplete())
        <form method="GET" action="$req.contextPath/dosearchsite.action" name="searchForm"><input type="hidden" name="quickSearch" value="true" />
        <td align=right width=200 valign="bottom"><span class="tobBarDiv"><a href="$req.contextPath/searchsite.action">Search</a>:<input type="text" accessKey="s" name="searchQuery.queryString" size="10"/><input type="submit" value="Go"/><br/><img src="$req.contextPath/images/border/spacer.gif" height="1" width="200"/></span></td>
        </form>
    #end
#end

#*
    Prints the breadcrumbs
*#
#macro(breadcrumbs)
    #if ($sitemeshPage.getProperty("page.breadcrumbs"))
        $sitemeshPage.getProperty("page.breadcrumbs")
    #end
#end


#macro(usernavbar)
    #if ($bootstrap.isSetupComplete())

    <span class="smalltext">
        #if ($user)
            Welcome $generalUtil.htmlEncode($user.fullName) |

            #if ($userHistory)
                #set ($windowHeight = 100 + (25 * $userHistory.content.size()))
                <a href="$req.contextPath/users/viewuserhistory.action" onClick="window.open(this.href,'user_history', 'width=620, height=${windowHeight}, resizable'); return false;" title="View History">History</a> |
            #end

            <a href="$req.contextPath/display/~$generalUtil.doubleUrlEncode($user.name)">Profile</a> |

            #if ($generalUtil.isGlobalAdministrator($permissionManager, $user))
                <a href="$req.contextPath/admin/console.action">Administration</a> |
            #end

            <a href="$req.contextPath/logout.action" id="logout">Log Out</a>&nbsp;
        #else
            #*  for the login link, we want it to carry the current page the user is viewing anonymously, so that once they login they will be taken back
                to this page. However, we do not want to do this if they are on the logout/signup page/forgot password pages *#

            #set ($currentPage = $req.getAttribute('atlassian.core.seraph.original.url'))
            #if ($currentPage.indexOf('/logout.action') == -1 && $currentPage.indexOf('/login.action') == -1 && $currentPage.indexOf('/signup.action') == -1 && $currentPage.indexOf('forgotuserpassword.action') == -1 && $currentPage.indexOf('forgotusername.action') == -1)
                <a href="$req.contextPath/login.action?os_destination=$currentPage">Log In</a>
            #else
                <a href="$req.contextPath/login.action">Log In</a>
            #end

            #if (!$settingsManager.getGlobalSettings().isExternalUserManagement())
                #if (!$settingsManager.getGlobalSettings().isDenyPublicSignup())
                | <a href="$req.contextPath/signup.action">Sign Up</a>
                #end
                &nbsp;
            #end
        #end
    </span>
    #end
#end

#macro(helpicon)
    <a href="http://confluence.atlassian.com/display/DOC"><img src="$req.contextPath/images/icons/help_16.gif" width="16" height="16" hspace="1" vspace="1" align="absmiddle" border="0" alt="Get help from the Confluence website." title="Get help from the Confluence website."/></a>
#end

#macro(printableicon)
        <a href="$req.requestURI?#if ($textUtil.stringSet($req.queryString))${req.queryString}&#end
decorator=printable"><img src="$req.contextPath/images/icons/print_16.gif" width="16" height="16" hspace="1" vspace="1" align="absmiddle" border="0" alt="View a printable version of the current page." title="View a printable version of the current page."/></a>

    #if ($sitemeshPage && $sitemeshPage.req)
        <a href="$sitemeshPage.req.requestURI?#if ($textUtils.stringSet($sitemeshPage.req.queryString))${sitemeshPage.req.queryString}&#end
decorator=printable"><img src="$req.contextPath/images/icons/print_16.gif" width="16" height="16" hspace="1" vspace="1" align="absmiddle" border="0" alt="View a printable version of the current page." title="View a printable version of the current page."/></a>
    #end
#end

#macro(pdficon)
    #set ($pageId = $sitemeshPage.getProperty("page.pageId"))

    #if ($sitemeshPage && $req && $pageId && $permissionCheckDispatcher.isPermitted("/pages/doexportpage.action?pageId=$pageId&type=TYPE_PDF"))
        <a href="$req.contextPath/pages/doexportpage.action?pageId=$pageId&type=TYPE_PDF">
        <img src="$req.contextPath/images/icons/attachments/pdf.gif" height="16" width="16" border="0" align="absmiddle" title="Export Page as PDF"></a>
    #else
        <img src="$req.contextPath/images/border/spacer.gif" height="16" width="16" border="0" align="absmiddle">
    #end
#end

#macro(pagetitle $class)
    #if ($bootstrap.isSetupComplete() && $sitemeshPage.getProperty("page.spacename"))
        <div class="$class">#if ($sitemeshPage.getProperty("page.spacekey"))<a href="$req.contextPath/display/$sitemeshPage.getProperty("page.spacekey")">#end<img src="#logo($sitemeshPage.getProperty("page.spacekey"))" align="absmiddle" border="0">#if ($sitemeshPage.getProperty("page.spacekey"))</a>#end $sitemeshPage.getProperty("page.spacename")</div>
    #else
        <div class="$class"><a href="$req.contextPath/"><img src="$req.contextPath/images/confluence_logo.gif" border="0"></a> <a href="$req.contextPath/">CONFLUENCE</a></div>
    #end
#end

#macro(bottomshadow)
  	    #if ($generalUtil.isSetupComplete())
            #set ($license = $licenseManager.getLicense("CONF") )
            #if ($license && $license.licenseType.niceName != "Confluence: Commercial Server")
                #if ($license.licenseType.niceName == "Confluence: Evaluation")
                    <div class="license-eval">
                      <b>#if ($generalUtil.isLicenseExpired()) LICENSE EXPIRED #else EVALUATION LICENSE #end</b> - Are you enjoying Confluence? Please consider <a href="http://www.atlassian.com/c/conf/10139">purchasing it</a> today.
                    </div>
                #elseif ($license.licenseType.niceName == "Confluence: Non-Profit / Open Source")
                    <div class="license-nonprofit">
                    Site powered by a free <b>Open Source Project / Non-profit License</b> (<a href="http://www.atlassian.com/c/conf/10138">more</a>) of <b><a href="http://www.atlassian.com/c/conf/10137">Confluence - the Enterprise wiki</a>.<br/>
                    <a href="http://www.atlassian.com/c/conf/10137">Learn more</a> or <a href="http://www.atlassian.com/c/conf/10137">evaluate Confluence for your organisation</a>.
                    </div>
                #elseif ($license.licenseType.niceName == "Confluence: Personal Server")
                    <div class="license-personal">
                      This site is powered by a free <a href="http://www.atlassian.com/c/conf/10137">Atlassian Confluence Personal Server License</a>.
                      <a href="http://www.atlassian.com/c/conf/10137">Evaluate Confluence</a> for your organisation or read more about Confluence licensing <a href="http://www.atlassian.com/c/conf/10138">here</a>.<br>
                    </div>
                #end
            #elseif (!$license)
                <div class="license-none">
                   <b>LICENSING ERROR</b> - An error has occurred with your license that may impact the usability of this application, please <a href="mailto:confluence-support@atlassian.com">contact us</a>.
                </div>
            #end
        #end
        <div class="bottomshadow"></div>
#end

#macro(poweredby)
  	<div id="poweredby" class="smalltext">
		Powered by
		<a href="http://www.atlassian.com/software/confluence/default.jsp?clicked=footer" class="smalltext">Atlassian Confluence</a>, the
		<a href="http://www.atlassian.com/software/confluence/default.jsp?clicked=footer" class="smalltext">Enterprise Wiki</a>.

		(Version: $generalUtil.versionNumber Build:#${generalUtil.buildNumber}
		${generalUtil.buildDateString})
		-
		<a href="http://jira.atlassian.com/secure/BrowseProject.jspa?id=10470" class="smalltext">Bug/feature request</a>
		- 
		<a href="$req.contextPath/administrators.action">Contact Administrators</a>
		<br/>
	</div>
#end

#macro(dashboardlink)
    #if ($req.getRequestURI().indexOf("dashboard.action") != -1)
        $action.getText("dashboard.name")
    #else
        <a href="$req.contextPath/dashboard.action">$action.getText("dashboard.name")</a>
    #end
#end

#macro (colourRow $name $colour $isDefault)
    <tr>
        <td nowrap width="40%" align="right"><b>$action.getText($name)</b></td>
        <td width="30"><div style="background-color: $colour; width: 30; border: 1px solid black">&nbsp;</div></td>
        <td><span class="monospaceInput">#if($isDefault)&lt;default&gt;#else$colour#end</span></td>
    </tr>
#end

#macro (trackbackRdf $identifier $title $ping)
<!--
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
         xmlns:dc="http://purl.org/dc/elements/1.1/"
         xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
<rdf:Description
    rdf:about="$identifier"
    dc:identifier="$identifier"
    dc:title="$title"
    trackback:ping="$ping"/>
</rdf:RDF>
-->
#end

#macro (onoff $test)
    #if ($test) <font color="009900"><b>ON</b></font> #else <font color="990000"><b>OFF</b></font> #end
#end

#macro (yesno $test)
    #if ($test) <font color="009900"><b>YES</b></font> #else <font color="990000"><b>NO</b></font> #end
#end

#macro (fielderror $fieldname)
    #set ($fieldErrors = $action.fieldErrors)
    #if ($fieldErrors)
      #if ($fieldErrors.get($fieldname))
          #foreach ($error in $fieldErrors.get($fieldname))
          <div class="error"><span class="errorMessage">
            #set( $message = $action.getText(${error}) )
            #if( $message && $message != "" )
              $message
            #else
              $error
            #end
          </span></div>
          #end
      #end
    #end
#end

#macro (fielderrorRow $fieldname)
    #set ($fieldErrors = $stack.findValue("fieldErrors"))
    #if ($fieldErrors)
        #if ($fieldErrors.get($fieldname))
            #foreach ($error in $fieldErrors.get($fieldname))
                <tr>
                <td colspan="2" class="error"><span class="errorMessage">
                #set( $message = $stack.findValue("getText(${error})") )
                #if( $message && $message != "" )
                  $message
                #else
                  $error
                #end
                </span></td>
                </tr>
            #end
        #end
    #end
#end



#*
    Sets up variables which are used to determine whether or not the help panel
    should be displayed.
*#

#macro(infoPanelInit)
    #if ($sitemeshPage.getProperty("meta.help-path"))
      #set ($helpPath = $sitemeshPage.getProperty("meta.help-path"))
    #end

    #if ($sitemeshPage.getProperty("page.help-content"))
      #set ($helpContent = $sitemeshPage.getProperty("page.help-content"))
    #end

    ## decide whether or not to include the right nav bar
    #if ($helpPath || $helpContent)
      #set ($helpAvailable = true)
    #end

    #if ($sitemeshPage.getProperty("meta.infopanel-width"))
      #set ($panelWidth = $sitemeshPage.getProperty("meta.infopanel-width"))
    #end

    #set ($infoPanelRequired = $helpAvailable)
#end

#*
    Sets up variables which are used to determine whether or not the help panel
    should be displayed, using the parameter object passed by the inline decorator
    directive: applyDecorator
*#

#macro(infoPanelInitFromParams)
    #if ($params.get("help-path"))
      #set ($helpPath = $params.get("help-path"))
    #end

    #if ($params.get("help-content"))
      #set ($helpContent = $params.get("help-content"))
    #end

    ## decide whether or not to include the right nav bar
    #if ($helpPath || $helpContent)
      #set ($helpAvailable = true)
    #end

    #if ($params.get("infopanel-width"))
      #set ($panelWidth = $params.get("infopanel-width"))
    #end

    #set ($infoPanelRequired = $helpAvailable)
#end

#macro(standardHeader)
    ##infoPanelInit() we  now initialize the info panel in the content decorator

    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <META HTTP-EQUIV="Expires" CONTENT="-1">
    <script language="javascript">
      var contextPath = '$req.contextPath';
    </script>
    #if ($sitemeshPage.getProperty("page.spacekey"))
        <link rel="stylesheet" href="$req.contextPath/styles/main-action.css?spaceKey=$sitemeshPage.getProperty("page.spacekey")" type="text/css" />
    #else
        <link rel="stylesheet" href="$req.contextPath/styles/main-action.css" type="text/css" />
    #end
    #if (!$sitemeshPage.getProperty("page.allowindex"))
        <meta name="robots" content="noindex,nofollow">
        <meta name="robots" content="noarchive">
    #end
    <link rel="shortcut icon" href="$req.contextPath/images/icons/favicon.ico">
    <link rel="icon" type="image/png" href="$req.contextPath/images/icons/favicon.png">
    <script src="$req.contextPath/decorators/effects.js"></script>

    #if ($sitemeshPage.getProperty("page.headsection"))
        $sitemeshPage.getProperty("page.headsection")
    #end
#end

#macro(infoPanel $incomingLinks $trackbacks $referrers $externalReferences)
<div class="rightpanel">
  #if ($helpAvailable)
      <div id="helpheading">
        <img src="$req.contextPath/images/icons/help_16.gif" height=16 width=16 border=0 align=absmiddle height=16 width=16 title="Help Tips">
        Help Tips
      </div>
      <div id="helpcontent">
          #if ($helpContent)
              $sitemeshPage.getProperty("page.help-content")
          #else
              #parse ($helpPath)
          #end
      </div>
  #else
      #if ($hasPageOperations)
          #if ($sitemeshPage.getProperty("page.operations.title"))
              <div class="menuheading">$sitemeshPage.getProperty("page.operations.title")</div>
          #else
              <div class="menuheading">Operations</div>
          #end
          <div class="menuitems">
              $sitemeshPage.getProperty("page.operations")

              #if ($incomingLinks && $sitemeshPage.getProperty("page.incoming-links"))
                  $sitemeshPage.getProperty("page.incoming-links")
              #end

              #if ($trackbacks && $sitemeshPage.getProperty("page.trackbacks"))
                  $sitemeshPage.getProperty("page.trackbacks")
              #end

              #if ($referrers && $sitemeshPage.getProperty("page.referrers"))
                  $sitemeshPage.getProperty("page.referrers")
              #end

              #if ($externalReferences && $sitemeshPage.getProperty("page.external-references"))
                  $sitemeshPage.getProperty("page.external-references")
              #end
          </div>
      #end
  #end
</div>
#end

#macro(breadcrumbsAndSearch)
  <div width="100%" class="breadcrumbs">
      <table width=100% cellspacing=0 cellpadding=0 border=0><tr>
          <td>
          &nbsp;#breadcrumbs()
          </td>
          #searchbox()
      </tr></table>
  </div>
#end

#macro (nameList $names)
    #set($user = "")
    #foreach ($user in $names)
        #if ($velocityCount == $names.size())
            #usernameLink ($user)
        #else
            #usernameLink($user), 
        #end
        #set($user = "")
    #end
#end

#macro (blogPostsCalendar $cal)
    <table class="blogcalendar" border="0" cellspacing="0" cellpadding="2" summary="Monthly calendar with links to each day's news items">
           <tr>
               <th class="calendarhead">
                   <a href="$req.contextPath/display/$cal.spaceKey/$cal.previousMonth/">
                       <img src="$req.contextPath/images/icons/back_16.gif" height=16 width=16 border=0 align=absmiddle title="Previous Month">
                   </a>
               </th>
               <th class="calendarhead" colspan="5"><a class="calendarhead" href="$req.contextPath/display/$cal.spaceKey/$cal.currentMonth/">$cal.formatMonthYear()</a></th>
               <th class="calendarhead">
                   <a href="$req.contextPath/display/$cal.spaceKey/$cal.nextMonth/">
                       <img src="$req.contextPath/images/icons/forwd_16.gif" height=16 width=16 border=0 align=absmiddle title="Next Month">
                   </a>
               </th>
           </tr>
           <tr>
               <th abbr="Sunday" align="center">Sun</th>
               <th abbr="Monday" align="center">Mon</th>
               <th abbr="Tuesday" align="center">Tue</th>
               <th abbr="Wednesday" align="center">Wed</th>
               <th abbr="Thursday" align="center">Thu</th>
               <th abbr="Friday" align="center">Fri</th>
               <th abbr="Saturday" align="center">Sat</th>
           </tr>
        #foreach ( $week in [0..4] )
           <tr>
           #foreach ($day in [1..7] )
              <td align="center">
              #set ($date = $week * 7 + $day - $cal.startingDayOfMonth)
              #if ($date < 1 || $date > $cal.getDaysInMonth())
                  &nbsp;
              #elseif ($cal.getPostsForDay($date).size() == 0)
                  $date
              #else
                  #set ($thePost = $cal.getPostsForDay($date).get(0))
                  <a href="$req.contextPath/display/$thePost.space.key/$thePost.datePath/">$date</a>
              #end
              </td>
           #end
           </tr>
        #end
    </table>
#end

#* passes the url to the permissionDispatcher first. if user has permissions to see link, this macro will display it
 * $url: the url of the action. You must drop the contextPath off the url before passing it in here.
 * $linkTextKey: the i18n key for the name of the link
 *#
#macro (confluenceLink $url $linkTextKey)
    #if ($permissionCheckDispatcher.isPermitted($url))
        <a href="$req.contextPath/$url">$action.getText($linkTextKey)</a>
    #end
#end

#macro (confluenceLink2 $url $linkTextKey $prefix $suffix)
    #if ($permissionCheckDispatcher.isPermitted($url))
        $prefix <a href="$req.contextPath/$url">$action.getText($linkTextKey)</a> $suffix
    #end
#end

#macro (showPermissionsHeader)
        <tr>
            <th class="permissionHeading" width="25%">&nbsp;</th>
            <th class="permissionHeading">&nbsp;</th>
            <th colspan=4 class="permissionSuperTab">Pages</th>
            <th colspan=2 class="permissionSuperTab">News</th>
            <th colspan=2 class="permissionSuperTab">Comments</th>
            <th colspan=2 class="permissionSuperTab">Attachments</th>
            <th class="permissionSuperTab">Mail</th>
            <th colspan=2 class="permissionSuperTab">Space</th>
        </tr>
        <tr>
            <th class="permissionHeading">&nbsp;</th>
            <th width="40" class="permissionSuperTab">View</th>
            <th width="40" class="permissionTab">Create</th>
            <th width="40" class="permissionTab">Export</th>
            <th width="40" class="permissionTab">Restrict</th>
            <th width="40" class="permissionTab">Remove</th>
            <th width="40" class="permissionTab">Create</th>
            <th width="40" class="permissionTab">Remove</th>
            <th width="40" class="permissionTab">Create</th>
            <th width="40" class="permissionTab">Remove</th>
            <th width="40" class="permissionTab">Create</th>
            <th width="40" class="permissionTab">Remove</th>
            <th width="40" class="permissionTab">Remove</th>
            <th width="40" class="permissionTab">Export</th>
            <th width="40" class="permissionTab">Admin</th>
        </tr>
#end

#*
 * Macro for getting the URL of a resource from within a themed decorator
 *#

#macro (themeResource $resourcePath)$req.contextPath$sitemeshPage.getProperty("theme.resource.path")$resourcePath#end

#*
 * This macro is quite messy but is neater than simply copying and pasting the HTML three times on two different
 * screens to represent view and edit views of permissions for groups, users, and anonymous entities.
 *
 * Note - this macro renders form elements when in edit mode but you must wrap it in a form element yourself.
 *
 * $who: list containing the following symbols - "g" (group), "u" (user), "a" (anonymous), "e" (everyone).
 * Each symbol is a directive to print out symbolized information in the order in which the symbols are expressed.
 * Note - "e" is actually ["g", "u", "a"]
 *
 * $action: an object carry functionality to support calls for group, user, and anonymous permissions; for example
 * com.atlassian.confluence.security.actions.EditSpacePermissionsAction .
 *
 * $edit: string literal; if set to "true" it will output input boxes for each permission listing, otherwise it will
 * use a tick or cross image for read-only.
 *#

#macro (showPermissions $who $action $edit )

    #if ($who == ["e"])
        #set ($who = ["g", "u", "a"])
    #end

    #foreach( $entity in $who )
       <table border="0" cellpadding=2 cellspacing=0 width="100%">

    #*  -- outputting group permissions from $action -- *#
        #if ($entity == "g")

            #set ($groups = $action.activeGroups)
            #if ($groups.size() > 0)
                #showPermissionsHeader()

                #foreach ($group in $groups)
                    <tr style=" #if ($velocityCount % 2 == 0) background: #f0f0f0; #end">
                        <td>
                            <img src="$req.contextPath/images/icons/group_16.gif" width=16 height=16 border=0 align=absmiddle>
                            <b>$group.name</b>
                        </td>
                        <td align="center" class="permissionCell">
                        #if ($edit == "true")
                            <input type="checkbox" name="$action.buildGroupCheckboxName('viewspace', $group.name)" checked>
                        #else
                            #if ($action.hasGroupPermission($group.name, 'viewspace'))
                                <img src="$req.contextPath/images/icons/emoticons/check.gif" width=16 height=16 align=absmiddle border=0>
                            #else
                                <img src="$req.contextPath/images/icons/emoticons/error.gif" width=16 height=16 align=absmiddle border=0>
                            #end
                        #end
                        </td>
                        #foreach ($permission in ["editspace", "exportpage", "setpagepermissions", "removepage", "editblog", "removeblog", "comment", "removecomment", "createattachment", "removeattachment", "removemail", "exportspace", "setspacepermissions"])
                        <td align="center" class="permissionCell" valign="middle">
                            #if ($edit == "true")
                                #if ($action.hasGroupPermission($group.name, $permission))
                                    <input type="checkbox" name="$action.buildGroupCheckboxName($permission, $group.name)" checked>
                                #else
                                    <input type="checkbox" name="$action.buildGroupCheckboxName($permission, $group.name)">
                                #end
                            #else
                                #if ($action.hasGroupPermission($group.name, $permission))
                                    <img src="$req.contextPath/images/icons/emoticons/check.gif" width=16 height=16 align=absmiddle border=0>
                                #else
                                    <img src="$req.contextPath/images/icons/emoticons/error.gif" width=16 height=16 align=absmiddle border=0>
                                #end
                            #end
                        </td>
                        #end
                    </tr>
                #end
            #else
                <tr><td colspan=5>No groups currently have access rights to this space. </td></tr>
            #end
        #end
    #*  -- outputting user permissions from $action -- *#
        #if ($entity == "u")
            #set ($users = $action.activeUsers)
            #if ($users.size() > 0)
                #showPermissionsHeader()

                #foreach ($user in $users)
                    <tr style=" #if ($velocityCount % 2 == 0) background: #f0f0f0; #end">
                        <td>
                            <img src="$req.contextPath/images/icons/group_16.gif" width=16 height=16 border=0 align=absmiddle>
                            <b>$generalUtil.htmlEncode($user.fullName)</b>
                        </td>
                        <td align="center" class="permissionCell">

                            #if ($edit == "true")
                                <input type="checkbox" name="$action.buildUserCheckboxName('viewspace', $user.name)" checked>
                            #else
                                #if ($action.hasUserPermission($user, 'viewspace'))
                                    <img src="$req.contextPath/images/icons/emoticons/check.gif" width=16 height=16 align=absmiddle border=0>
                                #else
                                    <img src="$req.contextPath/images/icons/emoticons/error.gif" width=16 height=16 align=absmiddle border=0>
                                #end
                            #end
                        </td>
                            #foreach ($permission in ["editspace", "exportpage", "setpagepermissions", "removepage", "editblog", "removeblog", "comment", "removecomment", "createattachment", "removeattachment", "removemail", "exportspace", "setspacepermissions"])
                            <td align="center" class="permissionCell" valign="middle">
                                #if ($edit == "true")
                                    #if ($action.hasUserPermission($user, $permission))
                                        <input type="checkbox" name="$action.buildUserCheckboxName($permission, $user.name)" checked>
                                    #else
                                        <input type="checkbox" name="$action.buildUserCheckboxName($permission, $user.name)">
                                    #end
                                #else
                                    #if ($action.hasUserPermission($user, $permission))
                                        <img src="$req.contextPath/images/icons/emoticons/check.gif" width=16 height=16 align=absmiddle border=0>
                                    #else
                                        <img src="$req.contextPath/images/icons/emoticons/error.gif" width=16 height=16 align=absmiddle border=0>
                                    #end
                                #end
                            </td>
                        #end
                    </tr>
                #end

            #else
                <tr><td colspan=5>No users currently have access rights to this space.</td></tr>
            #end
        #end

    #*  -- outputting anonymous permissions from $action -- *#
        #if ($entity == "a")
            #showPermissionsHeader()

            <tr>
                <td>
                    <img src="$req.contextPath/images/icons/group_anyone_16.gif" width=16 height=16 border=0 align=absmiddle>
                    <b>Anonymous</b>
                </td>
                <td align="center" class="permissionCell">
                    #if ($edit == "true")
                        #if ($action.hasAnonymousPermission('viewspace'))
                            <input type="checkbox" name="$action.buildAnonymousCheckboxName('viewspace')" checked>
                        #else
                            <input type="checkbox" name="$action.buildAnonymousCheckboxName('viewspace')">
                        #end
                    #else
                        #if ($action.hasAnonymousPermission('viewspace'))
                            <img src="$req.contextPath/images/icons/emoticons/check.gif" width=16 height=16 align=absmiddle border=0>
                        #else
                            <img src="$req.contextPath/images/icons/emoticons/error.gif" width=16 height=16 align=absmiddle border=0>
                        #end
                    #end
                </td>

                #foreach ($permission in ["editspace", "exportpage", "setpagepermissions", "removepage", "editblog", "removeblog", "comment", "removecomment", "createattachment", "removeattachment", "removemail", "exportspace", "setspacepermissions"])
                <td align="center" class="permissionCell">
                    #if ($edit == "true")
                        #if ($action.hasAnonymousPermission($permission))
                            <input type="checkbox" name="$action.buildAnonymousCheckboxName($permission)" checked>
                        #else
                            <input type="checkbox" name="$action.buildAnonymousCheckboxName($permission)">
                        #end
                    #else
                        #if ($action.hasAnonymousPermission($permission))
                            <img src="$req.contextPath/images/icons/emoticons/check.gif" width=16 height=16 align=absmiddle border=0>
                        #else
                            <img src="$req.contextPath/images/icons/emoticons/error.gif" width=16 height=16 align=absmiddle border=0>
                        #end
                    #end
                </td>
            #end
            </tr>
        #end
        </table>
    #end
#end

#macro (user_picker $formName)
<script language="javascript">
    function openUserPickerWindow(formName, element)
    {
        var vWinUsers = window.open('$req.contextPath/spaces/openuserpicker.action?key=$!key&formName=' + formName + '&elementName=' + element + '&multiSelect=true&startIndex=0&usersPerPage=10', 'UserPicker2', 'status=yes,resizable=yes,top=100,left=200,width=580,height=550,scrollbars=yes');
        vWinUsers.opener = self;
        vWinUsers.focus();
    }
</script>

<br/>
<table width = "100%">
      #if ($action.fieldErrors.get("usersToAdd"))
          #foreach ($error in $action.fieldErrors.get("usersToAdd"))
          <tr>
          <td align="left" class="error">
            #set( $message = $action.getText(${error}) )
            #if( $message && $message != "" )
              $message
            #else
              $error
            #end
          </td></tr>
          #end
      #end

    <tr>
        <td align="left">
            Users to add:
            <input type="text" name="usersToAdd" size="40"> <a href="#" onClick="openUserPickerWindow('$formName', 'usersToAdd'); return false;"><img src="$req.contextPath/images/icons/srch_16.gif" height=16 width=16 border=0 align=absmiddle title="Select Users"></a>
            <input type="submit" value="Add">
        </td>
    </tr>
<table>
<br/>
#end

## use this function in tr's to alternate the row colors when displaying a list of items.
#macro (alternateRowColors)
    #if ($velocityCount % 2 == 0)
        class="rowAlternate"
    #end
#end






#macro (spaceTitleLink)
    #if ($sitemeshPage.getProperty("page.spacename"))
        $sitemeshPage.getProperty("page.spacename")
    #else
        &nbsp;
    #end
#end

#macro (pageTitleLink)
    #if ($sitemeshPage.getProperty("page.pageTitle"))
        $sitemeshPage.getProperty("page.pageTitle")
    #else
        $title
    #end
#end

#macro (quickSearch)
    <form method="POST" action="$req.contextPath/dosearchsite.action" name="searchForm" style="padding: 1px; margin: 1px">
        <input type="hidden" name="quickSearch" value="true" />

        #if ($sitemeshPage.getProperty("page.spacekey"))
        <input type="hidden" name="spaceSearch" value="true" />
        <input type="hidden" name="searchQuery.spaceKey" value="$sitemeshPage.getProperty('page.spacekey')" />
        #end

        <input type="text" accessKey="s" name="searchQuery.queryString" size="10"/>
        <input type="submit" value="Search"/>
    </form>
#end


#macro (watchLink )

    #set ($action = $helper.action)

    #if(!$action.anonymousUser && !$action.isPrintableVersion() && $actionErrors.size() == 0)
        #if(!$action.userWatchingSpace)
            #if($action.userWatchingPage)
              #if( $permissionCheckDispatcher.isPermitted("/pages/removepagenotification.action?pageId=$helper.page.id") )
                    <a href="$req.contextPath/pages/removepagenotification.action?pageId=$helper.page.id"><img border="0" src="$req.contextPath/images/icons/watch_cancel_16.gif" align="absmiddle"></a>
                    <a href="$req.contextPath/pages/removepagenotification.action?pageId=$helper.page.id">Stop Watching</a>
              #end
            #else
                #if( $permissionCheckDispatcher.isPermitted("/pages/addpagenotification.action?pageId=$helper.page.id") )
                    <a href="$req.contextPath/pages/addpagenotification.action?pageId=$helper.page.id"><img border="0" src="$req.contextPath/images/icons/watch_16.gif" align="absmiddle"></a>
                    <a href="$req.contextPath/pages/addpagenotification.action?pageId=$helper.page.id" title="Watch this page to be notified of changes.">Watch</a>
                #end
            #end
        #else
                    <a href="$req.contextPath/spaces/viewspacecontent.action?key=$helper.spaceKey"><img border="0" src="$req.contextPath/images/icons/add_space_notification_16.gif" align="absmiddle"></a>
                    <a href="$req.contextPath/spaces/viewspacecontent.action?key=$helper.spaceKey" title="You are currently watching the $!page.space.name space">Watching Space</a>
        #end
    #end
#end



#*
    Renders an edit link with image, for a blog.
*#
#macro (editBlogPostWithImageLink )

    #set ($page = $helper.page)

   #if ($permissionCheckDispatcher.isPermitted("/pages/editblogpost.action?pageId=$page.id"))
       <a href="$req.contextPath/pages/editblogpost.action?pageId=$page.id"><img border="0" src="$req.contextPath/images/icons/edit_16.gif" align="absmiddle"></a>
       <a href="$req.contextPath/pages/editblogpost.action?pageId=$page.id">Edit</a>
   #end
#end


#macro (renderChildren )

    #set ($page = $helper.page)
    #if (!$page.originalVersion && $helper.childrenShowing)
        #if ($helper.action.getPermittedChildren().size() > 0)
            <div class="tabletitle">
                <a name="children">Children</a>

                <span class="bodytext">
                &nbsp;
                <a href="$req.contextPath$generalUtil.customGetPageUrl($page)showChildren=false">Hide Children</a>
                | <a href="$req.contextPath/pages/listpages-dirview.action?key=$page.space.key&openId=$page.id#selectedPageInHierarchy">View in hierarchy</a>
                #if( $permissionCheckDispatcher.isPermitted("/pages/createpage.action?spaceKey=$space.key") )
                    #if ($page.type == "page")
                        |
                        <a href="$req.contextPath/pages/createpage.action?spaceKey=$space.key&fromPageId=$page.id"><img src="$req.contextPath/images/icons/add_page_child_16.gif" height=16 width=16 border=0 align=absmiddle title="$helper.getText("action.add.page.child")"></a>
                        <a href="$req.contextPath/pages/createpage.action?spaceKey=$space.key&fromPageId=$page.id">$helper.getText("action.add.page.child")</a>
                    #end
                #end
                </span>
            </div>
            <div class="greybox" align="left">
                #foreach ($child in $helper.action.getPermittedChildren())
                    #contentLink ($child) <br/>
                #end
            </div>
        #end
    #else
        #if ($helper.action.getPermittedChildren().size() > 0)
        <div class="greybox">
            <img src="$req.contextPath/images/icons/page_hierarchy_16.gif" height="16" width="16" border="0" align="absmiddle">
            <a href="$req.contextPath$generalUtil.customGetPageUrl($page)showChildren=true&#0035;children">$helper.action.getPermittedChildren().size() children</a>
            | <a href="$req.contextPath/pages/listpages-dirview.action?key=$page.space.key&openId=$page.id#selectedPageInHierarchy">View in hierarchy</a>
        </div>
        #end
    #end
#end

#macro (renderComments)
    #applyDecorator("root")
        #decoratorParam("sitemeshPage" $sitemeshPage)
        #decoratorParam("page" $page)
        #decoratorParam("context" "sharedcomments")
    #end
#end


#macro (onLoad)
    #if (!$textUtil.stringSet($sitemeshPage.getProperty("page.bodyOnLoad")))
        <body onload="placeFocus()">
    #else
        <body onload="$sitemeshPage.getProperty('page.bodyOnLoad')">
    #end
#end

#macro (versionInfo)
<p style="clear: both">
<div class="noteMacro"><div class="padded">
    <img src="$req.contextPath/images/icons/emoticons/warning.gif" align="absmiddle" height=16 width=16> <b>You are viewing an old version (v. $page.version) of this page.</b><br>
    <div class="smallfont">
    The latest version is <b><a href="$req.contextPath$generalUtil.getPageUrl($page.originalVersion)">v. $page.originalVersion.version</a></b>, last edited on $generalUtil.format(${page.originalVersion.lastModificationDate})
    (<a href="$req.contextPath/pages/diffpagesbyversion.action?pageId=$page.originalVersion.id&originalVersion=$page.version&revisedVersion=$page.originalVersion.version">view differences</a>
    |
    #if ($permissionCheckDispatcher.isPermitted("/pages/revertpagebacktoversion.action?pageId=$page.originalVersion.id&version=${page.version}"))
    <a href="revertpagebacktoversion.action?pageId=$page.originalVersion.id&version=${page.version}">restore this version</a> |
    #end
    <a href="$req.contextPath/pages/viewpreviouspageversions.action?pageId=$page.originalVersion.id">view page history</a>).<br>
    #if ($action.hasPreviousVersion($page))
        <a href="$req.contextPath/pages/viewpage.action?pageId=$action.getPageIdOfVersionBefore($page)">&lt;&lt; View previous version</a> |
    #end
    #if ($action.hasNextVersion($page))
        <a href="$req.contextPath/pages/viewpage.action?pageId=$action.getPageIdOfVersionAfter($page)">View next version &gt;&gt;</a>
    #else
        No next version
    #end
    </div>
</div></div>
</p>
#end

#macro (editReport)
    Added by #usernameLink ($page.creatorName), #if ($page.isLatestVersion() == true)last#end edited by #usernameLink ($page.lastModifierName) on $generalUtil.format( $page.lastModificationDate )
#end


#macro (mailOperations $helper)

    <div class="menuheading">
        Mail Operations
    </div>
    <div class="menuitems">
        <div class="operations">
            #if ($helper.action.inThread || $helper.action.nextMail || $helper.action.previousMail)
                <ul style="list-style: none;">
                    #if ($helper.action.inThread)
                        <li>
                            <a href="$req.contextPath/spaces/viewthread.action?key=$helper.action.key&id=$helper.action.mail.id" title="$helper.getText("view.mail.thread.title")"><img src="$req.contextPath/images/icons/mail_thread_16.gif" border="0" height=16 width=16 alt="" align="absmiddle"></a>
                            <a href="$req.contextPath/spaces/viewthread.action?key=$helper.action.key&id=$helper.action.mail.id" title="$helper.getText("view.mail.thread.title")"><span class="label">$helper.getText("view.mail.thread.desc")</span></a>
                        </li>
                    #end

                    #if( $helper.action.nextMail && $permissionCheckDispatcher.isPermitted("/spaces/viewmail.action?key=$helper.action.nextMail.space.key&id=$helper.action.nextMail.id"))
                        <li>
                            <a href="${req.contextPath}$helper.action.nextMail.urlPath"><img src="$req.contextPath/images/icons/forwd_16.gif" height=16 width=16 border=0 align=absmiddle title="$generalUtil.escapeXml($helper.action.nextMail.title)"></a><span class="label">
                            <a href="${req.contextPath}$helper.action.nextMail.urlPath" title="$generalUtil.escapeXml($helper.action.nextMail.title)">$helper.getText("next.mail")</a></span>
                        </li>
                    #end

                    #if( $helper.action.previousMail && $permissionCheckDispatcher.isPermitted("/spaces/viewmail.action?key=$helper.action.previousMail.space.key&id=$helper.action.previousMail.id"))
                        <li>
                            <a href="${req.contextPath}$helper.action.previousMail.urlPath"><img src="$req.contextPath/images/icons/back_16.gif" height=16 width=16 border=0 align=absmiddle title="$generalUtil.escapeXml($helper.action.previousMail.title)"></a><span class="label">
                            <a href="${req.contextPath}$helper.action.previousMail.urlPath" title="$generalUtil.escapeXml($helper.action.previousMail.title)">$helper.getText("previous.mail")</a></span>
                        </li>
                    #end
                </ul>
            #end

            <ul style="list-style: none;">
                #if( $mail && $permissionCheckDispatcher.isPermitted("/spaces/removemail.action?key=$mail.space.key&id=$mail.id") )
                    <li>
                        <a href="$req.contextPath/spaces/removemail.action?key=$mail.space.key&id=$mail.id"><img src="$req.contextPath/images/icons/trash_16.gif" height=16 width=16 border=0 align=absmiddle title="${stack.findValue('getText("remove.mail.name")')}"></a><span class="label">
                        <a href="$req.contextPath/spaces/removemail.action?key=$mail.space.key&id=$mail.id">$helper.getText("remove.mail.name")</a></span>
                    </li>
                #end

                #if( $permissionCheckDispatcher.isPermitted("/spaces/viewmailarchive.action?key=$mail.space.key") )
                    <li>
                    #if ($mail)
                        <a href="$req.contextPath/spaces/viewmailarchive.action?key=$mail.space.key"><img src="$req.contextPath/images/icons/list_mail_content_16.gif" width="16" height="16" border="0" align="absmiddle" title="$helper.getText("mail.archive.name")"></a><span class="label">
                        <a href="$req.contextPath/spaces/viewmailarchive.action?key=$mail.space.key">$helper.getText("mail.archive.name")</a></span>
                    #else
                        <a href="$req.contextPath/spaces/viewmailarchive.action?key=$helper.action.key"><img src="$req.contextPath/images/icons/list_mail_content_16.gif" width="16" height="16" border="0" align="absmiddle" title="$helper.getText("mail.archive.name")"></a><span class="label">
                        <a href="$req.contextPath/spaces/viewmailarchive.action?key=$helper.action.key">$helper.getText("mail.archive.name")</a></span>
                    #end
                    </li>
                #end
            </ul>

        </div>
    </div>
#end


#* ----------------------------------------------- LOGO MACROS ----------------------------------------------- *#
#macro (globalLogo)
#if($resourceManager.getResource("logo", null))$req.contextPath/download/userResources/logo#else$req.contextPath/images/confluence_logo.gif#end
#end

#macro (logo $spaceKey)
#if(!$spaceKey)#globalLogo()#else#if($resourceManager.getResourceWithSpaceKey("logo", $spaceKey))$req.contextPath/download/userResources/$spaceKey/logo#else#globalLogo()#end#end
#end


#* ----------------------------------------------- SIMPLE LINK MACROS -----------------------------------------------
 Store macros which render a one line link here.
*#

#macro (tinyLink )
    <a href="$helper.domainName/x/$helper.tinyUrl">$helper.domainName/x/$helper.tinyUrl</a>
#end

#*
    Renders a link and image for removing the current page.
*#
#macro (removePageLinkAndImage )
    <img src="${req.contextPath}/images/icons/del_page_16.gif" width="16" height="16" align="absmiddle"> <a href="$req.contextPath/pages/removepage.action?pageId=$helper.page.id">Remove</a>
#end

#*
    Renders a link for removing the current page.
*#
#macro (removePageLink)
    <a href="$req.contextPath/pages/removepage.action?pageId=$helper.page.id">Remove</a>
#end

#*
    Renders a link and image for removing the current blogpost.
*#
#macro (removeBlogPostLinkAndImage )
    <img src="${req.contextPath}/images/icons/del_blogentry_16.gif" width="16" height="16" align="absmiddle"> <a href="$req.contextPath/pages/removeblogpost.action?pageId=$helper.page.id">Remove</a>
#end

#*
    Renders a link for removing the current blogpost.
*#
#macro (removeBlogPostLink )
    <a href="$req.contextPath/pages/removeblogpost.action?pageId=$helper.page.id">Remove</a>
#end

#macro (browseSpaceLinkAndImage)
    #set ($spaceKey = $helper.page.space.key)

    #if ($permissionCheckDispatcher.isPermitted("/pages/listpages.action?key=$spaceKey"))
        <a href="$req.contextPath/pages/listpages.action?key=$spaceKey"><img src="$req.contextPath/images/icons/browse_space.gif" height="16" width="16" border="0" align="absmiddle" title="Find Content"></a>
        <a href="$req.contextPath/spaces/browsespace.action?key=$spaceKey">Browse Space</a>
    #end
#end

#macro (browseSpaceLink)
    #set ($spaceKey = $helper.page.space.key)

    #if ($permissionCheckDispatcher.isPermitted("/pages/listpages.action?key=$spaceKey"))
        <a href="$req.contextPath/spaces/browsespace.action?key=$spaceKey">Browse Space</a>
    #end
#end

#macro (addPageLinkAndImage)
    #set ($spaceKey = $pagehelper.page.space.key)

    #if ($permissionCheckDispatcher.isPermitted("/pages/createpage.action?spaceKey=$spaceKey"))
        ## if user currently viewing a page, add page automatically creates a new page with that page is the parent
        #if ($helper.page.id && !$helper.page.postingDay)
            <a href="$req.contextPath/pages/createpage.action?spaceKey=$spaceKey&fromPageId=$helper.page.id"><img src="$req.contextPath/images/icons/add_page_16.gif" height=16 width=16 border=0 align=absmiddle title="Add Page"></a>
            <a href="$req.contextPath/pages/createpage.action?spaceKey=$spaceKey&fromPageId=$helper.page.id">Add Page</a>
        #else
            <a href="$req.contextPath/pages/createpage.action?spaceKey=$spaceKey"><img src="$req.contextPath/images/icons/add_page_16.gif" height=16 width=16 border=0 align=absmiddle title="Add Page"></a>
            <a href="$req.contextPath/pages/createpage.action?spaceKey=$spaceKey">Add Page</a>
        #end
    #end
#end

#macro (addPageLink)
    #set ($spaceKey = $pagehelper.page.space.key)

    #if ($permissionCheckDispatcher.isPermitted("/pages/createpage.action?spaceKey=$spaceKey"))
        ## if user currently viewing a page, add page automatically creates a new page with that page is the parent
        #if ($helper.page.pageId && !$helper.page.postingDay)
            <a href="$req.contextPath/pages/createpage.action?spaceKey=$spaceKey&fromPageId=$helper.page.id">Add Page</a>
        #else
            <a href="$req.contextPath/pages/createpage.action?spaceKey=$spaceKey">Add Page</a>
        #end
    #end
#end


#macro (addNewsLinkAndImage)
    #set ($spaceKey = $pagehelper.page.space.key)

    #if ($permissionCheckDispatcher.isPermitted("/pages/createblogpost.action?spaceKey=$spaceKey"))
        #if ($helper.page.id)
          #set ($fromPageParam = "&fromPageId=$helper.page.id")
        #else
          #set ($fromPageParam = "")
        #end
        <a href="$req.contextPath/pages/createblogpost.action?spaceKey=$spaceKey$fromPageParam"><img src="$req.contextPath/images/icons/add_blogentry_16.gif" height=16 width=16 border=0 align=absmiddle title="Add News"></a>
        <a href="$req.contextPath/pages/createblogpost.action?spaceKey=$spaceKey$fromPageParam">Add News</a>
    #end
#end

#macro (addNewsLink)
    #set ($spaceKey = $pagehelper.page.space.key)

    #if ($permissionCheckDispatcher.isPermitted("/pages/createblogpost.action?spaceKey=$spaceKey"))
        #if ($helper.page.id)
          #set ($fromPageParam = "&fromPageId=$helper.page.id")
        #else
          #set ($fromPageParam = "")
        #end
        <a href="$req.contextPath/pages/createblogpost.action?spaceKey=$spaceKey$fromPageParam">Add News</a>
    #end
#end


#macro (viewPageLink )
    #if ($helper.page.id)
        #if ( $permissionCheckDispatcher.isPermitted("/pages/viewpage.action?pageId=$pageId") )
            <a href="$req.contextPath/pages/viewpage.action?pageId=$pageId" #if ($tool == "view") id="current" #end>View</a>
        #end
    #end
#end

#macro (attachmentsLink)
    #if ( $permissionCheckDispatcher.isPermitted("/pages/viewattachments.action?pageId=$pageId") )
        <a href="$req.contextPath/pages/viewattachments.action?pageId=$pageId" #if ($tool == "attachments") id="current" #end>Attachments ($!helper.numberOfAttachments)</a>
    #end
#end

#macro (recentlyUpdatedListLink)
    <a href="$req.contextPath/pages/recentlyupdated.action?key=$key">Recently Updated</a>
#end

#macro (alphabeticalListLink)
    <a href="$req.contextPath/pages/listpages-alphaview.action?key=$key">Alphabetical View</a>
#end

#macro (contentTreeLink)
    <a href="$req.contextPath/pages/listpages-dirview.action?key=$key">Tree View</a>
#end

#macro (generalSpaceList)
    #bodytag (Component "template='general-spacelist.vm'")
        #param ("spaces" "availableSpaces")
        #param ("showOperations" "true")
        #param ("addSpaceButton" "true")
    #end
#end

    #macro (pluginStylesheet $pluginCompleteKey $stylesheetName)
            <link rel="stylesheet" href="$req.contextPath/styles/main-action.css?pluginCompleteKey=$generalUtil.urlEncode($pluginCompleteKey)&stylesheetName=$generalUtil.urlEncode($stylesheetName)" type="text/css" />
    #end

##
## As above, but do not show the operations or add space action buttons.
##
#macro (generalSpaceListWithoutActions)
    #bodytag (Component "template='general-spacelist.vm'")
        #param ("spaces" "availableSpaces")
    #end
#end

#macro (node $p $idsToExpandAsList $openId)
    #if ($action.hasPermittedChildren($p))
        <a href="#if($idsToExpandAsList.contains($p.id))$action.generateCollapseNodeLinkForNonJSUsers($p)#else $!action.generateExpandNodeLinkForNonJSUsers($p)#end" onClick="toggleChildren('$p.id'); return false;">
        #if($idsToExpandAsList.contains($p.id))
            <img border="0" onClick="togglePlusMinus(this)" src="$req.contextPath/images/icons/tree_minus.gif"></a>
        #else
            <img border="0" onClick="togglePlusMinus(this)" src="$req.contextPath/images/icons/tree_plus.gif"></a>
        #end
    #else
        <img border="0" src="$req.contextPath/images/icons/tree_square.gif">
    #end
    #if ($p.id == $openId)
        <span class="openPageHighlight">#contentLinkWithAnchor($p 'selectedPageInHierarchy')</span>
    #else
        #contentLink2 ($p true false)
    #end
    <div id="children$p.id" style="border: 1px solid white">
        #if ($idsToExpandAsList.contains($p.id))
            <ul style="list-style-type: none">
            #foreach ($child in $action.getPermittedChildren($p))
                <li>#node($child $idsToExpandAsList $openId)</li>
            #end
            </ul>
        #end
    </div>
#end

#macro (permitSearchEngines)
    <content tag="allowindex">true</content>
#end

#macro (commaDelimitedList $list)
#foreach($item in $list)#if($velocityCount != 1), #end$item#end
#end