function login(){

	//remove all the class add the messagebox classes and start fading
	$("#msgbox").removeClass().addClass('messagebox').text('Login....').fadeIn(1000);
	//check the username exists or not from ajax

	$.post("php/login_ajax.php",{ user_name:$('#user_name').val(),password:$('#password').val(),rand:Math.random() } ,function(data)
        { 
	//alert(data);
		if(data=='yes') //if correct login detail
		{
			$("#msgbox").fadeTo(200,0.1,function()  //start fading the messagebox
			{ 
				//add message and change the class of the box and start fading
				$(this).html('&nbsp;&nbsp;login.....').addClass('messageboxok').fadeTo(900,1,
			      	function()
				{ 
					//redirect to secure page
					document.location='index.php';
				});
				  
			});
		}else{
			$("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
			{ 
				//add message and change the class of the box and start fading
				$(this).html('&nbsp;&nbsp;Errore, reinserire dati').addClass('messageboxerror').fadeTo(900,1);
			});		
		};
				
	 return false; //not to post the  form physically
	});

	//now call the ajax also focus move from 
	$("#password").blur(function()
	{
		$("#form_login").trigger('submit');
	});

};

