function Menu(Name) {
	this.Name=null;	
	if( Name ) {this.Name = Name;}
	this.Create = function Menu_Create() {
		if ( this.Name ) {
			frame = this.FindFrame();
    	    this.div = frame.document.getElementById("menu");
			this.div.innerHTML +='<div class="submenu" id="' + this.Name + '"></div>';
			this.Style(); //background-repeat:no-repeat;
		}
	} // fin Menu_Create()
		
	this.addLien = function Menu_addLien(strURL,strName) {
		//window.alert(strURL);
    	var	strTemp = '<center><table border=0 cellpadding=3><tr><td><a class="blanc" href="' + strURL + '" >' + strName + '</a></td></tr></table></center>';
		this.div.menu = this.GetId();
		this.div.menu.innerHTML += strTemp;
	} // fin Menu_addLien
		
	this.Style = function Menu_Style() {
		menuId = this.GetId();

		if (this.FindFrame() != self ) {
			menuId.style.left = 0;
		}
		menuId.style.backgroundColor = "#C04040";
		menuId.style.border = '2px groove black';
		// On place la taille à 1, puis la placera en auto à l'affichage
		// tout ceci pour eviter d'avoir une scrollbar verticale
		menuId.style.height = '0';
	} // fin Menu_Style()

	this.Cache = function Menu_Cache() {
		menuId = this.GetId();

		if (menuId != null) {
			menuId.style.visibility="hidden";
			return 1;
		}
		return 0;
	} // fin Menu_Cache()
		
	this.Affiche = function Menu_Affiche(aEvent) {
		var menuId = this.GetId();

		if (menuId != null) {
			menuId.style.height="auto";
		    var myEvent = aEvent ? aEvent : window.event;
				
			menuId.style.top = myEvent.clientY - (myEvent.clientY % 50);
			menuId.style.visibility="visible";
		}
	} // fin Menu_Affiche()
		
	this.GetId = function Menu_GetId() {
		if (this.Name==null) {
			return null;
		}
		
		frame = this.FindFrame();
		return frame.document.getElementById( this.Name );
	} // fin Menu_GetId()
		
	this.FindFrame = function Menu_FindFrame() {
		var mother = window.parent;
		var main = null;//mother.frames["droite"];
     	if ( main != null ) {
     		return main;
		} else {
			// Debug
			return self;
		}
	} // fin Menu_FindFrame()
} // fin Menu

function Lien(Name) {
	this.Name=Name;
	
	this.GetId = function GetId() {
		return document.getElementById( this.Name );
	} // fin GetId
} // fin Lien

function Bouton(idx,lnkName,imgName,menuName) {
	this.idx=idx;
	this.imgName=imgName;
	this.link = new Lien(lnkName);
	this.menu = new Menu(menuName);
	this.clockId=null;
	this.bmpOn = new Image(140,31);
   	this.bmpOn.src = "img/"+this.imgName+"on.jpg";
 	this.bmpOff = new Image(140,31);
 	this.bmpOff.src = "img/"+this.imgName+"off.jpg";
	
	this.push = function Bouton_EnfonceBouton(event) {
    	document [this.imgName].src = this.bmpOn.src;

		//Efface tous les menus sauf le menu courant
		clearAllTimeout(this.idx);		
		this.menu.Affiche(event);
	}
	
	this.release = function Bouton_RelacheBouton() {
        document [this.imgName].src = this.bmpOff.src;

		this.delai2cache();
	}

	this.delai2cache = function Bouton_DelaiToCacheMenu(){
		var cmd="button["+this.idx+"].menu.Cache();";
	    this.clockId=window.setTimeout(cmd,300);
	} // fin DelaiToCacheMenu

	this.stopdelai2cache = function Bouton_StopDelaiToCacheMenu(){
		window.clearTimeout(this.clockId);
	} // fin StopDelaiToCacheMenu()
} // fin class Bouton

function clearAllTimeout(idx) {
    for(var i in button) {
		button[i].stopdelai2cache();
		if ((i != idx ) && (button[i].clockId != null)) {
			button[i].menu.Cache();
		}
	}
} // fin clearAllTimeout


