var reservationButtonSpeed = 2000;
var quotesShowSpeed = 2000;
var quotesScrollSpeed = 60;
function carouselInit(carousel)
{
    $('div.acties_slider > div.slide_prev > a').bind('click', function(){
        carousel.prev();
        return false;
    });
    $('div.acties_slider > div.slide_next > a').bind('click', function(){
        carousel.next();
        return false;
    });
}
$(function(){
    $('div.block, div.block2, div.block3').each(function(i, obj){
        obj = $(this);
        var head = $('div.head', obj);
        var link = $('span.bottom-link-box', obj);
        $('div.text', obj).height(336 - (head.length == 1 ? (head.height() + 6) : 0) + (link.length == 1 ? 0 : 24));
    });
    $('div.extras_block').each(function(i, obj){
        obj = $(this);
        var head = $('div.head', obj);
        $('div.content', obj).height(330 - (head.length == 1 ? head.height() : 0));
    });
    $('div.bookmark').slideDown(reservationButtonSpeed);
    var quotes = $('div.quote');
    if(quotes.length == 1)
    {
        var text = $('div.scrolling-text', quotes);
        text.hide();
        quotes.fadeIn(quotesShowSpeed, function(){
            text.show();
            quotes.SetScroller({
                velocity: quotesScrollSpeed,
                direction: 'horizontal',
                startfrom: 'right',
                loop: 'infinite',
                movetype: 'linear',
                onmouseover: 'pause',
                onmouseout: 'play',
                onstartup: 'play'
            });
        });
    }
    var photoPlayer = $('ul.photolist');
    if(photoPlayer.length == 1)
    {
        $('li a.lightbox', photoPlayer).lightBox();
        $('li a:not(.lightbox)', photoPlayer).click(function(event){
            event.preventDefault();
            var parent = $(this).parent('li');
            var next = parent.nextAll('li:has(a.lightbox)');
            if(next.length > 0)
            {
                $('a.lightbox', next.eq(0)).click();
            }
            else
            {
                var prev = parent.prevAll('li:has(a.lightbox)');
                if(prev.length > 0)
                {
                    $('a.lightbox', prev.eq(prev.length - 1)).click();
                }
            }
        });
    }
    photoPlayer = $('div.acties_belt > ul');
    if(photoPlayer.length == 1)
    {
        photoPlayer.jcarousel({
            scroll: 1,
            initCallback: carouselInit,
            buttonNextHTML: null,
            buttonPrevHTML: null
        });
    }
    $('a#disclaimer-show').click(function(event){
        event.preventDefault();
        $('div.footer').after('<div class="greyover"></div>');
        $('div.greyover').show();
        $('div#disclaimer-popup').show();
    });
    $('a.close').click(function(event){
        event.preventDefault();
        $('div.greyover').hide().remove();
        $(this).parent('div.popup-container').hide();
    })
    var location = window.location.href.replace(/#(.*)$/, '');
    $('a[href^="#"]').each(function(){
        var el = $(this);
        var href = location + el.attr('href').replace('/#.*/i', '');
        el.attr('href', href);
    });
});
