function onYouTubePlayerReady(playerId) {
    ytplayer = document.getElementById("ytplayer");
    ytplayer.addEventListener("onStateChange", "onytplayerStateChange");
}

function onytplayerStateChange(newState) {
    //console.log("Player's new state: " + newState);
    switch(newState) {
        case 0: $("#jsPlayMovie").fadeIn(); break;
    }
}


// JQuery loaded
$(document).ready(function() {

    // Kick start youtube player with swfobject
    swfobject.embedSWF(
        "http://www.youtube.com/e/leO6gwhmlyA?enablejsapi=1&version=3&playerapiid=ytplayer&rel=0&controls=0",
        "ytplayer",
        "853",
        "480",
        "8",
        null,
        null,
        {
            allowScriptAccess: "always",
            allowFullScreen: "true",
            wmode: "window"
        },
        { id: "ytplayer" }
    );

   $('#jsPlayMovie').click(function(e){
       $(this).slideUp();
       ytplayer.setVolume(100);
       ytplayer.playVideo();
   });

});


