$(document).ready(function() {
    $('#slideshow').cycle({
        prev:   '#prev',
        next:   '#next',
        nowrap: 1,
        timeout: 0,
        pager: '#nav',
        before: onAfter
    });

    $(".okoska").click(function(){
       $('#slideshow').cycle(parseInt($('span',$(this)).text()));
    });

    $("#scroll_pane").jScrollPane();

    $('#mainheader .bal').hover(function(){
        $(this).addClass('bal_on');
    }, function () {
        $(this).removeClass('bal_on');
    });

    $('#mainheader .jobb').hover(function(){
        $(this).addClass('jobb_on');
    }, function () {
        $(this).removeClass('jobb_on');
    });

    $('#mainheader .jobb').click(function(){
        window.location.href= $("a", $(this)).attr('href');
    });

    $('#mainheader .bal').click(function(){
        window.location.href= $("a", $(this)).attr('href');
    });
});


function onAfter()
{
  var tmp_alt = this.alt;
  $(".okoska").each(function(){
      if ($(this).text().slice(1) == tmp_alt || $(this).text().slice(2) == tmp_alt || $(this).text().slice(3) == tmp_alt)
      {
        $(this).addClass('okoska_on');
      }
      else
      {
        $(this).removeClass('okoska_on');
      }
    });
}
