




/* var menuBasePath = "/resources"; */
var menuDepthID = 1;
var menuPIDs = new Array();
var menuInited = 0;
var menuPendingEvent;
var menuPendingEventID;
var menuVisible = new Array();
var menuHysterisis = 200;
var menuIsIE = (navigator.appName == "Microsoft Internet Explorer");
var menuIsOpera = (navigator.appName == "Opera");
var menuTrimConst = (menuIsIE) ? 2 : 0;

/*	Find the offset of a given menu ID in the data array */
function menu_find_idx(id)
{
	for (idx = 0; idx < menuData.length; idx++) {
		if (menuData[idx][0] == id)
			return idx;
	}
	return false;
}
function array_contains(arr, key)
{
	for (acidx = 0; acidx < arr.length; acidx++) {
		if (arr[acidx] == key)
			return true;
	}
	return false;
}

/**
 *	Menu -> HTML generation functions
 */
function menu_write()
{
	var style, lastPID, lastDepth;

	/* Build parent ID list */
	menuPIDs = new Array();
	lastPID = -1;
	lastDepth = 0;
	for (n = 0; n < menuData.length; n++) {
		if (menuData[n][3] != lastPID) {
			/* Check if parent ID already in list */
			foundPID = false;
			for (ap = 0; ap < menuPIDs.length; ap++) {
				if (menuPIDs[ap] == menuData[n][3])
					foundPID = true;
			}
			if (!foundPID && menuData[n][3] != 0)
				menuPIDs[menuPIDs.length] = menuData[n][3];
			lastPID = menuData[n][3];

			parentIdx = menu_find_idx(lastPID);
			if (parentIdx) {
				lastDepth = menuData[parentIdx][6] + 1;
				menuData[parentIdx][5]++;
			}
		}
		menuData[n][6] = lastDepth;
	}

	/* Generate each block of data */
	//html = '<div class="topnavBar" id="topnav0">\n' + menu_write_group(0) + '</div>\n';
	html = '';
	for (pidx = 0; pidx < menuPIDs.length; pidx++) {
		pid = menuPIDs[pidx];
		style = "display: none; position: absolute; left: 20px; top: 20px; " + (menuIsIE ? " width: 1%;" : "");
		html += '<div class="topnavDrop" style="'+style+'" id="topnav'+pid+'"'+
			' onmouseover="menu_g_m_on('+pid+')" onmouseout="menu_g_m_out('+pid+')">\n' +
			menu_write_group(pid) + '</div>\n';
	}
	//ht_pre = '<pre>'+html.replace(/</g, "&lt;").replace(/>/g, "&gt;")+'</pre>';
	document.write(html);
}
function menu_write_group(pID)
{
	var lastID, startPos, cols, id, n, xdata, linkDest;

	lastID = 0;
	startPos = 0;
	cols = new Array();

	cols[0] = '';
	for (n = 0; n < menuData.length; n++) {
		if (menuData[n][3] == pID) {
			/* Split into next column if the IDs are non-sequential */
			if (lastID + 1 != menuData[n][0] && lastID != 0 && menuData[n][3] > 0)
				cols[cols.length] = '';
			lastID = menuData[n][0];

			id = menuData[n][0];
			xdata = (typeof(menuData[n][4]) == "object") ?
				'<img src="'+menuData[n][4][0]+'" width="'+menuData[n][4][1]+'" height="'+
				menuData[n][4][2]+'" border="0" align="top" id="topnavImg'+id+'">'
				: '';
			linkDest = (menuData[n][2].length > 0) ? menuData[n][2] : '#';
			cols[cols.length-1] += '\t<div>' +
				'<a id="topnavItem'+id+'" href="' + linkDest + '"' +
				(menuData[n][5] > 0 ? ' class="topnavArrow"' : '') +
				' onmouseover="menu_i_m_on('+id+')" onmouseout="menu_i_m_out('+id+')">' +
				'<span>' + menuData[n][1] + xdata + '</span></a></div>\n';
		}
	}
	if (cols.length > 1)
		return '<table><tr><td class="c1">' + cols.join('</td><td>') + '</td></tr></table>';
	else
		return cols[0];
}
function menu_init_stats()
{
	menuInited = 1;
}

/**
 *	Visibility control functions
 */

function menu_show(id)
{
	var mh_ix, r_ix, oGroup, oItem, oPGroup;

	if (menuInited == 0)
		menu_init_stats();

	/* Ensure parent nodes are shown */
	mh_ix = menu_find_idx(id);
	if (menuData[mh_ix][3] != 0)
		menu_show(menuData[mh_ix][3]);

	if (array_contains(menuVisible, id) || id == 0)
		return;

	oBannerWrap = document.getElementById("bannerWrapper");
	oBanner = document.getElementById("banner");
	oGroup = document.getElementById("topnav"+id);
	oItem = document.getElementById("topnavItem"+id);

	if (menuData[mh_ix][3] == 0) {
		/* Making this visible means we should cleanup any already exposed nodes */
		for (r_ix = 0; r_ix < menuVisible.length; r_ix++)
			menu_hide(menuVisible[r_ix]);

		/* This is a 2nd-level menu group */
		oItem.className = "mmSelected";
		iTop = oItem.offsetTop + oItem.offsetHeight;
		if (!menuIsOpera) iTop += oBannerWrap.offsetTop;
		oGroup.style.top = iTop + "px";
		oGroup.style.left = (menuData[mh_ix][7] + oBanner.offsetLeft) + "px";
		oGroup.style.display = "block";
		oGroup.style.width = (id == 1) ? "100px " :
			((oGroup.offsetWidth <= oItem.offsetWidth) ?
			oItem.offsetWidth : oGroup.offsetWidth - menuTrimConst) + "px";
		
		if (id == 3) oGroup.style.width = "195px";
		if (id == 4) oGroup.style.width = "120px";
		if (id == 5) oGroup.style.width = "115px"; 
		
		if (document.getElementById("topnavImg"+id)) {
			r_ix = menu_find_idx(id);
			oImg = document.getElementById("topnavImg"+id);
			oImg.src = menuData[r_ix][4][0].replace(/\./, "_on.");
		}
	}
	else {
		/* This is a 3rd-level or deeper menu group */
		oPGroup = oItem.parentNode.parentNode;
		oGroup.style.display = "block";
		oPGroup.style.display = "block";	// must be block to ensure the oPGroup.offset* props are set
		oGroup.style.top = (oItem.parentNode.offsetTop + oPGroup.offsetTop) + "px";
		oGroup.style.left = (oPGroup.offsetLeft + oPGroup.offsetWidth) + "px";
		//oGroup.style.width = oGroup.offsetWidth - menuTrimConst;
		oGroup.style.width = (id == 4001) ? "140px" : 
			((oGroup.offsetWidth <= oItem.offsetWidth) ?
			oItem.offsetWidth : oGroup.offsetWidth - menuTrimConst) + "px";
		oItem.parentNode.className = "mmSelected";
	}

	menuVisible.push(id);
//	document.getElementById("dbg").innerHTML = menuVisible.join(";");
}
function menu_hide(id)
{
	var mh_ix, oGroup, oItem;

	if (!array_contains(menuVisible, id) || id == 0)
		return;

	oGroup = document.getElementById("topnav"+id);
	oItem = document.getElementById("topnavItem"+id);
	menuPendingEventID = 0;

	mh_ix = menu_find_idx(id);
	if (menuData[mh_ix][3] == 0) {
		/* This is a 2nd-level menu group */
		oItem.className = "";
		oGroup.style.display = "none";
		if (document.getElementById("topnavImg"+id)) {
			ix = menu_find_idx(id);
			oImg = document.getElementById("topnavImg"+id);
			oImg.src = menuData[ix][4][0];
		}
	}
	else {
		/* This is a 3rd-level or deeper menu group */
		oGroup.style.display = "none";
		oItem.parentNode.className = "";

		//menuPendingEventID = menuData[mh_ix][3];
		//menuPendingEvent = window.setTimeout("menu_hide("+menuData[mh_ix][3]+")", menuHysterisis);
	}

	/* Pop this menu ID from the visibility list - push it up to the end of the list */
	for (mh_ix = 0; mh_ix < menuVisible.length - 1; mh_ix++) {
		if (menuVisible[mh_ix] == id) {
			menuVisible[mh_ix] = menuVisible[mh_ix+1];
			menuVisible[mh_ix+1] = id;
		}
	}
	menuVisible.pop();
//	document.getElementById("dbg").innerHTML = menuVisible.join(";");

	/* Ensure necessary parent nodes remain shown */
	for (mh_ix = 0; mh_ix < menuVisible.length; mh_ix++)
		menu_show(menuVisible[mh_ix]);
}
function menu_hide_all()
{
	var mh_ix;
	for (mh_ix = 0; mh_ix < menuVisible.length; mh_ix++)
		menu_hide(menuVisible[mh_ix]);
}

/* Item mouse over/out functions */
function menu_i_m_on(id)
{
	var ix, oImg;
	if (document.getElementById("topnav"+id))
		menu_show(id);
	else if (document.getElementById("topnavImg"+id)) {
		r_ix = menu_find_idx(id);
		oImg = document.getElementById("topnavImg"+id);
		if (menuData[r_ix][4][3] == 1)
			oImg.src = menuData[r_ix][4][0].replace(/\./, "_on.");
	}
}
function menu_i_m_out(id)
{
	if (document.getElementById("topnav"+id))
		menu_hide(id);
	else if (document.getElementById("topnavImg"+id)) {
		ix = menu_find_idx(id);
		oImg = document.getElementById("topnavImg"+id);
		if (menuData[r_ix][4][3] == 1)
			oImg.src = menuData[ix][4][0];
	}
}

/* Group mouse over/out functions */
function menu_g_m_on(id)
{
	if (menuPendingEventID == id)
		window.clearTimeout(menuPendingEvent);

	menu_show(id);
}
function menu_g_m_out(id)
{
	menuPendingEventID = id;
	menuPendingEvent = window.setTimeout("menu_hide("+id+")", menuHysterisis);
}


var menuData = [
	// 0=id, 1=title, 2=link_url, 3=parent_id, 4=image_data (src,width,height,is_rollover), 5=child_count, 6=depth, [set on load:] 7=Xcoord

	[2,'About Us','about/firm.asp',0,0,0,0,0],
	[3,'Expertise','expertise/expertise.asp',0,0,0,0,100],
	[4,'Our Team','team/team.asp',0,0,0,0,200],
	[5,'Careers','careers/careers.asp',0,0,0,0,300],
	[6,'Publications','publications/publications.asp',0,0,0,0,400],
	[7,'News & Events','news/newsandevents.asp',0,0,0,0,500],
	[8,'Conntact','contact.asp',0,0,0,0,638],

//	[999,'','',2,['/resources/shim.gif',1,17,0],0,0],

	[2001,'The Firm','about/firm.asp',2,0,0,0],
	[2002,'Our Mission','about/mission.asp',2,0,0,0],
	[2003,'Our Values','about/values.asp',2,0,0,0],
	[2004,'Facts','about/facts.asp',2,0,0,0],
	
	[3001,'Corporate & Commercial','expertise/corporate_commercial.asp',3,0,0,0],
	[3002,'Mergers & Acquisitions/Privatisation','expertise/mergers_acquisitions_privatisation.asp',3,0,0,0],
	[3003,'Real Estate, Projects/PPP','expertise/real_estate_projects_ppp.asp',3,0,0,0],
	[3004,'Banking, Finance & Capital Markets','expertise/banking_finance_capital_markets.asp',3,0,0,0],
	[3005,'IT & Telecommunications','expertise/it_telecommunications.asp',3,0,0,0],
	[3006,'Power, Energy & Natural Resources','expertise/power_energy_natural_resources.asp',3,0,0,0],
	[3007,'Competition','expertise/competition.asp',3,0,0,0],
	[3008,'Employment','expertise/employment.asp',3,0,0,0],
	[3009,'Insurance','expertise/insurance.asp',3,0,0,0],
	[3010,'Litigation & Arbitration','expertise/litigation_arbitration.asp',3,0,0,0],
	[3011,'Intellectual Property & Copyright','expertise/intellectual_property_copyright.asp',3,0,0,0],
	[3012,'Regulatory','expertise/regulatory.asp',3,0,0,0],
				
	[4001,'Partners','team/partn/partners.asp',4,0,0,0],
			[4101,'Ernest Popovici','team/partn/ernest_popovici.asp',4001,0,0,0],
			[4102,'Florian Nitu','team/partn/florian_nitu.asp',4001,0,0,0],
			//[4103,'Sorin Alazaroaie','team/partn/sorin_alazaroaie.asp',4001,0,0,0],
			[4103,'Anca Irena Tudorie','team/partn/anca_irena_tudorie.asp',4001,0,0,0],
			[4104,'Bogdan Constantin Stoica','team/partn/bogdan_c_stoica.asp',4001,0,0,0],
			[4105,'Vlad Neacsu','team/partn/vlad_neacsu.asp',4001,0,0,0],
			[4106,'Valentin Creata','team/partn/valentin_creata.asp',4001,0,0,0],
			[4107,'Silviu Stoica','team/partn/silviu_stoica.asp',4001,0,0,0],
			[4108,'Ciprian Dontu','team/partn/ciprian_dontu.asp',4001,0,0,0],
			[4109,'Alexandru Ambrozie','team/partn/alexandru_ambrozie.asp',4001,0,0,0],
	
	[4002,'Senior Associates','team/senior/senior.asp',4,0,0,0],
			[4201,'Ilinca Stefanescu','team/senior/ilinca_stefanescu.asp',4002,0,0,0],
			[4202,'Cristina Emilia Alexe','team/senior/cristina_emilia_alexe.asp',4002,0,0,0],
			[4203,'Ioana Postelnicu','team/senior/ioana_postelnicu.asp',4002,0,0,0],
			[4204,'Raluca Petrescu','team/senior/raluca_vidru.asp',4002,0,0,0],
			[4205,'Camelia Constantin','team/senior/camelia_constantin.asp',4002,0,0,0],
			[4206,'Serban Patriciu','team/senior/serban_patriciu.asp',4002,0,0,0],
			[4207,'Ioana Dumitru','team/senior/ioana_dumitru.asp',4002,0,0,0],
			[4208,'Ioana Sampek','team/senior/ioana_sampek.asp',4002,0,0,0],
			[4209,'Mihaela Ion','team/senior/mihaela_ion.asp',4002,0,0,0],
			[4210,'Adrian Nica','team/senior/adrian_nica.asp',4002,0,0,0],
			[4211,'Cristian Popescu','team/senior/cristian_popescu.asp',4002,0,0,0],
			[4212,'Ela Marin','team/senior/ela_marin.asp',4002,0,0,0],
			[4213,'Luana Dragomirescu','team/senior/luana_dragomirescu.asp',4002,0,0,0],
			
	[4003,'Associates','team/asoc/asoc.asp',4,0,0,0],
			[4301,'Bianca Chiurtu','team/asoc/bianca_chiurtu.asp',4003,0,0,0],
			[4302,'Codrin Taralunga','team/asoc/codrin_taralunga.asp',4003,0,0,0],
			[4303,'Andreea Grosu','team/asoc/andreea_grosu.asp',4003,0,0,0],
			[4304,'Lavinia Dinoci','team/asoc/lavinia_dinoci.asp',4003,0,0,0],
			[4305,'Mirela Cazacu','team/asoc/mirela_cazacu.asp',4003,0,0,0],
			[4306,'Camelia Patrascu','team/asoc/camelia_patrascu.asp',4003,0,0,0],
			[4307,'Dragos Zorin','team/asoc/dragos_zorin.asp',4003,0,0,0],
			[4308,'Mihaela Savu','team/asoc/mihaela_savu.asp',4003,0,0,0],
			[4309,'Cristina Radu','team/asoc/cristina_radu.asp',4003,0,0,0],
			[4310,'Madalina Panca','team/asoc/madalina_panca.asp',4003,0,0,0],
			[4311,'Andrei Ormenean','team/asoc/andrei_ormenean.asp',4003,0,0,0],
			[4312,'Gabriela Constantin','team/asoc/gabriela_constantin.asp',4003,0,0,0],
			[4313,'Dana Casandra','team/asoc/dana_casandra.asp',4003,0,0,0],
			[4314,'Mihaela Paraschiv','team/asoc/mihaela_paraschiv.asp',4003,0,0,0],
			[4315,'Andreea Hulub','team/asoc/andreea_hulub.asp',4003,0,0,0],
			[4316,'Cristian Dranca','team/asoc/cristian_dranca.asp',4003,0,0,0],

					
	/*
	[5001,'Student internship','careers/student_intern.asp',5,0,0,0],
	[5002,'Available positions','careers/available.asp',5,0,0,0],	
	[5003,'Support staff','careers/support.asp',5,0,0,0],
	[5004,'Our values','about/values.asp',5,0,0,0],
	*/
	
	[6001,'Legal Update','publications/legalupd.asp',6,0,0,0],
	[6002,'Articles','publications/articles.asp',6,0,0,0],
	
	[7001,'News','news/news.asp',7,0,0,0],
	[7002,'Press Releases','news/press.asp',7,0,0,0],
	[7003,'Press Reviews','news/reviews.asp',7,0,0,0]
	
];

/* Create menu structure */
menu_write();

