


$(document).ready(function() {

	$("#login_form").submit(function()
	{
	        $("#msgbox").removeClass().addClass('messagebox').text('Please wait ...').fadeIn(1000);
	        //check the username exists or not from ajax
	        $.post("./com/check.php",{ username:$('#username').val(),password:$('#password').val(),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('Loading ...').addClass('messageboxok').fadeTo(900,1,
	                  function()
	                  {
	                     //redirect to secure page
	                     document.location='./com/frameset.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(data).addClass('messageboxerror').fadeTo(900,1);
	                });
	          }
	       });
	       return false;//not to post the  form physically
	});
	
});
