<? global $vis_language; ?>
<script>
	$(document).ready(function(){
		function change_password_strength(strengthPercentage, is_valid){
			$("#strength_div").show();
			$("#password_strength_per").val(strengthPercentage);
			var show_password_result;
				if(strengthPercentage>=0 && strengthPercentage<50){show_password_result='<span class="label vh-yellow-bg"> <?=$vis_language['TXTWEAK'];?> </span>';}
				else if(strengthPercentage>=50 && strengthPercentage<70){show_password_result='<span class="label vh-green-bg"> <?=$vis_language['TXTMEDIUM'];?> </span>';}
				else if(strengthPercentage>=70 && strengthPercentage<90){show_password_result='<span class="label vh-orange-bg"> <?=$vis_language['TXTSTRONG'];?> </span>';}
				else if(strengthPercentage>=90 && strengthPercentage<=100){show_password_result='<span class="label vh-red-bg"> <?=$vis_language['TXTVERYSTRONG'];?> </span>';}
				if(is_valid=='not_allowed') $('#password_strenght_id').html('<? echo $vis_language['TXTPASSWORDSRENGTH']."&nbsp;&nbsp;"; ?> '+show_password_result+ '&nbsp;&nbsp; <?=$vis_language['TXTNOTALLOWED']?>');
				else if(is_valid=='allowed') $('#password_strenght_id').html('<? echo $vis_language['TXTPASSWORDSRENGTH']."&nbsp;&nbsp;"; ?> '+show_password_result+ '&nbsp;&nbsp; <?=$vis_language['TXTALLOWED']?>');
				return true;	
		}
		
		$('#vis_password').pStrength({
			'changeBackground'          : false,
			'onPasswordStrengthChanged' : function(passwordStrength, strengthPercentage) {
				if(passwordStrength!=0){change_password_strength(strengthPercentage,'not_allowed');}
			},
			'passwordValidFrom': <?= ($security_password_details != -1) ? $security_password_details[0]['content'] : 50;?>,
			'onValidatePassword': function(strengthPercentage) {
				change_password_strength(strengthPercentage,'allowed');
			}
		});
	});

/*  disable scacebar         */
	$(function() {
         var txt = $("input#vis_password");
         var func = function() {
             txt.val(txt.val().replace(/\s/g, ''));
    }
    txt.keyup(func).blur(func);
});
 </script>
 <section class="container m-t-md">
   <div class="row">
      <div class="col-md-12">
        <section class="panel shadow-none">
			<header class="vis_login_head">
				<?php if(isset($request_data['incorrect']) && $request_data['incorrect']=='email') {?>
				<script> $("#vis_submit_err_div").show(); $("#vis_submit_err_div").html('<? echo $vis_language['MSGCLTEMAILEXIST']; ?>'); </script>
				<?php } if(isset($operation['reg_message']) && $operation['reg_message']!='') {?>
				<script> $("#<?= (($operation['success']==1)?'vis_submit_msg_div':'vis_submit_err_div'); ?>").show(); $("#<?= (($operation['success']==1)?'vis_submit_msg_div':'vis_submit_err_div'); ?>").html('<? echo $operation['reg_message']; ?>'); </script> <?php } ?>
			</header>
           
			<div class="panel-body no-padder">
                <form class="form-horizontal" id="vis_form_register" name="vis_form_register" method="post" role="form">
                    <div class="col-md-12">
                      <div class="wrapper">
                          <div class="form-group">
                            <label for="FirstName" class="col-sm-2 control-label"><? echo $vis_language['TXTFIRSTNAME']; ?></label>
                            <div class="col-sm-8">
                              <input type="text" class="form-control input-sm" data-type="text" name="vis_firstname" id="vis_firstname" <? if(isset($operation['vis_firstname'])) echo 'value="'.$operation['vis_firstname'].'"'; ?>>
                            </div>
                          </div>
                          <div class="form-group">
                            <label for="LastName" class="col-sm-2 control-label"><? echo $vis_language['TXTLASTNAME']; ?></label>
                            <div class="col-sm-8">
                              <input type="text" class="form-control input-sm" data-type="text" name="vis_lastname" id="vis_lastname" <? if(isset($operation['vis_lastname'])) echo 'value="'.$operation['vis_lastname'].'"'; ?>>
                            </div>
                          </div>
                          <div class="form-group">
                            <label for="PersonalEmail" class="col-sm-2 control-label"><? echo $vis_language['TXTEMAIL']; ?></label>
                            <div class="col-sm-8">
                              <input type="email" class="form-control input-sm" data-type="email" name="vis_email" id="vis_email" <? if(isset($operation['vis_email'])) echo 'value="'.$operation['vis_email'].'"'; ?>>
                            </div>
                          </div>
                          <div class="form-group">
                            <label for="UserName" class="col-sm-2 control-label"><? echo $vis_language['TXTUSERNAME']; ?></label>
                            <div class="col-sm-8">
                              <input type="text" class="form-control input-sm" name="vis_username" id="vis_username" <? if(isset($operation['vis_username'])) echo 'value="'.$operation['vis_username'].'"'; ?>>
                            </div>
                          </div>
                          <div class="form-group">
                            <label for="Password" class="col-sm-2 control-label"><? echo $vis_language['TXTPASSWORD']; ?></label>
                            <div class="col-sm-8">
                              <input type="password" class="form-control input-sm" name="vis_password"  id="vis_password" data-display="password_strenght_id"/>
                            </div>
                          </div>
                          <div class="form-group" id="strength_div" style="display:none;">
							<label class="col-sm-2 control-label"></label>
							<div class="col-sm-8">
								 <input type="hidden" name="password_strength_per" id="password_strength_per" value='0'>
								 <div id="password_strenght_id"></div>
							</div>
						  </div>
                          <div class="form-group">
                            <label for="ConfirmPassword" class="col-sm-2 control-label"><? echo $vis_language['TXTCONFIRMNEWPASSWORD']; ?></label>
                            <div class="col-sm-8">
                              <input type="password" class="form-control input-sm" name="vis_confirm"  id="vis_confirm" />
                            </div>
                          </div>
                          <div class="form-group">
                            <label for="PhoneNumber" class="col-sm-2 control-label"><? echo $vis_language['TXTCONTACTNUMBER']; ?></label>
                            <div class="col-sm-8">
                              <input type="tel" class="form-control input-sm" name="vis_contact_number" id="vis_contact_number" <? if(isset($operation['vis_contact_number'])) echo 'value="'.$operation['vis_contact_number'].'"'; ?> data-type="phone"  placeholder="<? echo $vis_language['TXTPHONEEG']; ?>">
                            </div>
                          </div>
                          <? if($custom_field_var != '') echo $custom_field_var; 
                          if($setting_details==-1 || $setting_details[0]['content']==1) { ?>
                          <div class="form-group">
                            <label for="Password" class="col-sm-2 control-label"><? echo $vis_language['TXTIMGVERIFY']; ?></label>
                            <div class="col-sm-8">
							<div class="col-sm-10">	
							  <img src="<?= VIS_PATH_TEMPLATE ?>get_captcha.php?clr=<? echo str_replace("#",'',VIS_THEME_COLOR); ?>" alt="" id="captcha" class="col-sm-4"/>
                              <div id="refresh" class="col-sm-3 m-t link"><i class="vh vh-lg vh-refresh"></i> <? echo $vis_language['TXTREFRESH']; ?></div>
							</div> 
                              <input type="text" class="form-control input-sm" name="captchacode"  id="captchacode" autocomplete="off"/>
                            </div>
                          </div>
                          <? } ?>
                      </div>
                    </div>
                    <div class="col-lg-offset-2 col-lg-8 m-b-lg">
                          <button type="submit" class="btn btn-primary"><?= $vis_language['TXTREGISTER']; ?></button>
                          <input type="hidden" name="vis_operation" value="add_client" /><input type="hidden" name="vis_module" value="client" /><input type="hidden" name="vis_parent_id" value="0" />
                          <input type="hidden" name="vis_honeypot" id="vis_honeypot" />
                    </div>
                </form>    
			  </div> <!-- row -->                            
			 </section>
      </div>
   </div>
</section>
<script>
$('#refresh').click(function() {  
			
			change_captcha();
	 });
	 
	 function change_captcha()
	 {
	 	document.getElementById('captcha').src="<?= VIS_PATH_TEMPLATE ?>get_captcha.php?clr=<? echo str_replace("#",'',VIS_THEME_COLOR); ?>&rnd=" + Math.random();
	 }
   $('.start').datetimepicker();
</script>
