MENUBAR_MAXCHILD = 4;
MENUBAR_LASTLABEL = "...";
var initCalled = false;
MENUBAR_SEPARATOR = " ";

function initMenus()
{
	var menuBar = menuBars[0];
	// menuBar location
	
	var img = getImage("menuPlaceHolder0");
	if (img)
		menuBar.setPosition(getImagePageLeft(img), getImagePageTop(img));

	menuBar.create();
	menuBar.setzIndex(500);
}

/////////////////////////////////////////////////////////////////////
var menuSeparator = getAccessory("hsh:menuSeparatorColor","#000000");
var menuBgColor = getAccessory("*hsh:PTR_menuBgColor","#ffda01");
var menuFgColor = getAccessory("hsh:menuFgColor","#ff0000");
var menuHiBgColor = getAccessory("hsh:menuHiBgColor","#00ff00");
var menuHiFgColor = getAccessory("hsh:menuHiFgColor","#ffda01");


//fontFamily, fontWeight, fontSize, textDecoration, hiTextDecoration
var fontFamily = "Verdana, Arial, Helvetica";
var fontWeight = "bold";
var fontSize = "11px";
var textDecoration = "none";
var hiTextDecoration = "none";
/////////////////////////////////////////////////////////////////////

function customMenu() {
    // add call to 'initMenus the first time
    // customMenu is called
    if(!initCalled) {
	addLoadAction(initMenus);
	initCalled = true;
    }
    // In this theme, only one menuBar
    var menuBar = menuBars[0];
    
    // menuBar Options
    menuBar.setOrientation("horizontal");

    // levels Options
    var group = menuBar.childGroup;
    
    setGroupOptions(group, true);

    var n = (menuBar.childGroup.items.length+1) >> 1;
    // il faut le positionnner un peu plus sur la droite
    
    var w = n * 116 + (n-1)*10;
    var x = w > 800 ? 0 : (800 - (w-116)) >> 1;

	 x = 20

    // place holder image
    document.write("<IMG SRC='./iso_icons/empty.gif' WIDTH='"+x+"' HEIGHT='25' ALIGN='absmiddle'>");
    document.write("<IMG NAME='menuPlaceHolder0' ID='menuPlaceHolder0' SRC='./iso_icons/empty.gif' WIDTH='1' ALIGN='absmiddle' HEIGHT='25'>");
    
}

function setGroupOptions(group, bFirst) {
    group.setSizes (2,5,1);
    //borderColor, fgColor, bgColor, hiFgColor, hiBgColor
    group.setColors(menuSeparator, menuFgColor, menuBgColor, menuHiFgColor, menuHiBgColor);
    // fontFamily, fontWeight, fontSize, textDecoration, hiTextDecoration
    group.setFonts(fontFamily, fontWeight, fontSize, textDecoration, hiTextDecoration);
    if (bFirst != true) {
	//decoration, hiDecoration, nextImg, hiNextImg
	group.setDecoration("", "", "<img src='./iso_icons/img_next.png'>&nbsp;", 
			    "<img src='./iso_icons/hi_img_next.png'>&nbsp;");
	group.setTextAlign("left");
    }
    else {
	group.setBackground("./iso_icons/bouton.png",140,35);
	group.setTextAlign("center");
    }
    for (var i=0 ; i<group.items.length ; i++) {
	var item = group.items[i];
	if (item.childGroup != null) {
	    setGroupOptions(item.childGroup, false);
	}
    }
}

