Youtube Iframe: onYouTubePlayerAPIReady() not called

onYouTubePlayerAPIReady should be on the window object.

try:

window.onYouTubePlayerAPIReady = function() {
        alert('called onYouTubePlayerAPIReady');
        ytIframeplayer = new YT.Player('browser', {
             events: {
                "onStateChange": stopCycle
             }
    });
}

It seems like you're not closing the functions off correctly.

The last } is closing off onYouTubePlayerAPIReady(), not dispose_ytplayer().

Fixed code:

function dispose_ytplayer() {
    (function(){
        var s = document.createElement("script");
        s.src = "http://www.youtube.com/player_api";
        var before = document.getElementsByTagName("script")[0];
        before.parentNode.insertBefore(s, before);
    })();

    alert('called yt_dispose');

    var ytIframeplayer;

    function onYouTubePlayerAPIReady() {
        alert('called onYouTubePlayerAPIReady');
        ytIframeplayer = new YT.Player('browser', {
            events: {
                "onStateChange": stopCycle
            }
        });
    }
}