

function zm_closediv(id) {
 document.getElementById(id).style.display='none';
}
function zm_opendiv(id) {
 document.getElementById(id).style.display='';
}

function zm_textarea(id) { zm_textarea_run(id, 1); }
function zm_textarea_run(id, zfocus ) {
 var maxi=150;
 if ( document.getElementById(id).scrollHeight > document.getElementById(id).clientHeight  &&  document.getElementById(id).clientHeight < maxi) {
  var h = document.getElementById(id).scrollHeight;
  if ( h>maxi) h = maxi;
   document.getElementById('div_album_modif').style.height =  
   (document.getElementById('div_album_modif').scrollHeight + (h  - document.getElementById(id).clientHeight)) +'px';
       document.getElementById(id).style.height =  (h + 20)+ 'px' ;
   document.getElementById('doc_c_prive_amis').style.border = '1px solid #879EAC';  
 }
 if ( zfocus == 1) {document.getElementById(id).focus();  }
 setTimeout('zm_textarea_run(\''+id+'\',0)' , 300 ) ;
}

function zmarecode( s ) {
return (escape(s.replace(/\+/g, '&plus;')));
}


function putmsg( id,s) {
  document.getElementById(id).innerHTML = s;
}


function getxhr() {

  var xhr; 
  
  
    try {  xhr = new ActiveXObject('Msxml2.XMLHTTP');   }
    catch (e) {
        try {   xhr = new ActiveXObject('Microsoft.XMLHTTP');    }
        catch (e2) {
          try {  xhr = new XMLHttpRequest();     }
          catch (e3) {  xhr = false;   }
        }
     }
   return xhr;
}



function monprofil_modif_prefs(divid) {
/*********************************************************************/
    var xhr;
    var s=' ';
    var t, nbparpage, cp, ville, pays;
    xhr = getxhr();
 
    xhr.onreadystatechange = function() {        
         if (xhr.readyState == 4 && xhr.status == 200 ) {
	    document.getElementById(divid).innerHTML = xhr.responseText;
	 }
    }; 
    
    
 if ( divid == 'd_gus_prefs' ) {
   nbparpage=document.getElementById('gus_c_prefs_nbparpage').value;   
   t = document.getElementsByTagName("INPUT");
   for (i=0;i<t.length;i++) {
     p=t[i];
     if ( p.id.match('gus_suivre_reac') && p.checked) {
      s+= p.value + ' ';
     }
   }
 } else { 
   cp = document.getElementById('gus_c_cp').value;
   ville = document.getElementById('gus_c_ville').value;
   pays = document.getElementById('gus_c_pays').value;
 }
 
  document.getElementById(divid).innerHTML = '<br /><br />Chargement en cours ... <img src="pics/wait.gif" /><br /><br />';


    xhr.open( "POST", "/ajaxd.php", true);
    xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    if ( divid == 'd_gus_prefs' ) { 
       xhr.send("mod=gus_prefs_modif&nbparpage="+nbparpage+"&s="+s);
   } else {
       xhr.send("mod=gus_coords_modif&cp="+cp+"&ville="+ville+"&pays="+pays);   
   }
    
}



function zma_album_modif(id) { 
    var xhr;
    xhr = getxhr();
 
    xhr.onreadystatechange = function() {        
         if (xhr.readyState == 4 && xhr.status == 200 ) {
	    document.getElementById('div_album_modif').innerHTML = xhr.responseText;
	 }
    }; 
        
    document.getElementById('div_album_modif').style.display='';	
 document.getElementById('div_album_modif').innerHTML = 'Chargement en cours ...';
 
    xhr.open( "POST", "/ajaxd.php", true);
    xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xhr.send("mod=album_modif&album_id="+id);
       
}




function zmswitchdiv( id, mode ) {
  var p;
  p = document.getElementById(id); 
  if ( p!=undefined ){
    if ( mode == 'on' ) {p.style.display=''; }
    else {p.style.display='none'; } 
  }
}


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






function zmreacvalid( id, mode ) {
 if ( mode =='yep' ) {s='Certain de vouloir VALIDER et publier ce post ?';}
 else {s='Certain de REFUSER ce post ?';}
 if ( confirm(s)) {
    document.getElementById( "reagir_valid_reac_id" ).value=id ; 
    document.getElementById( "reagir_valid_reac_mode" ).value=mode ; 
    document.getElementById( "ff" ).submit();    
 }
}

function zm_unlink ( hidid, imgid ) {
  d=document;
  if ( d!=null) {
    d.getElementById('c_illustration_legend').value = '';
    d.getElementById(hidid).value = '';
    d.getElementById(imgid).src = 'pics/illustration_vide.jpg';
    window.close();
  }
}


function zm_attach( id, hidid, imgid, url, legende ) {
  d=window.opener.document;
  if ( d!=null) {
    d.getElementById('c_illustration_legend').value = legende;     
    d.getElementById(hidid).value = id;
    d.getElementById(imgid).src = url;
    window.close();
  }
}

function zm_open( url ) { 
 var p = window.open(url, "ZM", "width=800,height=600,fullscreen=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no");
 p.focus();
}
 
function zm_open2( url ) { 
 var p = window.open(url, "ZM", "width=800,height=600,toolbar=0,scrollbars=1,status=0,resizable=1");
 p.focus();
} 

function zm_ongletoff( id ) {
  t = document.getElementsByTagName("DIV");	
  for (i=0;i<t.length;i++) { p=t[i]; if ( p.id.match(id)) { p.style.display = 'none'; } }
}	
function zm_ongleton( objetname, id ) {
  zm_ongletoff(  objetname + '_onglet_' ); 
  p = document.getElementById( objetname + id );
  p.style.display = ''; 
}

function zm_panelongletA( id, ptr ) {
   t = document.getElementsByTagName("A");
   for (i=0;i<t.length;i++) { 
	p=t[i];  
	if ( p.id.match(id) ) { 
	  if (  p.id == id+ptr ) { // --- actif :
	     p.className='actif';
	  }                    // ----- inactif :
	  else { 
	  	 p.className=' ';
	  }
	} 
   }	
}

function zm_panelongletLI( id, ptr ) {
   t = document.getElementsByTagName("LI");
   for (i=0;i<t.length;i++) { 
	p=t[i];  
	if ( p.id.match(id) ) { 
	  if (  p.id == id+ptr ) { // --- actif :
	     p.className='actif';
	  }                    // ----- inactif :
	  else { 
	  	 p.className=' ';
	  }
	} 
   }	
}






function zm_divon(id) {p=document.getElementById( id );p.style.display = '';}
function zm_divon2(id,v) {zm_divon(id); v.value=1; }
function zm_divoff(id) {p=document.getElementById( id );p.style.display = 'none';}
function zm_divoff2(id,v) {zm_divoff(id);v.value=0;}


function zm_divonoff( id, champ ) {

var expire = new Date();
expire.setFullYear( expire.getFullYear() + 1 );

 p=document.getElementById( id );

 if ( p != null ) { 
  p.style.display = (p.style.display == 'none')?'':'none';
//  document.cookie = "zm_divonoff_"+id+"="+ ((p.style.display == 'none')?0:1) + "; expires=" +expire.toGMTString();
  if ( champ != '' ) {
   t=document.getElementById( champ );
   t.value = (p.style.display == 'none')?'off':'on';
  }
  i = document.getElementById( id+'_img'); 
  if ( i != null ) { 
    i.src = i.src.replace( /..gif$/ , ((p.style.display == 'none')?'0':'1') + '.gif' ); 
  }
 }
}
