/*##############################################################################
New account functions
##############################################################################*/

// parse registration data
function doSend() {
	var checkEmail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	var email = $('#email').val();
	var error = false;
	var errorText = '';

	if (!checkEmail.test(email) || email == '') {
		$('#email').addClass('wrong');
		error = true;
		text = LANG == 'ro' ? 'Email incorect.' : 'Wrong email.';
		errorText += '<li>'+text+'</li>';
	}
	if (!error) {
		$('#contactForm').submit();
		return true;
	} else {
		$('#wrongData').html(errorText);
		$('#wrongData').slideDown('fast');
	}
	return false;
}


$('document').ready(function() {
	
	$('#email').click(function() {
		$(this).removeClass('wrong');
	});

	$('#contactForm').submit(function() {
		if ($('#wrongData').attr('style') == 'display: block;') {
			$('#wrongData').slideUp('fast');
			doSend();
		}
	});
	$('#sendMessage').click(function() {
		doSend();
	});
});
