<%@ page language="java" buffer="100kb" errorPage="/common/error.jsp"%>

<%@ page import="vkc.view.WebShare" %>
<%@ page import="vkc.view.TabId" %>
<%@ page import="org.apache.struts.Globals" %>

<%@ taglib uri="struts-html" 	prefix="html"  %>
<%@ taglib uri="struts-bean" 	prefix="bean"  %>
<%@ taglib uri="struts-logic" 	prefix="logic" %>
<%@ taglib uri="vkc-taglib" 	prefix="vkc"   %>

<vkc:checkLogin />
<vkc:init/>
<html:html locale="true">
<head>

  	<vkc:cssinclude />

    <meta http-equiv="content-type"  content="text/html; charset=iso-8859-1" />
    <script type="text/javascript" src="<vkc:rewrite page='/common/utils.js'/>"></script>
    
    <script type="text/javascript">
    
    window.name = "MAINVIEW";
    var aclform = null;
    var associatedTabId = <%=TabId.ADMIN_USERMANAGEMENT_TAB%>;
    	
    function init() {
      	var tabView = getTabView();
        var tabViewForm = tabView.document.forms[0];

        if (tabView && tabView.systemviewtype == "administrationview" && tabView.selectedTabId != associatedTabId) {
          	tabView.location.replace("<%=ctxPath%>/adminTabView.do?selectedTabId=<%=TabId.ADMIN_USERMANAGEMENT_TAB%>"
          						   + "&lastCategoryId=" + tabViewForm.lastCategoryId.value
          						   + "&lastFunctionalId=" + tabViewForm.lastFunctionalId.value
          						   + "&lastProjectId=" + tabViewForm.lastProjectId.value);
        }

        <logic:present name="<%=WebShare.INFO_KEY%>" scope="request">
          <bean:define id="msg" type="java.lang.String" scope="request" name="<%=WebShare.INFO_KEY%>"/>
          alert( '<vkc:message javascript="true" filter="false" key="<%=msg%>"/>' );
        </logic:present>
    }

    function openUserInfoWindow( id ) {
	    var w = 800;
	    var h = 600;
	    var leftPosition = screen.width/2  - w/2;
	    var topPosition  = screen.height/2 - h/2;
	    var settings ='height=' + h + ', width=' + w + ', top=' + topPosition + ', left=' + leftPosition;
	    settings += ',scrollbars=yes,resizable';
	    settings += ',toolbar=no, location=no, directories=no, status=true, menubar=no';
	    var win = window.open( '<vkc:rewrite page="/displayUserInfo.do"/>?userId=' + id, 'USERINFO_MAINVIEW', settings );
		win.focus();                              
	}
    
    </script>
</head>
<body onload="init();" topmargin="0" marginheight="0">
<table align="center" cellspacing="1" cellpadding="5" border="0">

  <html:form action="/changeUserPassword" method="post">

  <bean:define id="form" name="changeUserPasswordForm" scope="request" type="vkc.administration.form.ChangeUserPasswordForm"/>
  <bean:define id="userInfo" name="form" property="userInfo" type="vkc.view.bean.UserInfo"/>

  <html:hidden property="userId"/>
  <html:hidden property="redirect"/>

  <tr>
    <td align="center">

	  <table width="1%" align="center" cellpadding="0" cellspacing="5" border="0">
        <logic:present name="<%=Globals.ERROR_KEY%>">
        <tr><td align="left" nowrap="nowrap" colspan="2"><font color="red"><b><vkc:errors/></b></font></td></tr>
        </logic:present>

		<tr>
          <td align="left" nowrap="nowrap" colspan="2">
            <table>
              <tr>
                <td nowrap="nowrap">
                  <b><vkc:message key="vkc.administration.userpasswordchange" /></b>&nbsp;
          		  <vkc:link href='<%="javascript:openUserInfoWindow(" + userInfo.getUserId().intValue() + ");"%>' title='<%=userInfo.getFirstnameLabel()%>'><vkc:write name="userInfo" property="username"/></vkc:link>
          		</td>
              </tr>
            </table>
          </td>
        </tr>

        <vkc:hline colspan="2" lineClass="hline" lineHeight="1" topSpace="3" bottomSpace="3"/>

		<tr>
		  <td align="left" nowrap="nowrap"><b><vkc:write name="<%=WebShare.USER_KEY%>" property="user"/>&nbsp;<vkc:message key="vkc.password"/>:</b></td>
		  <td width="100%" align="left" nowrap="nowrap"><html:password property="adminpassword" style="width:100%;"/></td>
		</tr>
		
        <vkc:hline colspan="2" lineClass="hline" lineHeight="1" topSpace="3" bottomSpace="3"/>
        
		<tr>
		  <td align="left" nowrap="nowrap"><b><vkc:message key="vkc.newpassword"/>:</b></td>
		  <td width="100%" align="left" nowrap="nowrap"><html:password property="newpassword" style="width:100%;"/></td>
		</tr>
		
		<tr>
		  <td align="left" nowrap="nowrap"><b><vkc:message key="vkc.repassword"/>:</b></td>
		  <td width="100%" align="left" nowrap="nowrap"><html:password property="repassword" style="width:100%;"/></td>
		</tr>
        
	    <logic:equal name="form" property="passwordChanged" value="true">
		<tr>
		  <td align="left" nowrap="nowrap"><b>&nbsp;</b></td>
		  <td width="100%" align="left" nowrap="nowrap"><b><vkc:message key="vkc.administration.userpasswordchange.successMessage"/></b></td>
		</tr>
        </logic:equal>

        <vkc:hline colspan="2" lineClass="hline" lineHeight="1" topSpace="3" bottomSpace="0"/>

        <tr>
          <td align="center" colspan="2">
            <table align="center" cellpadding="0" cellspacing="5" border="0">
              <tr>
                <logic:equal name="form" property="passwordChanged" value="false">
                  <td><vkc:button property="action.change.password" onclick="javascript:disableAllButtonsAndSubmit(this);"><vkc:message key="vkc.administration.button.changePassword"/></vkc:button></td>
                  <td><vkc:button property="action.random.password" onclick="javascript:disableAllButtonsAndSubmit(this);"><vkc:message key="vkc.administration.button.randomPassword"/></vkc:button></td>
                </logic:equal>
                <td><vkc:button property="action.back" onclick="javascript:disableAllButtonsAndSubmit(this);"><vkc:message key="button.back"/></vkc:button></td>
              </tr>
            </table>    
          </td>
        </tr>
	  </table>
    </td>
  </tr>
  </html:form>
</table>
</body>
</html:html>