$(document).ready(function() {
  populateElement('#zoekterm', "zoeken");
  populateElement('#zoekwoord', 'typ uw zoekwoord(en)');
  
  $('div#zoek label#zoek').hide();
  $('div.form_kennisbank span.check_all').show();
  
  
  $('td label, div.thema_checkboxes label, span.checkbox_label').click(function() {
    var check = $(this).prev('input.checkbox, input[name=check_all]').get(0);
    check.checked = !check.checked;
    var all = $(this).prev('input[name=check_all]');
    if (all.length) {
      var all = all.get(0);
      $('input.checkbox:not(.inbox1)').each(function() {
        this.checked = all.checked;
      });
    }
  });
  
  $('input.checkbox').click(function() {
    var n = 0;
    $('input.checkbox').each(function() { if (this.checked) n++ });
    //$('input[name=check_all]').attr('checked', (n == 6));
  });
  
  $('input[name=check_all]').click(function() {
    var all = this;
    $('input.checkbox:not(.inbox1)').each(function() {
      this.checked = all.checked;
    });
  });
  
  $('tr:even').addClass('even');
});



function populateElement(selector, defvalue) {
  $(selector).each(function() {
    if($.trim(this.value) == "") {
      this.value = defvalue;
    }
  });

  $(selector).focus(function() {
    if(this.value == defvalue) {
      this.value = "";
    }
  });
  
  $(selector).blur(function() {
    if($.trim(this.value) == "") {
      this.value = defvalue;
    }
  });
 }



