LFM.set("Activityfeed",{DeleteListener:Class.create({initialize:function(){
document.observe("click",this.bin.bindAsEventListener(this));
},bin:function(_1){
var _2=_1.findElement("a.removeActivity");
if(!_2){
return;
}
_1.stop();
var _3=_2.up("li");
new Ajax.Request("/ajax/deleteActivity",{parameters:{ajax:1,activities:_3.id,formtoken:LFM.Session.formtoken},onComplete:function(_4){
var _5=new LFM.Ajax.Response(_4);
if(_5.isSuccess()){
_3.remove();
}
}});
}})});
LFM.set("Activity",{buildFeedItem:function(_6){
var _7=new Element("ul",{"class":"minifeedSmall"});
var li=new Element("li",{"class":_6.action});
if(_6.icon){
li.insert(_6.icon);
}
li.insert(_6.message);
_7.update(li);
return _7;
}});
LFM.set("Util",{AdblockDetector:Class.create({initialize:function(){
},isBlocking:function(){
if(LFM.Session.language!="en"){
return false;
}
return this.isABP();
},isABP:function(){
return this.isEasyList();
},isEasyList:function(){
if($("footer_ads")&&$("footer_ads").visible()&&$("footer_ads").getStyle("-moz-binding")){
return $("footer_ads").getStyle("-moz-binding").include("abp-elemhidehit");
}
}})});
LFM.set("Library",{AddListener:Class.create({options:{},initialize:function(_9,_a){
this.bindTo=$(_9);
this.bindTo.observe("click",this._onClick.bindAsEventListener(this));
Object.extend(this.options,_a||{});
},_onClick:function(e){
var _c=e.element();
if(!_c||!_c.hasClassName("lfmAddButton")){
return true;
}
e.stop();
this._showDialog(this.options.resource||{url:_c.getAttribute("href")});
},_showDialog:function(_d){
var _e="/ajax/dialog/add";
var _f={resource:_d,onConfirm:this._onConfirmDialog.bindAsEventListener(this)};
this._dialog=new LFM.Dialog(_f);
this._dialog.show(_e);
},_onConfirmDialog:function(e){
}})});
LFM.set("Adserver",{getSponsoredByBranding:function(_11,_12,_13,_14){
var _15=new Element("div",{"class":"brand"});
if(!_14){
var _16=new Element("img",{"class":"sponsored",src:LFM.Session.staticHost+"/promotions/notifications_presented_grey.gif",width:88,height:5}).setStyle({padding:"2px 0"});
}
var _17=new Element("img",{src:_11,width:1,height:1}).setStyle({position:"absolute",top:0,left:0,visibility:"hidden"});
if(_12){
var _18=new Element("img",{src:_12,width:88,height:31});
if(_13){
_18=_18.wrap(new Element("a",{href:_13,target:"_blank"}));
}
if(_16){
_15.insert(_16);
}
_15.insert(_18);
}
_15.insert(_17);
return _15;
}});
LFM.set("Library",{AlbumStrip:Class.create({initialize:function(_19){
this._albumstrip=$(_19);
this._albumstrip.addClassName("js");
this._wrapper=this._albumstrip.down("div.wrapper");
this._wrapper.setStyle({overflow:"hidden"});
this._list=this._wrapper.down("ul");
if(this._list){
this._listItems=this._list.childElements();
}
this._currentFilterName=false;
this._leftButton=new Element("a",{"class":"leftButton",href:"#"});
this._rightButton=new Element("a",{"class":"rightButton",href:"#"});
this._albumstrip.insert(this._leftButton);
this._albumstrip.insert(this._rightButton);
this._offset=0;
this._itemcount=this._listItems?this._listItems.length:0;
var _1a=Prototype.Browser.WebKit?window:document;
var _1b=Prototype.Browser.WebKit?"load":"dom:loaded";
Event.observe(_1a,_1b,function(){
this._itemwidth=this._list.down("li").getWidth();
this._reflow();
Event.observe(window,"resize",this._reflow.bindAsEventListener(this));
this._leftButton.observe("click",this.scrollLeft.bindAsEventListener(this));
this._rightButton.observe("click",this.scrollRight.bindAsEventListener(this));
}.bind(this));
},setUpFilter:function(_1c){
this._filteredTable=$(_1c);
startTimer("setUpFilter");
this._filterDataTable={};
this._filterDataTable.albums=[];
this._filterDataTable.everything=this._filteredTable.select("tbody tr");
this._filterDataTable.everything.each(function(row){
var _1e=row.className.split(" ");
_1e.each(function(_1f){
if(_1f.substring(0,5)=="album"){
if(!this._filterDataTable.albums[_1f]){
this._filterDataTable.albums[_1f]=[];
}
this._filterDataTable.albums[_1f].push(row);
}
}.bind(this));
}.bind(this));
stopTimer("setUpFilter");
this._albumstrip.observe("click",this._filter.bindAsEventListener(this));
},_filter:function(_20){
if(!this._maxHeight){
this._maxHeight=this._filteredTable.up().getHeight();
this._filteredTable.up().setStyle({height:this._maxHeight+"px"});
var _21=this._filterDataTable.everything.first().select("td");
var _22=this._filteredTable.down("thead tr").select("th");
for(var i=_22.length-1;i>=0;i--){
var _24=_21[i].getWidth();
var _24=_24-20;
_22[i].setStyle({width:_24+"px"});
}
}
var _25=_20.findElement("a");
if(!_25){
return;
}
_20.stop();
if(_25.up("h3")){
_25.up("h3").addClassName("current");
this._listItems.invoke("removeClassName","selected");
if(!this._currentFilterName){
return;
}else{
this._currentFilterName=false;
this._filteredTable.show();
$("noTracksMessage").hide();
this._filterDataTable.everything.invoke("show");
LFM.Display.candyStripe(this._filteredTable);
}
}else{
var _26=_25.up("li").className.split(" ");
var _27="";
_26.each(function(_28){
if(_28.substring(0,5)=="album"){
_27=_28;
}
}.bind(this));
if(_27){
this._albumstrip.down("h3").removeClassName("current");
this._listItems.invoke("removeClassName","selected");
_25.up("li").addClassName("selected");
this._currentFilterName=_27;
this._filterDataTable.everything.invoke("hide");
if(this._filterDataTable.albums[_27]){
this._filterDataTable.albums[_27].invoke("show");
LFM.Display.candyStripe(this._filterDataTable.albums[_27]);
this._filteredTable.show();
$("noTracksMessage").hide();
}else{
this._filteredTable.hide();
$("noTracksMessage").show();
}
}else{
return;
}
}
},scrollRight:function(_29){
if(_29){
_29.stop();
}
var _2a=this._offset-this._itemwidth;
if(_2a*-1>this._list.getWidth()-this._wrapper.getWidth()){
_2a=this._wrapper.getWidth()-this._list.getWidth();
}
this._offset=_2a;
new Effect.Morph(this._list,{style:{left:_2a+"px"},duration:0.3,queue:{position:"end",scope:"scrollscope"}});
},scrollLeft:function(_2b){
if(_2b){
_2b.stop();
}
var _2c=this._offset+this._itemwidth;
if(_2c>0){
_2c=0;
}
this._offset=_2c;
new Effect.Morph(this._list,{style:{left:_2c+"px"},duration:0.3,queue:{position:"end",scope:"scrollscope"}});
},_reflow:function(){
var _2d=true;
var _2e=this._albumstrip.getWidth()-this._leftButton.getWidth()-this._rightButton.getWidth();
log(_2e);
var _2f=Math.floor(_2e/this._itemwidth);
if(_2f>=this._itemcount){
_2d=false;
_2f=this._itemcount;
}
var _30=_2f*this._itemwidth;
this._wrapper.setStyle({width:_30+"px"});
if(_2d){
this._leftButton.show();
this._rightButton.show();
}else{
this._leftButton.hide();
this._rightButton.hide();
}
}})});
LFM.set("Form",{Attachbutton:Class.create({initialize:function(_31,_32){
this.button=$(_31);
if(!_32){
_32={};
}
this.options=_32;
this._bindToButton();
},_bindToButton:function(){
Event.observe(this.button,"click",function(e){
Event.stop(e);
var _34=new LFM.Form.ResourcePicker({onSelect:this._onSelect.bind(this)});
_34.show();
}.bindAsEventListener(this));
},_onSelect:function(res){
if(res){
this._appendAttachment(res.type,res.id);
}
},_appendAttachment:function(_36,id){
if(!this.itemcontainer&&this.options.itemcontainer){
this.itemcontainer=$(this.options.itemcontainer);
}
if(this.itemcontainer){
this.itemcontainer.show();
this.itemcontainer.down("img.progress").show();
new Ajax.Request("/ajax/attachment",{method:"get",parameters:"type="+_36+"&id="+id,onComplete:this._appendAttachmentCallback.bind(this)});
}
var _38=this.button.up("form");
if(_38){
var _39=_38.down("input[name=attachmenttype]");
var _3a=_38.down("input[name=attachmentid]");
if(!_39){
var _39=document.createElement("input");
_39.setAttribute("type","hidden");
_39.setAttribute("name","attachmenttype");
var _3a=document.createElement("input");
_3a.setAttribute("type","hidden");
_3a.setAttribute("name","attachmentid");
_39.setAttribute("value",_36);
_3a.setAttribute("value",id);
_38.appendChild(_39);
_38.appendChild(_3a);
}else{
_39.setAttribute("value",_36);
_3a.setAttribute("value",id);
}
}
},_appendAttachmentCallback:function(req){
var _3c=req.responseText.evalJSON();
if(this.itemcontainer){
this.itemcontainer.insert({top:_3c.attachment});
this.itemcontainer.down("img.progress").hide();
}
}})});
LFM.set("Button",{MultiButton:{setup:function(){
this.activeButton=false;
this.menu=$("multiButtonMenu");
this.loadedInfo=$H();
this.menu.observe("click",this.observeMenu.bindAsEventListener(this));
$("page").observe("click",this.observeDocument.bindAsEventListener(this));
this.clickOffObserver=this.clickOff.bindAsEventListener(this);
this.parentIsUser=LFM.ParentResource&&LFM.ParentResource.type==4;
this.parentIsLoggedInUser=LFM.Session.loggedIn&&this.parentIsUser&&LFM.ParentResource.name==LFM.Session.userName;
},observeDocument:function(e){
var _3e=e.findElement("a.lfmMultiButton");
if(!_3e){
return false;
}
e.stop();
if(this.activeButton&&this.activeButton!=_3e){
this.clickOff();
}else{
if(this.activeButton&&this.activeButton==_3e){
this.clickOff();
return;
}
}
this.activeButton=_3e;
if(this.activeButton.hasClassName("lfmSmallButton")){
this.activeButton.addClassName("lfmSmallActiveMultiButton");
}else{
this.activeButton.addClassName("lfmBigActiveMultiButton");
}
if(this.activeButton.hasClassName("mBuy")){
this.updatePriceFromAjax();
}
if(LFM.Session.loggedIn&&!this.parentIsLoggedInUser&&_3e.hasClassName("lfmButtonFortrack")){
this.updateMenuFromAjax(this.activeButton);
}else{
this.showMenu(this.activeButton);
}
document.observe("click",this.clickOffObserver);
},clickOff:function(){
this.hideMenu(this.activeButton);
this.activeButton.removeClassName("lfmSmallActiveMultiButton");
this.activeButton.removeClassName("lfmBigActiveMultiButton");
this.activeButton=false;
var _3f=this.menu.down("li.mBuy a span");
if(_3f){
_3f.remove();
}
document.stopObserving("click",this.clickOffObserver);
},updatePriceFromAjax:function(){
this.menu.down("li.mBuy a").insert(" <img class=\"loading\" src=\""+LFM.Session.staticHost+"/flatness/spinner_13x13.gif\" height=\"7\" />");
var _40=new Ajax.Request("/ajax/affiliableprice",{parameters:{url:this.activeButton.href,cachebuster:Math.round(Math.random()*100)},method:"get",onComplete:function(_41){
this.menu.down("li.mBuy a img").remove();
if(_41.responseText){
this.menu.down("li.mBuy a").insert(" "+_41.responseText);
}
}.bind(this)});
},updateMenuFromAjax:function(_42){
var _42=_42;
if(this.loadedInfo.get(_42.href)){
_42.className=this.loadedInfo.get(_42.href);
this.sortOutClassNames(_42);
this.showMenu(_42);
}else{
var _43=new Ajax.Request("/ajax/library/gettrackinfo",{parameters:{url:_42.href,cachebuster:Math.round(Math.random()*100)},method:"get",onComplete:function(_44){
var _45=new LFM.Ajax.Response(_44);
if(_45.isSuccess()){
if(_45.get("loved")){
_42.removeClassName("mLove");
_42.addClassName("mUnlove");
}else{
_42.addClassName("mLove");
_42.removeClassName("mUnlove");
}
if(_45.get("banned")){
_42.removeClassName("mBan");
_42.addClassName("mUnban");
}else{
if(_42.hasClassName("lfmMultiButtonAllowBan")){
_42.addClassName("mBan");
}
_42.removeClassName("mUnban");
}
if(_42.hasClassName("lfmMultiButtonFull")){
if(_45.get("playcount")!==null){
_42.addClassName("mRemoveFromLibrary");
_42.removeClassName("mAddToLibrary");
}else{
_42.removeClassName("mRemoveFromLibrary");
_42.addClassName("mAddToLibrary");
}
}
this.loadedInfo.set(_42.href,_42.className);
}
if(_42==this.activeButton&&!_43.shown){
this.sortOutClassNames(_42);
this.showMenu(_42);
}
}.bind(this)});
(function checkTimeout(){
if(!(_43&&_43.getStatus()==200)&&_42==this.activeButton){
_43.shown=true;
this.sortOutClassNames(_42);
this.showMenu(_42);
}
}).bind(this).delay(0.5);
}
},showMenu:function(_46,_47){
var _47=_47||{};
var _48=_46.cumulativeOffset();
var _49=$("page").cumulativeOffset();
_48.left=_48.left-7-_49.left;
_48.top=_48.top+_46.getHeight()-_49.top;
var _4a=this.activeButton.getWidth();
if(Prototype.Browser.IE){
if(window.external&&typeof window.XMLHttpRequest=="undefined"){
_48.left=_48.left-35;
}else{
if(_46.hasClassName("lfmSmallMultiButton")&&_46.up("div.module")){
_48.left=_48.left-15;
}
}
}
this.menu.setStyle({top:_48.top+"px",left:_48.left+"px"});
var _4b=this.menu.down("ul");
_4a=_4a-_4b.getStyle("border-left-width").toPixels()-_4b.getStyle("border-right-width").toPixels()-_4b.getStyle("padding-left").toPixels()-_4b.getStyle("padding-right").toPixels();
_4b.setStyle({minWidth:_4a+"px"});
$w("tr li").each(function(_4c){
var _4d=_46.up(_4c);
if(_4d){
_4d.addClassName("open");
}
});
var _4e=_47.showLoadingState?"mLoading":false;
this.sortOutClassNames(_46,_4e);
this.menu.show();
},hideMenu:function(_4f){
$w("tr li").each(function(_50){
var _51=_4f.up(_50);
if(_51){
_51.removeClassName("open");
}
});
this.menu.down("ul").setStyle({minWidth:"0px"});
this.menu.hide();
},sortOutClassNames:function(_52,_53){
if(_53){
this.menu.className=_53;
this.menu.down("div").className=_53;
}else{
var _54=_52.className.match(/\blfmButtonFor([a-z]*)\b/)[1];
_54+="MultiMenu";
this.menu.className=_54;
var _55=_52.className;
this.menu.down("div").className=_55;
}
},observeMenu:function(e){
e.stop();
var _57=this.activeButton.hasClassName("lfmBigMultiButton")?"moreBtn":"multiBtn";
LFM.Omniture.prepareEvar("ClickSource",_57);
var _58=e.findElement("li").className;
if(Prototype.Browser.IE){
_58=_58.replace(/\b\w*hover_/gi,"").strip();
}
switch(_58){
case "mSave":
LFM.Save({url:this.activeButton.href});
break;
case "mObsess":
LFM.Obsess({url:this.activeButton.href});
break;
case "mAddToPlaylist":
LFM.Playlist({url:this.activeButton.href});
break;
case "mAddTags":
LFM.Tag({url:this.activeButton.href});
break;
case "mAddToFriends":
case "mAddToLibrary":
LFM.Add({url:this.activeButton.href});
break;
case "mRemoveFromLibrary":
LFM.RemoveFromLibrary({url:this.activeButton.href},{onDone:function(_59){
var _5a=LFM.get("Page","LibraryDeleteListener");
var _5b=LFM.get("Page","LibraryRemoveTagFromItemListener");
if(_5a){
_5a.onDone(_59);
}
if(_5b){
_5b.onSuccess(_59);
}
}});
break;
case "mSend":
LFM.Send({url:this.activeButton.href});
break;
case "mEditDetails":
location.href=LFM.ParentResource.url+"/settings";
break;
case "mMessageAll":
location.href=LFM.ParentResource.url+"/messageall";
break;
case "mEditPermissions":
location.href=LFM.ParentResource.url+"/permissions";
break;
case "mAbdicate":
location.href=LFM.ParentResource.url+"/abdicate";
break;
case "mLeave":
LFM.Leave({url:this.activeButton.href},{parameters:{leave:1}});
break;
case "mLove":
this.love.bind(this)(this.activeButton,true);
break;
case "mUnlove":
this.love.bind(this)(this.activeButton,false);
break;
case "mBan":
this.ban.bind(this)(this.activeButton,true);
break;
case "mUnban":
this.ban.bind(this)(this.activeButton,false);
break;
case "mBuy":
LFM.BuyDialog({url:this.activeButton.href});
break;
default:
LFM.Omniture.setEvar("ClickSource","");
break;
}
this.clickOff();
},love:function(_5c,_5d){
var _5e=this.activeButton;
new Ajax.Request("/ajax/library/love",{parameters:{ajax:true,url:_5e.href,loved:_5d,formtoken:LFM.Session.formtoken},onSuccess:function(_5f){
var _60=new LFM.Ajax.Response(_5f);
if(_60.isSuccess()){
var _61=_5e.up("tr");
var _62=_5e.up("li");
if(_61){
if(_61.hasClassName("odd")&&_61.up("table").hasClassName("chart")){
var _63="#f4f4f4";
}else{
var _63="#ffffff";
}
}
if((!this.parentIsUser||this.parentIsLoggedInUser)&&_61){
var _64=_61.down("td.lovedCell");
}else{
if(LFM.ParentResource&&LFM.ParentResource.type==9&&$("lovedIndicator")){
if(_5d){
if(LFM.Page.onAddToLibrary){
LFM.Page.onAddToLibrary(_60);
}
$("lovedIndicator").show();
}else{
$("lovedIndicator").hide();
}
}
}
this.loadedInfo.unset(_5e.href);
if(_5d){
LFM.Omniture.trackEvents("LoveTrack");
_5e.removeClassName("mLove");
_5e.addClassName("mUnlove");
if(_64){
_64.insert({top:LFM.Element.icon_loved_indicator});
}
if(_62){
_62.addClassName("loved");
}
var _65=_60.get("activity");
if(_65){
var _66=LFM.Activity.buildFeedItem(_65);
if(LFM.Adserver.showAds&&LFM.Session.location=="us"){
var _67=LFM.Adserver.getATTNotificationBranding();
}
var _68=new Element("div");
_68.insert(_67);
_68.insert(_66);
LFM.Notification.send(_68);
}
}else{
_5e.addClassName("mLove");
_5e.removeClassName("mUnlove");
if(_64){
var _69=_64.down("img.loved_indicator_icon");
if(_69){
_69.remove();
}
}
if(_62){
_62.removeClassName("loved");
}
}
if(_64){
new Effect.Highlight(_61,{endcolor:_63,afterFinish:function(_6a){
_6a.element.removeAttribute("style");
}});
}
}
}.bind(this)});
},ban:function(_6b,_6c){
var _6d=this.activeButton;
new Ajax.Request("/ajax/library/ban",{parameters:{ajax:true,url:_6d.href,banned:_6c,formtoken:LFM.Session.formtoken},onSuccess:function(_6e){
var _6f=new LFM.Ajax.Response(_6e);
if(_6f.isSuccess()){
var _70=_6d.up("tr");
if(_70){
if(_70.hasClassName("odd")&&_70.up("table").hasClassName("chart")){
var _71="#f4f4f4";
}else{
var _71="#ffffff";
}
}
if(LFM.ParentResource){
if(this.parentIsLoggedInUser&&_70){
var _72=_70.down("td.bannedCell");
}else{
if(LFM.ParentResource.type==9&&$("bannedIndicator")){
if(_6c){
$("bannedIndicator").show();
}else{
$("bannedIndicator").hide();
}
}
}
}
this.loadedInfo.unset(_6d.href);
if(_6c){
if(_72){
_72.insert({top:LFM.Element.icon_banned_indicator});
}
}else{
if(_72){
var _73=_72.down("img.banned_indicator_icon");
if(_73){
_73.remove();
}
}
}
if(_70){
new Effect.Fade(_70,{duration:0.5});
}
}
}.bind(this)});
}},affiliations:{"suppliers[]":[],"restypes[]":[],"resids[]":[]},pushAffiliation:function(_74,_75,_76){
LFM.Button.affiliations["suppliers[]"].push(_74);
LFM.Button.affiliations["restypes[]"].push(_75);
LFM.Button.affiliations["resids[]"].push(_76);
}});
LFM.set("Charts",{Switch:Class.create({initialize:function(_77,_78){
this.container=$(_77);
this.parameters=_78;
this.morelink=this.container.select("span.moduleOptions a")[0]||false;
this.cachedcharts=new Hash();
this.container.down("div.horizontalOptions").observe("click",this.switchChartEvent.bindAsEventListener(this));
this.container.select("div.chart").each(function(_79){
var _7a=this.getRangeTypeFromClassName(_79.className);
if(_7a){
this.cachedcharts.set(_7a,_79);
}
}.bind(this));
},switchChartEvent:function(_7b){
var _7c=_7b.element();
if(!_7c.match("a")){
return;
}
_7b.stop();
var _7d=_7c.up("li");
if(_7d.hasClassName("current")){
return;
}
this.container.down("div.horizontalOptions ul").childElements().invoke("removeClassName","current");
_7d.addClassName("current");
var _7e=this.getRangeTypeFromClassName(_7d.className);
this.switchChart(_7e);
},refresh:function(){
this.cachedcharts=new Hash();
this.switchChart();
},switchChart:function(_7f){
if(_7f&&this.cachedcharts.get(_7f)){
this.cachedcharts.each(function(_80){
_80.value.hide();
});
this.cachedcharts.get(_7f).show();
if(this.morelink){
this.morelink.href=this.container.down("ul li.chart"+_7f+" a").href;
}
}else{
var _81=Object.extend(this.parameters,{rangetype:_7f,ajax:1,cachebuster:Math.round(Math.random()*100)});
new Ajax.Request("/module",{method:"get",parameters:_81,onComplete:function(t){
var _83=new LFM.Ajax.Response(t);
if(_83.isSuccess()){
this.container.insert({bottom:_83.get("content").strip()});
var _84=!_7f;
var _85=this.container.childElements().last();
ieHover.add(_85);
if(!_7f){
_7f=this.getRangeTypeFromClassName(_85.className);
this.container.down("div.horizontalOptions ul").childElements().invoke("removeClassName","current");
this.container.down("div.horizontalOptions ul li.chart"+_7f).addClassName("current");
}
this.cachedcharts.set(_7f,_85);
if(this.morelink){
this.morelink.up().insert({before:this.cachedcharts.get(_7f)});
}
if(_84){
this.container.select("div.chart").each(function(_86){
if(_86!=_85){
_86.remove();
}
}.bind(this));
}
this.cachedcharts.each(function(_87){
if(_87.key!=_7f){
_87.value.hide();
}
});
this.cachedcharts.get(_7f).show();
if(this.morelink){
this.morelink.href=this.container.down("ul li.chart"+_7f+" a").href;
}
this.container.removeClassName("loading");
}
}.bind(this),onCreate:function(){
this.container.addClassName("loading");
}.bind(this),onFailure:function(){
this.container.removeClassName("loading");
}.bind(this)});
}
},getRangeTypeFromClassName:function(_88){
var _89=_88.match(/chart[^ ]+/)[0];
return _89.substr(5);
}})});
LFM.set("Display",{candyStripe:function(_8a,_8b){
var _8b=_8b||false;
if(is_array(_8a)){
var _8c=_8a;
}else{
_8a=$(_8a);
if(_8b.selector){
var _8c=_8a.select(_8b.selector);
}else{
if(_8a.tagName=="TABLE"){
_8a=_8a.down("tbody");
}
var _8c=_8a.childElements();
}
}
if(_8c.length>0){
_8c[0].up("table").addClassName("candyStriped");
_8c.each(function(row,i){
if(i%2){
row.removeClassName("odd");
}else{
row.addClassName("odd");
}
row.removeClassName("first");
row.removeClassName("last");
if(_8b.renumber){
var _8f=row.down("td.position");
if(_8f){
_8f.update(i+1);
}
}
});
_8c.first().addClassName("first");
_8c.last().addClassName("last");
}
},toggleSelector:function(_90){
var els=$$(_90);
if(els){
els.each(function(e){
e.toggle();
});
}
}});
document.observe("dom:loaded",function(_93){
$$(".downloadDriver").each(function(_94){
_94.observe("click",function(e){
var el=e.findElement("a");
if(el&&el.match("a")){
var _97=LFM.get("Page","hasManualAdded");
var _98="New user download CTA ("+(_97?"after":"before")+" library add)";
LFM.Omniture.setLink(el,_98);
LFM.Omniture.prepareEvar("ClickSource",_97?"downloadAfterManualAdd":"downloadBeforeManualAdd");
LFM.Omniture.trackEvents();
}
});
});
});
LFM.set("Display",{DropDown:Class.create({initialize:function(_99,_9a,_9b,_9c){
this.container=$(_99);
this.toggler=$(_9a);
this.ddbody=$(_9b);
this.ddbody.hide();
this.ddbody.setStyle({position:"absolute",zIndex:999999});
this.use_iframe=/Linux/.test(navigator.platform);
if(this.use_iframe){
this.iframe=new Element("iframe",{"src":"javascript: false","frameborder":0,"scrolling":"no","allowtransparency":"true"}).setStyle({position:"absolute",zIndex:999998,border:0});
}
this.shownOnce=false;
this.options=_9c||{};
this.container.addClassName("toggle");
this.offBinding=this.clickOff.bindAsEventListener(this);
this.toggler.observe("click",this.toggle.bindAsEventListener(this));
if(this.options.trackItemClick){
this.ddbody.observe("click",this.trackItemClick.bindAsEventListener(this));
}
},hide:function(){
if(this.options.onHide){
this.options.onHide(this);
}
if(this.use_iframe){
this.iframe.setStyle({"display":"none"});
}
this.ddbody.hide();
this.container.removeClassName("expanded");
Event.stopObserving(document,"click",this.offBinding,true);
if(LFM.Display.openDropDown&&LFM.Display.openDropDown==this){
LFM.Display.openDropDown=false;
}
},show:function(){
if(LFM.Display.openDropDown){
LFM.Display.openDropDown.hide(this);
}
if(!this.shownOnce){
if(this.use_iframe){
$("page").insert(this.iframe);
}
$("page").insert(this.ddbody);
this.shownOnce=true;
}
var _9d=this.container.cumulativeOffset();
var _9e=$("page").cumulativeOffset();
_9d.left=_9d.left-_9e.left;
_9d.top=_9d.top+this.container.getHeight()-_9e.top;
if(Prototype.Browser.IE&&this.container.getStyle("display")=="inline-block"){
var _9f=this.toggler.getWidth();
}else{
var _9f=this.container.getWidth();
}
var _a0=$("page").getWidth();
if((this.options.align&&this.options.align=="right")||((_9d.left+this.ddbody.getWidth())>_a0)){
var _a1=(_a0-_9f-_9d.left)+"px";
var _a2="auto";
}else{
var _a2=_9d.left+"px";
var _a1="auto";
if(Prototype.Browser.IE){
if(window.external&&typeof window.XMLHttpRequest=="undefined"){
_a2=(_9d.left-35)+"px";
}
}
}
if(!this.options.autoWidth){
_9f=_9f-this.ddbody.getStyle("border-left-width").toPixels()-this.ddbody.getStyle("border-right-width").toPixels()-this.ddbody.getStyle("padding-left").toPixels()-this.ddbody.getStyle("padding-right").toPixels();
this.ddbody.setStyle({minWidth:_9f+"px"});
if(this.use_iframe){
this.iframe.setStyle({minWidth:_9f+"px"});
}
}
this.ddbody.setStyle({top:_9d.top+"px",left:_a2,right:_a1}).show();
var _a3=this.ddbody.cumulativeOffset();
if(this.use_iframe){
this.iframe.clonePosition(this.ddbody);
this.iframe.show();
}
if(this.options.onShow){
this.options.onShow(this);
}
var tr=this.container.up("tr");
if(tr){
tr.addClassName("open");
}
LFM.Display.openDropDown=this;
this.container.addClassName("expanded");
Event.observe(document,"click",this.offBinding,true);
},toggle:function(_a5){
if(this.ddbody.visible()){
this.hide();
}else{
if(this.options.trackToggle){
LFM.Omniture.prepareEvar("ClickSource",this.options.clickSource||this.container.identify());
LFM.Omniture.trackEvents("DropDown");
}
this.show();
}
if(_a5.findElement("A")){
_a5.findElement("A").blur();
}
_a5.stop();
},clickOff:function(_a6){
var _a7=Event.element(_a6);
var _a8=false;
while(_a7.parentNode){
if(_a7==this.ddbody){
return true;
}else{
if(_a7==this.toggler){
_a8=true;
}
}
_a7=_a7.parentNode;
}
this.hide();
if(_a8){
_a6.stop();
}
},trackItemClick:function(e){
var _aa=e.findElement("a");
if(_aa){
var _ab=_aa.className;
var _ac=this.container.identify();
var _ad=_aa.up("li");
if(_ad){
_ab=_ad.className;
}
LFM.Omniture.setLink(_aa,_ac+":"+_ab);
LFM.Omniture.prepareEvar("ClickSource",_ac);
LFM.Omniture.trackEvents("Click");
}
}})});
var EventCalendar={calendars:null,currentMonth:null,lastRequested:null,next:function(url,_af,_b0){
_af.blur();
Element.addClassName(_af,"busy");
var c=EventCalendar.getCurrentMonth();
var _b2=_b0?EventCalendar.getPrevMonthAfterTable(c):EventCalendar.getNextMonthAfterTable(c);
var _b3=null;
var _b4=null;
if(!_b0){
_b4=document.getElementsByClassName("month-"+_b2,$("calendar"));
_b3=_b4.length>0?_b4[0]:false;
}else{
var m=EventCalendar.getPrevMonthAfterTable(c);
_b4=document.getElementsByClassName("month-"+m,$("calendar"));
_b3=_b4.length>0?_b4[0]:false;
}
if(_b3){
c.style.display="none";
_b3.style.display="table";
EventCalendar.currentMonth=_b3;
Element.removeClassName(_af,"busy");
}else{
if(_b3==-1){
Element.removeClassName(_af,"busy");
}else{
url=url.replace(/startdate=\d+-\d+-\d+(&)?/,"");
url=EventCalendar.convertURL(url);
var _b6=/\?$/.test(url)?"":"&";
EventCalendar.lastRequested=_b2;
var _b7=new Ajax.Request(url+_b6+"startdate="+_b2+"-01",{onSuccess:EventCalendar.receiveMonth.bind(_af),onFailure:EventCalendar.receiveMonthFailed.bind(_af)});
}
}
},prev:function(url,_b9){
EventCalendar.next(url,_b9,true);
},convertURL:function(url){
var _bb=/(events|festivals)/.exec(url);
var _bc=new RegExp("^/"+_bb[1]);
url=url.replace(_bc,"");
return "/"+_bb[1]+"/calendar"+url;
},receiveMonth:function(_bd){
if(_bd.responseText.indexOf("calendar")==-1){
var _be=EventCalendar.receiveMonthFailed.bind(this);
_be();
return;
}
Element.removeClassName(this,"busy");
new Insertion.Bottom("calendar",_bd.responseText);
var _bf=document.getElementsByClassName("calendar",$("calendar"));
if(_bf.length>0){
EventCalendar.currentMonth.style.display="none";
_bf[_bf.length-1].style.display="table";
EventCalendar.currentMonth=_bf[_bf.length-1];
}
},receiveMonthFailed:function(){
Element.removeClassName(this,"busy");
},getNextMonthAfterTable:function(_c0){
var _c1=EventCalendar.getMonthForTable(_c0);
var _c2=_c1.split("-");
var _c3=_c2[0];
var _c4=_c2[1];
if(_c4==12){
_c4=1;
_c3++;
}else{
_c4++;
}
if(_c4<10){
_c4="0"+_c4;
}
return _c3+"-"+_c4;
},getPrevMonthAfterTable:function(_c5){
var _c6=EventCalendar.getMonthForTable(_c5);
var _c7=_c6.split("-");
var _c8=_c7[0];
var _c9=_c7[1];
if(_c9=="01"){
_c9=12;
_c8--;
}else{
_c9--;
}
if(_c9<10){
_c9="0"+_c9;
}
return _c8+"-"+_c9;
},getMonthForTable:function(_ca){
if(_ca.month){
return _ca.month;
}
var _cb=$A(_ca.className.split(/\s+/));
var c=_cb.find(function(c){
return c.substring(0,5)=="month";
});
_ca.month=c.substring(6);
return _ca.month;
},getCurrentMonth:function(){
if(EventCalendar.currentMonth){
return EventCalendar.currentMonth;
}
EventCalendar.calendars=$A(document.getElementsByClassName("calendar",$("calendar")));
EventCalendar.currentMonth=EventCalendar.calendars.find(function(c){
return Element.hasClassName(c,"first");
});
EventCalendar.lastRequested=EventCalendar.getMonthForTable(EventCalendar.currentMonth);
return EventCalendar.currentMonth;
}};
LFM.set("Adserver",{"ExpandingAd":Class.create({inner_id:"",outer_id:"",embed_id:"",adExpandedHeight:0,adExpandedWidth:0,adCollapsedHeight:0,adCollapsedWidth:0,isCollapsing:false,toggleState:false,initialize:function(_cf,_d0,_d1){
this.inner_id=_d0;
this.outer_id=_cf;
this.embed_id=_d1;
this.getDimensions();
this.setStyles();
this.bindEventListeners();
},getDimensions:function(){
this.adExpandedHeight=$(this.embed_id).getHeight();
this.adExpandedWidth=$(this.embed_id).getWidth();
this.adCollapsedHeight=$(this.outer_id).getHeight();
this.adCollapsedWidth=$(this.outer_id).getWidth();
},setStyles:function(){
$(this.outer_id).setStyle({"zIndex":0,"overflow":"visible","position":"relative"});
$(this.inner_id).setStyle({"zIndex":0,"position":"relative","top":0,"text-align":"center"});
},bindEventListeners:function(){
var _d2=this;
$(document).observe("click",function(e){
_d2.collapse();
});
$(this.inner_id).observe("click",function(e){
e.stop();
});
$(this.inner_id).observe("mouseover",function(e){
_d2.isCollapsing=false;
if(_d2.toggleState){
_d2.expand();
}
});
$(this.inner_id).observe("mouseout",function(e){
if(!_d2.isCollapsing){
_d2.isCollapsing=true;
setTimeout(function(){
if(_d2.isCollapsing){
_d2.collapse();
_d2.isCollapsing=false;
}
},2000);
}
});
$(this.embed_id).observe("focus",function(e){
_d2.expand();
_d2.toggleState=true;
});
$(this.embed_id).observe("blur",function(e){
_d2.toggleState=false;
});
},collapse:function(){
$(this.outer_id).setStyle({"zIndex":0});
$(this.inner_id).setStyle({"zIndex":0,"width":this.adCollapsedWidth+"px","height":this.adCollapsedHeight+"px"});
this.isCollapsing=false;
},expand:function(){
$(this.outer_id).setStyle({"zIndex":99999});
$(this.inner_id).setStyle({"zIndex":99999,"width":this.adExpandedWidth+"px","height":this.adExpandedHeight+"px"});
}})});
LFM.set("Form",{Placeholder:Class.create({nativeSupport:Prototype.Browser.WebKit?true:false,required:true,initialize:function(_d9,_da){
if(typeof _da!="undefined"){
this.required=_da;
}
if(_d9){
this.element=$(_d9);
}
if(this.element){
if(this.element.match("input")||this.element.match("textarea")){
this.setUp(this.element);
}else{
this.element.select("input[placeholder]").each(function(_db){
this.setUp(_db);
}.bind(this));
}
}else{
if(!this.element){
$$("input[placeholder]").each(function(_dc){
this.setUp(_dc);
}.bind(this));
}
}
},setText:function(_dd,_de){
_dd.setAttribute("placeholder",_de);
if(!this.nativeSupport||_dd.match("textarea")){
if($F(_dd)==""||_dd.hasClassName("hint")){
_dd.addClassName("hint");
_dd.value=_de;
}
}
},clearPlaceholder:function(_df,_e0){
if($F(_df)==_df.getAttribute("placeholder")){
_df.removeClassName("hint");
_df.value="";
}
_e0.disabled=true;
},resetPlaceholder:function(_e1,_e2){
if(!$F(_e1).strip()){
_e1.addClassName("hint");
_e1.value=_e1.getAttribute("placeholder");
_e2.disabled=false;
}
},setUp:function(_e3){
this.setText(_e3,_e3.getAttribute("placeholder"));
if(!this.nativeSupport||_e3.match("textarea")){
var _e4=new Element("input",{"type":"hidden","name":"placeholder","value":1});
_e3.insert({after:_e4});
_e3.observe("focus",function(e){
this.clearPlaceholder(_e3,_e4);
}.bind(this));
_e3.observe("blur",function(e){
this.resetPlaceholder(_e3,_e4);
}.bind(this));
if(this.required){
var _e7=_e3.up("form");
_e7.observe("submit",function(e){
this.clearPlaceholder(_e3,_e4);
}.bind(this));
}
}
}})});
LFM.set("Form",{focusToRange:0,focusTo:function(_e9,_ea){
if(typeof _ea=="undefined"){
_ea=_e9.value.length;
}
if(_e9.createTextRange){
if(LFM.Form.focusToRange==0){
LFM.Form.focusToRange=_e9.createTextRange();
}
LFM.Form.focusToRange.moveEnd("character",_e9.value.length);
LFM.Form.focusToRange.moveStart("character",_ea);
setTimeout("LFM.Form.focusToRange.select()",10);
}else{
if(_e9.setSelectionRange){
_e9.focus();
_e9.select();
_e9.setSelectionRange(_ea,_e9.value.length);
}else{
_e9.focus();
}
}
}});
LFM.set("FullLengthPlayer",Class.create({soundManager:null,wrapperID:"fullLengthPreview",progressID:"fullLengthPreviewProgressBar",activeClass:"active",wrapperElement:null,progressElement:null,controlElement:null,oTrack:null,sound:null,oScrobbler:null,scrobblePoint:null,hasScrobbled:false,initialize:function(_eb,_ec,_ed){
this.soundManager=_eb;
this.oTrack=_ec;
this.oScrobbler=_ed;
this.soundManager.onready(this.apply.bind(this));
},apply:function(){
if(this.soundManager.supported()){
this.wrapperElement=$(this.wrapperID);
this.progressElement=$(this.progressID);
if(this.wrapperElement&&this.progressElement){
this.controlElement=this.wrapperElement.down("a");
this.controlElement.observe("click",this.onClick.bindAsEventListener(this));
this.scrobblePoint=this.oScrobbler.getScrobblePoint(this.oTrack);
if(this.wrapperElement.hasClassName("autoplay")){
this.play();
}
}
}
},show:function(){
this.progressElement.slideDown({duration:0.4});
},hide:function(){
this.progressElement.slideUp({duration:0.4});
},getAudioURL:function(){
var _ee=this.controlElement.getAttribute("href");
if(!_ee.endsWith(".mp3")){
_ee=this.decodeAudioURL(this.controlElement.getAttribute("data-track-scrabble"));
}
return _ee;
},decodeAudioURL:function(_ef){
return "http://"+_ef.split("").reverse().join("")+".mp3";
},play:function(){
var _f0="sound_"+this.oTrack.id;
this.soundManager.stopAll();
this.setPlaybackCounter(0);
this.hasScrobbled=false;
this.show();
this.wrapperElement.addClassName(this.activeClass);
this.sound=this.soundManager.getSoundById(_f0);
if(this.sound){
this.sound.play();
}else{
this.sound=this.soundManager.createSound({id:_f0,url:this.getAudioURL(),onfinish:this.onStop.bind(this),ondataerror:this.onError.bind(this),onstop:this.onStop.bind(this),whileplaying:this.onPlayback.bind(this),autoPlay:true});
}
this.oScrobbler.sendNowPlaying(this.oTrack);
},stop:function(){
this.sound.stop();
this.sound=null;
this.hide();
this.wrapperElement.removeClassName(this.activeClass);
},setPlaybackCounter:function(_f1){
_f1=Math.min(_f1,this.oTrack.duration);
this.progressElement.down(".duration").innerHTML=LFM.timeFormat(_f1);
},onStop:function(){
this.stop();
},onClick:function(_f2){
_f2.preventDefault();
this.controlElement.blur();
if(this.sound==null){
this.play();
}else{
this.stop();
}
},onPlayback:function(){
var _f3=this.sound.position/1000;
var _f4=(100/this.oTrack.duration)*_f3;
this.setPlaybackCounter(_f3);
this.progressElement.down(".bar").setStyle({"width":_f4+"%"});
if(!this.hasScrobbled&&_f3>this.scrobblePoint){
this.oScrobbler.sendScrobble(this.oTrack,this.onScrobble.bind(this));
this.hasScrobbled=true;
}
},onError:function(){
this.stop();
},onScrobble:function(){
LFM.log("Scrobbled track");
}}));
document.observe("dom:loaded",function(){
new LFM.FullLengthPlayer(LFM.SoundManager.getInstance(),LFM.ParentResource,LFM.Scrobbler);
});
LFM.set("Display",{setupHeader:function(){
if(LFM.Session.loggedIn){
$("idBadger").addClassName("withDropDown");
LFM.set("Page",{navDropDown:new LFM.Display.DropDown("idBadger","idBadgerDropper","idBadgerDropDown",{align:"right",trackToggle:true,trackItemClick:true})});
}
new LFM.Form.Placeholder("siteSearchBox");
this.setupLogout();
},setupLogout:function(){
var _f5=$("logoutLink");
var _f6=function(e){
e.preventDefault();
var _f8=new Element("input",{type:"hidden",name:"formtoken",value:LFM.Session.formtoken});
var _f9=new Element("Form",{action:this.href,method:"post"});
_f9.appendChild(_f8);
$(this).appendChild(_f9).submit();
};
if(_f5){
_f5.down("a").observe("click",_f6);
}
},colourToggle:function(_fa){
_fa=$(_fa);
$(document.body).toggleClassName("lfmBlack");
_fa.blur();
var _fb,_fc;
if($(document.body).hasClassName("lfmBlack")){
_fb="red";
_fc="black";
_fa.update(LFM.String.toRedStr);
}else{
_fb="black";
_fc="red";
_fa.update(LFM.String.toBlackStr);
}
LFM.setCookie("LFM_Colour",_fc);
LFM.Omniture.prepareEvar("ClickSource","colorToggle:"+_fc);
LFM.Omniture.trackEvents("Click");
return false;
}});
if((Math.round(Math.random()*100)>98)&&(LFM.get("Button","affiliations"))&&(LFM.Button.affiliations["suppliers[]"].length)){
document.observe("dom:loaded",function(_fd){
var url="/ajax/affiliableLookup?";
new Ajax.Request(url,{method:"post",parameters:LFM.Button.affiliations});
});
}
function log(){
if(typeof console!=="undefined"&&LFM&&LFM.get("config","DEVELOPMENT_SERVER")){
if(console.log.apply){
console.log.apply(console,arguments);
}else{
console.log(arguments[0]);
}
}
}
LFM.set("Display",{setMinHeight:function(){
document.observe("dom:loaded",function(){
var _ff=$("secondaryNavigation");
if(_ff){
var _100=_ff.getHeight()-2;
var _101=$("content");
if(_101&&_101.getHeight()<_100){
var _102=$$("#content > .rightCol");
_102=_102[0]||_101;
if(_102.match(".rightCol")){
_101.setStyle("min-height: 0");
}
_100-=_102.getStyle("padding-top").toPixels(_102);
_100-=_102.getStyle("padding-bottom").toPixels(_102);
_102.setStyle({minHeight:(_100>300?_100:300)+"px"});
}
}
});
}});
if(LFM&&LFM.get("config","DEVELOPMENT_SERVER")){
LFM.set("Timers",{});
}
function startTimer(name){
if(LFM&&LFM.get("config","DEVELOPMENT_SERVER")){
LFM.Timers[name]={};
LFM.Timers[name].startTime=new Date();
LFM.Timers[name].startTime=LFM.Timers[name].startTime.getTime();
}
}
function stopTimer(name){
if(LFM&&LFM.get("config","DEVELOPMENT_SERVER")){
if(LFM.Timers[name]){
LFM.Timers[name].endTime=new Date();
LFM.Timers[name].endTime=LFM.Timers[name].endTime.getTime();
log(LFM.Timers[name].endTime-LFM.Timers[name].startTime);
}else{
log("Timer "+name+" doesn\u2019t exist.");
}
}
}
function loadStyleSheet(_105){
if(isset(document.createStyleSheet)){
document.createStyleSheet(_105);
}else{
var _106=document.createElement("link");
_106.setAttribute("rel","stylesheet");
_106.setAttribute("type","text/css");
_106.setAttribute("href",_105);
document.getElementsByTagName("head")[0].appendChild(_106);
}
}
function is_array(obj){
return obj.constructor==Array;
}
function isset(obj){
return typeof obj!=="undefined";
}
String.prototype.pad=function(_109,_10a,_10b){
if(_109){
_109=_109-this.length;
}else{
return this;
}
var _10c=this;
if(_10a){
_10a=_10a+"";
}else{
_10a=" ";
}
if(!isset(_10b)){
_10b="STR_PAD_LEFT";
}
if(_10b=="STR_PAD_BOTH"){
var odd=_109%2;
var side=_109/2;
side=Math.round(side);
var left=_10a.times(side);
var _110=_10a.times(side-odd);
_10c=left+_10c+_110;
}else{
var _10a=_10a.times(_109);
if(_10b=="PAD_STR_RIGHT"){
_10c=_10c+_10a;
}else{
_10c=_10a+_10c;
}
}
return _10c;
};
Number.prototype.toPixels=function(){
return this;
};
String.prototype.toPixels=function(_111){
var size=this.match(/^(-?)(\d+(?:.\d+)?)(px|pt|em|)$/i);
var _113=size[1]?-1:1;
var _114=size[2];
var unit=size[3].toLowerCase();
function rule(_116,unit){
var _118=document.getElementById(unit+"Ruler");
if(!_118){
_118=document.createElement("div");
document.getElementsByTagName("BODY")[0].appendChild(_118);
_118.id=unit+"Ruler";
}
_118.style.width=_116+unit;
return _118.clientWidth*_113;
}
switch(unit){
case "px":
return _114*_113;
case "pt":
return rule(_114,unit);
case "em":
if(!_111){
log("It\u2019s better to give a reference element when calculating pixels from ems");
return rule(_114,unit);
}else{
var _119=document.createElement(_111.tagName);
_119.style.display="block";
_119.style.position="absolute";
_119.style.left="-9999px";
_119.style.top="-9999px";
_119.style.height="0";
_119.style.padding="0";
_119.style.border="0";
_119.style.width=_114+unit;
_111.parentNode.appendChild(_119);
returnValue=_119.clientWidth;
_111.parentNode.removeChild(_119);
return returnValue*_113;
}
default:
return _114*_113;
}
};
var CSSUtils={getCSSRule:function(_11a,_11b){
_11a=_11a.toLowerCase();
if(document.styleSheets){
for(var i=0;i<document.styleSheets.length;i++){
var _11d=document.styleSheets[i];
var ii=0;
var _11f=false;
do{
if(_11d.cssRules){
_11f=_11d.cssRules[ii];
}else{
_11f=_11d.rules[ii];
}
if(_11f){
if(_11f.selectorText.toLowerCase()==_11a){
if(_11b=="delete"){
if(_11d.cssRules){
_11d.deleteRule(ii);
}else{
_11d.removeRule(ii);
}
return true;
}else{
return _11f;
}
}
}
ii++;
}while(_11f);
}
}
return false;
},killCSSRule:function(_120){
return CSSUtils.getCSSRule(_120,"delete");
},addCSSRule:function(_121){
if(document.styleSheets){
if(!CSSUtils.getCSSRule(_121)){
if(document.styleSheets[0].addRule){
document.styleSheets[0].addRule(_121,null,0);
}else{
document.styleSheets[0].insertRule(_121+" { }",0);
}
}
}
return CSSUtils.getCSSRule(_121);
}};
function actsAsAspect(_122){
_122.yield=null;
_122.rv={};
_122.before=function(_123,f){
var _125=eval("this."+_123);
this[_123]=function(){
f.apply(this,arguments);
return _125.apply(this,arguments);
};
};
_122.after=function(_126,f){
var _128=eval("this."+_126);
this[_126]=function(){
this.rv[_126]=_128.apply(this,arguments);
return f.apply(this,arguments);
};
};
_122.around=function(_129,f){
var _12b=eval("this."+_129);
this[_129]=function(){
this.yield=_12b;
return f.apply(this,arguments);
};
};
}
var ieHover={selector:"tr, li",add:function(_12c){
if(!(/MSIE (5|6|8)/).test(navigator.userAgent)){
return;
}
var _12c=_12c||false;
if(Object.isString(_12c)&&$(_12c)){
$(_12c).select(ieHover.selector).each(function(item){
ieHover.prepareItem(item);
});
}else{
if(Object.isElement(_12c)){
_12c=$(_12c);
if(_12c.match("tr, li")){
ieHover.prepareItem(_12c);
}else{
_12c.select(ieHover.selector).each(function(item){
ieHover.prepareItem(item);
});
}
}else{
if(Object.isArray(_12c)){
_12c.each(function(item){
ieHover.prepareItem(item);
});
}
}
}
},prepareItem:function(item){
item.observe("mouseenter",ieHover.mouseOver);
item.observe("mouseleave",ieHover.mouseOut);
},mouseOver:function(_131){
this.className=this.className.replace(/(\w+[^_\s]{2})\b/ig,"$1 $1hover_")+" hover_";
},mouseOut:function(_132){
this.className=this.className.replace(/\w+_\b/ig,"").replace(/\s+/ig," ");
},setUp:function(){
if(!(/MSIE (5|6|8)/).test(navigator.userAgent)){
return;
}
var _133=document.createStyleSheet();
var _134=[];
var _135;
var _136=document.styleSheets,l=_136.length;
for(var i=0;i<l;i++){
parseStylesheet(_136[i]);
}
function parseStylesheet(_139){
if(_139.imports){
try{
var _13a=_139.imports,l=_13a.length;
for(var i=0;i<l;i++){
parseStylesheet(_139.imports[i]);
}
}
catch(securityException){
}
}
try{
var _13c=(_135=_139).rules;
var l=_13c.length;
var _13e=false;
var _13f=false;
for(var j=0;j<l;j++){
_13e=_13c[j].selectorText;
_13f=_13c[j].style.cssText;
if(_13e.match(/(tr|li)(\.(\w*))*:hover/ig)&&_13f){
_134.push([_13e.replace(/(tr|li)(\.(\w*))*:hover/ig,"$1.$3hover_"),_13f]);
}
}
}
catch(securityException){
}
}
var _141="";
for(var i=_134.length-1;i>=0;i--){
_141+=_134[i][0]+"\n{ "+_134[i][1]+"}\n";
}
_133.cssText=_141;
var _142=[];
var page=$("page");
ieHover.selector.split(",").each(function(weee){
_142.push($A(page.getElementsByTagName(weee.strip())));
});
_142=_142.flatten();
var i=_142.length-1;
for(i;i>=0;i--){
Event.observe(_142[i],"mouseenter",ieHover.mouseOver);
Event.observe(_142[i],"mouseleave",ieHover.mouseOut);
}
}};
LFM.set("Help",{popup:function(id){
var url="/popups/faq/?id="+id;
faq=window.open(url,"faq","toolbar=no, location=no, directories=no, status=no,menubar=no, scrollbars=yes, resizable=yes, width=350, height=400");
return false;
}});
HighlightEachOther=Class.create({initialize:function(el1,tag1,el2,tag2){
this.els=[$(el1).select(tag1),$(el2).select(tag2)].flatten();
this.els.each(function(el){
el.observe("mouseover",function(e){
this.highlight(el);
}.bindAsEventListener(this));
el.observe("mouseout",function(e){
this.highlight(el);
}.bindAsEventListener(this));
}.bind(this));
},highlight:function(el){
var el=el;
if(!el.relatives){
this.getRelatives(el);
}
el.relatives.each(function(_1b4){
Element.toggleClassName(_1b4,"highlight");
});
},getRelatives:function(el){
el.relatives=new Array();
var rel=el.readAttribute("class");
this.els.each(function(item){
if(item.readAttribute("class")==rel){
el.relatives.push(item);
}
});
}});
LFM.set("Page",{"InlineTabSwitcher":Class.create({initialize:function(_153){
this.menu=$(_153+"Tabs");
this.namespace=_153;
if(!this.menu){
LFM.log("couldn't find #"+_153+"Tabs, InlineTabSwitcher not created");
return;
}
var _154=this;
this.menu.observe("click",function(_155){
Event.stop(_155);
var li=_155.findElement("li");
if(li&&li.match("li")){
_154.switchTabs(li);
var _157=li.select("a");
if(_157&&_157.length){
_157[0].blur();
}
}
});
var _158=this.menu.select("li");
if(_158&&_158.length){
var hash=window.location.hash?window.location.hash.replace(/#/,""):"";
var _15a=null;
_158.each(function(_15b){
_154._getContentContainerForTab(_15b).hide();
if(_15b.hasClassName("current")){
_15a=_15b;
}else{
if(_15b.hasClassName("tabident-"+hash)){
_15a=_15b;
}
}
});
if(!_15a){
_15a=_158[0];
}
this.switchTabs(_15a);
}
},switchTabs:function(li){
var _15d=this.menu.select("li");
var _15e=this;
_15d.each(function(_15f){
if(_15f==li){
_15f.addClassName("current");
_15e._getContentContainerForTab(_15f).show();
}else{
_15f.removeClassName("current");
_15e._getContentContainerForTab(_15f).hide();
}
});
var _160=li.className.match(/tabident-([^ "]+)/);
if(_160&&_160.length>=2){
var _161=_160[1].replace(/hover_/g,"");
var loc=window.location;
var url=loc.toString().replace(/\#.*/,"");
loc.replace(url+"#"+_161);
}
},_getContentContainerForTab:function(li){
var _165=this.namespace+li.id.replace("Tab","").capitalize();
return $(_165);
}})});
LFM.set("LiveSwitch",Class.create({initialize:function(_166,_167){
this.element=$(_166);
this.options={selectedClass:"selected"};
Object.extend(this.options,_167);
this.items=this.element.select("li");
this.items.each(function(li){
var a=li.down("a");
a.observe("click",this.dispatchOnChange.bindAsEventListener(this));
}.bind(this));
},dispatchOnChange:function(_16a){
_16a.stop();
_16a.element().blur();
var li=_16a.findElement("li");
this.items.invoke("removeClassName",this.options.selectedClass);
li.addClassName(this.options.selectedClass);
this.options.onChange(li);
}}));
LFM.set("Module",{Buttons:Class.create({initialize:function(_16c,_16d){
this.container=$(_16c);
if(_16d){
Object.extend(this,_16d);
}
if(!this.onComplete){
this.onComplete=this._defaultOnComplete;
}
if(!this.resource){
this.resource=LFM.ParentResource;
}
this.container.observe("click",this.observeMenu.bindAsEventListener(this));
},observeMenu:function(_16e){
var link=_16e.findElement("a");
if(!link){
return;
}
if(link.hasClassName("mEdit")){
_16e.stop();
var url="/ajax/dialog/moduleedit?module="+this.moduleName;
this._dialog=new LFM.Dialog({action:url,classname:"modulePreferences",onConfirm:this._onConfirmDialog.bindAsEventListener(this)});
this._dialog.show(url);
}else{
if(link.hasClassName("mFeeds")){
_16e.stop();
var _171={module:this.moduleName,type:this.resource.type,id:this.resource.id};
var url="/ajax/dialog/feeds?"+Object.toQueryString(_171);
this._dialog=new LFM.Dialog({classname:"feedDialog",onConfirm:function(_172){
_172.stop();
this.hide();
}});
this._dialog.show(url);
}else{
if(link.hasClassName("mPaste")){
_16e.stop();
var _173=$$(".modulechartsartists li.current a")[0].getAttribute("href");
var _174=/rangetype=([^&]*)/;
var _175=_173.match(_174)[1];
var _171={module:this.moduleName,type:this.resource.type,id:this.resource.id,period:_175};
var url="/ajax/dialog/pasteyourtaste?"+Object.toQueryString(_171);
this._dialog=new LFM.Dialog({classname:"pasteDialog",onConfirm:function(_176){
_176.stop();
this.hide();
}});
this._dialog.show(url);
}
}
}
},_defaultOnComplete:function(){
if(this.container.down(".module-body")){
var url="/module";
var _178={method:"get",parameters:{name:this.moduleName,ajax:1},onComplete:this._defaultRefreshCallback.bind(this),onCreate:function(){
this.container.addClassName("loading");
}.bind(this),onFailure:function(){
this.container.removeClassName("loading");
}.bind(this)};
new Ajax.Request(url,_178);
}
},_onConfirmDialog:function(_179,form){
_179.stop();
if(form){
form.action="/ajax/dialog/moduleedit?module="+this.moduleName;
form.request({onComplete:this.onComplete.bind(this)});
}else{
this._dialog.hide();
this._dialog.overlayForm.request({onComplete:this.onComplete.bind(this)});
}
},_defaultRefreshCallback:function(_17b){
var _17c=new LFM.Ajax.Response(_17b);
if(_17c.isSuccess()){
this.container.down(".module-body").replace(_17c.get("content"));
}else{
this.container.removeClassName("loading");
}
}}),onRefresh:function(_17d,_17e){
if(!LFM.Module.refreshers){
LFM.Module.refreshers={};
}
LFM.Module.refreshers[_17d]=_17e;
}});
LFM.set("Display",{MultiTuner:Class.create({initialize:function(form,_180){
this.uuid=Math.round(Math.random()*100000);
this.form=$(form);
this.restype=_180.restype;
this.sampleContent=$(_180.sampleContent);
this.slotID=_180.slotID||"slot"+this.uuid;
this.slotClass=_180.slotClass||"";
this.choices=$(_180.choices);
this.autocomplete=$(_180.autocomplete);
this.length=_180.length||3;
this.itemClass=_180.itemClass||"";
this.onSelect=_180.onSelect;
this.onDeselect=_180.onDeselect;
this.onResourceJSON=_180.onResourceJSON;
this.slots=this.setupSlots(this.length);
this.selections=$H();
this.matching_choices=$H();
this.filled=0;
this.setupListeners();
},setupListeners:function(){
if(!LFM.get("Session","prefersClient")&&!this.form.down("input[name=ajax]")){
this.form.insert(new Element("input",{"type":"hidden","name":"ajax","value":1}));
}
if(this.choices){
this.choices.observe("click",function(e){
e.stop();
var item=e.findElement("li");
this.select(item.down("a").innerHTML.unescapeHTML());
}.bind(this));
}
if(this.autocomplete){
this.autocomplete.observe("submit",function(e){
e.stop();
var _184=this.autocomplete.serialize(true);
if(!_184.placeholder&&_184.name){
this.select(_184.name.unescapeHTML());
this.autocomplete.down("input[name=name]").value="";
}
}.bind(this));
}
},setupSlots:function(_185){
var that=this;
var _187=$A($R(1,_185));
_187.reverse(false).each(function(i){
if(!$(that.slotID+i)){
var slot=new Element("div",{"id":that.slotID+i,"class":that.slotClass});
that.form.insert({top:slot});
}
});
return _187.inject($H(),function(hash,i){
hash.set(i,false);
return hash;
});
},generate_item_id:function(_18c){
return "item"+this.uuid+"_"+_18c.toLowerCase().replace(/_/g,"__").replace(/ /g,"_");
},updateSampleContent:function(){
if(this.sampleContent&&this.restype){
var _18d=this.sampleContent.up("p");
if(!this.filled){
_18d.hide();
_18d.next("p.noSampleContent").hide();
this.sampleContent.update();
}else{
var that=this;
new Ajax.Request("/listen/tune",{parameters:Object.extend({"ajax":1},this.form.serialize(true)),onComplete:function(_18f){
var _190=new LFM.Ajax.Response(_18f);
if(_190.isError()){
var _191=that.sampleContent.up("p");
that.sampleContent.update();
_191.hide();
_191.next("p.noSampleContent").hide();
_191.next("p.sampleContentError").show();
}else{
var _192=_190.get("sampleContent");
var _191=that.sampleContent.up("p");
if(_192&&_192.items&&_192.items.length){
var _193=_192.items.inGroupsOf(3)[0].collect(function(item){
if(!item){
throw $break;
}
return item.res.name;
}).join(", ");
that.sampleContent.update(_193);
_191.next("p.noSampleContent").hide();
_191.next("p.sampleContentError").hide();
_191.show();
}else{
that.sampleContent.update();
_191.hide();
_191.next("p.sampleContentError").hide();
_191.next("p.noSampleContent").show();
}
}
}});
}
}
},fetchResourceJSON:function(_195,_196){
var that=this;
new Ajax.Request("/ajax/getResource",{method:"get",parameters:{"type":this.restype,"name":_195},onComplete:function(_198){
var _199=new LFM.Ajax.Response(_198);
that.onResourceJSON(_199,_196);
}});
},deselect:function(_19a){
var slot=this.selections.unset(_19a);
this.slots.set(slot,false);
var _19c=$(_19a);
_19c.remove();
$(_19a+"_input").remove();
this.filled--;
var _19d=this.matching_choices.get(_19a);
if(_19d){
_19d.removeClassName("disabled");
}
this.updateSampleContent();
if(this.onDeselect){
this.onDeselect(_19c);
}
},select:function(_19e){
var _19f=this.generate_item_id(_19e);
if(this.selections.get(_19f)){
this.deselect(_19f);
return false;
}
if(this.filled>=this.length){
return false;
}
if(this.choices){
var _1a0=this.choices.select("li").find(function(item){
return (item.down("a").innerHTML==_19e);
});
this.matching_choices.set(_19f,_1a0);
}
this.form.insert(new Element("input",{"type":"hidden","name":"names[]","value":_19e,"id":_19f+"_input"}));
var _1a2=new Element("a",{"href":"#","class":this.itemClass,"id":_19f}).observe("click",function(e){
e.stop();
this.deselect(_19f);
}.bind(this));
_1a2.insert(new Element("span").update(_19e));
var _1a4=this.slots.find(function(item){
return (item.value===false);
}).key;
var _1a6=$(this.slotID+_1a4);
_1a6.insert(_1a2);
this.selections.set(_19f,_1a4);
this.slots.set(_1a4,true);
this.filled++;
if(_1a0){
_1a0.addClassName("disabled");
}
this.updateSampleContent();
if(this.onResourceJSON){
this.fetchResourceJSON(_19e,_1a2);
}
if(this.onSelect){
this.onSelect(_19e,_1a2);
}
}})});
document.observe("dom:loaded",function(_1a7){
if($("noobStrapSubmit")){
new LFM.Form.Placeholder("noobStrapTextarea");
$("noobStrapSubmit").observe("click",function(e){
if($F("noobStrapTextarea")&&$F("noobStrapTextarea")!=$F("noobStrapPlaceholder")){
LFM.Omniture.setLink(e.element(),"Textarea add to Library");
LFM.Omniture.prepareEvar("ClickSource",LFM.get("Page","manualAddLocation"));
LFM.Omniture.trackEvents("AddtoLibrary");
}else{
e.stop();
}
});
}
});
var s,s_gi;
if(LFM.get("config","DEVELOPMENT_SERVER")){
LFM.OmnitureAccount="cbslastfmtest";
}else{
LFM.OmnitureAccount="cbslastfm";
}
(function(){
var _1a9=Class.create({blocked:false,initialize:function(){
this.resetTracker();
},resetTracker:function(){
if(s_gi){
this.tracker=s_gi(LFM.OmnitureAccount);
return this.tracker;
}
this.blocked=true;
return false;
},isBlocked:function(){
return this.blocked;
},event:function(name){
return _1ab.events[name];
},prop:function(name){
return _1ab.props[name];
},evar:function(name){
return _1ab.evars[name];
},setProp:function(name,_1af){
if(this.isBlocked()){
return false;
}
this.tracker[this.prop(name)]=_1af;
},getProp:function(name){
if(this.isBlocked()){
return false;
}
return this.tracker[this.prop(name)];
},setEvar:function(name,_1b2){
if(this.isBlocked()){
return false;
}
this.tracker[this.evar(name)]=_1b2;
},getEvar:function(name){
if(this.isBlocked()){
return false;
}
return this.tracker[this.evar(name)];
},currentEvars:[],prepareEvar:function(name,_1b5){
if(this.isBlocked()){
return false;
}
this.setEvar(name,_1b5);
this.currentEvars.push(name);
},clearEvars:function(){
if(this.isBlocked()){
return false;
}
this.currentEvars.each(function(name){
this.setEvar(name,"");
}.bind(this));
this.currentEvars.clear();
},linkElement:null,linkTitle:null,setLink:function(_1b7,_1b8){
if(this.isBlocked()){
return false;
}
this.linkElement=_1b7;
this.linkTitle=_1b8;
},clearLink:function(){
if(this.isBlocked()){
return false;
}
this.linkElement=null;
this.linkTitle=null;
},setLinkTrackEvars:function(){
if(this.isBlocked()){
return false;
}
var _1b9=["events"];
var _1ba={};
this.currentEvars.each(function(name){
var _1bc=this.evar(name);
_1b9.push(_1bc);
_1ba[name+"/"+_1bc]=this.getEvar(name);
}.bind(this));
this.tracker.linkTrackVars=_1b9.join(",");
return _1ba;
},setLinkTrackEvents:function(){
if(this.isBlocked()){
return false;
}
var _1bd=[];
var _1be=Array.prototype.join.call(arguments,",");
for(var i=0;i<arguments.length;i++){
_1bd.push(this.event(arguments[i]));
}
var _1c0=_1bd.join(",");
this.tracker.events=_1c0;
this.tracker.linkTrackEvents=_1c0;
return _1be;
},track:function(_1c1){
if(this.isBlocked()){
return false;
}
this.tracker.tl(this.linkElement||true,"o",this.linkTitle||_1c1);
},trackEvents:function(){
if(this.isBlocked()){
return false;
}
this.resetTracker();
var _1c2=this.setLinkTrackEvents.apply(this,arguments);
var _1c3=this.setLinkTrackEvars();
var _1c4="TRACK: "+_1c2;
if(this.linkTitle){
_1c4+=" ("+this.linkTitle+") ";
}
LFM.log(_1c4);
LFM.info(this.linkElement);
LFM.dir(_1c3);
this.track(_1c2);
this.clearEvars();
this.clearLink();
}});
var _1ab={events:{Registration:"event1",ClientDownload:"event2",EventAttendance:"event3",RadioPaneSwitch:"event4",ContentStart:"event5",StopPlayer:"event6",MusicPlay:"event7",Share:"event8",AddtoLibrary:"event9",BanTrack:"event10",LoveTrack:"event11",PageView:"event12",SkipTrack:"event13",ShoutPost:"event14",JoinGroup:"event15",CommentPost:"event16",AddFriend:"event17",SendMessage:"event18",Buy:"event19",AddTags:"event20",AddToPlaylist:"event21",DeleteFriend:"event22",LeaveGroup:"event23",DeletePlaylist:"event24",ArtistDisambiguation:"event25",RadioLaunch:"event26",Click:"event27",PageScroll:"event28",WindowFocus:"event29",RadioError:"event30",Dialog:"event31",DropDown:"event32",HeaderSearch:"event33",HeaderSearchFocus:"event34"},props:{SiteSectionLevel1:"prop1",SiteSectionLevel2:"prop2",SiteSectionLevel3:"prop3",ArtistNameAH:"prop4",ArtistNameIP:"prop5",ArtistNameQZ:"prop6",GroupNameAH:"prop7",GroupNameIP:"prop8",GroupNameQZ:"prop9",LoggedIn:"prop10",AlbumName:"prop11",URLExtension:"prop12",ChartSubtype:"prop17",Hour:"prop18",Day:"prop19",TagNameAM:"prop20",TagNameNZ:"prop21",ArtistID:"prop22",GroupID:"prop23",TagID:"prop24",DiscussionTitle:"prop25",DiscussionID:"prop26",ChartTypeYear:"prop27",ChartTypeMonth:"prop28",ChartTypeTimeFrame:"prop29",StationName:"prop30",StationID:"prop31",UserLanguage:"prop33",EventNameAM:"prop36",EventNameNZ:"prop37",EventID:"prop38",CorrectArtistName:"prop47",TestGroupID:"prop49"},evars:{Country:"eVar1",PageName:"eVar2",Channel:"eVar3",ArtistNameAH:"eVar4",ArtistNameIP:"eVar5",ArtistNameQZ:"eVar6",GroupNameAH:"eVar7",GroupNameIP:"eVar8",GroupNameQZ:"eVar9",LoggedIn:"eVar10",AlbumNameAH:"eVar11",AlbumNameIP:"eVar12",AlbumNameQZ:"eVar13",TitleAH:"eVar14",TitleIP:"eVar15",TitleQZ:"eVar16",StationNameAH:"eVar17",StationNameIP:"eVar18",StationNameQZ:"eVar19",ArtistID:"eVar20",GroupID:"eVar21",TagID:"eVar22",StationID:"eVar23",TagNameAM:"eVar24",TagNameNZ:"eVar25",ClickSource:"eVar26",DownloadPlatform:"eVar27",BuyDestination:"eVar28",FirstVisit:"eVar29",URLExtension:"eVar30",NewOrRepeatVisitors:"eVar31",DaysSinceLastVisit:"eVar32",AdSource:"eVar33",AdID:"eVar34",AdSize:"eVar35",MemberUserID:"eVar36",UserLanguage:"eVar37",UserScrobbles:"eVar38",LFMIABBrand:"eVar39",EventNameAM:"eVar40",EventNameNZ:"eVar41",EventID:"eVar42",ErrorCode:"eVar43",DialogType:"eVar44",HeaderSearchAction:"eVar45",SearchLength:"eVar46",SearchType:"eVar47",HeaderSearchRestype:"eVar48",TestGroupID:"eVar49"}};
document.observe("omniture:load",function(e){
LFM.set("Omniture",new _1a9());
});
})();
LFM.set("PreviewButtonManager",Class.create({buttonSelector:"a.previewbutton",activeClass:"previewbutton-active",trackIdAttribute:"data-track-id",soundManager:null,playingSound:null,loadingAnimation:null,loadingAnimationParams:{startFrame:3,length:5,loop:true,fps:10,play:true},playbackAnimation:null,playbackAnimationParams:{startFrame:8,length:33},initialize:function(_1c6,_1c7,_1c8,_1c9){
this.soundManager=_1c6;
this.webServiceHost=_1c7;
this.webServiceKey=_1c8;
this.spriteClass=_1c9;
this.soundManager.onready(this.apply.bind(this));
},apply:function(){
if(this.soundManager.supported()){
document.observe("click",this.onClick.bind(this));
}
},getAudioURL:function(_1ca){
var _1cb=_1ca.getAttribute("href");
if(!_1cb.endsWith(".mp3")){
var _1cc=this.getTrackId(_1ca);
_1cb=_1cc?this.generatePreviewURL(_1cc):false;
}
return _1cb;
},getTrackId:function(_1cd){
var _1ce=_1cd.down().up("["+this.trackIdAttribute+"]");
if(_1ce){
return _1ce.readAttribute(this.trackIdAttribute);
}
return false;
},generatePreviewURL:function(_1cf){
var _1d0={method:"track.previewmp3",trackid:_1cf,api_key:this.webServiceKey};
return "http://"+this.webServiceHost+"/2.0/?"+Object.toQueryString(_1d0);
},play:function(_1d1,_1d2,_1d3){
this.soundManager.stopAll();
this.loadingAnimation=new LFM.Util.SpriteAnimation(_1d2,this.loadingAnimationParams);
this.playbackAnimation=new LFM.Util.SpriteAnimation(_1d2,this.playbackAnimationParams);
_1d1.addClassName(this.activeClass);
this.playAudio(_1d3);
},playAudio:function(_1d4){
var id="sound_"+_1d4;
if(this.playingSound=this.soundManager.getSoundById(id)){
this.playingSound.play();
}else{
this.playingSound=this.soundManager.createSound({id:id,url:_1d4,onfinish:this.onStop.bind(this),onstop:this.onStop.bind(this),ondataerror:this.onError.bind(this),whileplaying:this.onPlayback.bind(this),autoPlay:true});
}
},stop:function(){
if(this.playingSound){
this.playingSound.stop();
}
this.cleanupAnimation();
var _1d6=this.buttonSelector+"."+this.activeClass;
$$(_1d6).invoke("removeClassName",this.activeClass);
},cleanupAnimation:function(){
if(this.loadingAnimation){
this.loadingAnimation.stop();
this.loadingAnimation.cleanup();
delete this.loadingAnimation;
}
if(this.playbackAnimation){
this.playbackAnimation.cleanup();
delete this.playbackAnimation;
}
},onClick:function(_1d7){
var _1d8=_1d7.element();
var _1d9=_1d8.match(this.buttonSelector)?_1d8:_1d8.up(this.buttonSelector);
var _1da=_1d9?_1d9.down("img",0):null;
if(!_1da||!_1d9){
return;
}
var _1db=_1d9.hasClassName(this.activeClass);
var _1dc=this.getAudioURL(_1d9);
this.stop();
if(_1dc){
_1d7.preventDefault();
_1d9.blur();
if(!_1db){
this.play(_1d9,_1da,_1dc);
}
}
},onPlayback:function(){
if(this.loadingAnimation.isPlaying()){
this.loadingAnimation.stop();
this.playbackAnimation.reset();
}
var _1dd=this.playingSound.duration;
if(_1dd<this.playingSound.durationEstimate){
_1dd=this.playingSound.durationEstimate;
}
var _1de=this.playingSound.position/_1dd*100;
var _1df=(this.playbackAnimation.getFramePosition()+1)/this.playbackAnimation.getLength()*100;
if(_1de>_1df){
this.playbackAnimation.next();
}
},onStop:function(){
this.stop();
},onError:function(){
this.stop();
}}));
document.observe("dom:loaded",function(){
new LFM.PreviewButtonManager(LFM.SoundManager.getInstance(),LFM.Session.wsHost,LFM.Session.wsKey);
});
LFM.set("Page",{Extract:{trackIds:function(_1e0,_1e1){
if(typeof _1e1=="undefined"){
_1e1=true;
}
_1e0=$(_1e0)||document.body;
var _1e2=_1e0.select("*[data-track-id]").collect(function(elem){
return elem.getAttribute("data-track-id");
});
return _1e1?this._unique(_1e2):_1e2;
},_unique:function(list){
var _1e5=list.sortBy(function(item){
return Number(item);
});
uniques=[list[0]];
for(var i=1;i<_1e5.length;i++){
if(_1e5[i-1]==_1e5[i]){
}else{
uniques.push(_1e5[i]);
}
}
return uniques;
}}});
LFM.set("Input",{RichText:Class.create({hasFocus:false,busy:false,wordSeparators:" \t\n,.()!?|=-\\",initialize:function(div,_1e9){
this.div=$(div);
this.options=_1e9?_1e9:{};
this.caret=this.div.down("span.caret");
this.caret.style.color="white";
this.caret.style.borderLeft="1px solid white";
this.textarea=this.div.next("textarea");
Event.observe(this.textarea,"keypress",this.keyPress.bindAsEventListener(this));
Event.observe(this.textarea,"keydown",this.keyDown.bindAsEventListener(this));
Event.observe(window,"keydown",this.keyDown.bindAsEventListener(this));
Event.observe(this.div,"click",this.focus.bindAsEventListener(this));
Event.observe(window,"blur",this.blur.bindAsEventListener(this));
new Ajax.Request("/ajax/getArtists",{onComplete:function(resp){
var out=resp.responseText.evalJSON();
this.artists=out.items;
}.bind(this)});
},keyDown:function(e){
e=window.event||e;
var _1ed=e.charCode||e.keyCode||e.which;
var s=String.fromCharCode(_1ed);
this.cancelOnDown=false;
if(this.specialKeyDown(_1ed,e)){
Event.stop(e);
this.cancelOnDown=true;
return false;
}
if(e.ctrlKey){
s=s.toLowerCase();
if(s=="a"||s=="m"){
Event.stop(e);
var sel=this.getSelection();
var name=this.getSelectedText(sel);
var _1f1;
if(s=="a"){
_1f1="<lfm:artist>"+name.strip().escapeHTML()+"</lfm:artist>";
}else{
if(s=="m"){
_1f1="<lfm:artist name=\""+name.strip().escapeHTML()+"\"><lfm:image size=\"small\" /></lfm:artist>";
}
}
this.replaceSelection(_1f1,sel);
}
}
},getSelection:function(){
var sel;
if(window.getSelection){
sel=window.getSelection();
}else{
if(document.selection){
sel=document.selection.createRange();
}
}
return sel;
},getSelectedText:function(sel){
var name="";
var next=sel.anchorNode;
while(next){
if(next.nodeValue){
name+=next.nodeValue;
}
if(next==sel.focusNode){
break;
}
next=next.nextSibling;
}
return name;
},replaceSelection:function(_1f6,sel){
new Ajax.Request("/ajax/richtextrenderer",{method:"post",parameters:{richtext:_1f6},onComplete:function(resp){
var out=resp.responseText.evalJSON();
var _1fa=sel.getRangeAt(0);
$(document.body).insert({bottom:out.rendered});
var node=$(document.body).lastChild;
node.remove();
_1fa.deleteContents();
_1fa.insertNode(node);
this.textarea.value+=out.richtext;
}});
},keyPress:function(e){
e=window.event||e;
var _1fd=e.charCode||e.keyCode||e.which;
var s=String.fromCharCode(_1fd);
if(this.specialKeyPress(_1fd,e)){
Event.stop(e);
return false;
}
if(e.altKey){
Event.stop(e);
return false;
}
if(!this.hasFocus||e.element()==window){
return;
}
var prev=this.caret.previousSibling;
if(prev&&prev.nodeType==3&&prev.nodeValue.strip().empty()&&prev.nodeValue!="\n"){
var _200=prev.parentNode;
var _201=prev.ownerDocument.createRange();
_201.setStartBefore(prev);
var _202=_201.createContextualFragment(s);
var n=_200.replaceChild(_202,prev);
var _201=this.caret.ownerDocument.createRange();
_201.setStartBefore(this.caret.previousSibling);
var _204=_201.createContextualFragment(" ");
_200.insertBefore(_204,this.caret.previousSibling);
}else{
this.caret.insert({before:s});
}
},_delete:function(prev){
var _206=false;
var _207=prev.previousSibling;
if(prev.nodeType==1){
if(prev.nodeName=="A"){
var _208=prev.firstChild;
prev.parentNode.replaceChild(_208,prev);
_208.unlinked=true;
var _209=this.textarea.selectionStart;
var tag="";
var i=_209-2;
while(i>=0&&(this.textarea.value.charAt(i)!="/")){
tag=this.textarea.value.charAt(i)+tag;
i--;
}
var _20c=i;
var _20d="<"+tag+">";
var _20e=_20d.length;
while(i>=0&&(this.textarea.value.substr(i,_20e)!=_20d)){
i--;
}
var _20f=this.textarea.value.substr(0,i);
var _210=i+_20e;
_20f+=this.textarea.value.substr(_210,_20c-_210-1);
_20f+=this.textarea.value.substr(_209);
this.textarea.value=_20f;
return;
}
}
if(prev.nodeValue=="\n"){
_206=true;
}
var _211=prev.parentNode;
if(prev.nodeType==3){
var _209=this.textarea.selectionStart;
var _20f=this.textarea.value.substr(0,_209-1);
if(_209<this.textarea.value.length){
_20f+=""+this.textarea.value.substr(_209);
}
this.textarea.value=_20f;
if(this.textarea.createTextRange){
var _212=this.textarea.createTextRange();
_212.moveStart("character",_209-1);
_212.moveEnd("character",_209-1);
_212.select();
}else{
if(this.textarea.setSelectionRange){
this.textarea.setSelectionRange(_209-1,_209-1);
}
}
if(prev.nodeValue.length>1){
prev.nodeValue=prev.nodeValue.substr(0,prev.nodeValue.length-1);
return;
}
}else{
if(prev.nodeName=="BR"){
this.textarea.value=this.textarea.value.substr(0,this.textarea.value.length-6);
}
}
_211.removeChild(prev);
if(_207&&_207.nodeType==3&&_207.nodeValue.strip().empty()&&_207.nodeValue!="\n"){
var _213=_207.ownerDocument.createRange();
_213.setStartAfter(_207);
var nbsp=_213.createContextualFragment("&nbsp;");
_211.replaceChild(nbsp,_207);
_207=nbsp;
}
if(_206){
var _207=prev.previousSibling;
_211.removeChild(prev);
this.caret.previousSibling=_207;
this.caret.remove();
}
if(_207){
_211.insertBefore(this.caret,_207.nextSibling);
}
},specialKeyDown:function(_215,e){
if(_215>=37&&_215<=40&&!(e.ctrlKey||e.altKey||e.shiftKey||e.metaKey)){
var prev=this.caret.previousSibling;
var next=this.caret.nextSibling;
var _219=this.caret.parentNode;
if(_215==37&&prev){
this.caret.remove();
_219.insertBefore(this.caret,prev);
var _21a=this.textarea.selectionStart;
if(this.textarea.createTextRange){
var _21b=this.textarea.createTextRange();
_21b.moveStart("character",_21a-1);
_21b.moveEnd("character",_21a-1);
_21b.select();
}else{
if(this.textarea.setSelectionRange){
this.textarea.setSelectionRange(_21a-1,_21a-1);
}
}
}else{
if(_215==39&&next){
this.caret.remove();
_219.insertBefore(this.caret,next.nextSibling);
var _21a=this.textarea.selectionStart;
if(this.textarea.createTextRange){
var _21b=this.textarea.createTextRange();
_21b.moveStart("character",_21a+1);
_21b.moveEnd("character",_21a+1);
_21b.select();
}else{
if(this.textarea.setSelectionRange){
this.textarea.setSelectionRange(_21a+1,_21a+1);
}
}
}
}
this.textarea.focus();
return true;
}else{
if(_215==46){
if(this.caret.nextSibling){
this.moveTextAreaCursorBy(1);
var next=this.caret.nextSibling;
this.caret.remove();
next.parentNode.insertBefore(this.caret,next.nextSibling);
this._delete(next);
}
return true;
}else{
if(_215==8){
if(this.caret.previousSibling){
this._delete(this.caret.previousSibling);
}
return true;
}else{
if(_215==13){
this.caret.insert({before:"<br />"});
this.textarea.value+="<br />";
return true;
}
}
}
}
},specialKeyPress:function(_21c,e){
var s=String.fromCharCode(_21c);
if(this.cancelOnDown){
return true;
}
if(this.wordSeparators.indexOf(s)>=0){
var _21f=this.caret;
if(_21f.previousSibling&&_21f.previousSibling.nodeType==3&&!_21f.previousSibling.unlinked){
var back=0;
var name="";
var _222;
while((_21f=_21f.previousSibling)&&_21f.nodeType==3&&_21f.nodeValue.unescapeHTML().strip()!=""){
name=_21f.nodeValue+name;
back++;
}
_222=_21f;
var _223=false;
name=name.strip();
if(s!="."&&name.match(/^((ht|f)tp(s?)\:\/\/|~\/|\/)?([\w]+:\w+@)?([a-zA-Z]{1}([\w\-]+\.)+([\w]{2,5}))(:[\d]{1,5})?((\/?\w+\/)+|\/?)(\w+\.[\w]{3,4})?((\?\w+=\w+)?(&\w+=\w+)*)?/)){
_223="<a href=\""+name.escapeHTML()+"\">"+name.escapeHTML()+"</a>";
}else{
var _224=name.toUpperCase();
var _225=this.artists.find(function(a){
return a.toUpperCase()==_224;
});
if(_225){
_223="<lfm:artist>"+name.escapeHTML()+"</lfm:artist>";
}
}
if(_223){
var _227=this.textarea.selectionStart;
new Ajax.Request("/ajax/richtextrenderer",{method:"post",parameters:{richtext:_223},onComplete:function(resp){
var out=resp.responseText.evalJSON();
var _22a=_222.nextSibling;
for(;back>0;back--){
var tmp=_22a.nextSibling;
_22a.parentNode.removeChild(_22a);
_22a=tmp;
}
if(_222){
var _22c=_222.ownerDocument.createRange();
_22c.setStartAfter(_222);
var _22d=_22c.createContextualFragment(out.rendered);
_222.parentNode.insertBefore(_22d,_222.nextSibling);
}else{
this.div.insert({top:out.rendered});
}
var _22e=this.textarea.value.substr(0,_227-name.length);
_22e+=out.richtext;
_22e+=""+this.textarea.value.substr(_227);
this.textarea.value=_22e;
}.bind(this)});
}
}
}else{
if(s=="/"){
var _21f=this.caret.previousSibling;
if(!_21f||_21f.nodeValue!="["){
return false;
}
var _22f=_21f;
var _230="";
var tag="";
var back=2;
while((_21f=_21f.previousSibling)&&_21f.nodeType==3&&_21f.nodeValue!="]"){
_230=_21f.nodeValue+_230;
back++;
}
while((_21f=_21f.previousSibling)&&_21f.nodeType==3&&_21f.nodeValue!="["){
tag=_21f.nodeValue+tag;
back++;
}
if(tag=="artist"){
_230=_230.strip();
var _227=this.textarea.selectionStart;
var _223="<lfm:artist>"+_230.escapeHTML()+"</lfm:artist>";
new Ajax.Request("/ajax/richtextrenderer",{method:"post",parameters:{richtext:_223},onComplete:function(resp){
var out=resp.responseText.evalJSON();
_21f=_22f;
for(var i=back;i>0;i--){
var tmp=_21f.previousSibling;
_21f.parentNode.removeChild(_21f);
_21f=tmp;
}
if(this.caret.previousSibling){
var rm=this.caret.previousSibling;
rm.parentNode.removeChild(rm);
}
this.caret.insert({before:out.rendered});
var _237=this.textarea.value.substr(0,_227-back-1);
_237+=""+out.richtext;
_237+=""+this.textarea.value.substr(_227);
this.textarea.value=_237;
}.bind(this)});
return true;
}
}
}
if(s==" "){
this.caret.insert({before:"&nbsp;"});
this.textarea.value+=" ";
return true;
}
},moveTextAreaCursorBy:function(n){
var _239=this.textarea.selectionStart;
if(this.textarea.createTextRange){
var _23a=this.textarea.createTextRange();
_23a.moveStart("character",_239+n);
_23a.moveEnd("character",_239+n);
_23a.select();
}else{
if(this.textarea.setSelectionRange){
this.textarea.setSelectionRange(_239+n,_239+n);
}
}
},focus:function(e){
Event.stop(e);
var _23c=e.rangeParent;
if(this.caret.parentNode){
this.caret.remove();
}
if(_23c!=this.caret&&_23c!=this.div){
_23c.parentNode.insertBefore(this.caret,_23c.nextSibling);
}else{
this.div.appendChild(this.caret);
}
this.hasFocus=true;
this.textarea.focus();
this.startBlinkingCaret();
},blur:function(){
this.hasFocus=false;
this.stopBlinkingCaret();
},startBlinkingCaret:function(){
this.caret.style.borderLeft="1px solid black";
},stopBlinkingCaret:function(){
this.blinkCaret();
},blinkCaret:function(){
this.caret.style.borderLeft=this.caret.style.borderLeft=="1px solid black"?"1px solid white":"1px solid black";
}})});
LFM.set("Scrobbler",new (Class.create({minScrobbleDuration:30,scrobbleURL:"/ajax/scrobble",nowPlayingURL:"/ajax/nowplaying",initialize:function(){
},sendScrobble:function(_23d,_23e,_23f){
var _240={method:"post",parameters:{track:_23d.id,formtoken:LFM.Session.formtoken},onSuccess:_23e,onFailure:_23f};
new Ajax.Request(this.scrobbleURL,_240);
},sendNowPlaying:function(_241,_242,_243){
var _244={method:"post",parameters:{track:_241.id,formtoken:LFM.Session.formtoken},onSuccess:_242,onFailure:_243};
new Ajax.Request(this.nowPlayingURL,_244);
},isScrobblable:function(_245){
var _246=_245.duration&&_245.duration>this.minScrobbleDuration;
var _247=_245.id;
return _246&&_247;
},getScrobblePoint:function(_248){
return Math.max(Math.round(_248.duration/2),30);
}}))());
LFM.set("ScrobbleStream",Class.create({id:null,updateInterval:10,updateLimit:50,maxUpdates:20,updateCount:0,scrobbles:[],streamURL:"/ajax/getgloballisteners",interval:null,isUpdating:false,isPopulated:false,initialize:function(id){
this.id=id;
},start:function(){
if(this.interval){
return;
}
this.update();
this.interval=setInterval(this.update.bind(this),this.updateInterval*1000);
},stop:function(){
clearInterval(this.interval);
this.interval=null;
},updateData:function(){
if(this.updateCount>=this.maxUpdates){
this.stop();
return;
}
this.updateCount++;
if(this.isUpdating){
return;
}
this.isUpdating=true;
new Ajax.Request(this.streamURL,{parameters:{limit:this.updateLimit,formtoken:LFM.Session.formtoken},onException:(function(r){
this.isUpdating=false;
}).bind(this),onFailure:(function(r){
this.isUpdating=false;
}).bind(this),onSuccess:(function(_24c){
if(_24c.responseText){
var _24d=_24c.responseText.evalJSON();
for(var i=0;i<_24d.length;i++){
this.scrobbles.push(_24d[i]);
}
}
this.isUpdating=false;
}).bind(this)});
},update:function(){
if(this.scrobbles.length<=1){
this.updateData();
}
if(this.scrobbles.length==0){
return;
}
var _24f=this.scrobbles.shift();
var li=new Element("li",{"style":"display: none;"}).update(_24f);
$(this.id).insert({"top":li});
new Effect.SlideDown(li,{duration:1});
}}));
var Scroller=Class.create({initialize:function(_251){
this.scroller=$(_251);
this.imageTrackContainer=$(document).getElementsByClassName("imageTrackContainer",this.scroller)[0];
this.imageTrack=this.imageTrackContainer.getElementsByTagName("UL")[0];
this.isScrolling=false;
this.makeScrollingWork();
this.centerSelectedImage();
},makeScrollingWork:function(){
Element.addClassName(this.scroller,"scrollerJS");
if(this.getWidth()<=this.getVisibleWidth()){
if(window.attachEvent&&!window.opera){
Element.setStyle(this.scroller,{width:this.getWidth()+"px"});
}
}else{
Element.setStyle(this.scroller,{padding:"0 10px",marginLeft:0,marginRight:0,overflow:"hidden"});
this.leftScrollButton=document.createElement("a");
this.leftScrollButton.innerHTML="scroll left";
this.leftScrollButton.href="#";
Element.addClassName(this.leftScrollButton,"scrollLeft");
this.scroller.insertBefore(this.leftScrollButton,this.imageTrackContainer);
Event.observe(this.leftScrollButton,"click",this.scrollLeft.bindAsEventListener(this));
this.rightScrollButton=document.createElement("a");
this.rightScrollButton.innerHTML="scroll right";
this.rightScrollButton.href="#";
Element.addClassName(this.rightScrollButton,"scrollRight");
this.scroller.insertBefore(this.rightScrollButton,this.imageTrackContainer);
Event.observe(this.rightScrollButton,"click",this.scrollRight.bindAsEventListener(this));
Event.observe(window,"resize",this.onResize.bindAsEventListener(this));
this.setWidth();
}
},setWidth:function(){
if(!this.imageWidth){
this.imageWidth=this.getImageWidth();
}
Element.setStyle(this.scroller,{maxWidth:this.getWidth()+"px"});
var _252=this.getVisibleWidth();
modulo=_252%this.imageWidth;
_252=_252-modulo;
if(_252>this.getWidth()){
_252=this.getWidth();
}
Element.setStyle(this.scroller,{maxWidth:_252+"px"});
var _253=this.getWidth()*-1+Math.abs(this.getOffset())+this.getVisibleWidth();
var _254=(this.getWidth()-this.getVisibleWidth())*-1;
this.setOffset(_254);
this.refreshButtonStates();
},onResize:function(_255){
this.setWidth();
},getImageWidth:function(){
if(this.imageWidth){
return this.imageWidth;
}else{
sampleImage=this.imageTrack.getElementsByTagName("LI")[0];
if(sampleImage){
this.imageWidth=sampleImage.offsetWidth;
this.imageWidth=this.imageWidth+Element.getStyle(sampleImage,"padding-left").replace("px","")*1;
this.imageWidth=this.imageWidth+Element.getStyle(sampleImage,"padding-right").replace("px","")*1;
this.imageWidth=this.imageWidth+Element.getStyle(sampleImage,"margin-left").replace("px","")*1;
this.imageWidth=this.imageWidth+Element.getStyle(sampleImage,"margin-right").replace("px","")*1;
var _256=Element.getStyle(sampleImage,"border-left-width").replace("px","")*1;
if(!isNaN(_256)){
this.imageWidth=this.imageWidth+_256;
}
var _257=Element.getStyle(sampleImage,"border-right-width").replace("px","")*1;
if(!isNaN(_257)){
this.imageWidth=this.imageWidth+_257;
}
return this.imageWidth;
}else{
return false;
}
}
},getMiddle:function(){
return Math.ceil(this.imageTrackContainer.offsetWidth/2);
},getWidth:function(){
return this.imageTrack.offsetWidth;
},getVisibleWidth:function(){
return this.imageTrackContainer.offsetWidth;
},getNumberOfVisibleImages:function(){
return Math.floor(this.getVisibleWidth()/this.getImageWidth());
},getNumberOfImages:function(){
return Math.floor(this.imageTrack.getElementsByTagName("LI").length);
},getOffset:function(){
offset=Element.getStyle(this.imageTrack,"left");
if(offset){
offset=offset.replace("px","")*1;
if(!isNaN(offset)){
return offset;
}else{
return 0;
}
}else{
return 0;
}
},setOffset:function(_258){
var blah=this.getWidth()-this.getVisibleWidth();
this.imageTrack.setStyle({left:_258+"px"});
},scrollLeft:function(_25a){
if(!this.isScrolling&&this.getOffset()<0){
var _25b=Math.abs(this.getOffset());
var _25c=this.getVisibleWidth();
if(_25c>_25b){
_25c=_25b;
}
this.scroll(_25c);
}
this.refreshButtonStates();
this.leftScrollButton.blur();
Event.stop(_25a);
},scrollRight:function(_25d){
if(!this.isScrolling&&(Math.abs(this.getOffset())+this.getVisibleWidth())<this.getWidth()){
var _25e=this.getWidth()-(Math.abs(this.getOffset())+this.getVisibleWidth());
var _25f=this.getVisibleWidth();
if(_25f>_25e){
_25f=_25e;
}
_25f=_25f*-1;
this.scroll(_25f);
}
this.refreshButtonStates();
this.rightScrollButton.blur();
Event.stop(_25d);
},scroll:function(_260,_261){
if(!this.isScrolling||_261){
new Effect.Move(this.imageTrack,{x:_260,y:0,mode:"relative",duration:0.5,afterFinish:this.afterScrolling.bind(this),beforeStart:this.beforeScrolling.bind(this),queue:{position:"end",scope:"scroller"}});
}
},beforeScrolling:function(_262){
this.isScrolling=true;
this.totalDelta=this.totalDelta+_262.options.x;
},afterScrolling:function(_263){
this.isScrolling=false;
this.totalDelta=this.totalDelta-_263.options.x;
this.refreshButtonStates();
},refreshButtonStates:function(){
if(this.rightScrollButton&&this.leftScrollButton){
if((Math.abs(this.getOffset())+this.getVisibleWidth())<this.getWidth()){
this.rightScrollButton.className="scrollRight";
}else{
this.rightScrollButton.className="scrollRight disabled";
}
if(this.getOffset()<0){
this.leftScrollButton.className="scrollLeft";
}else{
this.leftScrollButton.className="scrollLeft disabled";
}
}
},getSelectedImage:function(){
selectedImage=$(document).getElementsByClassName("selected",this.imageTrack)[0];
if(selectedImage){
return $(selectedImage);
}else{
return false;
}
},centerSelectedImage:function(){
if(this.getVisibleWidth()!=this.getWidth()){
var _264=this.getSelectedImage().id;
if(_264&&this.getImageWidth()){
_264=(_264.substring(5)*1)-1;
var _265=_264*this.getImageWidth();
_265=_265-this.getMiddle()+this.getImageWidth()/2;
if(_265>(this.getWidth()-this.getVisibleWidth())){
_265=this.getWidth()-this.getVisibleWidth();
}
_265=_265*-1;
if(_265>0){
_265=0;
}
Element.setStyle(this.imageTrack,{left:_265+"px"});
this.refreshButtonStates();
}
}
}});
LFM.set("Resource",{Shoutbox:Class.create({initialize:function(_266){
this.shoutbox=_266;
this.shoutbox.container=$(this.shoutbox.container);
this.textarea=$("shoutmsg");
this.overCharLimit=false;
if($("shoutPost")){
$("shoutPost").observe("submit",this.submit.bindAsEventListener(this));
this.textarea.observe("keyup",this.calculateCharCount.bindAsEventListener(this));
}
this.deleteButtons=this.shoutbox.container.select(".delete");
this.deleteButtons.each(function(_267){
_267.observe("click",this.bin.bindAsEventListener(this));
}.bind(this));
if($("shoutboxPopup")){
$("shoutboxPopup").observe("click",this.popup.bindAsEventListener(this));
}
if($("shoutPostToggler")&&$("shoutPostToggler").down("a")){
$("shoutPostToggler").down("a").observe("click",this.toggleInput.bindAsEventListener(this));
}
if($("shoutPostAgain")){
$("shoutPostAgain").observe("click",this.toggleInput.bindAsEventListener(this));
}
},submit:function(e){
e.stop();
if($F(this.textarea)==""){
return;
}
this.toggleInput(e);
$("shoutPostWait").show();
var url=this.shoutbox.destination;
if(url.substr(-1)!="/"){
url+="/";
}
url+="add";
var pars=$("shoutPost").serialize()+"&restype="+this.shoutbox.restype+"&resid="+this.shoutbox.resid+"&lang="+this.shoutbox.lang+"&ajax=1";
var _26b=new Ajax.Request(url,{method:"post",parameters:pars,onSuccess:this.addShout.bind(this)});
},addShout:function(_26c){
if(this.shoutbox.restype==20){
LFM.Omniture.trackEvents("CommentPost");
}else{
LFM.Omniture.trackEvents("ShoutPost");
}
var _26d=$("shoutList");
$("shoutList").insert({before:_26c.responseText});
if(this.shoutbox.order=="asc"){
_26d.innerHTML=_26d.innerHTML+$("newShoutList").innerHTML;
}else{
_26d.innerHTML=$("newShoutList").innerHTML+_26d.innerHTML;
}
$("newShoutList").remove();
$("shoutList").select("li").each(function(li){
var _26f=li.down(".delete");
if(_26f){
_26f.observe("click",this.bin.bindAsEventListener(this));
}
}.bind(this));
this.textarea.value="";
$("shoutPostWait").hide();
if($("noShouts")){
$("noShouts").remove();
}
if($("shoutPostToggler")){
$("shoutPostToggler").hide();
}
$("shoutPostAgain").show();
this.updateCharCountDisplay(0);
},bin:function(_270){
_270.stop();
var _271=_270.findElement("li");
var form=_271.down("form");
var _273=this.shoutbox.destination;
if(_273.substr(-1)!="/"){
_273+="/";
}
_273+="delete";
form.action=_273;
var _274=this.shoutbox.restype;
var _275=this.shoutbox.resid;
var _276=new LFM.Dialog({content:LFM.String.deleteMessagePrompt,confirmText:LFM.String.deleteButtonText,action:_273,onConfirm:function(e){
e.stop();
this.hide();
form.request({parameters:{restype:_274,resid:_275,ajax:1},onSuccess:function(req){
if(req.responseText=="OK"){
new Effect.Fade(_271,{duration:0.2});
}
}});
}});
_276.show();
},toggleInput:function(e){
if($("shoutPost").visible()){
$("shoutPost").hide();
}else{
$("shoutPostAgain").hide();
$("shoutPost").show();
this.textarea.focus();
}
e.stop();
},calculateCharCount:function(){
var _27a=this.textarea.value.length;
this.updateCharLimit(_27a);
this.updateCharCountDisplay(_27a);
},updateCharCountDisplay:function(_27b){
charCounter=$("sbCharCount");
var _27c=this.shoutbox.charlimitMessage;
if(charCounter){
_27c=_27c.replace(/CURRENTCHARS/,_27b);
_27c=_27c.replace(/MAXCHARS/,this.shoutbox.charlimit);
charCounter.innerHTML=_27c;
}
},updateCharLimit:function(_27d){
var _27e=(_27d>this.shoutbox.charlimit);
if(!this.overCharLimit&&_27e){
$("sbCharCount").up().addClassName("overCharLimit");
$("sbPost").disable();
this.textarea.focus();
}
if(this.overCharLimit&&!_27e){
$("sbCharCount").up().removeClassName("overCharLimit");
$("sbPost").enable();
}
this.overCharLimit=_27e;
}})});
LFM.set("SoundManager",Class.create({initialize:function(){
}}));
LFM.SoundManager.getInstance=function(){
if(!window.soundManager){
window.soundManager=new SoundManager();
window.soundManager.url=LFM.Session.staticHost+"/flatness/soundmanager/";
window.soundManager.onready(function(){
LFM.log("SoundManager2 Ready");
if(!window.soundManager.supported()){
LFM.log("SoundManager2 not supported");
}
});
window.soundManager.beginDelayedInit();
}
return window.soundManager;
};
LFM.set("Util",{SpriteAnimation:Class.create({initialize:function(_27f,_280){
this.element=_27f;
this.frameSize=_280.frameSize||this.element.getHeight();
this.startFrame=_280.startFrame||0;
this.endFrame=this.startFrame+_280.length-1;
this.loop=_280.loop||false;
this.positionX=_280.positionX||0;
this.positionY=_280.positionY||0;
this.axis=(_280.axis||"y").toUpperCase();
this.fps=_280.fps||1;
this.currentFrame=this.startFrame;
this.timer=null;
if(_280.play){
this.play();
}
},reset:function(){
this.setFrame(this.startFrame);
},getLength:function(){
return this.endFrame-this.startFrame+1;
},next:function(){
if(this.currentFrame!=this.endFrame){
this.setFrame(1+this.currentFrame);
}else{
if(this.loop){
this.reset();
}else{
this.stop();
}
}
},setFrame:function(_281){
this.currentFrame=_281;
this["position"+this.axis]=this.currentFrame*(this.frameSize*-1);
var pos=this.positionX+"px "+this.positionY+"px";
this.element.setStyle({backgroundPosition:pos});
},play:function(_283,end,loop){
this.stop();
this.reset();
this.timer=setInterval(this.next.bind(this),1000/this.fps);
},getFramePosition:function(){
return this.currentFrame-this.startFrame;
},stop:function(){
clearTimeout(this.timer);
this.timer=null;
},isPlaying:function(){
return !!this.timer;
},cleanup:function(){
this.element.setStyle({"backgroundPosition":""});
}})});
LFM.set("Display",{TableDragDrop:Class.create({initialize:function(_286,_287){
this.draggedRow=null;
this.rowWithBorderAndShit=null;
this.mouseOffset=null;
this.oldY=0;
this.dragged=false;
if(_287&&_287.dragHandle){
this.dragHandle=_287.dragHandle;
}else{
this.dragHandle=false;
}
this.table=$(_286);
this.table.addClassName("draggable");
this.table.observe("mousedown",this.onMouseDown.bindAsEventListener(this));
if(this.dragHandle){
this.table.addClassName("withDragHandles");
}else{
this.table.addClassName("allDraggable");
}
this.table.down("tbody").observe("click",this.onClick.bindAsEventListener(this));
},onClick:function(_288){
if(this.dragged){
_288.stop();
this.dragged=false;
}
},getMouseOffset:function(_289,_28a){
var _28b=_289.cumulativeOffset();
return {x:_28a.pointerX()-_28b.left,y:_28a.pointerY()-_28b.top};
},onMouseDown:function(_28c){
if(!_28c.isLeftClick()){
return;
}
if(this.dragHandle&&!_28c.element().hasClassName(this.dragHandle)){
return;
}
if((tag_name=_28c.element().tagName.toUpperCase())&&(tag_name=="INPUT"||tag_name=="SELECT"||tag_name=="OPTION"||tag_name=="BUTTON"||tag_name=="TEXTAREA")){
return;
}
this.draggedRow=_28c.findElement("tr");
if(this.draggedRow.previous("tr")){
this.rowWithBorderAndShit=this.draggedRow.previous("tr");
this.rowWithBorderAndShit.addClassName("beforeDraggedRow");
}else{
if(this.draggedRow.next("tr")){
this.rowWithBorderAndShit=this.draggedRow.next("tr");
this.rowWithBorderAndShit.addClassName("afterDraggedRow");
}
}
this.mouseOffset=this.getMouseOffset(this.draggedRow,_28c);
_28c.stop();
this.draggedRow.addClassName("dragging");
this.documentOnMouseMove=this.onMouseMove.bindAsEventListener(this);
this.documentOnMouseUp=this.onMouseUp.bindAsEventListener(this);
document.observe("mousemove",this.documentOnMouseMove);
document.observe("mouseup",this.documentOnMouseUp);
this.rows=this.table.down("tbody").select("tr");
},onMouseMove:function(_28d){
var y=_28d.pointerY()-this.mouseOffset.y;
_28d.stop();
if(y!=this.oldY){
var _28f=y>this.oldY;
this.oldY=y;
var _290=this.findDropTargetRow(y);
if(_290){
this.dragged=true;
if(_28f&&this.draggedRow!=_290){
this.draggedRow.parentNode.insertBefore(this.draggedRow,_290.nextSibling);
}else{
if(!_28f&&this.draggedRow!=_290){
this.draggedRow.parentNode.insertBefore(this.draggedRow,_290);
}
}
}
}
},onMouseUp:function(_291){
_291.stop();
this.draggedRow.removeClassName("dragging");
this.rowWithBorderAndShit.removeClassName("beforeDraggedRow");
this.rowWithBorderAndShit.removeClassName("afterDraggedRow");
if(this.onDrop){
this.onDrop(this.table,this.draggedRow);
}
this.draggedRow=null;
document.stopObserving("mousemove",this.documentOnMouseMove);
document.stopObserving("mouseup",this.documentOnMouseUp);
},findDropTargetRow:function(y){
return this.rows.find(function(row){
var rowY=row.cumulativeOffset().top;
var _295=row.getHeight()/2;
if((y>rowY-_295)&&(y<(rowY+_295))){
return true;
}else{
return false;
}
});
return null;
}})});
LFM.set("Resource",{Users:Class.create({initialize:function(_296){
this.container=$("users");
this.container.observe("click",function(_297){
log("clicked container");
var _298=_297.element();
if(_298.match("a.delete img")){
_297.stop();
var _299=_298.up("li");
if(_299){
this.bin(_299);
}
}
}.bind(this));
},bin:function(_29a){
var _29b=new LFM.Dialog({resource:_29a.getResource(),content:LFM.String.deleteFriendPrompt,confirmText:LFM.String.deleteButtonText,action:"friends/delete",onDone:function(_29c){
var _29d=_29c.getResourceElement();
new Effect.Fade(_29d,{duration:0.5});
},showDone:false});
_29b.show();
}})});
LFM.set("Video",{FullWidth:Class.create({initialize:function(id){
this.container=$(id);
this.wrapper=this.container.down("div.wrapper");
this.originalDimensions=this.wrapper.getDimensions();
this.aspectRatio=this.originalDimensions.height/this.originalDimensions.width;
this.resize();
Event.observe(document.onresize?document:window,"resize",function(_29f){
this.resize();
}.bind(this));
},resize:function(){
this.wrapper.setStyle({width:this.container.getWidth()+"px",height:Math.round(this.container.getWidth()*this.aspectRatio)+"px"});
}})});
LFM.Ajax.LazyRequest=Class.create({options:{laziness:2,beforeSend:false},_defaultAjaxOptions:{method:"post",parameters:{ajax:true,formtoken:LFM.get("Session","formtoken")}},_timeoutId:false,_ajaxUrl:false,_ajaxOptions:{},_lastTime:0,initialize:function(url,_2a1){
Object.extend(this.options,_2a1);
this._ajaxUrl=url;
if(this.options.lazyness){
this.options.laziness=this.options.lazyness;
}
},send:function(_2a2){
if(this._intervalId){
clearTimeout(this._intervalId);
}
var now=new Date();
this._lastTime=now.getTime()/1000;
this._ajaxOptions=this._defaultAjaxOptions;
if(_2a2){
if(_2a2.parameters){
Object.extend(this._ajaxOptions.parameters,_2a2.parameters);
_2a2.paramaters=this._ajaxOptions.parameters;
}
Object.extend(this._ajaxOptions,_2a2);
}
this._ajaxOptions.parameters.time=this._lastTime;
this._intervalId=setTimeout(this._performSend.bind(this),this.options.laziness*1000);
},_beforeSend:function(){
if(!this.options.beforeSend){
return;
}
Object.extend(this._ajaxOptions.parameters,this.options.beforeSend());
},_performSend:function(){
this._beforeSend();
new Ajax.Request(this._ajaxUrl,this._ajaxOptions);
}});
LFM.Ajax.Response=Class.create({initialize:function(_2a4){
try{
if(typeof _2a4=="string"){
this.ajaxResponse=_2a4.evalJSON();
}else{
if(_2a4.responseText){
this.ajaxResponse=_2a4.responseText.evalJSON();
}else{
this.ajaxResponse=_2a4;
}
}
}
catch(err){
this.ajaxResponse={errormessage:"Invalid JSON response"};
}
this.data=$H(this.ajaxResponse.data);
if(this.isError()){
this.printError();
}
},get:function(key){
return this.data.get(key);
},set:function(key,_2a7){
return this.data.set(key,_2a7);
},toObject:function(){
return this.data.toObject();
},isError:function(){
return !this.ajaxResponse.success;
},isSuccess:function(){
return !this.isError();
},getErrorCode:function(){
return this.ajaxResponse.errorcode?this.ajaxResponse.errorcode:null;
},getErrorMessage:function(){
return this.ajaxResponse.errormessage?this.ajaxResponse.errormessage:null;
},errorIs:function(code){
return this.getErrorCode()===code;
},isUnauthorised:function(){
return this.errorIs(LFM.Ajax.Response.Errors.UNAUTHORISED);
},printError:function(){
if(LFM.get("config","DEVELOPMENT_SERVER")){
if(!this.ajaxResponse){
LFM.warn("Error [No response]");
}else{
LFM.warn("Error ["+this.getErrorCode()+"]: "+this.getErrorMessage());
}
}
},getResource:function(){
return this.ajaxResponse.resource?this.ajaxResponse.resource:null;
},getResourceElement:function(){
return LFM.getResourceElement(this.getResource());
},buildResourceLink:function(){
var _2a9=this.getResource();
if(_2a9){
var link=new Element("a",{"href":_2a9.url});
if(_2a9.name){
link.update(_2a9.name);
}
return link;
}
return false;
},followRedirect:function(){
if(this.ajaxResponse.redirect){
window.location.href=this.ajaxResponse.redirect;
return true;
}else{
return false;
}
}});
LFM.Ajax.Response.Errors={UNAUTHORISED:401};
LFM.Ajax.setUserPref=function(pref,_2ac,_2ad){
new Ajax.Request("/ajax/setUserPref",{parameters:{formtoken:LFM.Session.formtoken,pref:pref,value:_2ac},onComplete:function(_2ae){
var _2af=new LFM.Ajax.Response(_2ae);
if(_2ad){
_2ad(_2af);
}
}});
};
LFM.Ajax.StatusHolder=Class.create({initialize:function(_2b0,_2b1){
this.status="idle";
this.element=$(_2b0);
this.options={position:"after"};
Object.extend(this.options,_2b1);
this.indicator=$(this.element.identify()+"_statusHolder");
if(this.indicator){
if(this.indicator.hasClassName("success")){
this.status="success";
}else{
if(this.indicator.hasClassName("failure")){
this.status="failure";
}else{
if(this.indicator.hasClassName("progress")){
this.status="busy";
}
}
}
}else{
this.indicator=document.createElement("img");
this.indicator=Element.extend(this.indicator);
this.indicator.src=LFM.Session.staticHost+"/tablestyles/pixel.gif";
this.indicator.height=16;
this.indicator.width=16;
if(this.options.position=="after"){
this.element.parentNode.insertBefore(this.indicator,this.element.nextSibling);
}else{
if(this.options.position=="before"){
this.element.parentNode.insertBefore(this.indicator,this.element);
}else{
if(this.options.position=="top"){
this.element.insertBefore(this.indicator,this.element.firstChild);
}else{
if(this.options.position=="bottom"){
this.element.appendChild(this.indicator);
}
}
}
}
this.indicator=this.indicator.wrap("SPAN");
this.indicator.addClassName("statusHolder");
this.indicator.id=this.element.identify()+"_statusHolder";
}
},remove:function(){
this.indicator.remove();
},busy:function(){
this.idle();
this.status="busy";
this.indicator.addClassName("progress");
this.indicator.down("img").src=LFM.Session.staticHost+"/depth/global/progress_new.gif";
},isBusy:function(){
return this.status=="busy";
},success:function(){
this.idle();
this.status="success";
this.indicator.addClassName("success");
this.indicator.down("img").src=LFM.Session.staticHost+"/depth/forms/correct_new.gif";
},isSuccess:function(){
return this.status=="success";
},failure:function(){
this.idle();
this.status="failure";
this.indicator.addClassName("failure");
this.indicator.down("img").src=LFM.Session.staticHost+"/depth/forms/incorrect_new.gif";
},isFailure:function(){
return this.status=="failure";
},idle:function(){
this.status="idle";
this.indicator.removeClassName("progress");
this.indicator.removeClassName("success");
this.indicator.removeClassName("failure");
this.indicator.down("img").src=LFM.Session.staticHost+"/tablestyles/pixel.gif";
},isIdle:function(){
return this.status=="idle";
}});
LFM.set("Ajax",{Autocompleter:Class.create(Ajax.Autocompleter,{setOptions:function(_2b2){
this.options=Object.extend({method:"get"},_2b2||{});
},buildItem:function(name){
return new Element("a",{href:"#"}).update(name).wrap(new Element("li"));
},onComplete:function(_2b4){
try{
var _2b5=_2b4.responseText.evalJSON();
}
catch(err){
return false;
}
if(_2b5&&_2b5.response.docs){
var list=new Element("ul");
var _2b7=this.getToken();
list.insert(this.buildItem(_2b7));
_2b5.response.docs.each(function(_2b8){
if(_2b8.name.toLowerCase()!=_2b7.toLowerCase()){
list.insert(this.buildItem(_2b8.name));
}
}.bind(this));
this.updateChoices(new Element("div").update(list).innerHTML);
}
}})});
LFM.set("Ajax",{Multicompleter:Class.create(LFM.Ajax.Autocompleter,{initialize:function(_2b9,_2ba,url,_2bc){
this.baseInitialize(_2b9,_2ba,_2bc);
this.url=url;
this.options.asynchronous=true;
this.options.onComplete=this.onComplete.bind(this);
this.options.onHide=function(_2bd,_2be){
window.status="";
new Effect.Fade(_2be,{duration:0.15});
};
this.form=this.element.up("form");
this.submit=this.form.down("input[type=submit]");
var _2bf={};
if(this.options.enabled){
_2bf["force"]=1;
}else{
this.show=function(){
return false;
};
this.startIndicator=function(){
return false;
};
}
if(LFM.Session.userName){
_2bf["username"]=LFM.Session.userName;
}
if(this.options.parameters){
_2bf=Object.extend(_2bf,this.options.parameters);
}
this.options.defaultParams=_2bf;
this.element.observe("keyup",this.onKeyUp.bindAsEventListener(this));
this.form.observe("submit",this.onSubmit.bindAsEventListener(this));
this.update.observe("mouseup",this.onClick.bindAsEventListener(this));
this.update.observe("mouseover",this.onHover.bindAsEventListener(this));
this.element.observe("focus",this.onFocus.bindAsEventListener(this));
this.init();
},init:function(){
},getUpdatedChoices:function(){
this.startIndicator();
var _2c0=encodeURIComponent(this.options.paramName)+"="+encodeURIComponent(this.getToken());
this.options.parameters={};
this.options.parameters[this.options.paramName]=this.getToken();
if(this.options.defaultParams){
Object.extend(this.options.parameters,this.options.defaultParams);
}
this.search();
},search:function(){
new Ajax.Request(this.url,this.options);
this.personalMatches=this.matchPersonalData(this.getToken());
},matchPersonalData:function(_2c1){
if(!_2c1.length||!this.personalData){
return false;
}
var _2c2=new RegExp(_2c1.replace(/([\\\^\$*+[\]?{}.=!:(|)])/g,"\\$1"),"i");
var _2c3=[];
var _2c4=this.personalData.get("friends");
if(_2c4){
_2c4.each(function(_2c5,i){
var _2c7=_2c5.name.match(_2c2)||(_2c5.realname&&_2c5.realname.match(_2c2));
if(_2c7){
_2c3.push(_2c5);
}
});
}
var _2c8=this.personalData.get("groups");
if(_2c8){
_2c8.each(function(_2c9,i){
var _2cb=_2c9.name.match(_2c2);
if(_2cb){
_2c3.push(_2c9);
}
});
}
var _2cc=this.personalData.get("labels");
if(_2cc){
_2cc.each(function(_2cd,i){
var _2cf=_2cd.name.match(_2c2)&&_2cd.single_artist!="t";
if(_2cf){
_2c3.push(_2cd);
}
});
}
return _2c3;
},buildEvent:function(_2d0){
var _2d1=_2d0.date.split("T");
var _2d2=_2d1[0].split("-");
var _2d3=_2d0.event||_2d0.artist;
var _2d4="<span class=\"calSheet calSheetSmall\">"+"<span title=\""+_2d0.date+"\">"+"<span class=\"month\">"+LFM.String.shortMonths[_2d2[1]-0]+"</span>"+"<span class=\"day\">"+(_2d2[2]-0)+"</span>"+"</span>"+"</span>";
var _2d5=_2d0["country_"+LFM.Session.language]||_2d0["country_en"];
return _2d4+"<strong>"+_2d3.truncate(25)+"</strong><br>"+_2d0.city.truncate(25)+", "+_2d5.truncate(25);
},buildEventTitle:function(_2d6){
var _2d7=_2d6.event||_2d6.artist;
var _2d8=_2d6["country_"+LFM.Session.language]||_2d6["country_en"];
return _2d7+", "+_2d6.venue+", "+_2d6.city+", "+_2d8;
},buildEventURL:function(_2d9){
return "/event/"+encodeURIComponent(encodeURIComponent(_2d9.resid));
},buildArtist:function(_2da){
var _2db=this.buildArtistImageURL(_2da);
var _2dc="<img src=\""+_2db+"\" width=\"34\" height=\"34\">";
return _2dc+this.buildName(_2da.artist);
},buildArtistTitle:function(_2dd){
return _2dd.artist;
},buildArtistURL:function(_2de){
return "/music/"+encodeURIComponent(encodeURIComponent(_2de.artist));
},buildArtistImageURL:function(_2df){
if(_2df.image){
return LFM.Session.userserveHost+"/serve/34s/"+_2df.image;
}else{
var _2e0={api_key:LFM.Session.wsKey,artist:_2df.artist,method:"artist.getImageRedirect",size:"smallsquare"};
return "http://"+LFM.Session.wsHost+"/2.0/?"+Object.toQueryString(_2e0);
}
},buildAlbum:function(_2e1){
var _2e2=this.buildAlbumImageURL(_2e1);
var _2e3="<span class=\"albumCover coverSmall\" />"+"<span class=\"art\"><img src=\""+_2e2+"\" width=\"34\" height=\"34\"></span>"+"<span class=\"jewelcase\"></span>"+"</span>";
return _2e3+this.buildName(_2e1.album)+"<br>"+_2e1.artist.truncate(25);
},buildAlbumTitle:function(_2e4){
return _2e4.album+" - "+_2e4.artist;
},buildAlbumURL:function(_2e5){
return "/music/"+encodeURIComponent(encodeURIComponent(_2e5.artist))+"/"+encodeURIComponent(encodeURIComponent(_2e5.album));
},buildAlbumImageURL:function(_2e6){
if(_2e6.image){
return LFM.Session.userserveHost+"/serve/34s/"+_2e6.image;
}else{
var _2e7={api_key:LFM.Session.wsKey,artist:_2e6.artist,album:_2e6.album,method:"album.getImageRedirect",size:"smallsquare"};
return "http://"+LFM.Session.wsHost+"/2.0/?"+Object.toQueryString(_2e7);
}
},buildTrack:function(_2e8){
var _2e9=this.buildArtistImageURL(_2e8);
var _2ea="<img src=\""+_2e9+"\" width=\"34\" height=\"34\">";
var _2eb=_2e8.duration?" <small> ("+LFM.timeFormat(_2e8.duration)+")</small>":"";
return _2ea+this.buildName(_2e8.track)+_2eb+"<br>"+_2e8.artist.truncate(25);
},buildTrackTitle:function(_2ec){
return _2ec.track+" - "+_2ec.artist;
},buildTrackURL:function(_2ed){
return "/music/"+encodeURIComponent(encodeURIComponent(_2ed.artist))+"/_/"+encodeURIComponent(encodeURIComponent(_2ed.track));
},buildTag:function(_2ee){
var icon="<img width=\"30\" height=\"30\" src=\""+LFM.Session.staticHost+"/flatness/icons/tag/1/tag_30.png\">";
return icon+this.buildName(_2ee.tag);
},buildTagTitle:function(_2f0){
return _2f0.tag;
},buildTagURL:function(_2f1){
return "/tag/"+encodeURIComponent(encodeURIComponent(_2f1.tag));
},buildUser:function(_2f2){
var _2f3=this.buildResImage(_2f2,"/flatness/catalogue/noimage/2/default_user_small.png");
var user=_2f3+this.buildName(_2f2.name);
if(_2f2.realname){
user+="<br>"+_2f2.realname.truncate(25);
}
return user;
},buildUserTitle:function(_2f5){
var _2f6=_2f5.name;
if(_2f5.realname){
_2f6+=" - "+_2f5.realname;
}
return _2f6;
},buildUserURL:function(_2f7){
return "/user/"+encodeURIComponent(encodeURIComponent(_2f7.name));
},buildGroup:function(_2f8){
var _2f9=this.buildResImage(_2f8,"/flatness/catalogue/noimage/2/default_group_small.png");
var name;
if(_2f8.group){
name=this.buildName(_2f8.group);
}else{
name=this.buildName(_2f8.name);
}
return _2f9+name;
},buildGroupTitle:function(_2fb){
return _2fb.name||_2fb.group;
},buildGroupURL:function(_2fc){
var name=_2fc.name||_2fc.group;
return "/group/"+encodeURIComponent(encodeURIComponent(name));
},buildLabel:function(_2fe){
var _2ff=this.buildResImage(_2fe,"/flatness/catalogue/noimage/2/default_label_small.png");
var name;
if(_2fe.label){
name=this.buildName(_2fe.label);
}else{
name=this.buildName(_2fe.name);
}
return _2ff+name;
},buildLabelTitle:function(_301){
return _301.name||_301.label;
},buildLabelURL:function(_302){
var root;
var name=_302.name||_302.label;
if(_302.single_artist=="t"){
root="/artist/";
}else{
root="/label/";
}
return root+encodeURIComponent(encodeURIComponent(name));
},buildName:function(name){
return "<strong>"+name.truncate(25)+"</strong>";
},buildResTitle:function(_306){
return _306.name;
},buildResImage:function(_307,_308){
var _309=LFM.Session.staticHost+_308;
if(_307.image_id){
_309=LFM.Session.userserveHost+"/serve/34s/"+_307.image_id+".jpg";
}else{
if(_307.image){
_309=LFM.Session.userserveHost+"/serve/34s/"+_307.image;
}
}
var _30a="<img src=\""+_309+"\" width=\"34\" height=\"34\">";
return _30a;
},buildItemLink:function(_30b){
var _30c=_30b.res?_30b.res.type:_30b.restype;
var _30d=LFM.resTypeLookup[_30c];
if(!_30d){
LFM.warn("no restype found: "+_30c);
}else{
try{
var url=this["build"+_30d+"URL"](_30b);
if(!this.urls[url]){
this.urls[url]=_30d;
var item=this["build"+_30d](_30b);
var _310=this["build"+_30d+"Title"](_30b);
var link=new Element("a",{href:url+"?ac="+encodeURIComponent(this.getToken()),title:_310}).addClassName(_30d.toLowerCase()+"Item").update(item);
return link;
}
}
catch(e){
LFM.warn(_30d,e);
}
}
},buildSearchLink:function(_312){
var _313=this.form.action+"?"+this.form.serialize();
var link=new Element("a",{href:_313}).addClassName("viewAll");
return new Element("span").addClassName("moduleOptions").update(_312).wrap(link);
},setOptions:function(_315){
_315=_315||{};
this.options=Object.extend({method:"get",onShow:function(_316,_317){
if(!_317.style.position||_317.style.position=="absolute"){
_317.style.position="absolute";
Position.clone(_316,_317,{setHeight:false,setWidth:false,offsetTop:_316.offsetHeight});
}
Effect.Appear(_317,{duration:0.15});
}},_315);
},markNext:function(){
if(this.index===null){
this.index=0;
}else{
if(this.index<this.entryCount-1){
this.index++;
}
}
var _318=this.getCurrentEntry();
if(_318){
window.status=_318.down("a").href;
}else{
window.status="";
}
},markPrevious:function(){
if(this.index>0){
this.index--;
}else{
this.index=null;
}
var _319=this.getCurrentEntry();
if(_319){
window.status=_319.down("a").href;
}else{
window.status="";
}
},getEntry:function(_31a){
if(_31a!==null){
return this.update.down("li.item",_31a);
}
},updateElement:function(item){
if(item){
var link=item.down("a");
if(link){
if(link.hasClassName("viewAll")){
LFM.Omniture.prepareEvar("HeaderSearchAction","ViewAllReturn");
}else{
LFM.Omniture.prepareEvar("HeaderSearchAction","Return");
if(this.urls[link.pathname]){
LFM.Omniture.prepareEvar("HeaderSearchRestype",this.urls[link.pathname]);
}
}
LFM.Omniture.setLink(link);
LFM.Omniture.trackEvents("HeaderSearch");
LFM.redirect(link.href);
return true;
}
}
},addLinkedItem:function(_31d,list){
var link;
var _320=_31d.res?_31d.res.type:_31d.restype;
if(_320){
link=this.buildItemLink(_31d);
}else{
link=this.buildSearchLink(_31d);
}
if(link){
var item=link.wrap(new Element("li").addClassName("item"));
list.insert(item);
return item;
}
return false;
},onBlur:function(e){
this.blurTimeout=setTimeout(function(){
this.hide();
this.hasFocus=false;
this.active=false;
}.bind(this),250);
},onFocus:function(e){
LFM.Omniture.trackEvents("HeaderSearchFocus");
if(this.options.enabled){
this.loadPersonalData();
}
},loadPersonalData:function(){
if(this.personalData||!LFM.Session.loggedIn||!LFM.Session.userURL||this.unauthorised){
return false;
}
LFM.info("AC: Load personal data");
new Ajax.Request(LFM.Session.userURL+"/acdata",{method:"get",parameters:{ajax:1},onSuccess:function(_324){
response=new LFM.Ajax.Response(_324);
if(response.isSuccess()){
LFM.info("AC: Personal data loaded");
this.personalData=response;
}else{
if(response.isUnauthorised()){
this.unauthorised=true;
}
}
}.bind(this)});
},onHover:function(e){
var link=e.findElement("a");
if(link){
if(this.index!=link.autocompleteIndex){
this.index=link.autocompleteIndex;
this.render();
}
}
},onClick:function(e){
this.element.focus();
clearTimeout(this.blurTimeout);
var link=e.findElement("a");
if(link){
if(link.hasClassName("viewAll")){
LFM.Omniture.prepareEvar("HeaderSearchAction","ViewAllClick");
}else{
LFM.Omniture.prepareEvar("HeaderSearchAction","Click");
if(this.urls[link.pathname]){
LFM.Omniture.prepareEvar("HeaderSearchRestype",this.urls[link.pathname]);
}
}
LFM.Omniture.setLink(link);
LFM.Omniture.trackEvents("HeaderSearch");
}
},onKeyPress:function(e){
if(this.active){
switch(e.keyCode){
case Event.KEY_TAB:
case Event.KEY_RETURN:
if(this.options.enabled&&this.getCurrentEntry()){
this.selectEntry();
e.stop();
}
break;
case Event.KEY_ESC:
if(this.options.enabled){
this.hide();
this.active=false;
e.stop();
}
return;
case Event.KEY_LEFT:
case Event.KEY_RIGHT:
return;
case Event.KEY_UP:
if(this.options.enabled){
this.markPrevious();
this.render();
e.stop();
}
return;
case Event.KEY_DOWN:
if(this.options.enabled){
this.markNext();
this.render();
e.stop();
}
return;
}
}else{
if(e.keyCode==Event.KEY_TAB||e.keyCode==Event.KEY_RETURN||(Prototype.Browser.WebKit>0&&e.keyCode==0)){
return;
}
}
this.changed=true;
this.hasFocus=true;
if(this.observer){
clearTimeout(this.observer);
}
this.observer=setTimeout(this.onObserverEvent.bind(this),this.options.frequency*1000);
},onKeyUp:function(e){
this.changed=false;
var _32b=this.getToken();
if(_32b.length>=this.options.minChars&&_32b!=this.lastToken){
this.startIndicator();
}
},onSubmit:function(e){
var _32d=this.form.serialize().toQueryParams();
var _32e=this.getToken();
LFM.Omniture.prepareEvar("SearchLength",_32e.length);
if(this.options.enabled){
LFM.Omniture.prepareEvar("SearchType","multicomplete");
}else{
if(_32d.m){
LFM.Omniture.prepareEvar("SearchType",_32d.m);
}
}
LFM.Omniture.prepareEvar("HeaderSearchAction","Search");
LFM.Omniture.trackEvents("HeaderSearch");
},onObserverEvent:function(){
this.changed=false;
var _32f=this.getToken();
if(_32f.length>=this.options.minChars){
if(_32f!=this.lastToken&&_32f!=this.element.getAttribute("placeholder")){
this.getUpdatedChoices();
}else{
this.render();
}
}else{
this.active=false;
this.hide();
}
this.lastToken=_32f;
this.oldElementValue=this.element.value;
},getToken:function(){
return $F(this.element);
},processResults:function(_330){
var list=new Element("ul");
if(_330){
this.urls={};
_330.each(function(_332,_333){
this.addLinkedItem(_332,list);
},this);
}
this.addViewAll(list,_330.length);
return list;
},addViewAll:function(list,_335){
this.addLinkedItem(LFM.String.siteSearchViewAll.replace("QUERY",this.getToken().escapeHTML()),list);
this.entryCount=_335+1;
},onComplete:function(_336){
if(this.changed||!this.hasFocus){
return false;
}
var _337=new Array,_338=0;
try{
var _339=_336.responseText.evalJSON();
_337=_339.response.docs;
}
catch(err){
LFM.warn("JSON error: "+_336.responseText);
}
if(this.personalMatches&&this.personalMatches.length){
var _33a=Math.min(this.personalMatches.length,3);
_337=this.personalMatches.slice(0,_33a).concat(_337.slice(0,10-_33a));
}
_338=_337.length;
var list=this.processResults(_337);
this.updateChoices(list,_338);
},updateChoices:function(list,_33d){
this.update.update(list);
var _33e=new Element("p",{"class":"header"});
if(_33d){
_33e.update(LFM.String.siteSearchSuggestions);
}else{
_33e.update(LFM.String.siteSearchNoSuggestions).addClassName("empty");
}
this.update.insert({"top":_33e});
if(LFM.Session.loggedIn&&!this.personalData){
var _33f=new Element("div").addClassName("message messageWarn").update(LFM.String.autocompletePersonalDataDown);
this.update.insert({"bottom":_33f});
}
this.update.select("li.item a").each(function(link,_341){
link.autocompleteIndex=_341;
},this);
this.stopIndicator();
this.index=null;
this.render();
}})});
LFM.set("Ajax",{GroupedMulticompleter:Class.create(LFM.Ajax.Multicompleter,{resTypeGroups:[LFM.resTypes.ARTIST,LFM.resTypes.ALBUM,LFM.resTypes.TRACK,LFM.resTypes.EVENT,LFM.resTypes.TAG,LFM.resTypes.USER,LFM.resTypes.GROUP,LFM.resTypes.LABEL],init:function(){
this.update.addClassName("grouped");
},buildArtist:function(_342){
var _343=this.buildArtistImageURL(_342);
var _344="<span class=\"img\"><span><img src=\""+_343+"\" width=\"34\" height=\"34\" /></span></span>";
return _344+"<strong class=\"artist\">"+_342.artist.truncate(25)+"</strong>";
},buildTrack:function(_345){
var _346=this.buildArtistImageURL(_345);
var _347="<span class=\"img\"><span><img src=\""+_346+"\" width=\"34\" height=\"34\" /></span></span>";
var _348=_345.duration?" <small class=\"time\"> ("+LFM.timeFormat(_345.duration)+")</small>":"";
return _347+"<strong class=\"track\">"+_345.track.truncate(20)+"</strong>"+_348+"<br>"+_345.artist.truncate(25);
},buildTag:function(_349){
var icon="<img width=\"20\" height=\"20\" src=\""+LFM.Session.staticHost+"/flatness/icons/activity/tagged.png\">";
return icon+"<strong class=\"tag\">"+_349.tag.truncate(25)+"</strong>";
},processResults:function(_34b,list){
var list=new Element("ul");
if(_34b){
this.urls={};
var _34d=this.groupResults(_34b);
var _34e,_34f,_350,_351;
this.resTypeGroups.each(function(_352,_353){
if(_34d[_352]){
_34e=new Element("li");
_351=(_352==LFM.resTypes.USER)?LFM.String.resTypePlural["friends"]:LFM.String.resTypePlural[_352];
_34f=new Element("h3").update(_351).addClassName(LFM.resTypeLookup[_352].toLowerCase());
_350=new Element("ul");
_34d[_352].each(function(_354,_355){
this.addLinkedItem(_354,_350);
},this);
_34e.insert(_34f);
_34e.insert(_350);
list.insert(_34e);
}
},this);
}
this.addViewAll(list,_34b.length);
return list;
},groupResults:function(_356){
var _357={},_358;
_356.each(function(_359,_35a){
_358=_359.res?_359.res.type:_359.restype;
if(!_357[_358]){
_357[_358]=[];
}
_357[_358].push(_359);
},this);
return _357;
}})});
LFM.set("Ajax",{SideGroupedMulticompleter:Class.create(LFM.Ajax.GroupedMulticompleter,{init:function(){
this.update.addClassName("grouped sidegrouped");
},processResults:function(_35b,list){
var _35d=new Element("table",{cellspacing:0,cellpadding:0,border:0});
var _35e=new Element("tbody");
var _35f=0;
if(_35b){
this.urls={};
var _360=this.groupResults(_35b);
var _361,_362,_363,_364;
this.resTypeGroups.each(function(_365,_366){
if(_360[_365]){
_35f++;
_361=new Element("tr");
if(_35f%2==0){
_361.addClassName("alt");
}
_364=(_365==LFM.resTypes.USER)?LFM.String.resTypePlural["friends"]:LFM.String.resTypePlural[_365];
_362=new Element("h3").update(_364).addClassName(LFM.resTypeLookup[_365].toLowerCase());
_363=new Element("ul");
_360[_365].each(function(_367,_368){
this.addLinkedItem(_367,_363);
},this);
_361.insert(new Element("th").update(_362));
var _369=new Element("td").update(_363);
if(_35f==1){
_369.addClassName("first");
}
_361.insert(_369);
_35e.insert(_361);
}
},this);
}
var _36a=new Element("tr");
if(_35f%2==0){
_36a.addClassName("alt");
}
var _36b=new Element("ul");
this.addViewAll(_36b,_35b.length);
_36a.insert(new Element("th"));
_36a.insert(new Element("td",{"class":"viewAll"}).update(_36b));
_35e.insert(_36a);
_35d.update(_35e);
return _35d;
}})});


