$(document).ready(function () {
    // Show flash.
    if ($.flash.hasVersion(10)) {
        $('#actie-kader').flash({
            swf: '/_swf/Sausshot.swf',
            width: 997,
            height: 420,
            id: 'swfSausshot',
            params: {
                wmode: 'transparent'
            }
        });
    } else {
        $('#noFlash').show();
    }

    // Meer/Minder uitleg toggle
    var meerUitleg = $("#meer-uitleg");
    var meerUitlegButton = $("#meer-uitleg-button");
    meerUitleg.hide();
    meerUitlegButton.click(function () {
        var html = meerUitlegButton.html();
        if (html.trim) html = html.trim();

        if (html == "Meer uitleg") {
            meerUitlegButton.html("Minder uitleg");
            $('#meer-uitleg div.bullet, #meer-uitleg div.bullet2').show(200);
            meerUitleg.animate({
                height: 320
            }, {
                duration: 1000
            });
            $("html, body").animate({
                scrollTop: meerUitleg.offset().top
            }, {
                duration: 1000, easing: "jswing"
            });
        } else {
            meerUitlegButton.html("Meer uitleg");
            $('#meer-uitleg div.bullet, #meer-uitleg div.bullet2').hide(200);
            meerUitleg.animate({
                height: 0
            }, {
                duration: 1000
            });
            $("html, body").animate({
                scrollTop: 0
            }, {
                duration: 1000, easing: "jswing"
            });
        }
    });
    $('#contentSubBanner').click(function () {
        $("#contentMenu li:first").click();
        $("#meer-uitleg-button").html("Meer uitleg").click();
    });

    // Menu buttons -> show pages
    $("#p-walibi, #p-actiecodes").hide();
    $("#contentMenu li").click(function (e) {

        e.preventDefault();
        e.stopPropagation();

        var cl = this.className;

        $(".p").hide();
        $("#p-" + cl).show();

        $("#contentMenu a").removeClass();
        $("li." + cl + " a").addClass("active");

        $("html, body").animate({
            scrollTop: $('#contentRight').offset().top
        }, {
            duration: 1000, easing: "jswing"
        });

        return false;

    });


    // Actievoorwaarden dialog
    $('#actievoorwaarden a').each(function () {
        var $link = $(this);
        var $dialog = $('<div></div>')
				.load($link.attr('href') + ' #content')
				.dialog({
				    autoOpen: false,
				    title: $link.attr('title'),
				    width: 600
				});

        $link.click(function () {
            $dialog.dialog('open');

            return false;
        });
    });
});

function ShowVoucher(strKey) {
    //$("#ifVoucher").attr("src", "/handlers/WalibiVoucherHandler.ashx?Key=" + strKey);
    $("#hrefVoucher").attr("href", "/handlers/WalibiVoucherHandler.ashx?Key=" + strKey);
    $("#voucher").dialog({
        autoOpen: false,
        title: "Kortingsvoucher",
        width: 600,
        resizable: false
    });
    $("#voucher").dialog('open');
}
