// JavaScript Document

function lister_ss_domaine(val, divId)
{
	var div=document.getElementById(divId);
	var contenu=file('http://www.compass-training.fr/admin/select-ss-domaines.php?id_domaine='+val+'&type=liste&actif=1');
	
	div.innerHTML=contenu
}


function charger_formation(id, divId)
{
	var fichier='http://www.compass-training.fr/admin/select-formation.php?id_sous_domaine='+id+'&liste=1';
	
	var res=file(fichier);
	
	document.getElementById(divId).innerHTML=res;
}


function afficher_champ(divId, inputId, val)
{
	div=document.getElementById(divId);
	input=document.getElementById(inputId);
	
	if(val=='nouveau')
	{
		div.style.display ="block"; 
	}
	else
	{
		div.style.display ="none"; 
		input.value='';
	}
}

function agrandir_image(image, divId, le_id)
{
	
	var exist=document.getElementById('image_agrandie'+le_id);
	if(exist)	{return;}
	
	var contenant = document.createElement("div");

	var div_bas=document.createElement("div");
	
	contenant.setAttribute("id","image_agrandie"+le_id);
	div_bas.setAttribute("id","fermer_image_agrandie"+le_id);
	
	contenant.className='image_agrandie';
	
	div_bas.className='fermer_image_agrandie';
	
	contenant.innerHTML='<img src='+image+' />';
	
	if (navigator.appName=='Microsoft Internet Explorer')
	{
		var bouton = document.createElement("span");
		bouton.setAttribute("id","ferme");
		bouton.innerHTML="Fermer"
		bouton.className="aide_bouton";
		bouton.onclick=function() { supprim(divId, 'image_agrandie'+le_id);}
	}
	else
	{
		var bouton = document.createElement("span");
		bouton.innerHTML="Fermer";
		bouton.className="aide_bouton";
		bouton.onclick=function() { supprim(divId, 'image_agrandie'+le_id);}
	}
	
	
	//***********
	div_bas.appendChild(bouton);
	contenant.appendChild(div_bas);
	
	document.getElementById(divId).appendChild(contenant);
	
}

function supprim(divId, div_a_supprimer)
{
	var div=document.getElementById(div_a_supprimer);
	document.getElementById(divId).removeChild(div);
}



function file(fichier)
{
    if(window.XMLHttpRequest) xhr_object = new XMLHttpRequest(); // FIREFOX
     
	 else if(window.ActiveXObject) xhr_object = new ActiveXObject("Microsoft.XMLHTTP");// IE
    
	 else return(false); 
	 xhr_object.open("GET", fichier, false);
     xhr_object.send(null);
     if(xhr_object.readyState == 4) return(xhr_object.responseText);
     else return(false);
}

function switchCode(div_id)
{
	var div=document.getElementById(div_id);
	
	if (div.style.display !="block")
	{
		div.style.display ="block"; 
		affiche=0;
	}
	else
	{
		div.style.display ="none"; 
		affiche=1;
	}
	
	return affiche;
}

function switchCode_special(div_id, img_id)
{
	var div=document.getElementById(div_id);
	var image=document.getElementById(img_id);
	
	if (div.style.display !="block")
	{
		div.style.display ="block"; 
		image.src="http://www.compass-training.fr/images/moins.gif";
		affiche=0;
	}
	
	else
	{
		div.style.display ="none"; 
		image.src="http://www.compass-training.fr/images/plus.gif";
		affiche=1;
	}
	
	return affiche;
}
