// JavaScript Document
function init(pageLocation)
{
	initMenu(pageLocation);
	//initMenuDateprelevements();
	initMenuHeader();
	initMenuEspaceChasseur(pageLocation);
	initMenuGoodiesPhotos();
	initMenuEspace();
	//initMenuDateprelevements();
}


//******************************************************************************************
//** GESTION DU MENU HEADER TOP, pour rendre les LI cliquables et pour le rollover sous IE6
//******************************************************************************************
function initMenu(pageLocation)
{	
	var tabLi = document.getElementsByTagName("LI");
	/*
	if(pageLocation == 'index')
	{
		var tabURL = new Array('index.php','cpu-pages/cpu-cest-quoi-01.php','cpu-pages/cpu-mon-compte-01.php','cpu-pages/cpu-contact-01.php');
	}
	else
	{
		var tabURL = new Array('../index.php','cpu-cest-quoi-01.php','cpu-mon-compte-01.php','cpu-contact-01.php');
	}
	*/
	for( i=0; i<tabLi.length; i++)
	{
		if(tabLi[i].parentNode.parentNode.id == 'menu-header-top')
		{			
			var btn = tabLi[i];
			//btn.url = tabURL[i];
			btn.url = tabLi[i].firstChild.href;
			
			btn.onclick = function(){ document.location.href = this.url };
			
			if( btn.className != 'selected')
			{
				btn.onmouseover = function()
				{
					this.style.backgroundColor = '#fcca00';
				};
				
				btn.onmouseout = function()
				{
					this.style.backgroundColor = '';
				};
			}
		}
	}
}

//******************************************************************************************
//** GESTION DU MENU DATE-PRELEVEMENTS
//******************************************************************************************
function initMenuDateprelevements()
{	
	/*var tabLi = document.getElementsByTagName("LI");
	var tabMenuLi = new Array();
	var tabURL = new Array('cpu-fnc-saisie-02.php?date=7','cpu-fnc-saisie-02.php?date=8','cpu-fnc-saisie-02.php?date=9','cpu-fnc-saisie-02.php?date=10','cpu-fnc-saisie-02.php?date=11','cpu-fnc-saisie-02.php?date=12','cpu-fnc-saisie-02.php?date=1','cpu-fnc-saisie-02.php?date=2');
	
	for(i=0; i<tabLi.length; i++){	
		if(tabLi[i].parentNode.className == 'submenu')
		{			
			tabMenuLi.push(tabLi[i]);
		}
	}

	for( i=0; i<tabMenuLi.length; i++)
	{			
			var btn = tabMenuLi[i];
			btn.url = tabURL[i];
			btn.onclick = function(){ document.location.href = this.url };		
			
			if( btn.className != 'selected')
			{
				btn.onmouseover = function()
				{
					this.style.backgroundColor = '#f4a306';
				};
				
				btn.onmouseout = function()
				{
					this.style.backgroundColor = '';
				};
			}
	}*/
}

//******************************************************************************************
//** MENU ESPACE
//******************************************************************************************
function initMenuEspace()
{	
	var tabLi = document.getElementsByTagName("LI");
	var tabMenuLi = new Array();
	var tabURL = new Array('cpu-fnc-tableaux-bords-01.htm','cpu-fnc-saisie-02.php','#');

	for(i=0; i<tabLi.length; i++){	
		if(tabLi[i].parentNode.className == 'submenu-espace')
		{			
			tabMenuLi.push(tabLi[i]);
		}
	}

	for( i=0; i<tabMenuLi.length; i++)
	{			
			var btn = tabMenuLi[i];
			btn.url = tabURL[i];
			
			btn.onclick = function(){ document.location.href = this.url };		
			
			if( btn.className != 'selected')
			{
				btn.onmouseover = function()
				{
					this.style.backgroundColor = '#f29400';
				};
				
				btn.onmouseout = function()
				{
					this.style.backgroundColor = '';
				};
			}
	}
}

//******************************************************************************************
//** GESTION DU MENU HEADER, menu avec images
//******************************************************************************************
function initMenuHeader()
{	
	var tabLi = document.getElementsByTagName("LI");
	
	for( i=0; i<tabLi.length; i++)
	{
		if(tabLi[i].parentNode.parentNode.id == 'menu-header')
		{			
			var btn = tabLi[i];
			btn.imgsrc = btn.firstChild.firstChild.src;
			
			btn.imgsrcoverExtension = btn.imgsrc.substring(btn.imgsrc.lastIndexOf('.'));
			btn.imgsrcoverFile = btn.imgsrc.substr(0,btn.imgsrc.lastIndexOf('.'));		
			btn.imgsrcover = btn.imgsrcoverFile + '2' + btn.imgsrcoverExtension;			
			
			btn.index = btn.imgsrc.substr(btn.imgsrc.length-7,1);
			
			if(btn.index == '-')
			{
				btn.onmouseover = function()
				{
					this.firstChild.firstChild.src = this.imgsrcover;
				};
				
				btn.onmouseout = function()
				{
					this.firstChild.firstChild.src = this.imgsrc;
				};
			}
		}
	}

}

//******************************************************************************************
//** GESTION DU MENU ESPACE CHASSEUR
//******************************************************************************************
function initMenuEspaceChasseur()
{	
	var tabLi = document.getElementsByTagName("LI");
	var tabMenuLi = new Array();
	
	/*
	var tabURL = new Array(
		'../index.php',
		'cpu-cest-quoi-01.php',
		'cpu-mon-compte-01.php',
		'cpu-contact-01.php',
		'../index.php',
		'cpu-cest-quoi-01.php',
		'cpu-mon-compte-01.php',
		'cpu-contact-01.php',
		'../index.php',
		'cpu-cest-quoi-01.php',
		'cpu-mon-compte-01.php',
		'cpu-contact-01.php'
	);
	*/
	
	for( i=0; i<tabLi.length; i++)
	{	

		if(tabLi[i].parentNode.className == 'submenu-account')
		{			
			tabMenuLi.push(tabLi[i]);
		}
	}
	
	for( i=0; i<tabMenuLi.length; i++)
	{	
			var btn = tabMenuLi[i];
			
			//alert(btn.firstChild.href);			
			//btn.url = tabURL[i];
			btn.url = btn.firstChild.href;
			btn.onclick = function(){ document.location.href = this.url };		
			
			if( btn.className != 'selected') {
				btn.onmouseover = function()
				{
					this.style.backgroundImage = 'url(../cpu-images/cpu-menu-espace/bkg-btn-012.gif)';
				};
				
				btn.onmouseout = function()
				{
					this.style.backgroundImage = 'url(../cpu-images/cpu-menu-espace/bkg-btn-01.gif)';
				};
			}
	}
	
}


//******************************************************************************************
//** GESTION DU MENU GOODIES PHOTOS
//******************************************************************************************
function initMenuGoodiesPhotos()
{	
	var tabLi = document.getElementsByTagName("LI");
	var tabMenuLi = new Array();

/*
	var tabURL = new Array(
		'?theme=1',
		'?theme=2',
		'?theme=3',
		'?theme=4',
		'?theme=5',
		'?theme=6',
		'?theme=7'
	);
*/	
	
	for( i=0; i<tabLi.length; i++)
	{	
		if(tabLi[i].parentNode.className == 'photos-menu')
		{			
			tabMenuLi.push(tabLi[i]);
		}
	}
	
	for( i=0; i<tabMenuLi.length; i++)
	{	
			
			var btn = tabMenuLi[i];
			btn.url = btn.firstChild.href;
		
			btn.onclick = function(){ document.location.href = this.url };		
			
			if( btn.className != 'menu-select')
			{
				btn.onmouseover = function()
				{
					this.className = 'menu-select';
				};
				
				btn.onmouseout = function()
				{
					this.className = 'menu';
				};
			}
	}
}


function fleche_goodies() {
	var fleche_01 = document.getElementById("fleche-01");
	var fleche_02 = document.getElementById("fleche-02");
	
	fleche_01.onmouseout = function() { this.className = 'fleche-01'; };
	fleche_01.onmouseover = function() { this.className = 'fleche-12'; };
				
	fleche_02.onmouseout = function() { this.className = 'fleche-02'; };
	fleche_02.onmouseover = function() { this.className = 'fleche-22'; };
}

//******************************************************************************************
//** GESTION DU MENU ESPECES
//******************************************************************************************
function initMenuEspeces()
{	
	var tabLi = document.getElementsByTagName("LI");
	var tabMenuLi = new Array();
	
	for( i=0; i<tabLi.length; i++)
	{
		if(tabLi[i].parentNode.id == 'ul-especes')
		{			
			tabMenuLi.push(tabLi[i]);
		}
	}
	
	for( i=0; i<tabMenuLi.length; i++)
	{	
			var btn = tabMenuLi[i];
			btn.url = btn.firstChild.href;
			
			btn.onclick = function(){ document.location.href = this.url };		
			
			if( btn.className != 'selected')
			{
				btn.onmouseover = function()
				{
					this.style.backgroundImage = 'url(../cpu-images/cpu-especes/bkg-btn-012.gif)';
				};
				
				btn.onmouseout = function()
				{
					this.style.backgroundImage = 'url(../cpu-images/cpu-especes/bkg-btn-01.gif)';
				};
			}
	}
	
}

//******************************************************************************************
//** GESTION DES BLOC PDF - TABLEAU DE BORD
//******************************************************************************************



function bloc_pdf(div,nb) {
	
	for (i=1; i<=4; i++){
	document.getElementById('bloc-0'+i).className = 'cadre-pdf';
	}
	
	document.getElementById(div).className = 'cadre-pdf-select';
	document.getElementById('selection').value = nb;
}

