var plus = "./icons-banners/plus.jpg";
var moins = "./icons-banners/moins.jpg";

var liste_Menu = new Array();

function AniMenu(id)
{
	if(liste_Menu[id].Ouvert)
	{
		document.getElementById('Menu_' + id).style.display = "none";
		document.getElementById('Image_Menu_' + id).src = plus;
		liste_Menu[id].Ouvert = false;
	}
	else
	{
		document.getElementById('Menu_' + id).style.display = "";
		document.getElementById('Image_Menu_' + id).src = moins;
		liste_Menu[id].Ouvert = true;
	}
}

function Affichage()
{
	var texte = "";
	
	for(var compteur = 0; compteur < liste_Menu.length; compteur++ )
	{
		texte += CreationMenu(compteur);
	}
	document.getElementById("menu").innerHTML = texte;

	if (location.search) 
	{
		param = location.search.substring(1);
		t_param = param.split("&");
		num = t_param[t_param.length - 1];
	}
	else
	{
		num = "0";
	}
	AniMenu(num);
}
		
function CreationMenu( id )
{
	var Menu = liste_Menu[id];
	var tableau = "";
	
	tableau = "\n<table border='0' width ='154' cellpadding ='1' cellspacing ='0'>\n";
	tableau += "	<tr>\n";
	tableau += "		<td class='haut'>\n";
	tableau += "			<table border='0' cellpadding = '0' cellspacing = '0'>\n";
	tableau += "				<tr>\n";
	tableau += "					<td height = '25' width = '16'>\n";
	tableau += "						<img src='./icons-banners/bord_gauche.jpg' border='0' width='16' height='25' alt=''>\n";
	tableau += "					</td>\n";
	tableau += "					<td class='lien-menu' height = '25' width = '131' background='./icons-banners/center-red.jpg'>\n";
	tableau += "						<a href='" + Menu.Lien + "?&" + id + "'>" + Menu.Titre + "</a>\n";
	tableau += "					</td>\n";
	tableau += "					<td>\n";
	tableau += "						<img id='Image_Menu_" + id + "' onClick = 'javascript:AniMenu(" + id + ");' style='cursor:hand;'  src='./icons-banners/plus.jpg' border='0' width='22' height='25' alt=''>\n";
	tableau += "					</td>\n";
	tableau += "					<td height = '25' width = '5'>\n";
	tableau += "						<img src='./icons-banners/bord_droit.jpg' border='0' width='5' height='25' alt=''>\n";
	tableau += "					</td>\n";
	tableau += "				</tr>\n";
	tableau += "			</table>\n";
	tableau += "		</td>\n";
	tableau += "	</tr>\n";
	tableau += "	<tr id = 'Menu_" + id + "' style='display: none'>\n";
	tableau += "		<td class='bas'>\n";
	tableau += "			<table border='0' width='100%' cellpadding='0' cellspacing='0'>\n";

	for( var compteur = 0; compteur < Menu.Liste_Lien.length; compteur++ )
	{	
		tableau += "				<tr>\n";
		tableau += "					<td height = '15' width = '1%'>\n";
		tableau += "						<img src='" + Menu.Liste_Lien[compteur].Image + "' border='0' width='10' height='10' align='left'>\n";
		tableau += "					</td>\n";
		tableau += "					<td class='lien-menu' height = '15'>\n";
		tableau += "						<a href = '" + Menu.Liste_Lien[compteur].Lien + "?&" + id + "' target = '" + Menu.Liste_Lien[compteur].Target + "'>&nbsp;" + Menu.Liste_Lien[compteur].Titre + "&nbsp;</a>\n";
		tableau += "					</td>";
		tableau += "				</tr>\n";
	}
	
	tableau += "			</table>\n";
	tableau += "		</td>\n";
	tableau += "	</tr>\n";
	tableau += "</table>\n";
	return tableau;
}

function CreerLien( titre_lien, lien, target, image)
{
	this.Liste_Lien[this.Liste_Lien.length] = new Lien( titre_lien, lien, target, image);
}

function Menu( titre_categorie, lien )
{
	this.Titre = titre_categorie;
	this.Lien = lien;
	
	this.Ouvert = false;
	
	liste_Menu[liste_Menu.length] = this;
	
	
	this.Liste_Lien = new Array();
	this.Creation_Lien = CreerLien;
	
	this.Creation_Menu = CreationMenu;
}

function Lien( titre_lien, lien, target, image)
{
	this.Titre = titre_lien;
	this.Lien = lien;
	
	this.Target = target;

	this.Image = image;
}

function favoris()
{
	if ( navigator.appName != 'Microsoft Internet Explorer' )
	{ window.sidebar.addPanel("ffjsn","http://www.ffjsn.com",""); }
	else { window.external.AddFavorite("http://www.ffjsn.com","ffjsn"); } 
}
