NavbarItems = Array(3);
NavbarItems[0] = Array(
 Array('1',1, Array(
   Array('2',1, null,'Home','/','','',0),
   Array('11',1, Array(
     Array('15',1, null,'Pension funds','/news/categoryfront.php/id/15/Pension_funds.html','','',0),
     Array('14',1, null,'Asset Management','/news/categoryfront.php/id/14/Asset_Management.html','','',0),
     Array('12',1, null,'Other news','/news/categoryfront.php/id/12/Other_news.html','','',0)),'News','/news/categoryfront.php/id/11/News.html','','',0),
   Array('16',1, Array(
     Array('21',1, null,'Denmark','/news/categoryfront.php/id/21/Denmark.html','','',0),
     Array('20',1, null,'Finland','/news/categoryfront.php/id/20/Finland.html','','',0),
     Array('19',1, null,'Iceland','/news/categoryfront.php/id/19/Iceland.html','','',0),
     Array('18',1, null,'Sweden','/news/categoryfront.php/id/18/Sweden.html','','',0),
     Array('17',1, null,'Norway','/news/categoryfront.php/id/17/Norway.html','','',0)),'Country focus','/news/categoryfront.php/id/16/Country_focus.html','','',0),
   Array('132',1, null,'Solvency II','/news/categoryfront.php/id/132/Solvency_II.html','','',0),
   Array('54',1, null,' Fund Profile','/news/categoryfront.php/id/54/_Fund_Profile.html','','',0),
   Array('29',1, null,'The Interview','/news/categoryfront.php/id/29/The_Interview.html','','',0),
   Array('113',1, null,'The asset manager','/news/categoryfront.php/id/113/The_asset_manager.html','','',0),
   Array('112',1, null,'Nrpn Awards','/news/categoryfront.php/id/112/Nrpn_Awards.html','','',0),
   Array('97',1, null,'Roundtables','/news/categoryfront.php/id/97/Roundtables.html','','',0),
   Array('24',1, Array(
     Array('83',1, null,'Cover feature','/news/categoryfront.php/id/83/Cover_feature.html','','',0),
     Array('52',1, null,'UN Principles of Responsible Investment','/news/categoryfront.php/id/52/UN_Principles_of_Responsible_Investment.html','','',0),
     Array('53',1, null,'EU  IORP Directive','/news/categoryfront.php/id/53/EU__IORP_Directive.html','','',0),
     Array('79',1, null,'Sponsored feature','/news/categoryfront.php/id/79/Sponsored_feature.html','','',0)),'Features','/news/categoryfront.php/id/24/Features.html','','',0),
   Array('67',1, null,'Cover image','http://www.nrpn-online.com/subscribe','/images/decor//cat_nav_67.jpg','',0)),'CURRENT ISSUE','/news/categoryfront.php/id/1/CURRENT_ISSUE.html','','',0),
 Array('33',1, Array(
   Array('125',1, null,'June 2010','/news/categoryfront.php/id/125/June_2010.html','','',0),
   Array('120',1, null,'February 2010','/news/categoryfront.php/id/120/February_2010.html','','',0),
   Array('108',1, null,'October 2009','/news/categoryfront.php/id/108/October_2009.html','','',0),
   Array('100',1, null,'June 2009','/news/categoryfront.php/id/100/June_2009.html','','',0),
   Array('93',1, null,'February 2009','/news/categoryfront.php/id/93/February_2009.html','','',0),
   Array('90',1, null,'December 2008','/news/categoryfront.php/id/90/December_2008.html','','',0),
   Array('85',1, null,'October 2008','/news/categoryfront.php/id/85/October_2008.html','','',0),
   Array('78',1, null,'May 2008','/news/categoryfront.php/id/78/May_2008.html','','',0),
   Array('76',1, null,'March 2008','/news/categoryfront.php/id/76/March_2008.html','','',0),
   Array('71',1, null,'Autumn 2007','/news/categoryfront.php/id/71/Autumn_2007.html','','',0),
   Array('69',1, null,'Summer 2007','/news/categoryfront.php/id/69/Summer_2007.html','','',0),
   Array('65',1, null,'Spring 2007','/news/categoryfront.php/id/65/Spring_2007.html','','',0),
   Array('60',1, null,'Winter 2006','/news/categoryfront.php/id/60/Winter_2006.html','','',0),
   Array('57',1, null,'Autumn 2006','/news/categoryfront.php/id/57/Autumn_2006.html','','',0),
   Array('51',1, null,'Summer 2006','/news/categoryfront.php/id/51/Summer_2006.html','','',0),
   Array('34',1, null,'Spring 2006','/news/categoryfront.php/id/34/Spring_2006.html','','',0),
   Array('49',1, null,'Winter 2005','/news/categoryfront.php/id/49/Winter_2005.html','','',0),
   Array('47',1, null,'Autumn 2005','/news/categoryfront.php/id/47/Autumn_2005.html','','',0)),'Quarterly Investor Surveys','/news/categoryfront.php/id/33/Quarterly_Investor_Surveys.html','','',0),
 Array('35',1, Array(
   Array('118',1, Array(
     Array('127',1, null,'August','/news/categoryfront.php/id/127/August.html','','',0),
     Array('124',1, null,'June','/news/categoryfront.php/id/124/June.html','','',0),
     Array('121',1, null,'April','/news/categoryfront.php/id/121/April.html','','',0),
     Array('119',1, null,'February','/news/categoryfront.php/id/119/February.html','','',0)),'2010','/news/categoryfront.php/id/118/2010.html','','',0),
   Array('91',1, Array(
     Array('114',1, null,'December','/news/categoryfront.php/id/114/December.html','','',0),
     Array('106',1, null,'October','/news/categoryfront.php/id/106/October.html','','',0),
     Array('103',1, null,'August','/news/categoryfront.php/id/103/August.html','','',0),
     Array('99',1, null,'June','/news/categoryfront.php/id/99/June.html','','',0),
     Array('98',1, null,'May','/news/categoryfront.php/id/98/May.html','','',0),
     Array('96',1, null,'April','/news/categoryfront.php/id/96/April.html','','',0),
     Array('94',1, null,'March','/news/categoryfront.php/id/94/March.html','','',0),
     Array('92',1, null,'February','/news/categoryfront.php/id/92/February.html','','',0)),'2009','/news/categoryfront.php/id/91/2009.html','','',0),
   Array('74',1, Array(
     Array('86',1, null,'December','/news/categoryfront.php/id/86/December.html','','',0),
     Array('84',1, null,'October','/news/categoryfront.php/id/84/October.html','','',0),
     Array('80',1, null,'July','/news/categoryfront.php/id/80/July.html','','',0),
     Array('77',1, null,'May','/news/categoryfront.php/id/77/May.html','','',0),
     Array('75',1, null,'March','/news/categoryfront.php/id/75/March.html','','',0)),'2008','/news/categoryfront.php/id/74/2008.html','','',0),
   Array('63',1, Array(
     Array('73',1, null,'Winter 2007','/news/categoryfront.php/id/73/Winter_2007.html','','',0),
     Array('70',1, null,'Autumn 2007','/news/categoryfront.php/id/70/Autumn_2007.html','','',0),
     Array('68',1, null,'Summer 2007','/news/categoryfront.php/id/68/Summer_2007.html','','',0),
     Array('64',1, null,'Spring 2007','/news/categoryfront.php/id/64/Spring_2007.html','','',0)),'2007','/news/categoryfront.php/id/63/2007.html','','',0),
   Array('38',1, Array(
     Array('58',1, null,'Winter 2006-2007','/news/categoryfront.php/id/58/Winter_2006-2007.html','','',0),
     Array('56',1, null,'Autumn 2006','/news/categoryfront.php/id/56/Autumn_2006.html','','',0),
     Array('50',1, null,'Summer 2006','/news/categoryfront.php/id/50/Summer_2006.html','','',0),
     Array('39',1, null,'Spring 2006','/news/categoryfront.php/id/39/Spring_2006.html','','',0)),'2006','/news/categoryfront.php/id/38/2006.html','','',0),
   Array('37',1, Array(
     Array('43',1, null,'Winter 2005-2006','/news/categoryfront.php/id/43/Winter_2005-2006.html','','',0),
     Array('42',1, null,'Autumn 2005','/news/categoryfront.php/id/42/Autumn_2005.html','','',0),
     Array('41',1, null,'Summer 2005','/news/categoryfront.php/id/41/Summer_2005.html','','',0)),'2005','/news/categoryfront.php/id/37/2005.html','','',0),
   Array('36',1, Array(
     Array('44',1, null,'Winter 2004-2005','/news/categoryfront.php/id/44/Winter_2004-2005.html','','',0)),'2004','/news/categoryfront.php/id/36/2004.html','','',0)),'Back Issues','/news/categoryfront.php/id/35/Back_Issues.html','','',0));
NavbarItems[1] = Array(
 Array('6',1, Array(
   Array('7',1, null,'About us','/info/about_us.php','','',0),
   Array('8',1, null,'Contact us','/info/contact_us.php','','',0),
   Array('9',1, null,'Subscribe','/subscribe','','',0),
   Array('10',1, null,'Links','/company_index/','','',0),
   Array('61',1, null,'Events','http://www.ftbusinessevents.com/','','',0),
   Array('62',1, null,'Pensions News','http://www.pensionsnews.com/','','',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%%%%SUB%%',
   '',
   '<div class="header navbar visual"><a href="%%LINK%%"><img src="%%IMG_URL%%" alt="" border="0"/></a></div>',
   '<div class="header navbar">%%TEXT%%</div>'),

   Array('<ul class="navbar">%%ITEMS%%</ul>', 
   '<li class="navbar item%%PADLOCK%%">%%ITEM%%</li>%%SUB%%',
   '',
   '<a class="button" href="%%LINK%%"><img src="%%IMG_URL%%" alt="" border="0"/></a>',
   '<a class="button" href="%%LINK%%">%%TEXT%%</a>',
   '<a class="button" href="javascript:void(0);" onclick="toggleNavbarItem(\'%%ID%%\');return false;">%%TEXT%%<img src="http://nrpn-online.com/pixmaps/up.gif" hspace="0" vspace="1" border="0"/></a>',
   '<a class="button" href="javascript:void(0);" onclick="toggleNavbarItem(\'%%ID%%\');return false;">%%TEXT%%<img src="http://nrpn-online.com/pixmaps/down.gif" hspace="0" vspace="1" border="0"/></a>'),

   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%%%%SUB%%',
   '',
   '<div class="header navbar visual"><a href="%%LINK%%"><img src="%%IMG_URL%%" alt="" border="0"/></a></div>',
   '<div class="header navbar">%%TEXT%%</div>'),

   Array('<ul class="navbar">%%ITEMS%%</ul>', 
   '<li class="navbar item%%PADLOCK%%">%%ITEM%%</li>%%SUB%%',
   '',
   '<a class="button" href="%%LINK%%"><img src="%%IMG_URL%%" alt="" border="0"/></a>',
   '<a class="button" href="%%LINK%%">%%TEXT%%</a>',
   '<a class="button" href="javascript:void(0);" onclick="toggleNavbarItem(\'%%ID%%\');return false;">%%TEXT%%<img src="http://nrpn-online.com/pixmaps/up.gif" hspace="0" vspace="1" border="0"/></a>',
   '<a class="button" href="javascript:void(0);" onclick="toggleNavbarItem(\'%%ID%%\');return false;">%%TEXT%%<img src="http://nrpn-online.com/pixmaps/down.gif" hspace="0" vspace="1" border="0"/></a>'),

   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=' padlock';
