YOUTUBES=7;(function(c){c.fn.shuffle=function(){if(!shufflestart){shufflestart=!0;var b=this.get(),d=c.map(b,function(){var d=Math.floor(Math.random()*b.length),h=c(b[d]).clone(!0)[0];b.splice(d,1);return h});this.each(function(b){c(d[b]).hide();c(this).fadeOut(200,function(){c(this).replaceWith(c(d[b]));c(d[b]).fadeIn(200,function(){shufflestart=!1})})});1<songs.getNumber()&&songs.burnUrl();return c(d)}}})(jQuery);function execute_function(c,b,d){return function(){c.apply(b,d)}}
function tube_top(c,b){var d=b.split(/\band\b|\bthe\b|\ba\b|\(|\)|\-/i).join(""),d=d.split(/\b\s+\b/),e=c.split(/\band\b|\bthe\b|\ba\b|\(|\)|\-|\bdemo\b/i).join("");return d[0]+" "+("undefined"==typeof d[1]?"":d[1]+" ")+("undefined"==typeof d[2]?"":d[2]+" ")+e.split(/\bfeat\./i)[0]}
function Songs(){function c(){f[globalindex][6].length-2!=f[globalindex][6][f[globalindex][6].length-1]?f[globalindex][6][f[globalindex][6].length-1]++:f[globalindex][6][f[globalindex][6].length-1]=0;player.loadVideoById(f[globalindex][6][f[globalindex][6][f[globalindex][6].length-1]].match(/=(.+?)\&/,"$1")[1])}function b(a){!flickq&&"undefined"!=typeof player&&"undefined"!=typeof player.pauseVideo&&player.pauseVideo();if(0==a.data)if(1==loop||2==loop&&1==g.getNumber())player.playVideo();else{var a=
g.getOrderedIndices(),b=$.inArray(last_index,a);b!=a.length-1?g.select(a[b+1],0):2==loop&&g.select(a[0],0)}else l&&(l=!1,player.cueVideoById(f[k][6][f[k][6][f[k][6].length-1]].match(/=(.+?)\&/,"$1")[1]),player.setPlaybackQuality("medium"),player.playVideo())}function d(a){a.target.setPlaybackQuality("medium");a.target.playVideo()}function e(){flickq?$("#tubecontainer").animate({right:"-16em"},200):$("#tubecontainer").animate({right:"0em"},200);flickq=!flickq}function h(a){globalindex=a;flickq||e();
$("iframe#tube").length?"undefined"!=typeof player&&"undefined"!=typeof player.getVideoUrl&&(player.getVideoUrl().match(/(\?|\&)v=(.+?)(\&|\b)/,"$1")[2]!=f[a][6][f[a][6][f[a][6].length-1]].match(/=(.+?)\&/,"$1")[1]?(player.cueVideoById(f[a][6][f[a][6][f[a][6].length-1]].match(/=(.+?)\&/,"$1")[1]),player.setPlaybackQuality("medium"),player.playVideo(),l=!0,k=a):"undefined"!=typeof player&&"undefined"!=typeof player.playVideo&&player.playVideo()):(onYouTubePlayerAPIReady=function(){player=new YT.Player("tube",
{height:"100%",width:"100%",videoId:f[a][6][f[a][6][f[a][6].length-1]].match(/=(.+?)\&/,"$1")[1],events:{onReady:d,onStateChange:b,onError:c}})},$.getScript("http://www.youtube.com/player_api"))}function m(){return $.map(f,function(a){return"undefined"!=typeof a?a[7]:-1})}var g=this,f=[],l=!1,j=0,k=-1;g.getNumber=function(){return $("#list").length?$("#list").children().length-1:0};g.select=function(a,b){"undefined"!=typeof t&&clearTimeout(t);$("#song_"+a).length&&(a!=last_index?(-1==last_index?h(a):
t=setTimeout(function(){h(a)},b),$("#song_"+last_index).length&&$("#song_"+last_index+" .item").removeClass("select",100),$("#song_"+a+" .item").addClass("select",100),$("#addhere").insertAfter("#song_"+a),last_index=a):(flickq&&e(),"undefined"!=typeof player&&"undefined"!=typeof player.pauseVideo&&player.pauseVideo(),$("#song_"+last_index+" .item").removeClass("select",100),last_index=-1))};g.burnUrl=function(){if(burnq){var a="burn.fm/"+encodeURIComponent("#"+g.getOrderedIds().join(",")+"&"+thehash.slice(1));
$.ajax({url:"http://d.burn.fm/yourls-api.php?signature=90e32f5ca0&action=shorturl&format=jsonp&url="+a,dataType:"jsonp",success:function(a){if("undefined"!=typeof a.shorturl&&thehash!="#"+a.shorturl.slice(17))thehash="#"+a.shorturl.slice(17),reloadq=!1,window.location.hash=thehash,$("#hash").fadeOut(100,function(){$("#hash").html(thehash);$("#hash").fadeIn(100)})}})}};g.getOrderedIds=function(){var a=[];$("#list").children().each(function(){"addhere"!=$(this).attr("id")&&a.push($(this).attr("id"))});
return $.map(a,function(a){return f[parseInt(a.slice(5))][7]})};g.getOrderedIndices=function(){var a=[];$("#list").children().each(function(){"addhere"!=$(this).attr("id")&&a.push(parseInt($(this).attr("id").slice(5)))});return a};g.isAdded=function(a){return-1!=$.inArray(a,m())?!0:!1};g.remove=function(a){$("#song_"+a).length&&$("#song_"+a).slideUp(200,function(){a==last_index?(player.pauseVideo(),last_index=-1,$("#song_"+a).remove(),delete f[a],g.burnUrl(),flickq&&e()):($("#song_"+a).remove(),delete f[a],
g.burnUrl())})};g.add=function(a,b,d,e,c,n,h,i,m,o){if(g.isAdded(i)||!$("#addhere").length)return!1;f[j]=[a,b,d,e,c,n,h,i,m,o];$("#addhere").before('<li id="song_'+j+'"></li>');$("#song_"+j).hide();$("#song_"+j).prepend('<div class="item"><span class="delete" id="remove_'+j+'">X</span><span class="sort">o</span><span class="title sel">'+a+' </span><span class="nobr"><span class="artist sel">'+d+' </span><span class="addartist" id="addartist_'+j+'">+</span><span class="album sel">'+b+' </span><span class="addalbum" id="addalbum_'+
j+'">+</span></span><a class="itunes" href="'+c+'">iTunes</a></div>');$("#remove_"+j).click(function(a){return function(b){b.stopPropagation();g.remove(a)}}(j));$("#addalbum_"+j).click(function(a){return function(b){b.stopPropagation();g.addAlbum(a)}}(j));$("#addartist_"+j).click(function(a){return function(b){b.stopPropagation();g.addArtist(a,10,!0,!0)}}(j));$("#song_"+j+" .sel").click(function(a){return function(){g.select(a,900)}}(j));$("#song_"+j).slideDown(100,function(){});j++;g.burnUrl();return!0};
g.addAlbum=function(a){if(-1!=f[a][8]){var b=g.getNumber();$.ajax({url:"http://itunes.apple.com/lookup?id="+f[a][8]+"&entity=song",dataType:"jsonp",success:function(a){for(var d=[],e=1;e<a.results.length;e++)$.ajax({url:"http://gdata.youtube.com/feeds/api/videos?alt=json-in-script&format=5&max-results="+YOUTUBES,data:{q:tube_top(a.results[e].trackName,a.results[e].artistName)},dataType:"jsonp",success:function(e){return function(c){d.push([e,execute_function(g.add,this,[a.results[e].trackName,a.results[e].collectionName,
a.results[e].artistName,a.results[e].artworkUrl100.substring(0,a.results[e].artworkUrl100.length-14)+"170x170-75.jpg",a.results[e].trackViewUrl,a.results[e].previewUrl,"undefined"!=typeof c.feed.entry?$.merge($.map(c.feed.entry,function(a){return a.link[0].href}),["http://www.youtube.com/watch?v=QgGbbVFMS4c&feature=youtube_gdata",0]):["http://www.youtube.com/watch?v=QgGbbVFMS4c&feature=youtube_gdata",0],a.results[e].trackId,"undefined"!=typeof a.results[e].collectionId?a.results[e].collectionId:-1,
"undefined"!=typeof a.results[e].artistId?a.results[e].artistId:-1])]);if(d.length==a.results.length-1){d=$.map(d.sort(function(a,b){return b[0]-a[0]}),function(a){return a[1]});for(burnq=!1;0<d.length;)d.pop()();burnq=!0;g.getNumber()!=b&&g.burnUrl()}}}(e)})}});return!0}return!1};g.addArtist=function(a,b,e,d){a=e?f[a][9]:a;if(-1!=a){var c=g.getNumber();$.ajax({url:"http://itunes.apple.com/lookup?id="+a+"&entity=song",dataType:"jsonp",success:function(a){for(var e=[],i=[],f=a.results.length,h=0;h<
b;h++)i.push(Math.ceil(Math.random()*(f-1)));for(h=0;h<i.length;h++)$.ajax({url:"http://gdata.youtube.com/feeds/api/videos?alt=json-in-script&format=5&max-results="+YOUTUBES,data:{q:tube_top(a.results[i[h]].trackName,a.results[i[h]].artistName)},dataType:"jsonp",success:function(b){return function(f){e.push([b,execute_function(g.add,this,[a.results[i[b]].trackName,a.results[i[b]].collectionName,a.results[i[b]].artistName,a.results[i[b]].artworkUrl100.substring(0,a.results[i[b]].artworkUrl100.length-
14)+"170x170-75.jpg",a.results[i[b]].trackViewUrl,a.results[i[b]].previewUrl,"undefined"!=typeof f.feed.entry?$.merge($.map(f.feed.entry,function(a){return a.link[0].href}),["http://www.youtube.com/watch?v=QgGbbVFMS4c&feature=youtube_gdata",0]):["http://www.youtube.com/watch?v=QgGbbVFMS4c&feature=youtube_gdata",0],a.results[i[b]].trackId,"undefined"!=typeof a.results[i[b]].collectionId?a.results[i[b]].collectionId:-1,"undefined"!=typeof a.results[i[b]].artistId?a.results[i[b]].artistId:-1])]);if(e.length==
i.length){e=$.map(e.sort(function(a,b){return b[0]-a[0]}),function(a){return a[1]});for(burnq=!1;0<e.length;)e.pop()();burnq=!0;d&&g.getNumber()!=c&&g.burnUrl()}}}(h)})}});return!0}return!1};g.addGenre=function(a,b,e){if(0<=a&&a<ids.length){var d;g.getNumber();for(var c,f=0,h=0;h<b;h++)d=ids[a][Math.floor(Math.random()*ids[a].length)][0],$.ajax({url:"http://itunes.apple.com/lookup?id="+d+"&entity=song&limit=50",dataType:"jsonp",success:function(a){c=Math.ceil(Math.random()*(a.results.length-1));$.ajax({url:"http://gdata.youtube.com/feeds/api/videos?alt=json-in-script&format=5&max-results="+
YOUTUBES,data:{q:tube_top(a.results[c].trackName,a.results[c].artistName)},dataType:"jsonp",success:function(d,c){return function(d){f++;g.add(a.results[c].trackName,a.results[c].collectionName,a.results[c].artistName,a.results[c].artworkUrl100.substring(0,a.results[c].artworkUrl100.length-14)+"170x170-75.jpg",a.results[c].trackViewUrl,a.results[c].previewUrl,"undefined"!=typeof d.feed.entry?$.merge($.map(d.feed.entry,function(a){return a.link[0].href}),["http://www.youtube.com/watch?v=QgGbbVFMS4c&feature=youtube_gdata",
0]):["http://www.youtube.com/watch?v=QgGbbVFMS4c&feature=youtube_gdata",0],a.results[c].trackId,"undefined"!=typeof a.results[c].collectionId?a.results[c].collectionId:-1,"undefined"!=typeof a.results[c].artistId?a.results[c].artistId:-1);f==b&&(burnq=!0,e&&g.burnUrl())}}(h,c)})}});return!0}return!1};g.shuffle=function(){$("#list li").shuffle()}}
function suggestRandomArtists(c){$("#randoartists").length?$("#randoartists").fadeOut(200,function(){$("#randoartists").html("");for(var b=[],d,e,h=0;h<c;h++){do if(d=Math.floor(Math.random()*ids.length),d=ids[d][Math.floor(Math.random()*ids[d].length)],e=-1==$.inArray(d[0],b))b.push(d[0]),$("#randoartists").append('<span id="rando_'+d[0]+'"></span> '),$("#rando_"+d[0]).html("+"+d[1]),$("#rando_"+d[0]).click(function(b){return function(){songs.addArtist(b,10,!1,!0)}}(d[0]));while(!e)}$("#randoartists").fadeIn(200)}):
($("#topcontainer").prepend('<div id="randoartists"></div>'),$("#randoartists").hide(),suggestRandomArtists(c))}function hashies(c,b){for(var d=ids[c].length,e=0;e<b;e++)songs.addArtist(ids[c][Math.ceil(Math.random()*(d-1))][0],1,!1,!1)}function updatehash(c){reloadq=!1;$("#hash").html("#"+c);window.location.hash="#"+c}function randommix(){toreload=Math.ceil(Math.random()*(reserved.length-2))+1;window.location.hash="#"+reserved[toreload];window.location.reload()}
function constructPage(){$("body").append('<div id="tubecontainer"><div id="tube"></div></div>');last_index=-1;flickq=reloadq=!1;thehash=window.location.hash;$(window).on("hashchange",function(){reloadq&&window.location.reload();reloadq=!0});loop=2;shufflestart=!1;$("body").append('<div id="topcontainer"><div id="top"><span id="brand">burn.fm/</span><span id="hash">'+thehash+'</span><img border="0" id="stumbleupon" class="icons" src="su.png" width="62" height="62" /><img border="0" id="facebook" class="icons" src="facebook.png" width="64" height="64" /><img border="0" id="twitter" class="icons" src="twitter.png" width="64" height="64" /></div><div id="newrandom"><span id="new">>New</span> <span id="random">>Random</span></div><div id="playcontrols"><span id="shuffle">shuffle</span><span id="loop">loop list</span></div><div id="songcontainer"><input id="song" /></div><div id="randos"><span id="pop">+pop</span> <span id="hiphop">+hip hop</span> <span id="indierock">+indie rock</span> <span id="underrated">+underrated</span></div></div><div id="transition"></div>');
$("#new").click(function(){window.location.hash="#newmix";window.location.reload()});$("#random").click(randommix);$("#shuffle").click(function(){songs.shuffle()});$("#loop").click(function(){0==loop?(loop=1,$("#loop").html("loop track")):1==loop?(loop=2,$("#loop").html("loop list")):2==loop&&(loop=0,$("#loop").html("loop none"))});$("#indierock").click(function(){songs.addGenre(2,10,!0)});$("#hiphop").click(function(){songs.addGenre(1,10,!0)});$("#pop").click(function(){songs.addGenre(0,10,!0)});
$("#underrated").click(function(){songs.addGenre(3,10,!0)});$("#stumbleupon").click(function(){window.open("http://www.stumbleupon.com/submit?url="+encodeURIComponent("http://burn.fm/"+thehash))});$("#facebook").click(function(){window.open("http://www.facebook.com/sharer.php?t="+encodeURIComponent("A music playlist")+"&u="+encodeURIComponent("http://burn.fm/"+thehash))});$("#twitter").click(function(){window.open("https://twitter.com/intent/tweet?text="+encodeURIComponent("A music playlist")+"&url="+
encodeURIComponent("http://burn.fm/"+thehash))});suggestRandomArtists(7);s=setInterval(function(){suggestRandomArtists(7)},1E4);$("body").append('<div id="content"></div>');$("#content").append('<ul id="list"><li id="addhere"><div class="item" id="insertionpoint"><span class="sort">o</span><span id="addheretext">[Where your next track(s) will go]</span></div></li></ul>');$("#list").sortable({handle:".sort",containment:"document",axis:"y",start:function(c,b){flagged=0;"addhere"==$("#"+b.item.context.id).next().next().attr("id")?
flagged=1:"addhere"==$("#"+b.item.context.id).prev().attr("id")&&(flagged=2)},update:function(c,b){"addhere"!=b.item.context.id&&!(1==flagged&&"addhere"==$("#"+b.item.context.id).prev().attr("id")||2==flagged&&"addhere"==$("#"+b.item.context.id).next().attr("id"))&&songs.burnUrl()}});$("#song").watermark("Find a track to add",{className:""});$("#song").addClass("ui-corner-all");$("#song").autocomplete({source:function(c,b){$.ajax({url:"http://itunes.apple.com/search",dataType:"jsonp",data:{term:c.term,
entity:"song",limit:14},success:function(d){b($.map(d.results,function(b){return{label:b.trackName+" | "+b.collectionName+" | "+b.artistName,itunes_id:b.trackId,collection_id:b.collectionId,artist_id:b.artistId,song:b.trackName,album:b.collectionName,artist:b.artistName,album_art:b.artworkUrl100.substring(0,b.artworkUrl100.length-14)+"170x170-75.jpg",value:b.name,itunes_url:b.trackViewUrl,preview_url:b.previewUrl}}))}})},minLength:2,delay:500,select:function(c,b){if(songs.isAdded(b.item.itunes_id))return alert("You've already added that song! If you like it so much, why don't you marry it?"),
$("#song").val(""),!1;$.ajax({url:"http://gdata.youtube.com/feeds/api/videos?alt=json-in-script&format=5&max-results="+YOUTUBES,data:{q:tube_top(b.item.song,b.item.artist)},dataType:"jsonp",success:function(d){songs.add(b.item.song,b.item.album,b.item.artist,b.item.album_art,b.item.itunes_url,b.item.preview_url,"undefined"!=typeof d.feed.entry?$.merge($.map(d.feed.entry,function(b){return b.link[0].href}),["http://www.youtube.com/watch?v=QgGbbVFMS4c&feature=youtube_gdata",0]):["http://www.youtube.com/watch?v=QgGbbVFMS4c&feature=youtube_gdata",
0],b.item.itunes_id,"undefined"!=typeof b.item.collection_id?b.item.collection_id:-1,"undefined"!=typeof b.item.artist_id?b.item.artist_id:-1)}});$("#song").val("");return!1},open:function(){$(this).removeClass("ui-corner-all").addClass("ui-corner-top")},close:function(){$(this).removeClass("ui-corner-top").addClass("ui-corner-all")}})}
if(1<window.location.hash.length&&-1==$.inArray(window.location.hash.slice(1),reserved))2==window.location.hash.split("&").length?$("body").prepend('<div id="hidehashinfo">'+window.location.hash+"</div>"):top===self&&($("body").prepend('<iframe id="hidehash" name="hidehash" style="display:none;" />'),$("#hidehash").load(function(){var c=$("#hidehash").contents().find("#hidehashinfo").html();null!=c&&(components=c.split("&"));"undefined"!=typeof components&&"#"!=components[0]?($("#hidehash").remove(),
$("body").prepend('<div id="loading"><span id="loadingtext">Loading</span> burn. . .</div>'),$.ajax({url:"http://itunes.apple.com/lookup?id="+components[0].slice(1),dataType:"jsonp",success:function(b){songs=new Songs;for(var d=[],c=0;c<b.results.length;c++)$.ajax({url:"http://gdata.youtube.com/feeds/api/videos?alt=json-in-script&format=5&max-results="+YOUTUBES,data:{q:tube_top(b.results[c].trackName,b.results[c].artistName)},dataType:"jsonp",success:function(c){return function(e){d.push([c,execute_function(songs.add,
this,[b.results[c].trackName,b.results[c].collectionName,b.results[c].artistName,b.results[c].artworkUrl100.substring(0,b.results[c].artworkUrl100.length-14)+"170x170-75.jpg",b.results[c].trackViewUrl,b.results[c].previewUrl,"undefined"!=typeof e.feed.entry?$.merge($.map(e.feed.entry,function(b){return b.link[0].href}),["http://www.youtube.com/watch?v=QgGbbVFMS4c&feature=youtube_gdata",0]):["http://www.youtube.com/watch?v=QgGbbVFMS4c&feature=youtube_gdata",0],b.results[c].trackId,"undefined"!=typeof b.results[c].collectionId?
b.results[c].collectionId:-1,"undefined"!=typeof b.results[c].artistId?b.results[c].artistId:-1])]);if(d.length==b.results.length){jQuery.fx.off=!0;d=$.map(d.sort(function(b,c){return c[0]-b[0]}),function(b){return b[1]});burnq=!1;$("#loading").remove();constructPage();for(reloadq=!0;0<d.length;)d.pop()();burnq=!0;$("html,body").scrollTop(0);jQuery.fx.off=!1}}}(c)})}})):(window.location.hash="#newmix",window.location.reload())}),$("#hidehash").attr("src","http://d.burn.fm/"+window.location.hash.slice(1)));
else switch("#random"==window.location.hash&&randommix(),songs=new Songs,constructPage(),window.location.hash){case "#indierock":songs.addGenre(2,20,!1);updatehash("indierock");break;case "#pop":songs.addGenre(0,20,!1);updatehash("pop");break;case "#hiphop":songs.addGenre(1,20,!1);updatehash("hiphop");break;case "#underrated":songs.addGenre(3,20,!1);updatehash("underrated");break;case "#britney":songs.addArtist(217005,20,!1,!1);break;case "#spoon":songs.addArtist(703784,20,!1,!1);break;case "#rihanna":songs.addArtist(63346553,
20,!1,!1);break;default:updatehash("newmix")};

