////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Menu specific functions

var K_SEP_TAB_MAIN = "|";
var K_TTW          = 300;
var K_SEP_TAG_1    = '<hr color="#555555" background-color="#555555">';
var isIE           = document.all ? true : false;
var iTC            = new Array('SELECT','OBJECT','INPUT');
var MB             = new Array();
var MBOV           = new Array();
var iMB            = 0;
var iMBOV          = 0;
var K_MB           = "b";
var K_MI           = "i";
var K_M            = "m";
var K_MS           = 's';
var K_TAB          = "a";
var K_DIV          = "d";
var K_TR           = "t";
var K_IMG          = "g";
var K_SEP          = '#separador#';
var aP             = null;
var aPT            = null;

//var inlineDivStyle   = "background: transparent none no-repeat scroll 0% 0%; border-top: 0px; border-bottom: 0px; border-left: 0px; border-right: 0px; padding-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; position: absolute; visibility: hidden; width: 0px;";
var inlineDivStyle   = "background: transparent none no-repeat scroll 0% 0%; border-top: 0px; border-bottom: 0px; border-left: 0px; border-right: 0px; padding-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; position: absolute; visibility: hidden;";
var inlineTableStyle = "background: transparent none no-repeat scroll 0% 0%; border-top: 0px; border-bottom: 0px; border-left: 0px; border-right: 0px; padding-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px;";

/////////////////////////////////////////////////////////////////
// Class that represents the whole menubar and items setup
// configurations.
//
function IMenuSetup( mbStyle , mbFirstElemStyle , mbMiddleElemStyle , mbLastElemStyle ,
                     mbFirstElemOnMouseOverStyle , mbMiddleElemOnMouseOverStyle , mbLastElemOnMouseOverStyle ,
                     mbFirstElemOnClickStyle , mbMiddleElemOnClickStyle , mbLastElemOnClickStyle ,
                     mbOverlayElemStyle , mbOverlayElemOnMouseOverStyle , mbOverlayElemOnClickStyle ,
                     
                     mpFirstElemStyle , mpMiddleElemStyle , mpLastElemStyle ,
                     mpFirstElemOnMouseOverStyle , mpMiddleElemOnMouseOverStyle , mpLastElemOnMouseOverStyle ,
                     mpFirstElemOnClickStyle , mpMiddleElemOnClickStyle , mpLastElemOnClickStyle ,
                     mpOverlayElemStyle , mpOverlayElemOnMouseOverStyle , mpOverlayElemOnClickStyle ,
                     
                     horOffsetL1 , verOffsetL1 , horOffsetL2 , verOffsetL2 , orientation , 
                     mbElemSpacing , mpElemSpacing
                   )					
{
	// Menu Bar Style
	this.menuBarStyle = mbStyle;
	
	// Menu Bar - Level 1
	this.menuBarFirstElementStyle                = mbFirstElemStyle;
	this.menuBarMiddleElementStyle               = mbMiddleElemStyle;
	this.menuBarLastElementStyle                 = mbLastElemStyle;
	this.menuBarFirstElementOnMouseOverStyle     = mbFirstElemOnMouseOverStyle;
	this.menuBarMiddleElementOnMouseOverStyle    = mbMiddleElemOnMouseOverStyle;
	this.menuBarLastElementOnMouseOverStyle      = mbLastElemOnMouseOverStyle;
	this.menuBarFirstElementOnClickStyle         = mbFirstElemOnClickStyle;
	this.menuBarMiddleElementOnClickStyle        = mbMiddleElemOnClickStyle;
	this.menuBarLastElementOnClickStyle          = mbLastElemOnClickStyle;
	this.menuBarOverlayElementStyle              = mbOverlayElemStyle;
	this.menuBarOverlayElementOnMouseOverStyle   = mbOverlayElemOnMouseOverStyle;
	this.menuBarOverlayElementOnClickStyle       = mbOverlayElemOnClickStyle;
	
	// Menu Panel - Levels [2,inf.]
	this.menuPanelFirstElementStyle              = mpFirstElemStyle;
	this.menuPanelMiddleElementStyle             = mpMiddleElemStyle;
	this.menuPanelLastElementStyle               = mpLastElemStyle;
	this.menuPanelFirstElementOnMouseOverStyle   = mpFirstElemOnMouseOverStyle;
	this.menuPanelMiddleElementOnMouseOverStyle  = mpMiddleElemOnMouseOverStyle;
	this.menuPanelLastElementOnMouseOverStyle    = mpLastElemOnMouseOverStyle;
	this.menuPanelFirstElementOnClickStyle       = mpFirstElemOnClickStyle;
	this.menuPanelMiddleElementOnClickStyle      = mpMiddleElemOnClickStyle;
	this.menuPanelLastElementOnClickStyle        = mpLastElemOnClickStyle;
	this.menuPanelOverlayElementStyle            = mpOverlayElemStyle;
	this.menuPanelOverlayElementOnMouseOverStyle = mpOverlayElemOnMouseOverStyle;
	this.menuPanelOverlayElementOnClickStyle     = mpOverlayElemOnClickStyle;
	
	// Other settings
	this.horizontalOffsetLevel1  = horOffsetL1;
	this.verticalOffsetLevel1    = verOffsetL1;
	this.horizontalOffsetLevel2  = horOffsetL2;
	this.verticalOffsetLevel2    = verOffsetL2;
	this.menuOrientation         = orientation;
	this.menuBarElementSpacing   = mbElemSpacing;
	this.menuPanelElementSpacing = mpElemSpacing;

	this.K_URL              = 'appImages/Controls/';
	this.defURLStart        = '';
}
/////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////
// Class that represents the whole menubar
//
function IMenuBar(menuSetup)
{
	this.setup  = menuSetup;
	var aId     = iMB++;
	this.v      = new Array();
	this.size   = 0;
	this.add    = IAdd;
	this.ac     = IAdd;
	this.get    = IGet;	
	this.draw   = IMBDraw;
	this.t      = K_MB;
	this.id     = K_MB + LZ(aId);
	var o       = new Object();
	o.ref       = this;
	o.ss        = new Array();
	o.iL        = 0;
	MB[this.id] = o;
	this.currentNode = null;
}

function IAdd(aLabel , aLink , isPopUp , aTarget)
{
	if(arguments.length < 3)
		isPopUp = 0;
	
	if(arguments.length < 4)
	{
		if (isPopUp) 
			aTarget = "";
		else aTarget = "main";
	}
	
	if(aLink.indexOf('?') < 0 
	&& aLink.indexOf('&') < 0 
	&& aLink.indexOf('=') < 0 
	&& aLink.indexOf('/') < 0 && aLink.length == 32) 
	{
		var cfg = getMB(this.id).setup;
		aLink = cfg.defURLStart + aLink;
	}
	
	var isInMB = false;
	if(this.t == K_MI)
	{
		this.v  = new Array();
		this.size = 0;
		this.t = K_M;
		var n = this.id.indexOf(K_MI);
		this.id = this.id.substring(0 , n) + K_M + this.id.substr(n + 1);
	}	
	else if(this.t == K_MB)
	{
		isInMB = true;
		if(aLabel == K_SEP)
			return;
	}
	
	var aNewId   = this.id + K_MI + LZ(this.size);	
	var aNewMI   = new IMenuItem(this , aNewId   , isInMB , aLabel , aLink , isPopUp , aTarget);
	this.v[this.size++] = aNewMI;

	return aNewMI;
}

function IGet(aId)
{
	if(this.id == aId)
		return this;
	
	if(this.t == K_MI || this.t == K_MS)
		return null;
	
	var m = null;
	for(var i = 0 ; i < this.v.length ; ++i)
	{
		m = this.v[i].get(aId);
		if(m != null)
			break;
	}
	return m;
}

function IMBDraw()
{	
	// Build root menu table
	if(this.setup.menuOrientation == "horizontal")
	{
		if(this.v.length > 0)
		{
			getStream(this.v[0].id).s += '<TABLE id="IMB" name="IMB" class="MenuBar" cellSpacing="' + this.setup.menuBarElementSpacing + '" style="' + this.setup.menuBarStyle + ';"><TBODY><TR>';
					
			var max = this.v.length;
			for(var i = 0 ; i < this.v.length ; ++i)
				this.v[i].draw(i,max);
			
			getStream(this.v[0].id).s += "</TR></TBODY></TABLE>";
		}
	}
	else
	{
		if(this.setup.menuOrientation == "vertical")
		{
			if(this.v.length > 0)
			{
				getStream(this.v[0].id).s += '<TABLE id="IMB" name="IMB" class="MenuBar" cellSpacing="' + this.setup.menuBarElementSpacing + '" style="' + this.setup.menuBarStyle + '"><TBODY>';
						
				var max = this.v.length;
				for(var i = 0 ; i < this.v.length ; ++i)
					this.v[i].draw(i,max);
				
				getStream(this.v[0].id).s += "</TBODY></TABLE>";
			}
		}
	}
	
	for(var i = 0 ; i < MB[this.id].ss.length ; ++i)
	{
		dw(MB[this.id].ss[i].s);
		MB[this.id].ss[i].s = null;
	}
	
	//dw("<div id='debug'></div>");
	//document.close();
}
/////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////
// Class that represents the whole menubar
//
function IMenuBarOv(menuSetup)
{
	this.setup    = menuSetup;
	var aId       = iMBOV++;
	this.v        = new Array();
	this.size     = 0;
	this.add      = IAddOv;
	this.ac       = IAddOv;
	this.get      = IGetOv;
	this.draw     = IMBDrawOv;
	this.t        = K_MB;
	this.id       = K_MB + LZ(aId) + "ov";
	var o         = new Object();
	o.ref         = this;
	o.ss          = new Array();
	o.iL          = 0;
	MBOV[this.id] = o;
}

function IAddOv(aLabel , aLink , isPopUp , aTarget)
{
	if(arguments.length < 3)
		isPopUp = 0;
	
	if(arguments.length < 4)
	{
		if (isPopUp) 
			aTarget = "";
		else aTarget = "main";
	}
	
	if(aLink.indexOf('?') < 0 
	&& aLink.indexOf('&') < 0 
	&& aLink.indexOf('=') < 0 
	&& aLink.indexOf('/') < 0 && aLink.length == 32) 
	{
		var cfg = getMBOV(this.id).setup;
		aLink = cfg.defURLStart + aLink;
	}
	
	var isInMB = false;
	if(this.t == K_MI)
	{
		this.v    = new Array();
		this.size = 0;
		this.t    = K_M;
		var n     = this.id.indexOf(K_MI);
		this.id   = this.id.substring(0 , n) + K_M + this.id.substr(n + 1);
	}	
	else if(this.t == K_MB)
	{
		isInMB = true;
		if(aLabel == K_SEP)
			return;
	}
	
	var aNewId   = this.id + K_MI + LZ(this.size);
	var aNewMI   = new IMenuItemOv(this , aNewId   , isInMB , aLabel , aLink , isPopUp , aTarget);
	this.v[this.size++]  = aNewMI;
	
	return aNewMI;
}

function IGetOv(aId)
{
	if(this.id == aId)
		return this;
	
	if(this.t == K_MI || this.t == K_MS)
		return null;
	
	var m = null;
	for(var i = 0 ; i < this.v.length ; ++i)
	{
		m = this.v[i].get(aId);
		if(m != null)
			break;
	}
	return m;
}

function IMBDrawOv()
{	
	// Build root menu table
	if(this.setup.menuOrientation == "horizontal")
	{
		if(this.v.length > 0)
		{
			getStreamOv(this.v[0].id).s += '<TABLE id="IMBov" name="IMBov" class="MenuBarOverlay" cellSpacing="' + this.setup.menuBarElementSpacing + '" style="display: none;"><TBODY><TR>';
					
			var max = this.v.length;
			for(var i = 0 ; i < this.v.length ; ++i)
				this.v[i].draw(i,max);
			
			getStreamOv(this.v[0].id).s += "</TR></TBODY></TABLE>";
		}
	}
	else
	{
		if(this.setup.menuOrientation == "vertical")
		{
			if(this.v.length > 0)
			{
				getStreamOv(this.v[0].id).s += '<TABLE id="IMBov" name="IMBov" class="MenuBarOverlay" cellSpacing="' + this.setup.menuBarElementSpacing + '" style="display: none;"><TBODY>';
						
				var max = this.v.length;
				for(var i = 0 ; i < this.v.length ; ++i)
					this.v[i].draw(i,max);
				
				getStreamOv(this.v[0].id).s += "</TBODY></TABLE>";
			}
		}
	}
	
	for(var i = 0 ; i < MBOV[this.id].ss.length ; ++i)
	{
		dw(MBOV[this.id].ss[i].s);
		MBOV[this.id].ss[i].s = null;
	}
	
	//prompt("",document.body.outerHTML);
	document.close();
}
/////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////
// Class that represents a menu item (or element)
//
function IMenuItem(aParent , aId , isInMB , aLabel , aLink , isPopUp , aTarget)
{
	this.p = aParent;
	
	if(aLabel == K_SEP)
	{
		this.t = K_MS;
		var n = aId.indexOf(K_MI);	
		this.id = aId.substring(0,n) + K_MS + aId.substr(n + 1);
	}
	else
	{
		this.t = K_MI;
		this.id = aId;
	}
	
	this.isInMB    = isInMB;
	this.isClicked = false;
	this.isOMOver  = false;
	this.isFirst   = false;
	this.isLast    = false;
	this.label     = aLabel;
	this.link      = aLink;
	this.isPU      = isPopUp;
	this.tg        = aTarget;
	this.add       = IAdd;
	this.ac        = IAdd;
	this.get       = IGet;
	this.draw      = IMIDraw;
	this.OMOvr     = OMOvr;
	this.OMOut     = OMOut;
	this.OMIOut    = OMIOut;
	this.OMIOvr    = OMIOvr;
	this.OMIClk    = OMIClk;
}

function IMIDraw(currentElemNum , maxElemNum)
{	
	var cfg = getMB(this.id).setup;
	
	// Draws the bar elements ( Level 1 )
	if(this.isInMB)
	{
		// Draws one row with several elements if it is a horizontal menu
		if(cfg.menuOrientation == "horizontal")
		{
			if(this.t == K_MI)
			{
				switch(currentElemNum)
				{
					case (maxElemNum-1): this.isLast = true;
							getStream(this.id).s += '<TD id="' + this.id + '" name="' + this.id + '"'
							+ ' class="MenuBarLastElement" style="' + cfg.menuBarLastElementStyle + '"'
							+ ' onmouseout="IMIOnMouseOut(isIE ? event.srcElement : this);"'
							+ ' onmouseover="IMIOnMouseOver(isIE ? event.srcElement : this)"'
							+ ' onclick="IMIOnClick(isIE ? event.srcElement : this)"' 
							+ ' noWrap ><IMG src="' + cfg.K_URL + 'spacer.gif" border="0" width="2" height="0">'
							+ this.label + '</TD>';
							break;
							
					case 0: this.isFirst = true;
							getStream(this.id).s += '<TD id="' + this.id + '" name="' + this.id + '"'
							+ ' class="MenuBarFirstElement" style="' + cfg.menuBarFirstElementStyle + '"'
							+ ' onmouseout="IMIOnMouseOut(isIE ? event.srcElement : this);"'
							+ ' onmouseover="IMIOnMouseOver(isIE ? event.srcElement : this)"'
							+ ' onclick="IMIOnClick(isIE ? event.srcElement : this)"' 
							+ ' noWrap ><IMG src="' + cfg.K_URL + 'spacer.gif" border="0" width="2" height="0">'
							+ this.label + '</TD>';
							break;
					
					default: getStream(this.id).s += '<TD id="' + this.id + '" name="' + this.id + '"'
							+ ' class="MenuBarMiddleElement" style="' + cfg.menuBarMiddleElementStyle + '"'
							+ ' onmouseout="IMIOnMouseOut(isIE ? event.srcElement : this);"'
							+ ' onmouseover="IMIOnMouseOver(isIE ? event.srcElement : this)"'
							+ ' onclick="IMIOnClick(isIE ? event.srcElement : this)"' 
							+ ' noWrap ><IMG src="' + cfg.K_URL + 'spacer.gif" border="0" width="2" height="0">'
							+ this.label + '</TD>';
							break;
				}
			}
			else if(this.t == K_M)
			{
				switch(currentElemNum)
				{
					case (maxElemNum-1): this.isLast = true;
							getStream(this.id).s += '<TD id="' + this.id + '" name="' + this.id + '"'
							+ ' class="MenuBarLastElement" style="' + cfg.menuBarLastElementStyle + '"'
							+ ' onmouseout="IMIOnMouseOut(isIE ? event.srcElement : this);"'
							+ ' onmouseover="IMIOnMouseOver(isIE ? event.srcElement : this)"'
							+ ' onclick="IMIOnClick(isIE ? event.srcElement : this)"' 
							+ ' noWrap><IMG src="' + cfg.K_URL + 'spacer.gif" border="0" width="2" height="0">'
							+ this.label + '</TD>';
							break;
							
					case 0: this.isFirst = true;
							getStream(this.id).s += '<TD id="' + this.id + '" name="' + this.id + '"'
							+ ' class="MenuBarFirstElement" style="' + cfg.menuBarFirstElementStyle + '"'
							+ ' onmouseout="IMIOnMouseOut(isIE ? event.srcElement : this);"'
							+ ' onmouseover="IMIOnMouseOver(isIE ? event.srcElement : this)"'
							+ ' onclick="IMIOnClick(isIE ? event.srcElement : this)"' 
							+ ' noWrap><IMG src="' + cfg.K_URL + 'spacer.gif" border="0" width="2" height="0">'
							+ this.label + '</TD>';
							break;
					
					default: getStream(this.id).s += '<TD id="' + this.id + '" name="' + this.id + '"'
							+ ' class="MenuBarMiddleElement" style="' + cfg.menuBarMiddleElementStyle + '"'
							+ ' onmouseout="IMIOnMouseOut(isIE ? event.srcElement : this);"'
							+ ' onmouseover="IMIOnMouseOver(isIE ? event.srcElement : this)"'
							+ ' onclick="IMIOnClick(isIE ? event.srcElement : this)"' 
							+ ' noWrap><IMG src="' + cfg.K_URL + 'spacer.gif" border="0" width="2" height="0">'
							+ this.label + '</TD>';
							break;
				}
				
				getStream(this.v[0].id).s += '<DIV id="'+ K_DIV + this.id +'" name="'+ K_DIV + this.id +'" style="' + inlineDivStyle + ' z-index: 100;">'
										+ '<TABLE id="'+ K_TAB + this.id +'" name="'+ K_TAB + this.id +'" onmouseout="IMOnMouseOut(isIE?event.srcElement:this)" onmouseover="IMOnMouseOver(isIE?event.srcElement:this)" '
										+ 'cellSpacing="' + cfg.menuPanelElementSpacing + '" style="' + inlineTableStyle + '">';
						
				var max = this.v.length;
				for(var i = 0 ; i < this.v.length ; ++i)
					this.v[i].draw(i,max);
				getStream(this.v[0].id).s += '</TABLE></DIV>';
			}
		}
		else
		{
			// Draws several rows with an element each if it is a vertical menu
			if(cfg.menuOrientation == "vertical")
			{
				if(this.t == K_MI)
				{
					switch(currentElemNum)
					{
						case (maxElemNum-1): this.isLast = true;
								getStream(this.id).s += '<TR><TD id="' + this.id + '" name="' + this.id + '"'
								+ ' class="MenuBarLastElement" style="' + cfg.menuBarLastElementStyle + '"'
								+ ' onmouseout="IMIOnMouseOut(isIE ? event.srcElement : this);"'
								+ ' onmouseover="IMIOnMouseOver(isIE ? event.srcElement : this)"'
								+ ' onclick="IMIOnClick(isIE ? event.srcElement : this)"' 
								+ ' noWrap ><IMG src="' + cfg.K_URL + 'spacer.gif" border="0" width="2" height="0">'
								+ this.label + '</TD></TR>';
								break;
								
						case 0: this.isFirst = true;
								getStream(this.id).s += '<TR><TD id="' + this.id + '" name="' + this.id + '"'
								+ ' class="MenuBarFirstElement" style="' + cfg.menuBarFirstElementStyle + '"'
								+ ' onmouseout="IMIOnMouseOut(isIE ? event.srcElement : this);"'
								+ ' onmouseover="IMIOnMouseOver(isIE ? event.srcElement : this)"' 
								+ ' onclick="IMIOnClick(isIE ? event.srcElement : this)"' 
								+ ' noWrap ><IMG src="' + cfg.K_URL + 'spacer.gif" border="0" width="2" height="0">'
								+ this.label + '</TD></TR>';
								break;
						
						default: getStream(this.id).s += '<TR><TD id="' + this.id + '" name="' + this.id + '"'
								+ ' class="MenuBarMiddleElement" style="' + cfg.menuBarMiddleElementStyle + '"'
								+ ' onmouseout="IMIOnMouseOut(isIE ? event.srcElement : this);"'
								+ ' onmouseover="IMIOnMouseOver(isIE ? event.srcElement : this)"'
								+ ' onclick="IMIOnClick(isIE ? event.srcElement : this)"' 
								+ ' noWrap ><IMG src="' + cfg.K_URL + 'spacer.gif" border="0" width="2" height="0">'
								+ this.label + '</TD></TR>';
								break;
					}
				}
				else if(this.t == K_M)
				{
					switch(currentElemNum)
					{
						case (maxElemNum-1): this.isLast = true;
								getStream(this.id).s += '<TR><TD id="' + this.id + '" name="' + this.id + '"'
								+ ' class="MenuBarLastElement" style="' + cfg.menuBarLastElementStyle + '"'
								+ ' onmouseout="IMIOnMouseOut(isIE ? event.srcElement : this);"'
								+ ' onmouseover="IMIOnMouseOver(isIE ? event.srcElement : this)"'
								+ ' onclick="IMIOnClick(isIE ? event.srcElement : this)"' 
								+ ' noWrap ><IMG src="' + cfg.K_URL + 'spacer.gif" border="0" width="2" height="0">'
								+ this.label + '</TD></TR>';
								break;
								
						case 0: this.isFirst = true;
								getStream(this.id).s += '<TR><TD id="' + this.id + '" name="' + this.id + '"'
								+ ' class="MenuBarFirstElement" style="' + cfg.menuBarFirstElementStyle + '"'
								+ ' onmouseout="IMIOnMouseOut(isIE ? event.srcElement : this);"'
								+ ' onmouseover="IMIOnMouseOver(isIE ? event.srcElement : this)"'
								+ ' onclick="IMIOnClick(isIE ? event.srcElement : this)"' 
								+ ' noWrap ><IMG src="' + cfg.K_URL + 'spacer.gif" border="0" width="2" height="0">'
								+ this.label + '</TD></TR>';
								break;
						
						default: getStream(this.id).s += '<TR><TD id="' + this.id + '" name="' + this.id + '"'
								+ ' class="MenuBarMiddleElement" style="' + cfg.menuBarMiddleElementStyle + '"'
								+ ' onmouseout="IMIOnMouseOut(isIE ? event.srcElement : this);"'
								+ ' onmouseover="IMIOnMouseOver(isIE ? event.srcElement : this)"'
								+ ' onclick="IMIOnClick(isIE ? event.srcElement : this)"' 
								+ ' noWrap ><IMG src="' + cfg.K_URL + 'spacer.gif" border="0" width="2" height="0">'
								+ this.label + '</TD></TR>';
								break;
					}
					
					getStream(this.v[0].id).s += '<DIV id="'+ K_DIV + this.id +'" name="'+ K_DIV + this.id +'" style="' + inlineDivStyle + ' z-index: 100;">'
										+ '<TABLE id="'+ K_TAB + this.id +'" name="'+ K_TAB + this.id +'" onmouseout="IMOnMouseOut(isIE?event.srcElement:this)" onmouseover="IMOnMouseOver(isIE?event.srcElement:this)" '
										+ 'cellSpacing="' + cfg.menuPanelElementSpacing + '" style="' + inlineTableStyle + '">';
						
					var max = this.v.length;
					for(var i = 0 ; i < this.v.length ; ++i)
						this.v[i].draw(i,max);
					getStream(this.v[0].id).s += '</TABLE></DIV>';
				}
			}
		}
	} // Draws the panel elements ( Level 2,inf. )
	else
	{
		if(this.t == K_MI)
		{
			switch(currentElemNum)
			{
				case (maxElemNum - 1): this.isLast = true;
					getStream(this.id).s += '<TR><TD id="'+ this.id +'" name="' + this.id + '"'
					+ ' class="MenuPanelLastElement" style="' + cfg.menuPanelLastElementStyle + '"'
					+ ' onmouseout="IMIOnMouseOut(isIE ? event.srcElement : this);fStatusBar(\'\');"'
					+ ' onmouseover="IMIOnMouseOver(isIE ? event.srcElement : this)"'
					+ ' onclick="IMIOnClick(isIE ? event.srcElement : this)"'
					+ ' noWrap colSpan="2" width="' + ForceWidthFirefox('MenuPanelLastElement' , cfg.menuPanelLastElementStyle , cfg.menuOrientation) + '">' + this.label + '</TD></TR>';
					break;
					
				case 0: this.isFirst = true;
					getStream(this.id).s += '<TR><TD id="'+ this.id +'" name="' + this.id + '"'
					+ ' class="MenuPanelFirstElement" style="' + cfg.menuPanelFirstElementStyle + '"'
					+ ' onmouseout="IMIOnMouseOut(isIE ? event.srcElement : this);fStatusBar(\'\');"'
					+ ' onmouseover="IMIOnMouseOver(isIE ? event.srcElement : this)"'
					+ ' onclick="IMIOnClick(isIE ? event.srcElement : this)"'
					+ ' noWrap colSpan="2" width="' + ForceWidthFirefox('MenuPanelFirstElement' , cfg.menuPanelFirstElementStyle , cfg.menuOrientation) + '">' + this.label + '</TD></TR>';
					break;
				
				default: 
					getStream(this.id).s += '<TR><TD id="'+ this.id +'" name="' + this.id + '"' +
					' class="MenuPanelMiddleElement" style="' + cfg.menuPanelMiddleElementStyle + '"' + 
					' onmouseout="IMIOnMouseOut(isIE ? event.srcElement : this);fStatusBar(\'\');"' +
					' onmouseover="IMIOnMouseOver(isIE ? event.srcElement : this)"' +
					' onclick="IMIOnClick(isIE ? event.srcElement : this)"' +
					' noWrap colSpan="2" width="' + ForceWidthFirefox('MenuPanelMiddleElement' , cfg.menuPanelMiddleElementStyle , cfg.menuOrientation) + '">'
					+ this.label + '</TD></TR>';
					break;
			}
		}
		else if(this.t == K_M)
		{
			switch(currentElemNum)
			{
				case (maxElemNum - 1): this.isLast = true;
						getStream(this.id).s += '<TR><TD id="' + this.id + '" name="' + this.id + '"'
						+ ' class="MenuPanelLastElement" style="' + cfg.menuPanelLastElementStyle + '"'
						+ ' onmouseout="IMIOnMouseOut(isIE ? event.srcElement : this)"'
						+ ' onmouseover="IMIOnMouseOver(isIE ? event.srcElement : this)"'
						+ ' onclick="IMIOnClick(isIE ? event.srcElement : this)"'
						+ ' noWrap width="' + ForceWidthFirefox('MenuPanelLastElement' , cfg.menuPanelLastElementStyle , cfg.menuOrientation) + '">' + this.label + '</TD></TR>';
						break;
						
				case 0: this.isFirst = true;
						getStream(this.id).s += '<TR><TD id="' + this.id + '" name="' + this.id + '"'
						+ ' class="MenuPanelFirstElement" style="' + cfg.menuPanelFirstElementStyle + '"'
						+ ' onmouseout="IMIOnMouseOut(isIE?event.srcElement:this)"'
						+ ' onmouseover="IMIOnMouseOver(isIE?event.srcElement:this)"'
						+ ' onclick="IMIOnClick(isIE?event.srcElement:this)"'
						+ ' noWrap width="' + ForceWidthFirefox('MenuPanelFirstElement' , cfg.menuPanelFirstElementStyle , cfg.menuOrientation) + '">' + this.label + '</TD></TR>';
						break;
				
				default: getStream(this.id).s += '<TR><TD id="'+ this.id +'" name="' + this.id + '"' +
						' class="MenuPanelMiddleElement" style="' + cfg.menuPanelMiddleElementStyle + '"' + 
						' onmouseout="IMIOnMouseOut(isIE ? event.srcElement : this);fStatusBar(\'\');"' +
						' onmouseover="IMIOnMouseOver(isIE ? event.srcElement : this)"' +
						' onclick="IMIOnClick(isIE ? event.srcElement : this)"' +
						' noWrap colSpan="2" width="' + ForceWidthFirefox('MenuPanelMiddleElement' , cfg.menuPanelMiddleElementStyle , cfg.menuOrientation) + '">'
						+ this.label + '</TD></TR>';
						break;
			}
			
			getStream(this.v[0].id).s += '<DIV id="'+ K_DIV + this.id +'" name="' + K_DIV + this.id +'" style="' + inlineDivStyle + ' z-index: 100;">'
									+'<TABLE id="'+ K_TAB + this.id +'" name="' + K_TAB + this.id +'" onmouseout="IMOnMouseOut(isIE?event.srcElement:this)" onmouseover="IMOnMouseOver(isIE?event.srcElement:this)" '
									+'cellSpacing="' + cfg.menuPanelElementSpacing + '" style="' + inlineTableStyle + '">'+'<TBODY>';
				
			var max2 = this.v.length;
			for(var i = 0 ; i < this.v.length ; ++i) 
				this.v[i].draw(i,max2);
			getStream(this.v[0].id).s += "</TBODY></TABLE></DIV>";
		}
	}
}

function OMOvr(v)
{
	while(v.tagName != "TABLE")
		v = v.parentNode;
	
	if(v == null)
		return;
	
	var dId = K_DIV + v.id.substr(K_TAB.length);
	if(aPT != null)
	{
		clearTimeout(aPT);
		aPT = null;
	}
}

function OMOut(v)
{
	var cfg = getMB(v.id).setup;
	while(v.tagName != "TABLE") 
		v = v.parentNode;
	
	if(v == null)
		return;
		
	var dId = K_DIV + v.id.substr(K_TAB.length);
	myST(this , dId , aP , "");
}

function OMIOut(v)
{
	var cfg = getMB(v.id).setup;
	var myPopUp = this.isInMB ? (K_DIV + v.id) : (K_DIV + v.id.substr(0 , v.id.length));
	
	if(this.isInMB && this.t == K_M)
	{
		if(!getMB(v.id).get(v.id).isClicked)
		{
			myST(this , myPopUp , aP);
		}
	}
	else if(this.isInMB && this.t == K_MI)
	{
		if(!getMB(v.id).get(v.id).isClicked)
		{
			ApplyStyle("MenuBar" , "onmouseout" , this , cfg);
		}
	}
	else if(!this.isInMB && this.t == K_MI)
	{
		ApplyStyle("MenuPanel" , "onmouseout" , this , cfg);
		IMOnMouseOut(dg(v.id));
	}
	else if(!this.isInMB && this.t == K_M)
	{
		ApplyStyle("MenuPanel" , "onmouseout" , this , cfg);
		myST(this , myPopUp , aP);
	}

	v.isOMOver = false;
}

function OMIOvr(v)
{
	var cfg = getMB(v.id).setup;
	var a = this.isInMB;
	var myPopUp = a ? (K_DIV + v.id) : (K_DIV + v.id.substr(0 , v.id.length - 3));
				
	if(aP != null)
	{
		var b = myPopUp != aP;
		
		if((aPT != null) && ((a == b) || (!b || a)))
		{
			if(aP.indexOf(myPopUp) != -1)
			{
				clearTimeout(aPT);
				aPT = null;
			}
		}
		if(b)
		{
			if(! (!this.isInMB && (aP.substr(1) == v.id)) )
			{
				Hide(this , aP , myPopUp , 1 , "");
			}
		}
	}
				
	if(!getMB(v.id).get(v.id).isClicked)
	{
		if(this.isInMB)
		{
			var menuBarElements = getMB(v.id).v;
			for(var i = 0 ; i < menuBarElements.length ; i++)
			{
				if(!menuBarElements[i].isClicked)
				{ 
					menuBarElements[i].isOMOver = false;
					ApplyStyle("MenuBar" , "onmouseout" , menuBarElements[i] , cfg);
				}
			}
		}
				
		if(a)
		{
			ApplyStyle("MenuBar" , "onmouseover" , this , cfg);
		}
		else
		{
			if(this.t == K_MI)
			{
				ApplyStyle("MenuPanel" , "onmouseover" , this , cfg);
			}
			else if(this.t == K_M)
			{
				ApplyStyle("MenuPanel" , "onmouseover" , this , cfg);
			}
		}
	}
		
	if(this.t == K_M)
	{
		//var el = (a ? v : isIE ? (this.t == K_MS ? v.parentNode.parentNode : v.parentNode) : v);
		//var elem = document.getElementById(el.id);
		
		var el = (a ? dg(v.id) : isIE ? (this.t == K_MS ? dg(v.id).parentNode.parentNode : dg(v.id).parentNode) : dg(v.id));
		var p = GetM(el);
		var x;
		var y;
		
		if(cfg.menuOrientation == "horizontal")
		{
			x = a ? (p.x + cfg.horizontalOffsetLevel1) : (p.x + p.w + cfg.horizontalOffsetLevel2);
			y = a ? (p.y + cfg.verticalOffsetLevel1 + p.h) : (p.y + cfg.verticalOffsetLevel2);
		}
		else
		{
			if(cfg.menuOrientation == "vertical")
			{
				x = a ? (p.x + p.w + cfg.horizontalOffsetLevel1) : (p.x + p.w + cfg.horizontalOffsetLevel2);
				y = a ? (p.y + cfg.verticalOffsetLevel1) : (p.y + cfg.verticalOffsetLevel2);
			}
		}
					
		if(!a)
			myPopUp = K_DIV + v.id;
		
		var d = dg(myPopUp);
		var dOvId = CalculateOvDivId(d.id);
		var dOv = dg(dOvId);
		
		if(isIE)
		{
			var dm = GetM(d);
			if(parseInt(x + dm.w) > document.body.offsetWidth)
			{	
				x = x - dm.w + (a ? (p.w - cfg.horizontalOffsetLevel1) : (-p.w - cfg.horizontalOffsetLevel2));
			}
		}
			
		with(d.style)
		{
			top = y + 1;
			left = x;
		}
		
		with(dOv.style)
		{
			top = y + 1;
			left = x;
		}
		
		showDiv(d);
		showDiv(dOv);
		aP = myPopUp;
	}
	
	v.isOMOver = true;
}

function OMIClk(v)
{
	var cfg = getMB(v.id).setup;
	if(!IsNill(this.link))
	{
		if(this.isPU)
			open(this.link);
		else window.location = this.link;
	}
	
	var element = getMB(v.id).get(v.id);
	if(element.isInMB)
	{
		ApplyStyle("MenuBar" , "onclick" , v , cfg);
	}
	else
	{
		ApplyStyle("MenuPanel" , "onclick" , v , cfg);
	}
	
	if(getMB(v.id).get(v.id).isInMB)
		element = getMB(v.id).get(v.id);
	else
	{
		element = getMB(v.id).get(v.id).p;
		while(!element.isInMB)
			element = element.p;
	}
			
	var menuBarElements = getMB(v.id).v;
	for(var i = 0 ; i < menuBarElements.length ; i++)
	{
		if(menuBarElements[i].isClicked)
		{
			if(menuBarElements[i].label != element.label)
			{
				menuBarElements[i].isClicked = false;
				ApplyStyle("MenuBar" , "onmouseout" , menuBarElements[i] , cfg);
	        }
		}
	}
	
	element.isClicked = true;
}
/////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////
// Class that represents a menu item overlay (or element)
//
function IMenuItemOv(aParent , aId , isInMB , aLabel , aLink , isPopUp , aTarget)
{
	this.p = aParent;
	
	if(aLabel == K_SEP)
	{
		this.t = K_MS;
		var n = aId.indexOf(K_MI);	
		this.id = aId.substring(0 , n) + K_MS + aId.substr(n + 1) + "ov";
	}
	else
	{
		this.t = K_MI;
		this.id = aId + "ov";
	}
	
	this.isInMB    = isInMB;
	this.isClicked = false;
	this.isFirst   = false;
	this.isLast    = false;
	this.label     = aLabel;
	this.link      = aLink;
	this.isPU      = isPopUp;
	this.tg        = aTarget;
	this.add       = IAddOv;
	this.ac        = IAddOv;
	this.get       = IGetOv;
	this.draw      = IMIDrawOv;
}

function IMIDrawOv(currentElemNum , maxElemNum)
{
	var cfg = getMBOV(this.id).setup;
	
	// Draws the bar elements ( Level 1 )
	if(this.isInMB)
	{
		// Draws one row with several elements if it is a horizontal menu
		if(cfg.menuOrientation == "horizontal")
		{
			if(this.t == K_MI)
			{
				switch(currentElemNum)
				{
					case 0: this.isFirst = true;
							getStreamOv(this.id).s += '<TD id="' + this.id + '" name="' + this.id + '"'
							                       + ' class="MenuBarOverlayInvisibleElement" style="Z-INDEX: 1000;"'
							                       + ' onmouseout="IMIOnMouseOutOv(this , false);"'
							                       + ' onmouseover="IMIOnMouseOverOv(this , false);"'
							                       + ' onclick="IMIOnClickOv(this , false);">&nbsp;</TD>';
							break;
					
					case (maxElemNum-1): 
							this.isLast = true;
							getStreamOv(this.id).s += '<TD id="' + this.id + '" name="' + this.id + '"'
							                       + ' class="MenuBarOverlayInvisibleElement" style="Z-INDEX: 1000;"' 
							                       + ' onmouseout="IMIOnMouseOutOv(this , false);"'
							                       + ' onmouseover="IMIOnMouseOverOv(this , false);"'
							                       + ' onclick="IMIOnClickOv(this , false);">&nbsp;</TD>';
							break;
					
					default: getStreamOv(this.id).s += '<TD id="' + this.id + '" name="' + this.id + '"'
													+ ' class="MenuBarOverlayInvisibleElement" style="Z-INDEX: 1000;"' 
													+ ' onmouseout="IMIOnMouseOutOv(this , false);"' 
													+ ' onmouseover="IMIOnMouseOverOv(this , false);"' 
													+ ' onclick="IMIOnClickOv(this , false);">&nbsp;</TD>';
							break;
				}
			}
			else if(this.t == K_M)
			{
				switch(currentElemNum)
				{
					case 0: this.isFirst = true;
							getStreamOv(this.id).s += '<TD id="' + this.id + '" name="' + this.id + '"' 
													+ ' class="MenuBarOverlayElement" style="Z-INDEX: 1000;' + cfg.menuBarOverlayElementStyle + '"' 
													+ ' onmouseout="IMIOnMouseOutOv(this , true);"' 
													+ ' onmouseover="IMIOnMouseOverOv(this , true);"' 
													+ ' onclick="IMIOnClickOv(this , true);"'
													+ ' width="' + ForceWidthFirefox('MenuBarOverlayElement' , '' , cfg.menuOrientation) + '"><img src="appImages/spacer.gif" alt="" width="' + ForceWidthFirefox('MenuBarOverlayElement' , '' , cfg.menuOrientation) + '" height="0"></TD>';
							break;
					
					case (maxElemNum-1): 
							this.isLast = true;
							getStreamOv(this.id).s += '<TD id="' + this.id + '" name="' + this.id + '"' 
													+ ' class="MenuBarOverlayElement" style="Z-INDEX: 1000;' + cfg.menuBarOverlayElementStyle + '"' 
													+ ' onmouseout="IMIOnMouseOutOv(this , true);"' 
													+ ' onmouseover="IMIOnMouseOverOv(this , true);"' 
													+ ' onclick="IMIOnClickOv(this , true);"'
													+ ' width="' + ForceWidthFirefox('MenuBarOverlayElement' , '' , cfg.menuOrientation) + '"><img src="appImages/spacer.gif" alt="" width="' + ForceWidthFirefox('MenuBarOverlayElement' , '' , cfg.menuOrientation) + '" height="0"></TD>';
							break;
					
					default: getStreamOv(this.id).s += '<TD id="' + this.id + '" name="' + this.id + '"' 
													+ ' class="MenuBarOverlayElement" style="Z-INDEX: 1000;' + cfg.menuBarOverlayElementStyle + '"' 
													+ ' onmouseout="IMIOnMouseOutOv(this , true);"' 
													+ ' onmouseover="IMIOnMouseOverOv(this , true);"'
													+ ' onclick="IMIOnClickOv(this , true);"'
													+ ' width="' + ForceWidthFirefox('MenuBarOverlayElement' , '' , cfg.menuOrientation) + '"><img src="appImages/spacer.gif" alt="" width="' + ForceWidthFirefox('MenuBarOverlayElement' , '' , cfg.menuOrientation) + '" height="0"></TD>';
							break;
				}
				
				getStreamOv(this.v[0].id).s += '<DIV id="' + K_DIV + this.id + '" name="' + K_DIV + this.id + '" style="' + inlineDivStyle + ' z-index: 100;">'
										   + '<TABLE id="' + K_TAB + this.id + '" name="' + K_TAB + this.id + '" style="' + inlineTableStyle + '" cellSpacing="' + cfg.menuPanelElementSpacing + '">';
						
				var max = this.v.length;
				for(var i = 0 ; i < this.v.length ; ++i)
					this.v[i].draw(i,max);
				getStreamOv(this.v[0].id).s += '</TABLE></DIV>';
			}
		}
		else
		{
			// Draws several rows with an element each if it is a vertical menu
			if(cfg.menuOrientation == "vertical")
			{
				if(this.t == K_MI)
				{
					switch(currentElemNum)
					{
						case 0: this.isFirst = true;
								getStreamOv(this.id).s += '<TR><TD id="' + this.id + '" name="' + this.id + '"'
														+ ' class="MenuBarOverlayInvisibleElement" style="Z-INDEX: 1000;"' 
														+ ' onmouseout="IMIOnMouseOutOv(this , false);"' 
														+ ' onmouseover="IMIOnMouseOverOv(this , false);"'
														+ ' onclick="IMIOnClickOv(this , false);">&nbsp;</TD></TR>';
								break;
								
						case (maxElemNum-1): 
								this.isLast = true;
								getStreamOv(this.id).s += '<TR><TD id="' + this.id + '" name="' + this.id + '"'
														+ ' class="MenuBarOverlayInvisibleElement" style="Z-INDEX: 1000;"'
														+ ' onmouseout="IMIOnMouseOutOv(this , false);"'
														+ ' onmouseover="IMIOnMouseOverOv(this , false);"'
														+ ' onclick="IMIOnClickOv(this , false);">&nbsp;</TD></TR>';
								break;
						
						default: getStreamOv(this.id).s += '<TR><TD id="' + this.id + '" name="' + this.id + '"'
														+ ' class="MenuBarOverlayInvisibleElement" style="Z-INDEX: 1000;"'
														+ ' onmouseout="IMIOnMouseOutOv(this , false);"'
														+ ' onmouseover="IMIOnMouseOverOv(this , false);"'
														+ ' onclick="IMIOnClickOv(this , false);">&nbsp;</TD></TR>';
								break;
					}
				}
				else if(this.t == K_M)
				{
					switch(currentElemNum)
					{
						case 0: this.isFirst = true;
								getStreamOv(this.id).s += '<TR><TD><DIV id="' + this.id + '" name="' + this.id + '"'
														+ ' class="MenuBarOverlayElement" style="Z-INDEX: 1000;' + cfg.menuBarOverlayElementStyle + '"'
														+ ' onmouseout="IMIOnMouseOutOv(this , true);"' 
														+ ' onmouseover="IMIOnMouseOverOv(this , true);"'
														+ ' onclick="IMIOnClickOv(this , true);"'
														+ ' width="' + ForceWidthFirefox('MenuBarOverlayElement' , '' , cfg.menuOrientation) + '"></DIV></TD></TR>';
								break;
								
						case (maxElemNum-1): 
								this.isLast = true;
								getStreamOv(this.id).s += '<TR><TD><DIV id="' + this.id + '" name="' + this.id + '"'
														+ ' class="MenuBarOverlayElement" style="Z-INDEX: 1000;' + cfg.menuBarOverlayElementStyle + '"'
														+ ' onmouseout="IMIOnMouseOutOv(this , true);"'
														+ ' onmouseover="IMIOnMouseOverOv(this , true);"'
														+ ' onclick="IMIOnClickOv(this , true);"'
														+ ' width="' + ForceWidthFirefox('MenuBarOverlayElement' , '' , cfg.menuOrientation) + '"></DIV></TD></TR>';
								break;
						
						default: getStreamOv(this.id).s += '<TR><TD><DIV id="' + this.id + '" name="' + this.id + '"'
														 + ' class="MenuBarOverlayElement" style="Z-INDEX: 1000;' + cfg.menuBarOverlayElementStyle + '"'
														 + ' onmouseout="IMIOnMouseOutOv(this , true);"'
														 + ' onmouseover="IMIOnMouseOverOv(this , true);"'
														 + ' onclick="IMIOnClickOv(this , true);"'
														 + ' width="' + ForceWidthFirefox('MenuBarOverlayElement' , '' , cfg.menuOrientation) + '"></DIV></TD></TR>';
								break;
					}
					
					getStreamOv(this.v[0].id).s += '<DIV id="' + K_DIV + this.id + '" name="' + K_DIV + this.id + '" style="' + inlineDivStyle + ' z-index: 100;">'
										     + '<TABLE id="' + K_TAB + this.id + '" name="' + K_TAB + this.id + '" cellspacing="' + cfg.menuPanelElementSpacing + '" style="' + inlineTableStyle + '">';
						
					var max = this.v.length;
					for(var i = 0 ; i < this.v.length ; ++i)
						this.v[i].draw(i,max);
					getStreamOv(this.v[0].id).s += '</TABLE></DIV>';
				}
			}
		}
	} // Draws the panel elements ( Level 2,inf. )
	else
	{
		if(this.t == K_MI)
		{
			switch(currentElemNum)
			{
				case 0: 
					this.isFirst = true;
					getStreamOv(this.id).s += '<TR><TD id="' + this.id + '" name="' + this.id + '"'
											+ ' class="MenuPanelOverlayInvisibleElement" style="Z-INDEX: 1000;"'
											+ ' onmouseout="IMIOnMouseOutOv(this , false);"'
											+ ' onmouseover="IMIOnMouseOverOv(this , false);"'
											+ ' onclick="IMIOnClickOv(this , false);"'
											+ ' width="' + ForceWidthFirefox('MenuPanelOverlayInvisibleElement' , '' , cfg.menuOrientation) + '">&nbsp;</TD></TR>';
			
					break;
				
				case (maxElemNum - 1): 
					this.isLast = true;
					getStreamOv(this.id).s += '<TR><TD id="' + this.id + '" name="' + this.id + '"'
											+ ' class="MenuPanelOverlayInvisibleElement" style="Z-INDEX: 1000;"'
											+ ' onmouseout="IMIOnMouseOutOv(this , false);"'
											+ ' onmouseover="IMIOnMouseOverOv(this , false);"'
											+ ' onclick="IMIOnClickOv(this , false);"'
											+ ' width="' + ForceWidthFirefox('MenuPanelOverlayInvisibleElement' , '' , cfg.menuOrientation) + '">&nbsp;</TD></TR>';
					break;
				
				default: 
					getStreamOv(this.id).s += '<TR><TD id="' + this.id + '" name="' + this.id + '"'
											+ ' class="MenuPanelOverlayInvisibleElement" style="Z-INDEX: 1000;"'
											+ ' onmouseout="IMIOnMouseOutOv(this , false);"'
											+ ' onmouseover="IMIOnMouseOverOv(this , false);"'
											+ ' onclick="IMIOnClickOv(this , false);"'
											+ ' width="' + ForceWidthFirefox('MenuPanelOverlayInvisibleElement' , '' , cfg.menuOrientation) + '">&nbsp;</TD></TR>';
					break;
			}
		}
		else if(this.t == K_M)
		{
			switch(currentElemNum)
			{
				case 0: this.isFirst = true;
						getStreamOv(this.id).s += '<TR><TD><DIV id="' + this.id + '" name="' + this.id + '"'
												+ ' class="MenuPanelOverlayElement" style="Z-INDEX: 1000;' + cfg.menuPanelOverlayElementStyle + '"'
												+ ' onmouseout="IMIOnMouseOutOv(this , true);"'
												+ ' onmouseover="IMIOnMouseOverOv(this , true);"'
												+ ' onclick="IMIOnClickOv(this , true);"'
												+ ' width="' + ForceWidthFirefox('MenuPanelOverlayElement' , '' , cfg.menuOrientation) + '"></DIV></TD></TR>';
						break;
				
				case (maxElemNum - 1): 
						this.isLast = true;
						getStreamOv(this.id).s += '<TR><TD><DIV id="' + this.id + '" name="' + this.id + '"'
												+ ' class="MenuPanelOverlayElement" style="Z-INDEX: 1000;' + cfg.menuPanelOverlayElementStyle + '"'
												+ ' onmouseout="IMIOnMouseOutOv(this , true);"'
												+ ' onmouseover="IMIOnMouseOverOv(this , true);"'
												+ ' onclick="IMIOnClickOv(this , true);"'
												+ ' width="' + ForceWidthFirefox('MenuPanelOverlayElement' , '' , cfg.menuOrientation) + '"></DIV></TD></TR>';
						break;
				
				default: getStreamOv(this.id).s += '<TR><TD><DIV id="' + this.id + '" name="' + this.id + '"'
												 + ' class="MenuPanelOverlayElement" style="Z-INDEX: 1000;' + cfg.menuPanelOverlayElementStyle + '"'
												 + ' onmouseout="IMIOnMouseOutOv(this , true);"'
												 + ' onmouseover="IMIOnMouseOverOv(this , true);"'
												 + ' onclick="IMIOnClickOv(this , true);"'
												 + ' width="' + ForceWidthFirefox('MenuPanelOverlayElement' , '' , cfg.menuOrientation) + '"></DIV></TD></TR>';
						break;
			}
			
			getStreamOv(this.v[0].id).s += '<DIV id="' + K_DIV + this.id + '" name="' + K_DIV + this.id + '" style="' + inlineDivStyle + ' z-index: 100;">'
									  +'<TABLE id="' + K_TAB + this.id + '" name="' + K_TAB + this.id + '" onmouseout="IMOnMouseOut(isIE?event.srcElement:this)" onmouseover="IMOnMouseOver(isIE?event.srcElement:this)" '
									  +'cellSpacing="' + cfg.menuPanelElementSpacing + '" style="' + inlineTableStyle + '">'+'<TBODY>';
				
			var max2 = this.v.length;
			for(var i = 0 ; i < this.v.length ; ++i) 
				this.v[i].draw(i,max2);
			getStreamOv(this.v[0].id).s += "</TBODY></TABLE></DIV>";
		}
	}
}
/////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////
// Class that represents a measure in terms
// of its x and y axis values and width
// and height
function Measure(x,y,w,h)
{
	this.x = x;
	this.y = y;
	this.w = w;
	this.h = h;
}
/////////////////////////////////////////////////////////////////

function Hide(element , i , t , r , withTO , overlay)
{	
	if(arguments.length < 5)
	{
		withTO = true;
		r = false;
	}
	else if(arguments.length < 6)
		withTO = true;
	
	var mI = false;
	var d = dg(i);
	if(d == null)
		return;
		
	if(overlay == "")
	{
		if(d.id.length > 7)
		{
			var x = d.id.substr(1);
			if(!getMB(x).get(x).isClicked)
			{
				// switch menu panel style to mouse out style
			}
		}
		else if(d.id.length == 7)
		{
			var k = d.id.substr(1);
			if(!getMB(k).get(k).isClicked)
			{
				ApplyStyle("MenuBar" , "onmouseout" , getMB(k).get(k) , getMB(k).setup);
				// switch menu bar style to mouse out style
			}
			mI = true;
		}
	}
	else if(overlay == "ov")
	{
		if(d.id.length > 11)
		{
			var x = d.id.substr(1);
			if(!getMBOV(x).get(x).isClicked)
			{
				// switch menu panel style to mouse out style
			}
		}
		else if(d.id.length == 11)
		{
			var k = d.id.substr(1);
			if(!getMBOV(k).get(k).isClicked)
			{
				// switch menu bar style to mouse out style
			}
			mI = true;
		}
	}
	
	hideDiv(d);
	var dOvId = CalculateOvDivId(d.id);
	var dOv = dg(dOvId);
	hideDiv(dOv);
	
	currentNode = getMB(d.id.substring(1,d.id.length)).currentNode;
	if(currentNode == null || (d.id.length > 7 && aP == d.id && !r && ContainerDiv(d.id)))
	{
		var dId = d.id.substring(0,d.id.length - 3);
		aP = dId;
		if(withTO)
		{
			myST(element , dId , aP , overlay);
			bS = false;
		}
		else 
		{
			Hide(element , dId , aP , false , true , overlay);
			bS = false;
		}
	}
	else if(aP != null && aP.indexOf(d.id) != -1)
	{
		var z = aP;
		if(aP.length == 7) 
			aP = null;
		else aP = aP.substring(0 , aP.length - 3);
		Hide(element , z , aP , false , true , overlay);
		bS = false;
	}
}

function ContainerDiv(dId)
{
	var elem = dg(getMB(dId.substring(1,dId.length)).currentNode);
	while(elem.tagName != "DIV")
		elem = elem.parentNode;
		
	if(elem.id == dId)
		return false;
	return true;
}

function myST(element , pTH , oPU , overlay)
{
	if(aPT != null)
	{
		clearTimeout(aPT);
		aPT = null;
	}
	aPT = setTimeout('Hide("' + element + '" , "' + pTH + '" , "' + oPU + '" , false , true , "' + overlay + '")' , K_TTW);
}

function IMOnMouseOver(v)
{
	if(v.tagName == "HR" || v.tagName == "IMG")
		v = v.parentNode;
	else if(!isIE)
		OMOvr(v);
	else if(v.tagName == "TABLE")
		return;
	
	var m = getMB(v.id).get(v.id);
	if(m != null)
		m.OMOvr(v);
}

function IMOnMouseOut(v)
{
	if(v.tagName == "HR" || v.tagName == "IMG")
		v = v.parentNode;
	else if(!isIE)
		OMOut(v);
	else if(v.tagName == "TABLE")
		return;
		
	var m = getMB(v.id).get(v.id);
	if(m != null)
		m.OMOut(v);
}

function IMIOnMouseOutOv(v , visible)
{
	getMB(v.id).currentNode = null;
	
	if(visible)
	{
		// Changes style of the overlay element
		var cfg = getMBOV(v.id).setup;
		if(getMBOV(v.id).get(v.id).isInMB)
		{
			if(!getMBOV(v.id).get(v.id).isClicked)
			{
				if(cfg.menuBarOverlayElementStyle == "")
				{
					v.style.cssText = "";
					v.className = "MenuBarOverlayElement";
				}
				else
				{
					v.style.cssText = cfg.menuBarOverlayElementStyle;
					v.className = "";
				}
			}
		}
		else
		{
			if(cfg.menuPanelOverlayElementStyle == "")
			{
				v.style.cssText = "";
				v.className = "MenuPanelOverlayElement";
			}
			else
			{
				v.style.cssText = cfg.menuPanelOverlayElementStyle;
				v.className = "";
			}
		}
	}
	else
	{
		//debugger;
	}
	
	// Calls OnMouseOut event handler of the underlay element
	var newId = RemoveOv(v.id);
	var newObj = GetObject(newId);
	IMIOnMouseOut(newObj);
}

function IMIOnMouseOut(v)
{
	if(v.tagName == "HR" || v.tagName == "IMG")
		v = v.parentNode;
	if(dg(v.id).tagName == "HR" || dg(v.id).tagName == "IMG")
		dg(v.id) = dg(v.id).parentNode;
	var m = getMB(v.id).get(v.id);
	if(m != null)
		m.OMIOut(v);
}

function IMIOnMouseOverOv(v , visible)
{
	if(visible)
	{
		// Changes style of the overlay element
		var cfg = getMBOV(v.id).setup;
		if(getMBOV(v.id).get(v.id).isInMB)
		{
			if(cfg.menuBarOverlayElementOnMouseOverStyle == "")
			{
				v.style.cssText = "";
				v.className = "MenuBarOverlayElementOnMouseOver";
			}
			else
			{
				v.style.cssText = cfg.menuBarOverlayElementOnMouseOverStyle;
				v.className = "";
			}
		}
		else
		{
			if(cfg.menuPanelOverlayElementOnMouseOverStyle == "")
			{
				v.style.cssText = "";
				v.className = "MenuPanelOverlayElementOnMouseOver";
			}
			else
			{
				v.style.cssText = cfg.menuPanelOverlayElementOnMouseOverStyle;
				v.className = "";
			}
		}
	}
	else
	{
		//debugger;
	}
	
	// Calls OnMouseOver event handler of the underlay element
	var newId = RemoveOv(v.id);
	var newObj = GetObject(newId);
	IMIOnMouseOver(newObj);
}

function IMIOnMouseOver(v)
{
	//debugger;
	if(String(v) != "undefined")
	{
		if(v.tagName == "HR" || v.tagName == "IMG")
			v = v.parentNode;
		
		if(v != null)
		{
			var vid = v.id;			
			if(!v.isInMB)
			{				
				if(v.isInMB != null) //executar o while, se "v" for um objecto "MenuItem", caso contrario,
				                     //o objecto nao irá conter a propriedade "p" e o while irá rebentar (estoura, quando o rato passa num menu sem filhos).
					while(dg("d" + v.id) == null || dg("d" + v.id).tagName != "DIV")
						v = v.p;
				
				getMB(v.id).currentNode = "d" + v.id;
			}
			
			v = getMB(vid).get(vid);
		}
		
		var m = getMB(v.id).get(v.id);
		if(m != null)
			m.OMIOvr(v);
	}
}

function IMIOnClickOv(v , visible)
{
	if(visible)
	{
		// Changes style of the overlay element
		var cfg = getMBOV(v.id).setup;
		
		if(getMBOV(v.id).get(v.id).isInMB)
		{
			if(cfg.menuBarOverlayElementOnClickStyle == "")
			{
				v.style.cssText = "";
				v.className = "MenuBarOverlayElementOnClick";
			}
			else
			{
				v.style.cssText = cfg.menuBarOverlayElementOnClickStyle;
				v.className = "";
			}
		}
		else
		{
			if(cfg.menuPanelOverlayElementOnClickStyle == "")
			{
				v.style.cssText = "";
				v.className = "MenuPanelOverlayElementOnClick";
			}
			else
			{
				v.style.cssText = cfg.menuPanelOverlayElementOnClickStyle;
				v.className = "";
			}
		}
		
		getMBOV(v.id).get(v.id).isClicked = true;
	}
	
	// Retira o click do elemento que estiver clicado
	var menuBarOvElements = getMBOV(v.id).v;
	for(var i = 0 ; i < menuBarOvElements.length ; i++)
	{
		if(menuBarOvElements[i].isClicked)
		{
			if(menuBarOvElements[i].label != getMBOV(v.id).get(v.id).label)
			{
				menuBarOvElements[i].isClicked = false;
				dg(menuBarOvElements[i].id).className = "MenuBarOverlayElement";
			}
		}
	}
	
	// Calls OnClick event handler of the underlay element
	var newId = RemoveOv(v.id);
	var newObj = GetObject(newId);
	IMIOnClick(newObj);
}

function IMIOnClick(v)
{
	if(v.id.length == 12)
		IMOnMouseOut( dg( v.id.substring( 0 , v.id.length - 3 ) ) );
		
	if(v.tagName == "HR" || v.tagName == "IMG")
		v = v.parentNode;
	
	var m = getMB(v.id).get(v.id);
	if(m != null)
		m.OMIClk(v);
}

function GetM(e)
{
	l = e.offsetLeft;
	t = e.offsetTop;
	w = e.offsetWidth;
	
	if(w == 0)
		w = 200;
	
	h = e.offsetHeight;
	p = e.offsetParent;
	while(p.tagName != "BODY")
	{
		l += p.offsetLeft;
		t += p.offsetTop;
		p = p.offsetParent;
	}
	return new Measure(l , t , w , h);
}

function showDiv(oDiv)
{
	if (oDiv.style.visibility == 'visible')
		return;
	
	var CBO;
	if (oDiv.id.length > 7)
		CBO = dg('CBO2');
	else CBO = dg('CBO1');
	
	oDiv.style.zIndex = 10000;
	if (CBO)
	{
		CBO.style.zIndex = 0;
		CBO.style.top = oDiv.style.top;
		CBO.style.left = oDiv.style.left;
		CBO.style.width = oDiv.offsetWidth;
		CBO.style.height = oDiv.offsetHeight;
		CBO.style.visibility = 'visible';
	}
	oDiv.style.visibility = 'visible';
}

function hideDiv(oDiv)
{
	if (oDiv.style.visibility == 'hidden')
		return;
	
	var CBO;
	if (oDiv.id.length > 7)
		CBO = dg('CBO2');
	else CBO = dg('CBO1');
	
	if (CBO)
		CBO.style.visibility = 'hidden';
	oDiv.style.visibility = 'hidden';
}

function getMB(aId)
{
	var s = aId.substring(0 , K_MB.length + 2);
	if (s == "")
		s = "b00";
	return MB[s].ref;
}

function getMBOV(aId)
{
	var s = aId.substring(0 , K_MB.length + 4);
	if(s == "")
		s = "b00ov";
	return MBOV[s].ref;
}

function getStream(aId)
{
	var s = aId.substring(0 , K_MB.length + 2);
	var n = aId.length / 3 - 2;
	if(MB[s].iL < n + 1)
	{
		var o = new Object();
		o.s = "";
		++MB[s].iL;
		MB[s].ss[n] = o;
	}
	return MB[s].ss[n];
}

function getStreamOv(aId)
{
	var s = aId.substring(0 , K_MB.length + 4);
	var n = aId.length / 5 - 2;
	if(MBOV[s].iL < n + 1)
	{
		var o = new Object();
		o.s = "";
		++MBOV[s].iL;
		MBOV[s].ss[n] = o;
	}
	return MBOV[s].ss[n];	
}

function InitCBOIframes()
{
	AppendFrame('CBO1');
	AppendFrame('CBO2');
	return;
}

function AppendFrame(frmId)
{
	if (!document.getElementById(frmId) == null)
		document.write('<IFRAME ID=\'' + frmId + '\' STYLE=\'{border:0;width:0;height:0;position:absolute;}\'></IFRAME>');
}

function fStatusBar(sStatus) 
{
	window.status = sStatus;
}

function dw(s)
{
	document.write(s);
}

function dwln(s)
{
	document.writeln(s);
}

function dg(i)
{
	return document.getElementById(i);
}

function dgN(i)
{
	return document.getElementsByName(i);
}

function silentDebug(message)
{
	document.getElementById("debug").innerHTML += "<br/>" + message;
}

function IsNill(p)
{
	return p == null || (typeof(p) == "undefined") || String(p) == "";
}

function LZ(n)
{
	n = parseInt(n , 10);
	if(n < 10)
		return '0' + n;
	return n;
}

function RemoveOv(aId)
{
	var str = aId.replace("ov" , "");
	
	while(str.lastIndexOf("ov") != -1)
		str = str.replace("ov" , "");
		
	return str;
}

function CalculateOvDivId(aId)
{
	var tmp1 = aId.substring(0 , 1);
	var tmp2 = aId.substring(1 , aId.length);
	
	var tmp3 = "";
	var j = 0;
	for(var i = 0 ; i < tmp2.length/3 ; i++)
	{
		tmp3 += tmp2.substring(j , (i + 1) * 3) + "ov";
		j = (i + 1) * 3;
	}
		
	return tmp1 + tmp3;
}

function GetObject(aId)
{
	return getMB(aId).get(aId);
}

function ForceWidthFirefox(ClassName , CssTextFromSetup , MenuOrientation)
{
	var cssFileName = "";
	if(MenuOrientation == "horizontal")
		cssFileName = "skins/HorizMenu.css";
	else cssFileName = "skins/VertMenu.css";
	
	var width = GetWidth(CssTextFromSetup , "");
	if(width != "")	
	{
		return width;
	}
	else
	{
		var ssheets = document.styleSheets;
		for(var i = 0 ; i < ssheets.length ; i++)
		{
			if(isIE)
			{
				if(ssheets[i].href == cssFileName)
				{
					var ssheet = ssheets[i];
					var csstext = ssheet.cssText;
					if(ExistsClassNameInStyleSheet(ClassName , csstext))
					{
						width = GetWidth(csstext , ClassName);
					}
					else
					{ 
						width = "";
					}
					break;
				}
			}
			else
			{
				var ssheetFireFox = String(ssheets[i].href);
				if(ssheetFireFox.indexOf(cssFileName) != -1)
				{
					var ssheet = ssheets[i];
					var rules = ssheet.cssRules;
					
					for(var i = 0 ; i < rules.length ; i++)
					{
						var cName = "." + ClassName
						if(rules[i].selectorText == cName)
						{	
							var csstext = rules[i].style.cssText;
							width = GetWidth(csstext , "");
						}
					}
					break;
				}
			}
		}
	}
	return width; 
}

function ExistsClassNameInStyleSheet(ClassName , csstext)
{
	if(csstext.indexOf(ClassName) != -1)
		return true;
	else return false;
}

function GetWidth(csstext , classname)
{	
	if(csstext != "")
	{
		if(classname == "")
		{
			// Obtem o width text do csstext passado como argumento
			classCssText = csstext.toLowerCase();
			var ind1 = classCssText.indexOf("width: ");
			if(ind1 != -1)
			{
				var tmp2 = classCssText.substr(ind1);
				var ind2 = tmp2.indexOf(";");
				var widthText = tmp2.substring(0 , ind2 + 1);
				
				// Finalmente extrai o valor do width
				var ind3 = tmp2.indexOf(";");
				return tmp2.substring(7 , ind3);
			}
			else
			{
				// A propriedade width nao esta especificada
				// no csstext passado como argumento
				return "";
			}
		}
		else
		{
			// Saca primeiro a o csstext da classe classname
			var startIndex = csstext.indexOf(classname);
			if(startIndex != -1)
			{
				var tmp = csstext.substr(startIndex);
				var endIndex = tmp.indexOf("}");
				var classCssText = tmp.substring(0 , endIndex + 1);
				
				// E depois o width text dessa classe
				classCssText = classCssText.toLowerCase();
				var ind1 = classCssText.indexOf("width: ");
				if(ind1 != -1)
				{
					var tmp2 = classCssText.substr(ind1);
					var ind2 = tmp2.indexOf(";");
					var widthText = tmp2.substring(0 , ind2 + 1);
					
					// Finalmente extrai o valor do width
					var ind3 = tmp2.indexOf(";");
					return tmp2.substring(7 , ind3);
				}
				else
				{
					// A propriedade width nao esta especificada na classe
					return "";
				}
			}
			else
			{
				// A classe não existe
				return "";
			}
		}
	}
	else
	{
		// Não foi passado qualquer texto de css
		return "";
	}
}

function CalculateOverlayPosition()
{
	dg("IMBov").style.display = "block";
	var verticalOffset   = parseInt(dg("IMB").offsetTop) - parseInt(dg("IMBov").offsetTop);
	var horizontalOffset = parseInt(dg("IMB").offsetLeft) - parseInt(dg("IMBov").offsetLeft);
	dg("IMBov").style.top  = String(verticalOffset) + "px";
	dg("IMBov").style.left = String(horizontalOffset) + "px";
}

function ApplyStyle(element , event , obj , cfg)
{
	
	if(element == "MenuBar")
	{
		if(event == "onmouseout")
		{
			if(obj.isFirst)
			{
				if(cfg.menuBarFirstElementStyle == '')
				{
					dg(obj.id).style.cssText = '';
					dg(obj.id).className = 'MenuBarFirstElement';
				}
				else
				{
					dg(obj.id).style.cssText = cfg.menuBarFirstElementStyle;
					dg(obj.id).className = '';
				}
			}
			else
			{
				if(obj.isLast)
				{		
					if(cfg.menuBarLastElementStyle == '')
					{
						dg(obj.id).style.cssText = '';
						dg(obj.id).className = 'MenuBarLastElement';
					}
					else
					{
						dg(obj.id).style.cssText = cfg.menuBarLastElementStyle;
						dg(obj.id).className = '';
					}
				}
				else
				{
					if(cfg.menuBarMiddleElementStyle == '')
					{
						dg(obj.id).style.cssText = '';
						dg(obj.id).className = 'MenuBarMiddleElement';
					}
					else
					{
						dg(obj.id).style.cssText = cfg.menuBarMiddleElementStyle;
						dg(obj.id).className = '';
					}
				}
			}			
		}
		
		if(event == "onmouseover")		
		{
			if(obj.isFirst)
			{
				if(cfg.menuBarFirstElementOnMouseOverStyle == '')
				{
					dg(obj.id).style.cssText = '';
					dg(obj.id).className = 'MenuBarFirstElementOnMouseOver';
				}
				else
				{
					dg(obj.id).style.cssText = cfg.menuBarFirstElementOnMouseOverStyle;
					dg(obj.id).className = '';
				}
			}
			else
			{
				if(obj.isLast)
				{		
					if(cfg.menuBarLastElementOnMouseOverStyle == '')
					{
						dg(obj.id).style.cssText = '';
						dg(obj.id).className = 'MenuBarLastElementOnMouseOver';
					}
					else
					{
						dg(obj.id).style.cssText = cfg.menuBarLastElementOnMouseOverStyle;
						dg(obj.id).className = '';
					}
				}
				else
				{
					if(cfg.menuBarMiddleElementOnMouseOverStyle == '')
					{
						dg(obj.id).style.cssText = '';
						dg(obj.id).className = 'MenuBarMiddleElementOnMouseOver';
					}
					else
					{
						dg(obj.id).style.cssText = cfg.menuBarMiddleElementOnMouseOverStyle;
						dg(obj.id).className = '';
					}
				}
			}
		}
		
		if(event == "onclick")
		{
			if(obj.isFirst)
			{
				if(cfg.menuBarFirstElementOnClickStyle == '')
				{
					dg(obj.id).style.cssText = '';
					dg(obj.id).className = 'MenuBarFirstElementOnClick';
				}
				else
				{
					dg(obj.id).style.cssText = cfg.menuBarFirstElementOnClickStyle;
					dg(obj.id).className = '';
				}
			}
			else
			{
				if(obj.isLast)
				{		
					if(cfg.menuBarLastElementOnClickStyle == '')
					{
						dg(obj.id).style.cssText = '';
						dg(obj.id).className = 'MenuBarLastElementOnClick';
					}
					else
					{
						dg(obj.id).style.cssText = cfg.menuBarLastElementOnClickStyle;
						dg(obj.id).className = '';
					}
				}
				else
				{
					if(cfg.menuBarMiddleElementOnClickStyle == '')
					{
						dg(obj.id).style.cssText = '';
						dg(obj.id).className = 'MenuBarMiddleElementOnClick';
					}
					else
					{
						dg(obj.id).style.cssText = cfg.menuBarMiddleElementOnClickStyle;
						dg(obj.id).className = '';
					}
				}
			}
		}
	}
	else
	{
		if(element == "MenuPanel")
		{
			if(event == "onmouseout")
			{
				if(obj.isFirst)
				{
					if(cfg.menuPanelFirstElementStyle == '')
					{
						dg(obj.id).style.cssText = '';
						dg(obj.id).className = 'MenuPanelFirstElement';
					}
					else
					{
						dg(obj.id).style.cssText = cfg.menuPanelFirstElementStyle;
						dg(obj.id).className = '';
					}
				}
				else
				{
					if(obj.isLast)
					{		
						if(cfg.menuPanelLastElementStyle == '')
						{
							dg(obj.id).style.cssText = '';
							dg(obj.id).className = 'MenuPanelLastElement';
						}
						else
						{
							dg(obj.id).style.cssText = cfg.menuPanelLastElementStyle;
							dg(obj.id).className = '';
						}
					}
					else
					{
						if(cfg.menuPanelMiddleElementStyle == '')
						{
							dg(obj.id).style.cssText = '';
							dg(obj.id).className = 'MenuPanelMiddleElement';
						}
						else
						{
							dg(obj.id).style.cssText = cfg.menuPanelMiddleElementStyle;
							dg(obj.id).className = '';
						}
					}
				}			
			}
							
			if( event == "onmouseover")
			{
				if(obj.isFirst)
				{
					if(cfg.menuPanelFirstElementOnMouseOverStyle == '')
					{
						dg(obj.id).style.cssText = '';
						dg(obj.id).className = 'MenuPanelFirstElementOnMouseOver';
					}
					else
					{
						dg(obj.id).style.cssText = cfg.menuPanelFirstElementOnMouseOverStyle;
						dg(obj.id).className = '';
					}
				}
				else
				{
					if(obj.isLast)
					{		
						if(cfg.menuPanelLastElementOnMouseOverStyle == '')
						{
							dg(obj.id).style.cssText = '';
							dg(obj.id).className = 'MenuPanelLastElementOnMouseOver';
						}
						else
						{
							dg(obj.id).style.cssText = cfg.menuPanelLastElementOnMouseOverStyle;
							dg(obj.id).className = '';
						}
					}
					else
					{
						if(cfg.menuPanelMiddleElementOnMouseOverStyle == '')
						{
							dg(obj.id).style.cssText = '';
							dg(obj.id).className = 'MenuPanelMiddleElementOnMouseOver';
						}
						else
						{
							dg(obj.id).style.cssText = cfg.menuBarMiddleElementOnMouseOverStyle;
							dg(obj.id).className = '';
						}
					}
				}
			}
					
			if(event == "onclick")
			{
				if(obj.isFirst)
				{
					if(cfg.menuPanelFirstElementOnClickStyle == '')
					{
						dg(obj.id).style.cssText = '';
						dg(obj.id).className = 'MenuPanelFirstElementOnClick';
					}
					else
					{
						dg(obj.id).style.cssText = cfg.menuPanelFirstElementOnClickStyle;
						dg(obj.id).className = '';
					}
				}
				else
				{
					if(obj.isLast)
					{		
						if(cfg.menuBarLastElementOnClickStyle == '')
						{
							dg(obj.id).style.cssText = '';
							dg(obj.id).className = 'MenuPanelLastElementOnClick';
						}
						else
						{
							dg(obj.id).style.cssText = cfg.menuPanelLastElementOnClickStyle;
							dg(obj.id).className = '';
						}
					}
					else
					{
						if(cfg.menuPanelMiddleElementOnClickStyle == '')
						{
							dg(obj.id).style.cssText = '';
							dg(obj.id).className = 'MenuPanelMiddleElementOnClick';
						}
						else
						{
							dg(obj.id).style.cssText = cfg.menuPanelMiddleElementOnClickStyle;
							dg(obj.id).className = '';
						}
					}
				}
			}
		}
	}
}
