jQuery(document).ready(function() {
    Frontpage.timeout = window.setTimeout('Frontpage.next()', 3000);
    jQuery(".pager-inner").each(function() {
        if (this.innerHTML.length === 0) {
            jQuery(this).hide();   
        }
    });
    jQuery("a.popup").click(function() {
        var height = Math.max(screen.height - 200, 600);
        var width = Math.max(screen.width - 200, 600);
        var left = Math.round((screen.width - width) / 2);
        var top = Math.round((screen.height - height) / 2);
        return !window.open(this.href, 'Popup', 'resizable=1,left=' + left + ',top=' + top + ',width=' + width + ',height=' + height);
    });
    jQuery(".shadow-anchor a").click(function() {
        jQuery(this).parents(".views-row").find(".sb-image a").click();
    });     
});

var Frontpage = {
    'current' : 1,
    'timeout' : 0,
    'next' : function() {
        window.clearTimeout(this.timeout);
        var next = this.current + 1;
        if (next > 4) {
            next = 1;
        }
            jQuery('#header-carrousel-' + this.current).fadeOut(1000, function() {} );
            jQuery('#header-carrousel-' + next).fadeIn(2000, function() {
                this.timeout = window.setTimeout('Frontpage.next()', 3000);
             });

            jQuery('#header-carroussel-nav-' + Frontpage.current).removeClass('active');
            jQuery('#header-carroussel-nav-' + next).addClass('active');
            Frontpage.current = next;

    }
};

