LFM.set("Radio",{ActivityTimer:Class.create({counter:0,timer:null,pollLength:0,timeoutPeriod:0,timeoutCallback:null,initialize:function(_1,_2,_3){
this.timeoutCallback=_1;
this.timeoutPeriod=_2;
this.pollLength=_3||_2;
},start:function(){
log("Started ActivityTimer");
this.setTimeout();
},stop:function(){
log("Stopped ActivityTimer");
this.clearTimeout();
this.reset();
},reset:function(){
log("Reset ActivityTimer");
this.setTimeout();
this.counter=0;
},update:function(){
this.counter+=this.pollLength;
if(this.counter>=this.timeoutPeriod){
return this.timeout();
}
this.setTimeout();
},timeout:function(){
this.stop();
this.timeoutCallback();
},clearTimeout:function(){
clearTimeout(this.timer);
},setTimeout:function(){
this.clearTimeout();
this.timer=setTimeout(this.update.bind(this),this.pollLength);
}})});
LFM.set("Radio",{Metadata:Class.create({currentTrack:null,currentTrackNum:null,newTrack:null,playing:false,artistInfoBlinding:false,waitingShowResponseArg:false,shoutSuccess:"0",originalTitle:document.title,isLovedTrack:false,isLastTrackBanned:false,statusTimer:null,scrobbling:true,slideshow:true,stopOnTrackComplete:false,initialize:function(_4,_5){
LFM.info("initialize Radio MetaData");
document.observe("click",this.clickSniffer.bind(this));
setTimeout(function(){
Event.observe(window,"focus",this.focusCallback.bind(this));
}.bind(this),10000);
setInterval(this.scrollSniffer.bind(this),10000);
window.onbeforeunload=this.unloadPage.bind(this);
$("playerControlLove").observe("click",function(e){
e.element().blur();
LFM.Flash.Player.love();
this.addClassName("highlight");
LFM.Page.Metadata.logInteraction(e,true);
});
$("playerControlBan").observe("click",function(e){
e.element().blur();
LFM.Page.Metadata.isLastTrackBanned=true;
LFM.Flash.Player.ban();
LFM.Page.Metadata.logInteraction(e,true);
});
$("playerControlPlay").observe("click",function(e){
e.element().blur();
LFM.Flash.Player.play();
LFM.Page.Metadata.logInteraction(e,true);
});
$("playerControlStop").observe("click",function(e){
e.element().blur();
LFM.Flash.Player.stop();
LFM.Page.Metadata.logInteraction(e,true);
});
$("playerControlSkip").observe("click",function(e){
e.element().blur();
LFM.Flash.Player.skip();
if($("lfmSlideshow")&&$("lfmSlideshow").stopPlayback){
$("slideshowPhotoCredits").hide();
try{
$("lfmSlideshow").stopPlayback();
}
catch(e){
LFM.error("Error calling Slideshow.stopPlayback()");
LFM.log(e);
}
}else{
LFM.warn("slideshow unavailable stopPlayback()");
}
LFM.Page.Metadata.logInteraction(e,true);
});
$("userMetadata").observe("click",function(e){
if(e.element().up().match("h2")){
e.element().up().up().toggleClassName("closed");
}
});
if($("scrobbleToggle")){
$("scrobbleToggle").observe("click",this.scrobbleToggle.bind(this));
}
if($("slideshowToggle")){
$("slideshowToggle").observe("click",this.slideshowToggle.bind(this));
}
var _c=$("playerControlVolSlider");
var _d=(LFM.getCookie("lfmVol"))?LFM.getCookie("lfmVol"):80;
var _e=new Control.Slider(_c.down(".handle"),_c,{range:$R(0,100),sliderValue:_d,onSlide:function(_f){
LFM.Flash.Player.setVolume(Math.round(_f));
LFM.setCookie("lfmVol",Math.round(_f));
LFM.Page.Metadata.logInteraction();
},onChange:function(_10){
LFM.Flash.Player.setVolume(Math.round(_10));
LFM.setCookie("lfmVol",Math.round(_10));
LFM.Page.Metadata.logInteraction();
}});
$("playerControlVolMute").observe("click",function(e){
LFM.Page.Metadata.logInteraction(e,true);
LFM.Flash.Player.setVolume(Math.round(0));
LFM.setCookie("lfmVol",Math.round(0));
_e.setValue(0);
});
$("playerControlVolFull").observe("click",function(e){
LFM.Page.Metadata.logInteraction(e,true);
LFM.Flash.Player.setVolume(Math.round(100));
LFM.setCookie("lfmVol",Math.round(100));
_e.setValue(100);
});
},onLoad:function(){
LFM.info("Flash player loaded");
LFM.logGroup("Flash player listeners");
LFM.Flash.Player.addEventListener("playback",this.onPlayback);
LFM.Flash.Player.addEventListener("nextTrack",this.onNextTrack.bind(this));
LFM.Flash.Player.addEventListener("completeTrack",this.onCompleteTrack.bind(this));
LFM.Flash.Player.addEventListener("stopTrack",this.onStopTrack.bind(this));
LFM.Flash.Player.addEventListener("error",this.onError.bind(this));
LFM.Flash.Player.addEventListener("bufferingStart",this.onBufferingStart.bind(this));
LFM.Flash.Player.addEventListener("loveTrack",this.onLoveTrack.bind(this));
LFM.Flash.Player.addEventListener("tune",this.onTune.bind(this));
LFM.Flash.Player.addEventListener("unsupportedPlayerVersion",this.onUnsupportedPlayerVersion.bind(this));
LFM.Flash.Player.addEventListener("getSession",this.onGetSession.bind(this));
LFM.logGroupEnd();
this.setScrobblingPref();
},onGetSession:function(){
LFM.info("getSession is in");
LFM.Flash.Player.readyToTune=true;
LFM.Flash.PreRoll.onGetSession();
},setScrobblingPref:function(){
if(!LFM.Page.Metadata.scrobbling){
LFM.Flash.Player.switchOffScrobbling();
}
},onError:function(_13){
log("Flash Player event: onError: "+_13.code+" : "+_13.message);
if(_13.code==1){
$("stationPlaybackContentError").show();
this.setStatus({type:"error",message:"Not enough content"});
this.onStopTrack(LFM.Page.RadioState.hasCurrentStation());
}else{
if(_13.code==2){
$("stationPlaybackConnectionError").show();
this.setStatus({type:"error",message:"Connection error"});
this.onStopTrack(LFM.Page.RadioState.hasCurrentStation());
}else{
if(_13.code==3){
this.setStatus({type:"error",message:_13.message});
this.onStopTrack(true);
this.inactivityDialog();
}
}
}
if(!LFM.Page.RadioState.hasCurrentStation()){
LFM.Page.RadioState.newStationError();
}
LFM.Page.RadioState.fixPaneHeight();
},onBufferingStart:function(_14){
log("Flash Player event: onBufferingStart: "+_14.message);
this.setStatus({type:"loading",message:LFM.String.buffering});
},onLoveTrack:function(_15){
log("Flash Player Event: onLoveTrack: "+_15.message);
if(!_15.error){
this.setStatus({type:"info",message:LFM.String.trackLoved,duration:4000});
$("playerControlLove").addClassName("highlight");
LFM.Flash.Player.logLove();
LFM.Adserver.refreshAds(true);
}
},onUnsupportedPlayerVersion:function(_16){
log("unsupported player version");
this.setStatus({type:"error",message:LFM.String.unsupportedPlayerVersion});
},onTune:function(_17){
$$("#stationPlaybackErrors div").invoke("hide");
LFM.Page.RadioState.onTune(_17.error);
},onPlayback:function(_18){
var _19=function(_1a){
var _1b=Math.floor(_1a/60);
_1b=(""+_1b).length==1?"0"+_1b:_1b;
_1a=_1a%60;
_1a=(""+_1a).length==1?"0"+_1a:_1a;
return _1b+":"+_1a;
};
_18.position=Math.min(_18.duration,_18.position);
var _1c=Math.round(_18.position/_18.duration*10000)/100;
if(_1c<100){
$$("#progressBar span")[0].setStyle({width:_1c+"%"});
$("trackPlayed").update(_19(Math.round(_18.position/1000)));
$("trackRemaining").update("-"+_19(Math.round((_18.position-_18.duration)*-1/1000)));
}
},onCompleteTrack:function(){
if(this.stopOnTrackComplete){
LFM.log("Soft Stopping player");
this.inactivityDialog();
LFM.Flash.Player.stop();
}
},onNextTrack:function(_1d,_1e){
LFM.log("flash player onNextTrack event: "+_1d.albumImage);
if(_1d.manual){
this.logSkip();
}
if(!_1e){
_1e=0;
}
this.currentTrack=_1d;
this.playing=true;
document.title=_1d.creator+" - "+_1d.name+" - Last.fm";
if(_1d.manual){
var _1f=this.isLastTrackBanned;
this.isLastTrackBanned=false;
setTimeout(function(){
LFM.Adserver.refreshAds(false,_1f);
},1000);
}
if(this.hasShout()){
log("has shout");
functionArguments=[_1d];
this.finishShout(LFM.Flash.Player.context.onNextTrack.bind(this),functionArguments);
}else{
this.hideContent();
setTimeout(function(){
LFM.Flash.Player.context.getMetadata(_1d.creator,_1d.name,_1e);
},100);
}
$("webRadioPlayer-visualisation").setStyle({backgroundImage:"none"});
this.toggleStopPlayButton();
this.setNowPlaying(this.currentTrack);
LFM.Page.RadioState.onNextTrack(function(){
this.loadArtist(_1d.creator);
}.bind(this));
},loadArtist:function(_20){
if($("lfmSlideshow")&&$("lfmSlideshow").loadArtist){
$("slideshowPhotoCredits").hide();
log("loading artist image: "+encodeURIComponent(_20));
try{
$("lfmSlideshow").loadArtist(encodeURIComponent(_20));
}
catch(e){
LFM.error("Error calling Slideshow.loadArtist()");
LFM.log(e);
}
}else{
LFM.warn("slideshow unavailable loadArtist()");
}
},logInteraction:function(e,_22){
log("Logged interaction. Reset timer");
if(LFM.Page.InteractionTimer){
LFM.Page.InteractionTimer.reset();
}
if(e&&_22){
e.stop();
}
},interactionTimeout:function(){
LFM.log("Stop after this track");
this.stopOnTrackComplete=true;
LFM.Flash.Player.stopOnNextTrack();
},onStopTrack:function(_23){
if(this.stopOnTrackComplete){
this.stopOnTrackComplete=false;
_23=true;
}
this.playing=false;
this.toggleStopPlayButton();
document.title=this.originalTitle;
if(this.hasShout()){
this.finishShout("onFlashPlayerStopTrack");
}else{
this.removeContent();
if($("calltoaction")){
new Effect.Appear("calltoaction",{duration:0.5,delay:1});
}
}
$("listenContent").stopObserving();
this.setNowPlaying(false);
this.onPlayback({position:0,duration:1});
LFM.Page.RadioState.onStopTrack(_23);
if($("lfmSlideshow")&&$("lfmSlideshow").stopPlayback){
try{
$("lfmSlideshow").stopPlayback();
}
catch(e){
LFM.error("Error calling Slideshow.stopPlayback()");
LFM.log(e);
}
}else{
LFM.warn("slideshow unavailable stopPlayback()");
}
},logSkip:function(){
log("log skip");
LFM.Omniture.trackEvents("SkipTrack");
},logScroll:function(){
log("Scroll position: "+position);
LFM.Omniture.trackEvents("PageScroll");
},logFocus:function(){
LFM.Omniture.trackEvents("WindowFocus");
},clickSniffer:function(_24){
this.logInteraction(_24);
if(!(Prototype.Browser.IE)&&!_24.isLeftClick()){
return;
}
if(!this.playing){
return;
}
var _25=_24.findElement("a");
if(!_25){
return;
}
if(_25.hasClassName("stationbutton")||_25.hasClassName("scrobbleToggle")||_25.hasClassName("playCombo")){
return;
}
var _26=_25.pathname.replace(/^\//,"");
var _27=window.location.pathname.replace(/^\//,"");
if(_26==_27){
return;
}
if(_25.hasClassName("lfmSendButton")){
return;
}
if(_25.up("#listenContent")||_25.up("#sampleContent")||_25.up("#recentTracks")){
var _28="unknownLink";
if(_25.hasClassName("ontour")){
_28="onTourLink";
}else{
if(_25.up("#similarArtists")&&_25.up(".tags")){
_28="similarArtistsTagLink";
}else{
if(_25.up("#similarArtists")){
_28="similarArtistsLink";
}else{
if(_25.up("#shoutbox")){
_28="shoutboxLink";
}else{
if(_25.up("#sampleContent")){
_28="sampleContentLink";
}else{
if(_25.up("#topInfoBox")&&_25.hasClassName("artist")){
_28="artistNameInfoBoxLink";
}else{
if(_25.up("#topInfoBox")&&_25.up(".tags")){
_28="tagsInfoBoxLink";
}else{
if(_25.up("#topInfoBox")){
_28="InfoBoxLink";
}else{
if(_25.up("#events")){
_28="eventLink";
}
}
}
}
}
}
}
}
}
LFM.Omniture.prepareEvar("ClickSource",_28);
LFM.Omniture.trackEvents("Click");
log(_28);
}
_24.stop();
window.open(_25.href);
},focusCallback:function(){
log("focus callback");
if(this.playing){
this.logFocus();
}
},scrollSniffer:function(){
position=document.viewport.getScrollOffsets().top;
if(this.lastYPos!=undefined&&position!=this.lastYPos){
this.logScroll();
}
this.lastYPos=position;
},finishShout:function(_29,_2a){
if(!$("shoutOutOutOutOut").visible){
new Effect.BlindDown("shoutOutOutOutOut",{duration:0.3});
}
if(LFM.Page.Shoutboxen){
actsAsAspect(LFM.Page.Shoutboxen.shoutbox);
LFM.Page.Shoutboxen.shoutbox.after("addShout",function(){
$("shoutmsg").value="";
_2a.push(1);
log("function arguments:");
_2a.each(function(arg){
log(arg);
});
_29.apply(this,_2a);
});
$$("#shoutOutOutOutOut a")[0].observe("click",function(e){
$("shoutmsg").value="";
_29.apply(this,_2a);
e.stop();
}.bind(this));
}
},getMetadata:function(_2d,_2e,_2f){
log("get meta data");
this.getArtistInfo(_2d,_2e,_2f,true);
},getArtistInfo:function(_30,_31,_32){
var url="/listen/listeningNow";
log("get artist info: "+_30+", "+_31+", "+_32);
if(isset(_30)&&isset(_31)){
this.setStatus({type:"loading",message:LFM.String.loadingTrackInfo});
new Ajax.Request(url,{method:"get",parameters:{"artist":_30,"track":_31,"shoutsuccess":_32,"ajax":1,"zone":LFM.Adserver.zone,"geo":LFM.Session.location,"res":LFM.Adserver.res},onSuccess:this.handleMetadataResponse.bind(this)});
}
},waitedShowResponse:function(){
this.handleMetadataResponse(this.waitingShowResponseArg);
},handleMetadataResponse:function(_34){
if(this.artistInfoBlinding){
this.waitingShowResponseArg=_34;
setTimeout(this.waitedShowResponse(),1000);
}
if(this.playing){
var _35=new LFM.Ajax.Response(_34);
if(_35.isError()){
log("Metadata Error: Invalid response, status: "+_34.status);
this.setStatus({type:"error",message:LFM.String.errorLoadingTrackInfo});
this.removeContent();
this.showContent();
return;
}
this.updateFreeTrialMessage(_35);
setTimeout(function(){
$("nowPlayingMeta").update(_35.get("html"));
if($("recentTracks")&&$("recentTracksSource")){
$("recentTracks").update($("recentTracksSource").remove().innerHTML);
}
if($("recentStations")&&$("recentStationsSource")){
$("recentStations").update($("recentStationsSource").remove().innerHTML);
}
LFM.Page.RadioState.fixPaneHeight();
setTimeout(function(){
new Effect.Appear("nowPlayingMeta",{duration:0.5,afterFinish:function(){
this.artistInfoBlinding=false;
setTimeout(LFM.Page.RadioState.fixPaneHeight.bind(LFM.Page.RadioState),20);
}.bind(this)});
$("button1").down().observe("click",this.logInteraction);
$("button2").down().observe("click",this.logInteraction);
}.bind(this),1);
}.bind(this),1);
this.setStatus(null);
this.isLovedTrack=_35.get("hasLovedTrack");
if($("playerControlLove").hasClassName("highlight")!=this.isLovedTrack){
$("playerControlLove").toggleClassName("highlight");
}
$("playerControlBan").removeClassName("highlight");
LFM.Adserver.setTandemID(_35.get("lfmtandem"));
}
this.setNewWindowTooltips();
this.showContent();
},onFreeTrialExpiry:function(){
log("Free trial expire");
if($("trialStart")){
$("trialStart").hide();
}
$("midTrial").hide();
$("trialExpired").show();
this.onStopTrack();
LFM.Page.RadioState.newStationError(LFM.Session.ERROR_TRIAL_EXPIRED);
},updateFreeTrialMessage:function(_36){
if(!_36.get("freeTrial")){
return;
}
if($("trialStart")){
$("trialStart").hide();
}
var _37=_36.get("freeTrialLeft");
log("Free trial left: "+_37);
if(_37==0){
log("Trial ended");
$("midTrial").hide();
$("trialExpired").show();
return;
}else{
if(_37<=5){
color=LFM.get("Page","trialRemainColourFinal");
}else{
color=LFM.get("Page","trialRemainColour");
}
}
var _38=$("trialLeftProgressBar");
if(_38){
var _39=_36.get("freeTrialPercentLeft")+"%";
log("Update progress: "+color+" / "+_39);
_38.setStyle({width:_39,background:"#"+color});
var _3a={"trialLastPlay":(_37==1),"trialFewPlaysLeft":(_37<=5&&_37!=1),"trialPlaysLeft":(_37>5)};
for(trialMessageID in _3a){
var _3b=$(trialMessageID);
if(_3b){
if(_3a[trialMessageID]){
log("Show: "+trialMessageID);
var _3c=_3b.down("span.trialPlaysCount");
if(_3c){
_3c.update(_37);
}
_3b.show();
}else{
log("Hide: "+trialMessageID);
_3b.hide();
}
}
}
$("midTrial").show();
}
},hasShout:function(){
if($("shoutmsg")){
return shout=$F("shoutmsg").strip()!="";
}else{
return false;
}
},removeContent:function(){
if($("nowPlayingMeta")){
this.artistInfoBlinding=true;
new Effect.Fade("nowPlayingMeta",{duration:0.3,afterFinish:function(_3d){
this.artistInfoBlinding=false;
_3d.element.innerHTML="";
}.bind(this)});
}
log("removed all content");
},hideContent:function(){
$("trackMetadataOverlay").appear();
},showContent:function(){
$("trackMetadataOverlay").fade();
},unloadPage:function(_3e){
if($("dontTouchDialEnabled")&&$F("dontTouchDialEnabled")&&this.playing){
return LFM.String.unloadWarningMessage;
}
},toggleStopPlayButton:function(){
if(this.playing){
$("playerControlPlay").hide();
$("playerControlStop").show();
}else{
$("playerControlPlay").show();
$("playerControlStop").hide();
}
},setNowPlaying:function(_3f){
var _40=$("playerTrackMeta");
var _41=function(_42,_43){
return new Element("a",{href:_42}).update(_43);
};
if(!_3f&&_40.visible()){
_40.hide();
}else{
if(_3f){
if(!_40.visible()){
_40.show();
}
_3f.creatorURL=_3f.trackURL.split("/").slice(0,-2).join("/");
_40.down("p .artist").update(_41(_3f.creatorURL,_3f.creator));
_40.down("p .track").update(_41(_3f.trackURL,_3f.name));
if(_3f.albumName){
_40.down("p.album span.title").update(_41(_3f.albumURL,_3f.albumName));
}else{
_40.down("p.album span.title").update(LFM.String.unknownAlbum);
}
}
}
},setNewWindowTooltips:function(){
$$("#nowPlayingMeta a").each(function(e){
if(!(e.up(".buttons")||e.hasClassName("toggle")||e.hash=="#toggle")){
e.setAttribute("title",LFM.String.newWindowTooltip);
}
});
},setStatus:function(_45){
var _46=$("listenStatus");
if(this.statusTimer){
log("Cancelling status timer");
clearTimeout(this.statusTimer);
}
_45=_45||{type:"empty",message:""};
log("Status Update Event: "+_45.message);
if(_46){
_46.className=_45.type;
_46.update(_45.message);
}
if(_45.duration){
log("Statu Update Event: Will fade in "+_45.duration);
this.statusTimer=setTimeout(this.setStatus.bind(this),_45.duration);
}
},disablePlayerControls:function(){
$("webRadioPlayer-content").addClassName("disabled");
},enablePlayerControls:function(){
$("webRadioPlayer-content").removeClassName("disabled");
},scrobbleToggle:function(e){
LFM.Page.Metadata.logInteraction(e,true);
this.scrobbling=!this.scrobbling;
LFM.Flash.Player.scrobble(this.scrobbling);
$("nowPlayingMeta").toggleClassName("scrobbling-enabled");
var _48=this.scrobbling?LFM.String.scrobblingEnabled:LFM.String.scrobblingDisabled;
_48=_48+" "+LFM.String.scrobblingHelp;
this.setStatus({type:"info",message:_48,duration:5000});
$("scrobbleToggle").toggleClassName("enabled");
LFM.Ajax.setUserPref("webRadioScrobbling",this.scrobbling?1:0);
},slideshowToggle:function(e){
LFM.Page.Metadata.logInteraction(e,true);
log("slideshowtoggle called");
this.slideshow=!this.slideshow;
$("slideshowToggle").toggleClassName("enabled");
var _4a=this.slideshow?LFM.String.slideshowEnabled:LFM.String.slideshowDisabled;
this.setStatus({type:"info",message:_4a,duration:5000});
if(LFM.Session.loggedIn){
LFM.Ajax.setUserPref("webRadioSlideshow",this.slideshow?1:0);
}
if($("lfmSlideshow")&&$("lfmSlideshow").toggleAnimation){
try{
$("lfmSlideshow").toggleAnimation();
}
catch(e){
LFM.error("Error calling Slideshow.toggleAnimation()");
LFM.log(e);
}
}else{
LFM.warn("slideshow unavailable toggleAnimation()");
}
},updateSlideshowPhoto:function(_4b){
if(_4b.image.owner){
var _4c=_4b.image.owner.name;
var _4d=_4b.image.url;
if(_4c){
$("slideshowPhotoCredits").update(LFM.String.slideshowPhotoCaption);
$$("#slideshowPhotoCredits span.author")[0].update(_4c);
$("slideshowPhotoCredits").setAttribute("href",_4d);
$("slideshowPhotoCredits").show();
return true;
}
}
$("slideshowPhotoCredits").hide();
return false;
},inactivityDialog:function(){
var _4e=LFM.AJAXDialogWrapper("/ajax/dialog/stilllistening",{title:LFM.String.stillListening,fadeDone:true,modal:true,parameters:{width:"500px"},onConfirm:function(e){
e.stop();
LFM.refreshPage();
this.hide();
},onCancel:function(){
LFM.Page.Metadata.onStopTrack();
this.hide();
}});
_4e({id:LFM.Page.RadioState.currentStation.id,type:LFM.Page.RadioState.currentStation.type,url:LFM.Page.RadioState.currentStation.url},{});
},problemDialog:function(_50){
var _51=LFM.AJAXDialogWrapper("/ajax/dialog/radioproblem",{title:LFM.String.radioProblems,fadeDone:true,modal:true,parameters:{width:"500px",isAdBlocking:_50},onConfirm:function(e){
e.stop();
LFM.refreshPage();
this.hide();
}});
_51();
}})});
LFM.set("Radio",{MixedContentPane:{expanded:false,MIN_HEIGHT:320,MAX_HEIGHT:426,expand:function(_53,_54){
if(_53<this.getHeight()){
log("cant resize content pane to a size smaller than the current height");
return;
}
log("expanding MixedContentPane to "+_53);
var _53=Math.min(_53,this.MAX_HEIGHT);
if(!this.expanded){
this.expanded=true;
var _55=_53-$("webRadioPlayer-content").getHeight();
log("expander height "+_55);
$("mixedContentPaneExpander").setStyle({height:_55+"px"});
LFM.info("mixedContentPaneExpander getStyle(height): "+$("mixedContentPaneExpander").getStyle("height"));
LFM.info("mixedContentPaneExpander style.height: "+$("mixedContentPaneExpander").style.height);
LFM.info("mixedContentPaneExpander getHeight: "+$("mixedContentPaneExpander").getHeight());
new Effect.BlindDown("mixedContentPaneExpander",{afterFinish:_54.afterFinish.bind(_54.target),duration:0.5,delay:2});
}else{
_54.afterFinish.bind(_54.target);
}
},collapse:function(_56){
if(this.expanded){
$("mixedContentPaneExpander").setStyle({display:"block"});
this.expanded=false;
Effect.BlindUp("mixedContentPaneExpander",{restoreAfterFinish:false,scaleContent:false,afterFinish:_56.afterFinish.bind(_56.target),duration:0.5});
}else{
_56.afterFinish.apply(_56.target);
}
},getHeight:function(){
return $("webRadioPlayer-content").getHeight();
},isExpanded:function(){
return this.expanded;
}}});
(function(){
var _57=window.location.hash.substr(1).toQueryParams();
if(_57&&_57.station){
document.loaded=true;
window.location=decodeURIComponent(_57.station);
}
})();
LFM.set("Radio",{State:Class.create({currentPane:"webRadioPlayer",tuningStation:null,currentStation:null,tuning:false,retuning:false,updating_hash:false,switching_panes:false,adsLoaded:false,initialize:function(_58,_59){
LFM.log("initialize Radio State");
if(_58){
this.setTuneState(_58);
}
if(_59){
this.currentPane=_59;
}
this.setupListeners();
this.setupIntervals();
this.prefersClient=LFM.get("Session","prefersClient");
},hasStation:function(){
if(this.currentStation||this.tuningStation){
return true;
}
return false;
},hasCurrentStation:function(){
return this.currentStation!=null;
},getStationURL:function(){
if(this.hasCurrentStation()){
return this.currentStation.url;
}else{
if(this.tuningStation){
return this.tuningStation.url;
}
}
},getDecodedCurrentStationURL:function(){
if(this.hasCurrentStation()){
return decodeURIComponent(decodeURIComponent(this.currentStation.url));
}
return "";
},setupIntervals:function(){
setInterval(this.checkCurrentPane.bind(this),1000);
},findElementLocation:function(_5a){
var _5b=_5a.up("#userStations,"+"#recentStations,"+"#recentTracks,"+"#recentStationsTab,"+"#playlistsTab,"+"#tagStationsTab,"+"#recommendedStations,"+"#simpleStarter,"+"#multiTagTab,"+"#multiArtistTab,"+"#listenContent,"+"#webRadioPlayer,");
if(_5b){
var _5c=_5b.id;
$w("stationTable webRadioHeader multiTunerContainer stationSection").each(function(_5d){
if(_5a.up("."+_5d)){
_5c+="."+_5d;
throw $break;
}
});
return _5c;
}
return false;
},setupListeners:function(){
document.observe("click",function(e){
var _5f;
_5f=e.findElement("a.switchPane");
if(_5f){
e.stop();
var _60=_5f.hash.substr(1);
var _61=this.findElementLocation(_5f);
if(_61){
var _62=_60+"["+_61+"]";
LFM.Omniture.prepareEvar("ClickSource",_62);
}else{
LFM.Omniture.prepareEvar("ClickSource","unknownLocation");
}
LFM.Omniture.trackEvents("RadioPaneSwitch");
this.switchPanes(_60);
}
_5f=e.findElement("img.dismiss_trans_icon");
if(_5f){
$$(".starterError").invoke("hide");
this.fixPaneHeight();
}
_5f=e.findElement("#shareStation");
if(_5f){
e.stop();
if(this.currentStation){
LFM.Send(this.currentStation);
}
}
_5f=e.findElement("a.playCombo");
if(_5f){
e.stop();
var _61=this.findElementLocation(_5f);
if(_61){
var _62="comboStation["+_61+"]";
LFM.Omniture.prepareEvar("ClickSource",_62);
}else{
LFM.Omniture.prepareEvar("ClickSource","unknownLocation");
}
this.fetchStationFromForm(_5f.up("form"));
}
_5f=e.findElement("a.stationbutton");
if(_5f){
if(!_5f.protocol.include("lastfm")){
e.stop();
var _61=this.findElementLocation(_5f);
if(_61){
var _62="stationBtn["+_61+"]";
LFM.Omniture.prepareEvar("ClickSource",_62);
}else{
LFM.Omniture.prepareEvar("ClickSource","unknownLocation");
}
this.fetchStationFromURL(_5f.pathname);
}
}
}.bindAsEventListener(this));
$$("form.starterForm").each(function(_63){
_63.observe("submit",function(e){
e.stop();
var _65=this.findElementLocation(_63);
if(_65){
var _66="starterForm["+_65+"]";
LFM.Omniture.prepareEvar("ClickSource",_66);
}else{
LFM.Omniture.prepareEvar("ClickSource","unknownLocation");
}
this.fetchStationFromForm(_63);
}.bind(this));
}.bind(this));
},checkCurrentPane:function(){
if(this.updating_hash||this.retuning||this.tuning||this.switching_panes){
return false;
}
var _67=this.getLocationHash();
if(!_67.station&&this.hasCurrentStation()){
log("set hash params to getDecodedCurrentStationURL");
_67.station=this.getDecodedCurrentStationURL();
}
if(!_67.pane){
if(this.currentStation){
_67.pane="webRadioPlayer";
}else{
_67.pane="simpleStarter";
}
}
if(!this.prefersClient&&_67.station){
var _68=this.getDecodedCurrentStationURL();
if(_68!=_67.station){
log("hash out of sync with tuned station");
log(" - current url: "+_68);
log(" - hash url: "+_67.station);
LFM.Omniture.prepareEvar("ClickSource","hashSync");
this.fetchStationFromURL(_67.station);
return true;
}
}
if(_67.pane&&_67.pane!=this.currentPane){
this.switchPanes(_67.pane);
return true;
}
},switchPanes:function(_69,_6a){
if($(_69)&&$(_69).hasClassName("webRadioPane")){
if(this.currentPane==_69){
this.updateLocationHash();
if(_6a){
_6a();
}
}else{
log("switch to: "+_69);
this.switching_panes=true;
from_element=$(this.currentPane);
if(this.currentPane!="webRadioPlayer"){
$$(".starterError").invoke("hide");
}
this.currentPane=_69;
var _6b=$(this.currentPane);
$$("div.starterPane").invoke("hide");
from_element.show();
$("webRadio").setStyle({left:from_element.positionedOffset().left*-1+"px"});
this.fixPaneHeight();
if(_6b){
_6b.show();
new Effect.Move("webRadio",{x:_6b.positionedOffset().left*-1,y:0,mode:"absolute",duration:0.2,transition:Effect.Transitions.sinoidal,afterFinish:function(el){
new Effect.ScrollTo(document.body,{duration:0.2});
this.updateLocationHash();
this.switching_panes=false;
if(_6a){
_6a();
}
}.bind(this)});
}
}
}
},fixPaneHeight:function(){
if(!LFM.Adserver.hasPreRoll()){
$("webRadioWrapper").setStyle({height:$(this.currentPane).getHeight()+"px"});
}
},fetchStationFromURL:function(url){
if(!url.startsWith("/")){
url="/"+url;
}
if(this.hasCurrentStation()){
log("current station: "+this.getDecodedCurrentStationURL());
}
log("fetching new station from url: "+url);
this.newStationLoading();
LFM.Omniture.trackEvents("RadioLaunch");
new Ajax.Request("/listen/tune",{method:"get",parameters:{"ajax":1,"url":url,"zone":LFM.Adserver.zone,"geo":LFM.Session.location},onComplete:this.newStationHandler.bind(this)});
},fetchStationFromForm:function(_6e){
var _6f=_6e.down("input[type=submit]");
if(_6f){
_6f.blur();
}
var _70=_6e.serialize(true);
var _71=!_70.name||_70.placeholder;
log("isBlankSearch: "+_71);
var _72=$$("#recentStationsList ul li a")[0];
if(_71&&_70.type=="artisttag"){
if(_72){
log("fetching last station: "+_72.pathname);
LFM.Omniture.prepareEvar("ClickSource","restartLastStation");
this.fetchStationFromURL(_72.pathname);
}else{
return false;
}
}else{
LFM.Omniture.trackEvents("RadioLaunch");
if(this.prefersClient){
_6e.submit();
return;
}
if(this.hasCurrentStation()){
log("current station: "+this.getDecodedCurrentStationURL());
}
log("fetching new station from form: "+Object.toQueryString(_70));
this.newStationLoading();
_6e.request({method:"get",parameters:{"ajax":1,"zone":LFM.Adserver.zone,"geo":LFM.Session.location},onComplete:this.newStationHandler.bind(this)});
}
},setTuneState:function(_73){
log("new station: "+_73.url);
this.tuning=true;
this.tuningStation=_73;
if(LFM.Adserver.hasPreRoll()){
setTimeout(this.checkAdBlocking.bind(this),3000);
}
},newStationLoading:function(){
this.retuning=true;
$$(".nowPlaying").invoke("hide");
$$(".tuneLoading").invoke("show");
new Effect.ScrollTo(document.body,{duration:0.2});
this.fixPaneHeight();
},newStationLoaded:function(){
this.retuning=false;
this.resuming=false;
$$(".tuneLoading").invoke("hide");
$$(".nowPlaying").invoke("show");
$$(".starterError").invoke("hide");
this.fixPaneHeight();
},newStationHandler:function(_74){
var _75=new LFM.Ajax.Response(_74);
if(_75.isError()){
log("New station error");
log(_75);
this.newStationError(_75.getErrorCode());
}else{
var _76=_75.getResource();
if(_76.parent){
LFM.Adserver.setResource(_76.parent);
LFM.Adserver.setZone(LFM.Adserver.stationZone);
LFM.Adserver.setStation(_76.url);
}
LFM.Adserver.setTandemID(_75.get("lfmtandem"));
if($("webRadioPlayer-title")){
log("Update player content");
$("webRadioPlayer-title").update(new Element("span",{title:_76.name}).update(_76.name.truncate(30,"\u2026")));
if($("shareStation")){
$("shareStation").href=_76.url;
}
var _77=_75.get("sampleContent");
if(_77&&_77.items&&_77.items.length){
var _78=_77.items.inGroupsOf(3)[0].collect(function(_79){
if(!_79){
throw $break;
}
return _79.res.name;
}).join(", ");
$("sampleContent").update(_78);
$("sampleContent").show();
}else{
$("sampleContent").update("");
$("sampleContent").hide();
}
this.setTuneState(_76);
LFM.Flash.Player.stop();
if(LFM.Adserver.hasPreRoll()){
LFM.info("Radio State: serve Preroll");
this.switchPanes("webRadioPlayer");
LFM.Adserver.servePreRoll();
}else{
if(LFM.Flash.PreRoll.isDART()){
LFM.Flash.PreRoll.hide();
}
LFM.info("Radio State: Tune flash player");
LFM.Flash.Player.tune(_76.url);
}
}
}
},onTune:function(_7a){
LFM.info("Radio State onTune");
LFM.Flash.PreRoll.onTune();
this.fixPaneHeight();
if(_7a){
LFM.dir(_7a);
LFM.warn("Tuning error: "+_7a.code+": "+_7a.message);
this.clearCurrentStation();
this.newStationError(_7a.code);
}else{
this.currentStation=this.tuningStation;
LFM.Flash.Player.stationURL=this.currentStation.url;
LFM.info("tuned station: "+this.currentStation.url);
if(LFM.Page.InteractionTimer){
LFM.Page.InteractionTimer.start();
}
this.hideAdBlockingError();
}
this.tuning=false;
this.tuningStation=null;
this.updateLocationHash();
},newStationError:function(_7b){
this.retuning=false;
$$(".tuneLoading").invoke("hide");
$$(".starterError").invoke("hide");
if($$(".starterError"+_7b).length){
$$(".starterError"+_7b).invoke("show");
}else{
$$(".starterErrorDefault").invoke("show");
}
LFM.Omniture.prepareEvar("ErrorCode",_7b);
LFM.Omniture.trackEvents("RadioError");
if(this.currentPane=="webRadioPlayer"){
this.switchPanes("simpleStarter");
}
this.fixPaneHeight();
},onNextTrack:function(_7c){
LFM.info("onNextTrack");
if(this.tuning){
LFM.warn("Calling onTune for buggy Flash player");
this.onTune();
}
if(this.retuning||this.resuming){
this.switchPanes("webRadioPlayer",_7c);
LFM.Adserver.refreshAds();
LFM.log("New station started");
this.newStationLoaded();
}else{
this.hideAdBlockingError();
if(_7c){
_7c();
}
}
},onStopTrack:function(_7d){
if(LFM.Page.InteractionTimer){
LFM.Page.InteractionTimer.stop();
}
if(!_7d&&!this.retuning){
LFM.Omniture.prepareEvar("ClickSource","stopBtn");
LFM.Omniture.trackEvents("StopPlayer");
this.switchPanes("simpleStarter");
this.clearCurrentStation();
}
},clearCurrentStation:function(){
$$(".nowPlaying").invoke("hide");
this.currentStation=null;
LFM.Adserver.setZone(LFM.Adserver.landingZone);
this.updateLocationHash();
},getLocationHash:function(){
var _7e=window.location.hash.substr(1).toQueryParams();
if(_7e.station){
_7e.station=decodeURIComponent(_7e.station);
}
return _7e;
},updateLocationHash:function(){
var _7f=this.getLocationHash();
var _80={pane:this.currentPane};
if(this.hasCurrentStation()){
_80.station=this.getDecodedCurrentStationURL();
}
if((_80.pane!=_7f.pane)||(_80.station!=_7f.station)){
this.updating_hash=true;
setTimeout(function(){
if(_80.station){
_80.station=encodeURIComponent(_80.station);
}
var _81=Object.toQueryString(_80);
window.location.hash=_81;
this.updating_hash=false;
}.bind(this),100);
}
},checkAdBlocking:function(){
if((LFM.isAdBlocking()&&$("adBlockError"))&&!this.adsLoaded){
Effect.SlideDown($("adBlockError"));
}
},hideAdBlockingError:function(){
this.adsLoaded=true;
if($("adBlockError")){
$("adBlockError").hide();
}
}})});
LFM.set("RadioPrototype",{Component:Class.create({rsmInstance:null,notify:function(_82,_83){
if(this.rsmInstance===null){
throw "rsmInstance is null";
}
setTimeout(function(){
this.rsmInstance.callbacks[_82].apply(this.rsmInstance,_83);
},1);
}})});
LFM.set("RadioPrototype",{ErrorDisplay:Class.create({onError:function(_84){
}})});
LFM.set("RadioPrototype",{LibraryActions:Class.create({proxy:LFM.Flash.Player,love:function(_85){
proxy.love(_85);
},ban:function(){
proxy.ban(track);
}})});
LFM.set("RadioPrototype",{ListComponent:Class.create(LFM.RadioPrototype.Component,{CLASS_OPEN:"open",CLASS_CLOSED:"closed",elements:{container:null},url:null,initialize:function(url,_87){
this.url=url;
this._initializeDOM(_87);
},_initializeDOM:function(_88){
Object.extend(this.elements,_88);
},refresh:function(){
this._currentRequest=new Ajax.Request(this.url,{method:"get",onSuccess:this.onRefreshComplete.bind(this)});
},onRefreshComplete:function(){
},open:function(){
this.elements.container.addClassName(this.CLASS_OPEN);
this.elements.container.removeClassName(this.CLASS_CLOSED);
},close:function(){
this.elements.container.addClassName(this.CLASS_CLOSED);
this.elements.container.removeClassName(this.CLASS_OPEN);
},toggle:function(){
if(this.isOpen()){
this.close();
}else{
this.open();
}
},isOpen:function(){
return !this.elements.container.hasClassName(this.CLASS_CLOSED);
}})});
LFM.set("RadioPrototype",{PageManager:Class.create(LFM.RadioPrototype.Component,{onUnload:function(){
},setupLogging:function(){
},interaction:function(){
},updateTitle:function(_89){
},})});
LFM.set("RadioPrototype",{RecentStations:Class.create(LFM.RadioPrototype.ListComponent,{})});
LFM.set("RadioPrototype",{RecentTracks:Class.create(LFM.RadioPrototype.ListComponent,{url:"/radio/ajax/recentTracks"})});
LFM.set("RadioPrototype",{SettingsStore:Class.create(LFM.RadioPrototype.Component,{})});
LFM.set("RadioPrototype",{Slideshow:Class.create(LFM.RadioPrototype.Component,{flash:null,elements:{photoCredit:null,photoCreditAuthor:null},initialize:function(_8a){
this.flash=_8a;
},load:function(_8b){
this.flash.loadArtist(_8b);
this.hidePhotoCredit();
},stop:function(){
this.flash.stopPlayback();
this.hidePhotoCredit();
},showPhotoCredit:function(){
this.elements.photoCredit.show();
},hidePhotoCredit:function(){
this.elements.photoCredit.hide();
},updatePhotoCredit:function(_8c){
this.showPhotoCredit();
},toggleAnimation:function(){
if(this.isAnimating()){
this.flash.stopAnimation();
}else{
this.flash.startAnimation();
}
},isAnimating:function(){
return this.flash.isAnimating();
},hide:function(){
}})});
LFM.set("RadioPrototype",{StateManager:Class.create({initialize:function(){
this.player=new LFM.RadioPrototype.Player();
this.adsManager=new LFM.RadioPrototype.AdsManager();
this.slideshow=new LFM.RadioPrototype.Slideshow();
this.errorDisplay=new LFM.RadioPrototype.ErrorDisplay();
this.library=new LFM.RadioPrototype.LibraryActions();
this.trackInfo=new LFM.RadioPrototype.PlayerMetadata();
this.controls=new LFM.RadioPrototype.PlayerControls();
},fuckingGo:function(){
this.adsManager.refreshAds();
},onSkip:function(){
this.adsManager.refreshAds();
this.player.skip();
this.slideshow.stop();
},onLove:function(){
this.library.love();
this.adsManager.refreshAds();
},onBan:function(){
this.library.ban();
this.adsManager.refreshAds();
},onError:function(_8d){
this.controls.setStopped();
this.trackInfo.hide();
this.slideshow.hide();
this.errorDisplay.onError(_8d);
},onVolumeChange:function(_8e){
LFM.setCookie("lfmVol",_8e);
},onRefreshAdsComplete:function(_8f){
switch(this.player.getPlayState()){
case this.player.STATION_PLAYING:
break;
case this.player.STATION_STOPPED:
break;
default:
break;
}
},onTrackStart:function(){
},onTrackEnd:function(){
},onPlayback:function(_90){
this.trackInfo.onPlayback(_90);
},onBuffering:function(_91){
this.trackInfo.onBuffering(_91);
},onSlideshowToggle:function(){
this.slideshow.toggleAnimation();
LFM.Ajax.setUserPref("webRadioSlideshow",this.slideshow.isAnimating()?1:0);
},onScrobblingToggled:function(){
},onSlideshowPhotoChange:function(_92){
}})});
LFM.set("RadioPrototype",{TrackMetadata:Class.create(LFM.RadioPrototype.Component,{elements:[],hide:function(){
}})});
LFM.set("Radio",{Metadata:Class.create({currentTrack:null,currentTrackNum:null,newTrack:null,playing:false,artistInfoBlinding:false,waitingShowResponseArg:false,shoutSuccess:"0",originalTitle:document.title,isLovedTrack:false,statusTimer:null,scrobbling:true,slideshow:true,stopOnTrackComplete:false,initialize:function(_93,_94){
if($("scrobbleToggle")){
$("scrobbleToggle").observe("click",this.scrobbleToggle.bind(this));
}
if($("slideshowToggle")){
$("slideshowToggle").observe("click",this.slideshowToggle.bind(this));
}
},onLoad:function(){
LFM.info("Flash player loaded");
LFM.logGroup("Flash player listeners");
LFM.Flash.Player.addEventListener("playback",this.onPlayback);
LFM.Flash.Player.addEventListener("nextTrack",this.onNextTrack.bind(this));
LFM.Flash.Player.addEventListener("completeTrack",this.onCompleteTrack.bind(this));
LFM.Flash.Player.addEventListener("stopTrack",this.onStopTrack.bind(this));
LFM.Flash.Player.addEventListener("error",this.onError.bind(this));
LFM.Flash.Player.addEventListener("bufferingStart",this.onBufferingStart.bind(this));
LFM.Flash.Player.addEventListener("loveTrack",this.onLoveTrack.bind(this));
LFM.Flash.Player.addEventListener("tune",this.onTune.bind(this));
LFM.Flash.Player.addEventListener("unsupportedPlayerVersion",this.onUnsupportedPlayerVersion.bind(this));
LFM.Flash.Player.addEventListener("getSession",this.onGetSession.bind(this));
LFM.logGroupEnd();
this.setScrobblingPref();
},onGetSession:function(){
LFM.info("getSession is in");
LFM.Flash.Player.readyToTune=true;
LFM.Flash.PreRoll.onGetSession();
},setScrobblingPref:function(){
if(!LFM.Page.Metadata.scrobbling){
LFM.Flash.Player.switchOffScrobbling();
}
},onError:function(_95){
log("Flash Player event: onError: "+_95.code+" : "+_95.message);
if(_95.code==1){
$("stationPlaybackContentError").show();
this.setStatus({type:"error",message:"Not enough content"});
this.onStopTrack(LFM.Page.RadioState.hasCurrentStation());
}else{
if(_95.code==2){
$("stationPlaybackConnectionError").show();
this.setStatus({type:"error",message:"Connection error"});
this.onStopTrack(LFM.Page.RadioState.hasCurrentStation());
}else{
if(_95.code==3){
this.setStatus({type:"error",message:_95.message});
this.onStopTrack(true);
this.inactivityDialog();
}
}
}
if(!LFM.Page.RadioState.hasCurrentStation()){
LFM.Page.RadioState.newStationError();
}
LFM.Page.RadioState.fixPaneHeight();
},onBufferingStart:function(_96){
},onLoveTrack:function(_97){
LFM.Adserver.refreshAds(true);
},onUnsupportedPlayerVersion:function(_98){
},onTune:function(_99){
},onPlayback:function(_9a){
},onCompleteTrack:function(){
if(this.stopOnTrackComplete){
LFM.log("Soft Stopping player");
this.inactivityDialog();
LFM.Flash.Player.stop();
}
},onNextTrack:function(_9b,_9c){
LFM.log("flash player onNextTrack event: "+_9b.albumImage);
if(_9b.manual){
this.logSkip();
}
if(!_9c){
_9c=0;
}
this.currentTrack=_9b;
this.playing=true;
if(_9b.manual){
setTimeout(function(){
LFM.Adserver.refreshAds();
},1000);
}
if(this.hasShout()){
log("has shout");
functionArguments=[_9b];
this.finishShout(LFM.Flash.Player.context.onNextTrack.bind(this),functionArguments);
}else{
}
},loadArtist:function(_9d){
},logInteraction:function(e,_9f){
},interactionTimeout:function(){
LFM.log("Stop after this track");
this.stopOnTrackComplete=true;
LFM.Flash.Player.stopOnNextTrack();
},onStopTrack:function(_a0){
if(this.stopOnTrackComplete){
this.stopOnTrackComplete=false;
_a0=true;
}
this.playing=false;
if(this.hasShout()){
this.finishShout("onFlashPlayerStopTrack");
}else{
}
},logSkip:function(){
},logScroll:function(){
},logFocus:function(){
},clickSniffer:function(_a1){
},focusCallback:function(){
},scrollSniffer:function(){
},finishShout:function(_a2,_a3){
if(!$("shoutOutOutOutOut").visible){
new Effect.BlindDown("shoutOutOutOutOut",{duration:0.3});
}
if(LFM.Page.Shoutboxen){
actsAsAspect(LFM.Page.Shoutboxen.shoutbox);
LFM.Page.Shoutboxen.shoutbox.after("addShout",function(){
$("shoutmsg").value="";
_a3.push(1);
log("function arguments:");
_a3.each(function(arg){
log(arg);
});
_a2.apply(this,_a3);
});
$$("#shoutOutOutOutOut a")[0].observe("click",function(e){
$("shoutmsg").value="";
_a2.apply(this,_a3);
e.stop();
}.bind(this));
}
},getMetadata:function(_a6,_a7,_a8){
},getArtistInfo:function(_a9,_aa,_ab){
},waitedShowResponse:function(){
},handleMetadataResponse:function(_ac){
if(this.playing){
this.updateFreeTrialMessage(ajaxResponse);
LFM.Adserver.setTandemID(ajaxResponse.get("lfmtandem"));
}
this.setNewWindowTooltips();
},onFreeTrialExpiry:function(){
log("Free trial expire");
if($("trialStart")){
$("trialStart").hide();
}
$("midTrial").hide();
$("trialExpired").show();
this.onStopTrack();
LFM.Page.RadioState.newStationError(LFM.Session.ERROR_TRIAL_EXPIRED);
},updateFreeTrialMessage:function(_ad){
if(!_ad.get("freeTrial")){
return;
}
if($("trialStart")){
$("trialStart").hide();
}
var _ae=_ad.get("freeTrialLeft");
log("Free trial left: "+_ae);
if(_ae==0){
log("Trial ended");
$("midTrial").hide();
$("trialExpired").show();
return;
}else{
if(_ae<=5){
color=LFM.get("Page","trialRemainColourFinal");
}else{
color=LFM.get("Page","trialRemainColour");
}
}
var _af=$("trialLeftProgressBar");
if(_af){
var _b0=_ad.get("freeTrialPercentLeft")+"%";
log("Update progress: "+color+" / "+_b0);
_af.setStyle({width:_b0,background:"#"+color});
var _b1={"trialLastPlay":(_ae==1),"trialFewPlaysLeft":(_ae<=5&&_ae!=1),"trialPlaysLeft":(_ae>5)};
for(trialMessageID in _b1){
var _b2=$(trialMessageID);
if(_b2){
if(_b1[trialMessageID]){
log("Show: "+trialMessageID);
var _b3=_b2.down("span.trialPlaysCount");
if(_b3){
_b3.update(_ae);
}
_b2.show();
}else{
log("Hide: "+trialMessageID);
_b2.hide();
}
}
}
$("midTrial").show();
}
},hasShout:function(){
if($("shoutmsg")){
return shout=$F("shoutmsg").strip()!="";
}else{
return false;
}
},removeContent:function(){
},setNewWindowTooltips:function(){
$$("#nowPlayingMeta a").each(function(e){
if(!(e.up(".buttons")||e.hasClassName("toggle")||e.hash=="#toggle")){
e.setAttribute("title",LFM.String.newWindowTooltip);
}
});
},setStatus:function(_b5){
},disablePlayerControls:function(){
},enablePlayerControls:function(){
},scrobbleToggle:function(e){
LFM.Page.Metadata.logInteraction(e,true);
this.scrobbling=!this.scrobbling;
LFM.Flash.Player.scrobble(this.scrobbling);
$("nowPlayingMeta").toggleClassName("scrobbling-enabled");
var _b7=this.scrobbling?LFM.String.scrobblingEnabled:LFM.String.scrobblingDisabled;
_b7=_b7+" "+LFM.String.scrobblingHelp;
this.setStatus({type:"info",message:_b7,duration:5000});
$("scrobbleToggle").toggleClassName("enabled");
LFM.Ajax.setUserPref("webRadioScrobbling",this.scrobbling?1:0);
},slideshowToggle:function(e){
LFM.Page.Metadata.logInteraction(e,true);
log("slideshowtoggle called");
this.slideshow=!this.slideshow;
$("slideshowToggle").toggleClassName("enabled");
var _b9=this.slideshow?LFM.String.slideshowEnabled:LFM.String.slideshowDisabled;
this.setStatus({type:"info",message:_b9,duration:5000});
if(LFM.Session.loggedIn){
LFM.Ajax.setUserPref("webRadioSlideshow",this.slideshow?1:0);
}
if($("lfmSlideshow")&&$("lfmSlideshow").toggleAnimation){
try{
$("lfmSlideshow").toggleAnimation();
}
catch(e){
LFM.error("Error calling Slideshow.toggleAnimation()");
LFM.log(e);
}
}else{
LFM.warn("slideshow unavailable toggleAnimation()");
}
},updateSlideshowPhoto:function(_ba){
},inactivityDialog:function(){
var _bb=LFM.AJAXDialogWrapper("/ajax/dialog/stilllistening",{title:LFM.String.stillListening,fadeDone:true,modal:true,parameters:{width:"500px"},onConfirm:function(e){
e.stop();
LFM.refreshPage();
this.hide();
},onCancel:function(){
LFM.Page.Metadata.onStopTrack();
this.hide();
}});
_bb({id:LFM.Page.RadioState.currentStation.id,type:LFM.Page.RadioState.currentStation.type,url:LFM.Page.RadioState.currentStation.url},{});
},problemDialog:function(_bd){
var _be=LFM.AJAXDialogWrapper("/ajax/dialog/radioproblem",{title:LFM.String.radioProblems,fadeDone:true,modal:true,parameters:{width:"500px",isAdBlocking:_bd},onConfirm:function(e){
e.stop();
LFM.refreshPage();
this.hide();
}});
_be();
}})});
LFM.set("RadioPrototype",{AdsManager:Class.create(LFM.RadioPrototype.Component,{elements:["LastAd_Top"],initialize:function(){
},refreshAds:function(){
if(LFM.Adserver.showAds){
$(document.body).setStyle({backgroundColor:"teal"});
this.refreshAdsComplete();
}else{
$(document.body).setStyle({background:"maroon"});
this.refreshAdsComplete();
}
},refreshAdsComplete:function(){
this.communicate("refreshAdsComplete",[1,2,3]);
}})});
LFM.set("RadioPrototype",{PlayerControls:Class.create(LFM.RadioPrototype.Component,{volume:{min:0,max:100,current:80},elements:{volumeSlider:null,volumeSliderHandle:null,volumeMute:null,volumeFull:null},volumeSlider:null,initialize:function(_c0,_c1){
if(_c0&&_c0.volume){
this.volume.current=_c0.volume;
}
this._initializeDOM(_c1);
this.setupVolumeControls();
},_initializeDOM:function(_c2){
Object.extend(this.elements,_c2);
},setupVolumeControls:function(){
this.volumeSlider=new Control.Slider(this.elements.volumeSliderHandle,this.elements.volumeSlider,{range:$R(this.volume.min,this.volume.max),sliderValue:this.getVolume(),onSlide:this.setVolume.bind(this),onChange:this.setVolume.bind(this)});
this.elements.volumeMute.observe("click",this.setVolumeMin.bind(this));
this.elements.volumeFull.observe("click",this.setVolumeMax.bind(this));
},getVolume:function(){
return this.volume.current;
},setVolume:function(_c3){
_c3=Math.round(_c3);
if(_c3>this.volume.max){
_c3=this.volume.max;
}else{
if(_c3<this.volume.min){
_c3=this.volume.min;
}
}
if(_c3!=this.getVolume()){
this.volume.current=_c3;
this.volumeSlider.setValue(_c3);
document.fire("lfm:radio:setVolume",{volume:_c3});
}
},setVolumeMin:function(){
this.setVolume(this.volume.min);
},setVolumeMax:function(){
this.setVolume(this.volume.max);
},setStopped:function(){
},togglePlayAndStop:function(){
},disable:function(){
},enable:function(){
},setupControls:function(){
}})});
LFM.set("RadioPrototype",{FlashPlayer:Class.create(LFM.RadioPrototype.Component,{})});
LFM.set("RadioPrototype",{PlayerMetadata:Class.create(LFM.RadioPrototype.Component,{elements:[],setNowPlaying:function(){
},updatePlayback:function(){
},onBuffering:function(_c4){
},onPlayback:function(_c5){
},hide:function(){
}})});
LFM.set("RadioPrototype",{Player:Class.create({STATION_STOPPED:"stopped",STATION_PLAYING:"playing",metadata:null,_playState:null,initialize:function(){
this.flashPlayer=LFM.Flash.Player;
},tune:function(){
},play:function(){
this.flashPlayer.play();
},stop:function(){
this.flashPlayer.stop();
},skip:function(){
this.flashPlayer.skip();
},setStatus:function(){
},setVolume:function(_c6){
},setPlayState:function(_c7){
this._playState=_c7;
},getPlayState:function(){
return this._playState;
}})});


