// Initialize global variables:
var lang = 'en-us';
var languagelist = new Array(
 'nl',
 'en-us',
 'endlistmarker'
);

var menuitems = new Array(
 'Main Menu', 'Hoofdmenu', 1, '',
  'Home', 'Thuis', 0, 'home.htm',
  'Archive', 'Archief', 1, 'archive/',
   'Downloads', 'Downloads', 0, 'downloads.htm',
   'Photos', 'Fotos', 0, 'photos.htm',
   'Videos', 'Videos', 0, 'videos.htm',
   'Games', 'Spellen', 0, 'games.htm',
   'Projects', 'Projecten', 0, 'projects.htm',
   '', '', -1, '',
  'Information', 'Informatie', 1, 'info/',
   'About', 'Over', 0, 'about.htm',
   'Projects', 'Projecten', 0, 'projects.htm',
   'Contact', 'Contact', 0, 'contact.htm',
   'Links', 'Links', 0, 'links.htm',
   'Legal', 'Gerechtelijk', 0, 'legal.htm',
   '', '', -1, '',
  'Work In Progress', 'Werk In Uitvoering', 1, 'workinprogress/',
   'Courses', 'Cursussen', 0, 'courses.htm',
   'Websites', 'Websites', 0, 'websites.htm',
   '', '', -1, '',
 // 'Download the internet', 'Download het internet', 2, 'http://www.w3schools.com/downloadwww.htm',
 // 'Has the large Hadron collider destroyed the world yet?', 'Heeft de grote Hadron versneller de wereld al vernietigd?', 2, 'http://hasthelargehadroncolliderdestroyedtheworldyet.com/',
 '', '', -1, '',
 'endlistmarker'
);

// Functions:
// ---------------------------------------------------------------------------------------------
 // Initialize document:
  function initPage() {
   window.status = 'RT&D Softworks reminds you to respect the pixel...';
   handleMenu();
   handleDisplayContent( './' + lang + '/home.htm' );
  }
 // Written: 12:48 PM 10/28/2008
 // Last Edited: 12:48 PM 10/28/2008 
 // By: Roland ten Napel
// ---------------------------------------------------------------------------------------------

// ---------------------------------------------------------------------------------------------
 // Display content handler:
  function handleDisplayContent( url ) {
   document.getElementById('displaycontent').innerHTML = '<iframe frameborder="0" style="width: 100%; height: 100%; position: absolute; left: 0px; right: 0px; top: 0px; bottom: 0px;" src="' + url + '"></iframe>';
  }
 // Written: 3:36 PM 10/28/2008
 // Last Edited: 4:38 PM 10/28/2008
 // By: Roland ten Napel
// ---------------------------------------------------------------------------------------------

// ---------------------------------------------------------------------------------------------
 // Menu handler:
  function handleMenu() {
   var result = '';
   var option = '';
   var sub = 0;
   var folder = '';
   var counter = 0;
   var url = '';
   while( menuitems[counter] != 'endlistmarker' ) { 
    if( lang == 'nl' ) { option = menuitems[counter+1]; } else { option = menuitems[counter]; }
    sub = menuitems[counter+2];

    if( sub == 1 ) { result = result + '<ul><b>' + option + '</b>'; folder = menuitems[counter+3]; } 

    if( menuitems[counter+2] == 0 ) { 
     page = menuitems[counter+3];
     url = './' + lang + '/' + folder + page;
     result = result + '<li><a onclick="handleDisplayContent(\'' + url + '\');">' + option + '</a></li>';
     if( option.length > 10 ) { result = result + '<br />'; }
    }

    if( menuitems[counter+2] == 2 ) { 
     page = menuitems[counter+3];
     url = page;
     result = result + '<li><a onclick="handleDisplayContent(\'' + url + '\');">' + option + '</a></li>';
     if( option.length > 10 ) { result = result + '<br />'; }
    }

    if( menuitems[counter+2] == -1 ) { result = result + '</ul><br />'; folder = ''; }

    counter = counter + 4;
   }
   result = result + '</ul>';
   document.getElementById('menucontent').innerHTML = result;
  }
 // Written: 12:48 PM 10/28/2008
 // Last Edited: 3:34 PM 10/28/2008
 // By: Roland ten Napel
// ---------------------------------------------------------------------------------------------

// ---------------------------------------------------------------------------------------------
 // Determine language:
  function getLanguage() {
   var result = 'en-us';
   var counter = 0;
   var string = navigator.userAgent+navigator.browserLanguage;
   while( languagelist[counter] != 'endlistmarker' ) {
    if( string.indexOf(languagelist[counter]) != -1 ) {
     result = languagelist[counter];
    }
    counter++;
   }
   return result;
  }
 // Written: 6:55 PM 10/27/2008
 // By: Roland ten Napel
// ---------------------------------------------------------------------------------------------