  var iTimeOutId = null;
  
  $(document).ready(function() {
    
    $('#div_flashvideolink').click(function() {
      window.open('flashvideo.php', 'flashvideo', 'width=800px,height=600px');
    });
    
    $('.click_goto_a').click(function() {
      document.location = $(this).find('a:first').attr('href');
    });
    
    $('.a_menuitem_top').hover(function() {
      window.clearTimeout(iTimeOutId);
      $('.div_submenu_top_container:visible').not($(this).next('.div_submenu_top_container')).slideUp(300);
      if($(this).next('.div_submenu_top_container').length > 0) {
        $(this).next('.div_submenu_top_container').slideDown(300);
      }
    }, function() {
      iTimeOutId = window.setTimeout(slideUp, 200);
    });
    
    $('.div_submenu_top_container').hover(function() {
      window.clearTimeout(iTimeOutId);
    }, function() {
      iTimeOutId = window.setTimeout(slideUp, 200);
    });
    
    // tabel met tekstcellen
    if($('#table_content').length > 0) {
      genLeesmeer('.div_content_celtekst', 106);
    }
    
    // nieuwsitems
    if($('.div_nieuwsitem').length > 0) {
      $('.a_nieuwsitem_content').lightBox({txtImage:'Foto',txtOf:'v/d'});
      genLeesmeer('.div_nieuwsitem_content', 60);
    }
    
    // boeken
    if($('.div_boek').length > 0) {
      $('.a_boek').lightBox({txtImage:'Boek',txtOf:'v/d'});
      genLeesmeer('.div_boek_omschrijving', 150);
    }
    
    // consultant
    $('.a_consultant').lightBox({txtImage:'Foto',txtOf:'v/d'});
    
    // publicatie
    $('.a_publicatie').lightBox({txtImage:'Foto',txtOf:'v/d'});
    
    // boek
    $('.a_boek').lightBox({txtImage:'Foto',txtOf:'v/d'});
    
    // websites
    $(':input[name=select_bpmsites]').change(function() {
      if($(this).val() != '') {
        window.open($(this).val());
      }
    });
    
    if($('.div_leesmeer').length > 0) {
      $('.div_leesmeer').click(function() {
        if($('.div_nieuwsitem').length > 0) {
          $('.div_leesmeer:hidden').not('.div_leesmeer_src') .each(function() {
            $(this).prev().animate({height: '60px'}, 500);
            $(this).slideDown(500);
          });
        }
        
        $(this).slideUp(500);
        $(this).prev().animate({height: $(this).prev().attr('org_height')}, 500);
      });
    }
    
  });
  
  function genLeesmeer(sContainer, iMaxHeight) {
    $(sContainer).each(function() {
      if(!$(this).children('.a_leesmeer').length > 0) {
        if($(this).outerHeight() > iMaxHeight) {
          $(this).attr('org_height', $(this).outerHeight());
          $(this).css({height: iMaxHeight+'px'});
          oLeesmeer = $('.div_leesmeer_src').clone();
          oLeesmeer.removeClass('div_leesmeer_src');
          $(this).parent().append(oLeesmeer);
        }
      }
    });
  }
  
  function slideUp() {
    $('.div_submenu_top_container:visible').slideUp(300);
  }
