//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 imgsrc1;	//image source
	var imgsrc2;	//second image source
	var targetval;	//target for link
	var textval;	//text for link/header
	var menulen;	//menu length
	var nameval;
	var div_name;	//name of the layer
	var new_none;
	var temp_str;
	var apost;
	var debug;
	var temp_str2;
	
	new_none = "'none'";
	apost = "'";

	//Write the start of the menu table
	document.write('<table cellpadding="0" cellspacing="5" width="'+ menuWidth +'" 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 (!menuitems[i][12]) div_name="none"
//		else div_name=menuitems[i][12]
		if (!menuitems_dyn[i][0]) nameval="oops"
		else nameval = menuitems_dyn[i][0]
		if (!menuitems_dyn[i][1]) linkval = "none"
		else linkval = menuitems_dyn[i][1]
		if (!menuitems_dyn[i][2]) imgsrc = "none"
		else imgsrc = menuitems_dyn[i][2]
		if (!menuitems_dyn[i][3]) imgsrc2="none"
		else imgsrc2=menuitems_dyn[i][3]
		if (!menuitems_dyn[i][4]) targetval="_top"
		else targetval=menuitems_dyn[i][4]
		if (!menuitems_dyn[i][12]) div_name="none"
		else div_name=menuitems_dyn[i][12]
		//div_name = "none";

		if(linkval == "none")
		{
			//If there is no link specified then it is a title so print the correct information
			document.write('<td bgcolor="' + titleCol + '"' +
				' ALIGN="'+ titleAlign + '"' +
				' VALIGN="' + titleVAlign + '"' +
				' WIDTH="' + menuWidth + '">' );
			document.write('<FONT face="' + titleFontFace + '"' +
					' Size="' + titleFontSize + '"' +
					' COLOR="' + titleFontCol + '">' +
					'<B>' + nameval + '</B></FONT></TD>');
		}
		else 
		{
			//Write the menu items
			document.write('<td background="'+ linkbgimage + '"' +
				' ALIGN="'+ linkAlign + '"' +
				' VALIGN="' + linkVAlign + '"' +
				' WIDTH="' + menuWidth + '">' +
				'<FONT face="' + linkFontFace + '"' +
				' Size="' + linkFontSize + '"' + '>');
				if (div_name == "none")//or(piccies==false)
				{
					//no layer information hence just a normal link
					temp_str = '<a href="' + linkval + '">';
					document.write(temp_str);						
				}
				else
				{
					//use the layer information
					if (is_NS4)
					{
						temp_str = '<a href="' + linkval + '">';
					}
					else
					{
						temp_str = '<a href="' + linkval + '"';
						temp_str = temp_str  + 'onMouseOut="HideLayerChangeBut(' ;
						temp_str = temp_str + apost + div_name + apost + ',' + new_none + ')"';
						temp_str = temp_str  +' onMouseOver="ShowLayerChangeBut(' ;
						temp_str = temp_str + apost + div_name + apost +',';
						temp_str = temp_str + new_none + ',' + new_none + ',1)"';
						temp_str = temp_str + '>';
					}
					document.write(temp_str);
				}			
			document.write ('<b>'+nameval+'</b></a></td>');
		}
		document.write("</tr>");
	}
	document.write("</table>");
}
