var hoofditems = new Array();
var subitems = new Array();

var navRootURL = "/jeugdjournaal";
hoofditems['name'] = new Array('dummy', 'Voorpagina', 'Nieuws', 'Mening', 'Uitleg', 'Actie', 'Jouw&nbsp;video-foto', 'Achter&nbsp;de&nbsp;schermen', 'Service', 'artikelen');
hoofditems['link'] = new Array('dummy', '/voorpagina/', '/nieuws/', '/mening/', '/uitleg/', '/actie/', '/jouwvideo-foto/', '/achterdeschermen/', '/service/', '/artikelen/');
hoofditems['id'] = new Array('dummy', 05, 10, 15, 20, 25, 30, 65, 80, 99);
subitems[10] = new Array();
subitems[10]['name'] = new Array('dummy', 'Hoofdpunten', 'Nieuwsoverzicht', 'In&nbsp;de&nbsp;uitzending', 'Weer', 'Videohoek');
subitems[10]['link'] = new Array('dummy', '/nieuws/hoofdpunten/', '/nieuws/nieuwsoverzicht/', '/nieuws/indeuitzending/', '/nieuws/weer/', '/nieuws/videohoek/');
subitems[15] = new Array();
subitems[15]['name'] = new Array('dummy', 'Stelling', 'De&nbsp;mening&nbsp;van', 'Klaagmuur', 'Gastenboek', 'Mail');
subitems[15]['link'] = new Array('dummy', '/mening/stelling/', '/mening/demeningvan/', '/mening/klaagmuur/', '/mening/gastenboek/', '/mening/mail/');
subitems[25] = new Array();
subitems[25]['name'] = new Array('dummy', 'Spellen', 'Downloads', 'E-cards', 'Webcam');
subitems[25]['link'] = new Array('dummy', '/actie/spellen/', '/actie/downloads/', '/actie/ecards/', '/actie/webcam/');
subitems[30] = new Array();
subitems[30]['name'] = new Array('dummy', 'Jouw&nbsp;video', 'Jouw&nbsp;foto');
subitems[30]['link'] = new Array('dummy', '/jouwvideo-foto/jouwvideo/', '/jouwvideo-foto/jouwfoto/');
subitems[65] = new Array();
subitems[65]['name'] = new Array('dummy', 'Studio', 'De&nbsp;makers', 'Uitzending&nbsp;maken', 'Geschiedenis');
subitems[65]['link'] = new Array('dummy', '/achterdeschermen/studio/', '/achterdeschermen/demakers/', '/achterdeschermen/uitzendingmaken/', '/achterdeschermen/geschiedenis/');
subitems[80] = new Array();
subitems[80]['name'] = new Array('dummy', 'Zoeken', 'Help', 'Sitemap', 'Mail', 'Colofon');
subitems[80]['link'] = new Array('dummy', '/service/zoeken/', '/service/help/', '/service/sitemap/', '/service/mail/', '/service/colofon/'); 
ReplaceMainTopicURL(10); 
ReplaceMainTopicURL(15); 
ReplaceMainTopicURL(25); 
ReplaceMainTopicURL(30); 
ReplaceMainTopicURL(65);

switch (location.pathname){
   case navRootURL +'/' :
   case navRootURL+'/index.html' :
      // Redirect to main page
      location.href = navRootURL + hoofditems['link'][1] + 'index.html'
      break;
  case navRootURL +'/artikelen/index.html' :
  case navRootURL +'/artikelen/' :
      // gastenboek
      location.href = 'http://static.nos.nl/jeugdjournaal/nieuws/hoofdpunten/index.html'
      break;
  case navRootURL +'/mening/gastenboek/index.html' :
  case navRootURL +'/mening/gastenboek/' :
      // gastenboek
      location.href = 'http://cgi.nos.nl/cgi/nosrtv/gastenboek/jeugdjournaal.php?site=13'
      break;
  case navRootURL +'/mening/stelling/index.html' :
  case navRootURL +'/mening/stelling/' :
      // gastenboek
      location.href = 'http://cgi.nos.nl/cgi/nosrtv/jeugdjournaal/poll/poll.php'
      break;
}

function ReplaceMainTopicURL(id)
{
  for(i=1;i<hoofditems['id'].length;i++){
      if(id == hoofditems['id'][i]) {
         if ((location.pathname == navRootURL + hoofditems['link'][i] + 'index.html') || (location.pathname == navRootURL + hoofditems['link'][i])){
           location.href = navRootURL+subitems[id]['link'][1] + 'index.html';
         } else {
         hoofditems['link'][i] = subitems[id]['link'][1];
         }
      }
  }
} // ReplaceMainTopicURL

function displaySubTopics(key,subselected,strRubriek)
{
		for(j=1;j<subitems[key]['name'].length;j++){
			var url = subitems[key]['link'][j];
			if(subitems[key]['name'][j].toLowerCase( ) == subselected.toLowerCase( )) {  //check selected
				document.write('  <tr>');
				document.write('    <td height="26" valign="top" class="pijl_subnav_hoofd_'+strRubriek+'" style="padding: 8px 0 0 58px"><a href="'+navRootURL+url+'index.html" class="hoofdnav_wit">'+subitems[key]['name'][j]+'</a></td>');
				document.write('  </tr>');
			} else {
				document.write('  <tr>');
				document.write('    <td height="23" class="pijl_subnav_sub_'+strRubriek+'"><a href="'+navRootURL+url+'index.html" class="subnav_'+strRubriek+'">'+subitems[key]['name'][j]+'</a></td>');
				document.write('  </tr>');
			}
		}
} // displaySubTopics

function displaySubTopicUitleg(key,subselected,strRubriek)
{
		document.write('  <tr>');
		document.write('    <td height="26" valign="top" class="pijl_subnav_hoofd_'+strRubriek+'" style="padding: 8px 0 0 58px"><a href="'+navRootURL+'/uitleg/index.html" class="hoofdnav_wit">Uitleg</a></td>');
		document.write('  </tr>');
		
		displayUitlegOnderwerpen()

		document.write('  <tr>');
		document.write('    <td height="23" class="pijl_subnav_sub_'+strRubriek+'"><a href="'+navRootURL+'/uitleg/uitleg_overzicht.html" class="subnav_'+strRubriek+'">Meer uitleg</a></td>');
		document.write('  </tr>');
} // displaySubTopics

function displayHoofdNav(selected,subselected,strRubriek)
{
	document.write('<table width="100%"  border="0" cellspacing="0" cellpadding="0">');

	for(i=1;i<hoofditems['name'].length;i++){
		if(selected.toLowerCase( ) == hoofditems['name'][i].toLowerCase( )) {
			if(hoofditems['name'][i].toLowerCase() == "uitleg") {
				displaySubTopicUitleg(hoofditems['id'][i],subselected,strRubriek);
			}
                                               else if(hoofditems['name'][i].toLowerCase() == "artikelen") {
				displaySubTopics(10,'','nieuws');
                                                }
                                                else {
				displaySubTopics(hoofditems['id'][i],subselected,strRubriek);
			}
		}
	}
	document.write('</table>');
}