function CheckIfOver()
	{
	var blnMenuOver;
	var intButtonIndex

	blnMenuOver = eval("document.all." + g_strBoroughMenu + ".blnOver");

	for (intButtonIndex = 0; intButtonIndex < g_astrButtons.length; intButtonIndex++)
		{
		 if (eval("document.all.button_" + intButtonIndex + ".blnOver"))
		 	{
		 	blnMenuOver = true;
		 	}
		}

	if (!blnMenuOver)
		{
		Hide()
		}
	}


function Hide()
	{
	var intButtonIndex;

	for (intButtonIndex = 0; intButtonIndex < g_astrButtons.length; intButtonIndex++)
		{
		eval("document.all.button_" + intButtonIndex + ".style.visibility = 'hidden'");
		}
	}


function Initialize()
	{
	var objBoroughMenu = eval("document.all." + g_strBoroughMenu);
	with (objBoroughMenu)
		{
		onmouseover = MouseOver;
		onmouseout = MouseOut;
		blnOver = false;
		}

	var objNavigationBar = eval("document.all." + g_strNavigation);
	for (intButtonIndex = 0; intButtonIndex < g_astrButtons.length; intButtonIndex++)
		{

		strID = "button_" + intButtonIndex;
		objNavigationBar.insertAdjacentHTML("BeforeEnd", "<SPAN CLASS=\"" + g_strBoroughMenuItem + "\" ID=\"" + strID + "\">" 
			+ g_astrButtons[intButtonIndex][0] + "</SPAN>");
		objButton = eval("document.all." + strID);

		if (g_astrButtons[intButtonIndex][1] != "")
			{
			objButton.onclick = LoadPage;
			objButton.strNextPage = g_astrButtons[intButtonIndex][1];
			}

		objButton.intButtonNumber = intButtonIndex;

		with (objButton)
			{
			blnOver = false;
			onmouseover = MouseOver;
			onmouseout = MouseOut;
			with (style)
				{
				left = g_intLeft + "px";
				top = (g_intTop + intButtonIndex * (g_intHeight - 1)) + "px";
				height = g_intHeight + "px";
				width = g_intWidth + "px";
				visibility = "hidden";
				color = g_strColour;
				cursor = "hand";
				}
			}
		}
	}


function IsIE5up()
	{
	var strAgent = navigator.userAgent.toLowerCase();
	var intMajor = parseInt(navigator.appVersion);
	var intMinor = parseFloat(navigator.appVersion);
	var blnIsIe = ((strAgent.indexOf("msie") != -1) && (strAgent.indexOf("opera") == -1));
	var blnIsIe3 = (blnIsIe && (intMajor < 4));
	var blnIsIe4 = (blnIsIe && (intMajor == 4) && (strAgent.indexOf("msie 4")!=-1) );
	var blnIsIe5up  = (blnIsIe && !blnIsIe3 && !blnIsIe4);
	return blnIsIe5up;
	}


function LoadPage()
	{
	self.location = this.strNextPage;
	}


function MouseOver()
	{
	this.blnOver = true;

	if (this.id == g_strBoroughMenu)
		{
		Show()
		}
	else
		{
		this.style.color = g_strOverColour;
		}
	}


function MouseOut()
	{
	this.blnOver = false;
	if (this.intButtonNumber > -1)
		{
		this.style.color = g_strColour;
		}

	setTimeout("CheckIfOver()", g_intTimeOutDelay);
	}


function Show()
	{
	var intButtonIndex;
	for (intButtonIndex = 0; intButtonIndex < g_astrButtons.length; intButtonIndex++)
		{
		eval("document.all.button_" + intButtonIndex + ".style.visibility = 'visible'");
		}
	}


if (IsIE5up())
{
	var g_astrButtons = 
		[ ["City of London","http://www.casweb.org/cityoflondon/"],["City of Westminster","http://www.casweb.org/westminster/"],["London Borough of Camden","http://www.casweb.org/camden/"],["London Borough of Islington","http://www.casweb.org/islington/"],["Royal Borough of Kensington & Chelsea","http://www.casweb.org/rbkc/"] ];

	// positioning for the menu items - uses navigation bar top left as the origin
	var g_intTop = 19;
	var g_intLeft = 401;
	var g_intHeight = 20;
	var g_intWidth = 270;
	
	// normal and mouse over colours for the text
	var g_strColour = "#336699";
	var g_strOverColour = "#ff6600";
	
	// system waits for user's mouse out before checking to see if it's moved away from the menu
	// (gives time for the user to move to another item in the menu & for that mouseover function
	// to be called)
	var g_intTimeOutDelay = 50;
	// id of borough menu link
	var g_strBoroughMenu = "boroughMenu";
	// class for each item in the bar
	var g_strBoroughMenuItem = "boroughMenuItem";
	// id of navigation bar
	var g_strNavigation = "nav";

	Initialize();
	}
