var Filmhuset = {
};

Filmhuset.base = function() {
    return {
        init: function() {
            if (window.screen.height > 1030) {
                $('#startpage #main-content').css('marginTop', '300px');
            }
            if ($('#startpage').length > 0) {
                Filmhuset.base.backgroundCarouselHandler(0);
            }
        },
        backgroundCarouselHandler: function(showIndex) {
            var carouselLength = arrayOfBackgrounds.length;
            $('#img-wrap2 img').animate({ opacity: 0 }, 0);
            var tempIndex = showIndex;
            if (carouselLength <= tempIndex) {
                Filmhuset.base.animateFlow(arrayOfBackgrounds[0], 0);
            }
            else {
                Filmhuset.base.animateFlow(arrayOfBackgrounds[tempIndex], tempIndex);
            }
        },
        animateFlow: function(nextBackground, tempIndex) {
            var fadeInTime = 10000;
            var holdTime = 7000;
            
            $('#img-wrap2 img').attr('src', nextBackground);

            $('#img-wrap2 img').animate({
                opacity: 1
            }, fadeInTime, function() {
                $('#img-wrap1 img').attr('src', nextBackground);
                $('#img-wrap2 img').animate({ opacity: 0 }, 100);
                window.setTimeout('Filmhuset.base.backgroundCarouselHandler(' + (tempIndex + 1) + ')', holdTime);
            });
        }
    };
} ();
$(document).ready(Filmhuset.base.init);

Filmhuset.equalheights = function() {
    return {
        init: function() {
        $('#main-content .section').each(function() {                
                try{
                    $(this).equalHeights();                
                }catch(ex){}
            });           
        }
    };
} ();
$(window).load(Filmhuset.equalheights.init);

