// Preload Images
img1 = new Image(16, 16);
img1.src="images/spinner.gif";

img2 = new Image(220, 19);
img2.src="images/ajax-loader.gif";

// When DOM is ready
$(document).ready(function(){

// Launch MODAL BOX if the Login Link is clicked
$("#login_link").click(function(){
$('#mlist_form').modal();
});

// When the form is submitted
$("#condition > form").submit(function(){

// Hide 'Submit' Button
$('#submitml').hide();

// Show Gif Spinning Rotator
$('#ajax_loading-mlist').show();

// 'this' refers to the current submitted form
var str = $(this).serialize();

// -- Start AJAX Call --

$.ajax({
    type: "POST",
    url: "do-mlist.php",  // Send the login info to this page
    data: str,
    success: function(msg){

$("#condition").ajaxComplete(function(event, request, settings){

 // Show 'Submit' Button
$('#submitml').show();

// Hide Gif Spinning Rotator
$('#ajax_loading-mlist').hide();

 if(msg == 'OK') // LOGIN OK?
 {
 var mlist_response= '<div id="logged_in">' +
	 '<div style="width: 100px; float: center; margin-center: 0px;">' +
	 '<div style="width: 55 px; float: left;">' +
	 '<img style="margin: 0px 0px 10px 0px;" align="center" src="images/ajax-loader.gif">' +
	 '</div>' +

	 '<div style="margin:16px; float: center; width: 85px;">'+
	 "تجربة ناجحة<br /> الرجاء الإ نتظارسيتم تحويلك</div></div>";




 $(this).html(mlist_response); // Refers to 'condition'

// After 3 seconds redirect the
setTimeout('go_to_private_page()', 3000);
 }
 if(msg == 'LOG') // LOGIN OK?
 {


 var mlist_response= '<div id="logged_in">' +
	 '<div style="width: 100px; float: center; margin-left: 0px;">' +
	 '<div style="width: 55px; float: left;">' +
	 '<img style="margin: 0px 0px 10px 0px;" align="center" src="images/ajax-loader.gif">' +
	 '</div>' +
	 '<div style="margin: 0px 0px 0px 1px; float: center; width: 95px;">'+
	 "لقد تم تسجيل الخروج بنجاح <br /> الرجاء الإ نتظارسيتم تحويلك</div></div>";




 $(this).html(mlist_response); // Refers to 'condition'

// After 3 seconds redirect the
setTimeout('go_to_private_page()', 3000);
 }








 else // ERROR?
 {
 var mlist_response= msg;
 $('#mlist_response').html(mlist_response);
 }

 });

 }

  });

// -- End AJAX Call --

return false;

}); // end submit event

});

function go_to_private_page()
{
window.location = 'index.php'; // Members Area
}
