$(document).ready(function() {
	
		$('a.take_a_look_around, a[href=#done]').click(function() {
			parent.closeLanding();
			return false;
		});
		
		
		// Preserve Return Key - hiding submit using alt. method
		$('input.to_replace_alt').css('position', 'absolute');
		$('input.to_replace_alt').css('margin-left', '-100em');
		
		$('a.button.replacement').click(function() {
			$($(this).attr('href')).click();
			return false;
		});
		
		// Forgotten password mode
		$('a[href=#forgotten_login]').click(function() {
			$('#login_normal').hide();
			$('#forgotten_password').show();
			$('#forgotten_password input[name="email_address"]').focus();
			return false;
		});
		
		// Prevent submission via return key
		$('#forgotten_password form').submit(function() {
			return false;
		});
		
		// Normal login mode
		$('a[href=#back_login_normal]').click(function() {
			$('#login_normal').show();
			$('#forgotten_password').hide();
			return false;
		});
		
		// Reset password action
		$('a[href="#reset_password"]').click(function() {
		
			var email_address = $('#forgotten_password input[name=email_address]').val();
			
			if (email_address != '') {
			
				$.post("/account/settings/forgotten_password/request_handlers/email_token.php", { email: email_address }, function(data){
					if (data == 'done') {
					
						$('#forgotten_password_started').show();
						$('#forgotten_password').hide();
					
					} else {
						
						$('#forgotten_password_retry').show();
						$('#forgotten_password').hide();
						
					}
				});
			
			} else {
				
				$('#forgotten_password_retry').show();
				$('#forgotten_password').hide();
				
			}

			return false;
			
		});
		
		$('a[href=#try_again]').click(function() {
			$('#forgotten_password_retry').hide();
			$('#forgotten_password').show();
			return false;
		});
		
		
	
});