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

$(document).ready(function(){

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

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

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

	if(msg == 'OK')
	{ 
        $("#serialno").removeClass('object_error'); // if necessary
		$("#serialno").addClass("object_ok");
		$(this).html('&nbsp;<img src="images/alert.png" align="absmiddle"> <font color="red">Already Taken </font>  ');
	}  
	else  
	{  
		$("#serialno").removeClass('object_ok'); // if necessary
		$("#serialno").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");
	}

});

});