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&&_13){
var _18=new Element("img",{src:_12,width:88,height:31}).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(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;
document.stopObserving("click",this.clickOffObserver);
},updateMenuFromAjax:function(_3f){
var _3f=_3f;
if(this.loadedInfo.get(_3f.href)){
_3f.className=this.loadedInfo.get(_3f.href);
this.sortOutClassNames(_3f);
this.showMenu(_3f);
}else{
var _40=new Ajax.Request("/ajax/library/gettrackinfo",{parameters:{url:_3f.href,cachebuster:Math.round(Math.random()*100)},method:"get",onComplete:function(_41){
var _42=new LFM.Ajax.Response(_41);
if(_42.isSuccess()){
if(_42.get("loved")){
_3f.removeClassName("mLove");
_3f.addClassName("mUnlove");
}else{
_3f.addClassName("mLove");
_3f.removeClassName("mUnlove");
}
if(_42.get("banned")){
_3f.removeClassName("mBan");
_3f.addClassName("mUnban");
}else{
if(_3f.hasClassName("lfmMultiButtonAllowBan")){
_3f.addClassName("mBan");
}
_3f.removeClassName("mUnban");
}
if(_3f.hasClassName("lfmMultiButtonFull")){
if(_42.get("playcount")!==null){
_3f.addClassName("mRemoveFromLibrary");
_3f.removeClassName("mAddToLibrary");
}else{
_3f.removeClassName("mRemoveFromLibrary");
_3f.addClassName("mAddToLibrary");
}
}
this.loadedInfo.set(_3f.href,_3f.className);
}
if(_3f==this.activeButton&&!_40.shown){
this.sortOutClassNames(_3f);
this.showMenu(_3f);
}
}.bind(this)});
(function checkTimeout(){
if(!(_40&&_40.getStatus()==200)&&_3f==this.activeButton){
_40.shown=true;
this.sortOutClassNames(_3f);
this.showMenu(_3f);
}
}).bind(this).delay(0.5);
}
},showMenu:function(_43,_44){
var _44=_44||{};
var _45=_43.cumulativeOffset();
var _46=$("page").cumulativeOffset();
_45.left=_45.left-7-_46.left;
_45.top=_45.top+_43.getHeight()-_46.top;
var _47=this.activeButton.getWidth();
if(Prototype.Browser.IE){
if(window.external&&typeof window.XMLHttpRequest=="undefined"){
_45.left=_45.left-35;
}else{
if(_43.hasClassName("lfmSmallMultiButton")&&_43.up("div.module")){
_45.left=_45.left-15;
}
}
}
this.menu.setStyle({top:_45.top+"px",left:_45.left+"px"});
var _48=this.menu.down("ul");
_47=_47-_48.getStyle("border-left-width").toPixels()-_48.getStyle("border-right-width").toPixels()-_48.getStyle("padding-left").toPixels()-_48.getStyle("padding-right").toPixels();
_48.setStyle({minWidth:_47+"px"});
$w("tr li").each(function(_49){
var _4a=_43.up(_49);
if(_4a){
_4a.addClassName("open");
}
});
var _4b=_44.showLoadingState?"mLoading":false;
this.sortOutClassNames(_43,_4b);
this.menu.show();
},hideMenu:function(_4c){
$w("tr li").each(function(_4d){
var _4e=_4c.up(_4d);
if(_4e){
_4e.removeClassName("open");
}
});
this.menu.down("ul").setStyle({minWidth:"0px"});
this.menu.hide();
},sortOutClassNames:function(_4f,_50){
if(_50){
this.menu.className=_50;
this.menu.down("div").className=_50;
}else{
var _51=_4f.className.match(/\blfmButtonFor([a-z]*)\b/)[1];
_51+="MultiMenu";
this.menu.className=_51;
var _52=_4f.className;
this.menu.down("div").className=_52;
}
},observeMenu:function(e){
e.stop();
var _54=this.activeButton.hasClassName("lfmBigMultiButton")?"moreBtn":"multiBtn";
LFM.Omniture.prepareEvar("ClickSource",_54);
var _55=e.findElement("li").className;
if(Prototype.Browser.IE){
_55=_55.replace(/\b\w*hover_/gi,"").strip();
}
switch(_55){
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(_56){
var _57=LFM.get("Page","LibraryDeleteListener");
var _58=LFM.get("Page","LibraryRemoveTagFromItemListener");
if(_57){
_57.onDone(_56);
}
if(_58){
_58.onSuccess(_56);
}
}});
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(_59,_5a){
var _5b=this.activeButton;
new Ajax.Request("/ajax/library/love",{parameters:{ajax:true,url:_5b.href,loved:_5a,formtoken:LFM.Session.formtoken},onSuccess:function(_5c){
var _5d=new LFM.Ajax.Response(_5c);
if(_5d.isSuccess()){
var _5e=_5b.up("tr");
var _5f=_5b.up("li");
if(_5e){
if(_5e.hasClassName("odd")&&_5e.up("table").hasClassName("chart")){
var _60="#f4f4f4";
}else{
var _60="#ffffff";
}
}
if((!this.parentIsUser||this.parentIsLoggedInUser)&&_5e){
var _61=_5e.down("td.lovedCell");
}else{
if(LFM.ParentResource&&LFM.ParentResource.type==9&&$("lovedIndicator")){
if(_5a){
if(LFM.Page.onAddToLibrary){
LFM.Page.onAddToLibrary(_5d);
}
$("lovedIndicator").show();
}else{
$("lovedIndicator").hide();
}
}
}
this.loadedInfo.unset(_5b.href);
if(_5a){
LFM.Omniture.trackEvents("LoveTrack");
_5b.removeClassName("mLove");
_5b.addClassName("mUnlove");
if(_61){
_61.insert({top:LFM.Element.icon_loved_indicator});
}
if(_5f){
_5f.addClassName("loved");
}
var _62=_5d.get("activity");
if(_62){
var _63=LFM.Activity.buildFeedItem(_62);
if(LFM.Adserver.showAds&&LFM.Session.location=="us"){
var _64=LFM.Adserver.getATTNotificationBranding();
}
var _65=new Element("div");
_65.insert(_64);
_65.insert(_63);
LFM.Notification.send(_65);
}
}else{
_5b.addClassName("mLove");
_5b.removeClassName("mUnlove");
if(_61){
var _66=_61.down("img.loved_indicator_icon");
if(_66){
_66.remove();
}
}
if(_5f){
_5f.removeClassName("loved");
}
}
if(_61){
new Effect.Highlight(_5e,{endcolor:_60,afterFinish:function(_67){
_67.element.removeAttribute("style");
}});
}
}
}.bind(this)});
},ban:function(_68,_69){
var _6a=this.activeButton;
new Ajax.Request("/ajax/library/ban",{parameters:{ajax:true,url:_6a.href,banned:_69,formtoken:LFM.Session.formtoken},onSuccess:function(_6b){
var _6c=new LFM.Ajax.Response(_6b);
if(_6c.isSuccess()){
var _6d=_6a.up("tr");
if(_6d){
if(_6d.hasClassName("odd")&&_6d.up("table").hasClassName("chart")){
var _6e="#f4f4f4";
}else{
var _6e="#ffffff";
}
}
if(LFM.ParentResource){
if(this.parentIsLoggedInUser&&_6d){
var _6f=_6d.down("td.bannedCell");
}else{
if(LFM.ParentResource.type==9&&$("bannedIndicator")){
if(_69){
$("bannedIndicator").show();
}else{
$("bannedIndicator").hide();
}
}
}
}
this.loadedInfo.unset(_6a.href);
if(_69){
if(_6f){
_6f.insert({top:LFM.Element.icon_banned_indicator});
}
}else{
if(_6f){
var _70=_6f.down("img.banned_indicator_icon");
if(_70){
_70.remove();
}
}
}
if(_6d){
new Effect.Fade(_6d,{duration:0.5});
}
}
}.bind(this)});
}},affiliations:{"suppliers[]":[],"restypes[]":[],"resids[]":[]},pushAffiliation:function(_71,_72,_73){
LFM.Button.affiliations["suppliers[]"].push(_71);
LFM.Button.affiliations["restypes[]"].push(_72);
LFM.Button.affiliations["resids[]"].push(_73);
}});
LFM.set("Charts",{Switch:Class.create({initialize:function(_74,_75){
this.container=$(_74);
this.parameters=_75;
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(_76){
var _77=this.getRangeTypeFromClassName(_76.className);
if(_77){
this.cachedcharts.set(_77,_76);
}
}.bind(this));
},switchChartEvent:function(_78){
var _79=_78.element();
if(!_79.match("a")){
return;
}
_78.stop();
var _7a=_79.up("li");
if(_7a.hasClassName("current")){
return;
}
this.container.down("div.horizontalOptions ul").childElements().invoke("removeClassName","current");
_7a.addClassName("current");
var _7b=this.getRangeTypeFromClassName(_7a.className);
this.switchChart(_7b);
},refresh:function(){
this.cachedcharts=new Hash();
this.switchChart();
},switchChart:function(_7c){
if(_7c&&this.cachedcharts.get(_7c)){
this.cachedcharts.each(function(_7d){
_7d.value.hide();
});
this.cachedcharts.get(_7c).show();
if(this.morelink){
this.morelink.href=this.container.down("ul li.chart"+_7c+" a").href;
}
}else{
var _7e=Object.extend(this.parameters,{rangetype:_7c,ajax:1,cachebuster:Math.round(Math.random()*100)});
new Ajax.Request("/module",{method:"get",parameters:_7e,onComplete:function(t){
var _80=new LFM.Ajax.Response(t);
if(_80.isSuccess()){
this.container.insert({bottom:_80.get("content").strip()});
var _81=!_7c;
var _82=this.container.childElements().last();
ieHover.add(_82);
if(!_7c){
_7c=this.getRangeTypeFromClassName(_82.className);
this.container.down("div.horizontalOptions ul").childElements().invoke("removeClassName","current");
this.container.down("div.horizontalOptions ul li.chart"+_7c).addClassName("current");
}
this.cachedcharts.set(_7c,_82);
if(this.morelink){
this.morelink.up().insert({before:this.cachedcharts.get(_7c)});
}
if(_81){
this.container.select("div.chart").each(function(_83){
if(_83!=_82){
_83.remove();
}
}.bind(this));
}
this.cachedcharts.each(function(_84){
if(_84.key!=_7c){
_84.value.hide();
}
});
this.cachedcharts.get(_7c).show();
if(this.morelink){
this.morelink.href=this.container.down("ul li.chart"+_7c+" 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(_85){
var _86=_85.match(/chart[^ ]+/)[0];
return _86.substr(5);
}})});
CopyProtection=Class.create({initialize:function(){
document.observe("keydown",this.cancelKeyDown);
document.observe("contextmenu",this.cancelContextMenu);
document.observe("mousedown",this.disableSelect);
document.observe("mouseup",this.enableSelect);
},cancelKeyDown:function(key){
var _88=new Array("a","u","c","x","v","j");
if(key.ctrlKey||key.metaKey){
for(i=0;i<_88.length;i++){
var _89=key.keyCode;
if(_88[i].toLowerCase()==String.fromCharCode(_89).toLowerCase()){
key.stop();
return false;
}
}
}
},cancelContextMenu:function(e){
e.stop();
return false;
},disableSelect:function(e){
var _8c=new Array("input","select","textarea","radio","checkbox");
var _8d=false;
for(var i=0;i<_8c.length;i++){
if(e.target.tagName.toLowerCase()==_8c[i]){
_8d=true;
}
}
if(!_8d){
e.stop();
return false;
}
},enableSelect:function(e){
return true;
}});
LFM.set("Display",{candyStripe:function(_90,_91){
var _91=_91||false;
if(is_array(_90)){
var _92=_90;
}else{
_90=$(_90);
if(_91.selector){
var _92=_90.select(_91.selector);
}else{
if(_90.tagName=="TABLE"){
_90=_90.down("tbody");
}
var _92=_90.childElements();
}
}
if(_92.length>0){
_92[0].up("table").addClassName("candyStriped");
_92.each(function(row,i){
if(i%2){
row.removeClassName("odd");
}else{
row.addClassName("odd");
}
row.removeClassName("first");
row.removeClassName("last");
if(_91.renumber){
var _95=row.down("td.position");
if(_95){
_95.update(i+1);
}
}
});
_92.first().addClassName("first");
_92.last().addClassName("last");
}
}});
document.observe("dom:loaded",function(_96){
$$(".downloadDriver").each(function(_97){
_97.observe("click",function(e){
var el=e.findElement("a");
if(el&&el.match("a")){
var _9a=LFM.get("Page","hasManualAdded");
var _9b="New user download CTA ("+(_9a?"after":"before")+" library add)";
LFM.Omniture.setLink(el,_9b);
LFM.Omniture.prepareEvar("ClickSource",_9a?"downloadAfterManualAdd":"downloadBeforeManualAdd");
LFM.Omniture.trackEvents();
}
});
});
});
LFM.set("Display",{DropDown:Class.create({initialize:function(_9c,_9d,_9e,_9f){
this.container=$(_9c);
this.toggler=$(_9d);
this.ddbody=$(_9e);
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=_9f||{};
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 _a0=this.container.cumulativeOffset();
var _a1=$("page").cumulativeOffset();
_a0.left=_a0.left-_a1.left;
_a0.top=_a0.top+this.container.getHeight()-_a1.top;
if(Prototype.Browser.IE&&this.container.getStyle("display")=="inline-block"){
var _a2=this.toggler.getWidth();
}else{
var _a2=this.container.getWidth();
}
var _a3=$("page").getWidth();
if((this.options.align&&this.options.align=="right")||((_a0.left+this.ddbody.getWidth())>_a3)){
var _a4=(_a3-_a2-_a0.left)+"px";
var _a5="auto";
}else{
var _a5=_a0.left+"px";
var _a4="auto";
if(Prototype.Browser.IE){
if(window.external&&typeof window.XMLHttpRequest=="undefined"){
_a5=(_a0.left-35)+"px";
}
}
}
if(!this.options.autoWidth){
_a2=_a2-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:_a2+"px"});
if(this.use_iframe){
this.iframe.setStyle({minWidth:_a2+"px"});
}
}
this.ddbody.setStyle({top:_a0.top+"px",left:_a5,right:_a4}).show();
var _a6=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(_a8){
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(_a8.findElement("A")){
_a8.findElement("A").blur();
}
_a8.stop();
},clickOff:function(_a9){
var _aa=Event.element(_a9);
var _ab=false;
while(_aa.parentNode){
if(_aa==this.ddbody){
return true;
}else{
if(_aa==this.toggler){
_ab=true;
}
}
_aa=_aa.parentNode;
}
this.hide();
if(_ab){
_a9.stop();
}
},trackItemClick:function(e){
var _ad=e.findElement("a");
if(_ad){
var _ae=_ad.className;
var _af=this.container.identify();
var _b0=_ad.up("li");
if(_b0){
_ae=_b0.className;
}
LFM.Omniture.setLink(_ad,_af+":"+_ae);
LFM.Omniture.prepareEvar("ClickSource",_af);
LFM.Omniture.trackEvents("Click");
}
}})});
var EventCalendar={calendars:null,currentMonth:null,lastRequested:null,next:function(url,_b2,_b3){
_b2.blur();
Element.addClassName(_b2,"busy");
var c=EventCalendar.getCurrentMonth();
var _b5=_b3?EventCalendar.getMonthForTable(c):EventCalendar.getNextMonthAfterTable(c);
var _b6=null;
var _b7=null;
if(!_b3){
_b7=document.getElementsByClassName("month-"+_b5,$("calendar"));
_b6=_b7.length>0?_b7[0]:false;
}else{
var m=EventCalendar.getPrevMonthAfterTable(c);
_b7=document.getElementsByClassName("month-"+m,$("calendar"));
_b6=_b7.length>0?_b7[0]:false;
}
if(_b6){
c.style.display="none";
_b6.style.display="table";
EventCalendar.currentMonth=_b6;
Element.removeClassName(_b2,"busy");
}else{
if(_b6==-1){
Element.removeClassName(_b2,"busy");
}else{
url=EventCalendar.convertURL(url);
EventCalendar.lastRequested=_b5;
var _b9=new Ajax.Request(url+"&startdate="+_b5+"-01",{onSuccess:EventCalendar.receiveMonth.bind(_b2),onFailure:EventCalendar.receiveMonthFailed.bind(_b2)});
}
}
},prev:function(url,_bb){
EventCalendar.next(url,_bb,true);
},convertURL:function(url){
url=url.replace(/^\/events/,"");
return "/events/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("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");
},colourToggle:function(_eb){
_eb=$(_eb);
$(document.body).toggleClassName("lfmBlack");
_eb.blur();
var _ec,_ed;
if($(document.body).hasClassName("lfmBlack")){
_ec="red";
_ed="black";
_eb.update(LFM.String.toRedStr);
}else{
_ec="black";
_ed="red";
_eb.update(LFM.String.toBlackStr);
}
LFM.setCookie("LFM_Colour",_ed);
LFM.Omniture.prepareEvar("ClickSource","colorToggle:"+_ed);
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(_ee){
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 _f0=$("secondaryNavigation");
if(_f0){
var _f1=_f0.getHeight()-2;
var _f2=$("content");
if(_f2&&_f2.getHeight()<_f1){
var _f3=$$("#content > .rightCol");
_f3=_f3[0]||_f2;
if(_f3.match(".rightCol")){
_f2.setStyle("min-height: 0");
}
_f1-=_f3.getStyle("padding-top").toPixels(_f3);
_f1-=_f3.getStyle("padding-bottom").toPixels(_f3);
_f3.setStyle({minHeight:(_f1>300?_f1:300)+"px"});
}
}
});
}});
if(LFM&&LFM.get("config","DEVELOPMENT_SERVER")){
LFM.set("Timers",{});
}
function startTimer(_f4){
if(LFM&&LFM.get("config","DEVELOPMENT_SERVER")){
LFM.Timers[_f4]={};
LFM.Timers[_f4].startTime=new Date();
LFM.Timers[_f4].startTime=LFM.Timers[_f4].startTime.getTime();
}
}
function stopTimer(_f5){
if(LFM&&LFM.get("config","DEVELOPMENT_SERVER")){
if(LFM.Timers[_f5]){
LFM.Timers[_f5].endTime=new Date();
LFM.Timers[_f5].endTime=LFM.Timers[_f5].endTime.getTime();
log(LFM.Timers[_f5].endTime-LFM.Timers[_f5].startTime);
}else{
log("Timer "+_f5+" doesn\u2019t exist.");
}
}
}
function loadStyleSheet(_f6){
if(isset(document.createStyleSheet)){
document.createStyleSheet(_f6);
}else{
var _f7=document.createElement("link");
_f7.setAttribute("rel","stylesheet");
_f7.setAttribute("type","text/css");
_f7.setAttribute("href",_f6);
document.getElementsByTagName("head")[0].appendChild(_f7);
}
}
function is_array(obj){
return obj.constructor==Array;
}
function isset(obj){
return typeof obj!=="undefined";
}
String.prototype.pad=function(_fa,_fb,_fc){
if(_fa){
_fa=_fa-this.length;
}else{
return this;
}
var _fd=this;
if(_fb){
_fb=_fb+"";
}else{
_fb=" ";
}
if(!isset(_fc)){
_fc="STR_PAD_LEFT";
}
if(_fc=="STR_PAD_BOTH"){
var odd=_fa%2;
var _ff=_fa/2;
_ff=Math.round(_ff);
var left=_fb.times(_ff);
var _101=_fb.times(_ff-odd);
_fd=left+_fd+_101;
}else{
var _fb=_fb.times(_fa);
if(_fc=="PAD_STR_RIGHT"){
_fd=_fd+_fb;
}else{
_fd=_fb+_fd;
}
}
return _fd;
};
Number.prototype.toPixels=function(){
return this;
};
String.prototype.toPixels=function(_102){
var size=this.match(/^(-?)(\d+(?:.\d+)?)(px|pt|em|)$/i);
var _104=size[1]?-1:1;
var _105=size[2];
var unit=size[3].toLowerCase();
function rule(_107,unit){
var _109=document.getElementById(unit+"Ruler");
if(!_109){
_109=document.createElement("div");
document.getElementsByTagName("BODY")[0].appendChild(_109);
_109.id=unit+"Ruler";
}
_109.style.width=_107+unit;
return _109.clientWidth*_104;
}
switch(unit){
case "px":
return _105*_104;
case "pt":
return rule(_105,unit);
case "em":
if(!_102){
log("It\u2019s better to give a reference element when calculating pixels from ems");
return rule(_105,unit);
}else{
var _10a=document.createElement(_102.tagName);
_10a.style.display="block";
_10a.style.position="absolute";
_10a.style.left="-9999px";
_10a.style.top="-9999px";
_10a.style.height="0";
_10a.style.padding="0";
_10a.style.border="0";
_10a.style.width=_105+unit;
_102.parentNode.appendChild(_10a);
returnValue=_10a.clientWidth;
_102.parentNode.removeChild(_10a);
return returnValue*_104;
}
default:
return _105*_104;
}
};
var CSSUtils={getCSSRule:function(_10b,_10c){
_10b=_10b.toLowerCase();
if(document.styleSheets){
for(var i=0;i<document.styleSheets.length;i++){
var _10e=document.styleSheets[i];
var ii=0;
var _110=false;
do{
if(_10e.cssRules){
_110=_10e.cssRules[ii];
}else{
_110=_10e.rules[ii];
}
if(_110){
if(_110.selectorText.toLowerCase()==_10b){
if(_10c=="delete"){
if(_10e.cssRules){
_10e.deleteRule(ii);
}else{
_10e.removeRule(ii);
}
return true;
}else{
return _110;
}
}
}
ii++;
}while(_110);
}
}
return false;
},killCSSRule:function(_111){
return CSSUtils.getCSSRule(_111,"delete");
},addCSSRule:function(_112){
if(document.styleSheets){
if(!CSSUtils.getCSSRule(_112)){
if(document.styleSheets[0].addRule){
document.styleSheets[0].addRule(_112,null,0);
}else{
document.styleSheets[0].insertRule(_112+" { }",0);
}
}
}
return CSSUtils.getCSSRule(_112);
}};
function actsAsAspect(_113){
_113.yield=null;
_113.rv={};
_113.before=function(_114,f){
var _116=eval("this."+_114);
this[_114]=function(){
f.apply(this,arguments);
return _116.apply(this,arguments);
};
};
_113.after=function(_117,f){
var _119=eval("this."+_117);
this[_117]=function(){
this.rv[_117]=_119.apply(this,arguments);
return f.apply(this,arguments);
};
};
_113.around=function(_11a,f){
var _11c=eval("this."+_11a);
this[_11a]=function(){
this.yield=_11c;
return f.apply(this,arguments);
};
};
}
var ieHover={selector:"tr, li",add:function(_11d){
if(!(/MSIE (5|6|8)/).test(navigator.userAgent)){
return;
}
var _11d=_11d||false;
if(Object.isString(_11d)&&$(_11d)){
$(_11d).select(ieHover.selector).each(function(item){
ieHover.prepareItem(item);
});
}else{
if(Object.isElement(_11d)){
_11d=$(_11d);
if(_11d.match("tr, li")){
ieHover.prepareItem(_11d);
}else{
_11d.select(ieHover.selector).each(function(item){
ieHover.prepareItem(item);
});
}
}else{
if(Object.isArray(_11d)){
_11d.each(function(item){
ieHover.prepareItem(item);
});
}
}
}
},prepareItem:function(item){
item.observe("mouseenter",ieHover.mouseOver);
item.observe("mouseleave",ieHover.mouseOut);
},mouseOver:function(_122){
this.className=this.className.replace(/(\w+[^_\s]{2})\b/ig,"$1 $1hover_")+" hover_";
},mouseOut:function(_123){
this.className=this.className.replace(/\w+_\b/ig,"").replace(/\s+/ig," ");
},setUp:function(){
if(!(/MSIE (5|6|8)/).test(navigator.userAgent)){
return;
}
var _124=document.createStyleSheet();
var _125=[];
var _126;
var _127=document.styleSheets,l=_127.length;
for(var i=0;i<l;i++){
parseStylesheet(_127[i]);
}
function parseStylesheet(_12a){
if(_12a.imports){
try{
var _12b=_12a.imports,l=_12b.length;
for(var i=0;i<l;i++){
parseStylesheet(_12a.imports[i]);
}
}
catch(securityException){
}
}
try{
var _12d=(_126=_12a).rules;
var l=_12d.length;
var _12f=false;
var _130=false;
for(var j=0;j<l;j++){
_12f=_12d[j].selectorText;
_130=_12d[j].style.cssText;
if(_12f.match(/(tr|li)(\.(\w*))*:hover/ig)&&_130){
_125.push([_12f.replace(/(tr|li)(\.(\w*))*:hover/ig,"$1.$3hover_"),_130]);
}
}
}
catch(securityException){
}
}
var _132="";
for(var i=_125.length-1;i>=0;i--){
_132+=_125[i][0]+"\n{ "+_125[i][1]+"}\n";
}
_124.cssText=_132;
var _133=[];
var page=$("page");
ieHover.selector.split(",").each(function(weee){
_133.push($A(page.getElementsByTagName(weee.strip())));
});
_133=_133.flatten();
var i=_133.length-1;
for(i;i>=0;i--){
Event.observe(_133[i],"mouseenter",ieHover.mouseOver);
Event.observe(_133[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("LiveSwitch",Class.create({initialize:function(_144,_145){
this.element=$(_144);
this.options={selectedClass:"selected"};
Object.extend(this.options,_145);
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(_148){
_148.stop();
_148.element().blur();
var li=_148.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(_14a,_14b){
this.container=$(_14a);
if(_14b){
Object.extend(this,_14b);
}
if(!this.onComplete){
this.onComplete=this._defaultOnComplete;
}
if(!this.resource){
this.resource=LFM.ParentResource;
}
this.container.observe("click",this.observeMenu.bindAsEventListener(this));
},observeMenu:function(_14c){
var link=_14c.findElement("a");
if(!link){
return;
}
if(link.hasClassName("mEdit")){
_14c.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")){
_14c.stop();
var _14f={module:this.moduleName,type:this.resource.type,id:this.resource.id};
var url="/ajax/dialog/feeds?"+Object.toQueryString(_14f);
this._dialog=new LFM.Dialog({classname:"feedDialog",onConfirm:function(_150){
_150.stop();
this.hide();
}});
this._dialog.show(url);
}else{
if(link.hasClassName("mPaste")){
_14c.stop();
var _151=$$(".modulechartsartists li.current a")[0].getAttribute("href");
var _152=/rangetype=([^&]*)/;
var _153=_151.match(_152)[1];
var _14f={module:this.moduleName,type:this.resource.type,id:this.resource.id,period:_153};
var url="/ajax/dialog/pasteyourtaste?"+Object.toQueryString(_14f);
this._dialog=new LFM.Dialog({classname:"pasteDialog",onConfirm:function(_154){
_154.stop();
this.hide();
}});
this._dialog.show(url);
}
}
}
},_defaultOnComplete:function(){
if(this.container.down(".module-body")){
var url="/module";
var _156={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,_156);
}
},_onConfirmDialog:function(_157,form){
_157.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(_159){
var _15a=new LFM.Ajax.Response(_159);
if(_15a.isSuccess()){
this.container.down(".module-body").replace(_15a.get("content"));
}else{
this.container.removeClassName("loading");
}
}}),onRefresh:function(_15b,_15c){
if(!LFM.Module.refreshers){
LFM.Module.refreshers={};
}
LFM.Module.refreshers[_15b]=_15c;
}});
LFM.set("Display",{MultiTuner:Class.create({initialize:function(form,_15e){
this.uuid=Math.round(Math.random()*100000);
this.form=$(form);
this.restype=_15e.restype;
this.sampleContent=$(_15e.sampleContent);
this.slotID=_15e.slotID||"slot"+this.uuid;
this.slotClass=_15e.slotClass||"";
this.choices=$(_15e.choices);
this.autocomplete=$(_15e.autocomplete);
this.length=_15e.length||3;
this.itemClass=_15e.itemClass||"";
this.onSelect=_15e.onSelect;
this.onDeselect=_15e.onDeselect;
this.onResourceJSON=_15e.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 _162=this.autocomplete.serialize(true);
if(!_162.placeholder&&_162.name){
this.select(_162.name.unescapeHTML());
this.autocomplete.down("input[name=name]").value="";
}
}.bind(this));
}
},setupSlots:function(_163){
var that=this;
var _165=$A($R(1,_163));
_165.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 _165.inject($H(),function(hash,i){
hash.set(i,false);
return hash;
});
},generate_item_id:function(_16a){
return "item"+this.uuid+"_"+_16a.toLowerCase().replace(/_/g,"__").replace(/ /g,"_");
},updateSampleContent:function(){
if(this.sampleContent&&this.restype){
var _16b=this.sampleContent.up("p");
if(!this.filled){
_16b.hide();
_16b.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(_16d){
var _16e=new LFM.Ajax.Response(_16d);
if(_16e.isError()){
var _16f=that.sampleContent.up("p");
that.sampleContent.update();
_16f.hide();
_16f.next("p.noSampleContent").hide();
_16f.next("p.sampleContentError").show();
}else{
var _170=_16e.get("sampleContent");
var _16f=that.sampleContent.up("p");
if(_170&&_170.items&&_170.items.length){
var _171=_170.items.inGroupsOf(3)[0].collect(function(item){
if(!item){
throw $break;
}
return item.res.name;
}).join(", ");
that.sampleContent.update(_171);
_16f.next("p.noSampleContent").hide();
_16f.next("p.sampleContentError").hide();
_16f.show();
}else{
that.sampleContent.update();
_16f.hide();
_16f.next("p.sampleContentError").hide();
_16f.next("p.noSampleContent").show();
}
}
}});
}
}
},fetchResourceJSON:function(_173,_174){
var that=this;
new Ajax.Request("/ajax/getResource",{method:"get",parameters:{"type":this.restype,"name":_173},onComplete:function(_176){
var _177=new LFM.Ajax.Response(_176);
that.onResourceJSON(_177,_174);
}});
},deselect:function(_178){
var slot=this.selections.unset(_178);
this.slots.set(slot,false);
var _17a=$(_178);
_17a.remove();
$(_178+"_input").remove();
this.filled--;
var _17b=this.matching_choices.get(_178);
if(_17b){
_17b.removeClassName("disabled");
}
this.updateSampleContent();
if(this.onDeselect){
this.onDeselect(_17a);
}
},select:function(_17c){
var _17d=this.generate_item_id(_17c);
if(this.selections.get(_17d)){
this.deselect(_17d);
return false;
}
if(this.filled>=this.length){
return false;
}
if(this.choices){
var _17e=this.choices.select("li").find(function(item){
return (item.down("a").innerHTML==_17c);
});
this.matching_choices.set(_17d,_17e);
}
this.form.insert(new Element("input",{"type":"hidden","name":"names[]","value":_17c,"id":_17d+"_input"}));
var _180=new Element("a",{"href":"#","class":this.itemClass,"id":_17d}).observe("click",function(e){
e.stop();
this.deselect(_17d);
}.bind(this));
_180.insert(new Element("span").update(_17c));
var _182=this.slots.find(function(item){
return (item.value===false);
}).key;
var _184=$(this.slotID+_182);
_184.insert(_180);
this.selections.set(_17d,_182);
this.slots.set(_182,true);
this.filled++;
if(_17e){
_17e.addClassName("disabled");
}
this.updateSampleContent();
if(this.onResourceJSON){
this.fetchResourceJSON(_17c,_180);
}
if(this.onSelect){
this.onSelect(_17c,_180);
}
}})});
document.observe("dom:loaded",function(_185){
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 _187=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 _189.events[name];
},prop:function(name){
return _189.props[name];
},evar:function(name){
return _189.evars[name];
},setProp:function(name,_18d){
if(this.isBlocked()){
return false;
}
this.tracker[this.prop(name)]=_18d;
},getProp:function(name){
if(this.isBlocked()){
return false;
}
return this.tracker[this.prop(name)];
},setEvar:function(name,_190){
if(this.isBlocked()){
return false;
}
this.tracker[this.evar(name)]=_190;
},getEvar:function(name){
if(this.isBlocked()){
return false;
}
return this.tracker[this.evar(name)];
},currentEvars:[],prepareEvar:function(name,_193){
if(this.isBlocked()){
return false;
}
this.setEvar(name,_193);
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(_195,_196){
if(this.isBlocked()){
return false;
}
this.linkElement=_195;
this.linkTitle=_196;
},clearLink:function(){
if(this.isBlocked()){
return false;
}
this.linkElement=null;
this.linkTitle=null;
},setLinkTrackEvars:function(){
if(this.isBlocked()){
return false;
}
var _197=["events"];
var _198={};
this.currentEvars.each(function(name){
var _19a=this.evar(name);
_197.push(_19a);
_198[name+"/"+_19a]=this.getEvar(name);
}.bind(this));
this.tracker.linkTrackVars=_197.join(",");
return _198;
},setLinkTrackEvents:function(){
if(this.isBlocked()){
return false;
}
var _19b=[];
var _19c=Array.prototype.join.call(arguments,",");
for(var i=0;i<arguments.length;i++){
_19b.push(this.event(arguments[i]));
}
var _19e=_19b.join(",");
this.tracker.events=_19e;
this.tracker.linkTrackEvents=_19e;
return _19c;
},track:function(_19f){
if(this.isBlocked()){
return false;
}
this.tracker.tl(this.linkElement||true,"o",this.linkTitle||_19f);
},trackEvents:function(){
if(this.isBlocked()){
return false;
}
this.resetTracker();
var _1a0=this.setLinkTrackEvents.apply(this,arguments);
var _1a1=this.setLinkTrackEvars();
var _1a2="TRACK: "+_1a0;
if(this.linkTitle){
_1a2+=" ("+this.linkTitle+") ";
}
LFM.log(_1a2);
LFM.info(this.linkElement);
LFM.dir(_1a1);
this.track(_1a0);
this.clearEvars();
this.clearLink();
}});
var _189={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 _187());
});
})();
LFM.set("Input",{RichText:Class.create({hasFocus:false,busy:false,wordSeparators:" \t\n,.()!?|=-\\",initialize:function(div,_1a5){
this.div=$(div);
this.options=_1a5?_1a5:{};
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 _1a9=e.charCode||e.keyCode||e.which;
var s=String.fromCharCode(_1a9);
this.cancelOnDown=false;
if(this.specialKeyDown(_1a9,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 _1ad;
if(s=="a"){
_1ad="<lfm:artist>"+name.strip().escapeHTML()+"</lfm:artist>";
}else{
if(s=="m"){
_1ad="<lfm:artist name=\""+name.strip().escapeHTML()+"\"><lfm:image size=\"small\" /></lfm:artist>";
}
}
this.replaceSelection(_1ad,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(_1b2,sel){
new Ajax.Request("/ajax/richtextrenderer",{method:"post",parameters:{richtext:_1b2},onComplete:function(resp){
var out=resp.responseText.evalJSON();
var _1b6=sel.getRangeAt(0);
$(document.body).insert({bottom:out.rendered});
var node=$(document.body).lastChild;
node.remove();
_1b6.deleteContents();
_1b6.insertNode(node);
this.textarea.value+=out.richtext;
}});
},keyPress:function(e){
e=window.event||e;
var _1b9=e.charCode||e.keyCode||e.which;
var s=String.fromCharCode(_1b9);
if(this.specialKeyPress(_1b9,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 _1bc=prev.parentNode;
var _1bd=prev.ownerDocument.createRange();
_1bd.setStartBefore(prev);
var _1be=_1bd.createContextualFragment(s);
var n=_1bc.replaceChild(_1be,prev);
var _1bd=this.caret.ownerDocument.createRange();
_1bd.setStartBefore(this.caret.previousSibling);
var _1c0=_1bd.createContextualFragment(" ");
_1bc.insertBefore(_1c0,this.caret.previousSibling);
}else{
this.caret.insert({before:s});
}
},_delete:function(prev){
var _1c2=false;
var _1c3=prev.previousSibling;
if(prev.nodeType==1){
if(prev.nodeName=="A"){
var _1c4=prev.firstChild;
prev.parentNode.replaceChild(_1c4,prev);
_1c4.unlinked=true;
var _1c5=this.textarea.selectionStart;
var tag="";
var i=_1c5-2;
while(i>=0&&(this.textarea.value.charAt(i)!="/")){
tag=this.textarea.value.charAt(i)+tag;
i--;
}
var _1c8=i;
var _1c9="<"+tag+">";
var _1ca=_1c9.length;
while(i>=0&&(this.textarea.value.substr(i,_1ca)!=_1c9)){
i--;
}
var _1cb=this.textarea.value.substr(0,i);
var _1cc=i+_1ca;
_1cb+=this.textarea.value.substr(_1cc,_1c8-_1cc-1);
_1cb+=this.textarea.value.substr(_1c5);
this.textarea.value=_1cb;
return;
}
}
if(prev.nodeValue=="\n"){
_1c2=true;
}
var _1cd=prev.parentNode;
if(prev.nodeType==3){
var _1c5=this.textarea.selectionStart;
var _1cb=this.textarea.value.substr(0,_1c5-1);
if(_1c5<this.textarea.value.length){
_1cb+=""+this.textarea.value.substr(_1c5);
}
this.textarea.value=_1cb;
if(this.textarea.createTextRange){
var _1ce=this.textarea.createTextRange();
_1ce.moveStart("character",_1c5-1);
_1ce.moveEnd("character",_1c5-1);
_1ce.select();
}else{
if(this.textarea.setSelectionRange){
this.textarea.setSelectionRange(_1c5-1,_1c5-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);
}
}
_1cd.removeChild(prev);
if(_1c3&&_1c3.nodeType==3&&_1c3.nodeValue.strip().empty()&&_1c3.nodeValue!="\n"){
var _1cf=_1c3.ownerDocument.createRange();
_1cf.setStartAfter(_1c3);
var nbsp=_1cf.createContextualFragment("&nbsp;");
_1cd.replaceChild(nbsp,_1c3);
_1c3=nbsp;
}
if(_1c2){
var _1c3=prev.previousSibling;
_1cd.removeChild(prev);
this.caret.previousSibling=_1c3;
this.caret.remove();
}
if(_1c3){
_1cd.insertBefore(this.caret,_1c3.nextSibling);
}
},specialKeyDown:function(_1d1,e){
if(_1d1>=37&&_1d1<=40&&!(e.ctrlKey||e.altKey||e.shiftKey||e.metaKey)){
var prev=this.caret.previousSibling;
var next=this.caret.nextSibling;
var _1d5=this.caret.parentNode;
if(_1d1==37&&prev){
this.caret.remove();
_1d5.insertBefore(this.caret,prev);
var _1d6=this.textarea.selectionStart;
if(this.textarea.createTextRange){
var _1d7=this.textarea.createTextRange();
_1d7.moveStart("character",_1d6-1);
_1d7.moveEnd("character",_1d6-1);
_1d7.select();
}else{
if(this.textarea.setSelectionRange){
this.textarea.setSelectionRange(_1d6-1,_1d6-1);
}
}
}else{
if(_1d1==39&&next){
this.caret.remove();
_1d5.insertBefore(this.caret,next.nextSibling);
var _1d6=this.textarea.selectionStart;
if(this.textarea.createTextRange){
var _1d7=this.textarea.createTextRange();
_1d7.moveStart("character",_1d6+1);
_1d7.moveEnd("character",_1d6+1);
_1d7.select();
}else{
if(this.textarea.setSelectionRange){
this.textarea.setSelectionRange(_1d6+1,_1d6+1);
}
}
}
}
this.textarea.focus();
return true;
}else{
if(_1d1==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(_1d1==8){
if(this.caret.previousSibling){
this._delete(this.caret.previousSibling);
}
return true;
}else{
if(_1d1==13){
this.caret.insert({before:"<br />"});
this.textarea.value+="<br />";
return true;
}
}
}
}
},specialKeyPress:function(_1d8,e){
var s=String.fromCharCode(_1d8);
if(this.cancelOnDown){
return true;
}
if(this.wordSeparators.indexOf(s)>=0){
var _1db=this.caret;
if(_1db.previousSibling&&_1db.previousSibling.nodeType==3&&!_1db.previousSibling.unlinked){
var back=0;
var name="";
var _1de;
while((_1db=_1db.previousSibling)&&_1db.nodeType==3&&_1db.nodeValue.unescapeHTML().strip()!=""){
name=_1db.nodeValue+name;
back++;
}
_1de=_1db;
var _1df=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+)*)?/)){
_1df="<a href=\""+name.escapeHTML()+"\">"+name.escapeHTML()+"</a>";
}else{
var _1e0=name.toUpperCase();
var _1e1=this.artists.find(function(a){
return a.toUpperCase()==_1e0;
});
if(_1e1){
_1df="<lfm:artist>"+name.escapeHTML()+"</lfm:artist>";
}
}
if(_1df){
var _1e3=this.textarea.selectionStart;
new Ajax.Request("/ajax/richtextrenderer",{method:"post",parameters:{richtext:_1df},onComplete:function(resp){
var out=resp.responseText.evalJSON();
var _1e6=_1de.nextSibling;
for(;back>0;back--){
var tmp=_1e6.nextSibling;
_1e6.parentNode.removeChild(_1e6);
_1e6=tmp;
}
if(_1de){
var _1e8=_1de.ownerDocument.createRange();
_1e8.setStartAfter(_1de);
var _1e9=_1e8.createContextualFragment(out.rendered);
_1de.parentNode.insertBefore(_1e9,_1de.nextSibling);
}else{
this.div.insert({top:out.rendered});
}
var _1ea=this.textarea.value.substr(0,_1e3-name.length);
_1ea+=out.richtext;
_1ea+=""+this.textarea.value.substr(_1e3);
this.textarea.value=_1ea;
}.bind(this)});
}
}
}else{
if(s=="/"){
var _1db=this.caret.previousSibling;
if(!_1db||_1db.nodeValue!="["){
return false;
}
var _1eb=_1db;
var _1ec="";
var tag="";
var back=2;
while((_1db=_1db.previousSibling)&&_1db.nodeType==3&&_1db.nodeValue!="]"){
_1ec=_1db.nodeValue+_1ec;
back++;
}
while((_1db=_1db.previousSibling)&&_1db.nodeType==3&&_1db.nodeValue!="["){
tag=_1db.nodeValue+tag;
back++;
}
if(tag=="artist"){
_1ec=_1ec.strip();
var _1e3=this.textarea.selectionStart;
var _1df="<lfm:artist>"+_1ec.escapeHTML()+"</lfm:artist>";
new Ajax.Request("/ajax/richtextrenderer",{method:"post",parameters:{richtext:_1df},onComplete:function(resp){
var out=resp.responseText.evalJSON();
_1db=_1eb;
for(var i=back;i>0;i--){
var tmp=_1db.previousSibling;
_1db.parentNode.removeChild(_1db);
_1db=tmp;
}
if(this.caret.previousSibling){
var rm=this.caret.previousSibling;
rm.parentNode.removeChild(rm);
}
this.caret.insert({before:out.rendered});
var _1f3=this.textarea.value.substr(0,_1e3-back-1);
_1f3+=""+out.richtext;
_1f3+=""+this.textarea.value.substr(_1e3);
this.textarea.value=_1f3;
}.bind(this)});
return true;
}
}
}
if(s==" "){
this.caret.insert({before:"&nbsp;"});
this.textarea.value+=" ";
return true;
}
},moveTextAreaCursorBy:function(n){
var _1f5=this.textarea.selectionStart;
if(this.textarea.createTextRange){
var _1f6=this.textarea.createTextRange();
_1f6.moveStart("character",_1f5+n);
_1f6.moveEnd("character",_1f5+n);
_1f6.select();
}else{
if(this.textarea.setSelectionRange){
this.textarea.setSelectionRange(_1f5+n,_1f5+n);
}
}
},focus:function(e){
Event.stop(e);
var _1f8=e.rangeParent;
if(this.caret.parentNode){
this.caret.remove();
}
if(_1f8!=this.caret&&_1f8!=this.div){
_1f8.parentNode.insertBefore(this.caret,_1f8.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";
}})});
var Scroller=Class.create({initialize:function(_1f9){
this.scroller=$(_1f9);
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 _1fa=this.getVisibleWidth();
modulo=_1fa%this.imageWidth;
_1fa=_1fa-modulo;
if(_1fa>this.getWidth()){
_1fa=this.getWidth();
}
Element.setStyle(this.scroller,{maxWidth:_1fa+"px"});
var _1fb=this.getWidth()*-1+Math.abs(this.getOffset())+this.getVisibleWidth();
var _1fc=(this.getWidth()-this.getVisibleWidth())*-1;
this.setOffset(_1fc);
this.refreshButtonStates();
},onResize:function(_1fd){
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 _1fe=Element.getStyle(sampleImage,"border-left-width").replace("px","")*1;
if(!isNaN(_1fe)){
this.imageWidth=this.imageWidth+_1fe;
}
var _1ff=Element.getStyle(sampleImage,"border-right-width").replace("px","")*1;
if(!isNaN(_1ff)){
this.imageWidth=this.imageWidth+_1ff;
}
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(_200){
var blah=this.getWidth()-this.getVisibleWidth();
this.imageTrack.setStyle({left:_200+"px"});
},scrollLeft:function(_202){
if(!this.isScrolling&&this.getOffset()<0){
var _203=Math.abs(this.getOffset());
var _204=this.getVisibleWidth();
if(_204>_203){
_204=_203;
}
this.scroll(_204);
}
this.refreshButtonStates();
this.leftScrollButton.blur();
Event.stop(_202);
},scrollRight:function(_205){
if(!this.isScrolling&&(Math.abs(this.getOffset())+this.getVisibleWidth())<this.getWidth()){
var _206=this.getWidth()-(Math.abs(this.getOffset())+this.getVisibleWidth());
var _207=this.getVisibleWidth();
if(_207>_206){
_207=_206;
}
_207=_207*-1;
this.scroll(_207);
}
this.refreshButtonStates();
this.rightScrollButton.blur();
Event.stop(_205);
},scroll:function(_208,_209){
if(!this.isScrolling||_209){
new Effect.Move(this.imageTrack,{x:_208,y:0,mode:"relative",duration:0.5,afterFinish:this.afterScrolling.bind(this),beforeStart:this.beforeScrolling.bind(this),queue:{position:"end",scope:"scroller"}});
}
},beforeScrolling:function(_20a){
this.isScrolling=true;
this.totalDelta=this.totalDelta+_20a.options.x;
},afterScrolling:function(_20b){
this.isScrolling=false;
this.totalDelta=this.totalDelta-_20b.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 _20c=this.getSelectedImage().id;
if(_20c&&this.getImageWidth()){
_20c=(_20c.substring(5)*1)-1;
var _20d=_20c*this.getImageWidth();
_20d=_20d-this.getMiddle()+this.getImageWidth()/2;
if(_20d>(this.getWidth()-this.getVisibleWidth())){
_20d=this.getWidth()-this.getVisibleWidth();
}
_20d=_20d*-1;
if(_20d>0){
_20d=0;
}
Element.setStyle(this.imageTrack,{left:_20d+"px"});
this.refreshButtonStates();
}
}
}});
LFM.set("Resource",{Shoutbox:Class.create({initialize:function(_20e){
this.shoutbox=_20e;
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(_20f){
_20f.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 _213=new Ajax.Request(url,{method:"post",parameters:pars,onSuccess:this.addShout.bind(this)});
},addShout:function(_214){
if(this.shoutbox.restype==20){
LFM.Omniture.trackEvents("CommentPost");
}else{
LFM.Omniture.trackEvents("ShoutPost");
}
var _215=$("shoutList");
$("shoutList").insert({before:_214.responseText});
if(this.shoutbox.order=="asc"){
_215.innerHTML=_215.innerHTML+$("newShoutList").innerHTML;
}else{
_215.innerHTML=$("newShoutList").innerHTML+_215.innerHTML;
}
$("newShoutList").remove();
$("shoutList").select("li").each(function(li){
var _217=li.down(".delete");
if(_217){
_217.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(_218){
_218.stop();
var _219=_218.findElement("li");
var form=_219.down("form");
var _21b=this.shoutbox.destination;
if(_21b.substr(-1)!="/"){
_21b+="/";
}
_21b+="delete";
form.action=_21b;
var _21c=this.shoutbox.restype;
var _21d=this.shoutbox.resid;
var _21e=new LFM.Dialog({content:LFM.String.deleteMessagePrompt,confirmText:LFM.String.deleteButtonText,action:_21b,onConfirm:function(e){
e.stop();
this.hide();
form.request({parameters:{restype:_21c,resid:_21d,ajax:1},onSuccess:function(req){
if(req.responseText=="OK"){
new Effect.Fade(_219,{duration:0.2});
}
}});
}});
_21e.show();
},toggleInput:function(e){
if($("shoutPost").visible()){
$("shoutPost").hide();
}else{
$("shoutPostAgain").hide();
$("shoutPost").show();
this.textarea.focus();
}
e.stop();
},calculateCharCount:function(){
var _222=this.textarea.value.length;
this.updateCharLimit(_222);
this.updateCharCountDisplay(_222);
},updateCharCountDisplay:function(_223){
charCounter=$("sbCharCount");
var _224=this.shoutbox.charlimitMessage;
if(charCounter){
_224=_224.replace(/CURRENTCHARS/,_223);
_224=_224.replace(/MAXCHARS/,this.shoutbox.charlimit);
charCounter.innerHTML=_224;
}
},updateCharLimit:function(_225){
var _226=(_225>this.shoutbox.charlimit);
if(!this.overCharLimit&&_226){
$("sbCharCount").up().addClassName("overCharLimit");
$("sbPost").disable();
this.textarea.focus();
}
if(this.overCharLimit&&!_226){
$("sbCharCount").up().removeClassName("overCharLimit");
$("sbPost").enable();
}
this.overCharLimit=_226;
}})});
LFM.set("Display",{TableDragDrop:Class.create({initialize:function(_227,_228){
this.draggedRow=null;
this.rowWithBorderAndShit=null;
this.mouseOffset=null;
this.oldY=0;
this.dragged=false;
if(_228&&_228.dragHandle){
this.dragHandle=_228.dragHandle;
}else{
this.dragHandle=false;
}
this.table=$(_227);
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(_229){
if(this.dragged){
_229.stop();
this.dragged=false;
}
},getMouseOffset:function(_22a,_22b){
var _22c=_22a.cumulativeOffset();
return {x:_22b.pointerX()-_22c.left,y:_22b.pointerY()-_22c.top};
},onMouseDown:function(_22d){
if(!_22d.isLeftClick()){
return;
}
if(this.dragHandle&&!_22d.element().hasClassName(this.dragHandle)){
return;
}
if((tag_name=_22d.element().tagName.toUpperCase())&&(tag_name=="INPUT"||tag_name=="SELECT"||tag_name=="OPTION"||tag_name=="BUTTON"||tag_name=="TEXTAREA")){
return;
}
this.draggedRow=_22d.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,_22d);
_22d.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(_22e){
var y=_22e.pointerY()-this.mouseOffset.y;
_22e.stop();
if(y!=this.oldY){
var _230=y>this.oldY;
this.oldY=y;
var _231=this.findDropTargetRow(y);
if(_231){
this.dragged=true;
if(_230&&this.draggedRow!=_231){
this.draggedRow.parentNode.insertBefore(this.draggedRow,_231.nextSibling);
}else{
if(!_230&&this.draggedRow!=_231){
this.draggedRow.parentNode.insertBefore(this.draggedRow,_231);
}
}
}
}
},onMouseUp:function(_232){
_232.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 _236=row.getHeight()/2;
if((y>rowY-_236)&&(y<(rowY+_236))){
return true;
}else{
return false;
}
});
return null;
}})});
LFM.set("Resource",{Users:Class.create({initialize:function(_237){
this.container=$("users");
this.container.observe("click",function(_238){
log("clicked container");
var _239=_238.element();
if(_239.match("a.delete img")){
_238.stop();
var _23a=_239.up("li");
if(_23a){
this.bin(_23a);
}
}
}.bind(this));
},bin:function(_23b){
var _23c=new LFM.Dialog({resource:_23b.getResource(),content:LFM.String.deleteFriendPrompt,confirmText:LFM.String.deleteButtonText,action:"friends/delete",onDone:function(_23d){
var _23e=_23d.getResourceElement();
new Effect.Fade(_23e,{duration:0.5});
},showDone:false});
_23c.show();
}})});
LFM.set("Ajax",{Autocompleter:Class.create(Ajax.Autocompleter,{setOptions:function(_23f){
this.options=Object.extend({method:"get"},_23f||{});
},buildItem:function(name){
return new Element("a",{href:"#"}).update(name).wrap(new Element("li"));
},onComplete:function(_241){
try{
var _242=_241.responseText.evalJSON();
}
catch(err){
return false;
}
if(_242&&_242.response.docs){
var list=new Element("ul");
var _244=this.getToken();
list.insert(this.buildItem(_244));
_242.response.docs.each(function(_245){
if(_245.name.toLowerCase()!=_244.toLowerCase()){
list.insert(this.buildItem(_245.name));
}
}.bind(this));
this.updateChoices(new Element("div").update(list).innerHTML);
}
}})});
LFM.set("Ajax",{Multicompleter:Class.create(LFM.Ajax.Autocompleter,{initialize:function(_246,_247,url,_249){
this.baseInitialize(_246,_247,_249);
this.url=url;
this.options.asynchronous=true;
this.options.onComplete=this.onComplete.bind(this);
this.options.onHide=function(_24a,_24b){
window.status="";
new Effect.Fade(_24b,{duration:0.15});
};
this.form=this.element.up("form");
this.submit=this.form.down("input[type=submit]");
var _24c={};
if(this.options.enabled){
_24c["force"]=1;
}else{
this.show=function(){
return false;
};
this.startIndicator=function(){
return false;
};
}
if(LFM.Session.userName){
_24c["username"]=LFM.Session.userName;
}
if(this.options.parameters){
_24c=Object.extend(_24c,this.options.parameters);
}
this.options.defaultParams=_24c;
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 _24d=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(_24e){
if(!_24e.length||!this.personalData){
return false;
}
var _24f=new RegExp(_24e.replace(/([\\\^\$*+[\]?{}.=!:(|)])/g,"\\$1"),"i");
var _250=[];
var _251=this.personalData.get("friends");
if(_251){
_251.each(function(_252,i){
var _254=_252.name.match(_24f)||(_252.realname&&_252.realname.match(_24f));
if(_254){
_250.push(_252);
}
});
}
var _255=this.personalData.get("groups");
if(_255){
_255.each(function(_256,i){
var _258=_256.name.match(_24f);
if(_258){
_250.push(_256);
}
});
}
var _259=this.personalData.get("labels");
if(_259){
_259.each(function(_25a,i){
var _25c=_25a.name.match(_24f)&&_25a.single_artist!="t";
if(_25c){
_250.push(_25a);
}
});
}
return _250;
},buildEvent:function(_25d){
var _25e=_25d.date.split("T");
var _25f=_25e[0].split("-");
var _260=_25d.event||_25d.artist;
var _261="<span class=\"calSheet calSheetSmall\">"+"<span title=\""+_25d.date+"\">"+"<span class=\"month\">"+LFM.String.shortMonths[_25f[1]-0]+"</span>"+"<span class=\"day\">"+(_25f[2]-0)+"</span>"+"</span>"+"</span>";
var _262=_25d["country_"+LFM.Session.language]||_25d["country_en"];
return _261+"<strong>"+_260.truncate(25)+"</strong><br>"+_25d.city.truncate(25)+", "+_262.truncate(25);
},buildEventTitle:function(_263){
var _264=_263.event||_263.artist;
var _265=_263["country_"+LFM.Session.language]||_263["country_en"];
return _264+", "+_263.venue+", "+_263.city+", "+_265;
},buildEventURL:function(_266){
return "/event/"+encodeURIComponent(encodeURIComponent(_266.resid));
},buildArtist:function(_267){
var _268=this.buildArtistImageURL(_267);
var _269="<img src=\""+_268+"\" width=\"34\" height=\"34\">";
return _269+this.buildName(_267.artist);
},buildArtistTitle:function(_26a){
return _26a.artist;
},buildArtistURL:function(_26b){
return "/music/"+encodeURIComponent(encodeURIComponent(_26b.artist));
},buildArtistImageURL:function(_26c){
if(_26c.image){
return LFM.Session.userserveHost+"/serve/34s/"+_26c.image;
}else{
var _26d={api_key:LFM.Session.wsKey,artist:_26c.artist,method:"artist.getImageRedirect",size:"smallsquare"};
return "http://"+LFM.Session.wsHost+"/2.0/?"+Object.toQueryString(_26d);
}
},buildAlbum:function(_26e){
var _26f=this.buildAlbumImageURL(_26e);
var _270="<span class=\"albumCover coverSmall\" />"+"<span class=\"art\"><img src=\""+_26f+"\" width=\"34\" height=\"34\"></span>"+"<span class=\"jewelcase\"></span>"+"</span>";
return _270+this.buildName(_26e.album)+"<br>"+_26e.artist.truncate(25);
},buildAlbumTitle:function(_271){
return _271.album+" - "+_271.artist;
},buildAlbumURL:function(_272){
return "/music/"+encodeURIComponent(encodeURIComponent(_272.artist))+"/"+encodeURIComponent(encodeURIComponent(_272.album));
},buildAlbumImageURL:function(_273){
if(_273.image){
return LFM.Session.userserveHost+"/serve/34s/"+_273.image;
}else{
var _274={api_key:LFM.Session.wsKey,artist:_273.artist,album:_273.album,method:"album.getImageRedirect",size:"smallsquare"};
return "http://"+LFM.Session.wsHost+"/2.0/?"+Object.toQueryString(_274);
}
},buildTrack:function(_275){
var _276=this.buildArtistImageURL(_275);
var _277="<img src=\""+_276+"\" width=\"34\" height=\"34\">";
var _278=_275.duration?" <small> ("+LFM.timeFormat(_275.duration)+")</small>":"";
return _277+this.buildName(_275.track)+_278+"<br>"+_275.artist.truncate(25);
},buildTrackTitle:function(_279){
return _279.track+" - "+_279.artist;
},buildTrackURL:function(_27a){
return "/music/"+encodeURIComponent(encodeURIComponent(_27a.artist))+"/_/"+encodeURIComponent(encodeURIComponent(_27a.track));
},buildTag:function(_27b){
var icon="<img width=\"30\" height=\"30\" src=\""+LFM.Session.staticHost+"/flatness/icons/tag/1/tag_30.png\">";
return icon+this.buildName(_27b.tag);
},buildTagTitle:function(_27d){
return _27d.tag;
},buildTagURL:function(_27e){
return "/tag/"+encodeURIComponent(encodeURIComponent(_27e.tag));
},buildUser:function(_27f){
var _280=this.buildResImage(_27f,"/flatness/catalogue/noimage/2/default_user_small.png");
var user=_280+this.buildName(_27f.name);
if(_27f.realname){
user+="<br>"+_27f.realname.truncate(25);
}
return user;
},buildUserTitle:function(_282){
var _283=_282.name;
if(_282.realname){
_283+=" - "+_282.realname;
}
return _283;
},buildUserURL:function(_284){
return "/user/"+encodeURIComponent(encodeURIComponent(_284.name));
},buildGroup:function(_285){
var _286=this.buildResImage(_285,"/flatness/catalogue/noimage/2/default_group_small.png");
var name;
if(_285.group){
name=this.buildName(_285.group);
}else{
name=this.buildName(_285.name);
}
return _286+name;
},buildGroupTitle:function(_288){
return _288.name||_288.group;
},buildGroupURL:function(_289){
var name=_289.name||_289.group;
return "/group/"+encodeURIComponent(encodeURIComponent(name));
},buildLabel:function(_28b){
var _28c=this.buildResImage(_28b,"/flatness/catalogue/noimage/2/default_label_small.png");
var name;
if(_28b.label){
name=this.buildName(_28b.label);
}else{
name=this.buildName(_28b.name);
}
return _28c+name;
},buildLabelTitle:function(_28e){
return _28e.name||_28e.label;
},buildLabelURL:function(_28f){
var root;
var name=_28f.name||_28f.label;
if(_28f.single_artist=="t"){
root="/artist/";
}else{
root="/label/";
}
return root+encodeURIComponent(encodeURIComponent(name));
},buildName:function(name){
return "<strong>"+name.truncate(25)+"</strong>";
},buildResTitle:function(_293){
return _293.name;
},buildResImage:function(_294,_295){
var _296=LFM.Session.staticHost+_295;
if(_294.image_id){
_296=LFM.Session.userserveHost+"/serve/34s/"+_294.image_id+".jpg";
}else{
if(_294.image){
_296=LFM.Session.userserveHost+"/serve/34s/"+_294.image;
}
}
var _297="<img src=\""+_296+"\" width=\"34\" height=\"34\">";
return _297;
},buildItemLink:function(_298){
var _299=_298.res?_298.res.type:_298.restype;
var _29a=LFM.resTypeLookup[_299];
if(!_29a){
LFM.warn("no restype found: "+_299);
}else{
try{
var url=this["build"+_29a+"URL"](_298);
if(!this.urls[url]){
this.urls[url]=_29a;
var item=this["build"+_29a](_298);
var _29d=this["build"+_29a+"Title"](_298);
var link=new Element("a",{href:url+"?ac="+encodeURIComponent(this.getToken()),title:_29d}).addClassName(_29a.toLowerCase()+"Item").update(item);
return link;
}
}
catch(e){
LFM.warn(_29a,e);
}
}
},buildSearchLink:function(_29f){
var _2a0=this.form.action+"?"+this.form.serialize();
var link=new Element("a",{href:_2a0}).addClassName("viewAll");
return new Element("span").addClassName("moduleOptions").update(_29f).wrap(link);
},setOptions:function(_2a2){
_2a2=_2a2||{};
this.options=Object.extend({method:"get",onShow:function(_2a3,_2a4){
if(!_2a4.style.position||_2a4.style.position=="absolute"){
_2a4.style.position="absolute";
Position.clone(_2a3,_2a4,{setHeight:false,setWidth:false,offsetTop:_2a3.offsetHeight});
}
Effect.Appear(_2a4,{duration:0.15});
}},_2a2);
},markNext:function(){
if(this.index===null){
this.index=0;
}else{
if(this.index<this.entryCount-1){
this.index++;
}
}
var _2a5=this.getCurrentEntry();
if(_2a5){
window.status=_2a5.down("a").href;
}else{
window.status="";
}
},markPrevious:function(){
if(this.index>0){
this.index--;
}else{
this.index=null;
}
var _2a6=this.getCurrentEntry();
if(_2a6){
window.status=_2a6.down("a").href;
}else{
window.status="";
}
},getEntry:function(_2a7){
if(_2a7!==null){
return this.update.down("li.item",_2a7);
}
},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(_2aa,list){
var link;
var _2ad=_2aa.res?_2aa.res.type:_2aa.restype;
if(_2ad){
link=this.buildItemLink(_2aa);
}else{
link=this.buildSearchLink(_2aa);
}
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(_2b1){
response=new LFM.Ajax.Response(_2b1);
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 _2b8=this.getToken();
if(_2b8.length>=this.options.minChars&&_2b8!=this.lastToken){
this.startIndicator();
}
},onSubmit:function(e){
var _2ba=this.form.serialize().toQueryParams();
var _2bb=this.getToken();
LFM.Omniture.prepareEvar("SearchLength",_2bb.length);
if(this.options.enabled){
LFM.Omniture.prepareEvar("SearchType","multicomplete");
}else{
if(_2ba.m){
LFM.Omniture.prepareEvar("SearchType",_2ba.m);
}
}
LFM.Omniture.prepareEvar("HeaderSearchAction","Search");
LFM.Omniture.trackEvents("HeaderSearch");
},onObserverEvent:function(){
this.changed=false;
var _2bc=this.getToken();
if(_2bc.length>=this.options.minChars){
if(_2bc!=this.lastToken&&_2bc!=this.element.getAttribute("placeholder")){
this.getUpdatedChoices();
}else{
this.render();
}
}else{
this.active=false;
this.hide();
}
this.lastToken=_2bc;
this.oldElementValue=this.element.value;
},getToken:function(){
return $F(this.element);
},processResults:function(_2bd){
var list=new Element("ul");
if(_2bd){
this.urls={};
_2bd.each(function(_2bf,_2c0){
this.addLinkedItem(_2bf,list);
},this);
}
this.addViewAll(list,_2bd.length);
return list;
},addViewAll:function(list,_2c2){
this.addLinkedItem(LFM.String.siteSearchViewAll.replace("QUERY",this.getToken()),list);
this.entryCount=_2c2+1;
},onComplete:function(_2c3){
if(this.changed||!this.hasFocus){
return false;
}
var _2c4,_2c5=0;
try{
var _2c6=_2c3.responseText.evalJSON();
_2c4=_2c6.response.docs;
}
catch(err){
LFM.warn("JSON error: "+_2c3.responseText);
}
if(this.personalMatches&&this.personalMatches.length){
var _2c7=Math.min(this.personalMatches.length,3);
_2c4=this.personalMatches.slice(0,_2c7).concat(_2c4.slice(0,10-_2c7));
}
_2c5=_2c4.length;
var list=this.processResults(_2c4);
this.updateChoices(list,_2c5);
},updateChoices:function(list,_2ca){
this.update.update(list);
var _2cb=new Element("p",{"class":"header"});
if(_2ca){
_2cb.update(LFM.String.siteSearchSuggestions);
}else{
_2cb.update(LFM.String.siteSearchNoSuggestions).addClassName("empty");
}
this.update.insert({"top":_2cb});
if(LFM.Session.loggedIn&&!this.personalData){
var _2cc=new Element("div").addClassName("message messageWarn").update(LFM.String.autocompletePersonalDataDown);
this.update.insert({"bottom":_2cc});
}
this.update.select("li.item a").each(function(link,_2ce){
link.autocompleteIndex=_2ce;
},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(_2cf){
var _2d0=this.buildArtistImageURL(_2cf);
var _2d1="<span class=\"img\"><span><img src=\""+_2d0+"\" width=\"34\" height=\"34\" /></span></span>";
return _2d1+"<strong class=\"artist\">"+_2cf.artist.truncate(25)+"</strong>";
},buildTrack:function(_2d2){
var _2d3=this.buildArtistImageURL(_2d2);
var _2d4="<span class=\"img\"><span><img src=\""+_2d3+"\" width=\"34\" height=\"34\" /></span></span>";
var _2d5=_2d2.duration?" <small class=\"time\"> ("+LFM.timeFormat(_2d2.duration)+")</small>":"";
return _2d4+"<strong class=\"track\">"+_2d2.track.truncate(20)+"</strong>"+_2d5+"<br>"+_2d2.artist.truncate(25);
},buildTag:function(_2d6){
var icon="<img width=\"20\" height=\"20\" src=\""+LFM.Session.staticHost+"/flatness/icons/activity/tagged.png\">";
return icon+"<strong class=\"tag\">"+_2d6.tag.truncate(25)+"</strong>";
},processResults:function(_2d8,list){
var list=new Element("ul");
if(_2d8){
this.urls={};
var _2da=this.groupResults(_2d8);
var _2db,_2dc,_2dd,_2de;
this.resTypeGroups.each(function(_2df,_2e0){
if(_2da[_2df]){
_2db=new Element("li");
_2de=(_2df==LFM.resTypes.USER)?LFM.String.resTypePlural["friends"]:LFM.String.resTypePlural[_2df];
_2dc=new Element("h3").update(_2de).addClassName(LFM.resTypeLookup[_2df].toLowerCase());
_2dd=new Element("ul");
_2da[_2df].each(function(_2e1,_2e2){
this.addLinkedItem(_2e1,_2dd);
},this);
_2db.insert(_2dc);
_2db.insert(_2dd);
list.insert(_2db);
}
},this);
}
this.addViewAll(list,_2d8.length);
return list;
},groupResults:function(_2e3){
var _2e4={},_2e5;
_2e3.each(function(_2e6,_2e7){
_2e5=_2e6.res?_2e6.res.type:_2e6.restype;
if(!_2e4[_2e5]){
_2e4[_2e5]=[];
}
_2e4[_2e5].push(_2e6);
},this);
return _2e4;
}})});
LFM.set("Ajax",{SideGroupedMulticompleter:Class.create(LFM.Ajax.GroupedMulticompleter,{init:function(){
this.update.addClassName("grouped sidegrouped");
},processResults:function(_2e8,list){
var _2ea=new Element("table",{cellspacing:0,cellpadding:0,border:0});
var _2eb=new Element("tbody");
var _2ec=0;
if(_2e8){
this.urls={};
var _2ed=this.groupResults(_2e8);
var _2ee,_2ef,_2f0,_2f1;
this.resTypeGroups.each(function(_2f2,_2f3){
if(_2ed[_2f2]){
_2ec++;
_2ee=new Element("tr");
if(_2ec%2==0){
_2ee.addClassName("alt");
}
_2f1=(_2f2==LFM.resTypes.USER)?LFM.String.resTypePlural["friends"]:LFM.String.resTypePlural[_2f2];
_2ef=new Element("h3").update(_2f1).addClassName(LFM.resTypeLookup[_2f2].toLowerCase());
_2f0=new Element("ul");
_2ed[_2f2].each(function(_2f4,_2f5){
this.addLinkedItem(_2f4,_2f0);
},this);
_2ee.insert(new Element("th").update(_2ef));
var _2f6=new Element("td").update(_2f0);
if(_2ec==1){
_2f6.addClassName("first");
}
_2ee.insert(_2f6);
_2eb.insert(_2ee);
}
},this);
}
var _2f7=new Element("tr");
if(_2ec%2==0){
_2f7.addClassName("alt");
}
var _2f8=new Element("ul");
this.addViewAll(_2f8,_2e8.length);
_2f7.insert(new Element("th"));
_2f7.insert(new Element("td",{"class":"viewAll"}).update(_2f8));
_2eb.insert(_2f7);
_2ea.update(_2eb);
return _2ea;
}})});
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,_2fa){
Object.extend(this.options,_2fa);
this._ajaxUrl=url;
if(this.options.lazyness){
this.options.laziness=this.options.lazyness;
}
},send:function(_2fb){
if(this._intervalId){
clearTimeout(this._intervalId);
}
var now=new Date();
this._lastTime=now.getTime()/1000;
this._ajaxOptions=this._defaultAjaxOptions;
if(_2fb){
if(_2fb.parameters){
Object.extend(this._ajaxOptions.parameters,_2fb.parameters);
_2fb.paramaters=this._ajaxOptions.parameters;
}
Object.extend(this._ajaxOptions,_2fb);
}
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(_2fd){
try{
if(typeof _2fd=="string"){
this.ajaxResponse=_2fd.evalJSON();
}else{
if(_2fd.responseText){
this.ajaxResponse=_2fd.responseText.evalJSON();
}else{
this.ajaxResponse=_2fd;
}
}
}
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,_300){
return this.data.set(key,_300);
},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 _302=this.getResource();
if(_302){
var link=new Element("a",{"href":_302.url});
if(_302.name){
link.update(_302.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,_305,_306){
new Ajax.Request("/ajax/setUserPref",{parameters:{formtoken:LFM.Session.formtoken,pref:pref,value:_305},onComplete:function(_307){
var _308=new LFM.Ajax.Response(_307);
if(_306){
_306(_308);
}
}});
};
LFM.Ajax.StatusHolder=Class.create({initialize:function(_309,_30a){
this.status="idle";
this.element=$(_309);
this.options={position:"after"};
Object.extend(this.options,_30a);
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";
}});

