/***************************************************************************************
ExpandMenu 1.0
****************************************************************************************/
/****************************************************************************************
* @version : 1.0
* @copyright : 2005
* @Date : 23/05/2005
* @Author : Coumarane COUPPANE
* @Mail : coumarane_c@hotmail.com
* @File name : ExpandMenu.js
****************************************************************************************/
var intCnt = 0;
var intCnt2 = 0;
var id;
function Menu (name) {
	id = "Menu" + intCnt++;
    document.write('<DIV id="' + id + '"></DIV>');
	this.name = name;
	this.mainDiv = document.getElementById (id);
	this.child = null;
	this.mainId = id;
	
}

Menu.prototype.getIdDiv = function () {
	return (this.mainDiv);
}

//var strId;
//var strSsMenuId;
var toto;
Menu.prototype.addParent = function (libelle) {
	var strId = "Id" + intCnt++;
	var strSsMenuId = "ssMenu" + intCnt2++;
	var strDiv = '<div id="'+ strId +'" class="parent" onClick="menuClick (\''+ strSsMenuId +'\'); OnclickChangeColor (\''+ strId +'\');" >';
	strDiv += libelle;
	strDiv += '<div id= "'+ strSsMenuId +'" style="display:none;" class="child"></div>';
	strDiv += '</div>';
	
	this.mainDiv.innerHTML += strDiv;
	this.idParent = document.getElementById (strId);
	this.idChild = document.getElementById (strSsMenuId);
	toto = strId;
}

Menu.prototype.addChild = function (libelle, link) {
	//var strDiv = '<a href="'+ link +'"  onClick="cancelBubble (arguments[0])">';
	var	strDiv =  '<table border="0" width="100%" onClick="cancelBubble (arguments[0])">';
		strDiv += ' <tr>';
		strDiv += '  <td bgcolor="#DEDEDE" style="font-family:verdana, arial, helvetica; font-size:12px" onMouseOver="this.style.background=\'#CECECE\'"  onMouseOut="this.style.background=\'\'"><a class="menu" href="'+ link +'"  onClick="cancelBubble (arguments[0])">' + libelle + '</a></td>';
		strDiv += ' </tr>';
		strDiv += '</table>';
	//strDiv += libelle;
	//strDiv += '<\/a><br>';
	
	if (document.all) {
		this.idChild.innerHTML += strDiv;
	} else {
		this.idChild.innerHTML += strDiv;
	}
}

function menuClick (elem) {
	var obj = document.getElementById (elem);
	var objParent = document.getElementsByTagName ('div');
	if (document.getElementById) {
		if (obj.style.display != 'block') {
			for (var i=0; i<objParent.length; i++) {
				if (objParent[i].className == 'child') {
					objParent[i].style.display = 'none';
				}
			}
			obj.style.display = 'block';
		} else {
			obj.style.display = 'none';
		}
	}
}

function cancelBubble (e) {
	if (document.all) {
		window.event.canceBubble = true;
	} else {
		e.cancelBubble = true;
	}
}

function OnclickChangeColor (elem) {
	/*
	var setColor = false;
	if (document.getElementById) {
		if (setColor == false) {
			document.getElementById(elem).style.background = '#cc0000';
		} else {
			document.getElementById(elem).style.background = '#DEE7F7';
			setColor = true;
		}
	}
	*/
}

