// JavaScript Document
Cufon.replace('#langselectcontainer .titel, #creditsfooter, #languagemenu, #contactliggingTop', { fontFamily: 'Rockwell' });
Cufon.replace('#langselectcontainer .tekst, #contentheader h1, #contentheader ul li span, #contentHeaderLarge h1');

Cufon.replace('#mainmenu ul li ul li a', {
	hover: {
		color: '#2a1c17'
	}
});

Cufon.replace('#mainmenu ul li a', {
	hover: {
		color: '#ec008c'
	}
});

$(window).load(function () {
    var activeItem = $('#mainmenu ul li.active:first');
    var activeSubItem = $('#mainmenu ul li ul li.active:first');
    var activeContentItem = $('#contentheader ul li.active:first');

    $("#imagegallery #itemscontainer").scrollable({
        size: 1
    });

    $("#imagegallery .prevPage, #imagegallery .nextPage").click(function () { return false; });

    if ($("#imagegallery #itemscontainer #imagegallery_items div").size() < 2) {
        $("#imagegallery .prevPage, #imagegallery .nextPage").addClass('disabled');
    };

    $('#mainmenu ul li.mainlink ul').css({ 'display': 'none' });

    $('#mainmenu ul li.mainlink').hover(function () {
        if ($('ul', this).size() > 0) {
            $('ul', this).css({ 'display': 'block' });
            //$('#mainmenu ul li.active ul').css({ 'display': 'none' });
        }
    }, function () {
        if ($('ul', this).size() > 0) {
            $('ul', this).css({ 'display': 'none' });
            //$('#mainmenu ul li.active ul').css({ 'display': 'block' });
        }
    });

    $('#nederlandsselect, #engelsselect').hover(function () {
        $('#langselectcontainer').stop().animate({ bottom: "0px" }, 500);
    }, function () {
        $('#langselectcontainer').stop().animate({ bottom: "-60px" }, 500);
    });

    $('#nederlandsselect, #engelsselect').click(function () {
        window.location = $('a:first', this).attr('href');
        return false;
    });

    var targetHeight = 150;

    if ($('#contentheader ul li').size() > 0) {
        targetHeight = targetHeight - (22 * $('#contentheader ul li').size());
    }

    var spaceLeftImageGallery;
    function setContentSize() {
        /*if ($(window).height() < 700) {
        $('#contentcontainer').css({ 'height': '350px' });
        $('#content').css({ 'height': targetHeight + 'px' });
        $('#contentLarge').css({ 'height': '180px' });
        $('.jScrollPaneContainer').css({ 'height': targetHeight + 'px' });
        $('#imagegallery').css({ 'padding-bottom': '0px' });
        } else if ($(window).height() > 900) {
        $('#contentcontainer').css({ 'height': '550px' });
        $('#content').css({ 'height': (targetHeight + 200) + 'px' });
        $('#contentLarge').css({ 'height': '380px' });
        $('.jScrollPaneContainer').css({ 'height': (targetHeight + 200) + 'px' });
        $('#imagegallery').css({ 'padding-bottom': '150px' });
        } else if ($(window).height() > 1100) {
        $('#contentcontainer').css({ 'height': '650px' });
        $('#content').css({ 'height': (targetHeight + 300) + 'px' });
        $('#contentLarge').css({ 'height': '480px' });
        $('.jScrollPaneContainer').css({ 'height': (targetHeight + 300) + 'px' });
        $('#imagegallery').css({ 'padding-bottom': '250px' });
        } else {
        $('#contentcontainer').css({ 'height': '450px' });
        $('#content').css({ 'height': (targetHeight + 100) + 'px' });
        $('#contentLarge').css({ 'height': '280px' });
        $('.jScrollPaneContainer').css({ 'height': (targetHeight + 100) + 'px' });
        $('#imagegallery').css({ 'padding-bottom': '50px' });
        }*/
        if ($("#imagegallery").size() > 0) {
            spaceLeftImageGallery = $("#wrapper").offset().left + 60;
            $("#imagegallery").css({ 'position': 'fixed', 'bottom': '0', 'left': spaceLeftImageGallery + 'px' });
        }

        if ($("#footercontainer #footerleft").size() > 0) {
            if ($(window).height() > ($("#contentcontainer").outerHeight() + 350)) {
                $("#footercontainer").css({ "position": "fixed", "bottom": "0", "left": ($("#wrapper").offset().left + 355) + "px", "width": "435px" });
            } else {
                $("#footercontainer").css({ "position": "relative", "bottom": "0", "left": "0", "width": "435px" });
            }
        }
    }

    setContentSize();
    $(window).resize(function () {
        setContentSize();
    });

    $('#mainmenu ul li.mainlink').hover(function () {
        $(this).css({ 'background': 'url(images/li_active_background.png) left center no-repeat', 'color': '#2a1c17' });
        $('#mainmenu ul li.active)').css({ 'background': 'none', 'color': '#ffffff' });
    }, function () {
        $(this).css({ 'background': 'none', 'color': '#ffffff' });
        $('#mainmenu ul li.active)').css({ 'background': 'url(images/li_active_background.png) left center no-repeat', 'color': '#2a1c17' });
    });

    /*$('#mainmenu ul:not(#mainmenu ul ul)').hover(function (){
    activeItem.removeClass('active');
    Cufon.refresh();
    }, function (){
    activeItem.addClass('active');
    Cufon.refresh();
    });*/

    $('#mainmenu ul li ul li').hover(function () {
        $(this).addClass('active');
    }, function () {
        $(this).removeClass('active');
    });

    $('#mainmenu ul ul').hover(function () {
        activeSubItem.removeClass('active');
        Cufon.refresh();
    }, function () {
        activeSubItem.addClass('active');
        Cufon.refresh();
    });

    $('#contentheader ul li').hover(function () {
        $(this).addClass('active');
    }, function () {
        $(this).removeClass('active');
    });

    $('#contentheader ul li').click(function () {
        $(this).addClass('active');
        activeContentItem.removeClass('active');
        activeContentItem = $('#contentheader ul li.active:first');
    });

    $('#contentheader ul').hover(function () {
        activeContentItem.removeClass('active');
    }, function () {
        activeContentItem.addClass('active');
    });

    $("a.thumblink").fancybox({
        'transitionIn': 'fade',
        'transitionOut': 'fade',
        'speedIn': 300,
        'speedOut': 300,
        'titlePosition': 'inside',
        'overlayColor': '#000000',
        'overlayOpacity': 0.7,
        'padding': 4
    });

    $("#hiddenclicker3").fancybox({
        'scrolling': 'no',
        'titleShow': false,
        'overlayColor': '#000000',
        'overlayOpacity': 0.7,
        'onClosed': function () {
            $("#opendeurdag").hide();
        }
    });

    $("#hiddenclicker2").trigger('click');
});
