

var siteRoot = sectionById[siteRootId];

//////////////////////////////////////
// Menu configuration parameters
//////////////////////////////////////
var NoOffFirstLineMenus = siteRoot.getChildren().length ;			// Number of main menu  items
					// Colorvariables:
					// Color variables take HTML predefined color names or "#rrggbb" strings
					//For transparency make colors and border color ""
var LowBgColor="";			// Background color when mouse is not over
var HighBgColor="";			// Background color when mouse is over
var FontLowColor="";	// Font color when mouse is not over
var FontHighColor="";	// Font color when mouse is over
var BorderColor="";		// Border color
var BorderWidthMain=0;		// Border width main items
var BorderWidthSub=0;		// Border width sub items
var BorderBtwnMain=0;		// Borderwidth between elements
var BorderBtwnSub=0;		// Borderwidth between elements sub items
var FontFamily="Verdana,Arial,sans-serif";	// Font family menu items
var FontSize=10;			// Font size menu items
var FontBold=1;				// Bold menu items 1 or 0
var FontItalic=0;			// Italic menu items 1 or 0
var MenuTextCentered="left";	// Item text position left, center or right
var MenuCentered="left";		// Menu horizontal position can be: left, center, right
var MenuVerticalCentered="top";	// Menu vertical position top, middle,bottom or static
var ChildOverlap=0;			// horizontal overlap child/ parent
var ChildVerticalOverlap=0;	// vertical overlap child/ parent
var StartTop=1;				// Menu offset x coordinate. If StartTop is between 0 and 1 StartTop is calculated as part of windowheight
var StartLeft=0;			// Menu offset y coordinate. If StartLeft is between 0 and 1 StartLeft is calculated as part of windowheight
var VerCorrect=0;			// Multiple frames y correction
var HorCorrect=0;			// Multiple frames x correction
var DistFrmFrameBrdr=0;		// Distance between main menu and frame border
var LeftPaddng=5;			// Left padding
var TopPaddng=-1;			// Top padding. If set to -1 text is vertically centered
var FirstLineHorizontal=1;	// Number defines to which level the menu must unfold horizontal; 0 is all vertical
var MenuFramesVertical=1;	// Frames in cols or rows 1 or 0
var DissapearDelay=175;	// delay before menu folds in
var UnfoldDelay=100;		// delay before sub unfolds	
var TakeOverBgColor=1;		// Menu frame takes over background color subitem frame
var FirstLineFrame="";		// Frame where first level appears
var SecLineFrame="";		// Frame where sub levels appear
var DocTargetFrame="";		// Frame where target documents appear
var TargetLoc="mainNav2";			// span id for relative positioning
var MenuWrap=1;				// enables/ disables menu wrap 1 or 0
var RightToLeft=0;			// enables/ disables right to left unfold 1 or 0
var BottomUp=0;				// enables/ disables Bottom up unfold 1 or 0
var UnfoldsOnClick=0;		// Level 1 unfolds onclick/ onmouseover
var BaseHref="";			// BaseHref lets you specify the root directory for relative links.
var BaseImg ="/charte/www.evialis.fr/fre/prod/images/";
					// The script precedes your relative links with BaseHref
					// For instance: 
					// when your BaseHref= "http://www.MyDomain/" and a link in the menu is "subdir/MyFile.htm",
					// the script renders to: "http://www.MyDomain/subdir/MyFile.htm"
					// Can also be used when you use images in the textfields of the menu
					// "MenuX=new Array("<img src=\""+BaseHref+"MyImage\">"
					// For testing on your harddisk use syntax like: BaseHref="file:///C|/MyFiles/Homepage/"

var Arrws=["",5,10,"",10,5,"",5,10,"",10,5];

					// Arrow source, width and height.
					// If arrow images are not needed keep source ""

var MenuUsesFrames=0;	// MenuUsesFrames is only 0 when Main menu, submenus,
					// document targets and script are in the same frame.
					// In all other cases it must be 1
var OverFormElements=1;	// Set this to 0 when the menu does not need to cover form elements.
var RememberStatus=1;	// RememberStatus: When set to 1, menu unfolds to the presetted menu item. 
var BuildOnDemand=0;	// 1/0 When set to 1 the sub menus are build when the parent is moused over
var BgImgLeftOffset=0;	// Only relevant when bg image is used as rollover
var ScaleMenu=0;		// 1/0 When set to 0 Menu scales with browser text size setting
					// When set to 2 only the relevant main item stays highligthed
					// The preset is done by setting a variable in the head section of the target document.
					// <head>
					//	<script type="text/javascript">var SetMenu="2_2_1";</script>
					// </head>
					// 2_2_1 represents the menu item Menu2_2_1=new Array(.......

var HooverBold=0;		// 1 or 0
var HooverItalic=0;		// 1 or 0
var HooverUnderLine=0;	// 1 or 0
var HooverTextSize=0;	// 0=off, number is font size difference on hoover
var HooverVariant=0;	// 1 or 0

// Below some pretty useless effects, since only IE6+ supports them
// I provided 3 effects: MenuSlide, MenuShadow and MenuOpacity
// If you don't need MenuSlide just leave in the line var MenuSlide="";
// delete the other MenuSlide statements
// In general leave the MenuSlide you need in and delete the others.
// Above is also valid for MenuShadow and MenuOpacity
// You can also use other effects by specifying another filter for MenuShadow and MenuOpacity.
// You can add more filters by concanating the strings
var MenuSlide="";
//var MenuSlide="progid:DXImageTransform.Microsoft.RevealTrans(duration=.5, transition=19)";
//var MenuSlide="progid:DXImageTransform.Microsoft.GradientWipe(duration=.5, wipeStyle=1)";

var MenuShadow="";
//var MenuShadow="progid:DXImageTransform.Microsoft.DropShadow(color=#888888, offX=2, offY=2, positive=1)";
//var MenuShadow="progid:DXImageTransform.Microsoft.Shadow(color=#888888, direction=135, strength=3)";

var MenuOpacity="";
//var MenuOpacity="progid:DXImageTransform.Microsoft.Alpha(opacity=85)";

function BeforeStart(){return}
function AfterBuild(){return}
function BeforeFirstOpen(){return}
function AfterCloseAll(){return}

// Menu tree:
// MenuX=new Array("ItemText","Link","background image",number of sub elements,height,width,"bgcolor","bghighcolor",
//	"fontcolor","fonthighcolor","bordercolor","fontfamily",fontsize,fontbold,fontitalic,"textalign","statustext");
// Color and font variables defined in the menu tree take precedence over the global variables
// Fontsize, fontbold and fontitalic are ignored when set to -1.
// For rollover images ItemText or background image format is:  "rollover?"+BaseHref+"Image1.jpg?"+BaseHref+"Image2.jpg" 


////////////////////////////////////
/// Smart Section declaration
////////////////////////////////////


// Configuration
var config = new Array;

function getConfig(Elmt,aSection) {
	
 //Basic configuration
 config['BgImage'] = "";
 config['Height'] = "20";
 config['Width'] = "110";
 config['bgColor'] = "#FFF";
 config['bgHighColor'] = "#000";
 config['FontColor'] = "#000";
 config['FontHighColor'] = "#FFF";
 config['BorderColor'] = "#FFF";

if(aSection.getLevel() == 1) {
 var aWidth = aSection.name;
 config['BgImage'] = "";
 config['Height'] = "15";
 aWidth = aWidth.length*11;
 config['Width'] = aWidth;
 config['bgColor'] = "";
 config['bgHighColor'] = "";
 config['FontColor'] = "#FFF";
 config['FontHighColor'] = "#655335";
 config['BorderColor'] = "";
}

if(aSection.getLevel() == 2) {
 var aSectionName = aSection.name;
 config['BgImage'] = "";
 config['Height'] = "13";
 if(aSectionName.length > 41) {
  config['Height'] = "28";
 }
 config['Width'] = "200";
 config['bgColor'] = "#FFF";
 config['bgHighColor'] = "#FFFFFF";
 config['FontColor'] = "#BEB3A3";
 config['FontHighColor'] = "#FFF";
 config['BorderColor'] = "#CACED1";
}

if(aSection.getLevel() == 3) {
 var aSectionName = aSection.name;
 config['BgImage'] = "";
 config['Height'] = "13";
 if(aSectionName.length > 31) {
  config['Height'] = "28";
 }
 config['Width'] = "150";
 config['bgColor'] = "#FFF";
 config['bgHighColor'] = "#FFFFFF";
 config['FontColor'] = "#BEB3A3";
 config['FontHighColor'] = "#FFF";
 config['BorderColor'] = "#CACED1";
}

 return config[Elmt];
}

function buildSectionMenu(aSection) {
	var menuVar = aSection.menuVar;
	if(menuVar == null) {
		menuVar = "Menu";
	} 
	var subSections = aSection.getChildren();
	if(subSections == null) {
		return false;
	}
	for(var i=0; i < subSections.length; ++i) {
		var cSection = subSections[i];
		cSection.menuVar = menuVar+(i+1)+"_";
		cSection.menuDeclaration = "var "+menuVar+(i+1)+" = new Array(menuLabel(cSection), \""+cSection.url+"/\", \""+getConfig('BgImage',cSection)+"\", "+cSection.getChildren().length+", "+getConfig('Height',cSection)+", "+getConfig('Width',cSection)+", \""+getConfig('bgColor',cSection)+"\", \""+getConfig('bgHighColor',cSection)+"\", \""+getConfig('FontColor',cSection)+"\", \""+getConfig('FontHighColor',cSection)+"\", \""+getConfig('BorderColor',cSection)+"\", \"\", -1, -1, -1, \"\", \"Test\");"; 
	}
	return true;
}

function menuLabel(aSection) {
 var aLabel = aSection.name;
 var aUrl = ""+aSection.url+"/";
if(aSection.getLevel() == 1) {
 aLabel = "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\"><tr><td id=\"menuTdFirst\"><a href=\""+aUrl+"\" class=\"mainMenuItem firstLevel\">"+aLabel+"</a></td></tr></table>"
}
if(aSection.getLevel() == 2) {
 aLabel = "<a href=\""+aUrl+"\" class=\"mainMenuItem secondLevel\">"+aLabel+"</a>"
}
if(aSection.getLevel() == 3) {
 aLabel = "<a href=\""+aUrl+"\" class=\"mainMenuItem secondLevel\">"+aLabel+"</a>"
}

 return aLabel;
}

var treeBuilder1 = new SectionVisitor();
treeBuilder1.process = buildSectionMenu;
treeBuilder1.visit(siteRoot);

for(var id in sectionById) {
		var cSection = sectionById[id];
		if(cSection.menuDeclaration != null) {
			eval(cSection.menuDeclaration);
		}
}
