var maxZ = 100;
menustr = "";
var menucontainer = document.createElement("DIV");
function initmen()
{
	

	var appnames = new Array();
	var applinks = new Array();
	
	appnames[0] = "role of an approved inspector";
	applinks[0] = "roaai.html";
	appnames[1] = "latest legislation";
	applinks[1] = "latestleg.php";
	appnames[2] = "current legislation";
	applinks[2] = "currleg.php";
	appnames[3] = "your questions answered";
	applinks[3] = "qanda.php";
	
	createmenulink(135, 120, 50, "appmenu", "approved inspector?", "roaai.html");

	var aboutnames = new Array();
	var aboutlinks = new Array();
	aboutnames[0] = "about BRCS";
	aboutlinks[0] = "about.html";
	aboutnames[1] = "professional services";
	aboutlinks[1] = "services.html";
	aboutnames[2] = "our personnel";
	aboutlinks[2] = "personnel.html";
	aboutnames[3] = "recruitment";
	aboutlinks[3] = "recruitment.html";

	createmenulink(110, 271, 50, "aboutmenu", "company profile", "about.html");

	createmenulink(70, 396, 50, "newsmenu", "newsletter", "newsletter.php");
	
	var projnames = new Array();
	var projlinks = new Array();
	projnames[0] = "retail";
	projlinks[0] = "profiles/retail.html"
	projnames[1] = "office";
	projlinks[1] = "profiles/office.html"
	projnames[2] = "hotel/leisure";
	projlinks[2] = "profiles/hotelleisure.html"
	projnames[3] = "education";
	projlinks[3] = "profiles/education.html"
	projnames[4] = "health";
	projlinks[4] = "profiles/health.html"
	projnames[5] = "crown";
	projlinks[5] = "profiles/crown.html"
	projnames[6] = "commercial";
	projlinks[6] = "profiles/commercial.html"
	projnames[7] = "residential";
	projlinks[7] = "profiles/residential.html"



	createmenulink(105, 482, 50, "projmenu", "project profiles", "profiles/retail.html");
	
	createmenulink(40, 602, 50, "formenu", "forum", "messageboard.php");

	var lnksnames = new Array();
	var lnkslinks = new Array();
	lnksnames[0] = "links";
	lnkslinks[0] = "links.php";
	lnksnames[1] = "downloads";	
	lnkslinks[1] = "downloads.html";
	
	createmenulink(30, 658, 50, "lnksmenu", "links", "links.php");
	
	createmenulink(50, 703, 50, "sitemenu", "sitemap", "sitemap.html");

	var esubnames = new Array();
	var esublinks = new Array();
	esubnames[0] = "fee quote";
	esublinks[0] = "feequote.html";
	esubnames[1] = "submit";
	esublinks[1] = "submit.html";
	
	createmenulink(90, 769, 50, "esubmenu", "e-submission", "submit.html");


	var contnames = new Array();
	var contlinks = new Array();
	contnames[0] = "contact details";
	contlinks[0] = "contact.html";
	contnames[1] = "Locations";
	contlinks[1] = "locations.html";
	
	createmenulink(50, 874, 50, "contmenu", "contact", "contact.html");


	menucontainer.setAttribute("id", "menucon");
	menucontainer.setAttribute("valign", "bottom");
	//document.body.appendChild(menucontainer);
}

function showmenu(mentoshow)
{
		close_menus();
		var men = document.getElementById(mentoshow);
		var tmen = document.getElementById(mentoshow + "title");
		men.style.visibility = "visible";
		//men.style.zIndex = (maxZ+2);
		//tmen.style.zIndex = (maxZ+2);
		//tmen.style.border = "1px solid black";
		men.style.border = "1px solid black";
		tmen.style.color = "#6666ff";
		maxZ++;

}

function hidemenu(mentoshow)
{
	var men = document.getElementById(mentoshow);
	var tmen = document.getElementById(mentoshow + "title");
	men.style.visibility = "hidden";
	men.style.border = "none";
	tmen.style.border="none"
	tmen.style.color = "#777777";
	men.style.zIndex = "-1";

}

function createmenu(twdth, bwdth, menl, ment, menid, mentitle, lnk_names_arr, lnk_href_arr)
{
	var titlehtmlstr = '<div align="center" valign="bottom" class="menutitle" id="' + menid + 'title" onMouseover="showmenu(\'' + menid + '\')"><a href="#">' + mentitle + '</a></div>';
	var bodyhtmlstr = '<span class="menu" id="' + menid + '" onMouseleave="hidemenu(\'' + menid + '\')">';
	if (lnk_names_arr.length != lnk_href_arr.length)
	{
		alert("Fatal Error: name and array lengths are different.\r Menu creation aborted");
	}
	else
	{
		for (n=0; n<lnk_names_arr.length; n++)
		{
			bodyhtmlstr += '<a href="./' + lnk_href_arr[n] + '">' + lnk_names_arr[n] + '</a><br>';
		}
		bodyhtmlstr += '</span>';
		var titleel = document.createElement("SPAN");
		titleel.style.position = "absolute";
		titleel.style.left = menl;
		titleel.style.top = ment;
		titleel.style.visibility = "visible";
		titleel.innerHTML = titlehtmlstr;



		var bodyel = document.createElement("SPAN");
		bodyel.style.position = "absolute";
		bodyel.style.top = 20;
		bodyel.style.left = 0;
		bodyel.innerHTML = bodyhtmlstr;


		titleel.appendChild(bodyel);
		document.body.appendChild(titleel);
		menustr += menid + "|";
	}
}


function close_menus()
{
	var tmparr = menustr.split("|");
	var tmpel;
	for(n=0; n<tmparr.length-1; n++)
	{
		hidemenu(tmparr[n]);

	}
}

function createmenulink(twdth, menl, ment, menid, mentitle, mendest)
{
	var titlehtmlstr = '<div valign="bottom" align="center" class="menutitle" id="' + menid + 'title" onMouseover="this.style.color=\'#6666ff\'; close_menus()" onMouseout="this.style.color=\'#777777\'"><a href="./' + mendest + '">' + mentitle + '</a></div>';
	var titleel = document.createElement("SPAN");
	titleel.style.position = "absolute";
	titleel.style.left = menl;
	titleel.style.top = ment;
	titleel.style.visibility = "visible";
	titleel.innerHTML = titlehtmlstr;
	document.body.appendChild(titleel);
}

document.onclick=new Function("close_menus()")

