//Validation form
$(document).ready(function(){
	$("#login_form").submit(function()	{
		$("#msgbox").removeClass().addClass('messagebox').text('Validation en cours....').fadeIn(1000);
		$.post("inc/ajax_login.php",{ logine:$('#logine').val(),passeworde:$('#passeworde').val(),rand:Math.random() } ,function(data){
		  if(data=='yes'){
		  	$("#msgbox").fadeTo(200,0.1,function() {
			  $(this).html('Connexion..... vous allez être redirigé(e)').addClass('messageboxok').fadeTo(900,1,
              function(){
				 document.location='identification.php';
			  });	  
			});
		  }
		  else {
		  	$("#msgbox").fadeTo(200,0.1,function() { 
			  //add message and change the class of the box and start fading
			  $(this).html('Vos identifiants sont incorrects...').addClass('messageboxerror').fadeTo(900,1);
			});		
      }
    });
 		return false; //not to post the  form physically
	});
	//now call the ajax also focus move from 
	$("#user_pass").blur(function(){
		$("#login_form").trigger('submit');
	});
});

