<script>
jQuery(document).ready(function($) {

    // Find input fields
    var textboxes = $("input:text, input:password");
    textboxes[0].focus();
    
    // Track keyboard
    if($.browser.mozilla){
        $(textboxes).keypress(checkForEnter);
    }
    else{
        $(textboxes).keydown(checkForEnter);
    }

    //submite form by pressing "Enter"
    function checkForEnter(event) {
    	currentTextboxNumber = textboxes.index(this);
        if(event.keyCode == 13) {
        	$("#sendPassworRecoveryMailButton").click();
            return false;
        }
    }
});    
</script>
<style>
#resetPasswordInner {
  border-radius: 3px;
  padding-top:40px; 
}
#returnLink {
color: #6d7078;
}
#sendPassworRecoveryMailButton{
  border-radius: 3px;
  cursor: pointer;
  width: 132px;
  height: 31px;
  border: 1px solid #adadad;
  box-shadow: inset 0px 1px 0px #E9ECF3;
  background-image: linear-gradient(bottom,#a9acbd 0%,#d9dfeb 100%);
  background-image: -o-linear-gradient(bottom,#a9acbd 0%,#d9dfeb 100%);
  background-image: -moz-linear-gradient(bottom,#a9acbd 0%,#d9dfeb 100%);
  background-image: -webkit-linear-gradient(bottom,#a9acbd 0%,#d9dfeb 100%);
  background-image: -ms-linear-gradient(bottom,#a9acbd 0%,#d9dfeb 100%);
  background-image: -webkit-gradient(linear,left bottom,left top,color-stop(0,#a9acbd),color-stop(1,#d9dfeb));
  color: #6d7078;
  text-shadow: 0px 1px 0px #eee;
  box-shadow: 0 1px 0 #eee;
  margin-right: 16px;
  margin-left: 8px;
}

</style>
<?php
if(cfg("TRANSLATE_MODE") && app()->params->devMode) {
    cs()->registerScriptFile(Yii::app()->baseUrl . '/js/jquery.contextmenu.js', CClientScript::POS_HEAD);
    cs()->registerScriptFile(Yii::app()->baseUrl . '/js/pl-translator.js', CClientScript::POS_HEAD);
    cs()->registerScript('translation', "
        var translator;
        $(function() {
            translator = new $.plTranslator({
                url: '".url('translation')."',
            });
        });
        
        $(document).ajaxSuccess(function() {
            translator.update();
        });
    ");
}

$this->pageTitle=Yii::app()->name . ' - Login';
?>
<div id="loginWrapper">

<div id="loginOuter">
	<div id="loginHeader">
		<h1 data-translation-id="RESET_PASSWORD_HEADER" ><?php echo __("RESET_PASSWORD_HEADER");?></h1>
	</div> 
	<div id="resetPasswordInner">
		
<?php 
    if ($expiredLink) {
      echo $this->alert("RESET_PASSWORD_EXPIRED_ONETIME_LINK_ERROR_MESSAGE",'error',NULL,false); //'The recovery link you used is expired, please try to create a new one.'
    }
    $form = $this->beginWidget('CActiveForm', array(
			'id'=>'resetPassword-form',
			'enableClientValidation'=>true,
			'clientOptions'=>array(
				'validateOnSubmit'=>true,
			),
    ));
    echo CHtml::textField('username','', array(
	  'autocapitalize'=>'off',
	  'placeholder'=>__("RESET_PASSWORD_USERNAME"),//'Username',
	  'spellcheck'=>'false',
          "data-translation-id"=>"RESET_PASSWORD_USERNAME"
        )) . "<br />\n";

    echo CHtml::ajaxButton(
	__("RESET_PASSWORD_SEND_RECOVERY_MAIL_BUTTON"),//'send recovery mail',
	array(
	    'site/ajaxResetPassword'
	),
	array(
	    'type'=>'POST',
	    'dataType'=>'json',
	    'beforeSend' => 'function(){
	    }',
	    'complete' => 'function(jqXHR, textStatus){
	    }',
	    'success' => 'function(data) {
                var alert = $("<div />")
                    .addClass("alert")
                    .addClass("alert-block")
                    .addClass("alert-"+data.type)
                    .css("margin-left", "28px")
                    .css("margin-right", "28px")
                    .css("margin-top", "-30px")
                    .attr("data-translation-id", data.translationId)
                    .text(data.message);
                    
                var returnLink = $("<a />")
                    .attr("data-translation-id", "RESET_PASSWORD_RETURN_LINK")
                    .attr("id", "returnLink")
                    .attr("href", data.url)
                    .text("'.__("RESET_PASSWORD_RETURN_LINK").'");

                $("#resetPasswordInner").html("");
                $("#resetPasswordInner").append(alert).append(returnLink);
		
	    }',
	),
	array(
            'id'=>'sendPassworRecoveryMailButton',
            'data-translation-id' => 'RESET_PASSWORD_SEND_RECOVERY_MAIL_BUTTON',
            'data-translation-target' => 'RESET_PASSWORD_SEND_RECOVERY_MAIL_BUTTON'
        )
    ) . "\n";
    $this->endWidget();
		
?>	

	</div>
</div>
    
<?php
if (cfg("TRANSLATE_MODE")) {
?>

<i data-translation-target="RESET_PASSWORD_SEND_RECOVERY_MAIL_BUTTON" data-translation-id="RESET_PASSWORD_RECOVERY_EMAIL_SUBJECT"></i>
<i data-translation-target="RESET_PASSWORD_SEND_RECOVERY_MAIL_BUTTON" data-translation-id="RESET_PASSWORD_RECOVERY_EMAIL_TEXT"></i>

<?php
}
?>

