NavbarItems = Array(3);
NavbarItems[0] = Array(
 Array('1',1, Array(
   Array('35',1, null,'Latest News','/news/categoryfront.php/id/35/Latest_News.html','','',0),
   Array('34',1, null,'World News','/news/categoryfront.php/id/34/World_News.html','','',0),
   Array('190',1, Array(
     Array('212',1, null,'Argolanda','/news/categoryfront.php/id/212/Argolanda.html','','',0),
     Array('213',1, null,'Emag','/news/categoryfront.php/id/213/Emag.html','','',0),
     Array('215',1, null,'Wet Blue International','/news/categoryfront.php/id/215/Wet_Blue_International.html','','',0)),'Hide and Skin Traders','/news/categoryfront.php/id/190/Hide_and_Skin_Traders.html','','',0),
   Array('114',1, Array(
     Array('39',1, null,'Editorial Comment','/news/categoryfront.php/id/39/Editorial_Comment.html','','',0),
     Array('40',1, null,'Letters','/news/categoryfront.php/id/40/Letters.html','','',0)),'Comments','/news/categoryfront.php/id/114/Comments.html','','',0),
   Array('41',1, null,'Limeblast','/news/categoryfront.php/id/41/Limeblast.html','','',0),
   Array('42',1, null,'Technology','/news/categoryfront.php/id/42/Technology.html','','',0),
   Array('102',1, null,'Raw Materials','/news/categoryfront.php/id/102/Raw_Materials.html','','',0),
   Array('43',1, null,'Features','/news/categoryfront.php/id/43/Features.html','','',0),
   Array('217',1, null,'Top 20 Power List 2009','/news/categoryfront.php/id/217/Top_20_Power_List_2009.html','','',0),
   Array('37',1, null,'African Platform','http://www.intracen.org/appli2/leather/africanplatform/default.aspx','','',0),
   Array('49',1, null,'Events','/news/categoryfront.php/id/49/Events.html','','',0),
   Array('68',1, null,'Chemicals','/news/categoryfront.php/id/68/Chemicals.html','','',0),
   Array('72',1, null,'Tanners\' Dilemma','/news/categoryfront.php/id/72/Tanners__Dilemma.html','','',0),
   Array('73',1, null,'Products & Services','/news/categoryfront.php/id/73/Products___Services.html','','',0),
   Array('75',1, null,'World Market Statistics','/news/categoryfront.php/id/75/World_Market_Statistics.html','','',0),
   Array('74',1, null,'Machinery','/news/categoryfront.php/id/74/Machinery.html','','',0),
   Array('176',1, null,'SauerReport','/news/categoryfront.php/id/176/SauerReport.html','','',0),
   Array('99',1, null,'Profiles','/news/categoryfront.php/id/99/Profiles.html','','',0),
   Array('87',1, null,'Surveys','/news/categoryfront.php/id/87/Surveys.html','','',0),
   Array('48',1, null,'Fair Reports','/news/categoryfront.php/id/48/Fair_Reports.html','','',0),
   Array('127',1, null,'People ','/news/categoryfront.php/id/127/People_.html','','',0),
   Array('86',1, null,'Conferences','/news/categoryfront.php/id/86/Conferences.html','','',0),
   Array('189',1, null,'Fashion','/news/categoryfront.php/id/189/Fashion.html','','',0),
   Array('188',1, null,'Environmental News','/news/categoryfront.php/id/188/Environmental_News.html','','',0),
   Array('153',1, null,'Book review','/news/categoryfront.php/id/153/Book_review.html','','',0),
   Array('47',1, null,'RSS News Feeds','/news/categoryfront.php/id/47/RSS_News_Feeds.html','','',0),
   Array('216',1, null,'Recruitment','/news/categoryfront.php/id/216/Recruitment.html','','',0)),'Leather International','/news/categoryfront.php/id/1/Leather_International.html','','',0),
 Array('62',1, Array(
   Array('218',1, Array(
     Array('219',1, null,'January','/news/categoryfront.php/id/219/January.html','','',0),
     Array('220',1, null,'February','/news/categoryfront.php/id/220/February.html','','',0),
     Array('221',1, null,'March','/news/categoryfront.php/id/221/March.html','','',0)),'2010','/news/categoryfront.php/id/218/2010.html','','',0),
   Array('193',1, Array(
     Array('194',1, null,'January','/news/categoryfront.php/id/194/January.html','','',0),
     Array('195',1, null,'February','/news/categoryfront.php/id/195/February.html','','',0),
     Array('198',1, null,'March','/news/categoryfront.php/id/198/March.html','','',0),
     Array('199',1, null,'April','/news/categoryfront.php/id/199/April.html','','',0),
     Array('200',1, null,'May','/news/categoryfront.php/id/200/May.html','','',0),
     Array('201',1, null,'June','/news/categoryfront.php/id/201/June.html','','',0),
     Array('202',1, null,'July','/news/categoryfront.php/id/202/July.html','','',0),
     Array('204',1, null,'September','/news/categoryfront.php/id/204/September.html','','',0),
     Array('205',1, null,'October','/news/categoryfront.php/id/205/October.html','','',0),
     Array('206',1, null,'November','/news/categoryfront.php/id/206/November.html','','',0),
     Array('207',1, null,'December','/news/categoryfront.php/id/207/December.html','','',0)),'2009','/news/categoryfront.php/id/193/2009.html','','',0),
   Array('81',1, Array(
     Array('82',1, null,'January','/news/categoryfront.php/id/82/January.html','','',0),
     Array('177',1, null,'February','/news/categoryfront.php/id/177/February.html','','',0),
     Array('178',1, null,'March','/news/categoryfront.php/id/178/March.html','','',0),
     Array('179',1, null,'April','/news/categoryfront.php/id/179/April.html','','',0),
     Array('180',1, null,'May','/news/categoryfront.php/id/180/May.html','','',0),
     Array('181',1, null,'June','/news/categoryfront.php/id/181/June.html','','',0),
     Array('182',1, null,'July','/news/categoryfront.php/id/182/July.html','','',0),
     Array('183',1, null,'August','/news/categoryfront.php/id/183/August.html','','',0),
     Array('184',1, null,'September','/news/categoryfront.php/id/184/September.html','','',0),
     Array('185',1, null,'October','/news/categoryfront.php/id/185/October.html','','',0),
     Array('186',1, null,'November','/news/categoryfront.php/id/186/November.html','','',0),
     Array('187',1, null,'December','/news/categoryfront.php/id/187/December.html','','',0)),'2008','/news/categoryfront.php/id/81/2008.html','','',0),
   Array('63',1, Array(
     Array('163',1, null,'2007 01 02 ','/news/categoryfront.php/id/163/2007_01_02_.html','','',0),
     Array('164',1, null,'2007 03 ','/news/categoryfront.php/id/164/2007_03_.html','','',0),
     Array('165',1, null,'2007 04 ','/news/categoryfront.php/id/165/2007_04_.html','','',0),
     Array('166',1, null,'2007 05 ','/news/categoryfront.php/id/166/2007_05_.html','','',0),
     Array('167',1, null,'2007 06','/news/categoryfront.php/id/167/2007_06.html','','',0),
     Array('168',1, null,'2007 07','/news/categoryfront.php/id/168/2007_07.html','','',0),
     Array('169',1, null,'2007 08 09','/news/categoryfront.php/id/169/2007_08_09.html','','',0),
     Array('159',1, null,'2007 10','/news/categoryfront.php/id/159/2007_10.html','','',0),
     Array('80',1, null,'December','/news/categoryfront.php/id/80/December.html','','',0),
     Array('64',1, null,'November','/news/categoryfront.php/id/64/November.html','','',0),
     Array('65',1, null,'October','/news/categoryfront.php/id/65/October.html','','',0)),'2007','/news/categoryfront.php/id/63/2007.html','','',0),
   Array('66',1, Array(
     Array('150',1, null,'2006 01 02','/news/categoryfront.php/id/150/2006_01_02.html','','',0),
     Array('151',1, null,'2006 03 ','/news/categoryfront.php/id/151/2006_03_.html','','',0),
     Array('154',1, null,'2006 04','/news/categoryfront.php/id/154/2006_04.html','','',0),
     Array('155',1, null,'2006 05 ','/news/categoryfront.php/id/155/2006_05_.html','','',0),
     Array('156',1, null,'2006 06','/news/categoryfront.php/id/156/2006_06.html','','',0),
     Array('157',1, null,'2006 07','/news/categoryfront.php/id/157/2006_07.html','','',0),
     Array('158',1, null,'2006 08 09 ','/news/categoryfront.php/id/158/2006_08_09_.html','','',0),
     Array('161',1, null,'2006 10','/news/categoryfront.php/id/161/2006_10.html','','',0),
     Array('160',1, null,'2006 11','/news/categoryfront.php/id/160/2006_11.html','','',0),
     Array('162',1, null,'2006 12 ','/news/categoryfront.php/id/162/2006_12_.html','','',0)),'2006','/news/categoryfront.php/id/66/2006.html','','',0),
   Array('137',1, Array(
     Array('143',1, null,'2005 01 02','/news/categoryfront.php/id/143/2005_01_02.html','','',0),
     Array('144',1, null,'2005 03','/news/categoryfront.php/id/144/2005_03.html','','',0),
     Array('145',1, null,'2005 04','/news/categoryfront.php/id/145/2005_04.html','','',0),
     Array('175',1, null,'2005 05','/news/categoryfront.php/id/175/2005_05.html','','',0),
     Array('146',1, null,'2005 06 ','/news/categoryfront.php/id/146/2005_06_.html','','',0),
     Array('136',1, null,'2005 07','/news/categoryfront.php/id/136/2005_07.html','','',0),
     Array('147',1, null,'2005 08 09 ','/news/categoryfront.php/id/147/2005_08_09_.html','','',0),
     Array('148',1, null,'2005 10','/news/categoryfront.php/id/148/2005_10.html','','',0),
     Array('149',1, null,'2005 11 ','/news/categoryfront.php/id/149/2005_11_.html','','',0),
     Array('142',1, null,'2005 12 ','/news/categoryfront.php/id/142/2005_12_.html','','',0)),'2005','/news/categoryfront.php/id/137/2005.html','','',0),
   Array('130',1, Array(
     Array('131',1, null,'2004 01 02 ','/news/categoryfront.php/id/131/2004_01_02_.html','','',0),
     Array('132',1, null,'2004 03 ','/news/categoryfront.php/id/132/2004_03_.html','','',0),
     Array('133',1, null,'2004 04 ','/news/categoryfront.php/id/133/2004_04_.html','','',0),
     Array('134',1, null,'2004 05','/news/categoryfront.php/id/134/2004_05.html','','',0),
     Array('135',1, null,'2004 06','/news/categoryfront.php/id/135/2004_06.html','','',0),
     Array('138',1, null,'2004 08 09','/news/categoryfront.php/id/138/2004_08_09.html','','',0),
     Array('139',1, null,'2004 10 ','/news/categoryfront.php/id/139/2004_10_.html','','',0),
     Array('140',1, null,'2004 11 ','/news/categoryfront.php/id/140/2004_11_.html','','',0),
     Array('141',1, null,'2004 12','/news/categoryfront.php/id/141/2004_12.html','','',0)),'2004','/news/categoryfront.php/id/130/2004.html','','',0),
   Array('119',1, Array(
     Array('120',1, null,'2003 02 ','/news/categoryfront.php/id/120/2003_02_.html','','',0),
     Array('122',1, null,'2003 03','/news/categoryfront.php/id/122/2003_03.html','','',0),
     Array('123',1, null,'2003 04','/news/categoryfront.php/id/123/2003_04.html','','',0),
     Array('125',1, null,'2003 05','/news/categoryfront.php/id/125/2003_05.html','','',0),
     Array('171',1, null,'2003 06','/news/categoryfront.php/id/171/2003_06.html','','',0),
     Array('172',1, null,'2003 07','/news/categoryfront.php/id/172/2003_07.html','','',0),
     Array('124',1, null,'2003 08','/news/categoryfront.php/id/124/2003_08.html','','',0),
     Array('173',1, null,'2003 09','/news/categoryfront.php/id/173/2003_09.html','','',0),
     Array('174',1, null,'2003 10','/news/categoryfront.php/id/174/2003_10.html','','',0),
     Array('126',1, null,'2003 11','/news/categoryfront.php/id/126/2003_11.html','','',0),
     Array('129',1, null,'2003 12','/news/categoryfront.php/id/129/2003_12.html','','',0)),'2003','/news/categoryfront.php/id/119/2003.html','','',0),
   Array('100',1, Array(
     Array('101',1, null,'2002 01','/news/categoryfront.php/id/101/2002_01.html','','',0),
     Array('103',1, null,'2002 02','/news/categoryfront.php/id/103/2002_02.html','','',0),
     Array('104',1, null,'2002 03','/news/categoryfront.php/id/104/2002_03.html','','',0),
     Array('105',1, null,'2002 04','/news/categoryfront.php/id/105/2002_04.html','','',0),
     Array('106',1, null,'2002 05','/news/categoryfront.php/id/106/2002_05.html','','',0),
     Array('107',1, null,'2002 06','/news/categoryfront.php/id/107/2002_06.html','','',0),
     Array('108',1, null,'2002 07','/news/categoryfront.php/id/108/2002_07.html','','',0),
     Array('109',1, null,'2002 08','/news/categoryfront.php/id/109/2002_08.html','','',0),
     Array('110',1, null,'2002 09','/news/categoryfront.php/id/110/2002_09.html','','',0),
     Array('111',1, null,'2002 10','/news/categoryfront.php/id/111/2002_10.html','','',0),
     Array('112',1, null,'2002 11','/news/categoryfront.php/id/112/2002_11.html','','',0),
     Array('113',1, null,'2002-12','/news/categoryfront.php/id/113/2002-12.html','','',0)),'2002','/news/categoryfront.php/id/100/2002.html','','',0),
   Array('83',1, Array(
     Array('84',1, null,'2001 01','/news/categoryfront.php/id/84/2001_01.html','','',0),
     Array('85',1, null,'2001 02','/news/categoryfront.php/id/85/2001_02.html','','',0),
     Array('89',1, null,'2001 03','/news/categoryfront.php/id/89/2001_03.html','','',0),
     Array('90',1, null,'2001 04','/news/categoryfront.php/id/90/2001_04.html','','',0),
     Array('91',1, null,'2001 05','/news/categoryfront.php/id/91/2001_05.html','','',0),
     Array('92',1, null,'2001 06','/news/categoryfront.php/id/92/2001_06.html','','',0),
     Array('93',1, null,'2001 07','/news/categoryfront.php/id/93/2001_07.html','','',0),
     Array('94',1, null,'2001 08','/news/categoryfront.php/id/94/2001_08.html','','',0),
     Array('95',1, null,'2001 09','/news/categoryfront.php/id/95/2001_09.html','','',0),
     Array('96',1, null,'2001 10','/news/categoryfront.php/id/96/2001_10.html','','',0),
     Array('97',1, null,'2001 11','/news/categoryfront.php/id/97/2001_11.html','','',0),
     Array('98',1, null,'2001 12','/news/categoryfront.php/id/98/2001_12.html','','',0)),'2001','/news/categoryfront.php/id/83/2001.html','','',0)),'Back Issues','/news/categoryfront.php/id/62/Back_Issues.html','','',0));
NavbarItems[1] = Array(
 Array('6',1, Array(
   Array('61',1, null,'Home','/','','',0),
   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','https://secure.getthatmag.com/index.php?wpgc=LEA-SUBS','','',0),
   Array('10',1, null,'Links','/company_index/','','',0),
   Array('192',1, null,'Recruitment','http://www.leathermag.com/news/categoryfront.php/id/216/Recruitment.html','','',0),
   Array('70',1, null,'Leather Guide','http://www.leatherbuyersguide.info/','','',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://www.leathermag.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://www.leathermag.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://www.leathermag.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://www.leathermag.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';
