function accountLogIn() {
	jQuery.ajax({
		url:		'scripts/modules/account/login.php',
		type:		'POST',
		success:	function(response) {
						response=jQuery.parseJSON(response);
						jQuery('.error').hide();
						if(response.result=='success') {
							window.location.assign('http://'+domain+'/account');
							return;
						}
						if(response.result=='error') {
							for(var i=0;i<response.errors.length;++i)
								jQuery('#error_'+response.errors[i]).show();
						}
					},
		data:		({
						login:				jQuery('#login').val(),
						password:			jQuery('#password').val()
					})
	});
}

function accountLogInBlock() {
	jQuery.ajax({
		url:		'scripts/modules/account/login.php',
		type:		'POST',
		success:	function(response) {
						response=jQuery.parseJSON(response);
						jQuery('.error').hide();
						if(response.result=='success') {
							window.location.assign('http://'+domain+'/account');
							return;
						}
						if(response.result=='error') {
							window.location.assign('http://'+domain+'/account/login');
							return;
						}
					},
		data:		({
						login:				jQuery('#login_block').val(),
						password:			jQuery('#password_block').val()
					})
	});
}

function accountRegister() {
	jQuery.ajax({
		url:		'scripts/modules/account/register.php',
		type:		'POST',
		success:	function(response) {
						response=jQuery.parseJSON(response);
						jQuery('.error').hide();
						if(response.result=='success') {
							if(response.info=='activation') {
								jQuery('#register').hide();
								jQuery('#registered').show();
								return;
							}
							else {
								window.location.assign('http://'+domain+'/account');
								return;
							}
						}
						if(response.result=='error') {
							for(var i=0;i<response.errors.length;++i) {
								jQuery('#error_'+response.errors[i]).show();
								if(response.errors[i]=='captcha') {
									var stamp=new Date();
									jQuery('#captcha').attr('src','images/captcha.php?hash='+stamp.getMilliseconds());
									jQuery('#code').val('');
								}
							}
						}
					},
		data:		({
						login:				jQuery('#login').val(),
						password:			jQuery('#password').val(),
						password_repeat:	jQuery('#password_repeat').val(),
						email:				jQuery('#email').val(),
						newsletter:			jQuery('#newsletter').is(':checked') ? 1 : 0,
						captcha:			jQuery('#code').val()
					})
	});
}

function accountSettings() {
	jQuery.ajax({
		url:		'scripts/modules/account/settings.php',
		type:		'POST',
		success:	function(response) {
						response=jQuery.parseJSON(response);
						jQuery('.error').hide();
						if(response.result=='success') {
							jQuery('#update').hide();
							jQuery('#updated').show();
							return;
						}
						if(response.result=='error') {
							if(response.info=='access denied') {
								window.location.assign('http://'+domain+'/account/login');
								return;
							}
							for(var i=0;i<response.errors.length;++i)
								jQuery('#error_'+response.errors[i]).show();
						}
					},
		data:		({
						theme:				jQuery('#theme').val(),
						posts:				jQuery('#posts').val(),
						newsletter:			jQuery('#newsletter').is(':checked') ? 1 : 0,
						messages:			jQuery('#messages').is(':checked') ? 1 : 0,
					})
	});
}

function accountPassword() {
	jQuery.ajax({
		url:		'scripts/modules/account/password.php',
		type:		'POST',
		success:	function(response) {
						response=jQuery.parseJSON(response);
						jQuery('.error').hide();
						if(response.result=='success') {
							jQuery('#update').hide();
							jQuery('#updated').show();
							return;
						}
						if(response.result=='error') {
							if(response.info=='access denied') {
								window.location.assign('http://'+domain+'/account/login');
								return;
							}
							for(var i=0;i<response.errors.length;++i)
								jQuery('#error_'+response.errors[i]).show();
						}
					},
		data:		({
						password:			jQuery('#password').val(),
						password_repeat:	jQuery('#password_repeat').val(),
						password_old:		jQuery('#password_old').val()
					})
	});
}

function accountRecover() {
	jQuery.ajax({
		url:		'scripts/modules/account/recover.php',
		type:		'POST',
		success:	function(response) {
						response=jQuery.parseJSON(response);
						jQuery('.error').hide();
						if(response.result=='success') {
							if(response.info=='activation') {
								jQuery('#recover').hide();
								jQuery('#recovered').show();
								return;
							}
							else {
								window.location.assign('http://'+domain+'/account');
								return;
							}
						}
						if(response.result=='error') {
							for(var i=0;i<response.errors.length;++i) {
								jQuery('#error_'+response.errors[i]).show();
								if(response.errors[i]=='captcha') {
									var stamp=new Date();
									jQuery('#captcha').attr('src','images/captcha.php?hash='+stamp.getMilliseconds());
									jQuery('#code').val('');
								}
							}
						}
					},
		data:		({
						email:				jQuery('#email').val(),
						captcha:			jQuery('#code').val()
					})
	});
}
