$(document).ready(function()
{
	$("#email").blur(function()
	{
		//remove all the class add the messagebox classes and start fading
		$("#msgbox").removeClass().addClass('userBox').text('Checking Availability...').fadeIn("slow");
		//check the username exists or not from ajax
		$.post("../Tools/ajax/check-user-name.php",{ user_name:$(this).val() } ,function(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('Email already exists').addClass('user_error').fadeTo(900,1);
			});
			
			//document.trd_reg_step2.reg.disabled=true;
          }
		  else
		  {
		  	$("#msgbox").fadeTo(200,0.0,function()  //start fading the messagebox
			{ 
			  //add message and change the class of the box and start fading
			  $(this).html('Email available to register').addClass('user_ok').fadeTo(900,1);	
			});
			//document.trd_reg_step2.reg.disabled=false;
		  }
				
        });
 
	});
});
