<?xml version="1.0" encoding="ISO-8859-15"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xslc="http://xslcomponents.org/TR/WD-xslc" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
	<xsl:import href="../xslc.xsl"/>
	<xsl:import href="../Common.xsl"/>
	<xsl:import href="XMLC_ProfileItem.xsl"/>
<xsl:variable name="XMLC_Administrator" select="/document/Locales/XMLC_Administrator"/>
<xsl:variable name="XMLC_Supervisor" select="/document/Locales/XMLC_Supervisor"/>
	<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/ProfileTitle"/>
			<xsl:with-param name="PageTitle">
<img align="absmiddle" src="{$XMLC_PictosPath}Buttons/Profile/Profile.gif"/>&#160;<xsl:value-of select="/document/Locales/FormProfileTitle"/>
			</xsl:with-param>
			<xsl:with-param name="Head">
<script language="javascript"><![CDATA[function handleKeyPress(e) {
  var keyCode = GetEventKeyCode(e);
  if (GetEventCtrlKey(e) && (keyCode == 83)) {
    SetField('MainForm', 'NextAction', '');
    SubmitForm('MainForm');
    SetField('MainForm', 'NextAction', 'XMLC_FormProfile');
    setTimeout('reloadMenu()', 500); // Should ensure user profile is already written
    CancelEvent(e);
    return false;
  }
  return true;
}]]><![CDATA[function handleKeyDown(e) {
  var keyCode = GetEventKeyCode(e);
  if (GetEventCtrlKey(e) && (keyCode == 83)) {
    CancelEvent(e);
    return false;
}
  return true;
}]]><![CDATA[function reloadMenu() {
  var Menu
  var F;
  if (Menu = parent.frames.MenuEML)
  {
    if (F = Menu.document.MainForm)
    {
      F.SelectedID.value = 'FormProfile';
      F.action = 'MenuEML';
      F.target = 'MenuEML';
      F.submit();
    } else {
      Menu.location.href = Menu.location.href;
    }
    if (Menu = parent.frames.XMLC_ResizeBar)
      Menu.location.href = Menu.location.href;
    if (Menu = parent.frames.ResizeBar)
      Menu.location.href = Menu.location.href;
    if (Menu = parent.frames.MenuTitle)
      Menu.location.href = MenuEMLForm.location.href;
  }
}]]><![CDATA[function setExtractWMSGNumberValue(obj) {
  var selValue, Value;
  selValue = obj.options[obj.selectedIndex].value;
  if  (selValue == '0') Value = '15' // Collapsed
  else if (selValue == '1') Value = '10' // Expanded
  else Value = '20'; // SingleLine
  SetField('MainForm', 'Profile.ExtractWMSGNumber', Value);
  SetField('MainForm', 'Profile.ExtractWMSGNumberUserForms', Value);
}]]><![CDATA[function OpenSection(ID) {
  if (isVisible(ID))
    SetField('MainForm', 'LastOpenedSection', '');
  else
    SetField('MainForm', 'LastOpenedSection', ID);
  ShowHide(ID);
}]]></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 name="CustomButtons">
<xsl:if test="$XMLC_Supervisor = '1'">
<CustomButton>
<xsl:call-template name="xslc:ToolbarButton">
<xsl:with-param name="Caption">
<img alt="{/document/Locales/SaveAsTemplate}" border="0" src="{$XMLC_PictosPath}Buttons/Common/FullSave.gif"/>
</xsl:with-param>
<xsl:with-param name="OnClick"><![CDATA[SetField('MainForm', 'NextAction', 'UpdateTemplateProfile'); SubmitForm('MainForm', 'CONFIRM', ']]><xsl:value-of select="/document/Locales/SaveAsTemplateConfirm"/>'); return false;</xsl:with-param>
				</xsl:call-template>
</CustomButton>
</xsl:if>
			</xsl:with-param>
</xsl:call-template>
<xsl:call-template name="ToolButtonRefresh"/>
			</xsl:with-param>
<xsl:with-param name="ToolbarButtonsRight"/>
			<xsl:with-param name="BodyAttributes">
<Attributes onkeydown="return handleKeyPress(event);" onkeypress="return handleKeyDown(event);" onkeyup="return handleKeyDown(event);">
<xsl:attribute name="onload">boldMenuItem('FormProfile');<xsl:if test="/document/PARAMS/RefreshMenu = '1'">reloadMenu();</xsl:if>return false;</xsl:attribute>
				</Attributes>
			</xsl:with-param>
			<xsl:with-param name="ActivePageName">FormProfile</xsl:with-param>
			<xsl:with-param name="Tabs">
<Item Name="FormProfile" Caption="{/document/Locales/FormProfileTitle}" Hint="{/document/Locales/FormProfileTitle}" HRef="{XMLC_Params/XMLC_ScriptName}/{XMLC_Params/XMLC_Action}?{XMLC_Params/XMLC_InputParams}" ImagePath="{$XMLC_PictosPath}Buttons/Profile/Profile.gif"/>
			</xsl:with-param>
			<xsl:with-param name="Body">
				<p>
<xsl:value-of select="/document/Locales/PersonalizeMyProfileCaption"/>
				</p>
<!--<iframe id="PartialUpdateLogin" name="PartialUpdateLogin" style="display: none;"/>-->
<form action="XMLC_RestoreProfile" method="post" name="RestoreForm">
<input type="hidden" name="RefreshMenu" value="1"/>
					<table>
						<tr>
							<td width="130">
								<b>
									<xsl:value-of select="/document/Locales/ProfileSelection"/>
								</b>
							</td>
							<td>
<select name="XMLC_ProfileName">
									<xsl:for-each select="Profiles/Profile">
										<option value="{XMLC_ProfileName}">
											<xsl:if test="XMLC_ProfileName = /document/XMLC_Profile/XMLC_ProfileName">
												<xsl:attribute name="selected"/>
											</xsl:if>
<xsl:variable name="ProfileName" select="XMLC_ProfileName/text()"/>
<xsl:variable name="Locale" select="/document/Locales/*[name() = $ProfileName]"/>
<xsl:choose>
<xsl:when test="$Locale != ''">
<xsl:value-of select="$Locale"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="XMLC_ProfileName"/>
</xsl:otherwise>
</xsl:choose>
										</option>
									</xsl:for-each>
								</select>
							</td>
							<td>
								<xsl:call-template name="xslc:Button">
									<xsl:with-param name="Caption">
<img alt="{/document/Locales/RestoreProfileTemplateAlt}" src="{$XMLC_PictosPath}Button_RefreshArrow.gif"/>
									</xsl:with-param>
									<xsl:with-param name="OnClick">SubmitForm('RestoreForm', 'CONFIRM', '<xsl:value-of select="/document/Locales/RestoreProfileConfirm"/>'); return false;</xsl:with-param>
								</xsl:call-template>
							</td>
						</tr>
					</table>
				</form>
<xsl:apply-templates select="ProfileItems"/>
<xsl:call-template name="xslc:PoweredBy"/>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template match="ProfileItems">
<form name="MainForm" method="post" action="XMLC_UpdateProfile">
<input type="hidden" name="XMLC_ProfileName" value="{/document/XMLC_Profile/XMLC_ProfileName}"/>
					<input type="hidden" name="NextAction" value="XMLC_FormProfile"/>
<input type="hidden" name="RefreshMenu" value="1"/>
<input type="hidden" name="LastOpenedSection" value="{/document/PARAMS/LastOpenedSection}"/>
					<!--Language and Regional settings-->
					<table>
						<tr>
							<td width="130">
								<b>
									<xsl:value-of select="/document/Locales/Language"/>
								</b>
							</td>
							<td>
<select name="Profile.XMLC_Language" onchange="SubmitForm('MainForm'); return false;" style="width: 150px">
<xsl:for-each select="/document/Languages/Language">
										<option value="{Code}">
											<xsl:if test="Code = /document/XMLC_Profile/XMLC_Language">
												<xsl:attribute name="selected"/>
											</xsl:if>
											<xsl:value-of select="Title"/>
										</option>
									</xsl:for-each>
								</select>
							</td>
						</tr>
						<tr>
							<td>
								<b>
									<xsl:value-of select="/document/Locales/XMLC_Culture"/>
								</b>
							</td>
							<td>
<select name="Profile.XMLC_Culture" onchange="SubmitForm('MainForm'); return false;" style="width: 150px">
<xsl:for-each select="/document/Cultures/Culture">
										<option value="{Code}">
											<xsl:if test="Code = /document/XMLC_Profile/XMLC_Culture">
												<xsl:attribute name="selected"/>
											</xsl:if>
											<xsl:value-of select="Title"/>
										</option>
									</xsl:for-each>
								</select>
							</td>
						</tr>
					</table>
					<hr size="1"/>
<xsl:apply-templates select="Groups"/>
</form>
</xsl:template>
<xsl:template match="Groups">
<xsl:apply-templates select="Group[Kind = /document/PARAMS/Group]">
<xsl:sort select="Name"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="Group">
<xsl:choose>
<xsl:when test="(Public = '0') and (System = '0')"/>
<xsl:otherwise>
<xsl:variable name="Name" select="Name"/>
<xsl:variable name="Kind" select="Kind"/>
<xsl:variable name="GroupName">Group<xsl:value-of select="$Kind"/>
<xsl:value-of select="$Name"/>
</xsl:variable>
<xsl:variable name="id">id<xsl:value-of select="$GroupName"/>
</xsl:variable>
						<table class="clFlatTable" width="100%">
<tr class="clRowHeader" onclick="OpenSection('{$id}');">
<td align="center" style="border: 1px 1px 0px 1px;" width="35">
<img>
<xsl:attribute name="src"><xsl:value-of select="$XMLC_PictosPath"/><xsl:choose><xsl:when test="ImagePath != ''"><xsl:value-of select="ImagePath"/></xsl:when><xsl:otherwise>Profile/Appearance.gif</xsl:otherwise></xsl:choose></xsl:attribute>
</img>
								</td>
								<td style="border: 0px 1px 1px 0px;">
<xsl:value-of select="/document/Locales/*[name() = $GroupName]"/>
								</td>
							</tr>
<tr>
<td>&#160;</td>
								<td>
<div id="{$id}">
<xsl:if test="/document/PARAMS/LastOpenedSection != $id">
<xsl:attribute name="style">display: none;</xsl:attribute>
</xsl:if>
<table class="clTableNoBorder" width="100%">
<xsl:apply-templates select="../../ProfileItem[Groups/Group[(Kind = $Kind) and (Name = $Name)]]">
<xsl:sort select="Name"/>
</xsl:apply-templates>
</table>
									</div>
								</td>
							</tr>
						</table>
						<br/>
</xsl:otherwise>
</xsl:choose>
	</xsl:template>
<xsl:template match="ProfileItem">
<xsl:choose>
<xsl:when test="Permissions = 'Deprecated'"/>
<xsl:otherwise>
<xsl:call-template name="ProfileItem"/>
</xsl:otherwise>
</xsl:choose>
	</xsl:template>
</xsl:stylesheet>
