// JavaScript Document
function verifFirebug() {
	if (console && "firebug" in console) {
	
	// afficher un message de mise en garde (ou de félicitations)
	$('alertfirebug').innerHTML='<div style="width:100%; color:white; background:red; text-align:center;">Attention ! Firebug emp\350che les captcha de fonctionner correctement.\n pensez \340 le d\351sactiver ou connectez vous avec un autre navigateur</div>';
}
}
/*******************************/
function sendAjaxForm(form, script, divcible){
  var url = 'ajax/'+script;
  
 // alert (form+'-'+script+'-'+divcible);
  
  lesvars = $(form).serialize(true); // retourne {param1: 'test', param2: 'test2'} 
 
 $('response').innerHTML = '';
  var myAjax = new Ajax.Request(
      url, 
      {
        method: 'post',
     asynchronous: false,
     contentType: 'application/x-www-form-urlencoded',
     encoding: 'UTF-8',
     parameters: lesvars,
		
         onLoading: function (xhr)
          { // Création de l'objet XHR
            $(divcible).innerHTML = '<img src="images/icons/loading.gif" />';
          },
    
        onSuccess: function (transport)
          { // Réponse HTTP == 2xx
			$(divcible).show(); 
			$('souhait').value='je veux '; 
            $(divcible).innerHTML = transport.responseText ;
            $('form_avantde').hide();  
			 verifFormV();
          },
        on404: function (xhr)
          { // Réponse HTTP "OK"
		  $(divcible).show(); 
            $(divcible).innerHTML = 'HTTP 404 "Not Found"<br /><br />';
          },
        onFailure: function (xhr)
          { // Réponse HTTP != 2xx
		  $(divcible).show(); 
            $(divcible).innerHTML = 'Failure : ' 
                + xhr.status + ' :' + xhr.statusText + '<br /><br />';
          },
        onException: function (xhr, exception)
          {
			  $(divcible).show(); 
            $(divcible).innerHTML = 'Exception : ' + exception + '<br />';
          }
      
 
      });
} // gestionClic()



function sendAjaxFormCmt(form, script, divcible){
  var url = 'ajax/'+script;
  
 // alert (form+'-'+script+'-'+divcible);
  
  lesvars = $(form).serialize(true); // retourne {param1: 'test', param2: 'test2'} 
 
 $('response_cmt').innerHTML = '';
  var myAjax2 = new Ajax.Request(
      url, 
      {
        method: 'post',
     asynchronous: false,
     contentType: 'application/x-www-form-urlencoded',
     encoding: 'UTF-8',
     parameters: lesvars,
		
         onLoading: function (xhr)
          { // Création de l'objet XHR
            $(divcible).innerHTML = '<img src="images/icons/loading.gif" />';
          },
    
        onSuccess: function (transport)
          { // Réponse HTTP == 2xx
			$(divcible).show(); 
			majCmt($('id').value, 'les_cmt', 'showcmt.php');
            $(divcible).innerHTML = transport.responseText ;
            $(form).hide();  
          },
        on404: function (xhr)
          { // Réponse HTTP "OK"
		  $(divcible).show(); 
            $(divcible).innerHTML = 'HTTP 404 "Not Found"<br /><br />';
          },
        onFailure: function (xhr)
          { // Réponse HTTP != 2xx
		  $(divcible).show(); 
            $(divcible).innerHTML = 'Failure : ' 
                + xhr.status + ' :' + xhr.statusText + '<br /><br />';
          },
        onException: function (xhr, exception)
          {
			  $(divcible).show(); 
            $(divcible).innerHTML = 'Exception : ' + exception + '<br />';
          }
      
 
      });
} // gestionClic()



/******************************/

function votePlus(id){
  var url = 'ajax/vote.php';
  
divcible = 'votePlus'+id;
 
 $(divcible).innerHTML = 'Vote en cours';
 
  var myAjax3 = new Ajax.Request(
      url, 
      {
        method: 'post',
     asynchronous: false,
     contentType: 'application/x-www-form-urlencoded',
     encoding: 'UTF-8',
     parameters: {'id': id, 'sens':1},
		
         onLoading: function (xhr)
          { // Création de l'objet XHR
           $(divcible).innerHTML = 'Vote en cours';
          },
    
        onSuccess: function (transport)
          { // Réponse HTTP == 2xx
			
			
            $(divcible).innerHTML = transport.responseText ;
           
          },
        on404: function (xhr)
          { // Réponse HTTP "OK"
		 
            $(divcible).innerHTML = 'HTTP 404 "Not Found"<br /><br />';
          },
        onFailure: function (xhr)
          { // Réponse HTTP != 2xx
		 
            $(divcible).innerHTML = 'Failure : ' 
                + xhr.status + ' :' + xhr.statusText + '<br /><br />';
          },
        onException: function (xhr, exception)
          {
			  $(divcible).show(); 
            $(divcible).innerHTML = 'Exception : ' + exception + '<br />';
          }
      
 
      });
}

function voteMoins(id){
  var url = 'ajax/vote.php';
  
divcible = 'voteMoins'+id;
 
 $(divcible).innerHTML = 'Vote en cours';
 
  var myAjax4 = new Ajax.Request(
      url, 
      {
        method: 'post',
     asynchronous: false,
     contentType: 'application/x-www-form-urlencoded',
     encoding: 'UTF-8',
     parameters: {'id': id, 'sens':0},
		
         onLoading: function (xhr)
          { // Création de l'objet XHR
           $(divcible).innerHTML = 'Vote en cours';
          },
    
        onSuccess: function (transport)
          { // Réponse HTTP == 2xx
			
			
            $(divcible).innerHTML = transport.responseText ;
           
          },
        on404: function (xhr)
          { // Réponse HTTP "OK"
		 
            $(divcible).innerHTML = 'HTTP 404 "Not Found"<br /><br />';
          },
        onFailure: function (xhr)
          { // Réponse HTTP != 2xx
		 
            $(divcible).innerHTML = 'Failure : ' 
                + xhr.status + ' :' + xhr.statusText + '<br /><br />';
          },
        onException: function (xhr, exception)
          {
			  $(divcible).show(); 
            $(divcible).innerHTML = 'Exception : ' + exception + '<br />';
          }
      
 
      });
}

/********************************/

function majCmt(id, divcible, script){
  var url = 'ajax/'+script;
  
 // alert (form+'-'+script+'-'+divcible);
  
 
 
 $('response_cmt').innerHTML = '';
  var myAjax5 = new Ajax.Request(
      url, 
      {
        method: 'post',
     asynchronous: false,
     contentType: 'application/x-www-form-urlencoded',
     encoding: 'UTF-8',
     parameters: {'id': id} ,
		
         onLoading: function (xhr)
          { // Création de l'objet XHR
            $(divcible).innerHTML = '<img src="images/icons/loading.gif" />';
          },
    
        onSuccess: function (transport)
          { // Réponse HTTP == 2xx
			$(divcible).show(); 
            $(divcible).innerHTML = transport.responseText ;
            
          },
        on404: function (xhr)
          { // Réponse HTTP "OK"
		  $(divcible).show(); 
            $(divcible).innerHTML = 'HTTP 404 "Not Found"<br /><br />';
          },
        onFailure: function (xhr)
          { // Réponse HTTP != 2xx
		  $(divcible).show(); 
            $(divcible).innerHTML = 'Failure : ' 
                + xhr.status + ' :' + xhr.statusText + '<br /><br />';
          },
        onException: function (xhr, exception)
          {
			  $(divcible).show(); 
            $(divcible).innerHTML = 'Exception : ' + exception + '<br />';
          }
      
 
      });
} // gestionClic()

/******************************/


function sendAbus(id, divcible){
  var url = 'ajax/sendabus.php';

   
 
 $('response').innerHTML = '';
  var myAjax = new Ajax.Request(
      url, 
      {
        method: 'post',
     asynchronous: false,
     contentType: 'application/x-www-form-urlencoded',
     encoding: 'UTF-8',
     parameters:   {'id': id} ,
		
         onLoading: function (xhr)
          { // Création de l'objet XHR
            $(divcible).innerHTML = '<img src="images/icons/loading.gif" />';
          },
    
        onSuccess: function (transport)
          { // Réponse HTTP == 2xx
			$(divcible).show(); 
			
            $(divcible).innerHTML = transport.responseText ;
           
          },
        on404: function (xhr)
          { // Réponse HTTP "OK"
		  $(divcible).show(); 
            $(divcible).innerHTML = 'HTTP 404 "Not Found"<br /><br />';
          },
        onFailure: function (xhr)
          { // Réponse HTTP != 2xx
		  $(divcible).show(); 
            $(divcible).innerHTML = 'Failure : ' 
                + xhr.status + ' :' + xhr.statusText + '<br /><br />';
          },
        onException: function (xhr, exception)
          {
			  $(divcible).show(); 
            $(divcible).innerHTML = 'Exception : ' + exception + '<br />';
          }
      
 
      });
} // gestionClic()
