
	//these variables have to be declared on individual page
	//please take this numbers from menu arrays, arrays starts from 0
	//var current_active_menu;
	//var current_active_item;
	
	var uagent = navigator.userAgent.toLowerCase();
	function getVer(aname,sp) {
		return parseFloat(uagent.substring(uagent.indexOf(sp, uagent.indexOf(aname))+1))	
	}

	var navVersion = 0;

	var isExp=uagent.indexOf('msie')!=-1;
	if (isExp) navVersion = getVer('msie', ' ');

	var isNS=uagent.indexOf('netscape')!=-1;
	if (isNS) navVersion = getVer('netscape', '/');

	var platform = "undef";
	if (uagent.indexOf('win')!=-1) platform = "win";
	if (uagent.indexOf('mac')!=-1) platform = "mac";

	var active_menu;
	var timeout_array = new Array(4);

	function setStyles() {
		if(isExp && platform == "win"){
			document.write("<link rel='stylesheet' href='/Web/ie.css' type='text/css'>");
		}
		else{
			document.write("<link rel='stylesheet' href='/Web/nie.css' type='text/css'>");
		}
	}
	
	function Button(title,location,menu,width) {
		this.title = title;
		this.location = location;
		this.menu = menu;
		this.width = width; // for ie 4.0 and mac ie
	}

	function Item(title,location,indent) {
		this.title = title;
		this.location = location;
		this.indent = indent; //0,1
	}

	var menu = new Array(
		new Button("ABOUT FTI", "/web/about", 
			new Array(	new Item("Who we are", "/web/about/who_we_are.aspx", 0), 
						new Item("What we do", "/web/about/what_we_do.aspx", 0), 
						new Item("History/Timeline", "/web/about/history.aspx", 0), 
						new Item("Management", "/web/about/management.aspx", 0), 
						new Item("Governance", "/web/about/corporate_governance.aspx", 0), 
						new Item("News<span style='padding-left: 4px; padding-right: 4px'>&amp;</span>Events", "/web/news/default.aspx", 0), 
						new Item("Locations", "/web/about/locations.aspx", 0), 
						new Item("Careers", "/web/about/careers.aspx", 0)), 100),
		new Button("SERVICES", "/web/services/default.aspx", null, 180),
		new Button("PROFESSIONALS", "/web/professionals/default.aspx", null, 80),
		new Button("INVESTOR RELATIONS", "/web/investor_relations.aspx", null, 130),
		new Button("RESOURCES", "/web/resources/default.aspx", null, 70)
	);


	function get_object(name) {
		if (document.all) {
			return document.all[name];
		} else {
			return document.getElementById(name);
		}
	}

	function change_style(index) {
		for ( i = 0; i < document.styleSheets.length; i++ )
		{
			if ( i != index ) document.styleSheets(i).disabled = true;
		}
		document.styleSheets(index).disabled = false;
	}

	function getPageOffsetLeft(el)	{
		return el.offsetParent != null ? el.offsetLeft + getPageOffsetLeft(el.offsetParent) : el.offsetLeft;
	} 

	function getPageOffsetTop(el)	{
		return el.offsetParent != null ? el.offsetTop + getPageOffsetTop(el.offsetParent) : el.offsetTop;
	} 

	function getElOffsetLeft(el)	{
		return isExp ? el.offsetParent.clientLeft + getPageOffsetLeft(el) : getPageOffsetLeft(el);
	} 

	function getElOffsetTop(el)	{
		return isExp ? el.offsetParent.clientTop + getPageOffsetTop(el) : getPageOffsetTop(el);
	} 

	function activate(i) {
			
		if (timeout_array[i] != null) clearTimeout(timeout_array[i]);

		if (active_menu != null && active_menu != i) do_hide(active_menu);
				
		var m = get_object("m" + i);
		var b = get_object("b" + i);
		var sml = get_object("subMenuLine");

		var x, y;

		x = getPageOffsetLeft(b);
		y = getPageOffsetTop(sml);
		if (isExp) {
			if (!(isExp && platform == "mac")) {
				x += b.offsetParent.clientLeft; 
				y += sml.offsetParent.clientTop; 
			}
		} 

		if (current_active_menu != i) {
			b.className = 'menuButtonActive';	
		}
			
		if (isExp)
			b.style.cursor = "hand";
		else
			b.style.cursor = "pointer";

		if (m != null) {
			m.style.left = x + "px";
			m.style.top = (y + 1) + "px"; 
			m.style.visibility ="visible";
			if (isExp)
				m.style.cursor = "hand";
			else
				m.style.cursor = "pointer";
		}
			
		active_menu = i;
	}
	
	function deactivate(i) {
		if (timeout_array[i] != null) clearTimeout(timeout_array[i]);
		timeout_array[i] = setTimeout("do_hide(" + i + ")", 200);
	}

	function do_hide(i) {
		if (current_active_menu != i) get_object("b" + i).className = 'menuButton';
		var m = get_object("m" + i);

		if (m != null) m.style.visibility ="hidden";

		if (active_menu == i) active_menu = null;
	}

	function activate_item(o,i,j) {
		if (!(current_active_menu == i && current_active_item == j)) o.className = 'menuItemActive';
	}


	function deactivate_item(o,i,j) {
		if (!(current_active_menu == i && current_active_item == j)) o.className = 'menuItem';
	}


	function print_menu() {
		for (var i = 0; i < menu.length; i++) {
		
			document.writeln('<td nowrap align="left" onmouseover="activate(' + i + ');" onmouseout="deactivate(' + i + ');">');
			if (current_active_menu == i)
				document.writeln('<div class="menuButtonActive">');
			else
				document.writeln('<div class="menuButton">');				

			if (i == menu.length - 1) {
				document.writeln('<div id="b' + i + '" style="padding: 0px 8px 0px 0px;margin-right: 4px;" onclick="location.href=\'' + menu[i].location + '\'">');
			} else {
				if (!isExp && !isNS)			
					document.writeln('<div id="b' + i + '" onclick="location.href=\'' + menu[i].location + '\'">');
				else
					document.writeln('<div id="b' + i + '" style="padding: 0px 8px 0px 0px;margin-right: 4px;" onclick="location.href=\'' + menu[i].location + '\'">');
			}
				
			document.writeln('<a href="' + menu[i].location + '">' + menu[i].title + '</a>');
			document.writeln('</div>');
			document.writeln('</div>');
			document.writeln('</td>');

		}
	}

	function print_submenu() {
		if (!(isExp && platform == "win")) return;
		
		for (var i = 0; i < menu.length; i++) {
			if (menu[i].menu != null) {
				document.writeln('<div id="m' + i + '" class="subMenu" onmouseover="activate(' + i + ');" onmouseout="deactivate(' + i + ');">');
				for (var j = 0; j < menu[i].menu.length; j++) {	
					if (current_active_menu == i && current_active_item == j)	
						document.writeln('<div class="menuItemActive" onmouseover="activate_item(this,' + i + ',' + j + ');" onmouseout="deactivate_item(this,' + i + ',' + j + ');" onclick="location.href=\'' + menu[i].menu[j].location + '\'">');
					else						
						document.writeln('<div class="menuItem" onmouseover="activate_item(this,' + i + ',' + j + ');" onmouseout="deactivate_item(this,' + i + ',' + j + ');" onclick="location.href=\'' + menu[i].menu[j].location + '\'">');
					document.writeln('<div id="w' + i + "" + j + '" style="padding: 4px 8px 4px ' + ((menu[i].menu[j].indent + 1) * 8) + 'px;">');
					document.writeln('<a href="' + menu[i].menu[j].location + '">' + menu[i].menu[j].title + '</a>');
					document.writeln('</div>');
					document.writeln('</div>');
				}
				document.writeln('</div>');
				//fixing sizes/position here
				get_object("m" + i).style.top = (getElOffsetTop(get_object("subMenuLine")) + 1) + "px"; 
				if (isExp) {
						for (j = 0; j < menu[i].menu.length; j++) {
							if (platform == "win" && navVersion >= 5)
								get_object("w" + i + "" + j).style.width = (get_object("m" + i).offsetWidth - 2) + "px";
						}
						if (!(platform == "win" && navVersion >= 5))
							get_object("m" + i).style.width = menu[i].width + "px";
				}
			}
		}
	}

	function openWindow(URL, features) {
		winA = window.open(URL, "_blank", features);
	}
