// 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(){
$('#gbook_form').modal();
});

// When the form is submitted
$("#statussss > form").submit(function(){

// Hide 'Submit' Button
$('#submit').hide();

// Show Gif Spinning Rotator
$('#ajax_loading-comment').show();

// 'this' refers to the current submitted form
var str = $(this).serialize();

// -- Start AJAX Call --

$.ajax({
    type: "POST",
    url: "do-gbook_form.php",  // Send the login info to this page
    data: str,
    success: function(msg){

$("#statussss").ajaxComplete(function(event, request, settings){

 // Show 'Submit' Button
$('#submit').show();

// Hide Gif Spinning Rotator
$('#ajax_loading-comment').hide();

 if(msg == 'OK') // LOGIN OK?
 {
 var gbook_response = '<div id="logged_in">' +'<div style="width: 100px; float: center; margin-center: 0px;">' +
	 '<div style="width: 109px; height:32px"><p align="center">' +

	 '</div>' +

	 '<div style="float: center; width: 109px;height:76px; margin-left:1px; margin-right:0px; margin-top:0px; margin-bottom:0px"><p align="center">'+
	 "شكرا للكتابة في دفتر الزوار سوف يتم نشر ماكتبت بعد موافقة الإدارة<br /> </div></div>";





 $(this).html(gbook_response); // Refers to 'statusss'

// After 3 seconds redirect the

 }
 if(msg == 'LOG') // LOGIN OK?
 {



 var gbook_response ='<div id="logged_in">' + '<div style="width: 100px; float: center; margin-center: 0px;">' +
	 '<div style="width: 109px; height:32px"><p align="center">' +
	 '<img style="margin: 0px 0px 10px 0px;" align="center" src="images/ajax-loader.gif" ' +
	 '</div>' +

	 '<div style="float: center; width: 109px;height:76px; margin-left:1px; margin-right:0px; margin-top:0px; margin-bottom:0px"><p align="center">'+
	 "لقد تم نشر التعليق <br /> الرجاء الإ نتظارسيتم تحويلك</div></div>";




 $(this).html(gbook_response); // Refers to 'statusss'

// After 3 seconds redirect the
setTimeout('go_to_private_page()', 3000);
 }








 else // ERROR?
 {
 var gbook_response = msg;
 $('#gbook_response').html(gbook_response);
 }

 });

 }

  });

// -- End AJAX Call --

return false;

}); // end submit event

});

function go_to_private_page()
{
window.location = 'index.php'; // Members Area
}
