function SubmitContact(module) {
	if ($('#name').val().length <= 0) {
		DisplayError($('#contact_form_error'), 'Name must be filled.');
		$('#name').focus();
		return false;
	}
	if ($('#email').val().length <= 0) {
		DisplayError($('#contact_form_error'), 'Email address must be filled.');
		$('#email').focus();
		return false;
	}
	if (ValidateEmail($('#email').val()) === false) {
		DisplayError($('#contact_form_error'), 'Invalid email address.');
		$('#email').focus();
		return false;
	}
	if ($('#message').val().length <= 0) {
		DisplayError($('#contact_form_error'), 'Message must be filled.');
		$('#message').focus();
		return false;
	}

	if ($('#captcha').val().length <= 0) {
		DisplayError($('#contact_form_error'), 'Sum result must be filled.');
		$('#captcha').focus();
		return false;
	}

	DeasactiveForm('#contact_form');
	$.ajax({
		type: 'POST',
		url: $('#contact_form').attr('action'),
		data: $('#contact_form').serialize(),
		success: function(msg) {
			ActiveForm('#contact_form');
			if (msg.indexOf('error:') > -1) {
				DisplayError($('#contact_form_error'), msg);
			} else {
				DisplayMsg('Message sent.', 'Thanks for your message !<br>We will read it and you will get an answer shortly via your email address.');
			}
		}
	});
}

function ChangeTo(module, key) {
	if (module == '') {
		module = 'contact';
	}
	if (key !== null) {
		requestUrl = 'contact/'+module+'/media/'+key+'/xhr';
	} else {
		requestUrl = 'contact/'+module+'/xhr';
	}
	$('#content').block({ message: null, overlayCSS: { backgroundColor: '#FFF' }  });
	$.ajax({
		url: '/',
		data: requestUrl,
		success: function(msg){
			$('#content').unblock();
			$('#content').html(msg);
			UpdateInterface();
			UpdateMenuLink(module);
			if (module == 'donate') {
				$('label.cur_select').click(function() {
					$('form input[name="currency_code"]').attr('value', $(this).find('input').attr('value'));
					$('form input[name="amount"]:text').focus();
				});
			}
		}
	});
}

function customHistory(hash) {
	var tableau=hash.split('/');
	if (tableau.length == 1) {
		ChangeTo(tableau[0]);
	} else if (tableau.length == 3) {
		ChangeTo(tableau[0], tableau[2]);
	}
}

function SubmitDonation() {
	DisplayMsg('Donation sent.', 'Thank you for your generosity !<br>People like you make it possible for us to continue spread good vibes aroung the globe.');
}
