//<!---------------------------------+
//  Developed by Roshan Bhattarai 
//  Visit http://roshanbh.com.np for this script and more.
//  This notice MUST stay intact for legal use
// --------------------------------->
$j(document).ready(function()
{
	$j("#username").blur(function()
	{
		//remove all the class add the messagebox classes and start fading
		$j("#msgbox").removeClass().addClass('messagebox').text('').fadeIn("fast"); //text('Checking...')
		//check the username exists or not from ajax
		$j.post("http://www.reggaelution.com/includes/user_availability.php",{ username:$j(this).val() } ,function(data)
        {
		  if(data=='no') //if username not avaiable
		  {
		  	$j("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
			{ 
			  //add message and change the class of the box and start fading
			  $j(this).html('Username taken').addClass('messageboxerror').fadeTo(900,1);
			});		
          }
		  else if(data=='yes')
		  {
		  	$j("#msgbox").fadeTo(200,0.1,function()  //start fading the messagebox
			{ 
			  //add message and change the class of the box and start fading
			  $j(this).html('Username available').addClass('messageboxok').fadeTo(900,1);	
			});
		  }
		  
		  
		   else if(data=='errors')
		  {
		  	$j("#msgbox").fadeTo(200,0.1,function()  //start fading the messagebox
			{ 
			  //add message and change the class of the box and start fading
			  $j(this).html('').addClass('messageboxerror').fadeTo(900,1);	
			  //$j(this).html('There was an error.').addClass('messageboxerror').fadeTo(900,1);	
			});
		  }
				
        });
 
	});
});
