var ChangePassword;
(function()
{
  var $ = function (id) { return document.getElementById(id); };

  if (ChangePassword == null)
  {
    ChangePassword = new Object();
  }
  var confirmTextBox;
  var submitBtn;
  var oldPasswordTextBox;
  var newPasswordTextBox;
  
  function initHandler(confirmTextBoxId, submitBtnId, oldPasswordTextBoxId, newPasswordTextBoxId)
  {
    this.confirmTextBox = $(confirmTextBoxId);
    this.oldPasswordTextBox = $(oldPasswordTextBoxId);
    this.newPasswordTextBox = $(newPasswordTextBoxId);
    ChangePassword.submitBtn =  $(submitBtnId);
   
    if (this.confirmTextBox != null && ChangePassword.submitBtn != null)
    {
      BonaPage.addHandler(this.confirmTextBox, 'keydown', this.catchPressEnter);
    }
    if (this.oldPasswordTextBox != null)
    {
      BonaPage.addHandler(this.oldPasswordTextBox, 'keydown', this.suppressEnter);
    }
    if (this.newPasswordTextBox != null)
    {
      BonaPage.addHandler(this.newPasswordTextBox, 'keydown', this.suppressEnter);
    }
  }

  function catchPressEnter(e)
  {
    if (!e && event)
    {
      e = event;
    }

    if (e)
    {
      var key = (document.all) ? e.keyCode : e.which;

      if (key == 13)
      {
        ChangePassword.submitBtn.click();
        return false;
      }
    }
  }    
  function suppressEnter(e)
  {
    if (!e && event)
    {
      e = event;
    }

    if (e)
    {
      var key = (document.all) ? e.keyCode : e.which;

      if (key == 13)
      {
        return false;
      }
    }
  }    
  
  ChangePassword.initHandler = initHandler;
  ChangePassword.catchPressEnter = catchPressEnter;
  ChangePassword.suppressEnter = suppressEnter;
  
})();

if(typeof(Sys) !== "undefined")
  Sys.Application.notifyScriptLoaded();


