<h1>
	{{title}}
</h1>
<form id="register">
	<div>
		Email: <input name="email" type="text"/>
	</div>
	<div>
		Username: <input name="username" type="text"/>
	</div>
	<div>
		Password: <input name="password" type="password"/>
	</div>
	<div>
		Verify Password: <input name="password1" type="password"/>
	</div>
	<div>
		<image id="captcha" src="index.php?get=captcha"/>
		<br/>
		Captcha: <input name="captcha" type="text"/>
	</div>
	<input type="submit" value="register"/>
	<input type="button" value="cancel" class="cancel"/>
</form>
<script>
	{{#if key}}
		History.back();
	{{else}}
		$('form#register').submit(function(){
			var data = $(this).serializeObject(),
					State = History.getState();
				for(var i in State.data){
					data[i] = State.data;
				}
				data.type = 'action';
				data.id = 'register';
				apiCall(data,function(d){
					if(!d.error){
						setKey(d.key);
						loadState('page-index');
					}else{
						setKey(null);
						$('#captcha').attr('src','index.php?get=captcha&timestamp='+new Date);
						$('#loading').hide();
					}
				});
			return false;
		}).children('.cancel').click(function(){
			History.back();
			return false;
		});
	{{/if}}
</script>