$(document).ready(function() {
    $('#coda-slider-1').codaSlider({
        autoSlide: true,
        autoSlideInterval: 4000,
        autoSlideStopWhenClicked: true,
        dynamicArrows: false,
        dynamicTabs: false
    });
    
    $('#coda-slider-2').codaSlider({
        autoSlide: false,
        autoSlideInterval: 0,
        dynamicArrows: false,
        dynamicTabs: false
    });
    
    
    $("#nextnews").hide();
    $("#prenews").hide();
          
    $("#newsbox").mouseover(function(){
        var shownews = document.getElementById('newscontainer');
        if(!($(shownews.children[0]).hasClass('newscolumn'))) {
            $("#prenews").fadeTo(200, 1.0);
        }
        if(!($(shownews.children[(shownews.children.length)-1]).hasClass('newscolumn'))) {
            $("#nextnews").fadeTo(200, 1.0);
        }
    });
          
          
    $("#newsbox").mouseleave(function(){
        $("#nextnews").fadeTo(200, 0.0);
        $("#prenews").fadeTo(200, 0.0);
    });
    
    
    
    $(".defaultText").focus(function(srcc) {
        if ($(this).val() == $(this)[0].title) {
            $(this).removeClass("defaultTextActive");
            $(this).val("");
        }
    });
    
    $(".defaultText").blur(function() {
        if ($(this).val() == "") {
            $(this).addClass("defaultTextActive");
            $(this).val($(this)[0].title);
        }
    });
    
    $(".defaultText").blur();   
    
});

function shiftforward() {
    var shownews = document.getElementById('newscontainer');
    for(var i=0; (shownews.children.length - 3)>i; i++) {
        if($(shownews.children[i]).hasClass('newscolumn')) {
            $(shownews.children[i]).removeClass('newscolumn');
            $(shownews.children[i]).addClass('hidden');
            j = i+3;
            $(shownews.children[j]).removeClass('hidden');
            $(shownews.children[j]).addClass('newscolumn');
            break;
        }
    }
}
function shiftbackward() {
    var shownews = document.getElementById('newscontainer');
    for(var i=shownews.children.length; i>2; i--) {
        if($(shownews.children[i]).hasClass('newscolumn')) {
            $(shownews.children[i]).removeClass('newscolumn');
            $(shownews.children[i]).addClass('hidden');
            var j = i-3;
            $(shownews.children[j]).removeClass('hidden');
            $(shownews.children[j]).addClass('newscolumn');
            break;
        }
    }
}

          
          
function closewindow() {
    // Ta bort data som finns i topbox
    $("#shadowlayer").addClass('hidden');
    $("#topbox").addClass('hidden');
    $("#closetopbox").addClass('hidden');
    $("#oldie").addClass('hidden');
}
function openwindow(url) {
    $("#shadowlayer").removeClass('hidden');
    $("#topbox").removeClass('hidden');
    $("#closetopbox").removeClass('hidden');
    $("#topbox").attr("src",url);
}


