

function zma_chat_call(id,deja,jesuisenchat) {
  var s;
  if ( deja == 0 ) {s='Certain(e) de vouloir appeler ce Zaclynaute\n pour discuter en salle de tchat ?'; }
  else {s='Ce Zaclynaute a déjà été appelé récemment \n et son signal d\'appel est encore activé.\n\n Certain(e) de vouloir quand même rappeler ce Zaclynaute\n pour discuter en salle de tchat ?'; }
  
  if (confirm(s)) {zma_chat_send('chat_call',id); }
  if ( document.getElementById('hidjesuisenchat').value!=1 && confirm('Voulez vous rejoindre la salle de Tchat ?')) {
    window.location='http://www.zaclypedia.com/?c=103';
  }
}

function zma_chat_ctrl(p) {
 var v;
 if ( p.selectedIndex != 0) {
      v=p.options[p.selectedIndex].value;
      if (v=='chat_ctrl_back_all'||v=='chat_ctrl_back_today'||v=='chat_ctrl_back_yesterday'||v=='chat_ctrl_back_clear') {
        document.getElementById('d_chat').innerHTML='';
        zma_chat_send(v,'');
      }
 }
}

function zmtruc() {
 p = document.getElementById('chat_saisie');
 if ( p != undefined ) { 
   zma_chat_send('chat_send',p.value);
   p.value = '';
   p.focus();
 }
 return false;
}

function zma_chat_attach() {
 p = document.getElementById('chat_saisie');
 if ( p != undefined ) { p.focus(); }
 p = document.getElementById('ff');
 if ( p != undefined ) { p.onsubmit = zmtruc; }
 
}


function prout(p) {
    
    
   document.getElementById( 'spool1_brasse').style.display='';
	  
    var xhr;
    xhr = getxhr();
 
    xhr.onreadystatechange = function() { 
       
         if (xhr.readyState == 4 && xhr.status == 200 ) {
	 
            document.getElementById( 'spool1_brasse').innerHTML= xhr.responseText;
	 }
    };     
    
    
    xhr.open( "POST", "/index.php", true);
    xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xhr.send("doc_mode=add&doc_valider_modif=1&site_categorie=75&doc_c_theme=76&c_fichier="+ document.getElementById( 'spool1_fichier') ); 
}



function zma_alive()
{ 
    var xhr;
    xhr = getxhr();
 
    xhr.onreadystatechange = function() { 
       
         if (xhr.readyState == 4 && xhr.status == 200 ) {
	 
	 
	    if ( xhr.responseText.match(/^chat_invit:/) ) {
	         var who =xhr.responseText.match(/^chat_invit:(.*)/)[1] ;
	     
	         if ( confirm('Vous avez reçu un appel de '+who+'\n\nRejoindre la salle de tchat ?')) {
		    window.location='http://www.zaclypedia.com/?c=103';
		 }
	    }
	 
	 }
    };     
    
    
    xhr.open( "POST", "/ajaxd.php", true);
    xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xhr.send("mod=alive");
    
   
    setTimeout( 'zma_alive()', 10000);
    
}



function zma_chat_send(mode, s ) {
    var xhr;
    s=''+s;
    xhr = getxhr();
     
    xhr.open( "POST", "/ajaxd.php",  true);
    xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xhr.send("mod="+mode+"&chat_s="+ zmarecode(s) );
}
     

function zma_reload( mode, divid, timeout )
{ 
    var xhr;
xhr = getxhr();
 
    xhr.onreadystatechange = function() {        
         if (xhr.readyState == 4 && xhr.status  == 200 ) {
	    if ( document.getElementById( divid) != undefined ) {
	    
	       if ( xhr.responseText!='' ) {
 	        if ( mode == 'reload_chat') {
	          p = document.getElementById(divid);
		  p.innerHTML = xhr.responseText + p.innerHTML; 
	        } else {
	       	   document.getElementById(divid).innerHTML = xhr.responseText;
	        }
	       }
	       
	       if ( timeout > 0 ) {
	         setTimeout('zma_reload("'+mode+'","'+divid+'",'+timeout+')', timeout) ;
	       }
	    }
	 }
    };
    
    xhr.open( "POST", "/ajaxd.php",  true);
    xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xhr.send("mod="+mode);
    

}





function zma_daemon() {
 zma_alive();
}

setTimeout( 'zma_daemon()', 10000);
