﻿function DynamicLoadPage(uri, history) {
	Helpers.DynamicLoadPage(uri, history);
}

function LoadScriptReference(reference) {
	Helpers.LoadScriptReference(reference);
}

function autoBindFB() {
	Helpers.AutoBindFB();
}

function AddLinks(text) {
	return Helpers.AddLinks(text);
}

function AddHash(text) {
	return Helpers.AddHash(text);
}

$(document).ready(function () {
    if ((window.location.href.indexOf("?r=1") > 0) || (window.location.href.indexOf("&r=1") > 0)) {
        //topOfPage = $("#MainPanel").position().top + 40 //(heigth of AVRO central nav);
        Helpers.TopOfPage = $(".Header").height() + 70 - 40;
        $("html,body").scrollTop(Helpers.TopOfPage);
        // TODO: [MSc] Implement animated scroll (as designed)
    }

    $('.NavTab a').each(function (i) {
        var url = $(this).attr('href');
        if (url.indexOf("?") > 0)
            $(this).attr("href", url + '&r=1');
        else
            $(this).attr("href", url + '?r=1');
    });

    $('.InternalLink').each(function (i) {
        var url = $(this).attr('href');
        if (url.indexOf("?") > 0)
            $(this).attr("href", url + '&r=1');
        else
            $(this).attr("href", url + '?r=1');
    });

    //    }

    Helpers.AutoBindFB();

    /* Footer Actions */
    if (typeof (footerItems) !== "undefined" && footerItems.length > 0) {

        var idx = Math.floor(Math.random() * (footerItems.length));

        var a = document.createElement('a');
        a.href = footerItems[idx].uri;
        a.alt = footerItems[idx].title;
        var img = document.createElement('img');
        img.src = footerItems[idx].img;
        img.alt = footerItems[idx].title;
        img.title = footerItems[idx].title;

        $(a).append(img);
        $('aside.PromoContainer').append(a);
    }

    if ($('ul.Sitemap ul.tvVandaag').children(':hidden').length == 0)
        $('ul.Sitemap ul.tvVandaag li.meer').hide();

    if ($('ul.Sitemap ul.radioVandaag').children(':hidden').length == 0)
        $('ul.Sitemap ul.radioVandaag li.meer').hide();

    /* End Footer Actions */

    $(".Header .HeaderContainer h2:empty").parents("div.HeaderContainer").css({ background: "none" });
});


