$(document).ready(function() {
		$("#login").submit(function(){
		var user = $("#username").val();
		var pass = $("#password").val();
        //remove all the class add the messagebox classes and start fading
        $("#msgbox").removeClass().addClass('messagebox').text('Validating....').fadeIn(500);
        //check the username exists or not from ajax
        $.ajax({
			type : 'POST',
			url : '/admin/login.php',
			data: { login: user, passwd: pass},
			success: function(data) {
				if(data == 1) {
				
					$("#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 in.....').addClass('messageboxok').fadeTo(500,1,
	                  function() {
	                     document.location.href='http://www.bookbormio.com/admin/index.html';
	                  });
	                });
				}
				else if(data == 2) {
				
					$("#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 in.....').addClass('messageboxok').fadeTo(500,1,
	                  function() {
	                     document.location.href='http://www.bookbormio.com/hotel/index.html';
	                  });
	                });
				}
				else if(data == 3) {
				
					$("#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 in.....').addClass('messageboxok').fadeTo(500,1,
	                  function() {
	                     document.location.href='http://www.bookbormio.com/media/index.html';
	                  });
	                });
				}
				else {
					$("#msgbox").fadeTo(200,0.1,function(){
						$(this).html('Wrong username/password').addClass('messageboxerror').fadeTo(500,1,function() {$(this).fadeOut('3000')});
					});
				}
			},
			error: function(XMLHttpRequest, textStatus, errorThrown) {
				$("#msgbox").fadeTo(200,0.1,function(){
						$(this).html('erron in AJAX code!ask webmaster!').addClass('messageboxerror').fadeTo(500,1);
				});
			}
		});
        
       return false;//not to post the  form physically
	});
});