<style>
	.field input[type="password"], .field input[type="text"]{
		height:28px;
	}
    .input_tooltip__ {
        position: relative;
    }
    .cl_report_error_block_v1 {
        top: 20px;
    }
</style>
<div class="to_regist">
	<h2><?php echo Yii::t("main","508_password_change"); ?></h2>
	<?php if($allow){ ?>
		<?php $form=$this->beginWidget('CActiveForm', array(
			'id'=>'change-pass-form',
			'enableAjaxValidation'=>true,
			 'clientOptions' => array(
			   'validateOnSubmit' => true,
			   'validateOnChange' => false,
			)
			));
		?>
		<h4><?php echo Yii::t("main","517_on_this_page"); ?></h4><br />
		
		
		<div class="password_change_block"> 
			<div class="field password_old">
				<div class="field_title"><div class="tvalign"><?php echo $Login->getAttributeLabel('password_old'); ?></div></div>
				<div class="field_value">
					<? 
					$Login->password_old = '';
					echo $form->passwordField($Login, 'password_old', array());	?>
					<div class="tooltip"></div>
					<div class="input_tooltip__" style="display:none;">
						<?echo $form->error($Login, 'password_old', array('class'=>"cl_report_error_block_v1", 'style'=>'display:none;'));?>
					</div>
					<div class="clr"></div>
					<div class="show_password password_sh"><?php echo Yii::t("main","510_show_password"); ?></div>
					<div class="hide_password password_sh" style="display:none"><?php echo Yii::t("main","511_hide_password"); ?></div>
				</div>
			</div>
			<div class="field password_new">
				<div class="field_title"><div class="tvalign"><?php echo $Login->getAttributeLabel('password_new'); ?></div></div>
				<div class="field_value">
					<? 
					echo $form->passwordField($Login, 'password_new', array());	?>
					<div class="tooltip"></div>
					<div class="input_tooltip__" style="display:none;">
						<?echo $form->error($Login, 'password_new', array('class'=>"cl_report_error_block_v1", 'style'=>'display:none;'));?>
					</div>
					<div class="clr"></div>
					<div class="show_password password_sh"><?php echo Yii::t("main","510_show_password"); ?></div>
					<div class="hide_password password_sh" style="display:none"><?php echo Yii::t("main","511_hide_password"); ?></div>
				</div>
			</div>
			<div class="field password_old">
				<div class="field_title"><div class="tvalign"></div></div>
				<div class="field_value">
					<div class="pbuttons submitbtn preload" style="margin:15px 0 0 0; width:96%; max-width:271px;"><input type="submit" value="<?php echo Yii::t("main","232_save_changes"); ?>" /></div>
				</div>
			</div>
		</div>
		<?php $this->endWidget(); 
	}else{
		$_SESSION['message'][] = array("text" => Yii::t("main", "711_the_page_wll_be_aval_after_live_trader"), "action" => Yii::app()->controller->id . "/" . Yii::app()->controller->action->id, "type" => "warning");
	}
	?>
</div>
<script>
$(document).ready(function(){
	$('.password_sh').click(function(){
		var value = $(this).closest('.field_value').find('input').val();
		var id = $(this).closest('.field_value').find('input').attr('id');
		var maxlength = $(this).closest('.field_value').find('input').attr('maxlength');
		var name = $(this).closest('.field_value').find('input').attr('name');
		var inp = document.createElement("input");
		inp.id = id;
		inp.value = value;
		inp.maxlength = maxlength;
		inp.name = name;
		var element = document.getElementById(id);
		if($(this).hasClass('show_password')){
			inp.type = "text";
			$(this).closest('.field_value').find('.show_password').hide();
			$(this).closest('.field_value').find('.hide_password').show();
		}else{
			inp.type = "password";
			$(this).closest('.field_value').find('.show_password').show();
			$(this).closest('.field_value').find('.hide_password').hide();		 	
		}
		element.parentNode.replaceChild(inp, element);
	});
	
	$('.tooltip').live('click',function(){
		if($(this).closest('.field_value').find('.input_tooltip__').is(':hidden')){
			if($(this).closest('.field_value').find('.input_tooltip__ .delta').length == 0){
				$(this).closest('.field_value').find('.input_tooltip__').prepend('<div class="delta"></div>');
			}
			$(this).closest('.field_value').find('.input_tooltip__').slideDown();
		}else{
			$(this).closest('.field_value').find('.input_tooltip__').slideUp();
		}
	});
	
	$('#change-pass-form').submit(function(){
		var form = $('#change-pass-form');
		$('.to_regist').css({'opacity':'0.2'});
		$('#loaderImage').css({'display':'block'});
		
		$(form).ajaxSuccess(function(event, jqXHR, ajaxOptions, error){		
			if(error){
				$('.to_regist').css({'opacity':'1'});
				$('#loaderImage').css({'display':'none'});
			}	 
		});
	});
	
});
</script>