//<!---------------------------------+
//  Developed by Roshan Bhattarai 
//  Visit http://roshanbh.com.np for this script and more.
//  This notice MUST stay intact for legal use
// --------------------------------->
$(document).ready(function()
{
	$("#email").blur(function()
	{
		//remove all the class add the messagebox classes and start fading
		$("#msgbox1").removeClass().addClass('messagebox').text('Checking...').fadeIn("slow");
		//check the username exists or not from ajax
		$.post("user_email_availability",{ email:$(this).val() } ,function(data)
        {
			if(data=='empty') //if username not avaiable
		  {
		  	$("#msgbox1").fadeTo(200,0.1,function() //start fading the messagebox
			{ 
			  //add message and change the class of the box and start fading
			  $(this).html('<font color="red">Enter Email</font>').addClass('messageboxerror1').fadeTo(900,1);
			});		
          }
		  else if(data=='no') //if username not avaiable
		  {
		  	$("#msgbox1").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('messageboxerror1').fadeTo(900,1);
			});		
          }
		  else
		  {
		  	$("#msgbox1").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 ').addClass('messageboxok1').fadeTo(900,1);	
			});
		  }
				
        });
 
	});
});

