function CJL_RegisterEvent(elem, type, listener, useCapture, noAutoStart){   var proto = arguments.callee.prototype;   this.e = elem;   this.type = type;   this.cap = useCapture;   this.l = listener;   proto.start = function()   {      if( this.e.attachEvent )      {         this.e.attachEvent("on" + this.type, this.l);      }      else if( this.e.addEventListener )      {         this.e.addEventListener(this.type, this.l, this.cap);      }   }   if( ! noAutoStart )   {      this.start(elem, type, listener);   }   proto.stop = function()   {      if( this.e.detachEvent )      {          this.e.detachEvent("on" + this.type, this.l);      }      else if( this.e.removeEventListener )      {          this.e.removeEventListener(this.type, this.l, this.cap);      }   }}

function getElementsByClassName(oElm, strTagName, strClassName){    var arrElements = (strTagName == "*" && document.all)? document.all :     oElm.getElementsByTagName(strTagName);    var arrReturnElements = new Array();    strClassName = strClassName.replace(/\-/g, "\\-");    var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");    var oElement;    for(var i=0; i<arrElements.length; i++){        oElement = arrElements[i];              if(oRegExp.test(oElement.className)){            arrReturnElements.push(oElement);        }       }    return (arrReturnElements)}

function init()  {
    $('mainmenu').style.display = 'none';
    $('oudnieuws').style.display = 'none';
    $('categories').style.display = 'none';
    $('hoofdmenu').innerHTML = 'Hoofdmenu [+]';
    $('catmenu').innerHTML = 'Categorie&euml;n [+]';
    $('oudnieuwsmenu').innerHTML = 'Ouder Nieuws [+]';
  if(menustate = getCookie('menuconfig'))  {
    menustate = menustate.split('-');
    if(menustate[0] == 'o')  {
      $('mainmenu').style.display = 'block';
      $('hoofdmenu').innerHTML = 'Hoofdmenu [-]';
      } 
    if(menustate[1] == 'o')  {
      $('categories').style.display = 'block';
      $('catmenu').innerHTML = 'Categorie&euml;n[-]';
      }  else  {
      $('categories').style.display = 'none';
      $('catmenu').innerHTML = 'Categorie&euml;n[+]';
      }
    if(menustate[2] == 'o')  {
      $('oudnieuws').style.display = 'block';
      $('oudnieuwsmenu').innerHTML = 'Ouder Nieuws [-]';
      }  else  {
      $('oudnieuws').style.display = 'none';
      $('oudnieuwsmenu').innerHTML = 'Ouder Nieuws [+]';
      }
    }
  new CJL_RegisterEvent($('hoofdmenu'), "click", toggleHoofdMenu);
  new CJL_RegisterEvent($('oudnieuwsmenu'), "click", toggleOudNieuws);
  new CJL_RegisterEvent($('catmenu'), "click", toggleOnderdelen);


  aElements = $('bottomphotos').getElementsByTagName('img');
  for(i=0;i<aElements.length;i++)  {
  if(document.all)  {
    aElements[i].style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=50)';
    }
  else  {
    aElements[i].style.opacity = '0.5';
    }
    new CJL_RegisterEvent(aElements[i], 'mouseover', photoLitUp);
    new CJL_RegisterEvent(aElements[i], 'mouseout', photoLitDown);    
    }
    if(document.getElementById('adbar') && (getCookie('adbs') != 'seen')) {
      adslide = new Effect.BlindDown('adbar');
    }
  }
  
function photoLitUp()  {
  if(document.all)  {
    window.event.srcElement.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=100)';
    }
  else  {
    this.style.opacity = '1.0';
    }
  }
function photoLitDown()  {
  if(document.all)  {
    window.event.srcElement.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=50)';
    }
  else  {
    this.style.opacity = '0.5';
    }
  }
function toggleOudNieuws()  {
  if(!(theCookie = getCookie('menuconfig')))  {
    theCookie = 'c-c-c';
    }
  theCookieArray = theCookie.split('-');
  if(theCookieArray[2] == 'c')  {
    newval = 'o';
    }
  else  {
    newval = 'c';
    }
  theNewCookieValue = theCookieArray[0] + '-' + theCookieArray[1] + '-' + newval;
  setCookie('menuconfig', theNewCookieValue, '', '/', 'waterkant.net', false);
  toggleMenuBox('Ouder Nieuws', 'oudnieuwsmenu', 'oudnieuws');
  }  
function toggleOnderdelen()  {
  if(!(theCookie = getCookie('menuconfig')))  {
    theCookie = 'c-c-c';
    }
  theCookieArray = theCookie.split('-');
  if(theCookieArray[1] == 'c')  {
    newval = 'o';
    }
  else  {
    newval = 'c';
    }
  theNewCookieValue = theCookieArray[0] + '-' + newval + '-' + theCookieArray[2];
  setCookie('menuconfig', theNewCookieValue, '', '/', 'waterkant.net', false);
  toggleMenuBox('Categorie&euml;n', 'catmenu', 'categories');
  } 
function toggleHoofdMenu()  {
  if(!(theCookie = getCookie('menuconfig')))  {
    theCookie = 'c-c-c';
    }
  theCookieArray = theCookie.split('-');
  if(theCookieArray[0] == 'c')  {
    newval = 'o';
    }
  else  {
    newval = 'c';
    }
  theNewCookieValue = newval + '-' + theCookieArray[1] + '-' + theCookieArray[2];
  setCookie('menuconfig', theNewCookieValue, '', '/', 'waterkant.net', false);
  toggleMenuBox('Hoofdmenu', 'hoofdmenu', 'mainmenu');
  } 
  
function toggleMenuBox(p_sHeadContent, p_sHeader, p_sList)  {
  if($(p_sList).style.display == 'none')  {
    $(p_sHeader).innerHTML = p_sHeadContent + ' [-]';
  }
  else  {
    $(p_sHeader).innerHTML = p_sHeadContent + ' [+]';
  }
  Effect.toggle(p_sList, 'Blind', {duration:0.5});
  }


/**
 * Sets a Cookie with the given name and value.
 *
 * name       Name of the cookie
 * value      Value of the cookie
 * [expires]  Expiration date of the cookie (default: end of current session)
 * [path]     Path where the cookie is valid (default: path of calling document)
 * [domain]   Domain where the cookie is valid
 *              (default: domain of calling document)
 * [secure]   Boolean value indicating if the cookie transmission requires a
 *              secure transmission
 */
function setCookie(name, value, expires, path, domain, secure) {
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function getCookie(name) {
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    } else {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1) {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}
