<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xslc="http://xslcomponents.org/TR/WD-xslc">
<xsl:import href="../xslc.xsl"/>
<xsl:import href="../Common.xsl"/>
<xsl:import href="XMLC_ProfileItem.xsl"/>
<xsl:variable name="XMLC_Language">
<xsl:choose>
<xsl:when test="/document/PARAMS/XMLC_Language != ''">
<xsl:value-of select="/document/PARAMS/XMLC_Language"/>
</xsl:when>
<xsl:otherwise>ENGLISH</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:template match="/">
<xsl:apply-templates select="document"/>
</xsl:template>
<xsl:template match="document">
<xsl:call-template name="xslc:Page">
<xsl:with-param name="Title" select="/document/Locales/XMLC_FormProfileXMLServiceTitle"/>
<xsl:with-param name="PageTitle">
<img align="absmiddle" src="{$XMLC_PictosPath}Button_Profile.gif"/>&#160;<xsl:value-of select="/document/Locales/XMLC_FormProfileXMLServicePageTitle"/>
</xsl:with-param>
<xsl:with-param name="Head">
<script language="javascript"><![CDATA[function handleKeyPress() {
  if (event.ctrlKey && (event.keyCode == 83)) { 
    SaveProfile();
    return false;
  }
}

function SaveProfile() {
  SubmitForm('MainForm');
}]]></script>
<style type="text/css">.clTableNoBorder TD {border: 0px;}</style>
</xsl:with-param>
<xsl:with-param name="ToolbarButtonsLeft">
<xsl:call-template name="xslc:ToolbarButtonPad"/>
</xsl:with-param>
<xsl:with-param name="ToolbarButtonsRight">
<xsl:call-template name="CommonToolbarButtonRight"/>
</xsl:with-param>
<xsl:with-param name="BodyAttributes">
<Attributes onkeydown="handleKeyPress();"/>
</xsl:with-param>
<xsl:with-param name="ActivePageName">XMLC_FormProfileXMLService</xsl:with-param>
<xsl:with-param name="Tabs">
<Item Name="XMLC_FormProfileXMLService" Caption="{/document/Locales/XMLC_FormProfileXMLServiceTabCaption}" Hint="{/document/Locales/XMLC_FormProfileXMLServiceTabHint}" ImagePath="{$XMLC_PictosPath}Button_Profile.gif">
<xsl:attribute name="HRef"><xsl:value-of select="/document/XMLC_Params/XMLC_ScriptName"/><xsl:choose><xsl:when test="/document/XMLC_Params/XMLC_UseXMLC_Action = '1'">?XMLC_Action=</xsl:when><xsl:otherwise>/</xsl:otherwise></xsl:choose><xsl:value-of select="XMLC_Params/XMLC_Action"/><xsl:choose><xsl:when test="/document/XMLC_Params/XMLC_UseXMLC_Action = '1'">&amp;</xsl:when><xsl:otherwise>?</xsl:otherwise></xsl:choose><xsl:value-of select="XMLC_Params/XMLC_InputParams"/></xsl:attribute>
</Item>
</xsl:with-param>
<xsl:with-param name="Body">
<form name="MainForm" method="post">
<xsl:attribute name="action"><xsl:value-of select="/document/XMLC_Params/XMLC_ScriptName"/><xsl:if test="/document/XMLC_Params/XMLC_UseXMLC_Action != '1'">/XMLC_UpdateProfile</xsl:if></xsl:attribute>
<xsl:if test="/document/XMLC_Params/XMLC_UseXMLC_Action = '1'">
<input type="hidden" name="XMLC_Action" value="XMLC_UpdateProfile"/>
</xsl:if>
<input type="hidden" name="NextAction" value="XMLC_FormProfileXMLService"/>
<input type="hidden" name="XMLService" value="{/document/PARAMS/XMLService}"/>
<xsl:apply-templates select="Groups"/>
</form>
<xsl:call-template name="xslc:PoweredBy"/>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template match="Groups">
<table cellpadding="2" cellspacing="0">
<xsl:apply-templates select="Group"/>
</table>
</xsl:template>
<xsl:template match="Group">
<xsl:variable name="Group" select="."/>
<xsl:variable name="colspan">
<xsl:choose>
<xsl:when test="/document/XMLC_Params/XMLC_Supervisor = '1'">3</xsl:when>
<xsl:otherwise>2</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<tr class="clRowHeader">
<td colspan="{$colspan}">
<xsl:value-of select="$Group"/>
<xsl:value-of select="/document/ProfileItems/Groups/Group[Name = $Group]/Locale/*[name() = $XMLC_Language]"/>
</td>
</tr>
<xsl:for-each select="/document/XMLServiceItems/XMLServiceItem">
<xsl:sort select="."/>
<xsl:variable name="Item" select="."/>
<xsl:apply-templates select="/document/ProfileItems/ProfileItem[Name = $Item and Groups/Group/Name = $Group]"/>
</xsl:for-each>
<tr>
<td colspan="{$colspan}">&#160;</td>
</tr>
</xsl:template>
<xsl:template match="ProfileItem">
<xsl:call-template name="ProfileItem"/>
</xsl:template>
</xsl:stylesheet>
