//menuContent Class Definition

//Dit is een function die dient als constructor van een menuContent object
function menuContent( aDocument, sId, sName )
{
	//These values can be changed during declaration of a new menu...
	this.Top=80;
	this.TopNS=10; //-4;
	this.Left=0;
	this.Width=98;
	this.Depth=1;										//layer depth (z value)					
	this.BorderColor = "#007ED7";						//color of border
	this.ForegroundColor = "#000000";					//foreground (font) color
	this.BackgroundColor = "#D5EAF9";					//default background color of menu items
	this.ExpandLocation = "right";
	this.highlightedMenuItem=null;

	this.activationScript="";                 //This function is called when the menu is shown
	this.deactivationScript="";               //This function is called when the the menu is hidden
		
		
	//methods
	this.newMenuItem = Menu_newMenuItem;
	
	this.hide = Menu_hide;
	this.hideIfNotActive = Menu_hideIfNotActive;
	
	this.show = Menu_show;
	this.setHighlight = Menu_setHighlight;
	
	this.IE_WriteMenu = Menu_IE_WriteMenu;
	this.OTHER_WriteMenu = Menu_OTHER_WriteMenu;

	this.onMouseOver = MenuContent_OnMouseOver;
	this.onMouseOut = MenuContent_OnMouseOut;

	//readonly variables
	this.bIsVisible=false;		    		 //is false when menu is hidden
	this.bMouseIsOverMenu = false;
	this.Height=0;                		     //Height will be set by the menuitems
	this.MenuItems = new Array();
		
	//Constructor functionality here
	this.Document = aDocument
	this.Id = sId;
	this.Name = sName;
}

function Menu_newMenuItem(sName, sURL)
{
	var aMenuItem;

	if(sURL == null)
		sURL = "";
	
	if(sURL == "")
		aMenuItem = new menuItem(this, sName, "javascript: doNothing();");
	else
		aMenuItem = new menuItem(this, sName, sURL);
		
	this.MenuItems[aMenuItem.Id] = aMenuItem;
	this.MenuItems[this.MenuItems.length] = aMenuItem;

	//Add to global collection of objects. Through this collection objects with a unique id can be found
	document.CA_objects[aMenuItem.Id] = aMenuItem;
	
	return aMenuItem
}

function MenuContent_OnMouseOver()
{
	this.bMouseIsOverMenu = true;
//	this.setHighlight( true );
}

function MenuContent_OnMouseOut()
{
	this.bMouseIsOverMenu = false;
//	this.setHighlight( false );

	//Set a delay because first order in which mouse events are processed
	setTimeout("document.menus[\'" + this.Id + "\'].hideIfNotActive()",30);
}


function Menu_setHighlight( bHighlightMenu )
{
	if( bHighlightMenu )
	{
		//Show highlighted menu image
		document.images[this.Id].src = "../pimg/" + this.Id + "Menu1Title-h.gif";
	}
	else
	{
		//Show normal menu image
		document.images[this.Id].src = "../pimg/" + this.Id + "Menu1Title.gif";
	}		
}

function Menu_show()
{
	var iTop, positioningObject, iLeft, aLayer, iHeight;

	iTop = this.Top;
	if(isMinIE4) //IE
	{
		//reposition menu
		positioningObject = findObject("OffsetX");

		if( positioningObject != null )
		{
			iLeft = positioningObject.offsetLeft + this.Left;
			aLayer = findObject(this.Id + 'Content');
			aLayer.style.left = iLeft;
		}
	}
	setLayerVisibility(this.Id + 'Content', 'show');
		
	this.bIsVisible = true;
}

function Menu_hide()
{
	setLayerVisibility(this.Id + 'Content', 'hide');

	this.bMouseIsOverMenu = false;
	this.bIsVisible = false;
}


function Menu_hideIfNotActive()
{
	if( this.bIsVisible && !this.bMouseIsOverMenu )
	{
		this.hide();
	}
}

function Menu_IE_WriteMenu()
{
	var sId = this.Id + "Content";
	var iWidth = this.Width;
	var iZIndex = 10;
	var sBGColor = this.BackgroundColor;
	var sBorderColor = this.BorderColor;
	var aLayer = null;
	var aMenuItem = null;

	if(isMinIE4) //IE
	{
		positioningObject = document.all["OffsetX"];
		iTop = this.Top;
		iLeft = positioningObject.offsetLeft + this.Left;
		iHeight= this.borderSizeTop + this.MenuItems.length * (this.itemHeight + this.borderSize) + this.borderSizeBottom;

		iHeight=1;
		this.Height = iHeight;

		document.write('<div onMouseOver="document.menus[\'' + this.Id + '\'].onMouseOver()" onmouseout="document.menus[\''+ this.Id + '\'].onMouseOut()" name="' + sId + '" id="'+ sId +'" style="position:absolute; width:' + iWidth + 'px; height:' + iHeight + 'px; z-index:' + iZIndex + '; left: '+ iLeft + 'px; top: ' + iTop + 'px; visibility: hidden; background-color: ' + sBGColor + ';">');

		document.write('<TABLE WIDTH="' + iWidth + '" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="' + sBGColor + '">');
		document.write('<TR>');
		document.write('<TD COLSPAN=3 BGCOLOR="' + sBorderColor + '"><IMG SRC="empty.gif" WIDTH="' + iWidth + '" HEIGHT="1"></TD>');
		document.write('</TR>');
		document.write('<TR>');
		document.write('<TD BGCOLOR="' + sBorderColor + '"><IMG SRC="empty.gif" WIDTH="1" HEIGHT="1"></TD>');

		document.write('<TD>');

		document.write('<TABLE WIDTH="' + (iWidth-2) + '" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#D5EAF9">');
		for( var iIndex = 0; iIndex < this.MenuItems.length; iIndex++ )
		{
			aMenuItem = this.MenuItems[iIndex]
			document.write('<TR>');
			
			if( this.ExpandLocation == "left" )
			{
				document.write('<TD>');
				document.write('<SPAN CLASS="StandardText" NAME="' + aMenuItem.Id + 'Title" ID="' + aMenuItem.Id + 'Title">');
				document.write('</SPAN>');
				document.write('&nbsp;');
				document.write('</TD>');
			}
			else
			{
				document.write('<TD>&nbsp;</TD>');
			}
			document.write('<TD>');
			
			document.write('<SPAN CLASS="StandardText">');
			document.write('<A STYLE="width: 100%" HREF="' + aMenuItem.URL + '" onMouseOver="document.menus[\'' + this.Id + '\'].MenuItems[\'' + aMenuItem.Id + '\'].onMouseOver()" onMouseOut="document.menus[\'' + this.Id + '\'].MenuItems[\'' + aMenuItem.Id + '\'].onMouseOut()">');
			document.write( '<NOBR>' );
			document.write('&gt; &nbsp;' + aMenuItem.Name );
			if( aMenuItem.MenuItems.length > 0 )
			{
				document.write('&nbsp;...' );
			}
			
			document.write( '</NOBR>' );
			document.write('</A>');
			document.write('</SPAN>');
			
			document.write('</TD>');
			document.write('<TD ALIGN=RIGHT>');
			if( this.ExpandLocation != "left" )
			{
				document.write('<SPAN CLASS="StandardText" NAME="' + aMenuItem.Id + 'Title" ID="' + aMenuItem.Id + 'Title">');
				document.write('</SPAN>');
			}
			document.write('<BR>');
			document.write('</TD>');
			document.write('</TR>');
		}
		document.write('</TABLE>');
		document.write('<BR>');

		document.write('<TD>');
		document.write('<TD BGCOLOR="' + sBorderColor + '"><IMG SRC="empty.gif" WIDTH="1" HEIGHT="1"></TD>');
		document.write('</TR>');

		document.write('<TR>');
		document.write('<TD COLSPAN=3 BGCOLOR="' + sBorderColor + '"><IMG SRC="empty.gif" WIDTH="' + iWidth + '" HEIGHT="1"></TD>');
		document.write('</TR>');
		document.write('</TABLE>');
		document.write('</div>');
		
		for( var iIndex = 0; iIndex < this.MenuItems.length; iIndex++ )
		{
			aMenuItem = this.MenuItems[iIndex]
			aMenuItem.WriteMenu();
		}
		
	}
	
	return true;
}


function Menu_OTHER_WriteMenu()
{
	var sId = this.Id + "Content";
	var iWidth = this.Width;
	var iZIndex = 10;
	var sBGColor = this.BackgroundColor;
	var sBorderColor = this.BorderColor;
	var aMenuItem = null;
	var aSubMenuItem = null;

	if( !isMinIE4 )
	{
//		document.write("<SELECT SIZE=1 CLASS=\"MenuListbox\" STYLE=\"width: " + iWidth + "px\" >");
//		document.write("<SELECT SIZE=1 sty" + "le=\"color: black; background-color: #D5EAF9; FONT-FAMILY: verdana; FONT-SIZE: 10px; HEIGHT: 17px; WIDTH: 90px\">");
//		document.write("<SELECT SIZE=1 CLASS=\"MenuListbox\">");
		
		for( var iIndex = 0; iIndex < this.MenuItems.length; iIndex++ )
		{
			aMenuItem = this.MenuItems[iIndex]
			document.write("<OPTION VALUE=\"0\">");
			document.write( aMenuItem.Name );
			document.write("</OPTION>");
			for( var iSubItemIndex = 0; iSubItemIndex < aMenuItem.MenuItems.length; iSubItemIndex++ )
			{
				aSubMenuItem = aMenuItem.MenuItems[iSubItemIndex]

				document.write("<OPTION VALUE=\"0\">");
				document.write("&nbsp;&nbsp;&nbsp;" + aSubMenuItem.Name );
				document.write("</OPTION>");
			}
		}
		document.write("</SELECT>");
	}
	
	return true;
}

