/* Javascript */

/* Cette fonction permet d'afficher un objet dont l'identifiant est id */
function showHide(id)
  {
  if (document.getElementById && document.getElementById(id) != null)
    {
		if (document.getElementById(id).style.visibility!='visible')
		{
		    document.getElementById(id).style.visibility='visible';
		    document.getElementById(id).style.display='block';
		}
		else
		{
		    document.getElementById(id).style.visibility='hidden';
		    document.getElementById(id).style.display='none';
	    }

		// enleve le focus du lien après avoir cliqué dessus
		document.getElementById(id).onMouseClicked = focus();

    }

}
window.onload=montre;
function montre(id) {
	var d = document.getElementById(id);
		for (var i = 1; i<=12; i++) {
			if (document.getElementById('smenu'+i)) {document.getElementById('smenu'+i).style.display='none';}
		}
	if (d != null) {d.style.display='block';}
}

var nbreg = 9;
	var curreg = 0;
	var cartes = new Array()
	var carteobj = null;
	var tmreg = null;
	var bigc = '';

	function init_cartes(){
		for(i=0;i<=nbreg;i++){
			cartes[i] = new Image();
			cartes[i].src = 'imgs/regions/carte_'+bigc+'reg'+i+'.gif';
		}

		cartemap = document.getElementById("carte_map");
		carteobj = document.getElementById("carte");
		carteobj.im = carteobj.getElementsByTagName("IMG")[0];

		for(i=1;i<=nbreg;i++){
			maparea = cartemap.getElementsByTagName("AREA")[i-1];
			maparea.ind = i;
			regobj = document.getElementById("reg"+i);

			maparea.onmouseover = function(){
				show_reg(this.ind);
			}
			maparea.onmouseout = function(){
				window.clearTimeout(tmreg);
				tmreg = null;
				tm_reg();
			}
			maparea.onclick = function(){
				//return _false();
			}

			regobj.onmouseover = function(){
				window.clearTimeout(tmreg);
				tmreg = null;
			}
			regobj.onmouseout = function(){
				window.clearTimeout(tmreg);
				tmreg = null;
				tm_reg();
			}
		}
	}

	function _false(){
		return false;
	}

	function show_reg(i){
		window.clearTimeout(tmreg);
		tmreg = null;
		if(curreg>0){
			hide_reg(curreg);
			curreg = 0;
		}
		carteobj.im.src = cartes[i].src;
		document.getElementById("reg"+i).style.display = 'block';
		curreg = i;
	}

	function hide_reg(i){
		document.getElementById("reg"+i).style.display = 'none';
		carteobj.im.src = cartes[0].src;
	}

	function tm_reg(){
		tmreg = window.setTimeout("hide_reg("+curreg+")", 100);
	}
function show_num(){
		document.getElementById("num-tel").style.display = 'block';
	}
function hide_num(){
		document.getElementById("num-tel").style.display = 'none';
	}


/* gestion des tableaux deplies/replies
------------------------------------------------------------------------------*/
function toggleBloc(Obj)
{
	Tabs = Obj.parentNode.parentNode.parentNode.getElementsByTagName("table");
	picto = Obj.getElementsByTagName("IMG")[0].src;
	for(i=0; i<Tabs.length; i++)
	{
		if(Tabs[i].className == "data" || Ps[i].className == "text")
		{
			if( (Tabs[i].style.display == "none") || (Tabs[i].style.display == ""))
			{
				if(document.all)
				{
					Tabs[i].style.display = "block";
				}
				else
				{
					Tabs[i].style.display = "table";
				}
				Obj.getElementsByTagName("IMG")[0].src = "img/noir/picto-moins.png";	// modification
			}
			else
			{
				Tabs[i].style.display = "none";
				Obj.getElementsByTagName("IMG")[0].src = "img/noir/picto-plus.png";	// modification
			}
		}
	}
}

var interrupteur="2007";
function f_onglet_catalogue(interrupteur){

	if(interrupteur=="2007"){
		location.replace('index.php?switchto=2007');
		//document.getElementById("onglet_catalogue").src="imgs/accueil/onglet_4.gif";
		interrupteur="2008";
	}else{
		location.replace('index.php?switchto=2008');
		//document.getElementById("onglet_catalogue").src="imgs/accueil/onglet_3.gif";
		interrupteur="2007";
	}
}

/* participants */
var part_ind = 0;

function ajout_part(o){
	p = o.parentNode;
	while(p.getElementsByTagName("TABLE").length==0)
		p = p.parentNode;
	thetab = p.getElementsByTagName("TABLE")[0];

	therow = document.createElement("TR");
	part_ind++;
	
	document.formulaire.cpt_participants.value = (parseInt(document.formulaire.cpt_participants.value)+1);
//	alert(document.formulaire.cpt_participants.value);
//	p. = part_ind+1;
	
	thecell = document.createElement("TD");
	thecell.innerHTML = '<div><input type="checkbox"/></div>';
	therow.appendChild(thecell);
	thecell = document.createElement("TD");
	thecell.innerHTML = '<input type="text" class="chp_nom" name="part_'+part_ind+'_nom" value=""/>';
	therow.appendChild(thecell);
	thecell = document.createElement("TD");
	thecell.innerHTML = '<input type="text" class="chp_nom" name="part_'+part_ind+'_prenom" value=""/>';
	therow.appendChild(thecell);
	thecell = document.createElement("TD");
	thecell.innerHTML = '<input type="text" class="chp_fonction" name="part_'+part_ind+'_fonc" value=""/>';
	therow.appendChild(thecell);
	thecell = document.createElement("TD");
	thecell.innerHTML = '<input type="text" class="chp_tel" name="part_'+part_ind+'_tel" value=""/>';
	therow.appendChild(thecell);
	thecell = document.createElement("TD");
	thecell.className = 'last';
	thecell.innerHTML = '<input type="text" class="chp_mail" name="part_'+part_ind+'_mail" value=""/>';
	therow.appendChild(thecell);

	thetab.getElementsByTagName("TBODY")[0].appendChild(therow);
	upd_part(thetab.rows);
	return false;
}

function suppr_part(o){
	p = o.parentNode;
	
//	tmp_nb_part = document.formulaire.cpt_participants.value;
	
//	document.formulaire.cpt_participants.value = document.formulaire.cpt_participants.value-1;
	
	
	
	while(p.getElementsByTagName("TABLE").length==0)
		p = p.parentNode;
	thetab = p.getElementsByTagName("TABLE")[0];
	theinps = thetab.getElementsByTagName("INPUT");
	inpind = 1;
	maxind = theinps.length;
	while(theinps[inpind]!=null){
		if(theinps[inpind].checked){
			thetab.getElementsByTagName("TBODY")[0].removeChild(theinps[inpind].parentNode.parentNode.parentNode);
			document.formulaire.cpt_participants.value = document.formulaire.cpt_participants.value-1;
		}
		else
			inpind+=6;
	}
	upd_part(thetab.rows);
	
//	alert(document.formulaire.cpt_participants.value);
	
	return false;
}

function sel_part(o){
	p = o.parentNode;
	while(p.getElementsByTagName("TABLE").length==0)
		p = p.parentNode;
	thetab = p.getElementsByTagName("TABLE")[0];
	theinps = thetab.getElementsByTagName("INPUT");
	for(i=1;i<theinps.length;i+=6){
		theinps[i].mast = o;
		theinps[i].onclick = function(){
			if(this.checked==0)
				this.mast.checked = 0;
		}
		theinps[i].checked = o.checked;
	}
	return true;
}

function upd_part(o){
	cls = 'dark';
	for(i=1;i<o.length;i++){
		o[i].className = cls;
		cls = (cls=='dark')?'':'dark';
	}
	o[o.length-1].className = o[o.length-1].className + ' last';
}
