/// 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 iMB = 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 fullUrl='';

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 = 20000;
	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 == "" || !isIE)
		s = "b00"
	return MB[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 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 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;
}

function IMBDraw()
{	
	// Build root menu table
	//debugger;	
	if(this.setup.menuOrientation == "horizontal")
	{
		if(this.v.length > 0)
		{
			getStream(this.v[0].id).s += '<TABLE id="IMB" name="IMB" class="ROOT_TABLE" cellSpacing="' + this.setup.rootCellSpacing + '" style="' + this.setup.rootTableStyle + '"><TBODY><TR>';
					
			for(var i = 0 ; i < this.v.length ; ++i)
			{
				this.v[i].draw();
				if (i+1<this.v.length) getStream(this.v[i].id).s+='<td class="ROOT_TABLE_CELL_SEP" >.</td>';				
			}
			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="ROOT_TABLE" cellSpacing="' + this.setup.rootCellSpacing + '" style="' + this.setup.rootTableStyle + '"><TBODY>';
						
				for(var i = 0 ; i < this.v.length ; ++i)
					this.v[i].draw();
				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;
	}
	document.close();
}

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.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 fStatusBar(sStatus) 
{
	window.status = sStatus;
}

function IMIDraw()
{
	var cfg = getMB(this.id).setup;
	
	if(this.isInMB)
	{
		if(cfg.menuOrientation == "horizontal")
		{
			getStream(this.id).s += '<TD  bgcolor="#000000" id="' + this.id + '" name="' + this.id
			+ '" onmouseover="IMIOnMouseOver(isIE ? event.srcElement : this)" onmouseout="IMIOnMouseOut(isIE ? event.srcElement : this);" onclick="IMIOnClick(isIE ? event.srcElement : this)" '
			+ 'class="ROOT_TABLE_CELL" style="' + cfg.rootTableCellStyle + '" noWrap >'
			+ this.label +'</TD>';			
		}
		else
		{
			if(cfg.menuOrientation == "vertical")
			{
				getStream(this.id).s += '<TR><TD  bgcolor="#000000" id="' + this.id + '" name="' + this.id
					+ '" onmouseover="IMIOnMouseOver(isIE ? event.srcElement : this)" onmouseout="IMIOnMouseOut(isIE ? event.srcElement : this);" onclick="IMIOnClick(isIE ? event.srcElement : this)" '
					+ 'class="ROOT_TABLE_CELL" style="' + cfg.rootTableCellStyle + '" noWrap >'
					+ this.label +'</TD></TR>';
			}
		}
		if(this.t == K_M)
		{
			getStream(this.v[0].id).s += '<DIV style="z-index:100;" id="'+ K_DIV + this.id +'" name="'+ K_DIV + this.id +'" class="MENU_DIV" style="' + cfg.menuvDivStyle + '">'
			+'<TABLE id="'+ K_TAB + this.id +'" name="'+ K_TAB + this.id +'" onmouseout="IMOnMouseOut(isIE?event.srcElement:this)" onmouseover="IMOnMouseOver(isIE?event.srcElement:this)" '
			+'class="MENU_TABLE" cellSpacing="' + cfg.menuCellSpacing + '" style="' + cfg.menuTableStyle + '">';
			//+'<TR class="MENU_TABLE_ROW" style="' + cfg.menuTableRowStyle + '"><td><IMG src="'+ fullUrl +'spacer.gif" border="0" width="0" height="0"></TD></TR>';
			
			for(var i = 0 ; i < this.v.length ; ++i)
				this.v[i].draw();
			//getStream(this.v[0].id).s += '</TABLE></DIV>';
			getStream(this.v[0].id).s += '<td style="padding: 0px 0px 0px 0px;height:3px;" colspan="2"><table cellspacing="0" cellpadding="0" style="width:100%;height:3px;"><tr style="height:3px;"><td style="width:3px;height:3px;background-color:Transparent;"><img alt="" src="' + httpsUrlImages +'canto-item-inf-esq.png" height="3px"></td><td style="width:100%;height:3px;background-color:#AFE100;"><img alt="" src="' + httpsUrlImages +'spacer.gif" height="3px"></td><td style="width:3px;background-color:Transparent;height:3px;"><img alt="" src="' + httpsUrlImages +'canto-item-inf-dir.png" height="3px"></td></tr></table></td></TABLE></DIV>';
		}
	}
	else
	{
		if(this.t == K_M)
		{
			getStream(this.id).s += '<TR id="'+ this.id +'" name="'+ this.id +'" onmouseover="IMIOnMouseOver(isIE?event.srcElement:this)" ' 
								 + 'onclick="IMIOnClick(isIE?event.srcElement:this)" onmouseout="IMIOnMouseOut(isIE?event.srcElement:this)" '
								 + 'class="MENU_TABLE_ROW" style="' + cfg.menuTableRowStyle + '"><TD id="'+ this.id +'" name="'+ this.id +'" class="MENU_TABLE_CELL1" style="' + cfg.menuTableCell1Style + '" noWrap >'+ this.label +'</TD>'
								 + '<TD id="'+ this.id +'" name="'+ this.id +'" class="MENU_TABLE_CELL2" style="' + cfg.menuTableCell2Style + '" noWrap >'
								 + '<IMG  hspace="5" id="'+ K_IMG + this.id +'" src="' + cfg.mArrOf + '" align="right" border="0" width="' + cfg.imgW + '" height="' + cfg.imgH + '"></TD></TR>';
			         
			
			getStream(this.v[0].id).s += '<DIV  style="z-index:100;"  id="'+ K_DIV + this.id +'" name="' + K_DIV + this.id +'" class="MENU_DIV" style="' + cfg.menuvDivStyle + '">'
			                          +'<TABLE id="'+ K_TAB + this.id +'" name="' + K_TAB + this.id +'" onmouseout="IMOnMouseOut(isIE?event.srcElement:this)" onmouseover="IMOnMouseOver(isIE?event.srcElement:this)" '
			                          +'class="MENU_TABLE" cellSpacing="' + cfg.menuCellSpacing + '" style="' + cfg.menuTableStyle + '">'+'<TBODY>';
			
			for(var i = 0 ; i < this.v.length ; ++i) 
				this.v[i].draw();
			getStream(this.v[0].id).s += '<td style="padding: 0px 0px 0px 0px;height:3px;" colspan="2"><table cellspacing="0" cellpadding="0" style="width:100%;height:3px;"><tr style="height:3px;"><td style="width:3px;height:3px;background-color:Transparent;"><img alt="" src="' + httpsUrlImages +'canto-item-inf-esq.png" height="3px"></td><td style="width:100%;height:3px;background-color:#AFE100;"><img alt="" src= "' + httpsUrlImages +'spacer.gif" height="3px"></td><td style="width:3px;background-color:Transparent;height:3px;"><img alt="" src="' + httpsUrlImages +'canto-item-inf-dir.png" height="3px"></td></tr></table></td></TBODY></TABLE></DIV>';
			//getStream(this.v[0].id).s += '</TBODY></TABLE></DIV>';
		}
		else 
		{
			if (this.label == K_SEP) 
			{
				//getStream(this.id).s += '<TR class="MENU_TABLE_ROW" style="' + cfg.menuTableRowStyle + '"><TD colspan="2" valign="middle" height="1px"><IMG src="appimages/Menu/spacer.gif" border="0" width="100%" height="1px" align="absmiddle"></TD></TR>';
				getStream(this.id).s += '<TR class="MENU_TABLE_ROW" style="' + cfg.menuTableRowStyle + '"><TD colspan="2" valign="middle" width="100%" height="1px"><IMG src="' + httpsUrlImages +'menu_separador.gif" border="0" width="100%" height="1px" align="absmiddle"></TD></TR>';
				//getStream(this.id).s += '<TR class="MENU_TABLE_ROW" style="' + cfg.menuTableRowStyle + '"><TD colspan="2" valign="middle" height="1px"><IMG src="appimages/Menu/spacer.gif" border="0" width="100%" height="1px" align="absmiddle"></TD></TR>';
			}
			else
			{
				getStream(this.id).s += '<TR id="' + this.id + '" name=' + this.id + (this.t == K_MI ? ' onmouseover="IMIOnMouseOver(isIE ? event.srcElement : this)" onclick="IMIOnClick(isIE ? event.srcElement : this)" onmouseout="IMIOnMouseOut(isIE ? event.srcElement : this);fStatusBar(\'\');" ':'')
				+ 'class="MENU_TABLE_ROW">'+'<TD colspan="2" nowrap id="'+ this.id +'" name="' + this.id + '" class="MENU_TABLE_CELL3" style="' + cfg.menuTableCell3Style + '" >'
				+ this.label +'</TD></TR>';
			}
		}
	}
}

function OMIClk(v)
{
	var cfg = getMB(v.id).setup;	
	if(!IsNill(this.link))
	{
		if(this.isPU)
			open(this.link);
		else window.location = this.link;
	} else return;
	
	dg(v.id).style.cssText = cfg.rootOnClickStyle;
		
	var rootItems = getMB(v.id).v;
	for(var i = 0 ; i < rootItems.length ; i++)
	{
		if(rootItems[i].isClicked)
			if(rootItems[i].label != getMB(v.id).get(v.id).label)
			{
				rootItems[i].isClicked = false;
	            dg(rootItems[i].id).style.cssText = cfg.rootStandardStyle;
	        }
	}
	getMB(v.id).get(v.id).isClicked = true;
}

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(myPopUp , aP , cfg.rootBgColor , cfg.menuBgColor , cfg.rootFontColor , cfg.fontColorOnMouseOut , cfg.mArrOf);
			var col = dgN(v.id);
			for(var w = 0 ; w < col.length ; ++w)
				with(col[w].style)
				{
					borderTop    = cfg.rootCellBorderTop;
					borderBottom = cfg.rootCellBorderBottom;
					borderLeft   = cfg.rootCellBorderLeft;
					borderRight  = cfg.rootCellBorderRight;		
				}
		}
	}
	else if(this.isInMB && this.t == K_MI)
	{
		var col = dgN(v.id);
		for( var w = 0 ; w < col.length ; ++w )
			with(col[w].style)
			{
				backgroundColor = cfg.rootBgColor;				
				color           = cfg.rootFontColor;
				borderTop       = cfg.rootCellBorderTop;
				borderBottom    = cfg.rootCellBorderBottom;
				borderLeft      = cfg.rootCellBorderLeft;
				borderRight     = cfg.rootCellBorderRight;
			}
	}
	else if(!this.isInMB && this.t == K_MI)
	{
		var col = dgN(v.id);
		for(var w = 0 ; w < col.length ; ++w)
		{
			with(col[w].style)
			{
				backgroundColor = cfg.menuBgColor;	
				fontWeight="normal";			
				color           = cfg.fontColorOnMouseOut;
			}
		}
	}
}

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(aP , myPopUp , aP.indexOf(myPopUp) != -1 , false , cfg.rootBgColor , cfg.menuBgColor , cfg.rootFontColor , cfg.fontColorOnMouseOut , cfg.mArrOf);
			}
		}
	}
				
	if(!getMB(v.id).get(v.id).isClicked)
	{
		var col = dgN(v.id);
		for(var w = 0 ; w < col.length ; ++w)
		{			
			with(col[w].style)
			{
				backgroundColor = a ? cfg.rootBgColorOnMouseOver : cfg.menuHighlightColor;
				//fontWeight="bold";
				color = a ? cfg.rootFontColorOnMouseOver : cfg.fontColorOnMouseOver;				
				// Change border style only in mouse over event in root menu elements
				if((this.isInMB && this.t == K_M) || (this.isInMB && this.t == K_MI))
				{
					borderTop    = cfg.rootCellBorderTopOnMouseOver;
					borderBottom = cfg.rootCellBorderBottomOnMouseOver;
					borderLeft   = cfg.rootCellBorderLeftOnMouseOver;
					borderRight  = cfg.rootCellBorderRightOnMouseOver;
					//fontWeight   = "bold";
				}
			}
			
		}
	}
		
	if(this.t == K_M)
	{
		var p = GetM(a ? v : isIE ? (this.t == K_MS ? v.parentNode.parentNode : v.parentNode) : v);
		var x;
		var y;
		
		if(cfg.menuOrientation == "horizontal")
		{
			x = a ? (p.x + cfg.l1MenuHorizontalOffset) : (p.x + p.w + cfg.l2MenuHorizontalOffset);
			y = a ? (p.y + cfg.l1MenuVerticalOffset + p.h) : (p.y + cfg.l2MenuVerticalOffset);
		}
		else
		{
			if(cfg.menuOrientation == "vertical")
			{
				x = a ? (p.x + p.w + cfg.l1MenuHorizontalOffset) : (p.x + p.w + cfg.l2MenuHorizontalOffset);
				y = a ? (p.y + cfg.l1MenuVerticalOffset) : (p.y + cfg.l2MenuVerticalOffset);
			}
		}
					
		if(!a)
		{
			myPopUp = K_DIV + v.id;
			dg(K_IMG + v.id).src = cfg.mArrOn;
		}
		
		var d = dg(myPopUp);

	    var dm = GetM(d);
	    if(parseInt(x + dm.w) > document.body.offsetWidth)
	    {
		    x = x - dm.w + (a ? (p.w - cfg.l1MenuHorizontalOffset) : (-p.w - cfg.l2MenuHorizontalOffset));
	    }
			
		with(d.style)
		{
			top = y + "px";
			left = x + "px";
		}
		showDiv(d);
		aP = myPopUp;
	}
}

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( dId, aP, cfg.rootBgColor, cfg.menuBgColor, cfg.rootFontColor, cfg.fontColorOnMouseOut, cfg.mArrOf );
}

function Hide(i , t , r , withTO , rootBgColor , menuBgColor , rootFontColor , fontColorOnMouseOut , mArrOf)
{	
	if(arguments.length < 3)
	{
		withTO = true;
		r = false;
	}
	else if(arguments.length < 4)
		withTO = true;
	
	var mI = false;
	var d = dg(i);
	if(d == null)
		return;
		
	if(d.id.length > 7)
	{
		var x = d.id.substr(1);
		
		if(!getMB(x).get(x).isClicked)
		{
			var col=dgN(x);
			for(var w = 0 ; w < col.length ; ++w)
			{
				with(col[w].style)
				{
					backgroundColor = menuBgColor;	
					fontWeight="normal";				
					color = fontColorOnMouseOut;
				}
			}
		}
		dg(K_IMG + x).src = mArrOf;	
	}
	else if(d.id.length == 7)
	{
		var k = d.id.substr(1);
		if(!getMB(k).get(k).isClicked)
		{
			var col = dgN(k);
			for(var w = 0 ; w < col.length ; ++w)
			{
				with(col[w].style)
				{
					backgroundColor = rootBgColor;					
					color = rootFontColor;
				}
			}
		}
		mI = true;
	}
	hideDiv(d);
	
	if(d.id.length > 7 && aP == d.id && (r+""=="false") ) //!r)
	{
		var dId = d.id.substring(0,d.id.length - 3);
		aP = dId;
		if(withTO)
		{
			myST(dId , aP , rootBgColor , menuBgColor , rootFontColor , fontColorOnMouseOut , mArrOf);
			bS = false;
		}
		else 
		{
			Hide(dId , aP , false , true , rootBgColor , menuBgColor, rootFontColor , fontColorOnMouseOut , mArrOf);
			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(z , aP , false , true , rootBgColor , menuBgColor , rootFontColor , fontColorOnMouseOut , mArrOf);
		bS = false;
	}
}

function myST(pTH , oPU , rootBgColor , menuBgColor , rootFontColor , fontColorOnMouseOut , mArrOf)
{
	if(aPT != null)
	{
		clearTimeout(aPT);
		aPT = null;
	}
	aPT = setTimeout('Hide("'+ pTH +'" , "'+ oPU +'" , "false" , "true" , "'+ rootBgColor +'" , "'+ menuBgColor +'" , "'+ rootFontColor +'" , "'+ fontColorOnMouseOut +'" , "'+ mArrOf +'")' , 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 IMIOnMouseOut(v)
{
	if(v.tagName == "HR" || v.tagName == "IMG")
		v = v.parentNode;
	var m = getMB(v.id).get(v.id);
	if(m != null)
		m.OMIOut(v);
}

function IMIOnMouseOver(v)
{
	if(v.tagName == "HR" || v.tagName == "IMG")
		v = v.parentNode;
	var m = getMB(v.id).get(v.id);
	if(m != null)
		m.OMIOvr(v);
}

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!=null && p.tagName != "BODY")
	{
		l += p.offsetLeft;
		t += p.offsetTop;
		p = p.offsetParent;
	}
	return new Measure(l,t,w,h);
}

function Measure(x,y,w,h)
{
	this.x = x;
	this.y = y;
	this.w = w;
	this.h = h;
}

function IMenuSetup(rootFont , rootFontColor , rootFontColorOnMouseOver , rootTextAlignment , rootBgColor , rootBgColorOnMouseOver 
					, rootCellHeight , rootCellWidth , rootWidth , rootBorderTop , rootBorderBottom , rootBorderLeft , rootBorderRight 
					, rootPaddingTop , rootPaddingBottom , rootPaddingLeft , rootPaddingRight , rootCursorType , rootCellSpacing
					, rootCellBorderTop , rootCellBorderBottom , rootCellBorderLeft , rootCellBorderRight 
					, rootCellBorderTopOnMouseOver , rootCellBorderBottomOnMouseOver , rootCellBorderLeftOnMouseOver , rootCellBorderRightOnMouseOver 
					, rootStandardStyle ,rootOnMouseOverStyle , rootOnClickStyle
					, menuCursorType , menuBgColor , menuUnderDivSectionColor , menuHighlightColor , menuFont , fontColorOnMouseOver 
					, fontColorOnMouseOut , menuTextAlignment , outerBorderTop , outerBorderBottom , outerBorderLeft 
					, outerBorderRight , outerPaddingTop , outerPaddingBottom , outerPaddingLeft , outerPaddingRight 
					, menuCellHeight , menuCellBorderTop , menuCellBorderBottom , menuCellBorderLeft , menuCellBorderRight , menuCellSpacing
					, menuPaddingTop , menuPaddingBottom , menuPaddingLeft , menuPaddingRight , l1MenuHorizontalOffset 
					, l1MenuVerticalOffset , l2MenuHorizontalOffset , l2MenuVerticalOffset , menuOrientation, fullHostDoomainUrl)
					
{
	this.rootFont                 = rootFont;                  // Font of the menu root
	this.rootFontColor            = rootFontColor;             // Font color in the menu root
	this.rootFontColorOnMouseOver = rootFontColorOnMouseOver;  // Font color in the menu root on mouse over event	
	this.rootTextAlignment        = rootTextAlignment;         // Alignment (left, center, right or justify) of the root menu elements text
	this.rootBgColor              = rootBgColor;               // Background color of the 'root' table cells
	this.rootBgColorOnMouseOver   = rootBgColorOnMouseOver;    // Background color of the 'root' table that represents the entire menu on mouse over event
	this.rootCellHeight           = rootCellHeight;            // Height of the 'root' table cells
	this.rootCellWidth            = rootCellWidth;             // Width of the 'root' table cells
	this.rootWidth                = rootWidth;                 // Root table width (total menu width)
	this.rootBorderTop            = rootBorderTop;             // Top Border in the root table
	this.rootBorderBottom         = rootBorderBottom;          // Bottom Border in the root table
	this.rootBorderLeft           = rootBorderLeft;            // Left Border in the root table
	this.rootBorderRight          = rootBorderRight;           // Right Border in the root table
	this.rootPaddingTop           = rootPaddingTop;            // Top Padding in the menu root
	this.rootPaddingBottom        = rootPaddingBottom;         // Bottom Padding in the menu root
	this.rootPaddingLeft          = rootPaddingLeft;           // Left Padding in the menu root
	this.rootPaddingRight         = rootPaddingRight;          // Right Padding in the menu root
	this.rootCursorType           = rootCursorType;            // Cursor type of the menu root
	this.rootCellSpacing          = rootCellSpacing;           // Spacing between root cells
	this.rootCellBorderTop        = rootCellBorderTop;         // Top Border in the menu root cells
	this.rootCellBorderBottom     = rootCellBorderBottom;      // Bottom Border in the menu root cells
	this.rootCellBorderLeft       = rootCellBorderLeft;        // Left Border in the menu root cells
	this.rootCellBorderRight      = rootCellBorderRight;       // Right Border in the menu root cells
	this.rootCellBorderTopOnMouseOver    = rootCellBorderTopOnMouseOver;    // Top border in the menu root cells on mouse over
	this.rootCellBorderBottomOnMouseOver = rootCellBorderBottomOnMouseOver; // Bottom border in the menu root cells on mouse over
	this.rootCellBorderLeftOnMouseOver   = rootCellBorderLeftOnMouseOver;   // Left border in the menu root cells on mouse over
	this.rootCellBorderRightOnMouseOver  = rootCellBorderRightOnMouseOver;  // Right border in the menu root cells on mouse over
	this.rootStandardStyle        = rootStandardStyle;
	this.rootOnMouseOverStyle     = rootOnMouseOverStyle;
	this.rootOnClickStyle         = rootOnClickStyle;
	
	this.menuCursorType           = menuCursorType;            // Cursor type of the menu
	this.menuBgColor              = menuBgColor;               // Background color of the level 1 menu
	this.menuUnderDivSectionColor = menuUnderDivSectionColor;  // Background color of the menu rows
	this.menuHighlightColor       = menuHighlightColor;        // Menu highlight color on mouse over event
	this.menuFont                 = menuFont;                  // Font of the menu
	this.fontColorOnMouseOver     = fontColorOnMouseOver;      // Font color in the menu rows on mouse over event	
	this.fontColorOnMouseOut      = fontColorOnMouseOut;       // Font color in the menu rows on mouse out event
	this.menuTextAlignment        = menuTextAlignment;         // Alignment (left, center, right or justify) of the menu elements text
	this.outerBorderTop           = outerBorderTop;            // Top border in the div that is a menu panel
	this.outerBorderBottom        = outerBorderBottom;         // Bottom border in the div that is a menu panel
	this.outerBorderLeft          = outerBorderLeft;           // Left border in the div that is a menu panel
	this.outerBorderRight         = outerBorderRight;          // Right border in the div that is a menu panel
	this.outerPaddingTop          = outerPaddingTop;           // Top padding in the div that represents a menu section
	this.outerPaddingBottom       = outerPaddingBottom;        // Bottom padding in the div that represents a menu section
	this.outerPaddingLeft         = outerPaddingLeft;          // Left padding in the div that represents a menu section
	this.outerPaddingRight        = outerPaddingRight;         // Right padding in the div that represents a menu section
	this.menuCellHeight           = menuCellHeight;            // Height of the other menu individual cells
	this.menuCellBorderTop        = menuCellBorderTop;         // Top border of the menu table cells
	this.menuCellBorderBottom     = menuCellBorderBottom;      // Bottom border of the menu table cells 
	this.menuCellBorderLeft       = menuCellBorderLeft;        // Left border of the menu table cells 
	this.menuCellBorderRight      = menuCellBorderRight;       // Right border of the menu table cells
	this.menuCellSpacing          = menuCellSpacing;           // Spacing between level 1 & 2 menu cells
	this.menuPaddingTop           = menuPaddingTop;            // Top padding in the menu rows
	this.menuPaddingBottom        = menuPaddingBottom;         // Bottom padding in the menu rows
	this.menuPaddingLeft          = menuPaddingLeft;           // Left padding in the menu rows
	this.menuPaddingRight         = menuPaddingRight;          // Right padding in the menu rows 
	
	this.l1MenuHorizontalOffset   = l1MenuHorizontalOffset;	   // Horizontal offset of the menu in relation to the root element from where it was open. 
	this.l1MenuVerticalOffset     = l1MenuVerticalOffset;      // Vertical offset of the menu in relation to the root element from where it was open.
	this.l2MenuHorizontalOffset   = l2MenuHorizontalOffset;    // Horizontal offset of the menu in relation to the mwnu element from where it was open.
	this.l2MenuVerticalOffset     = l2MenuVerticalOffset;      // Vertical offset of the menu in relation to the mwnu element from where it was open.
	this.menuOrientation          = menuOrientation;           // Indicates wether this is a horizontal menu or a vertical menu

	this.MainMenu_subImgOn  = theMLArrowGif;
	this.MainMenu_subImgOff = theMLArrowGif;
	this.MainMenu_ImgSep    = theMLSeparator;
	
	//if (fullHostDoomainUrl=="undefined")
	    this.K_URL  = fullHostDoomainUrl+'appImages/Menu/';
	//else
	  //  this.K_URL  = 'appImages/Menu/';	
    
    fullUrl = this.K_URL;            
    
	this.mArrOn = httpsUrlImages + this.MainMenu_subImgOn;
	this.mArrOf = httpsUrlImages + this.MainMenu_subImgOff;
	this.K_MENU_SEP = httpsUrlImages + this.MainMenu_ImgSep;
	this.defURLStart = fullHostDoomainUrl + 'cms.aspx?plg=';
	this.imgH = 8;
	this.imgW = 5;
	
	///////////////////////////
	/// ROOT_TABLE Style
	var rootTableStyle = "";
	if(this.rootBorderTop != null && this.rootBorderTop != "")
		rootTableStyle += "BORDER-TOP: " + this.rootBorderTop + ";";
	
	if(this.rootBorderBottom != null && this.rootBorderBottom != "")
		rootTableStyle += "BORDER-BOTTOM: " + this.rootBorderBottom + ";";
	
	if(this.rootBorderLeft != null && this.rootBorderLeft != "")
		rootTableStyle += "BORDER-LEFT: " + this.rootBorderLeft + ";";
	
	if(this.rootBorderRight != null && this.rootBorderRight != "")
		rootTableStyle += "BORDER-RIGHT: " + this.rootBorderRight + ";";
			
	if(this.rootWidth != null && this.rootWidth != "")
		rootTableStyle += "WIDTH: " + this.rootWidth + ";";
	this.rootTableStyle = rootTableStyle;
	/////////////////////////
	
	/////////////////////////
	/// ROOT_TABLE_CELL Style
	var rootTableCellStyle = "";
	if(this.rootCursor != null && this.rootCursor != "")
		rootTableCellStyle += "CURSOR: " + this.rootCursor + ";";
		
	if(this.rootPaddingTop != null && this.rootPaddingTop != "")
		rootTableCellStyle += "PADDING-TOP: " + this.rootPaddingTop + ";";
	
	if(this.rootPaddingBottom != null && this.rootPaddingBottom != "")
		rootTableCellStyle += "PADDING-BOTTOM: " + this.rootPaddingBottom + ";";
		
	if(this.rootPaddingLeft != null && this.rootPaddingLeft != "")
		rootTableCellStyle += "PADDING-LEFT: " + this.rootPaddingLeft + ";";
		
	if(this.rootPaddingRight != null && this.rootPaddingRight != "")
		rootTableCellStyle += "PADDING-RIGHT: " + this.rootPaddingRight + ";";
	
	if(this.rootCellBorderTop != null && this.rootCellBorderTop != "")
		rootTableCellStyle += "BORDER-TOP: " + this.rootCellBorderTop + ";";
		
	if(this.rootCellBorderBottom != null && this.rootCellBorderBottom != "")
		rootTableCellStyle += "BORDER-BOTTOM: " + this.rootCellBorderBottom + ";";
	
	if(this.rootCellBorderLeft != null && this.rootCellBorderLeft != "")
		rootTableCellStyle += "BORDER-LEFT: " + this.rootCellBorderLeft + ";";
		
	if(this.rootCellBorderRight != null && this.rootCellBorderRight != "")
		rootTableCellStyle += "BORDER-RIGHT: " + this.rootCellBorderRight + ";";
		
	if(this.rootFont != null && this.rootFont != "")
		rootTableCellStyle += "FONT: " + this.rootFont + ";";

	if(this.rootFontColor != null && this.rootFontColor != "")
		rootTableCellStyle += "COLOR: " + this.rootFontColor + ";";
	
	if(this.rootTextAlignment != null && this.rootTextAlignment != "")
		rootTableCellStyle += "TEXT-ALIGN: " + this.rootTextAlignment + ";";
	
	if(this.rootBgColor != null && this.rootBgColor != "")
		rootTableCellStyle += "BACKGROUND-COLOR: " + this.rootBgColor + ";";
	
	if(this.rootCellHeight != null && this.rootCellHeight != "")
		rootTableCellStyle += "HEIGHT: " + this.rootCellHeight + ";";
		
	if(this.rootCellWidth != null && this.rootCellWidth != "")
		rootTableCellStyle += "WIDTH: " + this.rootCellWidth + ";";
		
	this.rootTableCellStyle = rootTableCellStyle;
	////////////////////////
	
	/////////////////////////
	/// MENU_DIV Style
	var menuvDivStyle = "";
	if(this.outerBorderTop != null && this.outerBorderTop != "")
		menuvDivStyle += "BORDER-TOP: " + this.outerBorderTop + ";";
	
	if(this.outerBorderBottom != null && this.outerBorderBottom != "")
		menuvDivStyle += "BORDER-BOTTOM: " + this.outerBorderBottom + ";";
	
	if(this.outerBorderLeft != null && this.outerBorderLeft != "")
		menuvDivStyle += "BORDER-LEFT: " + this.outerBorderLeft + ";";
	
	if(this.outerBorderRight != null && this.outerBorderRight != "")
		menuvDivStyle += "BORDER-RIGHT: " + this.outerBorderRight + ";";
		
	if(this.outerPaddingTop != null && this.outerPaddingTop != "")
		menuvDivStyle += "PADDING-TOP: " + this.outerPaddingTop + ";";
		
	if(this.outerPaddingBottom != null && this.outerPaddingBottom != "")
		menuvDivStyle += "PADDING-BOTTOM: " + this.outerPaddingBottom + ";";
	
	if(this.outerPaddingLeft != null && this.outerPaddingLeft != "")
		menuvDivStyle += "PADDING-LEFT: " + this.outerPaddingLeft + ";";
	
	if(this.outerPaddingRight != null && this.outerPaddingRight != "")
		menuvDivStyle += "PADDING-RIGHT: " + this.outerPaddingRight + ";";
				
	if(this.menuUnderDivSectionColor != null && this.menuUnderDivSectionColor != "")
		menuvDivStyle += "BACKGROUND-COLOR: " + this.menuUnderDivSectionColor + ";";
		
	this.menuvDivStyle = menuvDivStyle;
	////////////////////////
	
	/////////////////////////
	/// MENU_TABLE Style
	var menuTableStyle = "";
	if(this.menuBgColor != null && this.menuBgColor != "")
		menuTableStyle += "BACKGROUND-COLOR: " + this.menuBgColor + ";";
	
	if(this.menuCellBorderBottom != null && this.menuCellBorderBottom != "")
		menuTableStyle += "BORDER-BOTTOM: " + this.menuCellBorderBottom + ";";
	this.menuTableStyle = menuTableStyle;
	////////////////////////
	
	/////////////////////////
	/// MENU_TABLE_ROW Style
	var menuTableRowStyle = "";
	if(this.menuBgColor != null && this.menuBgColor != "")
		menuTableRowStyle += "BACKGROUND-COLOR: " + this.menuBgColor + ";";
			
	if(this.menuFont != null && this.menuFont != "")
		menuTableRowStyle += "FONT: " + this.menuFont + ";";
	
	if(this.fontColorOnMouseOver != null && this.fontColorOnMouseOut != "")
		menuTableRowStyle += "COLOR: " + this.fontColorOnMouseOut + ";";
			
	if(this.menuCursor != null && this.menuCursor != "")
		menuTableRowStyle += "CURSOR: " + this.menuCursor + ";";
	
	if(this.menuCellHeight != null && this.menuCellHeight != "")
		menuTableRowStyle += "HEIGHT: " + this.menuCellHeight + ";";
	this.menuTableRowStyle = menuTableRowStyle;
	////////////////////////
	
	/////////////////////////
	/// MENU_TABLE_CELL1 Style
	var menuTableCell1Style = "";

	if(this.menuCellBorderTop != null && this.menuCellBorderTop != "")
		menuTableCell1Style += "BORDER-TOP: " + this.menuCellBorderTop + ";";
		
	if(this.menuCellBorderLeft != null && this.menuCellBorderLeft != "")
		menuTableCell1Style += "BORDER-LEFT: " + this.menuCellBorderLeft + ";";
		
	if(this.menuPaddingTop != null && this.menuPaddingTop != "")
		menuTableCell1Style += "PADDING-TOP: " + this.menuPaddingTop + ";";
	
	if(this.menuPaddingBottom != null && this.menuPaddingBottom != "")
		menuTableCell1Style += "PADDING-BOTTOM: " + this.menuPaddingBottom + ";";
		
	if(this.menuPaddingLeft != null && this.menuPaddingLeft != "")
		menuTableCell1Style += "PADDING-LEFT: " + this.menuPaddingLeft + ";";
		
	if(this.menuPaddingRight != null && this.menuPaddingRight != "")
		menuTableCell1Style += "PADDING-RIGHT: " + this.menuPaddingRight + ";";
	
	if(this.menuTextAlignment != null && this.menuTextAlignment != "")
		menuTableCell1Style += "TEXT-ALIGN: " + this.menuTextAlignment + ";";
		
	this.menuTableCell1Style = menuTableCell1Style;
	////////////////////////

	/////////////////////////
	/// MENU_TABLE_CELL2 Style
	var menuTableCell2Style = "";
	if(this.menuCellBorderTop != null && this.menuCellBorderTop != "")
		menuTableCell2Style += "BORDER-TOP: " + this.menuCellBorderTop + ";";
		
	if(this.menuCellBorderRight != null && this.menuCellBorderRight != "")
		menuTableCell2Style += "BORDER-RIGHT: " + this.menuCellBorderRight + ";";
		
	if(this.menuPaddingTop != null && this.menuPaddingTop != "")
		menuTableCell2Style += "PADDING-TOP: " + this.menuPaddingTop + ";";
	
	if(this.menuPaddingBottom != null && this.menuPaddingBottom != "")
		menuTableCell2Style += "PADDING-BOTTOM: " + this.menuPaddingBottom + ";";
		
	if(this.menuPaddingLeft != null && this.menuPaddingLeft != "")
		menuTableCell2Style += "PADDING-LEFT: " + this.menuPaddingLeft + ";";
		
	if(this.menuPaddingRight != null && this.menuPaddingRight != "")
		menuTableCell2Style += "PADDING-RIGHT: " + this.menuPaddingRight + ";";
	
	if(this.menuTextAlignment != null && this.menuTextAlignment != "")
		menuTableCell2Style += "TEXT-ALIGN: " + this.menuTextAlignment + ";";
	this.menuTableCell2Style = menuTableCell2Style;
	////////////////////////
	
	/////////////////////////
	/// MENU_TABLE_CELL3 Style
	var menuTableCell3Style = "";
	if(this.menuCellBorderTop != null && this.menuCellBorderTop != "")
		menuTableCell3Style += "BORDER-TOP: " + this.menuCellBorderTop + ";";
		
	if(this.menuCellBorderLeft != null && this.menuCellBorderLeft != "")
		menuTableCell3Style += "BORDER-LEFT: " + this.menuCellBorderLeft + ";";
		
	if(this.menuCellBorderRight != null && this.menuCellBorderRight != "")
		menuTableCell3Style += "BORDER-RIGHT: " + this.menuCellBorderRight + ";";
	
	if(this.menuPaddingTop != null && this.menuPaddingTop != "")
		menuTableCell3Style += "PADDING-TOP: " + this.menuPaddingTop + ";";
	
	if(this.menuPaddingBottom != null && this.menuPaddingBottom != "")
		menuTableCell3Style += "PADDING-BOTTOM: " + this.menuPaddingBottom + ";";
		
	if(this.menuPaddingLeft != null && this.menuPaddingLeft != "")
		menuTableCell3Style += "PADDING-LEFT: " + this.menuPaddingLeft + ";";
		
	if(this.menuPaddingRight != null && this.menuPaddingRight != "")
		menuTableCell3Style += "PADDING-RIGHT: " + this.menuPaddingRight + ";";
	
	if(this.menuTextAlignment != null && this.menuTextAlignment != "")
		menuTableCell3Style += "TEXT-ALIGN: " + this.menuTextAlignment + ";";
	this.menuTableCell3Style = menuTableCell3Style;
	////////////////////////
}
function debug(aMsg){if(!dbg)return;var d=dg("imtheone");d.innerText+="\r\n"+aMsg;d.doScroll('scrollbarDown');}
function debugEx(aMsg){return;dbg=true;debug(aMsg);dbg=false;}
function debugAlways(aMsg){dbg=true;debug(aMsg);dbg=false;}
function dwln(s){document.writeln(s);}
function dg(i){return document.getElementById(i);}
function dgN(i){return document.getElementsByName(i);}
function dw(s){document.write(s);}
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;}