NavbarItems = Array(3);
NavbarItems[0] = Array(
 Array('1',1, Array(
   Array('199',1, null,'HOME','/','','',0),
   Array('61',1, null,'NEWS & ANALYSIS','/news/categoryfront.php/id/61/NEWS___ANALYSIS.html','','',0),
   Array('14',1, Array(
     Array('20',1, null,'Agenda','/news/categoryfront.php/id/20/Agenda.html','','',0),
     Array('170',1, null,'Leader','/news/categoryfront.php/id/170/Leader.html','','',0),
     Array('29',1, null,'Consulting Room','/news/categoryfront.php/id/29/Consulting_Room.html','','',0),
     Array('171',1, null,'Soapbox','/news/categoryfront.php/id/171/Soapbox.html','','',0)),'COMMENT','/news/categoryfront.php/id/14/COMMENT.html','','',0),
   Array('193',1, null,'VIDEO & AUDIO','/news/categoryfront.php/id/193/VIDEO___AUDIO.html','','',0),
   Array('16',1, null,'STRATEGIES, ALLOCATION & PERFORMANCE','/news/categoryfront.php/id/16/STRATEGIES,_ALLOCATION___PERFORMANCE.html','','',0),
   Array('18',1, null,'OPERATIONS, TRADING & TECHNOLOGY ','/news/categoryfront.php/id/18/OPERATIONS,_TRADING___TECHNOLOGY_.html','','',0)),'','','','',0),
 Array('172',1, Array(
   Array('274',1, null,'Rupert Clarke, CEO, Hermes','http://ftmandate.com/news/fullstory.php/aid/2426/Getting_them_on_side.html','','',0)),'INTERVIEWS','','','',0),
 Array('173',1, Array(
   Array('182',1, null,'Global fund administration ','http://ftmandate.com/news/fullstory.php/aid/1795','','',0)),'SPECIAL REPORTS','','','',0),
 Array('11',1, Array(
   Array('255',1, Array(
     Array('272',1, null,'July - August','/news/categoryfront.php/id/272/July_-_August.html','','',0),
     Array('268',1, null,'June','/news/categoryfront.php/id/268/June.html','','',0),
     Array('271',1, null,'May','/news/categoryfront.php/id/271/May.html','','',0),
     Array('264',1, null,'April','/news/categoryfront.php/id/264/April.html','','',0),
     Array('261',1, null,'March','/news/categoryfront.php/id/261/March.html','','',0),
     Array('256',1, null,'February','/news/categoryfront.php/id/256/February.html','','',0)),'2010','/news/categoryfront.php/id/255/2010.html','','',0),
   Array('200',1, Array(
     Array('246',1, null,'December - January 2010','/news/categoryfront.php/id/246/December_-_January_2010.html','','',0),
     Array('243',1, null,'November','/news/categoryfront.php/id/243/November.html','','',0),
     Array('231',1, null,'October','/news/categoryfront.php/id/231/October.html','','',0),
     Array('219',1, null,'September','/news/categoryfront.php/id/219/September.html','','',0),
     Array('217',1, null,'July - August','/news/categoryfront.php/id/217/July_-_August.html','','',0),
     Array('215',1, null,'June','/news/categoryfront.php/id/215/June.html','','',0),
     Array('212',1, null,'May','/news/categoryfront.php/id/212/May.html','','',0),
     Array('209',1, null,'April','/news/categoryfront.php/id/209/April.html','','',0),
     Array('204',1, null,'March','/news/categoryfront.php/id/204/March.html','','',0),
     Array('201',1, null,'February','/news/categoryfront.php/id/201/February.html','','',0)),'2009','/news/categoryfront.php/id/200/2009.html','','',0),
   Array('164',1, Array(
     Array('197',1, null,'December - January 2009','/news/categoryfront.php/id/197/December_-_January_2009.html','','',0),
     Array('194',1, null,'November','/news/categoryfront.php/id/194/November.html','','',0),
     Array('188',1, null,'October','/news/categoryfront.php/id/188/October.html','','',0),
     Array('185',1, null,'September','/news/categoryfront.php/id/185/September.html','','',0),
     Array('184',1, null,'July - August','/news/categoryfront.php/id/184/July_-_August.html','','',0),
     Array('178',1, null,'June','/news/categoryfront.php/id/178/June.html','','',0),
     Array('168',1, null,'May','/news/categoryfront.php/id/168/May.html','','',0),
     Array('167',1, null,'April','/news/categoryfront.php/id/167/April.html','','',0),
     Array('166',1, null,'March','/news/categoryfront.php/id/166/March.html','','',0),
     Array('165',1, null,'February','/news/categoryfront.php/id/165/February.html','','',0)),'2008','/news/categoryfront.php/id/164/2008.html','','',0),
   Array('138',1, Array(
     Array('155',1, null,'December - January 2008','/news/categoryfront.php/id/155/December_-_January_2008.html','','',0),
     Array('153',1, null,'November','/news/categoryfront.php/id/153/November.html','','',0),
     Array('152',1, null,'October','/news/categoryfront.php/id/152/October.html','','',0),
     Array('150',1, null,'September','/news/categoryfront.php/id/150/September.html','','',0),
     Array('148',1, null,'July - August','/news/categoryfront.php/id/148/July_-_August.html','','',0),
     Array('146',1, null,'June','/news/categoryfront.php/id/146/June.html','','',0),
     Array('144',1, null,'May','/news/categoryfront.php/id/144/May.html','','',0),
     Array('142',1, null,'April','/news/categoryfront.php/id/142/April.html','','',0),
     Array('141',1, null,'March','/news/categoryfront.php/id/141/March.html','','',0),
     Array('139',1, null,'February','/news/categoryfront.php/id/139/February.html','','',0)),'2007','/news/categoryfront.php/id/138/2007.html','','',0),
   Array('113',1, Array(
     Array('133',1, null,'December - January 2007','/news/categoryfront.php/id/133/December_-_January_2007.html','','',0),
     Array('131',1, null,'November','/news/categoryfront.php/id/131/November.html','','',0),
     Array('130',1, null,'October','/news/categoryfront.php/id/130/October.html','','',0),
     Array('127',1, null,'September','/news/categoryfront.php/id/127/September.html','','',0),
     Array('125',1, null,'July - August','/news/categoryfront.php/id/125/July_-_August.html','','',0),
     Array('123',1, null,'June','/news/categoryfront.php/id/123/June.html','','',0),
     Array('121',1, null,'May','/news/categoryfront.php/id/121/May.html','','',0),
     Array('118',1, null,'April','/news/categoryfront.php/id/118/April.html','','',0),
     Array('115',1, null,'March','/news/categoryfront.php/id/115/March.html','','',0),
     Array('114',1, null,'February','/news/categoryfront.php/id/114/February.html','','',0)),'2006','/news/categoryfront.php/id/113/2006.html','','',0),
   Array('81',1, Array(
     Array('110',1, null,'December - January 2006','/news/categoryfront.php/id/110/December_-_January_2006.html','','',0),
     Array('107',1, null,'November','/news/categoryfront.php/id/107/November.html','','',0),
     Array('105',1, null,'October','/news/categoryfront.php/id/105/October.html','','',0),
     Array('102',1, null,'September','/news/categoryfront.php/id/102/September.html','','',0),
     Array('100',1, null,'July - August','/news/categoryfront.php/id/100/July_-_August.html','','',0),
     Array('97',1, null,'June','/news/categoryfront.php/id/97/June.html','','',0),
     Array('93',1, null,'May','/news/categoryfront.php/id/93/May.html','','',0),
     Array('91',1, null,'April','/news/categoryfront.php/id/91/April.html','','',0),
     Array('88',1, null,'March','/news/categoryfront.php/id/88/March.html','','',0),
     Array('85',1, null,'February','/news/categoryfront.php/id/85/February.html','','',0),
     Array('82',1, null,'January','/news/categoryfront.php/id/82/January.html','','',0)),'2005','/news/categoryfront.php/id/81/2005.html','','',0),
   Array('12',1, Array(
     Array('78',1, null,'November','/news/categoryfront.php/id/78/November.html','','',0),
     Array('69',1, null,'October','/news/categoryfront.php/id/69/October.html','','',0),
     Array('62',1, null,'September','/news/categoryfront.php/id/62/September.html','','',0),
     Array('60',1, null,'July - August 2004','/news/categoryfront.php/id/60/July_-_August_2004.html','','',0),
     Array('59',1, null,'31 May','/news/categoryfront.php/id/59/31_May.html','','',0),
     Array('58',1, null,'17 May','/news/categoryfront.php/id/58/17_May.html','','',0),
     Array('57',1, null,'3 May','/news/categoryfront.php/id/57/3_May.html','','',0),
     Array('56',1, null,'19 April','/news/categoryfront.php/id/56/19_April.html','','',0),
     Array('55',1, null,'5 April','/news/categoryfront.php/id/55/5_April.html','','',0)),'2004','/news/categoryfront.php/id/12/2004.html','','',0),
   Array('52',1, Array(
     Array('54',1, null,'20 October','/news/categoryfront.php/id/54/20_October.html','','',0),
     Array('53',1, null,'6 October','/news/categoryfront.php/id/53/6_October.html','','',0)),'2003','/news/categoryfront.php/id/52/2003.html','','',0)),'Archive','/news/categoryfront.php/id/11/Archive.html','','',0));
NavbarItems[1] = Array(
 Array('6',1, Array(
   Array('7',1, null,'About us','/info/about_us.php','','',0),
   Array('158',1, null,'Magazine','http://www.ftmandate.com/news/fullstory.php/aid/1764/Magazine_.html','','',0),
   Array('136',1, null,'Events','http://www.ftbusiness.com','','',0),
   Array('63',1, null,'MandateWire','http://www.mandatewire.com/default.aspx?AspxAutoDetectCookieSupport=1','','',0),
   Array('8',1, null,'Contact us','/info/contact_us.php','','',0),
   Array('13',1, null,'Advertising','/news/fullstory.php/aid/16/Advertising_information.html','','',0),
   Array('137',1, null,'MANDATE ON TWITTER','http://twitter.com/ftmandate','','',0)),'','','','',0));
NavbarItems[2] = Array(
);
function getPageItem(itemid) {
    if (document.getElementById) {
    	return document.getElementById(itemid);
    } else if (document.all) {
        return document.all[itemid];
    } else if (document.layers) {
    	return eval('document.'+itemid);
    }
    return null;
}

function writePageItem(itemid,html) {
    var lyr = null;
    if (document.getElementById) {
    	lyr = document.getElementById(itemid);
	lyr.innerHTML = html;
    } else if (document.all) {
        lyr = document.all[itemid];
	lyr.innerHTML = html;
    } else if (document.layers) {
    	// FIXME: ns4 compat
    }
}

function renderNavbarItem(container, level, item) {
    var html = "" + NavbarTemplates[container][level][1];

    var ihtm = NavbarTemplates[container][level][4];
    if (item[3] == '') { 
       // is empty
       ihtm = NavbarTemplates[container][level][2]; 
    } else if (item[5] != '') {  
       // has image
       ihtm = NavbarTemplates[container][level][3]; 
    }
    if (item[2] && (NavbarTemplates[container][level].length > 5)) { 
        // has children
    	if (item[1]) {  
	    // is open
      	    ihtm = NavbarTemplates[container][level][5];
    	} else {  
	    // is closed
      	    ihtm = NavbarTemplates[container][level][6];
    	}
    }

    html = html.replace(/%%ITEM%%/g, ihtm);

    html = html.replace(/%%ID%%/g, item[0]);
    html = html.replace(/%%TEXT%%/g, item[3]);
    html = html.replace(/%%LINK%%/g, item[4]);
    html = html.replace(/%%IMG_URL%%/g, item[5]);
    if (item[7] && PadlockTemplate) {
      html = html.replace(/%%PADLOCK%%/g, PadlockTemplate);
    } else {
      html = html.replace(/%%PADLOCK%%/g, '');
    }
    if (item[2] && item[1]) {  
	html = html.replace(/%%SUB%%/g, renderNavbarLevel(container, level+1, item[2]));
    } else {
	html = html.replace(/%%SUB%%/g, '');
    }
    return html;
} 

function renderNavbarLevel(container, level, items) {
    var html = NavbarTemplates[container][level][0];
    var buf = '';
    for(var i=0;i< items.length; i++) {
    	buf += renderNavbarItem(container, level, items[i]);
    }
    html = html.replace(/%%ITEMS%%/g, buf);
    return html;
}

function renderLeftNavbar() {
    return renderNavbarLevel(0,0,NavbarItems[0]);
}

function renderTopNavbar() {
    return renderNavbarLevel(1,0,NavbarItems[1]);
}

function renderRightNavbar() {
    return renderNavbarLevel(2,0,NavbarItems[2]);
}

// behavior specific

function getCategoryId() {
    var loc = "";
    loc += document.location; 
    loc = loc.replace(/^.*\/categoryfront\.php\/id\//,'');
    loc = loc.replace(/[^0-9].*$/,'');
    return loc;
}

function initNavbar() {
    var id = getCategoryId();
    for(var c=0; c< NavbarItems.length; c++) {
      for(var i=0;i< NavbarItems[c].length; i++) {
    	var items = NavbarItems[c][i][2];
    	if (items) {
    	    for(var j=0;j< items.length; j++) {
	      NavbarItems[c][i][2][j][1] = 0;
	      var jtems = items[j][2];
	      if (jtems && id!="") {
	        if (items[j][0] == id) { NavbarItems[c][i][2][j][1] = 1; }
	        else for (var k=0; k< jtems.length; k++) {
		  if (jtems[k][0] == id) { NavbarItems[c][i][2][j][1] = 1; }
		}
	      }
	    }
	}
      }
    }
}

function toggleNavbarItem(id) {
    for(var c=0; c< NavbarItems.length; c++) {
      for(var i=0;i< NavbarItems[c].length; i++) {
    	var items = NavbarItems[c][i][2];
    	if (items) {
    	    for(var j=0;j< items.length; j++) {
    	      if (items[j][0]==id) {
	    	NavbarItems[c][i][2][j][1] = 1 - items[j][1];
		var navdiv = getPageItem('navbar_'+c);
		if (navdiv) {
		    writePageItem('navbar_'+c,renderNavbarLevel(c,0,NavbarItems[c]));
		}
	      }
	    }
	}
      }
    }
    return 0;
}

function displaySWF(url,ver,w,h) {
  document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+ver+'" width="'+w+'" height="'+h+'"><param name="movie" value="'+url+'"><param name="quality" value="high"><embed src="'+url+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+w+'" height="'+h+'"></embed></object>');
}

var toid;
function toggleDiv(id) { var d = getPageItem(id); if (d) { if (d.style.visibility == 'hidden') d.style.visibility = 'visible'; else d.style.visibility = 'hidden'; } }
function showDiv(id) { var d=getPageItem(id); if (d) { d.style.visibility='visible'; } }
function hideDiv(id) { var d=getPageItem(id); if (d) { d.style.visibility='hidden'; } }

// template specific
// Array( 'main', 'item_main', 'empty_item', 'imgonly_item', 'nosub_item', 'sub_open_item', 'sub_close_item')
NavbarTemplates = Array(
 Array( 
   Array('%%ITEMS%%', 
   '%%ITEM%%<ul class="navbar">%%SUB%%</ul>',
   '',
   '<div class="header navbar visual"><a href="%%LINK%%"><img src="%%IMG_URL%%" alt="" border="0"></a></div>',
   '<div class="header navbar">%%TEXT%%</div>'),

   Array('%%ITEMS%%', 
   '%%ITEM%%%%SUB%%',
   '',
   '<li class="navbar item">%%PADLOCK%%<a class="button" href="%%LINK%%"><img src="%%IMG_URL%%" alt="" border="0"></a></li>',
   '<li class="navbar item">%%PADLOCK%%<a class="button" href="%%LINK%%">%%TEXT%%</a></li>',
   '<li class="navbar item haschild">%%PADLOCK%%<a class="button" href="%%LINK%%" onClick="toggleNavbarItem(\'%%ID%%\');return false;">%%TEXT%%<img src="http://ftmandate.com/pixmaps/up.gif" hspace=0 vspace=1 border=0></a></li>',
   '<li class="navbar item haschild">%%PADLOCK%%<a class="button" href="%%LINK%%" onClick="toggleNavbarItem(\'%%ID%%\');return false;">%%TEXT%%<img src="http://ftmandate.com/pixmaps/down.gif" hspace=0 vspace=1 border=0></a></li>'),

   Array('%%ITEMS%%', 
   '<li class="navbar item sub">%%PADLOCK%%%%ITEM%%</li>',
   '',
   '<a class="button" href="%%LINK%%"><img src="%%IMG_URL%%" alt="" border="0"></a>',   
   '<a class="button" href="%%LINK%%">%%TEXT%%</a>')
 ),
 Array(),
 Array( 
    Array('%%ITEMS%%', 
   '%%ITEM%%<ul class="navbar">%%SUB%%</ul>',
   '',
   '<div class="header navbar visual"><a href="%%LINK%%"><img src="%%IMG_URL%%" alt="" border="0"></a></div>',
   '<div class="header navbar">%%TEXT%%</div>'),

   Array('%%ITEMS%%', 
   '%%ITEM%%%%SUB%%',
   '',
   '<li class="navbar item">%%PADLOCK%%<a class="button" href="%%LINK%%"><img src="%%IMG_URL%%" alt="" border="0"></a></li>',
   '<li class="navbar item">%%PADLOCK%%<a class="button" href="%%LINK%%">%%TEXT%%</a></li>',
   '<li class="navbar item haschild">%%PADLOCK%%<a class="button" href="%%LINK%%" onClick="toggleNavbarItem(\'%%ID%%\');return false;">%%TEXT%%<img src="http://ftmandate.com/pixmaps/up.gif" hspace=0 vspace=1 border=0></a></li>',
   '<li class="navbar item haschild">%%PADLOCK%%<a class="button" href="%%LINK%%" onClick="toggleNavbarItem(\'%%ID%%\');return false;">%%TEXT%%<img src="http://ftmandate.com/pixmaps/down.gif" hspace=0 vspace=1 border=0></a></li>'),

   Array('%%ITEMS%%', 
   '<li class="navbar item sub">%%PADLOCK%%%%ITEM%%</li>',
   '',
   '<a class="button" href="%%LINK%%"><img src="%%IMG_URL%%" alt="" border="0"></a>',   
   '<a class="button" href="%%LINK%%">%%TEXT%%</a>')
 )
);

PadlockTemplate='<img src="http://ftmandate.com/pixmaps/padlock.gif" border="0" align="right" hspace="1" vspace="1">';
