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

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

// When the form is submitted
$("#status > 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: "/includes/do-login.php",  // Send the login info to this page
    data: str,  
    success: function(msg){  
   
$("#status").ajaxComplete(function(event, request, settings){  
 
	 // Show 'Submit' Button
	$('#submit').show();

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

	 if(msg == 'OK') // LOGIN OK?
	 {  
	 var login_response = '';  

	$(this).html(login_response); // Refers to 'status'

	// After 1 second redirect the 
//	setTimeout('go_to_private_page()', 1000); 
	setTimeout('', 500); 
	parent.location = 'catalog.php';
	
	}  
	else // ERROR?
	{  
		 var login_response = msg;
		 $('#login_response').html(login_response);
	}  
      
});  
   
 }  
   
  });  
  
// -- End AJAX Call --

return false;

}); // end submit event

});

function go_to_private_page()
{
// parent.$.fn.ceebox.closebox();
// parent.location.reload(1);
parent.$(parent.document).location = 'catalog.php';

}
