
$(document).ready(function(){ 

	$("#email").blur(function()
	 {
	   if (validateField('email','emailbox','email',1) == false)
	   {
		retVal = false ;
	   }
	   else 
	   {
			  //remove all the class add the messagebox classes and start fading
			  
			  $("#msgbox").removeClass().addClass('messagebox').text('Checking...').fadeIn("slow");
			  //check the username exists or not from ajax
			  
			  $.post("email_availability.php",{ email:$(this).val() } ,function(data)
				{
					if(data=='no') //if username not avaiable
					{
						$("#msgbox").fadeTo(200,0.1,function() {$(this).html('This Email already exists in our database').addClass('messageboxerror').fadeTo(900,1);});  
					}
					else
					{
						$("#msgbox").fadeTo(200,0.1,function() {$(this).html('Email available to register').addClass('messageboxok').fadeTo(900,1);});
					}
				});
		}
	});

});
