// ============================================= DETECTION FIREFOX
 function detectionFirefox()
    {
        if(navigator.userAgent.indexOf("Mozilla")!=-1 && navigator.userAgent.indexOf("Safari")==-1 && navigator.userAgent.indexOf("MSIE")==-1)
        {
          //  alert("Firefox"); // ici on indique quoi faire pour firefox
		  return true;
        }else{
			return false;	
		}
    }

function openMusic(lienIE,lienFirefox) {
	if(detectionFirefox()) {
		window.open(lienFirefox);
	}else{
		document.location=lienIE;
	}
}


// ============================================= FONCTIONNEMENT DU MENU
	function hover(obj){
		UL = obj.getElementsByTagName('ul');
		if(UL.length > 0){
		  sousMenu = UL[0].style;
		  if(sousMenu.display == 'none' || sousMenu.display == ''){
			if(obj.firstChild.className == "lienNiv3Premier")
			{
				sousMenu.top ="-1px";
			}
			sousMenu.display = 'block';
			sousMenu.left="0";
		  }else{
			sousMenu.display = 'none';
			if(obj.firstChild.className == "lienNiv3Premier")
			{
				sousMenu.top ="0";
			}
		  }
	  }
	}
	
	function masqueTout(obj)
	{
		/*
		lesUl = obj.getElementsByTagName('ul');
		for(i=0;i<lesUl.length;i++)
		{
			lesUl[i].style.display="none";
		}
		*/
	}
	
	function setHover()
	{
		LI = document.getElementById("menu").getElementsByTagName('li');
		nLI = LI.length;
		for(i=0; i < nLI; i++)
		{
			LI[i].onmouseover = function()
			{
				hover(this);
			}
			LI[i].onmouseout = function()
			{
		  		hover(this);
			}
			window.onunload = function()
			{
				masqueTout(this);
			}
	  	}
	}
	
	
	function survolMenu()
	{
		var tableA = document.getElementById("menu").getElementsByTagName("a"); // tableau avec tous les liens contenu dans "menu"
		var tableANiv1 = new Array; // tableau avec tous les liens de niveau 1
		var tableANiv2 = new Array; // tableau avec tous les liens de niveau 2
		var tableUl = document.getElementById("menu").getElementsByTagName("ul"); // tableau avec tous les ul contenus dans "menu"
		
		nA = tableA.length;
		nUl = tableUl.length;
		
		function survolA(objet)
		{
			// c'est un lien de niveau 1
			if(objet.className == "lienNiv1" || objet.className == "lienNiv1Actif")
			{
				if(objet.className == "lienNiv1Actif")
				{
					objet.style.backgroundPosition = "center 0";
				}
				objet.style.color = "#fff";
			}
			
			// c'est un lien de niveau 2
			else
			{
				objet.style.backgroundPosition = "0 -50px";
				if(navigator.userAgent.indexOf("MSIE 6")!=-1)
				{
					if(objet.parentNode.lastChild.nodeName == "UL")
					{
						objet.style.margin ="0 0 -14px 0";
					}
				}
			}
			
		}
		
		function finSurvolA(objet)
		{
			// c'est un lien de niveau 1
			if(objet.className == "lienNiv1" || objet.className == "lienNiv1Actif")
			{
				if(objet.className == "lienNiv1Actif")
				{
					objet.style.backgroundPosition = "center -39px";
				}
				else
				{
					objet.style.color = "#774407";
				}
			}
			
			// c'est un lien de niveau 2
			else
			{
				objet.style.backgroundPosition = "0 0";
				if(navigator.userAgent.indexOf("MSIE 6")!=-1)
				{
					if(objet.parentNode.lastChild.nodeName == "UL")
					{
						objet.style.margin ="0 0 0 0";
					}
				}
			}
			
		}
		
		function survolUl(objet)
		{
			if(objet.parentNode.firstChild.nodeName == "SPAN")
			{
				if(objet.parentNode.firstChild.firstChild.className == "lienNiv1Actif")
				{
					objet.parentNode.firstChild.firstChild.style.backgroundPosition = "center 0";
				}
				objet.parentNode.firstChild.firstChild.style.color = "#fff";
			}
			else
			{
				objet.parentNode.firstChild.style.backgroundPosition = "0 -50px";
				if(navigator.userAgent.indexOf("MSIE 6")!=-1)
				{
					if(objet.parentNode.firstChild.parentNode.lastChild.nodeName == "UL")
					{
						objet.parentNode.firstChild.style.margin ="0 0 -13px 0";
					}
				}
			}
		}
		
		function finSurvolUl(objet)
		{
			if(objet.parentNode.firstChild.nodeName == "SPAN")
			{
				if(objet.parentNode.firstChild.firstChild.className == "lienNiv1Actif")
				{
					objet.parentNode.firstChild.firstChild.style.backgroundPosition = "center -39px";
				}
				else
				{
					objet.parentNode.firstChild.firstChild.style.color = "#774407";
				}
			}
			else
			{
				objet.parentNode.firstChild.style.backgroundPosition = "0 0";
				if(navigator.userAgent.indexOf("MSIE 6")!=-1)
				{
					if(objet.parentNode.firstChild.parentNode.lastChild.nodeName == "UL")
					{
						objet.parentNode.firstChild.style.margin ="0 0 0 0";
					}
				}
			}
			
		}
		
		
		for(i=0; i < nA; i++)
		{
			tableA[i].onmouseover = function(){ survolA(this);};
			tableA[i].onmouseout = function(){ finSurvolA(this);};
	  	}
		
		for(i=0; i < nUl; i++)
		{
			tableUl[i].onmouseover = function(){ survolUl(this);};
			tableUl[i].onmouseout = function(){ finSurvolUl(this);};
	  	}
	}
// ============================================= FONCTIONNEMENT DU MENU	
	
	
// ============================================= FONCTIONNEMENT DE LA FENETRE MODALE	
	var hauteurContenu	= 0;
	function calculeHauteurContenu()
	{
		hauteurContenu=document.getElementById("repere").offsetTop+1;
	}
	
	var positionTimer;
	var positionFenetre;
	var positionLargeur;
	var positionHauteur;
	
	coordoonneeX = 0;
	coordoonneeY = 0;

	function alerte(fenetre,leTitre,leContenu,leContenuSwf,lalargeur,laHauteur)
	{
		largeur = lalargeur;
		hauteur = laHauteur;
		
		
		calculeHauteurContenu()
		positionFenetre = fenetre;
		positionLargeur = lalargeur+20;
		positionHauteur = laHauteur+47;
		calculeposition();
		
		if(navigator.userAgent.indexOf("MSIE 6")!=-1)
		{
			positionTimer = setInterval("calculeposition()",100);
		}
		
		document.getElementById("masque").style.display="block";
		if(navigator.userAgent.indexOf("MSIE 6")!=-1)
		{
			document.getElementById(fenetre).style.position="absolute";
		}
		
		
		if(navigator.userAgent.indexOf("MSIE 6")!=-1)
		{
			document.getElementById(fenetre).style.width = (lalargeur)+ "px";
		}
		
		document.getElementById("titreZoom").style.width = (lalargeur-29) + "px";
		document.getElementById("titreZoom").innerHTML = leTitre;
		document.getElementById("contenuZoom").innerHTML = leContenu;
		if(leContenuSwf != "")
		{
			eval(leContenuSwf);
		}
		
		document.getElementById(fenetre).style.display="block";
	}

	function calculeposition(){
		fenetre = positionFenetre;
		laLargeur = positionLargeur;
		lahauteur = positionHauteur;
		
		if(navigator.userAgent.indexOf("MSIE 6")!=-1)
		{
			var hauteurScroll=document.documentElement.scrollTop;
		}
		var largeurContenu=document.getElementById("repere").offsetLeft+1;
		
		var largeurAlerte=laLargeur;
		var hauteurAlerte=lahauteur;
		coordoonneeX=(largeurContenu-largeurAlerte)/2;
		
		if(navigator.userAgent.indexOf("MSIE 6")!=-1)
		{
			coordoonneeY=((hauteurScroll+hauteurContenu-hauteurAlerte)/2);
		}
		else
		{
			coordoonneeY=(hauteurContenu-hauteurAlerte)/2;
		}
		
		document.getElementById(fenetre).style.left=coordoonneeX+"px";
		document.getElementById(fenetre).style.top=coordoonneeY+"px";
		

		document.getElementById("masque").style.width=largeurContenu+"px";
		if(hauteurContenu < document.body.offsetHeight)
		{
			document.getElementById("masque").style.height=(document.body.offsetHeight)+"px";
		}
		else
		{
			document.getElementById("masque").style.height=(hauteurContenu)+"px";
		}
	}
	
	function replacerAlerte(fenetre,laLargeur,laHauteur){
		if(navigator.userAgent.indexOf("MSIE 6")!=-1)
		{
			var hauteurScroll=document.documentElement.scrollTop;
		}
			
		var largeurContenu=document.getElementById("repere").offsetLeft+1;
		var largeurAlerte=laLargeur+20;
		var hauteurAlerte=laHauteur+47;
		coordoonneeX=(largeurContenu-largeurAlerte)/2;
		
		if(navigator.userAgent.indexOf("MSIE 6")!=-1)
		{
			coordoonneeY=hauteurScroll+((hauteurContenu-hauteurAlerte)/2);
		}
		else
		{
			coordoonneeY=(hauteurContenu-hauteurAlerte)/2;
		}
		
		document.getElementById(fenetre).style.left=coordoonneeX+"px";
		document.getElementById(fenetre).style.top=coordoonneeY+"px";
		
		document.getElementById("masque").style.width=largeurContenu+"px";
		if(hauteurContenu < document.body.offsetHeight)
		{
			document.getElementById("masque").style.height=(document.body.offsetHeight)+"px";
		}
		else
		{
			document.getElementById("masque").style.height=(hauteurContenu)+"px";
		}
	}
	
	function fermerAlerte(fenetre){
		document.getElementById("masque").style.display="none";
		document.getElementById(fenetre).style.display="none";
		
		document.getElementById("titreZoom").innerHTML = "";
		document.getElementById("contenuZoom").innerHTML = "";
		
		if(navigator.userAgent.indexOf("MSIE 6")!=-1)
		{
			clearInterval(positionTimer);
		}
	}

// ============================================= FONCTIONNEMENT DE LA FENETRE MODALE

//rollover img game se
	function changeImg(idImg, urlImg) {
		document.getElementById(idImg).src=urlImg;
	}
	



function load_img(imgObj, imgName) {
   eval(imgObj+' = new Image()');
   eval(imgObj+'.src = "'+imgName+'"');
}

function change_img(ObjName, imgObj){
    document.images[ObjName].src = eval(imgObj+".src");
}

function init() {
  load_img('occ_out', 'images/photo/foto-okazjonalnie.jpg');
  load_img('occ_over', 'images/photo/foto-okazjonalnie_o.jpg');
  load_img('mod_out', 'images/photo/foto-czasami.jpg');
  load_img('mod_over', 'images/photo/foto-czasami_o.jpg');
  load_img('freq_out', 'images/photo/foto-czesto.jpg');
  load_img('freq_over', 'images/photo/foto-czesto_o.jpg');
  load_img('film_out', 'images/photo/foto-analog.jpg');
  load_img('film_over', 'images/photo/foto-analog_o.jpg');
  load_img('faq_out', 'images/photo/foto-faq.jpg');
  load_img('faq_over', 'images/photo/foto-faq_o.jpg');
}

function show_ans(objId) {
   obj = document.getElementById(objId);
   if (obj.style.display == "none") { obj.style.display = ""; }
   else                             { obj.style.display = "none"; }
}
	