//<!---------------------------------+
//  Visit http://roshanbh.com.np for this script and more.
// --------------------------------->
$(document).ready(function()
{
	$("#email_account").blur(function()
	{
		//remove all the class add the messagebox classes and start fading
		$("#msgbox").removeClass().addClass('messagebox').text('Verificando disponibilidad...').fadeIn("slow");
		//check the username exists or not from ajax
		$.post("includes/scripts/checkemail.php",{ cuenta:$(this).val() } ,function(data)
        {
		  if(data=='1') //if username not available
		  {
		  	$("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
			{ 
			  //add message and change the class of the box and start fading
			  $(this).html('El email ya existe en la base de datos.<input name=allow type=hidden>').addClass('messageboxerror').fadeTo(900,1);
			});		
          }
		  if(data=='2') {
		  	$("#msgbox").fadeTo(200,0.1,function()  //start fading the messagebox
			{ 
			  //add message and change the class of the box and start fading
			  $(this).html('Por favor, ingrese un email valido.<input name=allow type=hidden>').addClass('messageboxerror').fadeTo(900,1);	
			});
		  }
		if(data=='0') {
		  	$("#msgbox").fadeTo(200,0.1,function()  //start fading the messagebox
			{ 
			  //add message and change the class of the box and start fading
			  $(this).html('Este email esta disponible para registro.<input name=allow type=hidden value=1 >').addClass('messageboxok').fadeTo(900,1);	
			});
		  }


				
        });
 
	});
});
