// JavaScript Document
pic1 = new Image(16, 16); 
pic1.src = "images/ajax-loader.gif";

$(document).ready(function(){

$("#username").change(function() { 

var username = $("#username").val();
//var usr = $("#serialno").val();
var usr=username;
//alert(rollno);
if(usr.length >= 1)
{
$("#ustatus").html('<img src="images/ajax-loader.gif" align="absmiddle">&nbsp;Checking availability...');

    $.ajax({  
    type: "POST",  
    url: "checkLogin.php",  
    data: "usr="+ usr,  
    success: function(msg){ 
	//alert(msg);
    $("#ustatus").ajaxComplete(function(event, request, settings){ 

	if(msg == 'OK')
	{ 
        $("#username").removeClass('object_error'); // if necessary
		$("#username").addClass("object_ok");
		$(this).html('&nbsp;<img src="images/alert.png" align="absmiddle"> <font color="red">Already Taken </font>  ');
	}  
	else  
	{  
		$("#username").removeClass('object_ok'); // if necessary
		$("#username").addClass("object_error");
		$(this).html('&nbsp;<img src="images/accepted.png" align="absmiddle"> <font color="Green">Available </font>  ');
	}  
   
   });

 } 
   
  }); 

}
else
	{
	$("#status").html('<font color="red">The username should have at least <strong>1</strong> characters.</font>');
	$("#serialno").removeClass('object_ok'); // if necessary
	$("#serialno").addClass("object_error");
	}

});

});