<script type="text/javascript">
	$(document).ready(function(){
		$("form#register-form").validate();
		$("form#register-form #register-login").rules("add", {required: true});
		$("form#register-form #register-email").rules("add", {required: true, email: true});
		$("form#register-form #register-password").rules("add", {required: true});
		$("form#register-form #register-password2").rules("add", {required: true, equalTo: "#register-password"});
		
		{{if isset($sRulesLink)}}
			$("form#register-form #rules-accept").rules("add", {required: true, messages: {required: "{{$lang.Require_rules_accept}}"}});
		{{/if}}
		$("form#register-form #rules-confirm").rules("add", {required: true});
		
		$('#generate').click(function(e){
			e.preventDefault();
			var url = 'https://www.random.org/strings/?num=1&len=8&digits=on&upperalpha=on&loweralpha=on&unique=off&format=plain&rnd=new';
			$.get(url, null, function( password ){
				$('#register-password').prop( 'type', 'text' ).val( password );
				$('#register-password2').val( password );
			});
		});
		$('#register-password').on( 'keyup keypress bluyr change mouseup', function(){
			if( $(this).val().length != 8 || $(this).val() != $('#register-password2').val() ){
				$(this).prop( 'type', 'password' );
			}
		});
	});
</script>
<form action="{{$aMenuLoginInfo.sLinkRegister}}" method="post" id="register-form" class="form-styled">
	<div class="block50">
		<fieldset>
			<input type="hidden" name="sOption" value="save" />
			<table>
				<tr>
					<th><label for="register-login">{{$lang.Login}}</label>:</th><td><input type="text" name="sLogin" value="{{$_POST.sLogin}}" class="input" id="register-login" /><img class="tTip info" src="templates/images/info.png" alt="{{$lang.tooltip_login}}" title="{{$lang.tooltip_login}}" /></td>
				</tr><tr>
					<th><label for="register-email">{{$lang.Email}}</label>:</th><td><input type="text" name="sEmail" value="{{$_POST.sEmail}}" class="input" id="register-email" /><img class="tTip info" src="templates/images/info.png" alt="{{$lang.tooltip_email}}" title="{{$lang.tooltip_email}}" /></td>
				</tr><tr>
					<th><label for="register-password">{{$lang.Password}}</label>:</th><td><input type="password" name="sPass" value="{{$_POST.sPass}}" class="input" id="register-password" style="width: 165px" /><img class="tTip info" src="templates/images/info.png" alt="{{$lang.tooltip_pass}}" title="{{$lang.tooltip_pass}}" /> <a href="#" id="generate"></a></td>
				</tr><tr>
					<th><label for="register-password2">{{$lang.Password_confirm}}</label>:</th><td><input type="password" name="sPass2" value="{{$_POST.sPass2}}" class="input" id="register-password2" /></td>
				</tr>
			</table>
		</fieldset>
	</div>
	<div class="block50 register_rules">
		{{if isset($sRulesLink)}}
			<fieldset id="rules" style="margin-bottom: 10px;">
				<input type="checkbox" class="checkbox" name="iRulesAccept" value="1" alt="{{$lang.Require_rules_accept}}" id="rules-accept" />
				<label for="rules-accept">{{$lang.Rules_accept}} <a href="{{$sRulesLink}}">{{$lang.rules_read}}</a>.</label>
			</fieldset>
		{{/if}}
		
		<fieldset id="rules-confirm-box" style="margin-bottom: 10px;">
			<input type="checkbox" class="checkbox" name="iRulesAccept2" value="1" alt="{{$lang.Require_rules2_accept}}" id="rules-confirm" />
			<label for="rules-confirm">{{$lang.Rules2_accept}}</label>
		</fieldset>
		
		<fieldset id="newsletter-agreement">
			<input type="checkbox" class="checkbox" name="iNewsletterAccept" value="1" id="newsletter-accept" />
			<label for="newsletter-accept">{{$lang.Newsletter_accept}}</label>
		</fieldset>
		<fieldset>
			<input type="submit" id="register_submit" value="{{$lang.Register}}" name="sRegister" class="submit submit-styled reCaptcha" id="register" />
		</fieldset>
	</div>
</form>