// Preload Images
img1 = new Image(16, 16);  
img1.src="http://www.netradio.fr/includes/plugins/dedicaces/ajout/images/spinner.gif";

img2 = new Image(220, 19);  
img2.src="http://www.netradio.fr/includes/plugins/dedicaces/ajout/images/ajax-loader.gif";

// When DOM is ready
$(document).ready(function(){

// Launch MODAL BOX if the Login Link is clicked
$("#login_link").click(function(){
$('#login_form').modal();
});

$("#login_link_menu").click(function(){
$('#login_form').modal();
});

// When the form is submitted
$("#formulaire_dedicaces > form").submit(function(){  

// Hide 'Submit' Button
$('#submit').hide();

// Show Gif Spinning Rotator
$('#ajax_loading_mpperdu').show();

// 'this' refers to the current submitted form  
var str = $(this).serialize();  

// -- Start AJAX Call --

$.ajax({  
    type: "POST",
    url: "http://www.netradio.fr/includes/plugins/dedicaces/ajout/do-login.php",  // Send the login info to this page
    data: str,  
    success: function(msg){  
   
$("#formulaire_dedicaces").ajaxComplete(function(event, request, settings){  
 
 // Show 'Submit' Button
$('#submit').show();

// Hide Gif Spinning Rotator
$('#ajax_loading_mpperdu').hide();  

 if(msg == 'OK') // LOGIN OK?
 {  
 var login_response_dedicace = '' +
	 '<div style="text-align:center; color:#006600; font-weight:bold; margin-top:10px;">' + 
	 "Votre dédicace à été ajoutée avec succès. Elle est actuellement en attente d'approbation !</div>";  

$('a.modalCloseImg').hide();  

$('#simplemodal-container').css("width","500px");
$('#simplemodal-container').css("height","120px");
 
 $(this).html(login_response_dedicace); // Refers to 'mpperdu'

// After 3 seconds redirect the 
setTimeout('affichermessage()', 3000); 
 }  
 else // ERROR?
 {  
 var login_response_dedicace = msg;
 $('#login_response_dedicace').html(login_response_dedicace);
 }  
      
 });  
   
 }  
   
  });  
  
// -- End AJAX Call --

return false;

}); // end submit event

});


