// Functions for use with the GLS Avenue system

// CODE FOR DROPDOWN MENUS DELETED

function setNavButton(btnName, image, className) {
  setButton(btnName, 'nav/'+image, className);
}

function toggleNavMenu(opener, state) {
  var list = opener;
  while (list && (!list.tagName || list.tagName != 'UL')) {
    list = list.nextSibling;
  }
  if (list) {
    var ls = (document.layers)?list:list.style;
    if (typeof(state)=='undefined') {
      state=(ls.display!='block');
    }
    if (state) {
      ls.display='block';
      opener.innerHTML = '<img src="'+wwwroot+'/images/admin/hoofdnav_minus.gif" border="0" alt="-">';
    } else {
      ls.display='none';
      opener.innerHTML = '<img src="'+wwwroot+'/images/admin/hoofdnav_plus.gif" border="0" alt="+">';
    }
  }
  return false;
}

// Functions to update the navigation when using partial page loads
// currentPage, currentButtonId and updateNavButton are declared and initialized
// in page templates
function updateNavPage(newPage) {
  // Update the navigation for a new page
  var id;
  if (newPage!=currentPage) {
    if (currentButtonId && updateNavButton) {
      id = currentButtonId;
      while(id) {
        updateNavButton(id, 0);
        id = findParentButtonId(id);
      }
    }
    currentButtonId=findButtonId(newPage);
    if (currentButtonId && updateNavButton) {
      id = currentButtonId;
      while(id) {
        updateNavButton(id, 1);
        id = findParentButtonId(id);
      }
    }
    currentPage=newPage;
  }
}

function replaceContainer(containerId, contentsId) {
  // Replace a container in the main template with new contents from a
  // hidden element in a partial-page-load
  var container=document.getElementById(containerId);
  var contents=document.getElementById(contentsId);
  if (container && contents) {
    container.parentNode.insertBefore(contents, container);
    container.parentNode.removeChild(container);
    contents.style.display='';
    contents.id=containerId;
  }
}


