//Changes the image source for the mouse over of the links
function ChangeImage(number,no) 
{
	if (document.images) {
		document[menuitems[number][0]].src= menuitems[number][no];
   	}
}
	

function buildmenu()
{
	var i;		//loop counter
	var linkval;	//http link value
	var imgsrc;	//image source
	var targetval;	//target for link
	var textval;	//text for link/header
	var menulen;	//menu lenght

	//Write the start of the menu table
	document.write('<table cellpadding="0" cellspacing="5" width="150" border="0">');
	menulen = menuitems.length;
	//Write the menu items
	for(i=0;i<menulen;i++) 
	{
		document.write('<tr>');
		//Check the values passed in and record them
		if (!menuitems[i][0]) nameval="oops"
		else nameval = menuitems[i][0]
		if (!menuitems[i][1]) linkval = "none"
		else linkval = menuitems[i][1]
		if (!menuitems[i][2]) imgsrc = "none"
		else imgsrc = menuitems[i][2]
		if (!menuitems[i][3]) imgsrc2="none"
		else imgsrc2=menuitems[i][3]
		if (!menuitems[i][4]) targetval="_top"
		else targetval=menuitems[i][4]
		
		if(linkval == "none")
		{
			//If there is no link specified then it is a title so print the correct information
			document.write('<td colspan="2" bgcolor="' + titleCol + '"' +
				' ALIGN="'+ titleAlign + '"' +
				' VALIGN="' + titleVAlign + '"' +
				' WIDTH="' + menuWidth + '">' );
			if (imgsrc == "none")
			{
				document.write('<FONT face="' + titleFontFace + '"' +
					' Size="' + titleFontSize + '"' +
					' COLOR="' + titleFontCol + '">' +
					'<B>' + nameval + '</B></FONT></TD>');
			}
			else
			{
				document.write('<img src="' + imgsrc + '"' +
					' alt="' + nameval + '" border="0"></td>' );
			}
		}
		else 
		{
			//Write the menu item delimiter
			document.write('<td bgcolor="' + delimCol + '"' +
				' ALIGN ="' + delimAlign + '"' +
				' VALIGN = "' + delimValign + '">');
			document.write('<img src="' + delimGIF + '"' +
					' alt="*" border="0">');
			document.write ("</td>");

			//Write the menu items
			document.write('<td background="'+ linkbgimage + '"' +
				' ALIGN="'+ linkAlign + '"' +
				' VALIGN="' + linkVAlign + '"' +
				' WIDTH="' + menuWidth2 + '">' +
				'<FONT face="' + linkFontFace + '"' +
				' Size="' + linkFontSize + '"' +
				//' COLOR="' + linkFontCol + '"' +
				'><A HREF="' + linkval + '"' + 
				' target="' + targetval + '"' );
			if (imgsrc2 != "none")
			{
				document.write(' onmouseover=ChangeImage(' + i + ',3)' +
					' onmouseout=ChangeImage(' + i + ',2)');		
			}
			document.write('>');
			if (imgsrc == "none") document.write ('<b>'+nameval+'</b></a></td>');
			else
			{
				document.write('<img src="' + imgsrc + '"' +
					' alt="' + nameval + '" border="0"' +
					' name="' + nameval + '"' +
					'</a></td>');
			}
		}
		document.write("</tr>");
	}
	document.write("</table>");
}
