function switchimage(){
var Z=Math.floor(Math.random() * maxImg);
	t1 = new Sequence();  
	t2 = new Sequence();   
		var elem_boix = document.getElementById('logos_' + Z);
		
		elem_boix.style.display='block';
		t1.addChild(new OpacityTween(elem_boix,Tween.backEaseIn,100,100,1));    
	
	t1.start();
	t1.onMotionFinished = function(){
		t2.addChild(new OpacityTween(elem_boix,Tween.backEaseIn,100,0,5)); 
		t2.start();	 	
		boix(elem_boix);
	}; 
}
function boix(ancien_elem){ 
var Z=Math.floor(Math.random() * maxImg);
	t1 = new Sequence();  
	t2 = new Sequence();   
		var elem = document.getElementById('logos_' + Z);
		
		elem.style.display='block';
		t1.addChild(new OpacityTween(elem,Tween.backEaseIn,0,100,5));    
	
	t1.start();
	t1.onMotionFinished = function(){
	if(elem!=ancien_elem){
		ancien_elem.style.display='none';
	}
		t2.addChild(new OpacityTween(elem,Tween.backEaseIn,100,0,5)); 
		t2.start();	 
		boix(elem);
	};
}

function switchimage_sans_blanc(){ 
var Z=Math.floor(Math.random() * maxImg);
	t1 = new Sequence();  
	t2 = new Sequence();   
		var elem = document.getElementById('logos_' + Z);
		
		elem.style.display='block';
		t1.addChild(new OpacityTween(elem,Tween.backEaseIn,0,100,5));    
	
	t1.start();
	t1.onMotionFinished = function(){
		t2.addChild(new OpacityTween(elem,Tween.backEaseIn,100,0,5)); 
		t2.start();	
		switchimage();
	};
}
function switchimage_avec_blanc(){ 
var Z=Math.floor(Math.random() * maxImg);
	t1 = new Sequence();  
	t2 = new Sequence();   
		var elem = document.getElementById('logos_' + Z);
		
		elem.style.display='block';
		t1.addChild(new OpacityTween(elem,Tween.backEaseIn,0,100,3));    
	
	t1.start();
	t1.onMotionFinished = function(){
		t2.addChild(new OpacityTween(elem,Tween.backEaseIn,100,0,5)); 
		t2.start();	
		t2.onMotionFinished = function(){
		elem.style.display='none';
		switchimage();};
	};
}

function fast_ajout_adherent(){
	var entreprise=document.getElementById('ajout_entreprise').value;
	var type=document.getElementById('ajout_type').value;
	var nom=document.getElementById('ajout_nom').value;
	var ville=document.getElementById('ajout_ville').value;
	var xhr=getXhr();
	xhr.onreadystatechange= function(){
		if(xhr.readyState==4 && xhr.status==200){
		document.location.href='admin.php?edit=adherents2';
		}
	}	
	xhr.open("POST","traitement.php",true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("fast_ajout_adherent=fast_ajout_adherent&ville="+ville+"&entreprise="+entreprise+"&type="+type+"&nom="+nom);  
} 
function fast_modif_partenaire_adherent(onglet,lechamps,id){
	var lavalue=document.getElementById('input_'+lechamps+'_'+id).value;
	var xhr=getXhr();
	xhr.onreadystatechange= function(){
		if(xhr.readyState==4 && xhr.status==200){
		var tablo=xhr.responseText; 
		var xx=tablo.split('_;_'); 
		document.getElementById('affich_'+lechamps+'_'+id).innerHTML=xx[0]; 
		document.getElementById('input_'+lechamps+'_'+id).value=lavalue; 
		document.getElementById('span_'+lechamps+'_'+id).style.display="none"; 
		}
	}	
	xhr.open("POST","traitement.php",true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("fast_modif=fast_modif&id="+id+"&lechamps="+lechamps+"&onglet="+onglet+"&lavalue="+lavalue);  
}

function loginshowX(div){
	if(div=="formlogin"){
	showX("formlogin");
	hideX("forminscription");
	document.getElementById("radio_connect").style.backgroundImage="url('images/radio_selected.jpg')";
	document.getElementById("radio_inscription").style.backgroundImage="url('images/radio_vide.jpg')";
	}else{
	showX("forminscription");
	hideX("formlogin");
	document.getElementById("radio_inscription").style.backgroundImage="url('images/radio_selected.jpg')";
	document.getElementById("radio_connect").style.backgroundImage="url('images/radio_vide.jpg')";
	}
}

function gestcoms(id){
	if(id==''){
		id='all';
	}
div='affich_com';
document.getElementById(div).innerHTML=""; 
showX(div);
var xhr=getXhr();
	xhr.onreadystatechange= function(){
		if(xhr.readyState==4 && xhr.status==200){
		var tablo=xhr.responseText; 
		var xx=tablo.split('_;_');  
		document.getElementById(div).innerHTML=xx[0];
		}
	}	
	xhr.open("POST","traitement.php",true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("gestion_des_coms='gestion_des_coms'&id="+id);  


}
function formul_comment(id,cat){
document.getElementById('ajout_commentaire').innerHTML=""; 
div="ajout_commentaire";
showX(div);
	ajout_commentaire(id,cat);
}
function afficher_msg(id,cat){
div="affich_section";
showX(div);
document.getElementById('onglets_affich').innerHTML="";
document.getElementById('lecontenu_du_msg').innerHTML=""; 
	var xhr=getXhr();
	xhr.onreadystatechange= function(){
		if(xhr.readyState==4 && xhr.status==200){
		var tablo=xhr.responseText; 
		var xx=tablo.split('_;_'); 
		document.getElementById('onglets_affich').innerHTML=xx[0];
		showX('onglets_affich');
		showX('lecontenu_du_msg'); 
		showX('div_ajout_de_com');  
		document.getElementById('lecontenu_du_msg').innerHTML=xx[1]; 
		document.getElementById('div_ajout_de_com').innerHTML=xx[2]; 
		document.getElementById('ajout_commentaire').innerHTML=xx[3]; 
		}
	}	
	xhr.open("POST","traitement.php",true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("afficher_msg=afficher_msg&id="+id+"&cat="+cat);  
}
function ajout_msg(id,cat){
div="msg_statut"; 
pseudo=document.getElementById('pseudo_du_posteur').value;
contenu_sujet=document.getElementById('contenu_sujet').value; 
titre_sujet=document.getElementById('titre_sujet').value; 
document.getElementById(div).innerHTML="<strong>Envoie en cours</strong>"; 

	var xhr=getXhr();
	xhr.onreadystatechange= function(){
		if(xhr.readyState==4 && xhr.status==200){
		var tablo=xhr.responseText; 
		var xx=tablo.split('_;_');  
		document.getElementById(div).innerHTML="<strong>"+xx[0]+"</strong>"; 
		document.location.href='index.php?page=forum&cat='+cat;
		}
	}	
	xhr.open("POST","traitement.php",true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("ajout_msg='ajout_msg'&id="+id+"&cat="+cat+"&contenu_sujet="+contenu_sujet+"&titre_sujet="+titre_sujet+"&pseudo="+pseudo);  
}
function ajout_commentaire(id,cat){
div="com_statut"; 
pseudo=document.getElementById('pseudo_du_posteur').value;
com=document.getElementById('com').value; 
document.getElementById(div).innerHTML="Envoie en cours"; 

	var xhr=getXhr();
	xhr.onreadystatechange= function(){
		if(xhr.readyState==4 && xhr.status==200){
		var tablo=xhr.responseText; 
		var xx=tablo.split('_;_');  
		document.getElementById(div).innerHTML=xx[0];  
		document.location.href='index.php?page=forum&cat='+cat;
		}
	}	
	xhr.open("POST","traitement.php",true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("ajout_commentaire='ajout_commentaire'&id="+id+"&cat="+cat+"&com="+com+"&pseudo="+pseudo);  
}



/**************************************************
	LA FONCTION AJAX !! NE PAS TOUCHER MERCI
**************************************************/
function getXhr(){
	if(window.XMLHttpRequest){ //Firefox et autres
		xhr=new XMLHttpRequest();
	}
	else if(window.ActiveXObject){  // Internet Explorer
	try{
		xhr= new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e){
		xhr = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}else { //XMLHTTP request non suppor?par le navigatuer
		alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..");
		xhr=false;
	}
		return xhr;
}
/**************************************************
	AFFICHER / CACHER LES DIV DU CONTACT
**************************************************/
function showX(show_X){
	if(document.getElementById(show_X).style.display=='block'){
		document.getElementById(show_X).style.display='none'; 
	}else{	
		document.getElementById(show_X).style.display='block'; 
		document.getElementById(show_X).style.visibility='visible'; 
	}
}		
function hideX(hide_X){
document.getElementById(hide_X).style.display='none' ; 
} 
/**************************************************
	AFFICHER / CACHER LES DIV DU CONTACT
**************************************************/
function showcontact(){
document.getElementById('leformulairedecontact').style.display='block';
document.getElementById('leformulairedecontact').style.visibility='visible';
document.getElementById('dernierenews').style.display='none'; 
}		
function hidecontact(){
document.getElementById('dernierenews').style.display='block' ;
document.getElementById('dernierenews').style.visibility='visible';
document.getElementById('leformulairedecontact').style.display='none' ; 
}
/**************************************************
**************************************************/
/**************************************************
	AJAX - RESSOURCES => AIDES / FORMATION / REGLEMENTATION
**************************************************/
function trier_ressources(trierpar,div,onglet){
	document.getElementById(div).innerHTML="<h2 style='color:blue'>Triage en cours..</h2>";
		var xhr=getXhr();
	xhr.onreadystatechange= function(){
	if(xhr.readyState==4 && xhr.status==200){
			document.getElementById(div).innerHTML=xhr.responseText;		
	}
	} 
	xhr.open("POST","traitement_tri.php",true); 
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); 
	xhr.send("tri_ressource='tri_ressource'&trierpar="+trierpar+"&onglet="+onglet);  
}

function trier_projet(trierpar){
var div='contenu_projets';
	document.getElementById(div).innerHTML="<h2 style='color:blue'>Triage en cours..</h2>";
		var xhr=getXhr();
	xhr.onreadystatechange= function(){
	if(xhr.readyState==4 && xhr.status==200){
			document.getElementById(div).innerHTML=xhr.responseText;		
	}
	} 
	xhr.open("POST","traitement_tri.php",true); 
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); 
	xhr.send("tri_projet='tri_projet'&trierpar="+trierpar);  
}

function trier_aides(trierpar){
var div='ressources';
	document.getElementById(div).innerHTML="<h2 style='color:blue'>Triage en cours..</h2>";
		var xhr=getXhr();
	xhr.onreadystatechange= function(){
	if(xhr.readyState==4 && xhr.status==200){
			document.getElementById(div).innerHTML=xhr.responseText;		
	}
	} 
	xhr.open("POST","traitement_tri.php",true); 
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); 
	xhr.send("tri_aides='tri_aides'&trierpar="+trierpar);  
}
// AIDES (OK)
function voir_aide(id){
document.getElementById('voir_aide_'+id).style.display="block";
document.getElementById('voir_aide_'+id).innerHTML=""; 
var xhr = getXhr();
xhr.onreadystatechange = function(){ 
	if(xhr.readyState == 4 && xhr.status == 200){  
		var tablo=xhr.responseText; 
		var xx=tablo.split('_;_'); 
		var closediv="<h3 style='clear:both' style='float:left'><a href='#' onclick='document.getElementById(\"voir_aide_"+id+"\").style.display=\"none\" '> Fermer </a></h3>";
		var imgprojet;
		if(xx[2]==''){
		img_projet='';
		}else{
		img_projet="<img src='"+xx[2]+"' alt=''/>";
		}
		var ladiv=img_projet+xx[1]
		document.getElementById('voir_aide_'+id).innerHTML=ladiv+closediv;
	}
} 
xhr.open("POST","traitement_voir.php",true);      
xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');  
xhr.send("asso=aides&id="+id); 
} 
// PROJETS (OK)
function voir_projet(id){
	if(	document.getElementById('voir_projet_'+id).style.display=="block"){
	document.getElementById('voir_projet_'+id).style.display="none";
	}else{
	document.getElementById('voir_projet_'+id).style.display="block";
	document.getElementById('voir_projet_'+id).innerHTML=""; 
	var xhr = getXhr();
	xhr.onreadystatechange = function(){
		if(xhr.readyState == 4 && xhr.status == 200){  
			var tablo=xhr.responseText; 
			var xx=tablo.split('_;_'); 
			var closediv="<h3 style='clear:both' align='left'><a href='#' onclick='document.getElementById(\"voir_projet_"+id+"\").style.display=\"none\" '> Fermer </a></h3>";
			var ladiv="<div class='projets'><h1></h1><p>"+xx[1]+"</p><br/></div>"
			document.getElementById('voir_projet_'+id).innerHTML=ladiv+closediv;
		}
	} 
	xhr.open("POST","traitement_voir.php",true);      
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');  
	xhr.send("asso=projets&id="+id); 
	} 
} 

function aff_formation(id){
	var div='ressources';
	var xhr = getXhr();
xhr.onreadystatechange = function(){ 
	if(xhr.readyState == 4 && xhr.status == 200){  
	var tablo=xhr.responseText;  
		var xx=tablo.split('_;_');   
		document.getElementById(div).innerHTML="<h1>"+xx[0]+"</h1><p>"+xx[1]+xx[2]+"</p>";
	}
} 
xhr.open("POST","traitement_voir.php",true);      
xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');  
xhr.send("asso=formation&id="+id); 
}

/**************************************************
	AJAX - FIN RESSOURCES
**************************************************/

/**************************************************
	AJAX - FORMULAIRE DE LA NEWSLETTER
**************************************************/
function insert(){

	document.getElementById('message').innerHTML="Envoie en cours" ;
	var xhr=getXhr();
	var varmail=document.getElementById('lemail').value; 
	var varselect=document.getElementById('select-newsletter').value;
	xhr.onreadystatechange= function(){
		if(xhr.readyState==4 && xhr.status==200){  
			if(xhr.responseText==1){
			document.location.href='index_.php?page=login';
			}else{
			document.getElementById('message').innerHTML=xhr.responseText;
			}
		}
	} 
	// Ici on va voir comment faire du POST:
	xhr.open("POST","traitement_newsletter.php",true);
	//Ne pas oublier ?pour le POST:
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	// ~ xhr.send("email="+varmail+"&action="+varaction);
	xhr.send("email="+varmail+"&varselect="+varselect);
	
}
/**************************************************
**************************************************/

/**************************************************
	AJAX - FORMULAIRE DE CONTACT
**************************************************/

function contact(){
	document.getElementById('contacter').innerHTML="<h2 style='color:blue'>Veuillez patienter pendant l'envoi du mail..</h2>";
	var nom=document.getElementById('nom').value; 
	var prenom=document.getElementById('prenom').value; 
	var from=document.getElementById('from').value; 
	var sujet=document.getElementById('sujet').value; 
	var txtmsg=document.getElementById('txtmsg').value;  
	if(nom=="" || from =="" || sujet =="" ){	
	alert("Erreur: Le formulaire n'a pas été envoyé. Un champ obligatoire est vide.");
	document.getElementById('contacter').innerHTML="";	
	}else{
		var xhr=getXhr();
		xhr.onreadystatechange= function(){
		if(xhr.readyState==4 && xhr.status==200){  
		document.getElementById('contacter').innerHTML=xhr.responseText;		
		}
		}  
		xhr.open("POST","traitement_contact.php",true); 
		xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); 
		xhr.send("nom="+nom+"&prenom="+prenom+"&from="+from+"&sujet="+sujet+"&txtmsg="+txtmsg);  
	}
}
/**************************************************
**************************************************/ 
/**************************************************
 FONCTIONS SCROLL 
**************************************************/
var currentScroller;
function myScroll2(content,value){
	document.getElementById(content).scrollLeft+=value;
}

function movediapo(){ 
}

var movenews;
function gonews(div,valeur){
	document.getElementById(div).scrollTop+=valeur;
}
 
var current=86;
var maxi=185;
var ancienne_id=1; 
					function grandir(id){  
						
						flag=0;
						// On réduit l'ancienne id :
						if(ancienne_id != id && ancienne_id != 1 && flag == 0)
						{    
						reduire(ancienne_id);
						flag=1;
						}		 
						ancienne_id=id ;
						var ladiv="news_"+id ;
						var retrecir="reduire_"+id ;
						var agrandir="grandir_"+id;
						if(current<maxi)
							{
							current=maxi;
							element=document.getElementById(ladiv); 
							element.style.height=current+'px'; 
							compteur=setTimeout("grandir('"+id+"')",1);
							}		
						if(current>=maxi)
						{
						flag=1;
						clearTimeout(compteur); 
						document.getElementById(agrandir).style.overflow='hidden'; 
						document.getElementById(ladiv).style.height='auto';	
						document.getElementById(ladiv).style.overflow='auto';
						document.getElementById(ladiv).style.visibility='visible';
						document.getElementById(retrecir).style.overflow='none';
						document.getElementById(retrecir).style.visibility='visible';
						
						}
					}

var current_min=185;
var mini=86;
					function reduire(id){ 
					var ladiv="news_"+id ;
						var retrecir="reduire_"+id ;
						var agrandir="grandir_"+id;
					if(current_min>mini){ 
					
					current_min=mini;
					
					element=document.getElementById(ladiv);
					element.style.height=current_min+'px';
					compteur2=setTimeout("reduire('"+id+"')",1);
					}
					if(current_min<=mini){
					clearTimeout(compteur2);
					current_min=150;	
					document.getElementById(ladiv).scrollTop='auto';
					document.getElementById(ladiv).style.overflow='hidden';
					document.getElementById(ladiv).style.visibility='visible'; 
					document.getElementById(retrecir).style.overflow='hidden';
					document.getElementById(agrandir).style.overflow='none';
					document.getElementById(agrandir).style.visibility='visible';
					}
					}
/**************************************************
**************************************************/					 
					
				
function confirmer(){ 
window.confirm("Vouler vous supprimer ?");
if(window.confirm==true){window.location.href;}
}



/**************************************************
 AJAX => ADHERENTS // PARTENAIRES // PROJETS
**************************************************/
// ADHERENTS && PARTENAIRES 
function voir_(id,asso){
document.getElementById('voir_'+id).style.display="block";
 document.getElementById('voir_'+id).innerHTML= "Veuillez patienter, votre demande a été prise en compte";  
var xhr = getXhr();
xhr.onreadystatechange = function(){ 
	if(xhr.readyState == 4 && xhr.status == 200){  
		var tablo=xhr.responseText; 
		var xx=tablo.split('-_-'); 
		var closephoto="<h3 style='clear:both' align='left'><a href='#' onclick='document.getElementById(\"voir_"+id+"\").style.display=\"none\" '> Fermer </a></h3>";
		document.getElementById('voir_'+id).innerHTML=xx[0]+closephoto;
	} 
} 
xhr.open("POST","traitement_voir.php",true);      
xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');  
xhr.send("id="+id+"&asso="+asso); 
} 


/**************************************************
**************************************************/

/**************************************************
AJAX => NEWSLETTER 
**************************************************/
function envoie_newsletter(id){
	document.getElementById('nl_reponse_'+id).innerHTML="Envoie de la news numero"+id+" en cours" ;
	var xhr=getXhr();
	xhr.onreadystatechange= function(){
		if(xhr.readyState==4 && xhr.status==200){  
		document.getElementById('nl_reponse_'+id).innerHTML=xhr.responseText;
		}
	}
	xhr.open("POST","traitement_admin_newsletter.php",true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("id="+id);
}
/**************************************************
**************************************************/
/**************************************************
	AJAX - TRIER les PARTENAIRES / ADHERENTS
**************************************************/

function trier_autre(trierpar,div,onglet,ordre){

if(trierpar=="titre"){
	if(ordre=="asc"){
	document.getElementById('ascdesc_nom').innerHTML="<a href='javascript:void(trier_autre(\"titre\",\"reponse_du_tri\",\""+onglet+"\",\"desc\"));>Trier par Nom</a> -";
	}else{
	document.getElementById('ascdesc_nom').innerHTML="<a href='javascript:void(trier_autre(\"titre\",\"reponse_du_tri\",\""+onglet+"\",\"asc\"));>Trier par Nom</a> -";
	}
}
	leselect=document.getElementById('leselect_tri');
	option=leselect.options[leselect.selectedIndex].value;
	document.getElementById(div).innerHTML="<h2 style='color:blue'>Triage en cours..</h2>";
		var xhr=getXhr();
	xhr.onreadystatechange= function(){
	if(xhr.readyState==4 && xhr.status==200){
			document.getElementById(div).innerHTML=xhr.responseText;		
	}
	} 
	xhr.open("POST","traitement_tri.php",true); 
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); 
	xhr.send("update_tri_partenaire='update_tri_partenaire'&trierpar="+trierpar+"&onglet="+onglet+"&ordre="+ordre+"&option="+option);  
}
/**************************************************
**************************************************/ 
