// Ornibus Ltd 09/05/05
// MENU SYSTEM JAVA SCRIPT
// This is a java script menu system. It uses functions to build a menu system up that is easy to change or modify
// It also checks for different browsers and adjusts the positioning to accomodate the differences in browsers.
// A menu system is created/built up and then positioned relatively to an existing object. This is done upon load and resize events.


// Browser detection
var browser = navigator.appName;
if (navigator.userAgent.toLowerCase().indexOf("opera")>=0) browser = "Opera";
var platform = "pc";
var whichStyle = "pc_ie";
is = new BrowserCheck();
function BrowserCheck() {
if (navigator.appVersion.toLowerCase().indexOf('mac')>=0) {
platform = "mac";
this.mac = true;
}
else this.pc = true;
this.platform = platform;
var vers = parseInt(navigator.appVersion);
this.vers = vers;
this.browser = browser;
switch (browser) {
case "Microsoft Internet Explorer":
this.ie = true;
browser_base = "ie";
browser_family = "ie3";
whichStyle = "pc_ie";
if (vers <= 3) {
browser_vers = "ie3.0";
this.ie3 = true;
}
if (vers >= 4)	{
browser_family = "ie5";
browser_vers = "ie5.0";
if (navigator.userAgent.toLowerCase().indexOf('msie 4')>=0) {
this.ie4 = true;
browser_vers = "ie4.0";
}
if (navigator.userAgent.toLowerCase().indexOf('msie 5.0')>=0) {
this.ie5 = true;
this.vers = 5;
browser_vers = "ie5.0";
}
if (navigator.userAgent.toLowerCase().indexOf('msie 5.5')>=0) {
this.ie5 = true;
this.vers = 5;
browser_vers = "ie5.5";
}
if (navigator.userAgent.toLowerCase().indexOf('msie 6')>=0) {
this.ie5 = true;
this.vers = 5;
this.ie6 = true;
browser_vers = "ie6.0";
}
browser_family = browser_vers.substr(0,3);
}
break;
case "Netscape":
this.ns = true;
browser_base = "ns";
whichStyle = "pc_ns";
if (vers <= 3)	{
this.ns3 = true;
browser_family = "ns3";
browser_vers = "ns3.0";
}
if (vers == 4)	{
this.ns4 = true;
browser_vers = "ns4.0";
browser_family = "ns4";
if (navigator.userAgent.toLowerCase().indexOf('mozilla/4')>=0) browser_vers = "ns4.0";
if (navigator.userAgent.toLowerCase().indexOf('mozilla/4.7')>=0) browser_vers = "ns4.7";
}
if (vers >= 5)	{
this.ns5 = true;
this.ns6 = true;
browser_vers = "ns6.0";
browser_family = "ns6";
whichStyle = "pc_ie";
if (navigator.userAgent.toLowerCase().indexOf('netscape6')>=0) browser_vers = "ns6.0";
if (navigator.userAgent.toLowerCase().indexOf('netscape6/6.1')>=0) browser_vers = "ns6.1";
if (navigator.userAgent.toLowerCase().indexOf('netscape6/6.2')>=0) browser_vers = "ns6.2";
}
break;
case "Opera":
this.op = true;
if (navigator.userAgent.toLowerCase().indexOf("opera/5")>=0) {
browser_base = "op";
browser_family = "op5";
browser_vers = "op5.0";
whichStyle = "pc_ns";
}
else {
browser_base = "op";
browser_family = "op6";
browser_vers = "op6.0";
whichStyle = "pc_ie";
}
break;
default:
browser_base = "uk";
browser_vers = "uk5";
whichStyle = "pc_ie";
break;
}
}
if (platform == "mac") {
if (browser_family == "ns6") whichStyle="mac_ns";
else whichStyle="mac_ie";
}

// Function getElm()

function getElm(id){
if (document.layers) return document.layers[id];
else if (document.all) return document.all[id];
else return document.getElementById(id);
}

// Global vars

var cssClassSwap = "strat_colour3";
var HEADING=1;
var HEADINGLINK=2;
var SUBHEADING=3;
var LINK=4;
var TERTLINK=5;
var FINALARRAYELEMENT=6;
var LOGINBOX=7;
var button_delay;
var browser=navigator.appName;
var j=0;
var retrieve_count=0;
var lhcount=0;
var lhmenu=new Array(0);
var qstring_arr=new Array(0);
var forceclick="no";
var heading_link;
var subheading_link;
var highlight_subheading;
var headinglink_link;
var selected_array_pos;
var selected_pos_text;
var highlight_selected_pos;
var elmt_selected=-1;
var item_selected=-1;
var linkfound=false;
var queryfound=false;
var nav_space=0; //177
var iframewrite=true;
var macinitialload=false;
var strmac;
var menuTitle;

// for IE browser

if (browser_vers=="ie5.0" || browser_vers=="op6.0") iframewrite=false;
document.write('<div id="menu2" style="z-index: 999; visibility: visible;"></div>');

// Function menuTitle()

function menuTitle(txt)
{
    menuTitle = txt;
}

// Function menuItem()
// This function takes recieves the data and data type details for each menu item, be it a link, header, sublink... and where it links to or what it displays.

function menuItem(type,parid,id,text,link)
{
if (type==FINALARRAYELEMENT) return;
var item=new Item(type,parid,id,text,link);
lhmenu[lhcount]=item;
if (lhmenu[lhcount].id==document.nav_form.pageid.value && linkfound==false)
{ var prim="prim";
var sec="sec";
getQueryValue(prim);
qstring_arr[0]=string_arr[i].toUpperCase();
getQueryValue(sec);
if (string_arr[i]!="not found") qstring_arr[1]=string_arr[i].toUpperCase();
var exitloop=false;
selected_array_pos=lhcount;
highlight_selected_pos=selected_array_pos;
selected_pos_text=lhmenu[highlight_selected_pos].text;
var menutype=lhmenu[lhcount].type;
if (queryfound==true)
{	if (menutype==LINK) find_secondary();
if (menutype==TERTLINK)
{	find_tertiary();
find_secondary();
}
if (menutype==HEADINGLINK) find_headinglink(menutype);
}
else no_querylink(menutype);
}
lhcount+=1;
return;
}


function find_headinglink(menutype)
{	if (menutype==HEADINGLINK && lhmenu[lhcount].parid==qstring_arr[0])
{	headinglink_link=lhmenu[lhcount].text;
linkfound=true;
}
}
function no_querylink(menutype)
{	for (retrieve_count=lhcount; retrieve_count>=0; retrieve_count--)
{
if (menutype==LINK && lhmenu[retrieve_count].type==HEADING)
{ elmt_selected=retrieve_count;
heading_link=lhmenu[retrieve_count].text;
linkfound=true;
break;
}
if (menutype==TERTLINK && lhmenu[retrieve_count].type==SUBHEADING)
{	subheading_link=lhmenu[retrieve_count].text;
highlight_subheading=subheading_link;
for (retrieve_count=retrieve_count; retrieve_count>=0; retrieve_count--)
{	if (lhmenu[retrieve_count].type==HEADING)
{	elmt_selected=retrieve_count;
heading_link=lhmenu[retrieve_count].text;
linkfound=true;
exitloop=true;
break;
}
}
if (exitloop==true) break;
}
if (menutype==HEADINGLINK && lhmenu[retrieve_count].type==HEADINGLINK)
{	headinglink_link=lhmenu[retrieve_count].text;
linkfound=true;
break;
}
}
}
function Item(type,parid,id,text,link)
{	this.type=type;
this.parid=parid;
this.id=id;
this.text=text;
this.link=link;
}
function writeVerneNav(layerName, str)
{
	
if (str == "") return;

if (typeof getElm(layerName) == "undefined") return;

if (document.getElementById||document.all)
{
if (typeof getElm(layerName) != "undefined") getElm(layerName).innerHTML=str;
if (browser_vers=="op6.0") document.getElementById(layerName).innerHTML=str;
}
else if (document.layers)
{	getElm(layerName).document.open();
getElm(layerName).document.writeln(str);
getElm(layerName).document.close();
}
var DivMenu=document.getElementById('menu2');
if (iframewrite) var IfrMenu=document.getElementById('DivTert');
if (navigator.appName=="Netscape")
{	if (DivMenu.style.display=="none") DivMenu.style.display="block";
else if (DivMenu.style.display=="block") DivMenu.style.display="none";
}
else
{	if (document.getElementById("menu2").style.display=="none")
{	DivMenu.style.display="block";
}
}
}
function createMenu()

{cssClassSwap = "strat_colour3";
	if (browser=="Netscape")
{	nav_space=182;
str='<table width="221" border="0" cellpadding="0" cellspacing="0">';
}
else str='<table width="221" border="0"  cellpadding="0" cellspacing="0">';
menulen=lhmenu.length;

str+='<tr><td height="15" valign="middle" class="strat_colour_head">' + menuTitle + '' + 
'</tr></td>';

showItems=false;
subMenu=false;
prevHeading=false;
ypos=0;
for (lhcount=0; lhcount<menulen; lhcount++)
{
if ((lhmenu[lhcount].type==HEADING) || (lhmenu[lhcount].type==HEADING && lhmenu[lhcount].text==heading_link))
{
if ((lhcount==elmt_selected) || (lhmenu[lhcount].text==heading_link))
{	arrow="d";
menulink="Close";
showItems=true;
}
else
{	arrow="l";
menulink="Open";
showItems=false;
}
submenu=false;
if (cssClassSwap=="strat_colour2")
    cssClassSwap="strat_colour3";
else
    cssClassSwap="strat_colour2";
 
hreflink='<a href="javascript:void(0);" class="left_column grey_link" onClick="javascript:menu'+menulink+'('+lhcount+');return false;">';
str+='<tr class='+cssClassSwap+' height="15" valign="middle" onmouseover="this.className=\''+cssClassSwap+'\'" onmouseout="this.className=\''+cssClassSwap+'\'"><td height="15" valign="middle" class="'+cssClassSwap+'">'+hreflink+lhmenu[lhcount].text+'</a></td></tr>';
ypos=ypos+24;
prevHeading=true;
}
else if ((lhmenu[lhcount].type==HEADINGLINK) || (lhmenu[lhcount].type==HEADINGLINK && lhmenu[lhcount].text==headinglink_link))
{
if (cssClassSwap=="strat_colour2")
    cssClassSwap="strat_colour3";
else
    cssClassSwap="strat_colour2";
hreflink='<a href="javascript:findlink('+lhcount+')" class="left_column grey_link" onClick="linkto('+lhcount+')">';
str+='<tr class="'+cssClassSwap+'" onmouseover="this.className=\''+cssClassSwap+'\'" onmouseout="this.className=\''+cssClassSwap+'\'"><td height="15" valign="middle" class="'+cssClassSwap+'">'+hreflink+lhmenu[lhcount].text+'</a></td></tr>';


ypos=ypos+24;
prevHeading=true;
}
if (showItems)
{	prevHeading=false;
if ((lhcount==item_selected) || (lhcount==selected_array_pos)) cssClass="menu_selected";
else cssClass = "menu_item";
if (lhmenu[lhcount].type==SUBHEADING)
{	if (lhmenu[lhcount].text==highlight_subheading) cssClass="menu_selected2";
thelink='"javascript:menuPopup('+(lhcount+1)+','+ypos+');"';
hreflink='<a href="javascript:findlink('+lhcount+')" class="left_column grey_link" onClick="linkto('+lhcount+')">';
str+='<tr class="'+cssClassSwap+'" onmouseover="this.className=\''+cssClassSwap+'\'" onmouseout="this.className=\''+cssClassSwap+'\'"><td height="15" valign="middle" colspan="2" height="20">'+hreflink+lhmenu[lhcount].text+'</a></td></tr>';
if (lhmenu[lhcount].text==subheading_link)
{	forceclick="yes";
var ypos2=ypos;
var lhstore=lhcount+1;
}
subMenu=true;
ypos=ypos+20;
}
//submenu links
else
{ if (lhmenu[lhcount].type==LINK && !submenu)
{	if (lhcount==highlight_selected_pos) cssClass="menu_selected2";
hreflink='<a href="javascript:findlink('+lhcount+')" class="left_column grey_link" onClick="linkto('+lhcount+')">';
str+='<tr class="'+cssClassSwap+'" onmouseover="this.className=\''+cssClassSwap+'\'" onmouseout="this.className=\''+cssClassSwap+'\'"><td height="15" valign="middle" class="'+cssClassSwap+'">'+hreflink+lhmenu[lhcount].text+'</a></td></tr>';
ypos=ypos+20;
}
}
}
}
if (prevHeading) str+='<tr><td colspan="2"></td></tr>';
str+='<tr class="menu_primary"><td colspan="2">&nbsp;</td></tr>';
str+='</table>';
if (platform == "mac")
{
str+='</tr></table>&nbsp;\n';
strmac=str;
}
else str+='</tr></table>';
if (platform!="mac" || browser_vers!="ie5.0" || macinitialload==true)
writeVerneNav('menu',str);
if (forceclick=="yes") menuPopup(lhstore,ypos2);
selected_array_pos="";
}
function menuClose()
{	heading_link="";
subheading_link="";
selected_array_pos="";
j=0;
item_selected=-1;
elmt_selected=-1;
Clear_tert_menu(-25,0);
createMenu();
}
function menuOpen(menu_num)
{	heading_link="";
subheading_link="";
selected_array_pos="";
item_selected=-1;
elmt_selected=menu_num;
Clear_tert_menu(-25,0);
createMenu();
}

function Clear_tert_menu(menu_num,ypos)//deletes any tertiary menus currently open
{	menulen=lhmenu.length;
	str="";
	if (ypos>-1) getElm("menu2").style.top=(nav_space)+(ypos);
	//alert(str);
	writeVerneNav('menu2',str);
}
function linkto(link_num)
{	item_selected=link_num;
	cssClass="menu_selected";
}
//if the item contains a link this function is called.  If the item contains a page id use that, if not use the specified link.  We also need to build the querystring to enable our breadcrumb functionality
function findlink(lhcount)
{	var querylhnav="";
	var prim_par_id="";
	var sec_par_id="";
	var pagelink;
	
	//secondary or primary menu with a link
	if ((lhmenu[lhcount].type==LINK) || (lhmenu[lhcount].type==HEADINGLINK)) prim_par_id=lhmenu[lhcount].parid;
	
	else //we have a tertiary menu
	{	sec_par_id=lhmenu[lhcount].parid;
		//loop backwards to obtain the primary menu parent id
		for (retrieve_count=lhcount; retrieve_count>=0; retrieve_count--)
					{	if (lhmenu[retrieve_count].parid!=sec_par_id)
				  			{	prim_par_id=lhmenu[retrieve_count].parid;
				   		 		 break;
				  			}	
				 	}
	}	
	
	querylhnav="?prim="+prim_par_id.toLowerCase();

	if (lhmenu[lhcount].link!="")//if we have a page id use it
	{   pagelink=lhmenu[lhcount].link;
		window.location=pagelink;
	}
	else //we have page id
	{	pagelink=lhmenu[lhcount].id;
		
		if (sec_par_id=="")
		{	pagelink=buildVerneUrl(pagelink);
	      	pagelink+=querylhnav;
		  	window.location=pagelink;
		}
		else
		{	querylhnav=querylhnav+"&sec="+sec_par_id.toLowerCase();
		  	pagelink=buildVerneUrl(pagelink);
		 	pagelink+=querylhnav;
		  	window.location=pagelink;
		}  
	}
}
function buildVerneUrl(pageid)//build the url from the given pageid
{	var newLocation;
	if (arguments.length==1) newLocation=urlrewrite(pageid);
	
	else if (arguments.length==2) //add in content classifications and other parameters
	{   var urlextension=arguments[1];
		newLocation=urlrewrite(pageid,null,urlextension);
	}
	else if (arguments.length==3) //add in content classifications and other parameters
	{   var urlprotocol=arguments[1];
		var urlextension=arguments[2];
		newLocation=urlrewrite(pageid,urlprotocol,urlextension);
	}
	return(newLocation);
}
function popLinkto(menu_num,link_num)
{	heading_link="";
	subheading_link="";
	selected_array_pos="";
	item_selected=link_num;
}
function use_timer(thelink) //used to delay the appearance of the tertiary menu 
{	button_delay=setTimeout(thelink,500);
}
function button_off()
{	clearTimeout(button_delay);
}
function hide_table() //hides the tertiary menu
{	j=0;
	writeVerneNav('menu2',str);
}
function close_table(evnt)
{	var menucontent=document.getElementById("tertiary")

	if(document.all)
	{    if(!menucontent.contains(evnt.toElement))//IE
			setTimeout("hide_table()",300);
	}
	else
	{   if(evnt.currentTarget!= evnt.relatedTarget && !contains_ns6(menucontent, evnt.relatedTarget))//NS
			setTimeout("hide_table()",300);
	}
}
function contains_ns6(menucont, reltar)
{	while (reltar.parentNode)
	if ((reltar=reltar.parentNode)==menucont)
	return true;
	return false;	
}
function getQueryValue(fieldname)
{	querylhnav=this.location.href; //get the url string
	querylhnav=querylhnav.substring((querylhnav.indexOf('?')) + 1); //split the url so we get the query string
	string_arr=querylhnav.split('&'); //make an array of all the different name value pairs
	for (i=0; i< string_arr.length; i++) //for each pair....
		{ 	if ((string_arr[i].indexOf(fieldname)>-1) && (this.location.href.indexOf('?') > 0)) //search the string for our name
			{//split the string so we get RHS of = 
				string_arr[i]=string_arr[i].substring((string_arr[i].indexOf('=')) + 1);
				queryfound=true;
				return string_arr[i];
			}	
		}
	string_arr[i]="not found";
	return (string_arr[i]);
}



if (navigator.appName == "Netscape")
{
document.write('<div id="menu" style="visibility: visible;"></div>'); 
}

else
{
document.write('<div id="menu" style="visibility: visible;"></div>');
}



menuTitle("&nbsp;");
menuItem(HEADINGLINK,"CORPORATE","CORPORATE","Corporate","invrel.asp?tab=1");
//menuItem(HEADINGLINK,"DIRECTORS","DIRECTORS","Main Board Directors","invrel.asp?tab=12");
menuItem(HEADINGLINK,"PHILOSOPHY","PHILOSOPHY","Philosophy","invrel.asp?tab=9");
menuItem(HEADINGLINK,"PROCESS","PROCESS","Process","invrel.asp?tab=10");
menuItem(HEADINGLINK,"INVESTMENT_TEAM","INVESTMENT_TEAM","Investment Team","invrel.asp?tab=7");
//menuItem(HEADINGLINK,"MARKET_COMMENTARY","MARKET_COMMENTARY","MARKET COMMENTARY","invrel.asp?tab=4");
menuItem(HEADINGLINK,"PRESS_RELEASES","PRESS_RELEASES","Press Releases","invrel.asp?tab=3");
//menuItem(HEADINGLINK,"FUND_RESEARCH","FUND_RESEARCH","Fund Research","invrel.asp?tab=2");
//menuItem(HEADINGLINK,"PERFORMANCE_EMAILS","PERFORMANCE_EMAILS","Performance Emails","invrel.asp?tab=5");
menuItem(HEADINGLINK,"FURTHER_INFORMATION","FURTHER_INFORMATION","Further Information","invrel.asp?tab=6");
//menuItem(HEADINGLINK,"INVESTOR_GUIDE","INVESTOR_GUIDE","Investor Guide","invrel.asp?tab=6");
//menuItem(HEADINGLINK,"PRESS_PACK","PRESS_PACK","Press Pack","invrel.asp?tab=8");
menuItem(FINALARRAYELEMENT,"","","");createMenu();

