// JavaScript Document


//email availabilty showing
$(document).ready(function()
{
	$("#email").blur(function()
	{
		//remove all the class add the messagebox classes and start fading
		$("#email_msg_box").removeClass().addClass('messagebox').text('Checking...').fadeIn("slow");
		//check the username exists or not from ajax
		$.post("includes/email_available.php",{ email:$(this).val() } ,function(data)
        {
		  if(data=='no') //if username not avaiable
		  {
		  	$("#email_msg_box").fadeTo(200,0.1,function() //start fading the messagebox
			{ 
			  //add message and change the class of the box and start fading
			  $(this).html('This Email Already exists').addClass('messageboxerror').fadeTo(900,1);
			});		
          }
		  else
		  {
		  	$("#email_msg_box").fadeTo(200,0.1,function()  //start fading the messagebox
			{ 
			  //add message and change the class of the box and start fading
			  $(this).html('Email available to register').addClass('messageboxok').fadeTo(900,1);	
			});
		  }
				
        });
 
	});
});
