/**/
$(document).ready(function(){
	$("#contactLink").click(function(){
	if ($("#contactForm").is(":hidden"))
	{
		$("#contactForm").slideDown("slow");
	}
    else
	{
    $("#contactForm").slideUp("slow");
    }
	});
              
});
          
function EnvoiFerme()
{
	
	
	//$('#formContactF').submit(
	//function()
	//{
		 $(".formContainer input").each(function()
			{
				var text = $(this).attr("value");
				if ($(this).attr("id") == 'txtNom')
				{FFnom = text;}
				if ($(this).attr("id") == 'txtTel')
				{FFtel = text;}
				if ($(this).attr("id") == 'txtEmail')
				{FFmail = text;}
				if ($(this).attr("id") == 'checkb')
				{FFcheck = $(this).attr("checked");}
			})
		 $(".formContainer textarea").each(function()
			{
				var text = $(this).attr("value");
				if ($(this).attr("id") == 'txtMessage')
				{FFmessage = nl2br(text);}
			})
		 
		 $("#messageEnvoye").show("slow");

		$.post('includes/envoimail.php', {FFnom:FFnom, FFtel:FFtel, FFmail:FFmail, FFmessage:FFmessage, FFcheck:FFcheck});

	//})
    setTimeout('$("#messageEnvoye").hide();$("#contactForm").slideUp("slow")', 2000);
}
/**/
$(document).ready(function(){
            $(".formContainer input[type=text]").focus(function(){
                $(this).parent().find(".error").css("display", "none");
                $(this).parent().find(".info").css("display", "block");
            }).blur(function(){
                $(this).parent().find(".info").css("display", "none");
            });
			
			$(".formContainer textarea").focus(function(){
                $(this).parent().find(".error").css("display", "none");
                $(this).parent().find(".info").css("display", "block");
            }).blur(function(){
                $(this).parent().find(".info").css("display", "none");
            });
        });
        
        function validateForm()
        {
			valide = 'oui';
            $(".formContainer input[type=text]").each(function()
			{
				var text = $(this).attr("value");
				if ($(this).attr("id") == 'txtNom')
				{
                	if (text == "")
                	{
                 	   $(this).parent().find(".error").css("display", "block");
						valide = 'non';
                	}
				}
				if ($(this).attr("id") == 'txtEmail')
				{
					var reg = /^([a-zA-Z0-9_-])+([.]?[a-zA-Z0-9_-]{1,})*@([a-zA-Z0-9-_]{2,}[.])+[a-zA-Z]{2,3}$/;
					if (reg.test(text) == false)
					{
						$(this).parent().find(".error").css("display", "block");
						valide = 'non';
					}
				}
				
            });
			
			 $(".formContainer textarea").each(function()
			{
                var text = $(this).attr("value");
                if (text == "")
                {
                    $(this).parent().find(".error").css("display", "block");
					valide = 'non';
                }
			});	
				
			if (valide == 'oui')
			{
				EnvoiFerme();
			}
        }
        
		
        function clearForm()
        {
            $(".formContainer input[type=text]").each(function(){
                $(this).parent().find(".error").css("display", "none");
            });
       }

function nl2br (str, is_xhtml) {
    // Converts newlines to HTML line breaks  
    // PHPjs.org |rien|true|false|
    // version: 905.3122
    // discuss at: http://phpjs.org/functions/nl2br

    var breakTag = '';

    breakTag = '<br />';
    if (typeof is_xhtml != 'undefined' && !is_xhtml) {
        breakTag = '<br>';
    }

    return (str + '').replace(/([^>]?)\n/g, '$1'+ breakTag +'\n');
}
