// JavaScript Document

// Fonction On/Off pour voir un élement
function InvDisplay (nom){

	if (document.getElementById(nom).style.display==''){
		document.getElementById(nom).style.display='none';
	}else{
		document.getElementById(nom).style.display='';
	}

}

///////////// FONCTIONS DU MENU /////////////

var elm = document.getElementsByTagName('select');

function TaskOff(nb){
	
	for (i=0;i<nbtaskmenus;i++){
		nommenu = "sousmenu"+i;
		document.getElementById(nommenu).style.display='none';
		
		if (i==currenttasktab){
			val = "in";	
		}else{
			
			val = "off";
		}

		document.getElementById("onglet_coin_g_"+i).src=doc_location+"_include/images/taskbar_onglet_"+val+"_coin_g.gif";
		document.getElementById("onglet_coin_d_"+i).src=doc_location+"_include/images/taskbar_onglet_"+val+"_coin_d.gif";
		document.getElementById("onglet_bg_"+i).style.backgroundImage = "url("+doc_location+"_include/images/taskbar_onglet_"+val+"_bg.gif)";
		
	}
	
	document.getElementById("sousmenu"+currenttasktab).style.display='';
	/*Fade ("sousmenu"+currenttasktab,'in','0.1');*/
	//document.getElementById('sousmenu'+nb).style.display='none';
	
}

function TaskOn(nb){

	setTimeout('OpenTask('+nb+')',0);
	TaskOff();
	
}

function OpenTask(nb){
	
	nommenu = "sousmenu"+nb;
	
	document.getElementById("sousmenu"+currenttasktab).style.display='none';
	document.getElementById(nommenu).style.display='';
	/*if (document.getElementById(nommenu).style.display=='none'){
		
		Fade (nommenu,'in','0.1');
		
	}*/
	
	
	document.getElementById("onglet_coin_g_"+nb).src=doc_location+'_include/images/taskbar_onglet_on_coin_g.gif';
	document.getElementById("onglet_coin_d_"+nb).src=doc_location+'_include/images/taskbar_onglet_on_coin_d.gif';
	document.getElementById("onglet_bg_"+nb).style.backgroundImage = "url("+doc_location+'_include/images/taskbar_onglet_on_bg.gif)';

}

function SelectVisible(v,elem) {
		for (var i=0;i<elem.length;i++) elem[i].style.visibility=v;
}

function largeur_fenetre(){
	if (window.innerWidth) return window.innerWidth;
	else if (document.body && document.body.offsetWidth) return document.body.offsetWidth;
	else return 0;
}

function hauteur_fenetre(){
	if (window.innerHeight) return window.innerHeight  ;
	else if (document.body && document.body.offsetHeight) return document.body.offsetHeight;
	else return 0;
}

var timeout;

function ChangeOpacity(sens,elm,increment,nav){
	
	max_int = 1/increment;

	if (sens=="in"){
		opacity += eval(increment);
	}else{
		opacity -= eval(increment);
	}
	
	eval (opacity);

	if (nav=="moz"){
		document.getElementById(elm).style.MozOpacity=opacity;
	}else if (nav=="ie"){ 
		document.getElementById(elm).style.filter = "alpha(opacity="+(100*eval(opacity))+")";
	}else{

		if (sens=="in"){
			document.getElementById(elm).style.display = "";
		}else{
			document.getElementById(elm).style.display = "none";
		}
		
		window.clearInterval(fade);

	}

	nb_int += 1; 

	if (nb_int>=max_int){

		window.clearInterval(fade); 

		if (document.getElementById(elm).style.display=="" && sens == "out"){
			InvDisplay(elm);
		}
	}

}

function Fade (elm,sens,increment){
	
	if (sens=="in"){
		opacity = 0;
	}else{
		opacity = 1;
	}

	nav = "none";
	nb_int = 0;
	
	if (document.getElementById(elm) && document.getElementById(elm).style.MozOpacity){ //if Firefox/ NS6+
		nav = "moz";
	}else if (document.getElementById(elm) && document.getElementById(elm).style.filter){
		nav = "ie";
	}

	
	fade = window.setInterval("ChangeOpacity('"+sens+"','"+elm+"','"+increment+"','"+nav+"')",10);

}

///////////// FIN FONCTIONS DU MENU /////////////
