$(document).ready(function(){
/* $('ul.kockak').each(function(){
  $(this).height(Math.ceil($('li', this).length / 5) * $('li', this).outerHeight({margin:true}));
 });
 
 $('dl.kockak').each(function(){
  var sum = 0;
  
  $('dt', this).each(function(){
   sum += $(this).outerHeight();
  });
  
  $(this).height(sum + 5 * ($('dt', this).length - 1));
//  $(this).height((sum + 3) * ($('dt', this).length - 1));
 });*/
 
 $('ul.kockak li').hover(function(){
  $(this).addClass('hover');
 }, function(){
  $(this).removeClass('hover');
 });
 
 $('dl.kockak dt:not([class~="nohover"])').mouseover(function(){
  $(this).addClass('hover');
  $(this).next().addClass('hover');
 }).mouseout(function(){
  $(this).removeClass('hover');
  $(this).next().removeClass('hover');
 });
 
 $('dl.kockak dd:not([class~="nohover"])').mouseover(function(){
  $(this).addClass('hover');
  $(this).prev().addClass('hover');
 }).mouseout(function(){
  $(this).removeClass('hover');
  $(this).prev().removeClass('hover');
 }).click(function(){
  var a;
  
  if((a = $(this).prev().find('a')).attr('href')){
   if(a.attr('target'))
    window.open(a.attr('href'), a.attr('target'));
   else if(a.attr('href').match(/^http:\/\//i)
        || a.attr('href').match(/^mailto:/i)
        || a.attr('href').match(/^\//))
    window.location = a.attr('href');
   else
    window.location = $('head base').attr('href')+a.attr('href');
  }
 });
 
 $('dl.kockak dt, ul.kockak li').click(function(){
  var a = $(this).find('a');
  
  if(!$(this).hasClass('nohover')
  && a.length
  && a.attr('href')){
   if(a.attr('target'))
    window.open(a.attr('href'), a.attr('target'));
   else if(a.attr('href').match(/^http:\/\//i)
        || a.attr('href').match(/^mailto:/i)
        || a.attr('href').match(/^\//))
    window.location = a.attr('href');
   else
    window.location = $('head base').attr('href')+a.attr('href');
  }
 });
});
