$(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');
  
  $('div#recaptcha_image img').attr('alt', 'captcha');
});



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;
    }
  });
}


function popupEcard(card) {
  // if (document.all) {  // IE?
  //   var x = window.screenLeft + (document.body.clientWidth-670)/2;
  //   var y = window.screenTop + -30;
  // } else {  // Firefox
  //   var x = screenX + (outerWidth-670)/2;
  //   var y = window.screenY + 0;
  // }
  var url = '/cgi-bin/ecard.cgi?c=' + card;
  var w = window.open(url, "CrossOver", "scrollbars=0, resizable=0, width=975, height=740, status=0");
  w.focus();
}




