

          
function EnvoiFerme()
{
	
	
		 $(".formContainer2 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");}
			})
		 $(".formContainer2 textarea").each(function()
			{
				var text = $(this).attr("value");
				if ($(this).attr("id") == 'txtMessage')
				{FFmessage = nl2br(text);}
			})
		 

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

    setTimeout('$("#contactForm2").slideUp("slow");$("#messageEnvoye").show("slow");', 2000);
}
/**/
$(document).ready(function(){
            $(".formContainer2 input[type=text]").focus(function(){
                $(this).parent().find(".error").css("display", "none");
                
            }).blur(function(){
                $(this).parent().find(".info").css("display", "none");
				$(this).parent().find(".ok").css("display", "none");
            });
			
			$(".formContainer2 textarea").focus(function(){
                $(this).parent().find(".error").css("display", "none");

            }).blur(function(){
                $(this).parent().find(".info").css("display", "none");
				$(this).parent().find(".ok").css("display", "none");
            });
        });
        
function verifdonnees()
        {
			valide = 'oui';
            $(".formContainer2 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';
                	}
					else
					{
						$(this).parent().find(".ok").css("display", "block");
					}
				}
				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';
					}
					else
					{
						$(this).parent().find(".ok").css("display", "block");	
					}
				}
				if ($(this).attr("id") == 'txtTel')
				{
						$(this).parent().find(".ok").css("display", "block");
				}
				
            });
			
			 $(".formContainer2 textarea").each(function()
			{
                var text = $(this).attr("value");
                if (text == "")
                {
                    $(this).parent().find(".error").css("display", "block");
					valide = 'non';
                }
				else
				{
					$(this).parent().find(".ok").css("display", "block");	
				}
			});	
				
			if (valide == 'oui')
			{
				EnvoiFerme();
			}
        }
        
		
        function clearForm()
        {
            $(".formContainer2 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');
}
