var namebelt = { time: 5000, duration: 2000 };
var fncScrollName = function() {
    if(namebelt.pos <= namebelt.max)
    {
        namebelt.pos = 0;
        $('#namebelt').css('marginLeft', '0px');
    }
    namebelt.pos -= 140;
    $('#namebelt').animate({marginLeft : namebelt.pos + 'px'}, namebelt.duration);

    

    setTimeout('fncScrollName()', namebelt.time);
}

var fncKeepAlive = function() {
    $.get('/keepalive', function(data) {
       setTimeout('fncKeepAlive()', 60000);
    });
}


$(document).ready(function(){
	var curLoc = 0;
        var maxLoc = 115 * 4;

        $('a.album_image').each(function() {
           maxLoc -= 115;
        });

        if(maxLoc > 0) maxLoc = 0;

        if(curLoc >= 0) {
            curLoc = 0;
            $('a.album_left').hide();
        }
        if(curLoc <= maxLoc)
        {
            curLoc = maxLoc;
            $('a.album_right').hide();
        }

        $('div#albumscroll').css({ width : (0 - maxLoc + (115 * 4)) + 'px'});

	$('a.album_right').click(function(e) {
            e.preventDefault();
            curLoc -= 115;
            if(curLoc <= maxLoc)
            {
                curLoc = maxLoc;
                $('a.album_right').hide();
            }
            $('a.album_left').show();
            if(curLoc >= 0) {
                curLoc = 0;
                $('a.album_left').hide();
            }
            $('div#albumscroll').animate({ 'marginLeft' : curLoc +'px' });
        });
	$('a.album_left').click(function(e) {
            e.preventDefault();
            curLoc += 115;
            if(curLoc >= 0) {
                curLoc = 0;
                $('a.album_left').hide();
            }
            $('a.album_right').show();
             if(curLoc <= maxLoc)
            {
                curLoc = maxLoc;
                $('a.album_right').hide();
            }

            $('div#albumscroll').animate({ 'marginLeft' : curLoc +'px' });
        });

        $('a[rel*=album_item]').fancybox();


        $('a.subscribe').click(function(e) {
            e.preventDefault();
            $('form#subscribe_newsletter').submit();
        });

        $('form#form_newsletter').find('input#email').focus(function() {
            $(this).css('border', '1px solid #cccccc');
        });

        $.get('/nameticker', function(data) {
            $('#namebelt').html(data);
            namebelt.max = 0;
            $('#namebelt .name').each(function() {
               namebelt.max -= 140;
            });
            $('#namebelt').html(data+data);
            namebelt.pos = 0;
            
            $('#namebelt').css('width', (0 - namebelt.max) * 3);
            setTimeout('fncScrollName()', namebelt.time);
        });

        fncPreloadImage = function(url) {
            $('#wrapper').after('<img src="' + url + '" width="0" height="0" />');
        };

        fncPreloadImage('/images/buttons/blue-small-glow.png');
        fncPreloadImage('/images/buttons/blue-tiny-glow.png');
        fncPreloadImage('/images/buttons/green-large-glow.png');
        fncPreloadImage('/images/buttons/green-small-glow.png');
        fncPreloadImage('/images/buttons/grey-small-glow.png');
        fncPreloadImage('/images/buttons/orange-large-glow.png');
        fncPreloadImage('/images/buttons/orange-small-glow.png');
        fncPreloadImage('/images/buttons/gvb-glow.png');
        fncPreloadImage('/images/buttons/locations-glow.png');
        fncPreloadImage('/images/buttons/newsletter-glow.png');
        fncPreloadImage('/images/buttons/theorie-glow.png');
        fncPreloadImage('/images/buttons/vip-glow.png');

        $('#searchfield').focus(function() {
            if($(this).val() == 'Zoek') $(this).val('');
        }).blur(function() {
            if($(this).val() == '') $(this).val('Zoek');
        }).keyup(function() {
            $.post('/zoeken/' + escape($(this).val()), {  ajaxget : 'content' }, function(data) {
               $('#content').html(data);
            });
        });

        $('a.header_open').click(function(e) {
            if(document.location.href == $(this).attr('href') || document.location.pathname == $(this).attr('href')) {
                e.preventDefault();
                if($(this).hasClass('header_open')) {
                    $(this).removeClass('header_open');
                    $(this).parent().find('ul').removeClass('submenu_open');
                    $(this).parent().find('ul').slideUp();
                }
                else {
                    $(this).addClass('header_open');
                    $(this).parent().find('ul').addClass('submenu_open');
                    $(this).parent().find('ul').slideDown();
                }
            }
        })

	
});

$(document).ready(function(){
	var curLoc = 0;
        var maxLoc = 152 * 3;

        $('a.video_image').each(function() {
           maxLoc -= 152;
        });

        if(maxLoc > 0) maxLoc = 0;

        if(curLoc >= 0) {
            curLoc = 0;
            $('a.video_left').hide();
        }
        if(curLoc <= maxLoc)
        {
            curLoc = maxLoc;
            $('a.video_right').hide();
        }

        $('div#videoscroll').css({ width : (0 - maxLoc + (152 * 3)) + 'px'});

	$('a.video_right').click(function(e) {
            e.preventDefault();
            curLoc -= 152;
            if(curLoc <= maxLoc)
            {
                curLoc = maxLoc;
                $('a.video_right').hide();
            }
            $('a.video_left').show();
            if(curLoc >= 0) {
                curLoc = 0;
                $('a.video_left').hide();
            }
            $('div#videoscroll').animate({ 'marginLeft' : curLoc +'px' });
        });
	$('a.video_left').click(function(e) {
            e.preventDefault();
            curLoc += 152;
            if(curLoc >= 0) {
                curLoc = 0;
                $('a.video_left').hide();
            }
            $('a.video_right').show();
             if(curLoc <= maxLoc)
            {
                curLoc = maxLoc;
                $('a.video_right').hide();
            }

            $('div#videoscroll').animate({ 'marginLeft' : curLoc +'px' });
        });

//        $('a[rel*=video_item]').fancybox();

        $('.video_image').click(function() {
            $('.mainvid').html(' <object width="538" height="327"><param name="movie" value="http://www.youtube.com/v/' + $(this).attr('href').substr(1) + '&hl=nl_NL&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/' + $(this).attr('href').substr(1) + '&hl=nl_NL&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="538" height="327"></embed></object>'

                );
        });



});
