$(document).ready(function()
{

$("a.logout").click(function() {
	//$.post("ajax_logout.php");
	$("#msgbox").removeClass().addClass('messagebox').text('loading....').fadeIn(500);
		//check the username exists or not from ajax
		$.post("http://localhost/invent/ajax_logout.php",{ rand:Math.random() } ,function(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('Logging off.....').addClass('messageboxok').fadeTo(900,1,
              function()
			  { 
			  	 //redirect to secure page
				 window.location.reload( false );
			  });	  
			});
		  }

		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('logout failed').addClass('messageboxerror').fadeTo(900,1);
			});		
          }
				
        });
 		return false; //not to post the  form physically
});

});