$(document).ready(
  function () { startPage(); }
)

function startPage() {

  $("ul#topnav > li").each( 
    function() {
      if (!$(this).hasClass("geselecteerd")) {
        $(this).mouseover(
          function () {
            $(this).addClass('over');
            $("select").each ( function() {
              $(this).css({visibility:"hidden"});
            });
          }
        );
      }
    }
  );
  $("ul#topnav > li").mouseout(
    function () {
      $(this).removeClass('over');
      $("select").each ( function() {
        $(this).css({visibility:"inherit"});
      });
    }
  );

  $("a.bloklink").addClass('displaynone');
  $("div.klikblok").mouseover(
    function () {
      $(this).addClass('redblock');
    }
  );
  $("div.klikblok").mouseout(
    function () {
      $(this).removeClass('redblock');
    }
  );
  $("li.hidetextli").mouseover(
    function () {
      $(this).find("div.hidtext").show();
    }
  );
  $("li.hidetextli").mouseout(
    function () {
      $(this).find("div.hidtext").hide();
    }
  );
  $("div.verzenden input, fieldset.knoppen input, a.opnieuwzoeken, a.terugnaarresultaten, dd.afbeelding a img.vergrootglas, .bijdrage_reageren a, .weblog a.zoeken").mouseover(
    function () {
      $(this).fadeTo("fast", 0.8);
    }
  );
  $("div.verzenden input, fieldset.knoppen input, a.opnieuwzoeken, a.terugnaarresultaten, dd.afbeelding a img.vergrootglas, .bijdrage_reageren a, .weblog a.zoeken").mouseout(
    function () {
      $(this).fadeTo("fast", 1);
    }
  );
  $("div.klikblok").click(
    function () {
      $(this).find("a.bloklink").each( function() {
        if ($(this).hasClass("externLink")) {
          window.open($(this).attr('href'));
        }
        else location.href = $(this).attr('href');
      });
      return false;
    }
  );
  $("div.header div.weer").click(
    function () {
      window.location.href = $(this).find("a.weerlink").attr('href');
    }
  );
  $("input#Zoe").click(
    function () {
      $(this).val('');
    }
  );
  $("input#Zoe").blur(
    function () {
      if ($(this).val()=='') $(this).val('trefwoord');
    }
  );
}

function myDebug(msg) {
  //return;
  if ($("#debug").length == 0) {
    $('<div></div>').attr({
        id: 'debug'
      }).css({
          position: 'absolute',
          backgroundColor: '#dddddd',
          zIndex: '1000',
          right: '20px',
          top: '20px',
          width: '200px',
          height: 'auto'
      }).appendTo(document.body).html('<strong>DEBUG</strong><ul></ul>');
  }
  $('#debug ul').append('<li>'+msg+'</li>');
}