// Preload Images
img1 = new Image(16, 16);  
img1.src="images/spinner.gif";

img2 = new Image(220, 19);  
img2.src="images/loader-bar.gif";

// When DOM is ready
$(document).ready(function(){

// Launch MODAL BOX if the Login Link is clicked
$("#lost_link").click(function(){
$('#lostpass_form').modal();
});

// When the form is submitted
$("#erea > form").submit(function(){
    
// Hide 'Submit' Button
$('#submit').hide();

// Show Gif Spinning Rotator
$('#ajax_loading').show();

// 'this' refers to the current submitted form  
var str = $(this).serialize();  

// -- Start AJAX Call --

$.ajax({  
    type: "POST",
    url: "sendpass.php",
    data: str,  
    success: function(msg){ 
   
$("#erea").ajaxComplete(function(event, request, settings){  
 
 // Show 'Submit' Button
$('#submit').show();

// Hide Gif Spinning Rotator
$('#ajax_loading').hide();  

 if(msg == 'OK') // LOGIN OK?
 {
 var pass_response = '<div id="logged_in">' +
	 '<div style="width: 250px; float: left; margin-left: 0px;">' + 
	 '<div style="width: 40px; float: left;">' +
	 '<img align="left" src="images/success.jpeg">' +
	 '</div>' +
	 '<div style="margin: 10px 0px 0px 10px; float: right; width: 200px;">'+ 
	 "کلمه عبور درخواستی به ایمیل شما ارسال شد</div></div>";  


$('#simplemodal-container').css("width","300px");
$('#simplemodal-container').css("height","140px");
 
 $(this).html(pass_response); // Refers to 'status'

// After 3 seconds redirect the 

 }
 else // ERROR?
 {  
 var pass_response = msg;
 $('#simplemodal-container').css("width","300px");
$('#simplemodal-container').css("height","150px");
 $('#pass_response').html(pass_response);
 }  
      
 });  
   
 }  
   
  });  
  
// -- End AJAX Call --

return false;

}); // end submit event

});

