/////////////////////////////////////////////////////////////////////////////////////////////////
/*if( document.layers ) (Only Netscape layers compliant will be true here) or
if( document['divID'] ) (Only Netscape alternative compliant will be true here) or
if( document.all ) (Only IE4+ compliant will be true here) or
if( document.getElementById ) (DOM compliant browsers will be true here)
to detect which syntax is required. Then use
myReference = document.layers['divID'] in Netscape (layers) or
myReference = document['divID'] in Netscape (alternative) or
myReference = document.all['divID'] in IE4 compatible browsers
myReference = document.getElementById('divID') in W3C compatible browsers


function getRefToDiv(divID) {
    if( document.layers ) { //Netscape layers
        return document.layers[divID]; }
    if( document.getElementById ) { //DOM; IE5, NS6, Mozilla, Opera
        return document.getElementById(divID); }
    if( document.all ) { //Proprietary DOM; IE4
        return document.all[divID]; }
    if( document[divID] ) { //Netscape alternative
        return document[divID]; }
    return false;
}*/
function getRefToDiv(divID) {
    if( document.layers ) { //Netscape layers
        alert ("NS"); }
    if( document.getElementById ) { //DOM; IE5, NS6, Mozilla, Opera
        alert ( "DOM, IE5, NS6, Mozilla, Opera"); }
    if( document.all ) { //Proprietary DOM; IE4
        alert ( "Proprietary DOM, IE4"); }
    if( document[divID] ) { //Netscape alternative
        alert ( "NS alternative"); }
}
//getRefToDiv("Menu"); //------------------> TESTER SUR Netscape 6.2 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
/////////////////////////////////////////////////////////////////////////////////////////////////////
			var positionVerticale = "enHaut";
            var intCount = 0;
			var subintCount = 1;
			var dirImg = "../img/menu/";

            //-Fonction d'ajout d'entrées principales-------------------------
            function DynamicMenu_addParent(strName,strImg,strURL) {
				intCount++;
                var strID = 'menu' + intCount + 'Parent'; 
				var strIDChild = 'menu' + intCount + 'Child';

                var strTemp = '<DIV ID="' + strID + '" CLASS="menuParent">';
				strTemp += '<A HREF="' + strURL + '" NAME="'+strImg+'"';
				strTemp += ' onMouseOver="rollOverEntry(' + intCount + '); window.status=\'' + strName + '\';return true;"';
				strTemp += ' onMouseOut="rollOutEntry(' + intCount + '); window.status=\'\'; return true;">';
				strTemp += '<IMG ID="' + strID + 'Img" SRC= "' + dirImg + strImg + '.gif'+ '" Height="16" BORDER="0">';
				strTemp += '</A>';
                strTemp += '<DIV ID="' + strIDChild + '" STYLE="display: none" CLASS="menuChild"></DIV>';
                strTemp += '</DIV>';

                this.div.innerHTML += strTemp;
                this.currentChild = document.getElementById(strID);
			
				subintCount = 1;	
            }


            //-Fonction d'ajout de liens dans le menu-------------------------
            function DynamicMenu_addChild(strName,strURL) {	
				//var tmpCount = intCount - 1;
				var strChildImg = 'menu' + intCount + 'ChildImg' + subintCount;
				
				var strTemp = '<IMG ID="'+ strChildImg +'" SRC= "' + dirImg + 'black_arrow.gif'+ '">';
                /*strTemp += '<A HREF="' + strURL + '" CLASS="menu"'
                            + ' onClick="cancelBubble(arguments[0]);setActiveSubentry('+subintCount+')">' 
                            + strName + '</A><BR>';*/
				strTemp += '<A HREF="' + strURL + '" CLASS="menu"'
                            + ' onClick="cancelBubble(arguments[0]);">' 
                            + strName + '</A><BR>';
				subintCount++;
				
                if (document.all) {
                    this.currentChild.children[1].innerHTML += strTemp;
                } else {
					this.currentChild.childNodes[1].innerHTML += strTemp;
                }
            }


            //-inhibe la cascade d'évènements au DIV conteneur----------------
            function cancelBubble(netEvent) {
                if (document.all) {
                    window.event.cancelBubble = true;
                } else {
                    netEvent.cancelBubble = true;
                }
            }

            //-Contracte ou expanse le menu-----------------------------------
			//num indique le numéro de sous-menu à allumer
            function expandCollapse(objElement,num) {
				flottementMenu();
				if (objElement != null) {
                	if (document.all) {
						// IE
                    	var imgIcon = objElement.children[0].children[0];
                    	objElement = objElement.children[1];
						if (num > -1) var imgArrow = objElement.children[3*num];
					}
					else {
						// IE 5+ et NS 6+
                    	var imgIcon = objElement.childNodes[0].childNodes[0];
                    	objElement = objElement.childNodes[1];
						if (num > -1) var imgArrow = objElement.childNodes[3*num];
                	}    
                	if (objElement.style.display == "none") {  
						//On ferme les autres sous-menus
						for (var i=1; i<intCount;i++) {
							if (document.all) {
								document.getElementById('menu'+i+'Parent').children[0].children[0].src = dirImg + document.getElementById('menu'+i+'Parent').children[0].name + ".gif";
								document.getElementById('menu'+i+'Parent').children[1].style.display = "none";
							} else {				
								document.getElementById('menu'+i+'Parent').childNodes[0].childNodes[0].src = dirImg + document.getElementById('menu'+i+'Parent').childNodes[0].name + ".gif";
								document.getElementById('menu'+i+'Parent').childNodes[1].style.display = "none";
							}
						}		
						//On ouvre le sous-menu
                    	objElement.style.display = "block" ;
						if (num > -1) imgArrow.src = dirImg + "orange_arrow.gif";
						if (document.all) {
							imgIcon.src = dirImg + objElement.parentElement.children[0].name + "_roll.gif";
						} else {
							imgIcon.src = dirImg + objElement.parentNode.childNodes[0].name + "_roll.gif"
						}
                	}
				} 
				else {
					//On ferme les sous-menus : clic sur les liens du header
					for (var i=1; i<intCount;i++) {
						if (document.all) {
							document.getElementById('menu'+i+'Parent').children[0].children[0].src = dirImg + document.getElementById('menu'+i+'Parent').children[0].name + ".gif";
							document.getElementById('menu'+i+'Parent').children[1].style.display = "none";
						} else {				
							document.getElementById('menu'+i+'Parent').childNodes[0].childNodes[0].src = dirImg + document.getElementById('menu'+i+'Parent').childNodes[0].name + ".gif";
							document.getElementById('menu'+i+'Parent').childNodes[1].style.display = "none";
						}
					}	
				}
            }

            //-RollOver sur le menu-----------------------------------
			function rollOverEntry(entryID) {
				if (entryID != activeEntry) {
					imgName = 'menu' + entryID + 'ParentImg';
				
					currentFilename = document.images[imgName].src;
					newFilename = currentFilename.substring(0, currentFilename.indexOf(".gif")) + '_roll.gif';
		
					document.images[imgName].src = newFilename;
				}
			}
			
            //-RollOut sur le menu-----------------------------------
			function rollOutEntry(entryID) {
				if (entryID != activeEntry) {
					imgName = 'menu' + entryID + 'ParentImg';
				
					currentFilename = document.images[imgName].src;
					newFilename = currentFilename.substring(0, currentFilename.indexOf("_roll")) + '.gif';
		
					document.images[imgName].src = newFilename;
				}
			}
			

            //-Rend le menu visible-----------------------------------
            function showMenu() {
				var menu = document.getElementById("menu");
				menu.style.visibility = "visible";
			}

/*
            //-Allume l'entrée sélectionnée-----------------------------------
			function setActiveEntry(entryID) {
				activeImgName = 'menu' + activeEntry + 'ParentImg';
				newImgName = 'menu' + entryID + 'ParentImg';

				// inactive old entry
				if (document.images[activeImgName]) {
					currentFilename = document.images[activeImgName].src;
					newFilename = currentFilename.substring(0, currentFilename.indexOf("_roll")) + '.gif';

					document.images[activeImgName].src = newFilename;
				}
	
				// active current entry
				if (document.images[newImgName]) {
					currentFilename = document.images[newImgName].src;
					alert("currentFilename = "+document.images[newImgName].src);
					newFilename = currentFilename.substring(0, currentFilename.indexOf(".gif")) + '_roll.gif';
		
					document.images[newImgName].src = newFilename;
				}
	
				// update active entry var
				activeEntry = entryID;
			}

            //-Allume la sous-entrée sélectionnée-----------------------------------
			function setActiveSubentry(subentryID) {
				// inactive old bullet
				if (activeSubentry > 0) {
					document.images['menu' + activeEntry + 'ChildImg' + activeSubentry].src = dirImg + "black_arrow.gif";
				}
	
				// active current bullet
				if (subentryID > 0) {
					document.images['menu' + activeEntry + 'ChildImg' + subentryID].src = dirImg + "orange_arrow.gif";
				}
	
				// update active bullet
				activeSubentry = subentryID;
			}
*/
            //-Fonction de création de menu dynamique------------------------- 
            function DynamicMenu() {
				var id = "menu";
                document.write('<DIV Id="' + id + '"></DIV>');

                this.div = document.getElementById(id);
                this.currentChild = null;

                this.addParent = DynamicMenu_addParent;
                this.addChild = DynamicMenu_addChild;
            }

			
			
            //-Fonctions de mouvement du menu------------------------- 
			function flottementMenu(){
			    //var departX = 3, departY = 250;
				var departY = 25;
				
			    var ns = (navigator.appName.indexOf("Netscape") != -1);
			    var doc = document;
			
			    function support(id) {
			      	var elt = doc.getElementById?doc.getElementById(id):
			                              doc.all?doc.all[id]:doc.layers[id];

			      	/*if (doc.layers) {
						elt.style=elt;
					}*/

			      	//elt.sP = function(x,y){ this.style.left=x;this.style.top=y; };
					elt.sP = function(y){ this.style.top=y; };
			      	//elt.x = departX;
				    if (positionVerticale=="enHaut") elt.y = departY;
      				else{
        				elt.y=ns?pageYOffset+innerHeight: 
                				document.body.scrollTop+document.body.clientHeight;
        				elt.y -=departY;
      				}
      				return elt;
    			}
			
			    window.stabilisation = function() {
      				if (positionVerticale=="enHaut") {
        				var pY = ns ? pageYOffset : document.body.scrollTop;
        				ftlObj.y += (pY + departY - ftlObj.y)/8;
      				}
      				else {
        				var pY=ns?pageYOffset+innerHeight: 
                			document.body.scrollTop+document.body.clientHeight;
        				ftlObj.y += (pY - departY - ftlObj.y)/8;
      				}
      				//ftlObj.sP(ftlObj.x, ftlObj.y);
					ftlObj.sP(ftlObj.y);
      				setTimeout("stabilisation()", 10);
    			}
    		
				ftlObj = support("menu");
    			stabilisation();
  			}


