NavbarItems = Array(3);
NavbarItems[0] = Array(
 Array('3',1, Array(
   Array('21',1, null,'Circuit Components','/news/categoryfront.php/id/21/Circuit_Components.html','','',0),
   Array('11',1, null,'Comment & Analysis','/news/categoryfront.php/id/11/Comment___Analysis.html','','',0),
   Array('22',1, null,'Distribution','/news/categoryfront.php/id/22/Distribution.html','','',0),
   Array('23',1, null,'EDA & Development','/news/categoryfront.php/id/23/EDA___Development.html','','',0),
   Array('24',1, null,'Events','/news/categoryfront.php/id/24/Events.html','','',0),
   Array('25',1, null,'Freebies & Giveaways','/news/categoryfront.php/id/25/Freebies___Giveaways.html','','',0),
   Array('26',1, null,'ICs & Semiconductors','/news/categoryfront.php/id/26/ICs___Semiconductors.html','','',0),
   Array('27',1, null,'Interconnection','/news/categoryfront.php/id/27/Interconnection.html','','',0),
   Array('28',1, null,'News & Views','/news/categoryfront.php/id/28/News___Views.html','','',0),
   Array('29',1, null,'Power Electronics','/news/categoryfront.php/id/29/Power_Electronics.html','','',0),
   Array('20',1, null,'Profiles','/news/categoryfront.php/id/20/Profiles.html','','',0),
   Array('30',1, null,'Sub-Assemblies','/news/categoryfront.php/id/30/Sub-Assemblies.html','','',0),
   Array('50',1, null,'Web Exclusives','/news/categoryfront.php/id/50/Web_Exclusives.html','','',0),
   Array('31',1, null,'Wireless Technology','/news/categoryfront.php/id/31/Wireless_Technology.html','','',0)),'','/news/categoryfront.php/id/3/','','',0),
 Array('38',1, Array(
   Array('79',1, Array(
     Array('80',1, null,'January','http://content.yudu.com/A1v8zg/CIEDEC11JAN12','','',0)),'2012','','','',0),
   Array('68',1, Array(
     Array('78',1, null,'November','http://content.yudu.com/A1umol/CIENov2011','','',0),
     Array('76',1, null,'October','http://content.yudu.com/A1u977/CIEOct2011','','',0),
     Array('75',1, null,'September','http://content.yudu.com/A1tv5e/CIESept2011','','',0),
     Array('74',1, null,'Jul/Aug','http://content.yudu.com/A1tf3g/CIEJulAug2011','','',0),
     Array('73',1, null,'June','http://content.yudu.com/A1skqg/CIEJune2011','','',0),
     Array('72',1, null,'May','http://content.yudu.com/A1s5d0/CIEMay2011','','',0),
     Array('71',1, null,'April','http://content.yudu.com/A1rsww/CIEApril2011','','',0),
     Array('70',1, null,'March','http://content.yudu.com/A1rewi/CIEMarch2011','','',0),
     Array('69',1, null,'February','http://content.yudu.com/A1qysu/CIEFeb2011','','',0)),'2011','','','',0),
   Array('57',1, Array(
     Array('67',1, null,'Dec/Jan','http://content.yudu.com/A1qfcs/CIEDec10Jan11','','',0),
     Array('66',1, null,'November','http://content.yudu.com/A1q0sc/CIENov2010','','',0),
     Array('65',1, null,'October','http://content.yudu.com/A1pm2y/CIEOct2010','','',0),
     Array('64',1, null,'September','http://content.yudu.com/A1p6m0/CIESept2010','','',0),
     Array('63',1, null,'Jul/Aug','http://content.yudu.com/A1oj8j/CIEJulyAug2010','','',0),
     Array('62',1, null,'June','http://content.yudu.com/A1o8b1/CIEJune10/','','',0),
     Array('61',1, null,'May','http://content.yudu.com/A1nxy7/CIEMay2010','','',0),
     Array('60',1, null,'April','http://content.yudu.com/A1nkbh/CIEApril2010','','',0),
     Array('59',1, null,'March','http://content.yudu.com/A1n7kw/CIEMar2010/resources/index.htm?referrerUrl=','','',0),
     Array('58',1, null,'February','http://content.yudu.com/A1lxty/CIEfeb10/resources/index.htm?referrerUrl=','','',0)),'2010','','','',0),
   Array('39',1, Array(
     Array('55',1, null,'Dec/Jan','http://content.yudu.com/A1k3hl/CIEDecJan/resources/index.htm?referrerUrl=','','',0),
     Array('53',1, null,'November','http://content.yudu.com/A1irod/CIENov09/resources/index.htm?referrerUrl=','','',0),
     Array('40',1, null,'October','http://content.yudu.com/A1hhge/CIE-October-09/resources/index.htm?referrerUrl=','','',0),
     Array('41',1, null,'September','http://content.yudu.com/A1g1p5/CIESept09/resources/index.htm?referrerUrl=','','',0),
     Array('52',1, null,'August','http://content.yudu.com/A1cwxw/CIEJulyAug09/resources/index.htm?referrerUrl=','','',0)),'2009','','','',0)),'Digital Issues','','','',0));
NavbarItems[1] = Array(
 Array('6',1, Array(
   Array('10',1, null,'Directory','http://www.ciedirectory.co.uk','','',0),
   Array('19',1, null,'Registration','http://www.cieonline.co.uk/files/ciecirculation.html','','',0),
   Array('7',1, null,'About us','/info/about_us.php','','',0),
   Array('8',1, null,'Contact us','/info/contact_us.php','','',0),
   Array('18',1, null,'Media Pack (PDF)','http://www.cieonline.co.uk/files/CIEMedia.pdf','','',0),
   Array('77',1, null,'<font color=\"#ffd200\">Web Directory</font>','http://www.cieonline.co.uk/news/fullstory.php/aid/3909/_.html','','',0)),'Home','http://www.cieonline.co.uk','','',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://www.cieonline.co.uk/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://www.cieonline.co.uk/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://www.cieonline.co.uk/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://www.cieonline.co.uk/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';

