﻿function loadNewVideo(playerid, vidPath, title, recipePath) {
    var player = document.getElementById(playerid);
    player.loadNewVideo(vidPath, title, recipePath);
    scrollToTop();
}

function scrollToTop() {
    var scrollInterval = setInterval(
        function() {
            if (getCurrentYPos() < 50) {
                clearInterval(scrollInterval);
                scrollTo(0, 0);
            } else {
                scrollBy(0, -50);
            }
        },
        40
    );
}

function getCurrentYPos() {
    if (document.body && document.body.scrollTop)
        return document.body.scrollTop;
    if (document.documentElement && document.documentElement.scrollTop)
        return document.documentElement.scrollTop;
    if (window.pageYOffset)
        return window.pageYOffset;
    return 0;
}

