Math.seedrandom();function loadscript(b,c){var a=document.createElement("script");a.src=b+"&alt=json-in-script&callback="+c;a.type="text/javascript";document.body.parentNode.appendChild(a)}function load_playlist(a){loadscript(a+"&max-results=50","showPlayList")}function load(){if(swf){var a={allowScriptAccess:"always"};var b={id:"myytplayer"};swfobject.embedSWF("http://www.youtube.com/playlist?list=PL80AA0A57395705B9","ytapiplayer",vwidth,vheight,"8",null,null,a,b)}}var loading_playlist=1;var next_video;var videos=[];var video_meta={};var related_timer;function showPlayList(c){var o=c.feed;var g=o.entry||[];for(var d=0;d<g.length;d++){var m=g[d];var l=m.title.$t;var a=m.media$group.yt$videoid.$t;var n=undefined;for(var b=0;b<m.link.length;b++){var k=m.link[b];if(k.rel=="http://gdata.youtube.com/schemas/2007#video.related"){n=k.href;break}}var f;try{f=m.app$control.yt$state.$t}catch(h){}videos.push(a);video_meta[a]={title:l,related:n,error_reason:f}}for(var b=0;b<o.link.length;b++){var k=o.link[b];if(k.rel=="next"){progress_message(document.createTextNode("Loading more parts..."));progress_message(document.createElement("br"));setTimeout('loadscript("'+k.href+'", "showPlayList")',1000);return}}if(loading_playlist<playlisturls.length){loading_playlist++;progress_message(document.createTextNode("Loading playlist "+loading_playlist+"..."));progress_message(document.createElement("br"));setTimeout('load_playlist("'+playlisturls[loading_playlist-1]+'")',1000);return}progress_message(document.createTextNode("Ready. If the video doesn't start try reloading the page."));progress_message(document.createElement("br"));progress_message(document.createElement("br"));randomize_videos();document.getElementById("nextbutton").focus();next(embed&&!autoplay)}function randomize_videos(){videos=shuffle(videos);next_video=0}function shuffle(d){var a,c,b=d.length;if(b){while(--b){c=Math.floor(Math.random()*(b+1));a=d[c];d[c]=d[b];d[b]=a}}return d}function onYouTubePlayerReady(a){ytplayer=document.getElementById("myytplayer");try{ytplayer.addEventListener("onStateChange","onytplayerStateChange");ytplayer.addEventListener("onError","onytplayerError");load_playlist(playlisturls[0])}catch(b){window.location.href=window.location.href+"&swf=yes"}}function onytplayerStateChange(a){if(a==0){if(is_playlist_paused()){ytplayer.playVideo(0)}else{setTimeout("next()",1000)}}}function onytplayerError(a){setTimeout("next()",1000);insert_unplayable()}function next(a){if(next_video==videos.length){if(document.getElementById("repeatplaylist").checked){reshuffle()}else{alert("No more videos in playlist. Try the Reshuffle button.")}return}document.getElementById("previousbutton").disabled=next_video==0;var c=videos[next_video++];try{if(a){ytplayer.cueVideoById(c)}else{ytplayer.loadVideoById(c)}}catch(b){next_video--;onytplayerError()}document.getElementById("videotitle").innerHTML=video_meta[c].title;document.getElementById("videosleft").innerHTML="("+(videos.length-next_video)+" more)";document.getElementById("pauseplaylist").innerHTML=pause_playlist_text;document.getElementById("nextvideo").innerHTML="Next: "+(next_video==videos.length?"-":video_meta[videos[next_video]].title);document.title=video_meta[c].title;if(embed){return}if(video_meta[c].related){document.getElementById("related").innerHTML="loading...";clearTimeout(related_timer);related_timer=setTimeout('loadscript("'+video_meta[c].related+'", "show_related")',5000)}else{document.getElementById("related").innerHTML="No related videos"}}function previous(){next_video-=2;next()}function reshuffle(){randomize_videos();next()}function is_playlist_paused(){return document.getElementById("pauseplaylist").innerHTML!=pause_playlist_text}function pause_playlist(){document.getElementById("pauseplaylist").innerHTML=(is_playlist_paused()?pause_playlist_text:"Resume playlist")}function show_related(e){var n=e.feed;var g=n.entry||[];var h="";for(var f=0;f<g.length;f++){var m=g[f];var l=m.title.$t;var c=m.media$group.yt$videoid.$t;var b;if(c in video_meta){continue}for(var d=0;d<m.link.length;d++){var k=m.link[d];if(k.rel=="alternate"){b=k.href;break}}var a=m.media$group.media$content;if(!a){continue}var k='<a href="'+b+'" onclick="ytplayer.stopVideo()" target="_blank">';h+=k+l+"</a> ("+seconds_to_minutes(a[0].duration)+")<br/>"+k+'<img src="'+m.media$group.media$thumbnail[0].url+'"/></a><br/>'}document.getElementById("related").innerHTML=h}function seconds_to_minutes(a){var b=Math.floor(a/60);a=a%60;return(b<10?"0"+b:b)+":"+(a<10?"0"+a:a)}var unplayable_ul;function insert_unplayable(){if(!unplayable_ul){var b=document.createElement("h2");b.innerHTML="Not playable videos";document.getElementById("unplayable_li").appendChild(b);unplayable_ul=document.createElement("ul");document.getElementById("unplayable_li").appendChild(unplayable_ul)}var a=document.createElement("li");var c=video_meta[videos[next_video-1]];a.innerHTML=c.title+"<br/>"+(c.error_reason?"<i>"+c.error_reason+"</i><br/>":"")+'<a href="http://www.youtube.com/results?aq=f&search_query='+encodeURIComponent(c.title)+'" target="_blank">search for alternates</a>';if(unplayable_ul.firstChild){unplayable_ul.insertBefore(a,unplayable_ul.firstChild)}else{unplayable_ul.appendChild(a)}}function progress_message(a){if(!embed){document.getElementById("video").appendChild(a)}};
