 $(document).ready(function()
  {


$("#msgbox").html ('Waiting for data ... ');
$("#code").blur(function()
{
 //remove all the class add the messagebox classes and start fading
 //$("#msgbox").removeClass().addClass('messagebox').text('Checking...').fadeIn("slow");
 $("#msgbox").addClass('messagebox').text('Checking...').fadeIn("slow");
 //check the username exists or not from ajax
 $.post("/cp/exist",{ user_name:$("input#login").val() } ,function(data)
 {
    //alert ( data );
// $('#msgbox').ajaxForm(function(data) { alert(data); } );
 
  if(data=='no') //if username not avaiable
  {
   $("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
   {
    //add message and change the class of the box and start fading
    $(this).html('User not exist').addClass('messageboxerror').fadeTo(900,1);
   });
  }
  else
  {
   $("#msgbox").fadeTo(200,0.1,function()  //start fading the messagebox
   {
    //add message and change the class of the box and start fading
	if ( $("input#code").val() == $("#origin").text() ) {
	$(this).html( 'You can Login').addClass('messageboxok').fadeTo(900,1);
	//alert ( data );
	$("#submit").removeAttr("disabled");
	} else { 
	    $("#submit").attr("disabled","disabled");
	    $("#msgbox").fadeTo(200,0.1,function() {
		$(this).html('Please login').addClass('messageboxerror').fadeTo(900,1);
		});
	    }
   });
  }
 });
});



});