/*	This function loops through the information stored in the text file to 
	add items to the menu. Copyright Andrew Lawton 2008.	*/



//begin the normal code to read through an array

var x;

for (x in menu_items)
{

// This part of the code checks to see if the first item in the array is a heading. If it 
// is a heading then it will be displayed without a preceding linebreak.

if (menu_items[x][1] == "" && x == 0)
{
document.write ("<b class='menu'>" + menu_items[x][0] + ":</b><br>");
}


// This part of the code ignores the first item regardless of whether it is a link or a 
// heading. All subsequent headings will be displayed with a preceding linebreak.

if (menu_items[x][1] == "" && x != 0)
{
document.write ("<br><b class='menu'>" + menu_items[x][0] + ":</b><br>");
}


// if an item is not a header then it is a link! Note the id is inserted. This is so that
// the focus can be set on the active link on page open! ;-)

if (menu_items[x][1] != "")
{
var me = menu_items[x][1];

document.write ('<a id="' + menu_items[x][1] + '" href=');
document.write (me + ' target="main">');
document.write (menu_items[x][0] + '</a><br>');
}


// close the orignial 'for' task.
}


// To set the focus on the first link:
// select the first link from the array and store its value.

var y = 0

while (menu_items[y][1] == "") 
{
    y++;
  
var activelink = menu_items[y][1];
}

// Then set the focus using the value that is stored 
document.getElementById(activelink).focus();

