var login = {
	go: function() {
		$('#loginIncorrect').slideUp('slow');
		$.ajax({
	        type:   	'post',
	        url:    	'/backend/authentication/login',
			dataType: 	'json',
			data:       $('#loginForm').serialize() + '&fromLoginPage=true',
	        success: 	function(response) {
				if (response.result.login == true) {
					window.location = '/backend/dashboard';
				} else {
					if (parseInt(response.result.loginErrorCode) == -3) {
						$('#loginIncorrect').html('You a not owner of this subdomain and can not sign in here.');
					} else if (parseInt(response.result.loginErrorCode) == -2) {
						$('#loginIncorrect').html('You a not owner of this subdomain and can not sign in here. Use this <a href="http://rezpondr.com/backend/authentication/login">form for sign in</a>');
					} else {
						$('#loginIncorrect').html('Login incorrect');
					}
					
					$('#loginIncorrect').slideDown('slow');
				}
			},
		});
	},
	remind: function() {
		var email = prompt('Please provide your email address:', '');
		if (email == '') {
			alert('You should provide valid email address');
		} else if (email == null) {
			return; // action canceled
		} else {
			$.ajax({
	        	type:   	'post',
	        	url:    	'/backend/authentication/forgotten',
				dataType: 	'json',
				data:       'email=' + email,
	        	success: 	function(response) {
					if (!checkServerResponse(response)) { return; }
					if (response.errors) {
						alert(response.errors);
					} else {
						alert('Check out your email box for password reminder email');
					}
				},
			});
		}
	},
};