#parse ( "/template/includes/actionerrors.vm" )

#if ($action.getClass().getName() == "com.atlassian.confluence.admin.actions.lookandfeel.ChooseThemeAction")
    #set ($isGlobalAdmin = true)
#else
    #set ($isGlobalAdmin = false)
#end

<script language="JavaScript">
    function checkRadioButton(radioId)
      {
          radioButton = document.getElementById(radioId);
          radioButton.checked = true;
          return false;
      }
</script>

#if ($space.key) <input type="hidden" name="key" value="$space.key" /> #end

    <div class="form-block first">
        <div class="form-element-large">$action.getText('current.theme.title')</div>

        <p>$action.getText('current.theme.desc')</p>
        #if ($currentThemeDescriptor)
            <table border="0" cellpadding="5" cellspacing="0" width="100%">
                <tr bgcolor="ffffff">
                    <td width="90" rowspan="2" align="center">
                        #if ($action.hasIcon($currentThemeDescriptor))
                            <img src="$req.contextPath/download/resources/$currentThemeDescriptor.completeKey/themeicon.gif" alt="" class="greybox">
                        #else
                            <img src="$staticResourceUrlPrefix/images/themes/no-icon.gif" alt="" class="greybox">
                        #end
                    </td>
                    <td valign="top">
                        <label class="formtitle">
                            #if ($currentThemeDescriptor.i18nNameKey) $action.getText($currentThemeDescriptor.i18nNameKey, $currentThemeDescriptor.name)
                            #else $currentThemeDescriptor.name
                            #end
                        </label>
                        <br>
                        #if ($currentThemeDescriptor.descriptionKey) $action.getText($currentThemeDescriptor.descriptionKey, $!currentThemeDescriptor.description)
                        #else $!currentThemeDescriptor.description
                        #end
                    </td>
                </tr>
            </table>

            #if ($action.getConfigPath($currentThemeDescriptor))
                <div class="form-header">
                    <p><strong>
                        <a href="$bootstrap.webAppContextPath$action.getConfigPath($currentThemeDescriptor)#if($space.key)?key=$space.key#end">$action.getText('theme.configure')</a>
                    </strong>
                        $action.getText('theme.configure.desc')
                    </p>
                </div>
            #end
        #else
            <table border="0" cellpadding="5" cellspacing="0" width="100%">
                <tr bgcolor="ffffff">
                    <td width="90" rowspan="2" align="center">
                        <img src="$staticResourceUrlPrefix/images/themes/main-theme.gif" alt="" class="greybox">
                    </td>
                    <td valign="top">
                        <label>$action.getText("theme.default.choose")</label>
                        <br/>
                        #if ($action.getClass().getName() == "com.atlassian.confluence.admin.actions.lookandfeel.ChooseThemeAction")
                            $action.getText("global.theme.default.desc")
                        #else
                            $action.getText("theme.default.desc")
                        #end
                    </td>
                </tr>
            </table>
        #end
        </div>

        <div class="form-divider"></div>

        <div class="form-block">
            <div class="form-element-large">$action.getText('theme.choose.new')</div>

        <p>$action.getText('theme.select.desc')</p>
        #if ($currentThemeDescriptor)
            <table border="0" cellpadding="5" cellspacing="0" width="100%">
                <tr bgcolor="ffffff" onMouseOver="style.backgroundColor='f0f0f0'" onMouseOut="style.backgroundColor='ffffff'" onclick="javascript:checkRadioButton('themeKey.default');">
                    <td width="90" align="center">
                        <img src="$staticResourceUrlPrefix/images/themes/main-theme.gif" alt="" class="greybox">
                    </td>
                    <td valign="top">
                        <input type="radio" id="themeKey.default" name="themeKey" value="" #if ( (! $currentThemeDescriptor) || ($availableThemeDescriptors.size() == 0)) checked="true" #end >
                        <label>$action.getText("theme.default.choose")</label>
                        <br>
                        #if ($action.getClass().getName() == "com.atlassian.confluence.admin.actions.lookandfeel.ChooseThemeAction")
                            $action.getText("global.theme.default.desc")
                        #else
                            $action.getText("theme.default.desc")
                        #end
                    </td>
                </tr>
            </table>
        #end

        #if ($availableThemeDescriptors.size() == 0)
            $action.getText("theme.choose.nothemes")
        #else
            #foreach ($theme in $availableThemeDescriptors)
                #if (!$currentThemeDescriptor || $theme != $currentThemeDescriptor)
                    <div>
                    <table border="0" cellpadding="5" cellspacing="0" width="100%">
                        <tr bgcolor="ffffff" onMouseOver="style.backgroundColor='f0f0f0'" onMouseOut="style.backgroundColor='ffffff'" onclick="javascript:checkRadioButton('themeKey.$theme.completeKey');">
                            <td width="90" align="center">
                                #if ($action.hasIcon($theme))
                                    <img src="$req.contextPath/download/resources/$theme.completeKey/themeicon.gif" alt="" class="greybox">
                                #else
                                    <img src="$staticResourceUrlPrefix/images/themes/no-icon.gif" alt="" class="greybox">
                                #end
                            </td>
                            <td valign="top">
                                <input type="radio" id="themeKey.$theme.completeKey" name="themeKey" value="$theme.completeKey" #if (($currentThemeDescriptor && $theme == $currentThemeDescriptor) || $theme.completeKey == $themeKey) checked="true" #end>
                                <label>
                                    #if ($theme.i18nNameKey) $action.getText($theme.i18nNameKey, $theme.name)
                                    #else $theme.name
                                    #end
                                </label>
                                <br>
                                #if ($theme.descriptionKey) $action.getText($theme.descriptionKey, $!theme.description)
                                #else $!theme.description
                                #end
                            </td>
                        </tr>
                    </table>
                #end
            #end
        #end
        </div>
    <p>
