NavbarItems = Array(3);
NavbarItems[0] = Array(
 Array('1',1, Array(
   Array('86',1, null,'<B><SPAN style=\"color: red\">Breaking News</B></span>','/news/categoryfront.php/id/86/Breaking_News.html','','',0),
   Array('24',1, null,'<B>Footwear News</B>','/news/categoryfront.php/id/24/Footwear_News.html','','',0),
   Array('33',1, null,'<B>Ladies Footwear</B>','/news/categoryfront.php/id/33/Ladies_Footwear.html','','',0),
   Array('34',1, null,'<B>Men\'s Footwear</B>','/news/categoryfront.php/id/34/Men_s_Footwear.html','','',0),
   Array('32',1, null,'<b>Children\'s Footwear</b>','/news/categoryfront.php/id/32/Children_s_Footwear.html','','',0),
   Array('90',1, Array(
     Array('123',1, null,'Comfort','/news/categoryfront.php/id/123/Comfort.html','','',0),
     Array('42',1, null,'Sandals','/news/categoryfront.php/id/42/Sandals.html','','',0),
     Array('41',1, null,'Slippers','/news/categoryfront.php/id/41/Slippers.html','','',0),
     Array('43',1, null,'Outdoor','/news/categoryfront.php/id/43/Outdoor.html','','',0),
     Array('31',1, null,'Safety','/news/categoryfront.php/id/31/Safety.html','','',0),
     Array('37',1, null,'Sports/Exercise','/news/categoryfront.php/id/37/Sports_Exercise.html','','',0),
     Array('30',1, null,'Orthapedic ','/news/categoryfront.php/id/30/Orthapedic_.html','','',0)),'<B>Footwear</B>','/news/categoryfront.php/id/90/Footwear.html','','',0),
   Array('40',1, null,'<B>Below the Ankle</B>','/news/categoryfront.php/id/40/Below_the_Ankle.html','','',0),
   Array('92',1, Array(
     Array('93',1, null,'Handbags','/news/categoryfront.php/id/93/Handbags.html','','',0)),'<B>Accessories</B>','/news/categoryfront.php/id/92/Accessories.html','','',0),
   Array('28',1, null,'<b>Footwear Trade Shows</B>','/news/categoryfront.php/id/28/Footwear_Trade_Shows.html','','',0),
   Array('38',1, null,'<B>Technology</B>','/news/categoryfront.php/id/38/Technology.html','','',0),
   Array('44',1, null,'<B>Logistics</B>','/news/categoryfront.php/id/44/Logistics.html','','',0),
   Array('126',1, Array(
     Array('106',1, null,'Society of Shoe Fitters','/news/categoryfront.php/id/106/Society_of_Shoe_Fitters.html','','',0),
     Array('112',1, null,'Care International','/news/categoryfront.php/id/112/Care_International.html','','',0)),'<B>Footwear Trade Associations</B>','/news/categoryfront.php/id/126/Footwear_Trade_Associations.html','','',0),
   Array('133',1, null,'Recruitment','/news/categoryfront.php/id/133/Recruitment.html','/images/decor//cat_nav_133.gif','',0)),'<B>Contents</B>','/news/categoryfront.php/id/1/Contents.html','','',0),
 Array('87',1, Array(
   Array('113',1, Array(
     Array('134',1, null,'August','http://content.yudu.com/A1ok07/FootwearAugust2010','','',0),
     Array('131',1, null,'Jun/Jul',' http://content.yudu.com/A1o2p2/FootwearJuneJuly2010/','','',0),
     Array('130',1, null,'May','http://content.yudu.com/A1nptv/FootwearMay2010','','',0),
     Array('129',1, null,'<SPAN style=\"FONT-SIZE: 8pt; FONT-FAMILY: Verdana\">April</SPAN></FONT>','http://content.yudu.com/A1nerk/FootwearApril2010/resources/index.htm?referrerUrl=','','',0),
     Array('121',1, null,'March','http://content.yudu.com/A1n20z/FootwearMar2010/','','',0),
     Array('118',1, null,'February','http://content.yudu.com/A1m0zf/FootwearFeb2010/resources/index.htm?referrerUrl=','','',0),
     Array('114',1, null,'January','http://content.yudu.com/A1k7b7/FootwearJan2010/resources/index.htm?referrerUrl','','',0)),'<B>2010</B>','','','',0),
   Array('88',1, Array(
     Array('110',1, null,'Nov/Dec','http://content.yudu.com/A1ig0q/FootwearNovDec09/resources/index.htm?referrerUrl=','','',0),
     Array('109',1, null,'October','http://content.yudu.com/A1h148/FootwearOct09/resources/index.htm?referrerUrl=','','',0),
     Array('105',1, null,'September','http://content.yudu.com/A1fnuq/FoowearSept09/resources/index.htm?referrerUrl=','','',0),
     Array('103',1, null,'August','http://content.yudu.com/A1d5ft/FootwearAug09/resources/index.htm?referrerUrl=','','',0),
     Array('100',1, null,'Jun/Jul','http://content.yudu.com/A187z8/FootwearJune09/resources/index.htm?referrerUrl=','','',0),
     Array('89',1, null,'May','http://content.yudu.com/A17fhh/FootwearMay09/resources/index.htm?referrerUrl=','','',0)),'<B>2009</B>','','','',0)),'<B>Digitised Issues</B>','','','',0));
NavbarItems[1] = Array(
 Array('13',1, Array(
   Array('7',1, null,'About Us','/info/about_us.php','','',0),
   Array('15',1, null,'2010 Media Pack','http://www.footweartoday.co.uk/cp/2/FootwearMediaInfo2010.pdf','','',0),
   Array('14',1, null,'Registration','http://www.gotxt.biz/gotxt_betaold//inquiryform/subscription/55','','',0),
   Array('10',1, null,'Directory','/company_index/','','',0),
   Array('8',1, null,'Contact Us','/info/contact_us.php','','',0)),'Home','http://www.footweartoday.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.footweartoday.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.footweartoday.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.footweartoday.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.footweartoday.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';
