$(document).ready(function(){


    $("input:text, textarea, input:password").each(function(){
        if(this.value == '')
            this.value = this.title;
         	this.style.color="#6c6b6b"; 
        
    });
    $("input:text, textarea, input:password").focus(function(){
        if(this.value == this.title)
            this.value = ''; 
            this.style.color="#3c5b68";
            this.style.fontStyle="normal";
         	
    });
    
    
    
    $("input:text, textarea, input:password").blur(function(){
        if(this.title == ''){
            this.style.color="black";
            
        }
        if(this.value == ''){
            this.value = this.title;
         	this.style.color="#6c6b6b"; 
            this.style.fontStyle="italic";
        }
 	});
 	
    $("input:focus").click(function(){
        if(this.type =='text' || this.type =='textarea' || this.type =='password' ){
          if(this.value == this.title && this.title != ''){
               this.value='';
               
           }
        }
    });
});

function validation() 
			{ 

       		var nom = document.getElementById("msg_form").nom.value;
       		var prenom = document.getElementById("msg_form").prenom.value;
       		var email = document.getElementById("msg_form").email.value;
       		var message = document.getElementById("msg_form").message.value;
       		var sujet = document.getElementById("msg_form").sujet.value;
       		var compteur = 0;
			var somme = 0;

       		if (nom.search(/[A-Za-z0-9$_+!*();/?:~-]+[a-zA-Z0-9]+[a-zA-Z0-9]$/) == -1)
       		
        	{ 
        	
					alert(nom.search(/[A-Za-z0-9$_+!*();/?:~-]+[a-zA-Z0-9]+[a-zA-Z0-9]$/));
        	$("#war1").fadeIn(400);
        	
        	compteur++;
        	
        	somme+=compteur;
        	
         	}

        	else{
        	
        	$("#war1").fadeOut(400);
        	
        	}
        	
        	if (prenom.search(/[A-Za-z0-9$_+!*();/?:~-]+[a-zA-Z0-9]+[a-zA-Z0-9]$/) == -1)
       		
        	{ 
        	
        	$("#war2").fadeIn(400);
        	
        	compteur++;
        	
        	somme+=compteur;
        	
         	}

        	else{
        	
        	$("#war2").fadeOut(400);
        	
        	}

       		
			
        	if (email.search(/^[^._-][a-z0-9._-]+[^._-]@[a-z0-9._-]+([a-z0-9]+[^._-])?[.-]+[a-z]{2,4}$/) == -1)
        	
			{
			
			$("#war3").fadeIn(400);
			
			compteur++;
			
        	somme+=compteur;
        	
        	} 
        	
        	else{
        	
        	$("#war3").fadeOut(400);
        	
        	}
       		
			if (sujet.length < 12)
			
			{
			
			$("#war4").fadeIn(400);
			
			compteur++;
			
        	somme+=compteur;
        	
        	} 
        	
        	else{
        	
        	$("#war4").fadeOut(400);
        	
        	}
        	
			if (message.length < 18)
			{
			
			$("#war5").fadeIn(400);
			
			compteur++;
			
        	somme+=compteur;
			
        	} 
        	
        	else{
        	
        	$("#war5").fadeOut(400);
        	
        	}
        	
       		if (compteur == 0 )
       		
			{
			
			return true;
			
			}
			
			else
			
			{
			
			return false;
			
			}
}
			
