$(document).ready(function(){
	$("#login_form").submit(function()	{
		$("#msgbox").removeClass().addClass('messagebox').text('Validation en cours....').fadeIn(1000);
		$.post("ajax_login.php",{ dcomp_login:$('#dcomp_login').val(),dcomp_pass:$('#dcomp_pass').val(),rand:Math.random() } ,function(data){
		  if(data=='yes'){
		  	$("#msgbox").fadeTo(200,0.1,function()  { 
			  //add message and change the class of the box and start fading
			  $(this).html('Connexion..... vous allez être redirigé(e)').addClass('messageboxok').fadeTo(900,1,
              function(){ 
				 document.location='admin-upload/index.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 
	$("#dcomp_pass").blur(function(){
		$("#login_form").trigger('submit');
	});
});

