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){
_1e0=$(_1e0)||document.body;
return _1e0.select("*[data-track-id]").collect(function(elem){
return elem.getAttribute("data-track-id");
});
}}});
LFM.set("Input",{RichText:Class.create({hasFocus:false,busy:false,wordSeparators:" \t\n,.()!?|=-\\",initialize:function(div,_1e3){
this.div=$(div);
this.options=_1e3?_1e3:{};
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 _1e7=e.charCode||e.keyCode||e.which;
var s=String.fromCharCode(_1e7);
this.cancelOnDown=false;
if(this.specialKeyDown(_1e7,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 _1eb;
if(s=="a"){
_1eb="<lfm:artist>"+name.strip().escapeHTML()+"</lfm:artist>";
}else{
if(s=="m"){
_1eb="<lfm:artist name=\""+name.strip().escapeHTML()+"\"><lfm:image size=\"small\" /></lfm:artist>";
}
}
this.replaceSelection(_1eb,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(_1f0,sel){
new Ajax.Request("/ajax/richtextrenderer",{method:"post",parameters:{richtext:_1f0},onComplete:function(resp){
var out=resp.responseText.evalJSON();
var _1f4=sel.getRangeAt(0);
$(document.body).insert({bottom:out.rendered});
var node=$(document.body).lastChild;
node.remove();
_1f4.deleteContents();
_1f4.insertNode(node);
this.textarea.value+=out.richtext;
}});
},keyPress:function(e){
e=window.event||e;
var _1f7=e.charCode||e.keyCode||e.which;
var s=String.fromCharCode(_1f7);
if(this.specialKeyPress(_1f7,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 _1fa=prev.parentNode;
var _1fb=prev.ownerDocument.createRange();
_1fb.setStartBefore(prev);
var _1fc=_1fb.createContextualFragment(s);
var n=_1fa.replaceChild(_1fc,prev);
var _1fb=this.caret.ownerDocument.createRange();
_1fb.setStartBefore(this.caret.previousSibling);
var _1fe=_1fb.createContextualFragment(" ");
_1fa.insertBefore(_1fe,this.caret.previousSibling);
}else{
this.caret.insert({before:s});
}
},_delete:function(prev){
var _200=false;
var _201=prev.previousSibling;
if(prev.nodeType==1){
if(prev.nodeName=="A"){
var _202=prev.firstChild;
prev.parentNode.replaceChild(_202,prev);
_202.unlinked=true;
var _203=this.textarea.selectionStart;
var tag="";
var i=_203-2;
while(i>=0&&(this.textarea.value.charAt(i)!="/")){
tag=this.textarea.value.charAt(i)+tag;
i--;
}
var _206=i;
var _207="<"+tag+">";
var _208=_207.length;
while(i>=0&&(this.textarea.value.substr(i,_208)!=_207)){
i--;
}
var _209=this.textarea.value.substr(0,i);
var _20a=i+_208;
_209+=this.textarea.value.substr(_20a,_206-_20a-1);
_209+=this.textarea.value.substr(_203);
this.textarea.value=_209;
return;
}
}
if(prev.nodeValue=="\n"){
_200=true;
}
var _20b=prev.parentNode;
if(prev.nodeType==3){
var _203=this.textarea.selectionStart;
var _209=this.textarea.value.substr(0,_203-1);
if(_203<this.textarea.value.length){
_209+=""+this.textarea.value.substr(_203);
}
this.textarea.value=_209;
if(this.textarea.createTextRange){
var _20c=this.textarea.createTextRange();
_20c.moveStart("character",_203-1);
_20c.moveEnd("character",_203-1);
_20c.select();
}else{
if(this.textarea.setSelectionRange){
this.textarea.setSelectionRange(_203-1,_203-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);
}
}
_20b.removeChild(prev);
if(_201&&_201.nodeType==3&&_201.nodeValue.strip().empty()&&_201.nodeValue!="\n"){
var _20d=_201.ownerDocument.createRange();
_20d.setStartAfter(_201);
var nbsp=_20d.createContextualFragment("&nbsp;");
_20b.replaceChild(nbsp,_201);
_201=nbsp;
}
if(_200){
var _201=prev.previousSibling;
_20b.removeChild(prev);
this.caret.previousSibling=_201;
this.caret.remove();
}
if(_201){
_20b.insertBefore(this.caret,_201.nextSibling);
}
},specialKeyDown:function(_20f,e){
if(_20f>=37&&_20f<=40&&!(e.ctrlKey||e.altKey||e.shiftKey||e.metaKey)){
var prev=this.caret.previousSibling;
var next=this.caret.nextSibling;
var _213=this.caret.parentNode;
if(_20f==37&&prev){
this.caret.remove();
_213.insertBefore(this.caret,prev);
var _214=this.textarea.selectionStart;
if(this.textarea.createTextRange){
var _215=this.textarea.createTextRange();
_215.moveStart("character",_214-1);
_215.moveEnd("character",_214-1);
_215.select();
}else{
if(this.textarea.setSelectionRange){
this.textarea.setSelectionRange(_214-1,_214-1);
}
}
}else{
if(_20f==39&&next){
this.caret.remove();
_213.insertBefore(this.caret,next.nextSibling);
var _214=this.textarea.selectionStart;
if(this.textarea.createTextRange){
var _215=this.textarea.createTextRange();
_215.moveStart("character",_214+1);
_215.moveEnd("character",_214+1);
_215.select();
}else{
if(this.textarea.setSelectionRange){
this.textarea.setSelectionRange(_214+1,_214+1);
}
}
}
}
this.textarea.focus();
return true;
}else{
if(_20f==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(_20f==8){
if(this.caret.previousSibling){
this._delete(this.caret.previousSibling);
}
return true;
}else{
if(_20f==13){
this.caret.insert({before:"<br />"});
this.textarea.value+="<br />";
return true;
}
}
}
}
},specialKeyPress:function(_216,e){
var s=String.fromCharCode(_216);
if(this.cancelOnDown){
return true;
}
if(this.wordSeparators.indexOf(s)>=0){
var _219=this.caret;
if(_219.previousSibling&&_219.previousSibling.nodeType==3&&!_219.previousSibling.unlinked){
var back=0;
var name="";
var _21c;
while((_219=_219.previousSibling)&&_219.nodeType==3&&_219.nodeValue.unescapeHTML().strip()!=""){
name=_219.nodeValue+name;
back++;
}
_21c=_219;
var _21d=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+)*)?/)){
_21d="<a href=\""+name.escapeHTML()+"\">"+name.escapeHTML()+"</a>";
}else{
var _21e=name.toUpperCase();
var _21f=this.artists.find(function(a){
return a.toUpperCase()==_21e;
});
if(_21f){
_21d="<lfm:artist>"+name.escapeHTML()+"</lfm:artist>";
}
}
if(_21d){
var _221=this.textarea.selectionStart;
new Ajax.Request("/ajax/richtextrenderer",{method:"post",parameters:{richtext:_21d},onComplete:function(resp){
var out=resp.responseText.evalJSON();
var _224=_21c.nextSibling;
for(;back>0;back--){
var tmp=_224.nextSibling;
_224.parentNode.removeChild(_224);
_224=tmp;
}
if(_21c){
var _226=_21c.ownerDocument.createRange();
_226.setStartAfter(_21c);
var _227=_226.createContextualFragment(out.rendered);
_21c.parentNode.insertBefore(_227,_21c.nextSibling);
}else{
this.div.insert({top:out.rendered});
}
var _228=this.textarea.value.substr(0,_221-name.length);
_228+=out.richtext;
_228+=""+this.textarea.value.substr(_221);
this.textarea.value=_228;
}.bind(this)});
}
}
}else{
if(s=="/"){
var _219=this.caret.previousSibling;
if(!_219||_219.nodeValue!="["){
return false;
}
var _229=_219;
var _22a="";
var tag="";
var back=2;
while((_219=_219.previousSibling)&&_219.nodeType==3&&_219.nodeValue!="]"){
_22a=_219.nodeValue+_22a;
back++;
}
while((_219=_219.previousSibling)&&_219.nodeType==3&&_219.nodeValue!="["){
tag=_219.nodeValue+tag;
back++;
}
if(tag=="artist"){
_22a=_22a.strip();
var _221=this.textarea.selectionStart;
var _21d="<lfm:artist>"+_22a.escapeHTML()+"</lfm:artist>";
new Ajax.Request("/ajax/richtextrenderer",{method:"post",parameters:{richtext:_21d},onComplete:function(resp){
var out=resp.responseText.evalJSON();
_219=_229;
for(var i=back;i>0;i--){
var tmp=_219.previousSibling;
_219.parentNode.removeChild(_219);
_219=tmp;
}
if(this.caret.previousSibling){
var rm=this.caret.previousSibling;
rm.parentNode.removeChild(rm);
}
this.caret.insert({before:out.rendered});
var _231=this.textarea.value.substr(0,_221-back-1);
_231+=""+out.richtext;
_231+=""+this.textarea.value.substr(_221);
this.textarea.value=_231;
}.bind(this)});
return true;
}
}
}
if(s==" "){
this.caret.insert({before:"&nbsp;"});
this.textarea.value+=" ";
return true;
}
},moveTextAreaCursorBy:function(n){
var _233=this.textarea.selectionStart;
if(this.textarea.createTextRange){
var _234=this.textarea.createTextRange();
_234.moveStart("character",_233+n);
_234.moveEnd("character",_233+n);
_234.select();
}else{
if(this.textarea.setSelectionRange){
this.textarea.setSelectionRange(_233+n,_233+n);
}
}
},focus:function(e){
Event.stop(e);
var _236=e.rangeParent;
if(this.caret.parentNode){
this.caret.remove();
}
if(_236!=this.caret&&_236!=this.div){
_236.parentNode.insertBefore(this.caret,_236.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(_237,_238,_239){
var _23a={method:"post",parameters:{track:_237.id,formtoken:LFM.Session.formtoken},onSuccess:_238,onFailure:_239};
new Ajax.Request(this.scrobbleURL,_23a);
},sendNowPlaying:function(_23b,_23c,_23d){
var _23e={method:"post",parameters:{track:_23b.id,formtoken:LFM.Session.formtoken},onSuccess:_23c,onFailure:_23d};
new Ajax.Request(this.nowPlayingURL,_23e);
},isScrobblable:function(_23f){
var _240=_23f.duration&&_23f.duration>this.minScrobbleDuration;
var _241=_23f.id;
return _240&&_241;
},getScrobblePoint:function(_242){
return Math.max(Math.round(_242.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(_246){
if(_246.responseText){
var _247=_246.responseText.evalJSON();
for(var i=0;i<_247.length;i++){
this.scrobbles.push(_247[i]);
}
}
this.isUpdating=false;
}).bind(this)});
},update:function(){
if(this.scrobbles.length<=1){
this.updateData();
}
if(this.scrobbles.length==0){
return;
}
var _249=this.scrobbles.shift();
var li=new Element("li",{"style":"display: none;"}).update(_249);
$(this.id).insert({"top":li});
new Effect.SlideDown(li,{duration:1});
}}));
var Scroller=Class.create({initialize:function(_24b){
this.scroller=$(_24b);
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 _24c=this.getVisibleWidth();
modulo=_24c%this.imageWidth;
_24c=_24c-modulo;
if(_24c>this.getWidth()){
_24c=this.getWidth();
}
Element.setStyle(this.scroller,{maxWidth:_24c+"px"});
var _24d=this.getWidth()*-1+Math.abs(this.getOffset())+this.getVisibleWidth();
var _24e=(this.getWidth()-this.getVisibleWidth())*-1;
this.setOffset(_24e);
this.refreshButtonStates();
},onResize:function(_24f){
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 _250=Element.getStyle(sampleImage,"border-left-width").replace("px","")*1;
if(!isNaN(_250)){
this.imageWidth=this.imageWidth+_250;
}
var _251=Element.getStyle(sampleImage,"border-right-width").replace("px","")*1;
if(!isNaN(_251)){
this.imageWidth=this.imageWidth+_251;
}
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(_252){
var blah=this.getWidth()-this.getVisibleWidth();
this.imageTrack.setStyle({left:_252+"px"});
},scrollLeft:function(_254){
if(!this.isScrolling&&this.getOffset()<0){
var _255=Math.abs(this.getOffset());
var _256=this.getVisibleWidth();
if(_256>_255){
_256=_255;
}
this.scroll(_256);
}
this.refreshButtonStates();
this.leftScrollButton.blur();
Event.stop(_254);
},scrollRight:function(_257){
if(!this.isScrolling&&(Math.abs(this.getOffset())+this.getVisibleWidth())<this.getWidth()){
var _258=this.getWidth()-(Math.abs(this.getOffset())+this.getVisibleWidth());
var _259=this.getVisibleWidth();
if(_259>_258){
_259=_258;
}
_259=_259*-1;
this.scroll(_259);
}
this.refreshButtonStates();
this.rightScrollButton.blur();
Event.stop(_257);
},scroll:function(_25a,_25b){
if(!this.isScrolling||_25b){
new Effect.Move(this.imageTrack,{x:_25a,y:0,mode:"relative",duration:0.5,afterFinish:this.afterScrolling.bind(this),beforeStart:this.beforeScrolling.bind(this),queue:{position:"end",scope:"scroller"}});
}
},beforeScrolling:function(_25c){
this.isScrolling=true;
this.totalDelta=this.totalDelta+_25c.options.x;
},afterScrolling:function(_25d){
this.isScrolling=false;
this.totalDelta=this.totalDelta-_25d.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 _25e=this.getSelectedImage().id;
if(_25e&&this.getImageWidth()){
_25e=(_25e.substring(5)*1)-1;
var _25f=_25e*this.getImageWidth();
_25f=_25f-this.getMiddle()+this.getImageWidth()/2;
if(_25f>(this.getWidth()-this.getVisibleWidth())){
_25f=this.getWidth()-this.getVisibleWidth();
}
_25f=_25f*-1;
if(_25f>0){
_25f=0;
}
Element.setStyle(this.imageTrack,{left:_25f+"px"});
this.refreshButtonStates();
}
}
}});
LFM.set("Resource",{Shoutbox:Class.create({initialize:function(_260){
this.shoutbox=_260;
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(_261){
_261.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 _265=new Ajax.Request(url,{method:"post",parameters:pars,onSuccess:this.addShout.bind(this)});
},addShout:function(_266){
if(this.shoutbox.restype==20){
LFM.Omniture.trackEvents("CommentPost");
}else{
LFM.Omniture.trackEvents("ShoutPost");
}
var _267=$("shoutList");
$("shoutList").insert({before:_266.responseText});
if(this.shoutbox.order=="asc"){
_267.innerHTML=_267.innerHTML+$("newShoutList").innerHTML;
}else{
_267.innerHTML=$("newShoutList").innerHTML+_267.innerHTML;
}
$("newShoutList").remove();
$("shoutList").select("li").each(function(li){
var _269=li.down(".delete");
if(_269){
_269.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(_26a){
_26a.stop();
var _26b=_26a.findElement("li");
var form=_26b.down("form");
var _26d=this.shoutbox.destination;
if(_26d.substr(-1)!="/"){
_26d+="/";
}
_26d+="delete";
form.action=_26d;
var _26e=this.shoutbox.restype;
var _26f=this.shoutbox.resid;
var _270=new LFM.Dialog({content:LFM.String.deleteMessagePrompt,confirmText:LFM.String.deleteButtonText,action:_26d,onConfirm:function(e){
e.stop();
this.hide();
form.request({parameters:{restype:_26e,resid:_26f,ajax:1},onSuccess:function(req){
if(req.responseText=="OK"){
new Effect.Fade(_26b,{duration:0.2});
}
}});
}});
_270.show();
},toggleInput:function(e){
if($("shoutPost").visible()){
$("shoutPost").hide();
}else{
$("shoutPostAgain").hide();
$("shoutPost").show();
this.textarea.focus();
}
e.stop();
},calculateCharCount:function(){
var _274=this.textarea.value.length;
this.updateCharLimit(_274);
this.updateCharCountDisplay(_274);
},updateCharCountDisplay:function(_275){
charCounter=$("sbCharCount");
var _276=this.shoutbox.charlimitMessage;
if(charCounter){
_276=_276.replace(/CURRENTCHARS/,_275);
_276=_276.replace(/MAXCHARS/,this.shoutbox.charlimit);
charCounter.innerHTML=_276;
}
},updateCharLimit:function(_277){
var _278=(_277>this.shoutbox.charlimit);
if(!this.overCharLimit&&_278){
$("sbCharCount").up().addClassName("overCharLimit");
$("sbPost").disable();
this.textarea.focus();
}
if(this.overCharLimit&&!_278){
$("sbCharCount").up().removeClassName("overCharLimit");
$("sbPost").enable();
}
this.overCharLimit=_278;
}})});
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(_279,_27a){
this.element=_279;
this.frameSize=_27a.frameSize||this.element.getHeight();
this.startFrame=_27a.startFrame||0;
this.endFrame=this.startFrame+_27a.length-1;
this.loop=_27a.loop||false;
this.positionX=_27a.positionX||0;
this.positionY=_27a.positionY||0;
this.axis=(_27a.axis||"y").toUpperCase();
this.fps=_27a.fps||1;
this.currentFrame=this.startFrame;
this.timer=null;
if(_27a.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(_27b){
this.currentFrame=_27b;
this["position"+this.axis]=this.currentFrame*(this.frameSize*-1);
var pos=this.positionX+"px "+this.positionY+"px";
this.element.setStyle({backgroundPosition:pos});
},play:function(_27d,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(_280,_281){
this.draggedRow=null;
this.rowWithBorderAndShit=null;
this.mouseOffset=null;
this.oldY=0;
this.dragged=false;
if(_281&&_281.dragHandle){
this.dragHandle=_281.dragHandle;
}else{
this.dragHandle=false;
}
this.table=$(_280);
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(_282){
if(this.dragged){
_282.stop();
this.dragged=false;
}
},getMouseOffset:function(_283,_284){
var _285=_283.cumulativeOffset();
return {x:_284.pointerX()-_285.left,y:_284.pointerY()-_285.top};
},onMouseDown:function(_286){
if(!_286.isLeftClick()){
return;
}
if(this.dragHandle&&!_286.element().hasClassName(this.dragHandle)){
return;
}
if((tag_name=_286.element().tagName.toUpperCase())&&(tag_name=="INPUT"||tag_name=="SELECT"||tag_name=="OPTION"||tag_name=="BUTTON"||tag_name=="TEXTAREA")){
return;
}
this.draggedRow=_286.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,_286);
_286.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(_287){
var y=_287.pointerY()-this.mouseOffset.y;
_287.stop();
if(y!=this.oldY){
var _289=y>this.oldY;
this.oldY=y;
var _28a=this.findDropTargetRow(y);
if(_28a){
this.dragged=true;
if(_289&&this.draggedRow!=_28a){
this.draggedRow.parentNode.insertBefore(this.draggedRow,_28a.nextSibling);
}else{
if(!_289&&this.draggedRow!=_28a){
this.draggedRow.parentNode.insertBefore(this.draggedRow,_28a);
}
}
}
}
},onMouseUp:function(_28b){
_28b.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 _28f=row.getHeight()/2;
if((y>rowY-_28f)&&(y<(rowY+_28f))){
return true;
}else{
return false;
}
});
return null;
}})});
LFM.set("Resource",{Users:Class.create({initialize:function(_290){
this.container=$("users");
this.container.observe("click",function(_291){
log("clicked container");
var _292=_291.element();
if(_292.match("a.delete img")){
_291.stop();
var _293=_292.up("li");
if(_293){
this.bin(_293);
}
}
}.bind(this));
},bin:function(_294){
var _295=new LFM.Dialog({resource:_294.getResource(),content:LFM.String.deleteFriendPrompt,confirmText:LFM.String.deleteButtonText,action:"friends/delete",onDone:function(_296){
var _297=_296.getResourceElement();
new Effect.Fade(_297,{duration:0.5});
},showDone:false});
_295.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(_299){
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,_29b){
Object.extend(this.options,_29b);
this._ajaxUrl=url;
if(this.options.lazyness){
this.options.laziness=this.options.lazyness;
}
},send:function(_29c){
if(this._intervalId){
clearTimeout(this._intervalId);
}
var now=new Date();
this._lastTime=now.getTime()/1000;
this._ajaxOptions=this._defaultAjaxOptions;
if(_29c){
if(_29c.parameters){
Object.extend(this._ajaxOptions.parameters,_29c.parameters);
_29c.paramaters=this._ajaxOptions.parameters;
}
Object.extend(this._ajaxOptions,_29c);
}
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(_29e){
try{
if(typeof _29e=="string"){
this.ajaxResponse=_29e.evalJSON();
}else{
if(_29e.responseText){
this.ajaxResponse=_29e.responseText.evalJSON();
}else{
this.ajaxResponse=_29e;
}
}
}
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,_2a1){
return this.data.set(key,_2a1);
},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 _2a3=this.getResource();
if(_2a3){
var link=new Element("a",{"href":_2a3.url});
if(_2a3.name){
link.update(_2a3.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,_2a6,_2a7){
new Ajax.Request("/ajax/setUserPref",{parameters:{formtoken:LFM.Session.formtoken,pref:pref,value:_2a6},onComplete:function(_2a8){
var _2a9=new LFM.Ajax.Response(_2a8);
if(_2a7){
_2a7(_2a9);
}
}});
};
LFM.Ajax.StatusHolder=Class.create({initialize:function(_2aa,_2ab){
this.status="idle";
this.element=$(_2aa);
this.options={position:"after"};
Object.extend(this.options,_2ab);
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(_2ac){
this.options=Object.extend({method:"get"},_2ac||{});
},buildItem:function(name){
return new Element("a",{href:"#"}).update(name).wrap(new Element("li"));
},onComplete:function(_2ae){
try{
var _2af=_2ae.responseText.evalJSON();
}
catch(err){
return false;
}
if(_2af&&_2af.response.docs){
var list=new Element("ul");
var _2b1=this.getToken();
list.insert(this.buildItem(_2b1));
_2af.response.docs.each(function(_2b2){
if(_2b2.name.toLowerCase()!=_2b1.toLowerCase()){
list.insert(this.buildItem(_2b2.name));
}
}.bind(this));
this.updateChoices(new Element("div").update(list).innerHTML);
}
}})});
LFM.set("Ajax",{Multicompleter:Class.create(LFM.Ajax.Autocompleter,{initialize:function(_2b3,_2b4,url,_2b6){
this.baseInitialize(_2b3,_2b4,_2b6);
this.url=url;
this.options.asynchronous=true;
this.options.onComplete=this.onComplete.bind(this);
this.options.onHide=function(_2b7,_2b8){
window.status="";
new Effect.Fade(_2b8,{duration:0.15});
};
this.form=this.element.up("form");
this.submit=this.form.down("input[type=submit]");
var _2b9={};
if(this.options.enabled){
_2b9["force"]=1;
}else{
this.show=function(){
return false;
};
this.startIndicator=function(){
return false;
};
}
if(LFM.Session.userName){
_2b9["username"]=LFM.Session.userName;
}
if(this.options.parameters){
_2b9=Object.extend(_2b9,this.options.parameters);
}
this.options.defaultParams=_2b9;
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 _2ba=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(_2bb){
if(!_2bb.length||!this.personalData){
return false;
}
var _2bc=new RegExp(_2bb.replace(/([\\\^\$*+[\]?{}.=!:(|)])/g,"\\$1"),"i");
var _2bd=[];
var _2be=this.personalData.get("friends");
if(_2be){
_2be.each(function(_2bf,i){
var _2c1=_2bf.name.match(_2bc)||(_2bf.realname&&_2bf.realname.match(_2bc));
if(_2c1){
_2bd.push(_2bf);
}
});
}
var _2c2=this.personalData.get("groups");
if(_2c2){
_2c2.each(function(_2c3,i){
var _2c5=_2c3.name.match(_2bc);
if(_2c5){
_2bd.push(_2c3);
}
});
}
var _2c6=this.personalData.get("labels");
if(_2c6){
_2c6.each(function(_2c7,i){
var _2c9=_2c7.name.match(_2bc)&&_2c7.single_artist!="t";
if(_2c9){
_2bd.push(_2c7);
}
});
}
return _2bd;
},buildEvent:function(_2ca){
var _2cb=_2ca.date.split("T");
var _2cc=_2cb[0].split("-");
var _2cd=_2ca.event||_2ca.artist;
var _2ce="<span class=\"calSheet calSheetSmall\">"+"<span title=\""+_2ca.date+"\">"+"<span class=\"month\">"+LFM.String.shortMonths[_2cc[1]-0]+"</span>"+"<span class=\"day\">"+(_2cc[2]-0)+"</span>"+"</span>"+"</span>";
var _2cf=_2ca["country_"+LFM.Session.language]||_2ca["country_en"];
return _2ce+"<strong>"+_2cd.truncate(25)+"</strong><br>"+_2ca.city.truncate(25)+", "+_2cf.truncate(25);
},buildEventTitle:function(_2d0){
var _2d1=_2d0.event||_2d0.artist;
var _2d2=_2d0["country_"+LFM.Session.language]||_2d0["country_en"];
return _2d1+", "+_2d0.venue+", "+_2d0.city+", "+_2d2;
},buildEventURL:function(_2d3){
return "/event/"+encodeURIComponent(encodeURIComponent(_2d3.resid));
},buildArtist:function(_2d4){
var _2d5=this.buildArtistImageURL(_2d4);
var _2d6="<img src=\""+_2d5+"\" width=\"34\" height=\"34\">";
return _2d6+this.buildName(_2d4.artist);
},buildArtistTitle:function(_2d7){
return _2d7.artist;
},buildArtistURL:function(_2d8){
return "/music/"+encodeURIComponent(encodeURIComponent(_2d8.artist));
},buildArtistImageURL:function(_2d9){
if(_2d9.image){
return LFM.Session.userserveHost+"/serve/34s/"+_2d9.image;
}else{
var _2da={api_key:LFM.Session.wsKey,artist:_2d9.artist,method:"artist.getImageRedirect",size:"smallsquare"};
return "http://"+LFM.Session.wsHost+"/2.0/?"+Object.toQueryString(_2da);
}
},buildAlbum:function(_2db){
var _2dc=this.buildAlbumImageURL(_2db);
var _2dd="<span class=\"albumCover coverSmall\" />"+"<span class=\"art\"><img src=\""+_2dc+"\" width=\"34\" height=\"34\"></span>"+"<span class=\"jewelcase\"></span>"+"</span>";
return _2dd+this.buildName(_2db.album)+"<br>"+_2db.artist.truncate(25);
},buildAlbumTitle:function(_2de){
return _2de.album+" - "+_2de.artist;
},buildAlbumURL:function(_2df){
return "/music/"+encodeURIComponent(encodeURIComponent(_2df.artist))+"/"+encodeURIComponent(encodeURIComponent(_2df.album));
},buildAlbumImageURL:function(_2e0){
if(_2e0.image){
return LFM.Session.userserveHost+"/serve/34s/"+_2e0.image;
}else{
var _2e1={api_key:LFM.Session.wsKey,artist:_2e0.artist,album:_2e0.album,method:"album.getImageRedirect",size:"smallsquare"};
return "http://"+LFM.Session.wsHost+"/2.0/?"+Object.toQueryString(_2e1);
}
},buildTrack:function(_2e2){
var _2e3=this.buildArtistImageURL(_2e2);
var _2e4="<img src=\""+_2e3+"\" width=\"34\" height=\"34\">";
var _2e5=_2e2.duration?" <small> ("+LFM.timeFormat(_2e2.duration)+")</small>":"";
return _2e4+this.buildName(_2e2.track)+_2e5+"<br>"+_2e2.artist.truncate(25);
},buildTrackTitle:function(_2e6){
return _2e6.track+" - "+_2e6.artist;
},buildTrackURL:function(_2e7){
return "/music/"+encodeURIComponent(encodeURIComponent(_2e7.artist))+"/_/"+encodeURIComponent(encodeURIComponent(_2e7.track));
},buildTag:function(_2e8){
var icon="<img width=\"30\" height=\"30\" src=\""+LFM.Session.staticHost+"/flatness/icons/tag/1/tag_30.png\">";
return icon+this.buildName(_2e8.tag);
},buildTagTitle:function(_2ea){
return _2ea.tag;
},buildTagURL:function(_2eb){
return "/tag/"+encodeURIComponent(encodeURIComponent(_2eb.tag));
},buildUser:function(_2ec){
var _2ed=this.buildResImage(_2ec,"/flatness/catalogue/noimage/2/default_user_small.png");
var user=_2ed+this.buildName(_2ec.name);
if(_2ec.realname){
user+="<br>"+_2ec.realname.truncate(25);
}
return user;
},buildUserTitle:function(_2ef){
var _2f0=_2ef.name;
if(_2ef.realname){
_2f0+=" - "+_2ef.realname;
}
return _2f0;
},buildUserURL:function(_2f1){
return "/user/"+encodeURIComponent(encodeURIComponent(_2f1.name));
},buildGroup:function(_2f2){
var _2f3=this.buildResImage(_2f2,"/flatness/catalogue/noimage/2/default_group_small.png");
var name;
if(_2f2.group){
name=this.buildName(_2f2.group);
}else{
name=this.buildName(_2f2.name);
}
return _2f3+name;
},buildGroupTitle:function(_2f5){
return _2f5.name||_2f5.group;
},buildGroupURL:function(_2f6){
var name=_2f6.name||_2f6.group;
return "/group/"+encodeURIComponent(encodeURIComponent(name));
},buildLabel:function(_2f8){
var _2f9=this.buildResImage(_2f8,"/flatness/catalogue/noimage/2/default_label_small.png");
var name;
if(_2f8.label){
name=this.buildName(_2f8.label);
}else{
name=this.buildName(_2f8.name);
}
return _2f9+name;
},buildLabelTitle:function(_2fb){
return _2fb.name||_2fb.label;
},buildLabelURL:function(_2fc){
var root;
var name=_2fc.name||_2fc.label;
if(_2fc.single_artist=="t"){
root="/artist/";
}else{
root="/label/";
}
return root+encodeURIComponent(encodeURIComponent(name));
},buildName:function(name){
return "<strong>"+name.truncate(25)+"</strong>";
},buildResTitle:function(_300){
return _300.name;
},buildResImage:function(_301,_302){
var _303=LFM.Session.staticHost+_302;
if(_301.image_id){
_303=LFM.Session.userserveHost+"/serve/34s/"+_301.image_id+".jpg";
}else{
if(_301.image){
_303=LFM.Session.userserveHost+"/serve/34s/"+_301.image;
}
}
var _304="<img src=\""+_303+"\" width=\"34\" height=\"34\">";
return _304;
},buildItemLink:function(_305){
var _306=_305.res?_305.res.type:_305.restype;
var _307=LFM.resTypeLookup[_306];
if(!_307){
LFM.warn("no restype found: "+_306);
}else{
try{
var url=this["build"+_307+"URL"](_305);
if(!this.urls[url]){
this.urls[url]=_307;
var item=this["build"+_307](_305);
var _30a=this["build"+_307+"Title"](_305);
var link=new Element("a",{href:url+"?ac="+encodeURIComponent(this.getToken()),title:_30a}).addClassName(_307.toLowerCase()+"Item").update(item);
return link;
}
}
catch(e){
LFM.warn(_307,e);
}
}
},buildSearchLink:function(_30c){
var _30d=this.form.action+"?"+this.form.serialize();
var link=new Element("a",{href:_30d}).addClassName("viewAll");
return new Element("span").addClassName("moduleOptions").update(_30c).wrap(link);
},setOptions:function(_30f){
_30f=_30f||{};
this.options=Object.extend({method:"get",onShow:function(_310,_311){
if(!_311.style.position||_311.style.position=="absolute"){
_311.style.position="absolute";
Position.clone(_310,_311,{setHeight:false,setWidth:false,offsetTop:_310.offsetHeight});
}
Effect.Appear(_311,{duration:0.15});
}},_30f);
},markNext:function(){
if(this.index===null){
this.index=0;
}else{
if(this.index<this.entryCount-1){
this.index++;
}
}
var _312=this.getCurrentEntry();
if(_312){
window.status=_312.down("a").href;
}else{
window.status="";
}
},markPrevious:function(){
if(this.index>0){
this.index--;
}else{
this.index=null;
}
var _313=this.getCurrentEntry();
if(_313){
window.status=_313.down("a").href;
}else{
window.status="";
}
},getEntry:function(_314){
if(_314!==null){
return this.update.down("li.item",_314);
}
},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(_317,list){
var link;
var _31a=_317.res?_317.res.type:_317.restype;
if(_31a){
link=this.buildItemLink(_317);
}else{
link=this.buildSearchLink(_317);
}
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(_31e){
response=new LFM.Ajax.Response(_31e);
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 _325=this.getToken();
if(_325.length>=this.options.minChars&&_325!=this.lastToken){
this.startIndicator();
}
},onSubmit:function(e){
var _327=this.form.serialize().toQueryParams();
var _328=this.getToken();
LFM.Omniture.prepareEvar("SearchLength",_328.length);
if(this.options.enabled){
LFM.Omniture.prepareEvar("SearchType","multicomplete");
}else{
if(_327.m){
LFM.Omniture.prepareEvar("SearchType",_327.m);
}
}
LFM.Omniture.prepareEvar("HeaderSearchAction","Search");
LFM.Omniture.trackEvents("HeaderSearch");
},onObserverEvent:function(){
this.changed=false;
var _329=this.getToken();
if(_329.length>=this.options.minChars){
if(_329!=this.lastToken&&_329!=this.element.getAttribute("placeholder")){
this.getUpdatedChoices();
}else{
this.render();
}
}else{
this.active=false;
this.hide();
}
this.lastToken=_329;
this.oldElementValue=this.element.value;
},getToken:function(){
return $F(this.element);
},processResults:function(_32a){
var list=new Element("ul");
if(_32a){
this.urls={};
_32a.each(function(_32c,_32d){
this.addLinkedItem(_32c,list);
},this);
}
this.addViewAll(list,_32a.length);
return list;
},addViewAll:function(list,_32f){
this.addLinkedItem(LFM.String.siteSearchViewAll.replace("QUERY",this.getToken().escapeHTML()),list);
this.entryCount=_32f+1;
},onComplete:function(_330){
if(this.changed||!this.hasFocus){
return false;
}
var _331=new Array,_332=0;
try{
var _333=_330.responseText.evalJSON();
_331=_333.response.docs;
}
catch(err){
LFM.warn("JSON error: "+_330.responseText);
}
if(this.personalMatches&&this.personalMatches.length){
var _334=Math.min(this.personalMatches.length,3);
_331=this.personalMatches.slice(0,_334).concat(_331.slice(0,10-_334));
}
_332=_331.length;
var list=this.processResults(_331);
this.updateChoices(list,_332);
},updateChoices:function(list,_337){
this.update.update(list);
var _338=new Element("p",{"class":"header"});
if(_337){
_338.update(LFM.String.siteSearchSuggestions);
}else{
_338.update(LFM.String.siteSearchNoSuggestions).addClassName("empty");
}
this.update.insert({"top":_338});
if(LFM.Session.loggedIn&&!this.personalData){
var _339=new Element("div").addClassName("message messageWarn").update(LFM.String.autocompletePersonalDataDown);
this.update.insert({"bottom":_339});
}
this.update.select("li.item a").each(function(link,_33b){
link.autocompleteIndex=_33b;
},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(_33c){
var _33d=this.buildArtistImageURL(_33c);
var _33e="<span class=\"img\"><span><img src=\""+_33d+"\" width=\"34\" height=\"34\" /></span></span>";
return _33e+"<strong class=\"artist\">"+_33c.artist.truncate(25)+"</strong>";
},buildTrack:function(_33f){
var _340=this.buildArtistImageURL(_33f);
var _341="<span class=\"img\"><span><img src=\""+_340+"\" width=\"34\" height=\"34\" /></span></span>";
var _342=_33f.duration?" <small class=\"time\"> ("+LFM.timeFormat(_33f.duration)+")</small>":"";
return _341+"<strong class=\"track\">"+_33f.track.truncate(20)+"</strong>"+_342+"<br>"+_33f.artist.truncate(25);
},buildTag:function(_343){
var icon="<img width=\"20\" height=\"20\" src=\""+LFM.Session.staticHost+"/flatness/icons/activity/tagged.png\">";
return icon+"<strong class=\"tag\">"+_343.tag.truncate(25)+"</strong>";
},processResults:function(_345,list){
var list=new Element("ul");
if(_345){
this.urls={};
var _347=this.groupResults(_345);
var _348,_349,_34a,_34b;
this.resTypeGroups.each(function(_34c,_34d){
if(_347[_34c]){
_348=new Element("li");
_34b=(_34c==LFM.resTypes.USER)?LFM.String.resTypePlural["friends"]:LFM.String.resTypePlural[_34c];
_349=new Element("h3").update(_34b).addClassName(LFM.resTypeLookup[_34c].toLowerCase());
_34a=new Element("ul");
_347[_34c].each(function(_34e,_34f){
this.addLinkedItem(_34e,_34a);
},this);
_348.insert(_349);
_348.insert(_34a);
list.insert(_348);
}
},this);
}
this.addViewAll(list,_345.length);
return list;
},groupResults:function(_350){
var _351={},_352;
_350.each(function(_353,_354){
_352=_353.res?_353.res.type:_353.restype;
if(!_351[_352]){
_351[_352]=[];
}
_351[_352].push(_353);
},this);
return _351;
}})});
LFM.set("Ajax",{SideGroupedMulticompleter:Class.create(LFM.Ajax.GroupedMulticompleter,{init:function(){
this.update.addClassName("grouped sidegrouped");
},processResults:function(_355,list){
var _357=new Element("table",{cellspacing:0,cellpadding:0,border:0});
var _358=new Element("tbody");
var _359=0;
if(_355){
this.urls={};
var _35a=this.groupResults(_355);
var _35b,_35c,_35d,_35e;
this.resTypeGroups.each(function(_35f,_360){
if(_35a[_35f]){
_359++;
_35b=new Element("tr");
if(_359%2==0){
_35b.addClassName("alt");
}
_35e=(_35f==LFM.resTypes.USER)?LFM.String.resTypePlural["friends"]:LFM.String.resTypePlural[_35f];
_35c=new Element("h3").update(_35e).addClassName(LFM.resTypeLookup[_35f].toLowerCase());
_35d=new Element("ul");
_35a[_35f].each(function(_361,_362){
this.addLinkedItem(_361,_35d);
},this);
_35b.insert(new Element("th").update(_35c));
var _363=new Element("td").update(_35d);
if(_359==1){
_363.addClassName("first");
}
_35b.insert(_363);
_358.insert(_35b);
}
},this);
}
var _364=new Element("tr");
if(_359%2==0){
_364.addClassName("alt");
}
var _365=new Element("ul");
this.addViewAll(_365,_355.length);
_364.insert(new Element("th"));
_364.insert(new Element("td",{"class":"viewAll"}).update(_365));
_358.insert(_364);
_357.update(_358);
return _357;
}})});


