    
    function Timer(){   //Boucle de 60 seçondes (60000 miliseçondes)
          timeoutID = window.setTimeout("affiche_commentaires()",60000);
    }   
     
 
     function affiche_commentaires()
     {
     $('comments').innerHTML='Chargement en cours...';
     new Ajax.Updater('comments','./include/affiche_commentaires.php',
                                                                                     {
                                                                                      method:'post',
                                                                                      asynchronous:true,
                                                                                      evalScripts:true
                                                                                     }
                                                                                );

     } 
    
     function ouvre(t) {
                var v1 = new Dialog.alert({url: "./include/ajout.php", options: {method: 'post',parameters: {type: t} }},
                                   {className: "alphacube", width:540,  okLabel: "Envoyer", onOk:
                                               function(win) {
                                                              switch (t)
                                                              {
                                                                  case "ajout":
                                                                                Element.setStyle("wait",{display:''});
                                                                                var reponse="";
                                                                                
                                                                                if ($('nom').value=="")
                                                                                    reponse=reponse + "- Nom/Pseudo\n\n";
                                                                                if ($('commentaire').value=="")
                                                                                    reponse=reponse + "- Commentaire";
                                                                                if (reponse!="")
                                                                                {
                                                                                    reponse="Les champs suivants sont obligatoires svp :\n\n" + reponse +"\n\nMerci:-)";
                                                                                    alert(reponse);
                                                                                    Element.setStyle("wait",{display:'none'});
                                                                                }
                                                                                else 
                                                                                {
                                                                                    //sauvegarde du commentaire dans la base de données
                                                                                    new Ajax.Request('./include/commentaire.php',
                                                                                     {
                                                                                      method:'post',
                                                                                      asynchronous:true,
                                                                                      evalScripts:true,
                                                                                      parameters: 'nom=' + $F('nom') 
                                                                                                  + '&email=' + $F('email') 
                                                                                                  + '&site=' + $F('site')
                                                                                                  + '&commentaire=' + $F('commentaire')
                                                                                                  ,
                                                                                      onComplete: evalResponse
                                                                                     }
                                                                                     );
                                                                                }
                                                                                
                                                                                
                                                                  break;
                                                                  
                                                                  case "contact":
                                                                  
                                                                  break;
                                                              
                                                              }
                                                             
                                                             }
                                               , cancel:function(win2) {return true;}
                                               , buttonClass: "fermer"}
                                   );

                function evalResponse(req)
                {
                   Windows.focusedWindow.hide();
                   //affiche_tableau(1);
                   affiche_commentaires();
                   openInfoDialog();
                   Element.setStyle("wait",{display:'none'});
                }  // fin fonction evalResponse

           
             }   // fin fonction ouvre(t)

            function openInfoDialog() {
                                  Dialog.info("<div style='text-align:center;'>Votre commentaire a &eacute;t&eacute; ajout&eacute;.<br/><br/> Retour au site dans <b>3</b> secondes.</div>", {width:250, height:100, showProgress: true}); 
                        timeout=3; 
                        setTimeout(infoTimeout(), 1000); 
            }
            
            function infoTimeout() { 
                                  timeout--; 
                                  if (timeout >0) 
                                  { 
                                          Dialog.setInfoMessage("<div style='text-align:center;'>Votre commentaire a &eacute;t&eacute; ajout&eacute;.<br/><br/> Retour au tableau dans <b>" + timeout + "</b> seconde(s).</div>");
                                          setTimeout(infoTimeout, 1000); 
                                  } 
                                  else 
                                    Dialog.closeInfo();
        } 


      WindowCloseKey.init();
     /* WindowReturnKey.init();*/
     
 
    
     
     Event.observe(window, "load", function()
                                              {
                                               affiche_commentaires();
                                               
                                               Event.observe('ajout', 'click', function(e){
                                                             ouvre('ajout');
                                                        });
                                                        
                                               Event.observe('contact', 'click', function(e){
                                                                     ouvre('contact');
                                                                });
                                                                
                                               Event.observe('rafraichir', 'click', function(e){
                                                             affiche_commentaires();
                                                        });
                                                        
                                    //           Timer();                                        
                                              
                                              }
     );
     
     
     