$(document).ready(function() {

    //Set default open/close settings
    $('.acc_container').hide();
    //Hide/close all containers
    $('.acc_trigger:first').addClass('active').next().show();
    //Add "active" class to first trigger, then show/open the immediate next container
    //On Click
    $('.acc_trigger').click(function() {
        if ($(this).next().is(':hidden')) {
            //If immediate next container is closed...
            $('.acc_trigger').removeClass('active').next().slideUp();
            //Remove all "active" state and slide up the immediate next container
            $(this).toggleClass('active').next().slideDown();
            //Add "active" state to clicked trigger and slide down the immediate next container
        }
        return false;
        //Prevent the browser jump to the link anchor
    });

    // Hide "Vedlegg" if they are empty
    if ($('#attachments').find('span').length === 0) {
        $('#attachments').hide();
    };
    
    // Create tabs for subpages
    $(document).ready(function() {
      $("#tabs").tabs();
    });
    

    $("#featured").tabs({
        fx: {
            opacity: "toggle",
            duration: 1000,
            easing: "easeinout"
        }
    }).tabs("rotate", 5000, true);
    
    $("#featured ul.ui-tabs-nav li.ui-tabs-nav-item a, #featured").click(function(event, ui) { 
            var selected = $("#featured").tabs("option", "selected");
            var url = $("#featured").data("url-"+selected);
            if (url) {
                location.href = url;
            }
        });

    //$("a[href$='.pdf']").addClass("pdf");
    $("a[href*='lovdata.no']").addClass("paragraf");

    $("ul.thumb li").hover(function() {
        $(this).css({
            'z-index': '10'
        });
        /*Add a higher z-index value so this image stays on top*/
        $(this).find('img').addClass("hover").stop()
        /* Add class of "hover", then stop animation queue buildup*/
        .animate({
            marginTop: '-50px',
            /* The next 4 lines will vertically align this image */
            marginLeft: '-40px',
            top: '30%',
            left: '20%',
            width: '143px',
            /* Set new width */
            height: '108px',
            /* Set new height */
            padding: '0px'
        },
        300);
        /* this value of "200" is the speed of how fast/slow this hover animates */

    },
    function() {
        $(this).css({
            'z-index': '0'
        });
        /* Set z-index back to 0 */
        $(this).find('img').removeClass("hover").stop()
        /* Remove the "hover" class , then stop animation queue buildup*/
        .animate({
            marginTop: '0',
            /* Set alignment back to default */
            marginLeft: '0',
            top: '0',
            left: '0',
            width: '112px',
            /* Set width back to default */
            height: '86px',
            /* Set height back to default */
            padding: '0px'
        },
        400);
    });



});



























