$(document).ready(function()
	{
		$("#forgot").submit(function()
		{
			// remove all the class add the messagebox classes and start fading
			$("#msgbox3").removeClass().addClass('messagebox').text('Checking email address...').fadeIn(1000);
			// check the data exists or not from ajax
			$.post("/do-recover.php",{ email:$('#forgot_email').val() },function(data)
			{
			  if(data=='sent') // if email checked successfully
			  {
				$("#msgbox3").fadeTo(200,0.1,function()  // start fading the messagebox
				{ 
				  //add message and change the class of the box and start fading
				  $(this).html('Login details request sent successfully').addClass('messageboxok').fadeTo(900,1);
				  setTimeout("window.location.reload()",2000);
				});
			  }
			  else if(data=='email-invalid')
			  {
				$("#msgbox3").fadeTo(200,0.1,function() //start fading the messagebox
				{ 
				  //add message and change the class of the box and start fading
				  $(this).html('That does not appear to be a valid email address!').addClass('messageboxerror').fadeTo(900,1);
				});		
			  }
			  else if(data=='no-info')
			  {
				$("#msgbox3").fadeTo(200,0.1,function() //start fading the messagebox
				{ 
				  //add message and change the class of the box and start fading
				  $(this).html('Please enter an email address!').addClass('messageboxerror').fadeTo(900,1);
				});		
			  }
			  else if(data=='no-email')
			  {
				$("#msgbox3").fadeTo(200,0.1,function() //start fading the messagebox
				{ 
				  //add message and change the class of the box and start fading
				  $(this).html('Sorry, that email does not match any in our records').addClass('messageboxerror').fadeTo(900,1);
				});		
			  }
			});
			return false; // not to post the form physically
		});
	});
