﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  xmlns:msxsl="urn:schemas-microsoft-com:xslt">
    <xsl:template match="/">
        <xsl:variable name="TemplatePathURL" select="PublicationData/AjaxRequest/TemplateURL"/>
        <xsl:variable name="Mode" select="PublicationData/Mode"/>
        <xsl:variable name="Title" select="PublicationData/UpdatePublication/Content/Title"/>
        <xsl:variable name="ItemID" select="PublicationData/UpdatePublication/Content/ItemID"/>
        <xsl:variable name="SubTitle" select="PublicationData/UpdatePublication/Content/SubTitle"/>
        <xsl:variable name="StartDate" select="PublicationData/UpdatePublication/Content/StartDate"/>
        <xsl:variable name="EndDate" select="PublicationData/UpdatePublication/Content/EndDate"/>
        <xsl:variable name="PublicationLevel" select="PublicationData/UpdatePublication/Content/PublicationLevel"/>
        <xsl:variable name="ActiveYN" select="PublicationData/UpdatePublication/Content/ActiveYN"/>
        <xsl:variable name="PublishedYN" select="PublicationData/UpdatePublication/Content/PublishedYN"/>
        <xsl:variable name="Summary" select="PublicationData/UpdatePublication/Content/Summary"/>
        <xsl:variable name="IntroHTML" select="PublicationData/UpdatePublication/Content/IntroHTML"/>
        <xsl:variable name="ConclusionHTML" select="PublicationData/UpdatePublication/Content/ConclusionHTML"/>
        <xsl:variable name="ImageURL" select="PublicationData/UpdatePublication/Content/ImageURL"/>
        <xsl:variable name="Origin" select="PublicationData/Origin"/>
        <xsl:variable name="PublcationUpdatePermissionID" select="PublicationData/PublcationUpdatePermissionID"/>
        <xsl:variable name="BrandPermissionID" select="PublicationData/BrandPermissionID"/>
        <xsl:variable name="BrandImage" select="PublicationData/Brand/Detail/BrandLogoSmallURL"/>
        <xsl:variable name="IsCommunityAdmin" select="PublicationData/IsCommunityAdmin"/>
        <xsl:variable name="BrandID" select="PublicationData/BrandID"/>
        <xsl:variable name="BrandCount" select="count(PublicationData/Brands/Brand)"/>
        <xsl:variable name="OwnerBrandID" select="PublicationData/UpdatePublication/Content/OwnerBrandID"/>
        <xsl:variable name="PublicationStartDate" select="PublicationData/StartDate"/>
        <xsl:variable name="PromoteKey" select="PublicationData/Brand/Detail/PromoteKey"/>
        <xsl:variable name="DisplayName" select="PublicationData/User/UserData/DisplayName"/>
        <xsl:variable name="HostName" select="PublicationData/HostName"/>
        <xsl:variable name="UserID" select="PublicationData/UserID"/>
        <xsl:variable name="AuthorID" select="PublicationData/UpdatePublication/Content/AuthorID"/>


        <xsl:variable name="BrandDDRowDisplayStyle">
            <xsl:choose>
                <xsl:when test ="$BrandCount > 0">
                    display:table-row;
                </xsl:when>
                <xsl:otherwise>
                    display:none;
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>

        <xsl:choose>
            <xsl:when test="$Mode = 'UpdateItem' and $PublcationUpdatePermissionID != 4 and $BrandPermissionID != 4">
                <div id="divUnAuthorizedUsers">
                    <span class="labelError">You are not an authorized user.</span>
                </div>
            </xsl:when>
            <xsl:otherwise>
                <center>
                    <div id="divAuthorizedUsers">
                        <table class="tableMaster" cellpadding="0" cellspacing="0" border="0">
                            <tr>
                                <td style="padding-left: 10px;" rowspan="20" ></td>
                                <td colspan="2"></td>
                                <td style="padding-right: 10px;" rowspan="20" ></td>
                            </tr>
                            <tr>
                                <td colspan="2">
                                    <div id="divClose" align="right" style="margin:5px; text-align:right; display: none;">
                                        <span onclick="hideDiv();" class="link">[ X ]</span>
                                    </div>
                                </td>

                            </tr>
                            <tr>

                                <td width="30%">
                                    <span class="labelFormFields lineHeight">Publication Title</span>
                                </td>
                                <td width="70%">
                                    <input id="txtPublicationTitle" type="text" class="wideText"  value="{normalize-space($Title)}" tabindex="1" maxlength="75" />
                                </td>

                            </tr>
                            <tr>
                                <td>
                                    <span class="labelFormFields lineHeight">Sub-Title (Optional)</span>
                                </td>
                                <td>
                                    <input id="txtPublicationSubTitle" type="text" class="wideText" value="{normalize-space($SubTitle)}" tabindex="2" maxlength="75"/>
                                </td>
                            </tr>
                            <tr>
                                <td style="padding-bottom: 5px;"></td>
                            </tr>
                            <tr>
                                <td>
                                    <span class="labelFormFields lineHeight">Publication Body</span>
                                </td>
                                <td>
                                    <textarea id="txtIntroHtml" type="text" class="wideText mceEditor" tabindex="10" rows="16" style="width: 649px; height:350px;">
                                        <xsl:value-of select ="$IntroHTML" disable-output-escaping ="yes"/>
                                    </textarea>
                                </td>
                            </tr>
                            <tr>
                                <td style="padding-bottom: 5px;"></td>
                            </tr>
                            <tr>
                                <td>
                                    <span class="labelFormFields lineHeight">Start Date</span>
                                </td>
                                <td>
                                    <xsl:choose>
                                        <xsl:when test="$Mode = 'AddNew'">
                                            <input id="txt_Item_StartDate" type="text" onblur="checkdate(this)"
                                                   class="date" tabindex="3" value="{normalize-space($PublicationStartDate)}"/>
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <input id="txt_Item_StartDate" type="text" onblur="checkdate(this)"
                                                   class="date" tabindex="3" value="{normalize-space($StartDate)}"/>
                                        </xsl:otherwise>
                                    </xsl:choose>
                                    <img src="{normalize-space($TemplatePathURL)}Web/Images/big_spacer.gif"></img>
                                    <img id="img_Item_StartDate"
                                         src="{normalize-space($TemplatePathURL)}Web/Images/CalendarIcon.gif"
                                         onclick='dp("txt_Item_StartDate", "img_Item_StartDate");'></img>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <span class="labelFormFields lineHeight">End Date</span>
                                </td>
                                <td>
                                    <input id="txt_Item_EndDate" type="text" onblur="checkdate(this)"
                                           class="date" value ="{normalize-space($EndDate)}" tabindex="4"/>
                                    <img src="{normalize-space($TemplatePathURL)}Web/Images/big_spacer.gif"></img>
                                    <img id="img_Item_EndDate"
                                         src="{normalize-space($TemplatePathURL)}Web/Images/CalendarIcon.gif"
                                         onclick='dp("txt_Item_EndDate", "img_Item_EndDate");'></img>
                                </td>
                            </tr>
                            <tr style='{$BrandDDRowDisplayStyle};'>
                                <td>
                                    <span class="labelFormFields lineHeight">Brand</span>
                                </td>
                                <td>
                                    <select id ="ddlBrand" name="Brand" class="smallDropdown">
                                        <xsl:if test ="$Mode != 'AddNew'">
                                            <xsl:choose>
                                                <xsl:when test="$OwnerBrandID = ''">
                                                    <option value="-1" selected="selected">
                                                        Select Brand
                                                    </option>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    <option value="-1">
                                                        Select Brand
                                                    </option>
                                                </xsl:otherwise>
                                            </xsl:choose>

                                            <xsl:for-each select="PublicationData/Brands/Brand">
                                                <xsl:if test ="$OwnerBrandID = ''">
                                                    <option value="{BrandID/.}">
                                                        <xsl:value-of select="normalize-space(BrandKey/.)"/>
                                                    </option>
                                                </xsl:if>
                                                <xsl:if test ="$OwnerBrandID != ''">
                                                    <xsl:if test ="normalize-space(BrandID/.) = $OwnerBrandID">
                                                        <option value="{BrandID/.}" selected="selected">
                                                            <xsl:value-of select="normalize-space(BrandKey/.)"/>
                                                        </option>
                                                    </xsl:if>
                                                    <xsl:if test ="normalize-space(BrandID/.) != $OwnerBrandID">
                                                        <option value="{BrandID/.}">
                                                            <xsl:value-of select="normalize-space(BrandKey/.)"/>
                                                        </option>
                                                    </xsl:if>
                                                </xsl:if>
                                            </xsl:for-each>
                                        </xsl:if>
                                    </select>
                                </td>
                            </tr>

                            <xsl:if test="$BrandID != 0">
                                <tr>
                                    <td>
                                        <span class="labelFormFields lineHeight">Author</span>
                                    </td>
                                    <td>
                                        <xsl:choose>
                                            <xsl:when test="$Mode = 'AddNew'">
                                                <select id="ddlAuthor" name="Author" class="smallDropdown">
                                                    <xsl:for-each select="PublicationData/ShareITRecords/ShareIT">
                                                        <xsl:choose>
                                                            <xsl:when test="ID = $UserID">
                                                                <option value="{ID}" selected="selected">
                                                                    <xsl:value-of select="Name"/>
                                                                </option>
                                                            </xsl:when>
                                                            <xsl:otherwise>
                                                                <option value="{ID}">
                                                                    <xsl:value-of select="Name"/>
                                                                </option>
                                                            </xsl:otherwise>
                                                        </xsl:choose>
                                                    </xsl:for-each>
                                                </select>
                                            </xsl:when>
                                            <xsl:otherwise>                                                                                             
                                                <select id="ddlAuthor" name="Author" class="smallDropdown">
                                                    <xsl:for-each select="PublicationData/ShareITRecords/ShareIT">
                                                        <xsl:choose>
                                                            <xsl:when test="ID = $AuthorID">
                                                                <option value="{ID}" selected="selected">
                                                                    <xsl:value-of select="Name"/>
                                                                </option>
                                                            </xsl:when>
                                                            <xsl:otherwise>
                                                                <option value="{ID}">
                                                                    <xsl:value-of select="Name"/>
                                                                </option>
                                                            </xsl:otherwise>
                                                        </xsl:choose>
                                                    </xsl:for-each>
                                                </select>
                                            </xsl:otherwise>
                                        </xsl:choose>
                                    </td>
                                </tr>
                            </xsl:if>

                            <tr>
                                <td>
                                    <span class="labelFormFields lineHeight">Publication Level</span>
                                </td>
                                <td>
                                    <select id ="opt_Item_PublicationLevel" name="PublicationLevel" class="smallDropdown" tabindex="5">
                                        <xsl:if test ="$Mode != 'AddNew'">
                                            <xsl:for-each select="PublicationData/Publication/Item">
                                                <xsl:if test ="$PublicationLevel = ''">
                                                    <option value="{ID/.}">
                                                        <xsl:value-of select="normalize-space(Type/.)"/>
                                                    </option>
                                                </xsl:if>
                                                <xsl:if test ="$PublicationLevel != ''">
                                                    <xsl:if test ="normalize-space(ID/.) = $PublicationLevel">
                                                        <option value="{ID/.}" selected="selected">
                                                            <xsl:value-of select="normalize-space(Type/.)"/>
                                                        </option>
                                                    </xsl:if>
                                                    <xsl:if test ="normalize-space(ID/.) != $PublicationLevel">
                                                        <option value="{ID/.}">
                                                            <xsl:value-of select="normalize-space(Type/.)"/>
                                                        </option>
                                                    </xsl:if>
                                                </xsl:if>
                                            </xsl:for-each>
                                        </xsl:if>
                                        <xsl:if test ="$Mode = 'AddNew'">
                                            <xsl:for-each select="PublicationData/Publication/Item">
                                                <option value="{ID/.}">
                                                    <xsl:value-of select="normalize-space(Type/.)"/>
                                                </option>
                                            </xsl:for-each>
                                        </xsl:if>
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <span class="labelFormFields lineHeight">Active</span>
                                </td>
                                <td>
                                    <select id="opt_Item_Active" name="Active" class="smallDropdown" tabindex="6">
                                        <xsl:if test="$Mode != 'AddNew'">
                                            <xsl:if test ="$ActiveYN != ''">
                                                <xsl:if test="$ActiveYN = 'True'">
                                                    <option value="True" selected="selected">
                                                        <xsl:text>Yes</xsl:text>
                                                    </option>
                                                    <option value="False">
                                                        <xsl:text>No</xsl:text>
                                                    </option>
                                                </xsl:if>
                                                <xsl:if test="$ActiveYN ='False'">
                                                    <option value="True">
                                                        <xsl:text>Yes</xsl:text>
                                                    </option>
                                                    <option value="False" selected="selected">
                                                        <xsl:text>No</xsl:text>
                                                    </option>
                                                </xsl:if>
                                            </xsl:if>
                                            <xsl:if test="$ActiveYN= ''">
                                                <option value="True" selected="selected">
                                                    <xsl:text>Yes</xsl:text>
                                                </option>
                                                <option value="False">
                                                    <xsl:text>No</xsl:text>
                                                </option>
                                            </xsl:if>
                                        </xsl:if>
                                        <xsl:if test="$Mode='AddNew'">
                                            <option value="True">
                                                <xsl:text>Yes</xsl:text>
                                            </option>
                                            <option value="False" selected="selected">
                                                <xsl:text>No</xsl:text>
                                            </option>
                                        </xsl:if>
                                    </select>
                                </td>
                            </tr>

                            <!--start-->
                            <xsl:if test ="$Mode != 'AddNew'">

                                <xsl:variable name="UpdatePublishedDisplay">
                                    <xsl:choose>
                                        <xsl:when test="$IsCommunityAdmin = 'True'">
                                            <xsl:text></xsl:text>
                                        </xsl:when>
                                        <xsl:otherwise>display:none;</xsl:otherwise>
                                    </xsl:choose>
                                </xsl:variable>

                                <tr style="{$UpdatePublishedDisplay}">
                                    <td>
                                        <span class="labelFormFields lineHeight">Published</span>
                                    </td>
                                    <td>
                                        <select id ="opt_Item_Published" name="Published" class="smallDropdown" tabindex="7">
                                            <xsl:if test ="$PublishedYN != ''">
                                                <xsl:if test ="$PublishedYN = 'True'">
                                                    <option value="True" selected="selected">
                                                        <xsl:text>Yes</xsl:text>
                                                    </option>
                                                    <option value="False">
                                                        <xsl:text>No</xsl:text>
                                                    </option>
                                                </xsl:if>
                                                <xsl:if test ="$PublishedYN = 'False'">
                                                    <option value="True" >
                                                        <xsl:text>Yes</xsl:text>
                                                    </option>
                                                    <option value="False" selected="selected">
                                                        <xsl:text>No</xsl:text>
                                                    </option>
                                                </xsl:if>
                                            </xsl:if>
                                            <xsl:if test ="$PublishedYN = ''">
                                                <option value="True" selected="selected">
                                                    <xsl:text>Yes</xsl:text>
                                                </option>
                                                <option value="False">
                                                    <xsl:text>No</xsl:text>
                                                </option>
                                            </xsl:if>
                                        </select>
                                    </td>
                                </tr>
                            </xsl:if>
                            <xsl:if test ="$Mode = 'AddNew'">
                                <tr style="display:none;">
                                    <td>
                                        <span class="labelFormFields lineHeight">Published</span>
                                    </td>
                                    <td>
                                        <select id ="opt_Item_Published" name="Published" class="smallDropdown" tabindex="7">
                                            <option value="True" >
                                                <xsl:text>Yes</xsl:text>
                                            </option>
                                            <option value="False" selected="selected">
                                                <xsl:text>No</xsl:text>
                                            </option>
                                        </select>
                                    </td>
                                </tr>
                            </xsl:if>
                            <!--End-->


                            <tr>
                                <td>
                                    <span class="labelFormFields lineHeight">Summary</span>
                                </td>
                                <td>
                                    <textarea id="txtSummary" type="text" class="wideText" tabindex="8" rows="8">
                                        <xsl:value-of select ="$Summary" disable-output-escaping ="yes"/>
                                    </textarea>
                                </td>
                            </tr>
                            <!--<tr>
                                <td style="padding-bottom: 5px;"></td>
                            </tr>-->
                            <xsl:choose>
                                <xsl:when test="$Origin = 'Brand'">
                                    <tr style="display: none;">
                                        <td style="padding-bottom: 5px;">
                                            <span class="labelFormFields lineHeight">Conclusion HTML</span>
                                        </td>
                                        <td>
                                            <textarea id="txtConclusionHtml" type="text" class="wideText mceEditor" tabindex="10" rows="16" style="width: 649px; height:350px;">
                                                <xsl:value-of select ="$ConclusionHTML" disable-output-escaping ="yes"/>
                                            </textarea>
                                        </td>
                                    </tr>
                                </xsl:when>
                                <xsl:otherwise>
                                    <tr>
                                        <td style="padding-bottom: 5px;">
                                            <span class="labelFormFields lineHeight">Conclusion HTML</span>
                                        </td>
                                        <td>
                                            <textarea id="txtConclusionHtml" type="text" class="wideText mceEditor" tabindex="10" rows="16" style="width: 649px; height:350px;">
                                                <xsl:value-of select ="$ConclusionHTML" disable-output-escaping ="yes"/>
                                            </textarea>
                                        </td>
                                    </tr>
                                </xsl:otherwise>
                            </xsl:choose>
                            <tr>
                                <td style="padding-bottom: 10px;">
                                    <span class="labelFormFields lineHeight">Image URL</span>
                                </td>
                                <td >
                                    <xsl:choose>
                                        <xsl:when test="$Origin = 'Brand'">
                                            <xsl:choose>
                                                <xsl:when test="normalize-space($ImageURL) = ''">
                                                    <input id="txtImageURL" type="text" class="wideText" style="position:absolute; width:650px;" value="{$BrandImage}" tabindex="11" maxlength="250"/>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    <input id="txtImageURL" type="text" class="wideText" style="position:absolute; width:650px;"  value="{normalize-space($ImageURL)}" tabindex="11" maxlength="250"/>
                                                </xsl:otherwise>
                                            </xsl:choose>
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <input id="txtImageURL" type="text" class="wideText" value="{normalize-space($ImageURL)}" tabindex="11" maxlength="250"/>
                                        </xsl:otherwise>
                                    </xsl:choose>
                                </td>
                            </tr>
                            <xsl:if test ="count(PublicationData/SelectedCategoryList/Item) = 0">
                                <xsl:choose>
                                    <xsl:when test="$Origin = 'Brand'">
                                        <tr>
                                            <td>
                                                <span class="labelFormFields lineHeight">Category Keys</span>
                                            </td>
                                            <td>
                                                <table class="tableMaster" cellpadding="0" cellspacing="0" border="0">
                                                    <tr>
                                                        <td width="50%">
                                                            <select id="listLeftCategoryKeys" size="15" style="width:320px; margin-top:10px;" >
                                                                <xsl:for-each select="PublicationData/CategoryList/Item">
                                                                    <xsl:variable name="CategoryItemID" select="ID"></xsl:variable>
                                                                    <xsl:if test="count(../../Brand/BrandCategory
                                                                [normalize-space(ID) = $CategoryItemID and $Mode='AddNew']) = 0">
                                                                        <option style=" width:100px; font-family: Calibri, Verdana, Arial; font-size: 8pt; line-height: 1.5em;" value="{ID/.}">
                                                                            <xsl:value-of select="normalize-space(Name/.)"/>
                                                                        </option>
                                                                    </xsl:if>
                                                                </xsl:for-each>
                                                            </select>
                                                        </td>
                                                        <td>
                                                            <div>
                                                                <input type="button" class="button" value="&gt;" onclick="publication_MoveCategoryKeysList(this)"></input>
                                                            </div>&#xa0;
                                                            <div>
                                                                <input type="button" class="button" value="X" onclick="publication_MoveCategoryKeysList(this)"></input>
                                                            </div>
                                                        </td>
                                                        <td>
                                                            <select id="listRightCategoryKeys" size="15" style="width:280px; margin-top:4px;">
                                                                <xsl:if test="$Mode='AddNew'">
                                                                    <xsl:for-each select="PublicationData/Brand/BrandCategory">
                                                                        <option style="font-family: Calibri, Verdana, Arial; font-size: 8pt; line-height: 1.5em;"
                                                                                value="{normalize-space(ID)}">
                                                                            <xsl:value-of select="normalize-space(Name/.)"/>
                                                                        </option>
                                                                    </xsl:for-each>
                                                                </xsl:if>
                                                            </select>
                                                        </td>
                                                        <td>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </td>
                                        </tr>
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <tr>
                                            <td>
                                                <span class="labelFormFields lineHeight">Category Keys</span>
                                            </td>
                                            <td>
                                                <table class="tableMaster" cellpadding="0" cellspacing="0" border="0">
                                                    <tr>
                                                        <td >
                                                            <select id="listLeftCategoryKeys" size="15">
                                                                <xsl:for-each select="PublicationData/CategoryList/Item">
                                                                    <option style="font-family: Calibri, Verdana, Arial; font-size: 8pt; line-height: 1.5em;" value="{ID/.}">
                                                                        <xsl:value-of select="normalize-space(Name/.)"/>
                                                                    </option>
                                                                </xsl:for-each>
                                                            </select>
                                                        </td>
                                                        <td>
                                                            <div>
                                                                <input type="button" class="button" value="&gt;" onclick="publication_MoveCategoryKeysList(this)"></input>
                                                            </div>&#xa0;
                                                            <div>
                                                                <input type="button" class="button" value="X" onclick="publication_MoveCategoryKeysList(this)"></input>
                                                            </div>
                                                        </td>
                                                        <td width="45%">
                                                            <select id="listRightCategoryKeys" size="15" style="width:100%;">
                                                                
                                                            </select>
                                                        </td>
                                                        <td>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </td>
                                        </tr>
                                    </xsl:otherwise>
                                </xsl:choose>
                            </xsl:if>
                            <xsl:if test ="$Mode = 'UpdateItem'">
                                <xsl:if test ="count(PublicationData/SelectedCategoryList/Item) &gt; 0">
                                    <tr>
                                        <td>
                                            <span class="labelFormFields">Category Keys</span>
                                        </td>
                                        <td>
                                            <div id="divViewSelectedCategory" style="display: block;">
                                                <xsl:for-each select="PublicationData/SelectedCategoryList/Item">

                                                    <xsl:variable name="CategoryID" select="normalize-space(ID)"></xsl:variable>
                                                    <xsl:variable name="ItemCategoryID" select="normalize-space(ItemCategoryID)"></xsl:variable>

                                                    <div id="div_{$CategoryID}_CategoryItem" style="margin-top:5px;">
                                                        <table  border='1' cellspacing='0' cellpadding='0'>
                                                            <tr>
                                                                <td>
                                                                    <span style="margin:5px" class="label">
                                                                        <xsl:value-of select ="Name"/>&#xa0;
                                                                    </span>
                                                                </td>
                                                                <td>
                                                                    <span style="margin:5px;" class="link"
                                                                          onClick='deleteCategories("{normalize-space($ItemCategoryID)}", 
                                                                                          "div_{$CategoryID}_CategoryItem", 
                                                                                          "{$CategoryID}");'>
                                                                        &#xa0;X&#xa0;
                                                                    </span>

                                                                </td>
                                                            </tr>
                                                        </table>
                                                    </div>
                                                </xsl:for-each>
                                                <div style="margin-top:5px;" class="label link"
                                                     onClick='publication_EditCategory(
                                                "divViewSelectedCategory",
                                                "divEditSelectedCategory");'>
                                                    <u>
                                                        Edit...
                                                    </u>
                                                </div>
                                            </div>
                                            <div id="divEditSelectedCategory" style="display: none;">
                                                <table class="tableMaster" cellpadding="0" cellspacing="0" border="0">
                                                    <tr>
                                                        <td width="45%">
                                                            <select id="listLeftCategoryKeys" size="15" style="margin-top:10px;" >
                                                                <xsl:for-each select="PublicationData/CategoryList/Item">
                                                                    <xsl:variable name="CategoryItemID" select="ID"></xsl:variable>
                                                                    <xsl:if test="count(../../SelectedCategoryList/Item
                                                                [normalize-space(ID) = $CategoryItemID]) = 0">
                                                                        <option style="font-family: Calibri, Verdana, Arial; font-size: 8pt; line-height: 1.5em;" value="{ID/.}">
                                                                            <xsl:value-of select="normalize-space(Name/.)"/>
                                                                        </option>
                                                                    </xsl:if>
                                                                </xsl:for-each>
                                                            </select>
                                                        </td>
                                                        <td>
                                                            <div>
                                                                <input type="button" class="button" value="&gt;" onclick="publication_MoveCategoryKeysList(this)"></input>
                                                            </div>&#xa0;
                                                            <div>
                                                                <input type="button" class="button" value="X" onclick="publication_MoveCategoryKeysList(this)"></input>
                                                            </div>
                                                        </td>
                                                        <td>
                                                            <select id="listRightCategoryKeys" size="15" style="width:280px; margin-top:10px;">
                                                                <xsl:for-each select="PublicationData/SelectedCategoryList/Item">
                                                                    <option style="font-family: Calibri, Verdana, Arial; font-size: 8pt; line-height: 1.5em;"
                                                                            value="{normalize-space(ID)}">
                                                                        <xsl:value-of select="normalize-space(Name/.)"/>
                                                                    </option>
                                                                </xsl:for-each>
                                                            </select>
                                                        </td>
                                                        <td>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </div>
                                        </td>
                                    </tr>
                                </xsl:if>
                            </xsl:if>
                            <xsl:if test ="$Mode = 'UpdateItem'">
                                <tr>
                                    <td>
                                        <span class="labelFormFields">Link Templates</span>
                                    </td>
                                    <td>
                                        <div id="divEditSelectedTemplates" style="display: block;">
                                            <table class="tableMaster" cellpadding="0" cellspacing="0" border="0">
                                                <tr>
                                                    <td width="45%">
                                                        <select id="listLeftTemplateKeys" size="15" style="margin-top:10px;" >
                                                            <xsl:for-each select="PublicationData/TemplateList/Item">
                                                                <xsl:variable name="TemplateItemID" select="ID"></xsl:variable>
                                                                <xsl:if test="count(../../SelectedTemplateList/Item
                                                                [normalize-space(ID) = $TemplateItemID]) = 0">
                                                                    <option style="font-family: Calibri, Verdana, Arial; font-size: 8pt; line-height: 1.5em;" value="{ID/.}">
                                                                        <xsl:value-of select="normalize-space(Name/.)"/>
                                                                    </option>
                                                                </xsl:if>
                                                            </xsl:for-each>
                                                        </select>
                                                    </td>
                                                    <td>
                                                        <div>
                                                            <input type="button" class="button" value="&gt;" onclick="template_MoveTemplateKeysList(this)"></input>
                                                        </div>&#xa0;
                                                        <div>
                                                            <input type="button" class="button" value="X" onclick="template_MoveTemplateKeysList(this)"></input>
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <select id="listRightTemplateKeys" size="15" style="width:280px; margin-top:10px;">
                                                            <xsl:for-each select="PublicationData/SelectedTemplateList/Item">
                                                                <option style="font-family: Calibri, Verdana, Arial; font-size: 8pt; line-height: 1.5em;"
                                                                        value="{normalize-space(ID)}">
                                                                    <xsl:value-of select="normalize-space(Name/.)"/>
                                                                </option>
                                                            </xsl:for-each>
                                                        </select>
                                                    </td>
                                                    <td>
                                                    </td>
                                                </tr>
                                            </table>
                                        </div>
                                    </td>
                                </tr>
                            </xsl:if>
                            <tr>
                                <td></td>
                                <td style="padding-top: 10px; padding-bottom: 10px;">
                                    <xsl:if test ="$Mode = 'AddNew'">
                                        <input type="button" class="button" value="Save"
                                               onclick='return publications_AddPublishingData(
                                      "txtPublicationTitle",
                                      "txtPublicationSubTitle",
                                      "txt_Item_StartDate",
                                      "txt_Item_EndDate",
                                      "opt_Item_PublicationLevel",
                                      "opt_Item_Active",        
                                      "opt_Item_Published",
                                      "txtSummary",
                                      "txtIntroHtml",
                                      "txtConclusionHtml",
                                      "txtImageURL","22","divContent", "listRightCategoryKeys","{normalize-space($BrandID)}","ddlAuthor");'>
                                        </input>
                                    </xsl:if>
                                    <xsl:if test ="$Mode = 'UpdateItem'">
                                        <input type="button" class="button" value="Update"
                                               onclick='return publications_UpdatePublishingData("{normalize-space($ItemID)}",
                                      "txtPublicationTitle",
                                      "txtPublicationSubTitle",
                                      "txt_Item_StartDate",
                                      "txt_Item_EndDate",
                                      "opt_Item_PublicationLevel",
                                      "opt_Item_Active",        
                                      "opt_Item_Published",
                                      "txtSummary",
                                      "txtIntroHtml",
                                      "txtConclusionHtml",
                                      "ddlBrand",
                                      "txtImageURL","22","divContent", "listRightCategoryKeys", "ddlAuthor","listRightTemplateKeys");'></input>
                                    </xsl:if>
                                </td>
                            </tr>
                        </table>
                    </div>
                </center>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
</xsl:stylesheet>
