var intCount = 0;
var intCountPass = 0;

//-Fonction d'ajout d'entrées principales-------------------------
function DynamicMenu_addParent(strName, strUrl) {
	var strID = 'ID' + intCount++; 

	var strTemp = '<div id="' + strID + '" class="parent" onClick="expandCollapse(this);">';
	strTemp += '<img src="img/plus.gif" Height="12" alt="plus" />';
	strTemp += '&nbsp;' + strName;
	strTemp += '<div style="display: none" class="child"></div>';
	strTemp += '</div>';

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

function DynamicMenu_addParentDefault(strName, strUrl) {
	var strID = 'ID' + intCount++; 

	var strTemp = '<div id="' + strID + '" class="parent" onClick="expandCollapse(this);">';
	strTemp += '<img src="img/minus.gif" Height="12" alt="moins" />';
	strTemp += '&nbsp;' + strName;
	strTemp += '<div style="display: block" class="child"></div>';
	strTemp += '</div>';

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

function DynamicMenu_addParentDefaultPass(strName, strUrl) {
	var strID = 'ID' + intCountPass++; 

	var strTemp = '<div id="' + strID + '" class="infopass" onClick="expandCollapse(this);">';
	strTemp += '<img src="img/plus.gif" Height="12" alt="plus" />';
	strTemp += '&nbsp;' + strName;
	strTemp += '<div style="display: none" class="infopasschild"></div>';
	strTemp += '</div>';

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



//-Fonction d'ajout de liens dans le menu-------------------------
function DynamicMenu_addChild(strName,strURL) {
	var strTemp = '<li><a href="' + strURL + '" onClick="cancelBubble(arguments[0]);" title="'+strName+'">'+ strName + '</a></li>';
	if (document.all) {
		this.currentChild.children[1].innerHTML += strTemp;
	} else {
		this.currentChild.childNodes[2].innerHTML += strTemp;
	}
}

//-Fonction d'ajout de liens dans le menu-------------------------
function DynamicMenu_addChildactive(strName,strURL) {
	var strTemp = '<li>'+strName + '</li>';
	if (document.all) {
		this.currentChild.children[1].innerHTML += strTemp;
	} else {
		this.currentChild.childNodes[2].innerHTML += strTemp;
	}
}
//-Fonction d'ajout de liens dans le menu-------------------------
function DynamicMenu_addChildPass(strName,strURL) {
	var strTemp = '<li><a href="' + strURL + '" onClick="cancelBubble(arguments[0]);" title="'+strName+'">'+ strName + '</a></li>';
	if (document.all) {
		this.currentChild.children[1].innerHTML += strTemp;
	} else {
		this.currentChild.childNodes[2].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-----------------------------------
function expandCollapse(objElement) {
	if (document.all) {
		var imgIcon = objElement.children[0];
		objElement = objElement.children[1];
	} else {
		var imgIcon = objElement.childNodes[0];
		objElement = objElement.childNodes[2];
	}
	if (objElement.style.display == "none") {  
		objElement.style.display = "block" ;
		imgIcon.src = "img/minus.gif" ;
	} else {
		objElement.style.display = "none" ;
		imgIcon.src = "img/plus.gif" ;
	}
}

//-Fonction de création de menu dynamique------------------------- 
function DynamicMenu() {
	var id = "Menu" + intCount++;
	document.write('<ul>');
	document.write('<div id="' + id + '"></div>');

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

	this.addParentDefault = DynamicMenu_addParentDefault;
	this.addParent = DynamicMenu_addParent;
	this.addChild = DynamicMenu_addChild;
	this.addChildactive = DynamicMenu_addChildactive;
	document.write('</ul>');
}

function DynamicMenuPass() {
	var id = "Menu1";
	document.write('<ul>');
	document.write('<div id="' + id + '"></div>');

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

	this.addParentDefaultPass = DynamicMenu_addParentDefaultPass;
	this.addChildPass = DynamicMenu_addChildPass;
	document.write('</ul>');
}


