$(document).ready(function(){
    $('.sideButtonOrange').click(function(e){
        e.preventDefault();
        window.location = $(this).find('a').attr('href');
    });
    $('.sideButtonOrange td').hover(
        function () 
        {
            $(this).addClass('active');
        },
        function () 
        {
            $(this).removeClass("active");
        }
    );
    $('a[rel=back]').click(function(e){
        e.preventDefault();
        history.go(-1);
    });
    dblueBox302Height();
    sfHover();
    $('.basicField').click(function(){$(this).attr('value','');});
    $('.blueSlide_250_top h2 a').click(function(e){
        e.preventDefault();
        $('.blueSlide_250_content').slideToggle(200);
        $('.blueSlide_250_top').toggleClass('open');
    });
    $('#verktunnCheck').click(function(e){
        e.preventDefault();
        $('#domainSearch').submit();
    });
    $('#search').click(function(e){
        e.preventDefault();
        $('#siteSearch').submit();
    });
    $('#spyglass').click(function(e){
        e.preventDefault();
        $('#topSearch').submit();
    });
    $('a#normalNaviLink').click(function(e){
        e.preventDefault();
        $('ul#normalNavi').slideToggle(200,function(){$('ul#yearNavi').slideDown(200)});
    });
    $('a#yearNaviLink').click(function(e){
        e.preventDefault();
        $('ul#yearNavi').slideToggle(200,function(){$('ul#normalNavi').slideDown(200)});
    });
    $('a.external').click(function(e){
        window.open(this.href);
        return false;
    });

    $(function(){ 
        $('.twoCol').columnize({columns:2});
    });
    
    function dblueBox302Height(){
      var contAm = $('.contSect').length;
      var theAm = 0;
      var boxH = 0;
      var endH = 0;
      var box = 0;
      for(i=0;i<contAm;i++){
        theAm = $('#contSect_'+i+' .dblueBox302').length;
        for(u=0;u<theAm;u++){
          box = $('#contSect_'+i+' .dblueBox302 .boxContent')[u];
          boxH = $(box).height();
          if(boxH>endH){endH=boxH;}
          if(navigator.appName=='Microsoft Internet Explorer' && navigator.userAgent.split(';')[1].split('MSIE')[1]<7){endH=endH+15;}
        }  
        $('#contSect_'+i+' .dblueBox302 .boxContent').height(endH);
      }
    }


    function sfHover() {

        var sfEls = document.getElementById("topLinks").getElementsByTagName("li");
        
        for (var i=0; i<sfEls.length; i++) {
            var browser = $.browser.browser() + $.browser.version.string();
            sfEls[i].onmouseover=function() {
                if (browser == 'Internet Explorer6.0' && this.className == 'first' || browser == 'Internet Explorer6.0' && this.className == 'activefirst' ) {
                    this.className+="sfhoverIE";
                } else {
                    $(this).addClass('sfhover');
                }
            }
            sfEls[i].onmouseout=function() {
                if (browser == 'Internet Explorer6.0' && this.className == 'firstsfhoverIE' || browser == 'Internet Explorer6.0' && this.className == 'activefirstsfhoverIE' ) {
                    this.className=this.className.replace(new RegExp("sfhoverIE\\b"), "");
                } else {
                    $(this).removeClass('sfhover');
                }
            }
        }
    }
});