///////////////////////////////////////////////////////////////////////////////
// Global variables.
///////////////////////////////////////////////////////////////////////////////
var debug_str = "";   // String used for displaying the DIV-section, when debugging
var debugging = true;  // Flag indicating if you are debugging (display of debug messageboxes)
var activeIDs;
var imageNavArrow;
var imageSubNavArrow;
var imageNavArrowActive;
var imageSubNavArrowActive;
var imageNavHomeArrowActive;
var imageNavSpacer;
///////////////////////////////////////////////////////////////////////////////
// Name:  showDebugString
// Description: Displays the debug string in a textarea. This function can be
//    usefull when debugging.
///////////////////////////////////////////////////////////////////////////////
function showDebugString()
{
 if(debugging == true)
 {
  document.write('<textarea name="debug_str" rows="30" cols="110">');
  document.write(debug_str);
  document.write('</textarea>');
 }
}

///////////////////////////////////////////////////////////////////////////////
// Name:  preLoadMenuImages
// Description: Preloads the images so that they will be loaded into the
//    ImageCache of RedDot.
///////////////////////////////////////////////////////////////////////////////
function preLoadMenuImages(portal)
{
 imageNavHomeArrowActive = new Image();
 imageNavArrow = new Image();
 imageNavArrowActive = new Image();
 imageSubNavArrow = new Image();
 imageSubNavArrowActive = new Image();
 imageNavSpacer = new Image();
 switch(portal)
 {
  case 'musicals':
   {
    imageNavHomeArrowActive.src = "/images_musicals_general/musicals_pijl_nav_home.gif";
    imageNavArrow.src = "/images_musicals_general/musicals_pijl_nav.gif";
    imageNavArrowActive.src = "/images_musicals_general/musicals_pijl_nav_active.gif";
   } break;
  case 'toneel':
   {
    imageNavHomeArrowActive.src = "/images_musicals_general/toneel_pijl_nav_home.gif";
    imageNavArrow.src = "/images_musicals_general/toneel_pijl_nav.gif";
    imageNavArrowActive.src = "/images_musicals_general/toneel_pijl_nav_active.gif";
   } break;
  case 'musicalbon':
   {
    imageNavHomeArrowActive.src = "/images_musicals_general/musicalbon_pijl_nav_home.gif";
    imageNavArrow.src = "/images_musicals_general/musicalbon_pijl_nav.gif";
    imageNavArrowActive.src = "/images_musicals_general/musicalbon_pijl_nav_active.gif";
   } break;
  case 'theaterarrangementen':
   {
    imageNavHomeArrowActive.src = "/images_musicals_general/musicals_pijl_nav_home.gif";
    imageNavArrow.src = "/images_musicals_general/musicals_pijl_nav.gif";
    imageNavArrowActive.src = "/images_musicals_general/musicals_pijl_nav_active.gif";
   } break;
  default:
   {
    imageNavHomeArrowActive.src = "/images_musicals_general/musicals_pijl_nav_home.gif";
    imageNavArrow.src = "/images_musicals_general/musicals_pijl_nav.gif";
    imageNavArrowActive.src = "/images_musicals_general/musicals_pijl_nav_active.gif";
   } break;
 }
 imageSubNavArrow.src = "/images_musicals_general/pijl_nav_sub.gif";
 imageSubNavArrowActive.src = "/images_musicals_general/pijl_nav_sub_active.gif";
 imageNavSpacer.src = "/images_musicals_general/spacer.gif";
}

///////////////////////////////////////////////////////////////////////////////
// Name:  hideAll
// Description: Hides all menu items, by setting their style.display to 'none'.
///////////////////////////////////////////////////////////////////////////////
function hideAll()
{
 // Walk through all menu items
 for(i=0; i<folderList.length;i++)
 {
  if(folderList[i])
  {
   // If the item exists, walk through it's child items (if any)
   for(j=0; j<folderList[i].length;j++)
   {
    var currentID = folderList[i][j]["folderID"];
    if(document.getElementById(currentID))
    {
     // If the item with currentID exists, set it's
     // display style to 'none', so it will be hidden.
     document.getElementById(currentID).style.display = "none";
    }
   }
  }
 }
}

///////////////////////////////////////////////////////////////////////////////
// Name:  get_cookie
// Description: Gets the cookie with the supplied name,
///////////////////////////////////////////////////////////////////////////////
function get_cookie(Name)
{
 //Get cookie routine by Shelley Powers
 var search = Name + "="
 var returnvalue = "";
 if (document.cookie.length > 0)
 {
  offset = document.cookie.indexOf(search)
  // if cookie exists
  if (offset != -1)
  {
   offset += search.length
   // set index of beginning of value
   end = document.cookie.indexOf(";", offset);
   // set index of end of cookie value
   if (end == -1) end = document.cookie.length;
   returnvalue=unescape(document.cookie.substring(offset, end))
  }
 }
 return returnvalue;
}

///////////////////////////////////////////////////////////////////////////////
// Name:  set_cookie
// Description: Sets the supplied id in a cookie, and then opens the
//              supplied URL. When the page that is openend also includes this
//              javascript menu, the menu will be expanded up to the item with
//              the id from the cookie.
///////////////////////////////////////////////////////////////////////////////
function set_cookie(id, url)
{
 // Set the cookie
 document.cookie="menumusicals_id=" + id;
 // Open the URL
 document.location.href = url;
}

///////////////////////////////////////////////////////////////////////////////
// Name:  findParent
// Description: Finds the immediate parent for the supplied childID. The
//    parentID is returned.
///////////////////////////////////////////////////////////////////////////////
function findParent(childID)
{
 var parentID;
 // Walk through all menu items
 outerloop:
 for(var i = 0; i < folderList.length; i++)
 {
  if(folderList[i] != null)
  {
   // If the item exists, walk through it's child items (if any)
   innerloop:
   for(j = 0; j < folderList[i].length; j++)
   {
    if(folderList[i][j]["folderID"] == childID)
    {
     // If the current folderID equals the supplied childID, then it's parent is the value of 'i'.
     // For example: if childID == 10, and folderList[1][0]["folderID"]== 10,
     // then the parent is the item with ID '1'.
     parentID = i;
     break outerloop; // parentID is found --> stop the search
    }
   }
  }
 }
 // Return the found parentID
 return parentID;
}

///////////////////////////////////////////////////////////////////////////////
// Name:  getParentName
// Description: Returns the name of the immediate parent of the supplied childID.
///////////////////////////////////////////////////////////////////////////////
function getParentName(childID)
{
 var parentName;
 var parentID;
 // First, search the parentID for the given childID
 parentID = findParent(childID);
 // Get the name of the item with the parentID
 parentName = getItemName(parentID)
 // Return the found parent name
 return parentName;
}

///////////////////////////////////////////////////////////////////////////////
// Name:  getItemName
// Description: Returns the name of the item with the supplied childID.
///////////////////////////////////////////////////////////////////////////////
function getItemName(divID)
{
 var itemName;
 // Walk through all menu items
 outerloop:
 for(i=0; i<folderList.length;i++)
 {
  if(folderList[i])
  {
   // If the item exists, walk through it's child items (if any)
   innerloop:
   for(j=0; j<folderList[i].length;j++)
   {
    if(folderList[i][j]["folderID"] == divID)
    {
     // If the current folderID equals the supplied divID, then get it's name.
     itemName = folderList[i][j]["folderName"];
     break outerloop; // item name is found --> stop the search
    }
   }
  }
 }
 // Return the found item name
 return itemName;
}

///////////////////////////////////////////////////////////////////////////////
// Name:  findPreviousSibling
// Description: Finds the previous sibling of the item with the supplied ID.
///////////////////////////////////////////////////////////////////////////////
function findPreviousSibling(divID)
{
 var previousID;
 // Walk through all menu items
 outerloop:
 for(var i = 0; i < folderList.length; i++)
 {
  if(folderList[i] != null)
  {
   // If the item exists, walk through it's child items (if any)
   innerloop:
   for(j = 0; j < folderList[i].length; j++)
   {
    if(folderList[i][j]["folderID"] == divID)
    {
     // If the current folderID equals the supplied divID,
     // then it's previous item is the value of 'j - 1'.
     // For example: if divID == 104, and folderList[1][4]["folderID"]== 104,
     // then the ID of the previous sibling is folderList[1][3]["folderID"] == 103
     if((j - 1) >= 0)
     {
      previousID = folderList[i][j-1]["folderID"];
     }
     break outerloop; // previousID is found --> stop the search
    }
   }
  }
 }
 // Return the found ID
 return previousID;
}

///////////////////////////////////////////////////////////////////////////////
// Name:  isItemActive
// Description: Checks if the item with the supplied ID is active.
///////////////////////////////////////////////////////////////////////////////
function isItemActive(divID)
{
 var isActive = false;
 // Check if the item is active
 if(divID == activeIDs[0])
 {
  isActive = true;
 }
 else if(divID == activeIDs[1])
 {
  isActive = true;
 }
 else if(divID == activeIDs[2])
 {
  isActive = true;
 }
 return isActive;
}

///////////////////////////////////////////////////////////////////////////////
// Name:  hasChildren
// Description: Checks if the item with the supplied ID has children
///////////////////////////////////////////////////////////////////////////////
function itemHasChildren(divID)
{
 var hasChildren = false;
 // Check if the item has children
 if(folderList[divID] != null)
 {
  hasChildren = true;
 }
 return hasChildren;
}

///////////////////////////////////////////////////////////////////////////////
// Name:  isPreviousSiblingActiveWithChildren
// Description: Checks if the previous sibling is active, and has children.
//              Returns the ID of the found previous sibling, or 0 if previous
//              sibling is not active or does not have children.
///////////////////////////////////////////////////////////////////////////////
function isPreviousSiblingActiveWithChildren(divID)
{
 var result = 0;
 var prevID;
 // Find the ID of the previous item
 prevID = findPreviousSibling(divID);
 if(prevID != null)
 {
  // check if the previous item is active
  if(isItemActive(prevID) == true)
  {
   // check if the previous item has children
   if(itemHasChildren(prevID) == true)
   {
    result = prevID;
   }
  }
 }
 return result;
}

///////////////////////////////////////////////////////////////////////////////
// Name:  showAllChildren
// Description: Displays all children of the supplied parentID, by setting
//              their style.display to 'block'.
//              The 'showBorder' parameter indicates if a border should be drawn,
//              and for which level. This would result in a thin line on the
//              top and the bottom of the children DIV block.
///////////////////////////////////////////////////////////////////////////////
function showAllChildren(parentID, activeID, showBorder)
{
 if(!folderList[parentID])
 {
  // If the item with the supplied parentID does not exist, return immediately
  return;
 }
 // Determine the number of children of the supplied parent
 var nrOfChildren = folderList[parentID].length;
 // Check if an element with the ID 'arrow_*' exists (where * = parentID)
 if(document.getElementById("arrow_" + parentID) != null)
 {
  if(parentID != folderList[0][0]["folderID"] )
  {
   // Replace the current arrow of the parent, with the active arrow
   // Except for the 'Home' menu (with id == 'home'), which always remains 'pijl_nav_home.gif'.
   var curImage = document.getElementById("arrow_" + parentID).src;
   // Change the image name
   var newImage = curImage.replace(".gif", "_active.gif")
   // Set the new image for the element
   document.getElementById("arrow_" + parentID).src = newImage;
  }
 }
 // Walk through all children of the item, and display them
 for(var childIndex = 0; childIndex < nrOfChildren; childIndex++)
 {
  // Get the ID of the current child
  var curID = folderList[parentID][childIndex]["folderID"];
  if(document.getElementById(curID) != null)
  {
   // If an element with the current ID exists, set it display style to 'block'
   // so that it is displayed
   document.getElementById(curID).style.display = "block";
   var prevSiblingID = isPreviousSiblingActiveWithChildren(curID);
   if(prevSiblingID != 0)
   {
    // Previous sibling is active and has children. To make more space between
    // the expanded sub-items and the current item, use some extra padding.
    prevSiblingID = "container_" + prevSiblingID;
    document.getElementById(prevSiblingID).style.padding = '0px 0px 3px 0px'; // top right bottom left
   }
   if(showBorder != 0)
   {
    // A border must be drawn below the child items
    if(showBorder == 2)
    {
     if(childIndex == 0 && getItemName(parentID).length == 0)
     {
      // First child
      // If the parent name is empty, a top-border must be shown for the first child-item.
      // (needed for Musical items)
      // If the parent name is not empty, the parent will already have a separate color,
      // so the top border can be ommited.
      if(curID == activeID)
      {
       // Use the top-border with an active style
       document.getElementById(curID).className = "menumusicals_nav_l2_first_active";
      }
      else
      {
       // Use the top-border with a normal style
       document.getElementById(curID).className = "menumusicals_nav_l2_first";
      }
      document.getElementById(curID).style.padding = '3px 0px 0px 0px'; // top right bottom left';
     }
     else if(childIndex == nrOfChildren - 1)
     {
      // Last child
      if(curID == activeID)
      {
       // Use the bottom-border with an active style
       document.getElementById(curID).className = "menumusicals_nav_l2_last_active";
      }
      else
      {
       // Use the bottom-border with a normal style
       document.getElementById(curID).className = "menumusicals_nav_l2_last";
      }
      document.getElementById(curID).style.padding = '0px 0px 4px 0px'; // top right bottom left';
     }
    }
    else if(showBorder == 3)
    {
     if(childIndex == nrOfChildren - 1)
     {
      // Use the bottom-border with a normal style
      document.getElementById(curID).className = "menumusicals_nav_l3_last";
      document.getElementById(curID).style.padding = '2px 0px 2px 0px'; // top right bottom left';
     }
    }
   }
  }
 }
}

///////////////////////////////////////////////////////////////////////////////
// Name:  showAllSiblings
// Description: Displays all siblings of the supplied siblingID, by setting
//    their style.display to 'block'.
///////////////////////////////////////////////////////////////////////////////
function showAllSiblings(siblingID, activeID, showBorder)
{
 // First, search the parent for the given siblingID
 var parentID = findParent(siblingID);
 // When the parentID is found, display all children for that parent (= the requested siblings)
 showAllChildren(parentID, activeID, showBorder);
}

///////////////////////////////////////////////////////////////////////////////
// Name:  showAllParents
// Description: Displays all ancestors (= parent and the parent of the parent etc.)
//    of the supplied childID, by setting their style.display to 'block'.
///////////////////////////////////////////////////////////////////////////////
function showAllParents(childID, activeID, activeID_l2)
{
 var showBorder = 0;
 var parentID;
 if(childID != null)
 {
  // First, find the parent for the given child
  parentID = findParent(childID);
  if(parentID != null)
  {
   if(parentID == activeID_l2)
   {
    // If the parent is the active item in level 2, a border must be drawn for the parents siblings
    showBorder = 2;
   }
   // Now show all siblings of the found parent
   showAllSiblings(parentID, activeID, showBorder);
   // Do the same for the parent of the parent
   showAllParents(parentID, activeID, activeID_l2);
  }
 }
}

///////////////////////////////////////////////////////////////////////////////
// Name:  findActiveIDs
// Description: Finds the active IDs, for the supplied divID. Active ID's are the
//              ID's of the items that are active in each level. So if for example the menu
//              item 'Bedrijf / Bedrijfsinfo / Over ons' is selected, then the active ID's
//              are the ID's of the items 'Over ons' (level 3), 'Bedrijfsinfo' (level 2),
//              and 'Bedrijf' (level 1). So there is a maximum of 3 active ID's.
//              The supplied ID must always be the ID of the activated item in
//    the lowest level.
///////////////////////////////////////////////////////////////////////////////
function findActiveIDs(divID)
{
 var activeIDs = new Array();
 var parentID;
 var i = 0;
 // The supplied ID is activated, so add it to the activeIDs array
 activeIDs[i++] = divID;
 // Find the parent of the supplied divID
 parentID = findParent(divID);
 while(parentID != 0 && parentID != null)
 {
  // If the parentID is valid and not 0 (parent with ID '0' is the parent of the main menu items),
  // add the parentID to the array.
  activeIDs[i++] = parentID;
  // Find the parent of the parent, and do the same
  parentID = findParent(parentID);
 }
 // Return the array with the found active ID's
 return activeIDs;
}

///////////////////////////////////////////////////////////////////////////////
// Name:  displayDivSection
// Description: Displays the DIV section with all menu items. The supplied 'divID'
//              indicates the id of the item that must be selected. So, this id
//              determines to where the menu is axpanded.
///////////////////////////////////////////////////////////////////////////////
function displayDivSection(divID, activeID_l1, activeID_l2, activeLevel)
{
 var showBorder = 0; // Indicates if a border must be drawn. '0' means 'no border'.
      // '2' = border for level 2
      // '3' = border for level 3
 var activeID = divID;
 // Initially hide all menu items
 hideAll();
 if(document.getElementById(divID) != null)
 {
  // Show the item with given divID
  document.getElementById(divID).style.display = "block";
 }
 if(activeLevel == 1)
 {
  // If the activeLevel is 1, a border must be drawn for the children (level 2)
  showBorder = 2;
 }
 else if(activeLevel == 2)
 {
  // If the activeLevel is 2, a border must be drawn for the children (level 3)
  showBorder = 3;
 }
 // Show direct children of item with given divID
 showAllChildren(divID, activeID, showBorder);
 // Reset showBorder to 'false'
 showBorder = false;
 if(activeLevel == 2)
 {
  // If the active level equals 2, a border must be drawn for the siblings (level 2)
  showBorder = 2;
 }
 else if(activeLevel == 3)
 {
  // If the active level equals 3, a border must be drawn for the siblings (level 3)
  showBorder = 3;
 }
 // Show siblings of item with given ID
 showAllSiblings(divID, activeID, showBorder);
 // Show all parents and their siblings
 showAllParents(divID, activeID, activeID_l2);
}

///////////////////////////////////////////////////////////////////////////////
// Name:  expandMenu
// Description: Expands the menu. This function is called from within the webpage
//              that includes the menu. It takes care of the composition of the
//              DIV-section, and the display of it.
///////////////////////////////////////////////////////////////////////////////
function expandMenu(id)
{
 if(id == 'cookie')
 {
  // If an id is not supplied, fetch the 'menumusicals_id' cookie, to know what menu item to expand
  id = get_cookie('menumusicals_id');
 }
 // Find the active ID's, given the supplied id. These ID's are needed to know what items must
 // be highlighted.
 activeIDs = findActiveIDs(id);
 var activeID_l1;
 var activeID_l2;
 var activeLevel;
 if(activeIDs.length == 1)
 {
  // There is only one active ID
  activeID_l1 = activeIDs[0];
  activeLevel = 1;
 }
 else if(activeIDs.length == 2)
 {
  // There are two active ID's
  activeID_l1 = activeIDs[1];
  activeID_l2 = activeIDs[0];
  activeLevel = 2;
 }
 else if(activeIDs.length == 3)
 {
  // There are three active ID's, but only the one in level 1 and
  // the one in level 2 are needed. This is because only level 1 and 2 items\
  // will be highlighted.
  activeID_l1 = activeIDs[2];
  activeID_l2 = activeIDs[1];
  activeLevel = 3;
 }
 // Compose the DIV-sections that the menu is build up from.
 // Use the active ID's to highlight the correct menu items
 showFolderList(id, activeID_l1, activeID_l2);
 if(id == folderList[0][0]["folderID"])
 {
  // If the 'Home' item is clicked then collapse the whole menu, so only main menu items are visible
  hideAll();
 }
 else if(id != "")
 {
  // Expand the menu so that the item with the given ID is visisble
  displayDivSection(id, activeID_l1, activeID_l2, activeLevel);
 }
 else
 {
  // Cookie not set, so collapse the whole menu so only main menu items are visible
  hideAll();
 }
}

///////////////////////////////////////////////////////////////////////////////
// Name:  writeToDocument
// Description: Writes the supplied string to the document, and if debugging is
//    enabled, the string is also written to the variable 'debug_str'.
///////////////////////////////////////////////////////////////////////////////
function writeToDocument(write_str)
{
 // Write the supplied string to the current document
 document.write(write_str);
 if(debugging == true)
 {
  // If debuggin is enabled, add the string to the debug string
  debug_str = debug_str + write_str + "\n";
 }
}

///////////////////////////////////////////////////////////////////////////////
// Name:  writeMenuItemTable
// Description: Writes a table to the document, that contains one menu item.
//              A menu item consists of an image and a hyperlink.
//              The image can be one of the arrow images, or just the spacer image to
//              outline the menu items.
///////////////////////////////////////////////////////////////////////////////
function writeMenuItemTable(imgSrc, itemID, itemLink, itemName)
{
 // Write the table header to the document
 writeToDocument('<table cellspacing=0 cellpadding=0>');
 writeToDocument('<tr>');
 // Add the cell with the image
 if(imgSrc != "")
 {
  // If an image source is supplied, use this image for the menu item
  writeToDocument('<td valign="top"><img src="' + imgSrc + '" id="arrow_' + itemID + '"></td>');
 }
 else
 {
  // If an empty image source is supplied, use the spacer image to outline the menu item
  writeToDocument('<td><img height=1 src="' + imageNavSpacer.src + '" width=19></td>');
 }
 // Add the cell with the hyperlink
 writeToDocument('<td><a class="menumusicals_link" href="javascript:set_cookie(\'' + itemID + '\', \'' + itemLink + '\');">' + itemName + '</a></td>');
 // Close the table
 writeToDocument('</tr>');
 writeToDocument('</table>');
}

///////////////////////////////////////////////////////////////////////////////
// Name:  showFolderList
// Description: Creates the top DIV section for the DIV structure in which all
//    menu items from 'folderList' are placed. The parameter activeID
//    indicates the ID of the menu item that is currently active. The
//              parameters activeID_l1 en activeID_l2 indicate the active items in
//              level 1 and 2 (one of these might be the same ID as activeID).
//              These parameters are used for displaying the right arrows and
//              highlighting the correct menu items.
///////////////////////////////////////////////////////////////////////////////
function showFolderList(activeID, activeID_l1, activeID_l2)
{
 if(folderList[0])
 {
  // Menu container
  writeToDocument('<div class="menumusicals_nav" id="menucontainer">');
  if(debugging == true)
  {
   debug_str = debug_str + "\n";
  }
  if(activeID != folderList[0][0]["folderID"])
  {
   // Write the container DIV for the 'Home' item (this container will only contain 1 item: 'Home')
   writeToDocument('<div class="menumusicals_navl1" id="container_0" style="DISPLAY: block; padding-bottom: 1px; padding-top: 3px;">');
   // Write the header DIV for the 'Home' item
   writeToDocument('<div class="menumusicals_navl1" id="header_0" style="DISPLAY: block; padding-bottom: 0px;">');
   // Write the 'Home' menu item in a table
   writeMenuItemTable(imageNavHomeArrowActive.src, folderList[0][0]["folderID"], folderList[0][0]["folderLink"], folderList[0][0]["folderName"]);
   // Close DIV sections
   writeToDocument('</div>');
   writeToDocument('</div>');
  }
  else
  {
   // When the activeID is the 'home' item, make some extra space at the top of the menu,
   // so the menu will have the correct height
   writeToDocument('<img height=1 src="/images_musicals_general/spacer.gif">');
  }
  if(debugging == true)
  {
   // If debugging is enabled, add an extra '\n' for better readability
   debug_str = debug_str + "\n";
  }
  for (var i=1; i<folderList[0].length; i++)
  {
   // For each main item in the folderList, write a DIV section
   writeFolderDiv(0, i, 1, activeID, activeID_l1, activeID_l2);
   if(debugging == true)
   {
    // If debugging is enabled, add an extra '\n' for better readability
    debug_str = debug_str + "\n";
   }
  }
 }
 // End menu container
 writeToDocument('</div>');
}

///////////////////////////////////////////////////////////////////////////////
// Name:  writeFolderDiv
// Description: Creates a DIV structure for all menu items in 'folderList'.
///////////////////////////////////////////////////////////////////////////////
function writeFolderDiv(folderID, ctr, level, activeID, activeID_l1, activeID_l2)
{
 // Local variables for folderID, folderName and folderLink.
 var cur_folderID = folderList[folderID][ctr]["folderID"];
 var cur_folderName = folderList[folderID][ctr]["folderName"];
 var cur_folderLink = folderList[folderID][ctr]["folderLink"];
 if(!itemHasChildren(cur_folderID))
 {
  // The itme with cur_folderID has no submenu items
  writeFolderDiv_NoSubItems(cur_folderID, activeID, level, cur_folderName, cur_folderLink, activeID_l1, activeID_l2);
 }
 else
 {
  // The itme with cur_folderID has submenu items
  writeFolderDiv_WithSubItems(cur_folderID, activeID, level, cur_folderName, cur_folderLink, activeID_l1, activeID_l2);
 }
}

///////////////////////////////////////////////////////////////////////////////
// Name:  writeFolderDiv_NoSubItems
// Description: Creates a DIV structure for all menu items in 'folderList',
//    that don't have submenu items.
///////////////////////////////////////////////////////////////////////////////
function writeFolderDiv_NoSubItems(cur_folderID, activeID, level, cur_folderName, cur_folderLink, activeID_l1, activeID_l2)
{
 if(level == 1)
 {
  // For level 1 items without sub items, write an extra container around the menu item
  writeToDocument('<div class="menumusicals_nav_l' + level + '" id="container_' + cur_folderID + '" style="padding-bottom: 0px;">');
  if(cur_folderID == activeID_l1)
  {
   // If level == 1, and the current ID equals the active ID in level 1, use the 'menumusicals_activenav' style
   // Except if the item name is empty. Then an active style is never used.
   if(getItemName(cur_folderID) != "")
   {
    writeToDocument('<div class="menumusicals_activenav" id="header_' + cur_folderID + '" style="padding-bottom: 2px; padding-top: 2px;">');
   }
   else
   {
    // For items without a name, never use the 'active' style
    writeToDocument('<div class="menumusicals_nav_l' + level + '" id="header_' + cur_folderID + '" style="padding-bottom: 2px; padding-top: 2px;">');
   }
  }
  else
  {
   // For the non-active items, use the normal style
   writeToDocument('<div class="menumusicals_nav_l' + level + '" id="header_' + cur_folderID + '" style="padding-bottom: 2px; padding-top: 2px;">');
  }
  // Write the menu item in a table
  writeMenuItemTable(imageNavArrow.src, cur_folderID, cur_folderLink, cur_folderName);
  writeToDocument('</div>');
  // Use an empty DIV section, to create a DIV with the cur_folderID
  writeToDocument('<div class="menumusicals_nav_l"' + level + ' id="' + cur_folderID + '" style="padding-bottom: 0px;">');
  writeToDocument('</div>');
  writeToDocument('</div>');
 }
 else if(level == 2 && cur_folderID == activeID_l2)
 {
  // If level == 2, and the current ID equals the active ID in level 2, use the 'menumusicals_activesubnav' style
  writeToDocument('<div class="menumusicals_activesubnav" id="' + cur_folderID + '" style="padding-bottom: 2px; padding-top: 2px;">');
  writeMenuItemTable('', cur_folderID, cur_folderLink, cur_folderName);
  writeToDocument('</div>');
 }
 else
 {
  // If level == 3, no active style is ever used
  writeToDocument('<div class="menumusicals_nav_l' + level + '" id="' + cur_folderID + '" style="padding-bottom: 2px; padding-top: 2px;">');
  writeMenuItemTable('', cur_folderID, cur_folderLink, cur_folderName);
  writeToDocument('</div>');
 }
}

///////////////////////////////////////////////////////////////////////////////
// Name:  writeFolderDiv_WithSubItems
// Description: Creates a DIV structure for all menu items in 'folderList',
//    that have submenu items.
///////////////////////////////////////////////////////////////////////////////
function writeFolderDiv_WithSubItems(cur_folderID, activeID, level, cur_folderName, cur_folderLink, activeID_l1, activeID_l2)
{
 var activeItem = false;
 var arrowImgSrc = "";
 // Write the opening DIV tag for the container for the menu item
 writeToDocument('<div class="menumusicals_nav_l' + level + '" id="container_' + cur_folderID + '" style="padding-bottom: 0px;">');
 if(level == 1)
 {
  if(cur_folderID == activeID_l1)
  {
   // Level == 1, and the current folderID equals the activeID in level 1,
   // so use the 'activenav' style. Except if the name of the item is empty, in which case
   // no active style should be used.
   if(getItemName(cur_folderID) != "")
   {
    writeToDocument('<div class="menumusicals_activenav" id="header_' + cur_folderID + '" style="padding-bottom: 2px; padding-top: 2px;">');
    activeItem = true;
   }
   else
   {
    // For items without a name, never use the 'active' style
    writeToDocument('<div class="menumusicals_nav_l' + level + '" id="header_' + cur_folderID + '" style="padding-bottom: 0px; padding-top: 0px;">');
   }
  }
  else
  {
   // Current folderID is not the activeID in level 1, so just use the normal style
   if(getItemName(cur_folderID) != "")
   {
    // For items with a name use padding for the spacing between the items
    writeToDocument('<div class="menumusicals_nav_l' + level + '" id="header_' + cur_folderID + '" style="padding-bottom: 2px; padding-top: 2px;">');
   }
   else
   {
    // For items with an empty name, don't use padding, because these items should be invisible
    writeToDocument('<div class="menumusicals_nav_l' + level + '" id="header_' + cur_folderID + '" style="padding-bottom: 0px; padding-top: 0px;">');
   }
  }
  if(cur_folderName.length != 0)
  {
   // For 1st level items with a non-empty name, use the "pijl-nav.gif" image.
   arrowImgSrc = imageNavArrow.src;
  }
 }
 else if(level == 2)
 {
  if(cur_folderID == activeID_l2)
  {
   // Level == 2, and the current folderID equals the activeID in level 2,
   // so use the 'activesubnav' style.
   writeToDocument('<div class="menumusicals_activesubnav" style="padding-bottom: 2px; padding-top: 2px;">');
   activeItem = true;
  }
  else
  {
   // If the current folderID is not the same as the activeID in level 2, just use the normal style
   writeToDocument('<div class="menumusicals_nav_l' + level + '" id="' + cur_folderID + '" style="padding-bottom: 2px; padding-top: 2px;">');
  }
  if(cur_folderName.length != 0)
  {
   // For 2nd level items, use the "pijl-nav-sub.gif" image
   arrowImgSrc = imageSubNavArrow.src;
  }
 }
 // Write the menu item in a table
 writeMenuItemTable(arrowImgSrc, cur_folderID, cur_folderLink, cur_folderName);
 // Close the DIV section
 writeToDocument('</div>');
 if (cur_folderID!=0)
 {
  // We are not yet at the beginning of the folderList array,
  // build a container for the next level
  level = level + 1;
  if(level != 3)
  {
   // Level 3 menu items do not have sub-items, so no container is needed for those items
   // Open submenu container
   writeToDocument('<div class="menumusicals_nav_l' + level + '" id="' + cur_folderID +'" style="padding-bottom: 0px;">');
  }
  for (var i=0; i<folderList[cur_folderID].length; i++)
  {
   writeFolderDiv(cur_folderID, i, level, activeID, activeID_l1, activeID_l2);
  }
  if(level != 3)
  {
   // Level 3 menu items do not have sub-items, so no container is needed for those items
   // Close submenu container
   writeToDocument('</div>');
  }
 }
 // Write the closing DIV tag for the container for the menu item
 writeToDocument('</div>');
}
 
/* disable mousebuttons */
/*var message = "This page is copyrighted by \n ";
message += "Joop van den Ende Theaterproducties"; 
function click(e) {
  if (document.all) {
    if (event.button == 2) {
      alert(message);
      return false;
    }
  }
  if (document.layers) {
    if (e.which == 3) {
      alert(message);
      return false;
    }
  }
}
if (document.layers) {
  document.captureEvents(Event.MOUSEDOWN);
}
document.onmousedown=click;*/
/* end disable mouse button */

var objPopUpWindow = null;

function PopUpWindow(URL) {
   var iWidth=480;
   var iHeight=540;
   var iLeft=window.screen.width/2 - iWidth/2;
   var iTop=window.screen.height/2 - iHeight/2 - 25;
   if (objPopUpWindow != null) {
      objPopUpWindow.close();
   }
   objPopUpWindow=window.open(URL,"_blank",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=' + iWidth + ',height=' + iHeight + ',screenX=' + iLeft + ',screenY=' + iTop + ',left=' + iLeft + ',top=' + iTop);
}

// Correctly handle PNG transparency in Win IE 5.5 or higher.
// http://homepage.ntlworld.com/bobosola. Updated 02-March-2004
function correctPNG() 
   {
   for(var i=0; i<document.images.length; i++)
      {
   var img = document.images[i]
   var imgName = img.src.toUpperCase()
   if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
      {
   var imgID = (img.id) ? "id='" + img.id + "' " : ""
   var imgClass = (img.className) ? "class='" + img.className + "' " : ""
   var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
   var imgStyle = "display:inline-block;" + img.style.cssText 
   if (img.align == "left") imgStyle = "float:left;" + imgStyle
   if (img.align == "right") imgStyle = "float:right;" + imgStyle
   if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle  
   var strNewHTML = "<span " + imgID + imgClass + imgTitle
   + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
      + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
   + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
   img.outerHTML = strNewHTML
   i = i-1
      }
      }
   }
window.attachEvent("onload", correctPNG);