function ams_build_menu(menu)
{
var mlen = menu.length;
var menu_spacer = 100; 
outputHTML = "";

for(i=0;i<mlen;i++)
	{
	var smlen = menu[i].length;
	var ams_clip_height = (smlen * ams_menu_cell_height) + 25;
	var ams_id = "dd_" + idnum
	var menu_body = "<div id='"+ ams_id +"' style='position:absolute;left:"+ ams_left +";top:"+ ams_top +";width:"+ ams_menu_width +";height:"+ ams_clip_height +";clip: rect(0px, "+ ams_menu_width +"px, "+ ams_menu_cell_height +"px, 0px);' onmouseover='change_clip("+ ams_id +",0,"+ ams_menu_width +","+ ams_clip_height +",0);' onmouseout='change_clip("+ ams_id +",0,"+ ams_menu_width +","+ ams_menu_cell_height +",0);'><table cellspacing='0'>";
	menu_body += "<tr><td height='"+ ams_menu_cell_height +"' style='cursor:pointer;font-family:"+ ams_heading_font_family +";font-size:"+ ams_heading_font_size +";font-weight:"+ ams_heading_font_weight +";color:"+ ams_menu_text1_color +";'>" + menu[i][0][1] +"</td></tr>";
	for(j=1;j<smlen;j++)
		{
		menu_body += "<tr><td onclick=\"document.location='"+ menu[i][j][0] +"'\" onmouseover=\"change_color(this,'"+ ams_menu_highlight_color +"','"+ ams_menu_text2_color +"')\" onmouseout=\"change_color(this,'"+ ams_menu_background_color +"','"+ ams_menu_text1_color +"')\" width='"+ ams_menu_width +"' height='"+ ams_menu_cell_height +"' style='border-bottom:#005C00 2px solid;cursor:pointer;font-family:"+ ams_font_family +";font-size:"+ ams_font_size +";font-weight:"+ ams_font_weight +";background-color:"+ ams_menu_background_color +";color:"+ ams_menu_text1_color +";filter:alpha(opacity=90);'>"+ menu[i][j][1] +"</td></tr>";
		}
	menu_body += "</table></div>";
	outputHTML += menu_body;
	ams_left = ams_left + ams_horizontal_spacer;
	ams_top = ams_top + ams_vertical_spacer;
	idnum++;
	}
//alert(outputHTML);
return outputHTML;
}



function change_clip(div_name,nt,nr,nb,nl)
/* 
THIS FUNCTION CHANGES THE VALUES OF A DIVS CLIP VARIABLE. 
USED TO TOGGLE THE MENUS UP AND DOWN
*/
{
div_name.style.clip = "rect("+ nt +"px, "+ nr +"px, "+ nb +"px, "+ nl +"px)" ;
}

function change_color(elem,col,col2)
/*
THIS FUNCTION CHANGES THE BACKGROUND AND FORGROUND COLOURS FOR AN ELEMENT.
USED IN DROP DOWN MENU
*/
{
elem.style.backgroundColor = col;
elem.style.color = col2;

}
