﻿jQuery.noConflict();
(function ($) {
    $(document).ready(function () {
        Cufon.replace('#editiedatum', { fontFamily: 'swiss721black', textShadow: '1px 1px #ffffff' });
        Cufon.replace('#editie:not(span)', { fontFamily: 'swiss721' });
        Cufon.replace('#editie span', { fontFamily: 'swiss721black' });
        Cufon.replace('#mainmenu li', { fontFamily: 'swiss721condensedbold', hover: { color: "#000000"} });
        Cufon.replace('#resultatentabel thead', { fontFamily: 'swiss721condensedbold' });
        Cufon.replace('#inschrijvingmenu h2', { fontFamily: 'dinblack', textShadow: '1px 1px #f27070' });
        Cufon.replace('#reserveer h2', { fontFamily: 'DINBold', textShadow: '1px 1px #fee096' });
        Cufon.replace('.contentitemtitle, .articletitle', { fontFamily: 'swiss721bold' });
        Cufon.replace('#submenu h2', { fontFamily: 'swiss721bold', textShadow: '1px 1px #000000' });

        var $currentActiveItem = $("#mainmenu li.active");
        var $currentActiveSubItem = $("#submenu li.active");

        $("#mainmenu li a, #submenu li").hover(function () {
            if (!$(this).hasClass("active")) {
                $(this).addClass("active");
            }
        }, function () {
            $(this).removeClass("active");
        });

        $("#mainmenu").hover(function () {
            $currentActiveItem.removeClass("active");
            Cufon.refresh('#mainmenu li');
        }, function () {
            $currentActiveItem.addClass("active");
            Cufon.refresh('#mainmenu li');
        });

        $("#submenu").hover(function () {
            $currentActiveSubItem.removeClass("active");
        }, function () {
            $currentActiveSubItem.addClass("active");
        });

        $("#videocontainer .video").fadeTo(0, 0.5).hover(function () {
            $(this).stop().fadeTo(250, 1);
        }, function () {
            $(this).stop().fadeTo(250, 0.5);
        });

        $("#headerbgcontainer").cycle({
            fx: 'fade'
        });

        $("a.videopoplink").fancybox({
            'speedIn': 300,
            'speedOut': 300,
            'overlayOpacity': 0.8,
            'overlayColor': '#000000',
            'titlePosition': 'inside',
            'padding': 4,
            'width': 640,
            'height': 368,
            'centerOnScroll': true,
            'type': 'iframe'
        });

        $('#aankomst').datepicker({
            showOn: 'both',
            buttonImage: 'images/reserveerDatePickerBtn.png',
            buttonImageOnly: true,
            dateFormat: 'dd-mm-yy',
            firstDay: 1,
            onSelect: function (dateStr) {
                var d = $.datepicker.parseDate('dd-mm-yy', dateStr);
                d.setDate(d.getDate() + 1);
                $('#vertrek').datepicker('setDate', d);
            }
        });

        $('#vertrek').datepicker({
            showOn: 'both',
            buttonImage: 'images/reserveerDatePickerBtn.png',
            buttonImageOnly: true,
            dateFormat: 'dd-mm-yy',
            firstDay: 1
        });
    });

    $(window).load(function () {
        var targetSponsorHeight = 0;

        $("#gallerysponsorcontainer div").each(function () {
            if ($(this).height() > targetSponsorHeight) {
                targetSponsorHeight = $(this).height();
            }
        });

        $("#gallerysponsorcontainer").cycle({
            fx: 'scrollUp'
        }).css({ "height": targetSponsorHeight + "px" });

        var min = 295;

        $(window).scroll(function () {
            var scrollTop = $(window).scrollTop()

            if ($(window).height() < $("#rightcontentcontainer").height()) {
                if (scrollTop < min)
                    $('#rightcontentcontainer').css({ top: "0px" });
                else
                    $('#rightcontentcontainer').css({ top: ((scrollTop - min) + ($(window).height() - $("#rightcontentcontainer").height()) - 20) + "px" });
            } else {
                if (scrollTop < min)
                    $('#rightcontentcontainer').css({ top: "0px" });
                else
                    $('#rightcontentcontainer').css({ top: (scrollTop - min) + "px" });
            }
        });
    });
    
})(jQuery);

function submitmyform(form) {
    jQuery.fancybox({ href: form.action + '?' + jQuery(form).serialize(), type: 'iframe', width: 550, height: 550, overlayColor: "#000000", centerOnScroll: true });
    return false;
}
