//------------ Methods ------------//
function LqcMenu_addMenuId( menuId ){
	this.arTabId.push( menuId );
}
function LqcMenu_getDiv( divId ){
	if( document.getElementById ){
		return document.getElementById( divId );
	} else if( document.all ) {
		return document.all[divId];
	} else {
		 throw new Error( 'LqcMenu.js::getDiv : ' + msg__LqcMenu_nogetelement );		
	}
}
function LqcMenu_getLeft( oElt ){
	if( this.leftValue ){
		return this.leftValue;
	}
	this.leftValue = 0;
	var oTemp = oElt;
	while( oTemp.offsetParent ){
		this.leftValue += oTemp.offsetParent.offsetLeft;
		oTemp = oTemp.offsetParent;
	}
	return this.leftValue;
}
function LqcMenu_getTop( oElt ){
	if( this.topValue ){
		return this.topValue;
	}
	this.topValue = 0;
	var oTemp = oElt;
	while( oTemp.offsetParent ){
		this.topValue += oTemp.offsetParent.offsetTop;
		oTemp = oTemp.offsetParent;
	}
	return this.topValue;
}
function LqcMenu_hideAllMenu(){
	for( var i = 0; i < this.arTabId.length; i++ ){
		this.realHideMenu( this.arTabId[i] );
	}
}
function LqcMenu_hideMenu(){
	if( this.timerHide == null ){
		this.timerHide = setTimeout('lqcMenu.hideAllMenu()', this.timerDelay);
	}
}
function LqcMenu_init(){
	this.setPosition();
}
function LqcMenu_initMenu( menuId ){
	//Set DIV left and top
	try{
		var oDiv = this.getDiv( 'menu' + menuId );
		var oTab = this.getDiv( 'father' + menuId );
		if( oDiv && oTab){
			oDiv.style.left = (this.getLeft(oTab) + oTab.offsetLeft - 1) + "px";
			oDiv.style.top = (this.getTop(oTab) + oTab.offsetHeight - 1) + "px";
		}
	} catch( ex ){
		throw new Error( 'LqcMenu.js::initMenu : oDiv\n' + ex );
	}
}
function LqcMenu_keepMenu(){
	if( this.timerHide ){
		clearTimeout(this.timerHide);
		this.timerHide = null;
	}
}
function LqcMenu_realHideMenu( menuId ){
	//Set DIV visibility
	try{
		var oDiv = this.getDiv( 'menu' + menuId );
		if( oDiv ){
			this.setDivDisplay( oDiv, 'none' );
		}
	} catch( ex ){
		throw new Error( 'LqcMenu.js::hideMenu : oDiv\n' + ex );
	}
}
function LqcMenu_setDivDisplay( oDiv, strDisplay ){
	if( oDiv.style ){
		oDiv.style.display = strDisplay;
	} else {
		throw new Error( 'LqcMenu.js::setDivDisplay : ' + msg__LqcMenu_nostyle );
	}
}
function LqcMenu_setObjClassName( obj, strClassName ){
	if( obj.className ){
		obj.className = strClassName;
	} else {
		throw new Error( 'LqcMenu.js::setObjClassName : ' + msg__LqcMenu_noclassname );
	}
}
function LqcMenu_setPosition(){
	this.topValue = null;
	this.leftValue = null;
	for( var i = 0; i < this.arTabId.length; i++ ){
		this.initMenu( this.arTabId[i] );
	}
}
function LqcMenu_showMenu( menuId ){
	//Hide all menu
	this.hideAllMenu();
	
	//Set DIV visibility
	try{
		var oDiv = this.getDiv( 'menu' + menuId );
		if( oDiv ){
			this.setDivDisplay( oDiv, 'block' );
		}
	} catch( ex ){
		throw new Error( 'LqcMenu.js::hideMenu : oDiv\n' + ex );
	}
}

//------------ Constructor ------------//
function LqcMenu(){
	//Properties
	this.arTabId = [];
	this.currentMenuId = "";
	this.topValue = null;
	this.leftValue = null;
	this.timerHide = null;
	this.timerDelay = 200;
	
	//Methods
	this.addMenuId = LqcMenu_addMenuId;
	this.getDiv = LqcMenu_getDiv;
	this.getTop = LqcMenu_getTop;
	this.getLeft = LqcMenu_getLeft;
	this.hideAllMenu = LqcMenu_hideAllMenu;
	this.hideMenu = LqcMenu_hideMenu;
	this.init = LqcMenu_init;
	this.initMenu = LqcMenu_initMenu;
	this.keepMenu = LqcMenu_keepMenu;
	this.realHideMenu = LqcMenu_realHideMenu;
	this.setDivDisplay = LqcMenu_setDivDisplay;
	this.setPosition = LqcMenu_setPosition;
	this.setObjClassName = LqcMenu_setObjClassName;
	this.showMenu = LqcMenu_showMenu;
}