$(document).ready(function(){
	$('.btContact').click(function (){
		toggle();
	});
	
	$('.email').keyup(function() {
		mel = $(this).val();
		if (check_email(mel))
		{
			$('.emailfback').html('<img src="images/succes.png" />');
			$(this).css('background-color','#333333');
			$(this).css('color','#999999');
			$(this).css('border','none');
		}
		else
		{
			$('.emailfback').html('<img src="images/error.png" />');
			$(this).css('background-color','#ffcccc');
			$(this).css('border','1px solid red');
			$(this).css('color','#000000');
		}
	});
	$('.required').blur(function() {
		valeur = $(this).val();
		cible = '.' + $(this).attr('name') + 'fback';
		if (valeur.length > 0)
		{
			$(cible).html('<img src="images/succes.png" />');
			$(this).css('background-color','#333333');
			$(this).css('color','#999999');
			$(this).css('border','none');
		}
		else
		{
			$(cible).html('<img src="images/error.png" />');
			$(this).css('background-color','#ffcccc');
			$(this).css('border','1px solid red');
			$(this).css('color','#000000');
		}
	});
});

function check_email(email)
{
	var e  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (e.test(email))
	{
		return true;
	}
	else
	{
		return false;
	}
}
function toggle() {
	if ($("#haut").is(':visible')){
		$("#forMore").css("bottom","200px");
		$("#forMore").show();
	}else {
		$("#forMore").hide();
		$("#forMore").css("bottom","-4px");
	}
	$('#haut, #bas').animate({
		height: 'toggle'
	}, 1000);
	
}


