LFM.set("Activityfeed",{DeleteListener:Class.create({initialize:function(){
document.observe("click",this.bin.bindAsEventListener(this));
},bin:function(_1){
var _2=_1.findElement("a.removeActivity");
if(!_2){
return;
}
_1.stop();
var _3=_2.up("li");
new Ajax.Request("/ajax/deleteActivity",{parameters:{ajax:1,activities:_3.id,formtoken:LFM.Session.formtoken},onComplete:function(_4){
var _5=new LFM.Ajax.Response(_4);
if(_5.isSuccess()){
_3.remove();
}
}});
}})});
LFM.set("Activity",{buildFeedItem:function(_6){
var _7=new Element("ul",{"class":"minifeedSmall"});
var li=new Element("li",{"class":_6.action});
if(_6.icon){
li.insert(_6.icon);
}
li.insert(_6.message);
_7.update(li);
return _7;
}});
LFM.set("Util",{AdblockDetector:Class.create({initialize:function(){
},isBlocking:function(){
if(LFM.Session.language!="en"){
return false;
}
return this.isABP();
},isABP:function(){
return this.isEasyList();
},isEasyList:function(){
if($("footer_ads")&&$("footer_ads").visible()&&$("footer_ads").getStyle("-moz-binding")){
return $("footer_ads").getStyle("-moz-binding").include("abp-elemhidehit");
}
}})});
LFM.set("Library",{AddListener:Class.create({options:{},initialize:function(_9,_a){
this.bindTo=$(_9);
this.bindTo.observe("click",this._onClick.bindAsEventListener(this));
Object.extend(this.options,_a||{});
},_onClick:function(e){
var _c=e.element();
if(!_c||!_c.hasClassName("lfmAddButton")){
return true;
}
e.stop();
this._showDialog(this.options.resource||{url:_c.getAttribute("href")});
},_showDialog:function(_d){
var _e="/ajax/dialog/add";
var _f={resource:_d,onConfirm:this._onConfirmDialog.bindAsEventListener(this)};
this._dialog=new LFM.Dialog(_f);
this._dialog.show(_e);
},_onConfirmDialog:function(e){
}})});
LFM.set("Adserver",{getSponsoredByBranding:function(_11,_12,_13,_14){
var _15=new Element("div",{"class":"brand"});
if(!_14){
var _16=new Element("img",{"class":"sponsored",src:LFM.Session.staticHost+"/promotions/notifications_presented_grey.gif",width:88,height:5}).setStyle({padding:"2px 0"});
}
var _17=new Element("img",{src:_11,width:1,height:1}).setStyle({position:"absolute",top:0,left:0,visibility:"hidden"});
if(_12){
var _18=new Element("img",{src:_12,width:88,height:31});
if(_13){
_18=_18.wrap(new Element("a",{href:_13,target:"_blank"}));
}
if(_16){
_15.insert(_16);
}
_15.insert(_18);
}
_15.insert(_17);
return _15;
}});
LFM.set("Library",{AlbumStrip:Class.create({initialize:function(_19){
this._albumstrip=$(_19);
this._albumstrip.addClassName("js");
this._wrapper=this._albumstrip.down("div.wrapper");
this._wrapper.setStyle({overflow:"hidden"});
this._list=this._wrapper.down("ul");
if(this._list){
this._listItems=this._list.childElements();
}
this._currentFilterName=false;
this._leftButton=new Element("a",{"class":"leftButton",href:"#"});
this._rightButton=new Element("a",{"class":"rightButton",href:"#"});
this._albumstrip.insert(this._leftButton);
this._albumstrip.insert(this._rightButton);
this._offset=0;
this._itemcount=this._listItems?this._listItems.length:0;
var _1a=Prototype.Browser.WebKit?window:document;
var _1b=Prototype.Browser.WebKit?"load":"dom:loaded";
Event.observe(_1a,_1b,function(){
this._itemwidth=this._list.down("li").getWidth();
this._reflow();
Event.observe(window,"resize",this._reflow.bindAsEventListener(this));
this._leftButton.observe("click",this.scrollLeft.bindAsEventListener(this));
this._rightButton.observe("click",this.scrollRight.bindAsEventListener(this));
}.bind(this));
},setUpFilter:function(_1c){
this._filteredTable=$(_1c);
startTimer("setUpFilter");
this._filterDataTable={};
this._filterDataTable.albums=[];
this._filterDataTable.everything=this._filteredTable.select("tbody tr");
this._filterDataTable.everything.each(function(row){
var _1e=row.className.split(" ");
_1e.each(function(_1f){
if(_1f.substring(0,5)=="album"){
if(!this._filterDataTable.albums[_1f]){
this._filterDataTable.albums[_1f]=[];
}
this._filterDataTable.albums[_1f].push(row);
}
}.bind(this));
}.bind(this));
stopTimer("setUpFilter");
this._albumstrip.observe("click",this._filter.bindAsEventListener(this));
},_filter:function(_20){
if(!this._maxHeight){
this._maxHeight=this._filteredTable.up().getHeight();
this._filteredTable.up().setStyle({height:this._maxHeight+"px"});
var _21=this._filterDataTable.everything.first().select("td");
var _22=this._filteredTable.down("thead tr").select("th");
for(var i=_22.length-1;i>=0;i--){
var _24=_21[i].getWidth();
var _24=_24-20;
_22[i].setStyle({width:_24+"px"});
}
}
var _25=_20.findElement("a");
if(!_25){
return;
}
_20.stop();
if(_25.up("h3")){
_25.up("h3").addClassName("current");
this._listItems.invoke("removeClassName","selected");
if(!this._currentFilterName){
return;
}else{
this._currentFilterName=false;
this._filteredTable.show();
$("noTracksMessage").hide();
this._filterDataTable.everything.invoke("show");
LFM.Display.candyStripe(this._filteredTable);
}
}else{
var _26=_25.up("li").className.split(" ");
var _27="";
_26.each(function(_28){
if(_28.substring(0,5)=="album"){
_27=_28;
}
}.bind(this));
if(_27){
this._albumstrip.down("h3").removeClassName("current");
this._listItems.invoke("removeClassName","selected");
_25.up("li").addClassName("selected");
this._currentFilterName=_27;
this._filterDataTable.everything.invoke("hide");
if(this._filterDataTable.albums[_27]){
this._filterDataTable.albums[_27].invoke("show");
LFM.Display.candyStripe(this._filterDataTable.albums[_27]);
this._filteredTable.show();
$("noTracksMessage").hide();
}else{
this._filteredTable.hide();
$("noTracksMessage").show();
}
}else{
return;
}
}
},scrollRight:function(_29){
if(_29){
_29.stop();
}
var _2a=this._offset-this._itemwidth;
if(_2a*-1>this._list.getWidth()-this._wrapper.getWidth()){
_2a=this._wrapper.getWidth()-this._list.getWidth();
}
this._offset=_2a;
new Effect.Morph(this._list,{style:{left:_2a+"px"},duration:0.3,queue:{position:"end",scope:"scrollscope"}});
},scrollLeft:function(_2b){
if(_2b){
_2b.stop();
}
var _2c=this._offset+this._itemwidth;
if(_2c>0){
_2c=0;
}
this._offset=_2c;
new Effect.Morph(this._list,{style:{left:_2c+"px"},duration:0.3,queue:{position:"end",scope:"scrollscope"}});
},_reflow:function(){
var _2d=true;
var _2e=this._albumstrip.getWidth()-this._leftButton.getWidth()-this._rightButton.getWidth();
log(_2e);
var _2f=Math.floor(_2e/this._itemwidth);
if(_2f>=this._itemcount){
_2d=false;
_2f=this._itemcount;
}
var _30=_2f*this._itemwidth;
this._wrapper.setStyle({width:_30+"px"});
if(_2d){
this._leftButton.show();
this._rightButton.show();
}else{
this._leftButton.hide();
this._rightButton.hide();
}
}})});
LFM.set("Form",{Attachbutton:Class.create({initialize:function(_31,_32){
this.button=$(_31);
if(!_32){
_32={};
}
this.options=_32;
this._bindToButton();
},_bindToButton:function(){
Event.observe(this.button,"click",function(e){
Event.stop(e);
var _34=new LFM.Form.ResourcePicker({onSelect:this._onSelect.bind(this)});
_34.show();
}.bindAsEventListener(this));
},_onSelect:function(res){
if(res){
this._appendAttachment(res.type,res.id);
}
},_appendAttachment:function(_36,id){
if(!this.itemcontainer&&this.options.itemcontainer){
this.itemcontainer=$(this.options.itemcontainer);
}
if(this.itemcontainer){
this.itemcontainer.show();
this.itemcontainer.down("img.progress").show();
new Ajax.Request("/ajax/attachment",{method:"get",parameters:"type="+_36+"&id="+id,onComplete:this._appendAttachmentCallback.bind(this)});
}
var _38=this.button.up("form");
if(_38){
var _39=_38.down("input[name=attachmenttype]");
var _3a=_38.down("input[name=attachmentid]");
if(!_39){
var _39=document.createElement("input");
_39.setAttribute("type","hidden");
_39.setAttribute("name","attachmenttype");
var _3a=document.createElement("input");
_3a.setAttribute("type","hidden");
_3a.setAttribute("name","attachmentid");
_39.setAttribute("value",_36);
_3a.setAttribute("value",id);
_38.appendChild(_39);
_38.appendChild(_3a);
}else{
_39.setAttribute("value",_36);
_3a.setAttribute("value",id);
}
}
},_appendAttachmentCallback:function(req){
var _3c=req.responseText.evalJSON();
if(this.itemcontainer){
this.itemcontainer.insert({top:_3c.attachment});
this.itemcontainer.down("img.progress").hide();
}
}})});
LFM.set("Button",{MultiButton:{setup:function(){
this.activeButton=false;
this.menu=$("multiButtonMenu");
this.loadedInfo=$H();
this.menu.observe("click",this.observeMenu.bindAsEventListener(this));
$("page").observe("click",this.observeDocument.bindAsEventListener(this));
this.clickOffObserver=this.clickOff.bindAsEventListener(this);
this.parentIsUser=LFM.ParentResource&&LFM.ParentResource.type==4;
this.parentIsLoggedInUser=LFM.Session.loggedIn&&this.parentIsUser&&LFM.ParentResource.name==LFM.Session.userName;
},observeDocument:function(e){
var _3e=e.findElement("a.lfmMultiButton");
if(!_3e){
return false;
}
e.stop();
if(this.activeButton&&this.activeButton!=_3e){
this.clickOff();
}else{
if(this.activeButton&&this.activeButton==_3e){
this.clickOff();
return;
}
}
this.activeButton=_3e;
if(this.activeButton.hasClassName("lfmSmallButton")){
this.activeButton.addClassName("lfmSmallActiveMultiButton");
}else{
this.activeButton.addClassName("lfmBigActiveMultiButton");
}
this.updatePriceFromAjax();
if(LFM.Session.loggedIn&&!this.parentIsLoggedInUser&&_3e.hasClassName("lfmButtonFortrack")){
this.updateMenuFromAjax(this.activeButton);
}else{
this.showMenu(this.activeButton);
}
document.observe("click",this.clickOffObserver);
},clickOff:function(){
this.hideMenu(this.activeButton);
this.activeButton.removeClassName("lfmSmallActiveMultiButton");
this.activeButton.removeClassName("lfmBigActiveMultiButton");
this.activeButton=false;
this.menu.down("li.mBuy a span").remove();
document.stopObserving("click",this.clickOffObserver);
},updatePriceFromAjax:function(){
this.menu.down("li.mBuy a").insert(" <img class=\"loading\" src=\""+LFM.Session.staticHost+"/flatness/spinner_13x13.gif\" height=\"7\" />");
var _3f=new Ajax.Request("/ajax/affiliableprice",{parameters:{url:this.activeButton.href,cachebuster:Math.round(Math.random()*100)},method:"get",onComplete:function(_40){
this.menu.down("li.mBuy a img").remove();
if(_40.responseText){
this.menu.down("li.mBuy a").insert(" "+_40.responseText);
}
}.bind(this)});
},updateMenuFromAjax:function(_41){
var _41=_41;
if(this.loadedInfo.get(_41.href)){
_41.className=this.loadedInfo.get(_41.href);
this.sortOutClassNames(_41);
this.showMenu(_41);
}else{
var _42=new Ajax.Request("/ajax/library/gettrackinfo",{parameters:{url:_41.href,cachebuster:Math.round(Math.random()*100)},method:"get",onComplete:function(_43){
var _44=new LFM.Ajax.Response(_43);
if(_44.isSuccess()){
if(_44.get("loved")){
_41.removeClassName("mLove");
_41.addClassName("mUnlove");
}else{
_41.addClassName("mLove");
_41.removeClassName("mUnlove");
}
if(_44.get("banned")){
_41.removeClassName("mBan");
_41.addClassName("mUnban");
}else{
if(_41.hasClassName("lfmMultiButtonAllowBan")){
_41.addClassName("mBan");
}
_41.removeClassName("mUnban");
}
if(_41.hasClassName("lfmMultiButtonFull")){
if(_44.get("playcount")!==null){
_41.addClassName("mRemoveFromLibrary");
_41.removeClassName("mAddToLibrary");
}else{
_41.removeClassName("mRemoveFromLibrary");
_41.addClassName("mAddToLibrary");
}
}
this.loadedInfo.set(_41.href,_41.className);
}
if(_41==this.activeButton&&!_42.shown){
this.sortOutClassNames(_41);
this.showMenu(_41);
}
}.bind(this)});
(function checkTimeout(){
if(!(_42&&_42.getStatus()==200)&&_41==this.activeButton){
_42.shown=true;
this.sortOutClassNames(_41);
this.showMenu(_41);
}
}).bind(this).delay(0.5);
}
},showMenu:function(_45,_46){
var _46=_46||{};
var _47=_45.cumulativeOffset();
var _48=$("page").cumulativeOffset();
_47.left=_47.left-7-_48.left;
_47.top=_47.top+_45.getHeight()-_48.top;
var _49=this.activeButton.getWidth();
if(Prototype.Browser.IE){
if(window.external&&typeof window.XMLHttpRequest=="undefined"){
_47.left=_47.left-35;
}else{
if(_45.hasClassName("lfmSmallMultiButton")&&_45.up("div.module")){
_47.left=_47.left-15;
}
}
}
this.menu.setStyle({top:_47.top+"px",left:_47.left+"px"});
var _4a=this.menu.down("ul");
_49=_49-_4a.getStyle("border-left-width").toPixels()-_4a.getStyle("border-right-width").toPixels()-_4a.getStyle("padding-left").toPixels()-_4a.getStyle("padding-right").toPixels();
_4a.setStyle({minWidth:_49+"px"});
$w("tr li").each(function(_4b){
var _4c=_45.up(_4b);
if(_4c){
_4c.addClassName("open");
}
});
var _4d=_46.showLoadingState?"mLoading":false;
this.sortOutClassNames(_45,_4d);
this.menu.show();
},hideMenu:function(_4e){
$w("tr li").each(function(_4f){
var _50=_4e.up(_4f);
if(_50){
_50.removeClassName("open");
}
});
this.menu.down("ul").setStyle({minWidth:"0px"});
this.menu.hide();
},sortOutClassNames:function(_51,_52){
if(_52){
this.menu.className=_52;
this.menu.down("div").className=_52;
}else{
var _53=_51.className.match(/\blfmButtonFor([a-z]*)\b/)[1];
_53+="MultiMenu";
this.menu.className=_53;
var _54=_51.className;
this.menu.down("div").className=_54;
}
},observeMenu:function(e){
e.stop();
var _56=this.activeButton.hasClassName("lfmBigMultiButton")?"moreBtn":"multiBtn";
LFM.Omniture.prepareEvar("ClickSource",_56);
var _57=e.findElement("li").className;
if(Prototype.Browser.IE){
_57=_57.replace(/\b\w*hover_/gi,"").strip();
}
switch(_57){
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(_58){
var _59=LFM.get("Page","LibraryDeleteListener");
var _5a=LFM.get("Page","LibraryRemoveTagFromItemListener");
if(_59){
_59.onDone(_58);
}
if(_5a){
_5a.onSuccess(_58);
}
}});
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(_5b,_5c){
var _5d=this.activeButton;
new Ajax.Request("/ajax/library/love",{parameters:{ajax:true,url:_5d.href,loved:_5c,formtoken:LFM.Session.formtoken},onSuccess:function(_5e){
var _5f=new LFM.Ajax.Response(_5e);
if(_5f.isSuccess()){
var _60=_5d.up("tr");
var _61=_5d.up("li");
if(_60){
if(_60.hasClassName("odd")&&_60.up("table").hasClassName("chart")){
var _62="#f4f4f4";
}else{
var _62="#ffffff";
}
}
if((!this.parentIsUser||this.parentIsLoggedInUser)&&_60){
var _63=_60.down("td.lovedCell");
}else{
if(LFM.ParentResource&&LFM.ParentResource.type==9&&$("lovedIndicator")){
if(_5c){
if(LFM.Page.onAddToLibrary){
LFM.Page.onAddToLibrary(_5f);
}
$("lovedIndicator").show();
}else{
$("lovedIndicator").hide();
}
}
}
this.loadedInfo.unset(_5d.href);
if(_5c){
LFM.Omniture.trackEvents("LoveTrack");
_5d.removeClassName("mLove");
_5d.addClassName("mUnlove");
if(_63){
_63.insert({top:LFM.Element.icon_loved_indicator});
}
if(_61){
_61.addClassName("loved");
}
var _64=_5f.get("activity");
if(_64){
var _65=LFM.Activity.buildFeedItem(_64);
if(LFM.Adserver.showAds&&LFM.Session.location=="us"){
var _66=LFM.Adserver.getATTNotificationBranding();
}
var _67=new Element("div");
_67.insert(_66);
_67.insert(_65);
LFM.Notification.send(_67);
}
}else{
_5d.addClassName("mLove");
_5d.removeClassName("mUnlove");
if(_63){
var _68=_63.down("img.loved_indicator_icon");
if(_68){
_68.remove();
}
}
if(_61){
_61.removeClassName("loved");
}
}
if(_63){
new Effect.Highlight(_60,{endcolor:_62,afterFinish:function(_69){
_69.element.removeAttribute("style");
}});
}
}
}.bind(this)});
},ban:function(_6a,_6b){
var _6c=this.activeButton;
new Ajax.Request("/ajax/library/ban",{parameters:{ajax:true,url:_6c.href,banned:_6b,formtoken:LFM.Session.formtoken},onSuccess:function(_6d){
var _6e=new LFM.Ajax.Response(_6d);
if(_6e.isSuccess()){
var _6f=_6c.up("tr");
if(_6f){
if(_6f.hasClassName("odd")&&_6f.up("table").hasClassName("chart")){
var _70="#f4f4f4";
}else{
var _70="#ffffff";
}
}
if(LFM.ParentResource){
if(this.parentIsLoggedInUser&&_6f){
var _71=_6f.down("td.bannedCell");
}else{
if(LFM.ParentResource.type==9&&$("bannedIndicator")){
if(_6b){
$("bannedIndicator").show();
}else{
$("bannedIndicator").hide();
}
}
}
}
this.loadedInfo.unset(_6c.href);
if(_6b){
if(_71){
_71.insert({top:LFM.Element.icon_banned_indicator});
}
}else{
if(_71){
var _72=_71.down("img.banned_indicator_icon");
if(_72){
_72.remove();
}
}
}
if(_6f){
new Effect.Fade(_6f,{duration:0.5});
}
}
}.bind(this)});
}},affiliations:{"suppliers[]":[],"restypes[]":[],"resids[]":[]},pushAffiliation:function(_73,_74,_75){
LFM.Button.affiliations["suppliers[]"].push(_73);
LFM.Button.affiliations["restypes[]"].push(_74);
LFM.Button.affiliations["resids[]"].push(_75);
}});
LFM.set("Charts",{Switch:Class.create({initialize:function(_76,_77){
this.container=$(_76);
this.parameters=_77;
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(_78){
var _79=this.getRangeTypeFromClassName(_78.className);
if(_79){
this.cachedcharts.set(_79,_78);
}
}.bind(this));
},switchChartEvent:function(_7a){
var _7b=_7a.element();
if(!_7b.match("a")){
return;
}
_7a.stop();
var _7c=_7b.up("li");
if(_7c.hasClassName("current")){
return;
}
this.container.down("div.horizontalOptions ul").childElements().invoke("removeClassName","current");
_7c.addClassName("current");
var _7d=this.getRangeTypeFromClassName(_7c.className);
this.switchChart(_7d);
},refresh:function(){
this.cachedcharts=new Hash();
this.switchChart();
},switchChart:function(_7e){
if(_7e&&this.cachedcharts.get(_7e)){
this.cachedcharts.each(function(_7f){
_7f.value.hide();
});
this.cachedcharts.get(_7e).show();
if(this.morelink){
this.morelink.href=this.container.down("ul li.chart"+_7e+" a").href;
}
}else{
var _80=Object.extend(this.parameters,{rangetype:_7e,ajax:1,cachebuster:Math.round(Math.random()*100)});
new Ajax.Request("/module",{method:"get",parameters:_80,onComplete:function(t){
var _82=new LFM.Ajax.Response(t);
if(_82.isSuccess()){
this.container.insert({bottom:_82.get("content").strip()});
var _83=!_7e;
var _84=this.container.childElements().last();
ieHover.add(_84);
if(!_7e){
_7e=this.getRangeTypeFromClassName(_84.className);
this.container.down("div.horizontalOptions ul").childElements().invoke("removeClassName","current");
this.container.down("div.horizontalOptions ul li.chart"+_7e).addClassName("current");
}
this.cachedcharts.set(_7e,_84);
if(this.morelink){
this.morelink.up().insert({before:this.cachedcharts.get(_7e)});
}
if(_83){
this.container.select("div.chart").each(function(_85){
if(_85!=_84){
_85.remove();
}
}.bind(this));
}
this.cachedcharts.each(function(_86){
if(_86.key!=_7e){
_86.value.hide();
}
});
this.cachedcharts.get(_7e).show();
if(this.morelink){
this.morelink.href=this.container.down("ul li.chart"+_7e+" 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(_87){
var _88=_87.match(/chart[^ ]+/)[0];
return _88.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 _8a=new Array("a","u","c","x","v","j");
if(key.ctrlKey||key.metaKey){
for(i=0;i<_8a.length;i++){
var _8b=key.keyCode;
if(_8a[i].toLowerCase()==String.fromCharCode(_8b).toLowerCase()){
key.stop();
return false;
}
}
}
},cancelContextMenu:function(e){
e.stop();
return false;
},disableSelect:function(e){
var _8e=new Array("input","select","textarea","radio","checkbox");
var _8f=false;
for(var i=0;i<_8e.length;i++){
if(e.target.tagName.toLowerCase()==_8e[i]){
_8f=true;
}
}
if(!_8f){
e.stop();
return false;
}
},enableSelect:function(e){
return true;
}});
LFM.set("Display",{candyStripe:function(_92,_93){
var _93=_93||false;
if(is_array(_92)){
var _94=_92;
}else{
_92=$(_92);
if(_93.selector){
var _94=_92.select(_93.selector);
}else{
if(_92.tagName=="TABLE"){
_92=_92.down("tbody");
}
var _94=_92.childElements();
}
}
if(_94.length>0){
_94[0].up("table").addClassName("candyStriped");
_94.each(function(row,i){
if(i%2){
row.removeClassName("odd");
}else{
row.addClassName("odd");
}
row.removeClassName("first");
row.removeClassName("last");
if(_93.renumber){
var _97=row.down("td.position");
if(_97){
_97.update(i+1);
}
}
});
_94.first().addClassName("first");
_94.last().addClassName("last");
}
}});
document.observe("dom:loaded",function(_98){
$$(".downloadDriver").each(function(_99){
_99.observe("click",function(e){
var el=e.findElement("a");
if(el&&el.match("a")){
var _9c=LFM.get("Page","hasManualAdded");
var _9d="New user download CTA ("+(_9c?"after":"before")+" library add)";
LFM.Omniture.setLink(el,_9d);
LFM.Omniture.prepareEvar("ClickSource",_9c?"downloadAfterManualAdd":"downloadBeforeManualAdd");
LFM.Omniture.trackEvents();
}
});
});
});
LFM.set("Display",{DropDown:Class.create({initialize:function(_9e,_9f,_a0,_a1){
this.container=$(_9e);
this.toggler=$(_9f);
this.ddbody=$(_a0);
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=_a1||{};
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 _a2=this.container.cumulativeOffset();
var _a3=$("page").cumulativeOffset();
_a2.left=_a2.left-_a3.left;
_a2.top=_a2.top+this.container.getHeight()-_a3.top;
if(Prototype.Browser.IE&&this.container.getStyle("display")=="inline-block"){
var _a4=this.toggler.getWidth();
}else{
var _a4=this.container.getWidth();
}
var _a5=$("page").getWidth();
if((this.options.align&&this.options.align=="right")||((_a2.left+this.ddbody.getWidth())>_a5)){
var _a6=(_a5-_a4-_a2.left)+"px";
var _a7="auto";
}else{
var _a7=_a2.left+"px";
var _a6="auto";
if(Prototype.Browser.IE){
if(window.external&&typeof window.XMLHttpRequest=="undefined"){
_a7=(_a2.left-35)+"px";
}
}
}
if(!this.options.autoWidth){
_a4=_a4-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:_a4+"px"});
if(this.use_iframe){
this.iframe.setStyle({minWidth:_a4+"px"});
}
}
this.ddbody.setStyle({top:_a2.top+"px",left:_a7,right:_a6}).show();
var _a8=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(_aa){
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(_aa.findElement("A")){
_aa.findElement("A").blur();
}
_aa.stop();
},clickOff:function(_ab){
var _ac=Event.element(_ab);
var _ad=false;
while(_ac.parentNode){
if(_ac==this.ddbody){
return true;
}else{
if(_ac==this.toggler){
_ad=true;
}
}
_ac=_ac.parentNode;
}
this.hide();
if(_ad){
_ab.stop();
}
},trackItemClick:function(e){
var _af=e.findElement("a");
if(_af){
var _b0=_af.className;
var _b1=this.container.identify();
var _b2=_af.up("li");
if(_b2){
_b0=_b2.className;
}
LFM.Omniture.setLink(_af,_b1+":"+_b0);
LFM.Omniture.prepareEvar("ClickSource",_b1);
LFM.Omniture.trackEvents("Click");
}
}})});
var EventCalendar={calendars:null,currentMonth:null,lastRequested:null,next:function(url,_b4,_b5){
_b4.blur();
Element.addClassName(_b4,"busy");
var c=EventCalendar.getCurrentMonth();
var _b7=_b5?EventCalendar.getMonthForTable(c):EventCalendar.getNextMonthAfterTable(c);
var _b8=null;
var _b9=null;
if(!_b5){
_b9=document.getElementsByClassName("month-"+_b7,$("calendar"));
_b8=_b9.length>0?_b9[0]:false;
}else{
var m=EventCalendar.getPrevMonthAfterTable(c);
_b9=document.getElementsByClassName("month-"+m,$("calendar"));
_b8=_b9.length>0?_b9[0]:false;
}
if(_b8){
c.style.display="none";
_b8.style.display="table";
EventCalendar.currentMonth=_b8;
Element.removeClassName(_b4,"busy");
}else{
if(_b8==-1){
Element.removeClassName(_b4,"busy");
}else{
url=EventCalendar.convertURL(url);
EventCalendar.lastRequested=_b7;
var _bb=new Ajax.Request(url+"&startdate="+_b7+"-01",{onSuccess:EventCalendar.receiveMonth.bind(_b4),onFailure:EventCalendar.receiveMonthFailed.bind(_b4)});
}
}
},prev:function(url,_bd){
EventCalendar.next(url,_bd,true);
},convertURL:function(url){
url=url.replace(/^\/events/,"");
return "/events/calendar"+url;
},receiveMonth:function(_bf){
if(_bf.responseText.indexOf("calendar")==-1){
var _c0=EventCalendar.receiveMonthFailed.bind(this);
_c0();
return;
}
Element.removeClassName(this,"busy");
new Insertion.Bottom("calendar",_bf.responseText);
var _c1=document.getElementsByClassName("calendar",$("calendar"));
if(_c1.length>0){
EventCalendar.currentMonth.style.display="none";
_c1[_c1.length-1].style.display="table";
EventCalendar.currentMonth=_c1[_c1.length-1];
}
},receiveMonthFailed:function(){
Element.removeClassName(this,"busy");
},getNextMonthAfterTable:function(_c2){
var _c3=EventCalendar.getMonthForTable(_c2);
var _c4=_c3.split("-");
var _c5=_c4[0];
var _c6=_c4[1];
if(_c6==12){
_c6=1;
_c5++;
}else{
_c6++;
}
if(_c6<10){
_c6="0"+_c6;
}
return _c5+"-"+_c6;
},getPrevMonthAfterTable:function(_c7){
var _c8=EventCalendar.getMonthForTable(_c7);
var _c9=_c8.split("-");
var _ca=_c9[0];
var _cb=_c9[1];
if(_cb=="01"){
_cb=12;
_ca--;
}else{
_cb--;
}
if(_cb<10){
_cb="0"+_cb;
}
return _ca+"-"+_cb;
},getMonthForTable:function(_cc){
if(_cc.month){
return _cc.month;
}
var _cd=$A(_cc.className.split(/\s+/));
var c=_cd.find(function(c){
return c.substring(0,5)=="month";
});
_cc.month=c.substring(6);
return _cc.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(_d1,_d2,_d3){
this.inner_id=_d2;
this.outer_id=_d1;
this.embed_id=_d3;
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 _d4=this;
$(document).observe("click",function(e){
_d4.collapse();
});
$(this.inner_id).observe("click",function(e){
e.stop();
});
$(this.inner_id).observe("mouseover",function(e){
_d4.isCollapsing=false;
if(_d4.toggleState){
_d4.expand();
}
});
$(this.inner_id).observe("mouseout",function(e){
if(!_d4.isCollapsing){
_d4.isCollapsing=true;
setTimeout(function(){
if(_d4.isCollapsing){
_d4.collapse();
_d4.isCollapsing=false;
}
},2000);
}
});
$(this.embed_id).observe("focus",function(e){
_d4.expand();
_d4.toggleState=true;
});
$(this.embed_id).observe("blur",function(e){
_d4.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(_db,_dc){
if(typeof _dc!="undefined"){
this.required=_dc;
}
if(_db){
this.element=$(_db);
}
if(this.element){
if(this.element.match("input")||this.element.match("textarea")){
this.setUp(this.element);
}else{
this.element.select("input[placeholder]").each(function(_dd){
this.setUp(_dd);
}.bind(this));
}
}else{
if(!this.element){
$$("input[placeholder]").each(function(_de){
this.setUp(_de);
}.bind(this));
}
}
},setText:function(_df,_e0){
_df.setAttribute("placeholder",_e0);
if(!this.nativeSupport||_df.match("textarea")){
if($F(_df)==""||_df.hasClassName("hint")){
_df.addClassName("hint");
_df.value=_e0;
}
}
},clearPlaceholder:function(_e1,_e2){
if($F(_e1)==_e1.getAttribute("placeholder")){
_e1.removeClassName("hint");
_e1.value="";
}
_e2.disabled=true;
},resetPlaceholder:function(_e3,_e4){
if(!$F(_e3).strip()){
_e3.addClassName("hint");
_e3.value=_e3.getAttribute("placeholder");
_e4.disabled=false;
}
},setUp:function(_e5){
this.setText(_e5,_e5.getAttribute("placeholder"));
if(!this.nativeSupport||_e5.match("textarea")){
var _e6=new Element("input",{"type":"hidden","name":"placeholder","value":1});
_e5.insert({after:_e6});
_e5.observe("focus",function(e){
this.clearPlaceholder(_e5,_e6);
}.bind(this));
_e5.observe("blur",function(e){
this.resetPlaceholder(_e5,_e6);
}.bind(this));
if(this.required){
var _e9=_e5.up("form");
_e9.observe("submit",function(e){
this.clearPlaceholder(_e5,_e6);
}.bind(this));
}
}
}})});
LFM.set("Form",{focusToRange:0,focusTo:function(_eb,_ec){
if(typeof _ec=="undefined"){
_ec=_eb.value.length;
}
if(_eb.createTextRange){
if(LFM.Form.focusToRange==0){
LFM.Form.focusToRange=_eb.createTextRange();
}
LFM.Form.focusToRange.moveEnd("character",_eb.value.length);
LFM.Form.focusToRange.moveStart("character",_ec);
setTimeout("LFM.Form.focusToRange.select()",10);
}else{
if(_eb.setSelectionRange){
_eb.focus();
_eb.select();
_eb.setSelectionRange(_ec,_eb.value.length);
}else{
_eb.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(_ed){
_ed=$(_ed);
$(document.body).toggleClassName("lfmBlack");
_ed.blur();
var _ee,_ef;
if($(document.body).hasClassName("lfmBlack")){
_ee="red";
_ef="black";
_ed.update(LFM.String.toRedStr);
}else{
_ee="black";
_ef="red";
_ed.update(LFM.String.toBlackStr);
}
LFM.setCookie("LFM_Colour",_ef);
LFM.Omniture.prepareEvar("ClickSource","colorToggle:"+_ef);
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(_f0){
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 _f2=$("secondaryNavigation");
if(_f2){
var _f3=_f2.getHeight()-2;
var _f4=$("content");
if(_f4&&_f4.getHeight()<_f3){
var _f5=$$("#content > .rightCol");
_f5=_f5[0]||_f4;
if(_f5.match(".rightCol")){
_f4.setStyle("min-height: 0");
}
_f3-=_f5.getStyle("padding-top").toPixels(_f5);
_f3-=_f5.getStyle("padding-bottom").toPixels(_f5);
_f5.setStyle({minHeight:(_f3>300?_f3:300)+"px"});
}
}
});
}});
if(LFM&&LFM.get("config","DEVELOPMENT_SERVER")){
LFM.set("Timers",{});
}
function startTimer(_f6){
if(LFM&&LFM.get("config","DEVELOPMENT_SERVER")){
LFM.Timers[_f6]={};
LFM.Timers[_f6].startTime=new Date();
LFM.Timers[_f6].startTime=LFM.Timers[_f6].startTime.getTime();
}
}
function stopTimer(_f7){
if(LFM&&LFM.get("config","DEVELOPMENT_SERVER")){
if(LFM.Timers[_f7]){
LFM.Timers[_f7].endTime=new Date();
LFM.Timers[_f7].endTime=LFM.Timers[_f7].endTime.getTime();
log(LFM.Timers[_f7].endTime-LFM.Timers[_f7].startTime);
}else{
log("Timer "+_f7+" doesn\u2019t exist.");
}
}
}
function loadStyleSheet(_f8){
if(isset(document.createStyleSheet)){
document.createStyleSheet(_f8);
}else{
var _f9=document.createElement("link");
_f9.setAttribute("rel","stylesheet");
_f9.setAttribute("type","text/css");
_f9.setAttribute("href",_f8);
document.getElementsByTagName("head")[0].appendChild(_f9);
}
}
function is_array(obj){
return obj.constructor==Array;
}
function isset(obj){
return typeof obj!=="undefined";
}
String.prototype.pad=function(_fc,_fd,_fe){
if(_fc){
_fc=_fc-this.length;
}else{
return this;
}
var _ff=this;
if(_fd){
_fd=_fd+"";
}else{
_fd=" ";
}
if(!isset(_fe)){
_fe="STR_PAD_LEFT";
}
if(_fe=="STR_PAD_BOTH"){
var odd=_fc%2;
var side=_fc/2;
side=Math.round(side);
var left=_fd.times(side);
var _103=_fd.times(side-odd);
_ff=left+_ff+_103;
}else{
var _fd=_fd.times(_fc);
if(_fe=="PAD_STR_RIGHT"){
_ff=_ff+_fd;
}else{
_ff=_fd+_ff;
}
}
return _ff;
};
Number.prototype.toPixels=function(){
return this;
};
String.prototype.toPixels=function(_104){
var size=this.match(/^(-?)(\d+(?:.\d+)?)(px|pt|em|)$/i);
var _106=size[1]?-1:1;
var _107=size[2];
var unit=size[3].toLowerCase();
function rule(_109,unit){
var _10b=document.getElementById(unit+"Ruler");
if(!_10b){
_10b=document.createElement("div");
document.getElementsByTagName("BODY")[0].appendChild(_10b);
_10b.id=unit+"Ruler";
}
_10b.style.width=_109+unit;
return _10b.clientWidth*_106;
}
switch(unit){
case "px":
return _107*_106;
case "pt":
return rule(_107,unit);
case "em":
if(!_104){
log("It\u2019s better to give a reference element when calculating pixels from ems");
return rule(_107,unit);
}else{
var _10c=document.createElement(_104.tagName);
_10c.style.display="block";
_10c.style.position="absolute";
_10c.style.left="-9999px";
_10c.style.top="-9999px";
_10c.style.height="0";
_10c.style.padding="0";
_10c.style.border="0";
_10c.style.width=_107+unit;
_104.parentNode.appendChild(_10c);
returnValue=_10c.clientWidth;
_104.parentNode.removeChild(_10c);
return returnValue*_106;
}
default:
return _107*_106;
}
};
var CSSUtils={getCSSRule:function(_10d,_10e){
_10d=_10d.toLowerCase();
if(document.styleSheets){
for(var i=0;i<document.styleSheets.length;i++){
var _110=document.styleSheets[i];
var ii=0;
var _112=false;
do{
if(_110.cssRules){
_112=_110.cssRules[ii];
}else{
_112=_110.rules[ii];
}
if(_112){
if(_112.selectorText.toLowerCase()==_10d){
if(_10e=="delete"){
if(_110.cssRules){
_110.deleteRule(ii);
}else{
_110.removeRule(ii);
}
return true;
}else{
return _112;
}
}
}
ii++;
}while(_112);
}
}
return false;
},killCSSRule:function(_113){
return CSSUtils.getCSSRule(_113,"delete");
},addCSSRule:function(_114){
if(document.styleSheets){
if(!CSSUtils.getCSSRule(_114)){
if(document.styleSheets[0].addRule){
document.styleSheets[0].addRule(_114,null,0);
}else{
document.styleSheets[0].insertRule(_114+" { }",0);
}
}
}
return CSSUtils.getCSSRule(_114);
}};
function actsAsAspect(_115){
_115.yield=null;
_115.rv={};
_115.before=function(_116,f){
var _118=eval("this."+_116);
this[_116]=function(){
f.apply(this,arguments);
return _118.apply(this,arguments);
};
};
_115.after=function(_119,f){
var _11b=eval("this."+_119);
this[_119]=function(){
this.rv[_119]=_11b.apply(this,arguments);
return f.apply(this,arguments);
};
};
_115.around=function(_11c,f){
var _11e=eval("this."+_11c);
this[_11c]=function(){
this.yield=_11e;
return f.apply(this,arguments);
};
};
}
var ieHover={selector:"tr, li",add:function(_11f){
if(!(/MSIE (5|6|8)/).test(navigator.userAgent)){
return;
}
var _11f=_11f||false;
if(Object.isString(_11f)&&$(_11f)){
$(_11f).select(ieHover.selector).each(function(item){
ieHover.prepareItem(item);
});
}else{
if(Object.isElement(_11f)){
_11f=$(_11f);
if(_11f.match("tr, li")){
ieHover.prepareItem(_11f);
}else{
_11f.select(ieHover.selector).each(function(item){
ieHover.prepareItem(item);
});
}
}else{
if(Object.isArray(_11f)){
_11f.each(function(item){
ieHover.prepareItem(item);
});
}
}
}
},prepareItem:function(item){
item.observe("mouseenter",ieHover.mouseOver);
item.observe("mouseleave",ieHover.mouseOut);
},mouseOver:function(_124){
this.className=this.className.replace(/(\w+[^_\s]{2})\b/ig,"$1 $1hover_")+" hover_";
},mouseOut:function(_125){
this.className=this.className.replace(/\w+_\b/ig,"").replace(/\s+/ig," ");
},setUp:function(){
if(!(/MSIE (5|6|8)/).test(navigator.userAgent)){
return;
}
var _126=document.createStyleSheet();
var _127=[];
var _128;
var _129=document.styleSheets,l=_129.length;
for(var i=0;i<l;i++){
parseStylesheet(_129[i]);
}
function parseStylesheet(_12c){
if(_12c.imports){
try{
var _12d=_12c.imports,l=_12d.length;
for(var i=0;i<l;i++){
parseStylesheet(_12c.imports[i]);
}
}
catch(securityException){
}
}
try{
var _12f=(_128=_12c).rules;
var l=_12f.length;
var _131=false;
var _132=false;
for(var j=0;j<l;j++){
_131=_12f[j].selectorText;
_132=_12f[j].style.cssText;
if(_131.match(/(tr|li)(\.(\w*))*:hover/ig)&&_132){
_127.push([_131.replace(/(tr|li)(\.(\w*))*:hover/ig,"$1.$3hover_"),_132]);
}
}
}
catch(securityException){
}
}
var _134="";
for(var i=_127.length-1;i>=0;i--){
_134+=_127[i][0]+"\n{ "+_127[i][1]+"}\n";
}
_126.cssText=_134;
var _135=[];
var page=$("page");
ieHover.selector.split(",").each(function(weee){
_135.push($A(page.getElementsByTagName(weee.strip())));
});
_135=_135.flatten();
var i=_135.length-1;
for(i;i>=0;i--){
Event.observe(_135[i],"mouseenter",ieHover.mouseOver);
Event.observe(_135[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(_146,_147){
this.element=$(_146);
this.options={selectedClass:"selected"};
Object.extend(this.options,_147);
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(_14a){
_14a.stop();
_14a.element().blur();
var li=_14a.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(_14c,_14d){
this.container=$(_14c);
if(_14d){
Object.extend(this,_14d);
}
if(!this.onComplete){
this.onComplete=this._defaultOnComplete;
}
if(!this.resource){
this.resource=LFM.ParentResource;
}
this.container.observe("click",this.observeMenu.bindAsEventListener(this));
},observeMenu:function(_14e){
var link=_14e.findElement("a");
if(!link){
return;
}
if(link.hasClassName("mEdit")){
_14e.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")){
_14e.stop();
var _151={module:this.moduleName,type:this.resource.type,id:this.resource.id};
var url="/ajax/dialog/feeds?"+Object.toQueryString(_151);
this._dialog=new LFM.Dialog({classname:"feedDialog",onConfirm:function(_152){
_152.stop();
this.hide();
}});
this._dialog.show(url);
}else{
if(link.hasClassName("mPaste")){
_14e.stop();
var _153=$$(".modulechartsartists li.current a")[0].getAttribute("href");
var _154=/rangetype=([^&]*)/;
var _155=_153.match(_154)[1];
var _151={module:this.moduleName,type:this.resource.type,id:this.resource.id,period:_155};
var url="/ajax/dialog/pasteyourtaste?"+Object.toQueryString(_151);
this._dialog=new LFM.Dialog({classname:"pasteDialog",onConfirm:function(_156){
_156.stop();
this.hide();
}});
this._dialog.show(url);
}
}
}
},_defaultOnComplete:function(){
if(this.container.down(".module-body")){
var url="/module";
var _158={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,_158);
}
},_onConfirmDialog:function(_159,form){
_159.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(_15b){
var _15c=new LFM.Ajax.Response(_15b);
if(_15c.isSuccess()){
this.container.down(".module-body").replace(_15c.get("content"));
}else{
this.container.removeClassName("loading");
}
}}),onRefresh:function(_15d,_15e){
if(!LFM.Module.refreshers){
LFM.Module.refreshers={};
}
LFM.Module.refreshers[_15d]=_15e;
}});
LFM.set("Display",{MultiTuner:Class.create({initialize:function(form,_160){
this.uuid=Math.round(Math.random()*100000);
this.form=$(form);
this.restype=_160.restype;
this.sampleContent=$(_160.sampleContent);
this.slotID=_160.slotID||"slot"+this.uuid;
this.slotClass=_160.slotClass||"";
this.choices=$(_160.choices);
this.autocomplete=$(_160.autocomplete);
this.length=_160.length||3;
this.itemClass=_160.itemClass||"";
this.onSelect=_160.onSelect;
this.onDeselect=_160.onDeselect;
this.onResourceJSON=_160.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 _164=this.autocomplete.serialize(true);
if(!_164.placeholder&&_164.name){
this.select(_164.name.unescapeHTML());
this.autocomplete.down("input[name=name]").value="";
}
}.bind(this));
}
},setupSlots:function(_165){
var that=this;
var _167=$A($R(1,_165));
_167.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 _167.inject($H(),function(hash,i){
hash.set(i,false);
return hash;
});
},generate_item_id:function(_16c){
return "item"+this.uuid+"_"+_16c.toLowerCase().replace(/_/g,"__").replace(/ /g,"_");
},updateSampleContent:function(){
if(this.sampleContent&&this.restype){
var _16d=this.sampleContent.up("p");
if(!this.filled){
_16d.hide();
_16d.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(_16f){
var _170=new LFM.Ajax.Response(_16f);
if(_170.isError()){
var _171=that.sampleContent.up("p");
that.sampleContent.update();
_171.hide();
_171.next("p.noSampleContent").hide();
_171.next("p.sampleContentError").show();
}else{
var _172=_170.get("sampleContent");
var _171=that.sampleContent.up("p");
if(_172&&_172.items&&_172.items.length){
var _173=_172.items.inGroupsOf(3)[0].collect(function(item){
if(!item){
throw $break;
}
return item.res.name;
}).join(", ");
that.sampleContent.update(_173);
_171.next("p.noSampleContent").hide();
_171.next("p.sampleContentError").hide();
_171.show();
}else{
that.sampleContent.update();
_171.hide();
_171.next("p.sampleContentError").hide();
_171.next("p.noSampleContent").show();
}
}
}});
}
}
},fetchResourceJSON:function(_175,_176){
var that=this;
new Ajax.Request("/ajax/getResource",{method:"get",parameters:{"type":this.restype,"name":_175},onComplete:function(_178){
var _179=new LFM.Ajax.Response(_178);
that.onResourceJSON(_179,_176);
}});
},deselect:function(_17a){
var slot=this.selections.unset(_17a);
this.slots.set(slot,false);
var _17c=$(_17a);
_17c.remove();
$(_17a+"_input").remove();
this.filled--;
var _17d=this.matching_choices.get(_17a);
if(_17d){
_17d.removeClassName("disabled");
}
this.updateSampleContent();
if(this.onDeselect){
this.onDeselect(_17c);
}
},select:function(_17e){
var _17f=this.generate_item_id(_17e);
if(this.selections.get(_17f)){
this.deselect(_17f);
return false;
}
if(this.filled>=this.length){
return false;
}
if(this.choices){
var _180=this.choices.select("li").find(function(item){
return (item.down("a").innerHTML==_17e);
});
this.matching_choices.set(_17f,_180);
}
this.form.insert(new Element("input",{"type":"hidden","name":"names[]","value":_17e,"id":_17f+"_input"}));
var _182=new Element("a",{"href":"#","class":this.itemClass,"id":_17f}).observe("click",function(e){
e.stop();
this.deselect(_17f);
}.bind(this));
_182.insert(new Element("span").update(_17e));
var _184=this.slots.find(function(item){
return (item.value===false);
}).key;
var _186=$(this.slotID+_184);
_186.insert(_182);
this.selections.set(_17f,_184);
this.slots.set(_184,true);
this.filled++;
if(_180){
_180.addClassName("disabled");
}
this.updateSampleContent();
if(this.onResourceJSON){
this.fetchResourceJSON(_17e,_182);
}
if(this.onSelect){
this.onSelect(_17e,_182);
}
}})});
document.observe("dom:loaded",function(_187){
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 _189=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 _18b.events[name];
},prop:function(name){
return _18b.props[name];
},evar:function(name){
return _18b.evars[name];
},setProp:function(name,_18f){
if(this.isBlocked()){
return false;
}
this.tracker[this.prop(name)]=_18f;
},getProp:function(name){
if(this.isBlocked()){
return false;
}
return this.tracker[this.prop(name)];
},setEvar:function(name,_192){
if(this.isBlocked()){
return false;
}
this.tracker[this.evar(name)]=_192;
},getEvar:function(name){
if(this.isBlocked()){
return false;
}
return this.tracker[this.evar(name)];
},currentEvars:[],prepareEvar:function(name,_195){
if(this.isBlocked()){
return false;
}
this.setEvar(name,_195);
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(_197,_198){
if(this.isBlocked()){
return false;
}
this.linkElement=_197;
this.linkTitle=_198;
},clearLink:function(){
if(this.isBlocked()){
return false;
}
this.linkElement=null;
this.linkTitle=null;
},setLinkTrackEvars:function(){
if(this.isBlocked()){
return false;
}
var _199=["events"];
var _19a={};
this.currentEvars.each(function(name){
var _19c=this.evar(name);
_199.push(_19c);
_19a[name+"/"+_19c]=this.getEvar(name);
}.bind(this));
this.tracker.linkTrackVars=_199.join(",");
return _19a;
},setLinkTrackEvents:function(){
if(this.isBlocked()){
return false;
}
var _19d=[];
var _19e=Array.prototype.join.call(arguments,",");
for(var i=0;i<arguments.length;i++){
_19d.push(this.event(arguments[i]));
}
var _1a0=_19d.join(",");
this.tracker.events=_1a0;
this.tracker.linkTrackEvents=_1a0;
return _19e;
},track:function(_1a1){
if(this.isBlocked()){
return false;
}
this.tracker.tl(this.linkElement||true,"o",this.linkTitle||_1a1);
},trackEvents:function(){
if(this.isBlocked()){
return false;
}
this.resetTracker();
var _1a2=this.setLinkTrackEvents.apply(this,arguments);
var _1a3=this.setLinkTrackEvars();
var _1a4="TRACK: "+_1a2;
if(this.linkTitle){
_1a4+=" ("+this.linkTitle+") ";
}
LFM.log(_1a4);
LFM.info(this.linkElement);
LFM.dir(_1a3);
this.track(_1a2);
this.clearEvars();
this.clearLink();
}});
var _18b={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 _189());
});
})();
LFM.set("Input",{RichText:Class.create({hasFocus:false,busy:false,wordSeparators:" \t\n,.()!?|=-\\",initialize:function(div,_1a7){
this.div=$(div);
this.options=_1a7?_1a7:{};
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 _1ab=e.charCode||e.keyCode||e.which;
var s=String.fromCharCode(_1ab);
this.cancelOnDown=false;
if(this.specialKeyDown(_1ab,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 _1af;
if(s=="a"){
_1af="<lfm:artist>"+name.strip().escapeHTML()+"</lfm:artist>";
}else{
if(s=="m"){
_1af="<lfm:artist name=\""+name.strip().escapeHTML()+"\"><lfm:image size=\"small\" /></lfm:artist>";
}
}
this.replaceSelection(_1af,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(_1b4,sel){
new Ajax.Request("/ajax/richtextrenderer",{method:"post",parameters:{richtext:_1b4},onComplete:function(resp){
var out=resp.responseText.evalJSON();
var _1b8=sel.getRangeAt(0);
$(document.body).insert({bottom:out.rendered});
var node=$(document.body).lastChild;
node.remove();
_1b8.deleteContents();
_1b8.insertNode(node);
this.textarea.value+=out.richtext;
}});
},keyPress:function(e){
e=window.event||e;
var _1bb=e.charCode||e.keyCode||e.which;
var s=String.fromCharCode(_1bb);
if(this.specialKeyPress(_1bb,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 _1be=prev.parentNode;
var _1bf=prev.ownerDocument.createRange();
_1bf.setStartBefore(prev);
var _1c0=_1bf.createContextualFragment(s);
var n=_1be.replaceChild(_1c0,prev);
var _1bf=this.caret.ownerDocument.createRange();
_1bf.setStartBefore(this.caret.previousSibling);
var _1c2=_1bf.createContextualFragment(" ");
_1be.insertBefore(_1c2,this.caret.previousSibling);
}else{
this.caret.insert({before:s});
}
},_delete:function(prev){
var _1c4=false;
var _1c5=prev.previousSibling;
if(prev.nodeType==1){
if(prev.nodeName=="A"){
var _1c6=prev.firstChild;
prev.parentNode.replaceChild(_1c6,prev);
_1c6.unlinked=true;
var _1c7=this.textarea.selectionStart;
var tag="";
var i=_1c7-2;
while(i>=0&&(this.textarea.value.charAt(i)!="/")){
tag=this.textarea.value.charAt(i)+tag;
i--;
}
var _1ca=i;
var _1cb="<"+tag+">";
var _1cc=_1cb.length;
while(i>=0&&(this.textarea.value.substr(i,_1cc)!=_1cb)){
i--;
}
var _1cd=this.textarea.value.substr(0,i);
var _1ce=i+_1cc;
_1cd+=this.textarea.value.substr(_1ce,_1ca-_1ce-1);
_1cd+=this.textarea.value.substr(_1c7);
this.textarea.value=_1cd;
return;
}
}
if(prev.nodeValue=="\n"){
_1c4=true;
}
var _1cf=prev.parentNode;
if(prev.nodeType==3){
var _1c7=this.textarea.selectionStart;
var _1cd=this.textarea.value.substr(0,_1c7-1);
if(_1c7<this.textarea.value.length){
_1cd+=""+this.textarea.value.substr(_1c7);
}
this.textarea.value=_1cd;
if(this.textarea.createTextRange){
var _1d0=this.textarea.createTextRange();
_1d0.moveStart("character",_1c7-1);
_1d0.moveEnd("character",_1c7-1);
_1d0.select();
}else{
if(this.textarea.setSelectionRange){
this.textarea.setSelectionRange(_1c7-1,_1c7-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);
}
}
_1cf.removeChild(prev);
if(_1c5&&_1c5.nodeType==3&&_1c5.nodeValue.strip().empty()&&_1c5.nodeValue!="\n"){
var _1d1=_1c5.ownerDocument.createRange();
_1d1.setStartAfter(_1c5);
var nbsp=_1d1.createContextualFragment("&nbsp;");
_1cf.replaceChild(nbsp,_1c5);
_1c5=nbsp;
}
if(_1c4){
var _1c5=prev.previousSibling;
_1cf.removeChild(prev);
this.caret.previousSibling=_1c5;
this.caret.remove();
}
if(_1c5){
_1cf.insertBefore(this.caret,_1c5.nextSibling);
}
},specialKeyDown:function(_1d3,e){
if(_1d3>=37&&_1d3<=40&&!(e.ctrlKey||e.altKey||e.shiftKey||e.metaKey)){
var prev=this.caret.previousSibling;
var next=this.caret.nextSibling;
var _1d7=this.caret.parentNode;
if(_1d3==37&&prev){
this.caret.remove();
_1d7.insertBefore(this.caret,prev);
var _1d8=this.textarea.selectionStart;
if(this.textarea.createTextRange){
var _1d9=this.textarea.createTextRange();
_1d9.moveStart("character",_1d8-1);
_1d9.moveEnd("character",_1d8-1);
_1d9.select();
}else{
if(this.textarea.setSelectionRange){
this.textarea.setSelectionRange(_1d8-1,_1d8-1);
}
}
}else{
if(_1d3==39&&next){
this.caret.remove();
_1d7.insertBefore(this.caret,next.nextSibling);
var _1d8=this.textarea.selectionStart;
if(this.textarea.createTextRange){
var _1d9=this.textarea.createTextRange();
_1d9.moveStart("character",_1d8+1);
_1d9.moveEnd("character",_1d8+1);
_1d9.select();
}else{
if(this.textarea.setSelectionRange){
this.textarea.setSelectionRange(_1d8+1,_1d8+1);
}
}
}
}
this.textarea.focus();
return true;
}else{
if(_1d3==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(_1d3==8){
if(this.caret.previousSibling){
this._delete(this.caret.previousSibling);
}
return true;
}else{
if(_1d3==13){
this.caret.insert({before:"<br />"});
this.textarea.value+="<br />";
return true;
}
}
}
}
},specialKeyPress:function(_1da,e){
var s=String.fromCharCode(_1da);
if(this.cancelOnDown){
return true;
}
if(this.wordSeparators.indexOf(s)>=0){
var _1dd=this.caret;
if(_1dd.previousSibling&&_1dd.previousSibling.nodeType==3&&!_1dd.previousSibling.unlinked){
var back=0;
var name="";
var _1e0;
while((_1dd=_1dd.previousSibling)&&_1dd.nodeType==3&&_1dd.nodeValue.unescapeHTML().strip()!=""){
name=_1dd.nodeValue+name;
back++;
}
_1e0=_1dd;
var _1e1=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+)*)?/)){
_1e1="<a href=\""+name.escapeHTML()+"\">"+name.escapeHTML()+"</a>";
}else{
var _1e2=name.toUpperCase();
var _1e3=this.artists.find(function(a){
return a.toUpperCase()==_1e2;
});
if(_1e3){
_1e1="<lfm:artist>"+name.escapeHTML()+"</lfm:artist>";
}
}
if(_1e1){
var _1e5=this.textarea.selectionStart;
new Ajax.Request("/ajax/richtextrenderer",{method:"post",parameters:{richtext:_1e1},onComplete:function(resp){
var out=resp.responseText.evalJSON();
var _1e8=_1e0.nextSibling;
for(;back>0;back--){
var tmp=_1e8.nextSibling;
_1e8.parentNode.removeChild(_1e8);
_1e8=tmp;
}
if(_1e0){
var _1ea=_1e0.ownerDocument.createRange();
_1ea.setStartAfter(_1e0);
var _1eb=_1ea.createContextualFragment(out.rendered);
_1e0.parentNode.insertBefore(_1eb,_1e0.nextSibling);
}else{
this.div.insert({top:out.rendered});
}
var _1ec=this.textarea.value.substr(0,_1e5-name.length);
_1ec+=out.richtext;
_1ec+=""+this.textarea.value.substr(_1e5);
this.textarea.value=_1ec;
}.bind(this)});
}
}
}else{
if(s=="/"){
var _1dd=this.caret.previousSibling;
if(!_1dd||_1dd.nodeValue!="["){
return false;
}
var _1ed=_1dd;
var _1ee="";
var tag="";
var back=2;
while((_1dd=_1dd.previousSibling)&&_1dd.nodeType==3&&_1dd.nodeValue!="]"){
_1ee=_1dd.nodeValue+_1ee;
back++;
}
while((_1dd=_1dd.previousSibling)&&_1dd.nodeType==3&&_1dd.nodeValue!="["){
tag=_1dd.nodeValue+tag;
back++;
}
if(tag=="artist"){
_1ee=_1ee.strip();
var _1e5=this.textarea.selectionStart;
var _1e1="<lfm:artist>"+_1ee.escapeHTML()+"</lfm:artist>";
new Ajax.Request("/ajax/richtextrenderer",{method:"post",parameters:{richtext:_1e1},onComplete:function(resp){
var out=resp.responseText.evalJSON();
_1dd=_1ed;
for(var i=back;i>0;i--){
var tmp=_1dd.previousSibling;
_1dd.parentNode.removeChild(_1dd);
_1dd=tmp;
}
if(this.caret.previousSibling){
var rm=this.caret.previousSibling;
rm.parentNode.removeChild(rm);
}
this.caret.insert({before:out.rendered});
var _1f5=this.textarea.value.substr(0,_1e5-back-1);
_1f5+=""+out.richtext;
_1f5+=""+this.textarea.value.substr(_1e5);
this.textarea.value=_1f5;
}.bind(this)});
return true;
}
}
}
if(s==" "){
this.caret.insert({before:"&nbsp;"});
this.textarea.value+=" ";
return true;
}
},moveTextAreaCursorBy:function(n){
var _1f7=this.textarea.selectionStart;
if(this.textarea.createTextRange){
var _1f8=this.textarea.createTextRange();
_1f8.moveStart("character",_1f7+n);
_1f8.moveEnd("character",_1f7+n);
_1f8.select();
}else{
if(this.textarea.setSelectionRange){
this.textarea.setSelectionRange(_1f7+n,_1f7+n);
}
}
},focus:function(e){
Event.stop(e);
var _1fa=e.rangeParent;
if(this.caret.parentNode){
this.caret.remove();
}
if(_1fa!=this.caret&&_1fa!=this.div){
_1fa.parentNode.insertBefore(this.caret,_1fa.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(_1fb){
this.scroller=$(_1fb);
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 _1fc=this.getVisibleWidth();
modulo=_1fc%this.imageWidth;
_1fc=_1fc-modulo;
if(_1fc>this.getWidth()){
_1fc=this.getWidth();
}
Element.setStyle(this.scroller,{maxWidth:_1fc+"px"});
var _1fd=this.getWidth()*-1+Math.abs(this.getOffset())+this.getVisibleWidth();
var _1fe=(this.getWidth()-this.getVisibleWidth())*-1;
this.setOffset(_1fe);
this.refreshButtonStates();
},onResize:function(_1ff){
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 _200=Element.getStyle(sampleImage,"border-left-width").replace("px","")*1;
if(!isNaN(_200)){
this.imageWidth=this.imageWidth+_200;
}
var _201=Element.getStyle(sampleImage,"border-right-width").replace("px","")*1;
if(!isNaN(_201)){
this.imageWidth=this.imageWidth+_201;
}
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(_202){
var blah=this.getWidth()-this.getVisibleWidth();
this.imageTrack.setStyle({left:_202+"px"});
},scrollLeft:function(_204){
if(!this.isScrolling&&this.getOffset()<0){
var _205=Math.abs(this.getOffset());
var _206=this.getVisibleWidth();
if(_206>_205){
_206=_205;
}
this.scroll(_206);
}
this.refreshButtonStates();
this.leftScrollButton.blur();
Event.stop(_204);
},scrollRight:function(_207){
if(!this.isScrolling&&(Math.abs(this.getOffset())+this.getVisibleWidth())<this.getWidth()){
var _208=this.getWidth()-(Math.abs(this.getOffset())+this.getVisibleWidth());
var _209=this.getVisibleWidth();
if(_209>_208){
_209=_208;
}
_209=_209*-1;
this.scroll(_209);
}
this.refreshButtonStates();
this.rightScrollButton.blur();
Event.stop(_207);
},scroll:function(_20a,_20b){
if(!this.isScrolling||_20b){
new Effect.Move(this.imageTrack,{x:_20a,y:0,mode:"relative",duration:0.5,afterFinish:this.afterScrolling.bind(this),beforeStart:this.beforeScrolling.bind(this),queue:{position:"end",scope:"scroller"}});
}
},beforeScrolling:function(_20c){
this.isScrolling=true;
this.totalDelta=this.totalDelta+_20c.options.x;
},afterScrolling:function(_20d){
this.isScrolling=false;
this.totalDelta=this.totalDelta-_20d.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 _20e=this.getSelectedImage().id;
if(_20e&&this.getImageWidth()){
_20e=(_20e.substring(5)*1)-1;
var _20f=_20e*this.getImageWidth();
_20f=_20f-this.getMiddle()+this.getImageWidth()/2;
if(_20f>(this.getWidth()-this.getVisibleWidth())){
_20f=this.getWidth()-this.getVisibleWidth();
}
_20f=_20f*-1;
if(_20f>0){
_20f=0;
}
Element.setStyle(this.imageTrack,{left:_20f+"px"});
this.refreshButtonStates();
}
}
}});
LFM.set("Resource",{Shoutbox:Class.create({initialize:function(_210){
this.shoutbox=_210;
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(_211){
_211.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 _215=new Ajax.Request(url,{method:"post",parameters:pars,onSuccess:this.addShout.bind(this)});
},addShout:function(_216){
if(this.shoutbox.restype==20){
LFM.Omniture.trackEvents("CommentPost");
}else{
LFM.Omniture.trackEvents("ShoutPost");
}
var _217=$("shoutList");
$("shoutList").insert({before:_216.responseText});
if(this.shoutbox.order=="asc"){
_217.innerHTML=_217.innerHTML+$("newShoutList").innerHTML;
}else{
_217.innerHTML=$("newShoutList").innerHTML+_217.innerHTML;
}
$("newShoutList").remove();
$("shoutList").select("li").each(function(li){
var _219=li.down(".delete");
if(_219){
_219.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(_21a){
_21a.stop();
var _21b=_21a.findElement("li");
var form=_21b.down("form");
var _21d=this.shoutbox.destination;
if(_21d.substr(-1)!="/"){
_21d+="/";
}
_21d+="delete";
form.action=_21d;
var _21e=this.shoutbox.restype;
var _21f=this.shoutbox.resid;
var _220=new LFM.Dialog({content:LFM.String.deleteMessagePrompt,confirmText:LFM.String.deleteButtonText,action:_21d,onConfirm:function(e){
e.stop();
this.hide();
form.request({parameters:{restype:_21e,resid:_21f,ajax:1},onSuccess:function(req){
if(req.responseText=="OK"){
new Effect.Fade(_21b,{duration:0.2});
}
}});
}});
_220.show();
},toggleInput:function(e){
if($("shoutPost").visible()){
$("shoutPost").hide();
}else{
$("shoutPostAgain").hide();
$("shoutPost").show();
this.textarea.focus();
}
e.stop();
},calculateCharCount:function(){
var _224=this.textarea.value.length;
this.updateCharLimit(_224);
this.updateCharCountDisplay(_224);
},updateCharCountDisplay:function(_225){
charCounter=$("sbCharCount");
var _226=this.shoutbox.charlimitMessage;
if(charCounter){
_226=_226.replace(/CURRENTCHARS/,_225);
_226=_226.replace(/MAXCHARS/,this.shoutbox.charlimit);
charCounter.innerHTML=_226;
}
},updateCharLimit:function(_227){
var _228=(_227>this.shoutbox.charlimit);
if(!this.overCharLimit&&_228){
$("sbCharCount").up().addClassName("overCharLimit");
$("sbPost").disable();
this.textarea.focus();
}
if(this.overCharLimit&&!_228){
$("sbCharCount").up().removeClassName("overCharLimit");
$("sbPost").enable();
}
this.overCharLimit=_228;
}})});
LFM.set("Display",{TableDragDrop:Class.create({initialize:function(_229,_22a){
this.draggedRow=null;
this.rowWithBorderAndShit=null;
this.mouseOffset=null;
this.oldY=0;
this.dragged=false;
if(_22a&&_22a.dragHandle){
this.dragHandle=_22a.dragHandle;
}else{
this.dragHandle=false;
}
this.table=$(_229);
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(_22b){
if(this.dragged){
_22b.stop();
this.dragged=false;
}
},getMouseOffset:function(_22c,_22d){
var _22e=_22c.cumulativeOffset();
return {x:_22d.pointerX()-_22e.left,y:_22d.pointerY()-_22e.top};
},onMouseDown:function(_22f){
if(!_22f.isLeftClick()){
return;
}
if(this.dragHandle&&!_22f.element().hasClassName(this.dragHandle)){
return;
}
if((tag_name=_22f.element().tagName.toUpperCase())&&(tag_name=="INPUT"||tag_name=="SELECT"||tag_name=="OPTION"||tag_name=="BUTTON"||tag_name=="TEXTAREA")){
return;
}
this.draggedRow=_22f.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,_22f);
_22f.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(_230){
var y=_230.pointerY()-this.mouseOffset.y;
_230.stop();
if(y!=this.oldY){
var _232=y>this.oldY;
this.oldY=y;
var _233=this.findDropTargetRow(y);
if(_233){
this.dragged=true;
if(_232&&this.draggedRow!=_233){
this.draggedRow.parentNode.insertBefore(this.draggedRow,_233.nextSibling);
}else{
if(!_232&&this.draggedRow!=_233){
this.draggedRow.parentNode.insertBefore(this.draggedRow,_233);
}
}
}
}
},onMouseUp:function(_234){
_234.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 _238=row.getHeight()/2;
if((y>rowY-_238)&&(y<(rowY+_238))){
return true;
}else{
return false;
}
});
return null;
}})});
LFM.set("Resource",{Users:Class.create({initialize:function(_239){
this.container=$("users");
this.container.observe("click",function(_23a){
log("clicked container");
var _23b=_23a.element();
if(_23b.match("a.delete img")){
_23a.stop();
var _23c=_23b.up("li");
if(_23c){
this.bin(_23c);
}
}
}.bind(this));
},bin:function(_23d){
var _23e=new LFM.Dialog({resource:_23d.getResource(),content:LFM.String.deleteFriendPrompt,confirmText:LFM.String.deleteButtonText,action:"friends/delete",onDone:function(_23f){
var _240=_23f.getResourceElement();
new Effect.Fade(_240,{duration:0.5});
},showDone:false});
_23e.show();
}})});
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,_242){
Object.extend(this.options,_242);
this._ajaxUrl=url;
if(this.options.lazyness){
this.options.laziness=this.options.lazyness;
}
},send:function(_243){
if(this._intervalId){
clearTimeout(this._intervalId);
}
var now=new Date();
this._lastTime=now.getTime()/1000;
this._ajaxOptions=this._defaultAjaxOptions;
if(_243){
if(_243.parameters){
Object.extend(this._ajaxOptions.parameters,_243.parameters);
_243.paramaters=this._ajaxOptions.parameters;
}
Object.extend(this._ajaxOptions,_243);
}
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(_245){
try{
if(typeof _245=="string"){
this.ajaxResponse=_245.evalJSON();
}else{
if(_245.responseText){
this.ajaxResponse=_245.responseText.evalJSON();
}else{
this.ajaxResponse=_245;
}
}
}
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,_248){
return this.data.set(key,_248);
},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 _24a=this.getResource();
if(_24a){
var link=new Element("a",{"href":_24a.url});
if(_24a.name){
link.update(_24a.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,_24d,_24e){
new Ajax.Request("/ajax/setUserPref",{parameters:{formtoken:LFM.Session.formtoken,pref:pref,value:_24d},onComplete:function(_24f){
var _250=new LFM.Ajax.Response(_24f);
if(_24e){
_24e(_250);
}
}});
};
LFM.Ajax.StatusHolder=Class.create({initialize:function(_251,_252){
this.status="idle";
this.element=$(_251);
this.options={position:"after"};
Object.extend(this.options,_252);
this.indicator=$(this.element.identify()+"_statusHolder");
if(this.indicator){
if(this.indicator.hasClassName("success")){
this.status="success";
}else{
if(this.indicator.hasClassName("failure")){
this.status="failure";
}else{
if(this.indicator.hasClassName("progress")){
this.status="busy";
}
}
}
}else{
this.indicator=document.createElement("img");
this.indicator=Element.extend(this.indicator);
this.indicator.src=LFM.Session.staticHost+"/tablestyles/pixel.gif";
this.indicator.height=16;
this.indicator.width=16;
if(this.options.position=="after"){
this.element.parentNode.insertBefore(this.indicator,this.element.nextSibling);
}else{
if(this.options.position=="before"){
this.element.parentNode.insertBefore(this.indicator,this.element);
}else{
if(this.options.position=="top"){
this.element.insertBefore(this.indicator,this.element.firstChild);
}else{
if(this.options.position=="bottom"){
this.element.appendChild(this.indicator);
}
}
}
}
this.indicator=this.indicator.wrap("SPAN");
this.indicator.addClassName("statusHolder");
this.indicator.id=this.element.identify()+"_statusHolder";
}
},remove:function(){
this.indicator.remove();
},busy:function(){
this.idle();
this.status="busy";
this.indicator.addClassName("progress");
this.indicator.down("img").src=LFM.Session.staticHost+"/depth/global/progress_new.gif";
},isBusy:function(){
return this.status=="busy";
},success:function(){
this.idle();
this.status="success";
this.indicator.addClassName("success");
this.indicator.down("img").src=LFM.Session.staticHost+"/depth/forms/correct_new.gif";
},isSuccess:function(){
return this.status=="success";
},failure:function(){
this.idle();
this.status="failure";
this.indicator.addClassName("failure");
this.indicator.down("img").src=LFM.Session.staticHost+"/depth/forms/incorrect_new.gif";
},isFailure:function(){
return this.status=="failure";
},idle:function(){
this.status="idle";
this.indicator.removeClassName("progress");
this.indicator.removeClassName("success");
this.indicator.removeClassName("failure");
this.indicator.down("img").src=LFM.Session.staticHost+"/tablestyles/pixel.gif";
},isIdle:function(){
return this.status=="idle";
}});
LFM.set("Ajax",{Autocompleter:Class.create(Ajax.Autocompleter,{setOptions:function(_253){
this.options=Object.extend({method:"get"},_253||{});
},buildItem:function(name){
return new Element("a",{href:"#"}).update(name).wrap(new Element("li"));
},onComplete:function(_255){
try{
var _256=_255.responseText.evalJSON();
}
catch(err){
return false;
}
if(_256&&_256.response.docs){
var list=new Element("ul");
var _258=this.getToken();
list.insert(this.buildItem(_258));
_256.response.docs.each(function(_259){
if(_259.name.toLowerCase()!=_258.toLowerCase()){
list.insert(this.buildItem(_259.name));
}
}.bind(this));
this.updateChoices(new Element("div").update(list).innerHTML);
}
}})});
LFM.set("Ajax",{Multicompleter:Class.create(LFM.Ajax.Autocompleter,{initialize:function(_25a,_25b,url,_25d){
this.baseInitialize(_25a,_25b,_25d);
this.url=url;
this.options.asynchronous=true;
this.options.onComplete=this.onComplete.bind(this);
this.options.onHide=function(_25e,_25f){
window.status="";
new Effect.Fade(_25f,{duration:0.15});
};
this.form=this.element.up("form");
this.submit=this.form.down("input[type=submit]");
var _260={};
if(this.options.enabled){
_260["force"]=1;
}else{
this.show=function(){
return false;
};
this.startIndicator=function(){
return false;
};
}
if(LFM.Session.userName){
_260["username"]=LFM.Session.userName;
}
if(this.options.parameters){
_260=Object.extend(_260,this.options.parameters);
}
this.options.defaultParams=_260;
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 _261=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(_262){
if(!_262.length||!this.personalData){
return false;
}
var _263=new RegExp(_262.replace(/([\\\^\$*+[\]?{}.=!:(|)])/g,"\\$1"),"i");
var _264=[];
var _265=this.personalData.get("friends");
if(_265){
_265.each(function(_266,i){
var _268=_266.name.match(_263)||(_266.realname&&_266.realname.match(_263));
if(_268){
_264.push(_266);
}
});
}
var _269=this.personalData.get("groups");
if(_269){
_269.each(function(_26a,i){
var _26c=_26a.name.match(_263);
if(_26c){
_264.push(_26a);
}
});
}
var _26d=this.personalData.get("labels");
if(_26d){
_26d.each(function(_26e,i){
var _270=_26e.name.match(_263)&&_26e.single_artist!="t";
if(_270){
_264.push(_26e);
}
});
}
return _264;
},buildEvent:function(_271){
var _272=_271.date.split("T");
var _273=_272[0].split("-");
var _274=_271.event||_271.artist;
var _275="<span class=\"calSheet calSheetSmall\">"+"<span title=\""+_271.date+"\">"+"<span class=\"month\">"+LFM.String.shortMonths[_273[1]-0]+"</span>"+"<span class=\"day\">"+(_273[2]-0)+"</span>"+"</span>"+"</span>";
var _276=_271["country_"+LFM.Session.language]||_271["country_en"];
return _275+"<strong>"+_274.truncate(25)+"</strong><br>"+_271.city.truncate(25)+", "+_276.truncate(25);
},buildEventTitle:function(_277){
var _278=_277.event||_277.artist;
var _279=_277["country_"+LFM.Session.language]||_277["country_en"];
return _278+", "+_277.venue+", "+_277.city+", "+_279;
},buildEventURL:function(_27a){
return "/event/"+encodeURIComponent(encodeURIComponent(_27a.resid));
},buildArtist:function(_27b){
var _27c=this.buildArtistImageURL(_27b);
var _27d="<img src=\""+_27c+"\" width=\"34\" height=\"34\">";
return _27d+this.buildName(_27b.artist);
},buildArtistTitle:function(_27e){
return _27e.artist;
},buildArtistURL:function(_27f){
return "/music/"+encodeURIComponent(encodeURIComponent(_27f.artist));
},buildArtistImageURL:function(_280){
if(_280.image){
return LFM.Session.userserveHost+"/serve/34s/"+_280.image;
}else{
var _281={api_key:LFM.Session.wsKey,artist:_280.artist,method:"artist.getImageRedirect",size:"smallsquare"};
return "http://"+LFM.Session.wsHost+"/2.0/?"+Object.toQueryString(_281);
}
},buildAlbum:function(_282){
var _283=this.buildAlbumImageURL(_282);
var _284="<span class=\"albumCover coverSmall\" />"+"<span class=\"art\"><img src=\""+_283+"\" width=\"34\" height=\"34\"></span>"+"<span class=\"jewelcase\"></span>"+"</span>";
return _284+this.buildName(_282.album)+"<br>"+_282.artist.truncate(25);
},buildAlbumTitle:function(_285){
return _285.album+" - "+_285.artist;
},buildAlbumURL:function(_286){
return "/music/"+encodeURIComponent(encodeURIComponent(_286.artist))+"/"+encodeURIComponent(encodeURIComponent(_286.album));
},buildAlbumImageURL:function(_287){
if(_287.image){
return LFM.Session.userserveHost+"/serve/34s/"+_287.image;
}else{
var _288={api_key:LFM.Session.wsKey,artist:_287.artist,album:_287.album,method:"album.getImageRedirect",size:"smallsquare"};
return "http://"+LFM.Session.wsHost+"/2.0/?"+Object.toQueryString(_288);
}
},buildTrack:function(_289){
var _28a=this.buildArtistImageURL(_289);
var _28b="<img src=\""+_28a+"\" width=\"34\" height=\"34\">";
var _28c=_289.duration?" <small> ("+LFM.timeFormat(_289.duration)+")</small>":"";
return _28b+this.buildName(_289.track)+_28c+"<br>"+_289.artist.truncate(25);
},buildTrackTitle:function(_28d){
return _28d.track+" - "+_28d.artist;
},buildTrackURL:function(_28e){
return "/music/"+encodeURIComponent(encodeURIComponent(_28e.artist))+"/_/"+encodeURIComponent(encodeURIComponent(_28e.track));
},buildTag:function(_28f){
var icon="<img width=\"30\" height=\"30\" src=\""+LFM.Session.staticHost+"/flatness/icons/tag/1/tag_30.png\">";
return icon+this.buildName(_28f.tag);
},buildTagTitle:function(_291){
return _291.tag;
},buildTagURL:function(_292){
return "/tag/"+encodeURIComponent(encodeURIComponent(_292.tag));
},buildUser:function(_293){
var _294=this.buildResImage(_293,"/flatness/catalogue/noimage/2/default_user_small.png");
var user=_294+this.buildName(_293.name);
if(_293.realname){
user+="<br>"+_293.realname.truncate(25);
}
return user;
},buildUserTitle:function(_296){
var _297=_296.name;
if(_296.realname){
_297+=" - "+_296.realname;
}
return _297;
},buildUserURL:function(_298){
return "/user/"+encodeURIComponent(encodeURIComponent(_298.name));
},buildGroup:function(_299){
var _29a=this.buildResImage(_299,"/flatness/catalogue/noimage/2/default_group_small.png");
var name;
if(_299.group){
name=this.buildName(_299.group);
}else{
name=this.buildName(_299.name);
}
return _29a+name;
},buildGroupTitle:function(_29c){
return _29c.name||_29c.group;
},buildGroupURL:function(_29d){
var name=_29d.name||_29d.group;
return "/group/"+encodeURIComponent(encodeURIComponent(name));
},buildLabel:function(_29f){
var _2a0=this.buildResImage(_29f,"/flatness/catalogue/noimage/2/default_label_small.png");
var name;
if(_29f.label){
name=this.buildName(_29f.label);
}else{
name=this.buildName(_29f.name);
}
return _2a0+name;
},buildLabelTitle:function(_2a2){
return _2a2.name||_2a2.label;
},buildLabelURL:function(_2a3){
var root;
var name=_2a3.name||_2a3.label;
if(_2a3.single_artist=="t"){
root="/artist/";
}else{
root="/label/";
}
return root+encodeURIComponent(encodeURIComponent(name));
},buildName:function(name){
return "<strong>"+name.truncate(25)+"</strong>";
},buildResTitle:function(_2a7){
return _2a7.name;
},buildResImage:function(_2a8,_2a9){
var _2aa=LFM.Session.staticHost+_2a9;
if(_2a8.image_id){
_2aa=LFM.Session.userserveHost+"/serve/34s/"+_2a8.image_id+".jpg";
}else{
if(_2a8.image){
_2aa=LFM.Session.userserveHost+"/serve/34s/"+_2a8.image;
}
}
var _2ab="<img src=\""+_2aa+"\" width=\"34\" height=\"34\">";
return _2ab;
},buildItemLink:function(_2ac){
var _2ad=_2ac.res?_2ac.res.type:_2ac.restype;
var _2ae=LFM.resTypeLookup[_2ad];
if(!_2ae){
LFM.warn("no restype found: "+_2ad);
}else{
try{
var url=this["build"+_2ae+"URL"](_2ac);
if(!this.urls[url]){
this.urls[url]=_2ae;
var item=this["build"+_2ae](_2ac);
var _2b1=this["build"+_2ae+"Title"](_2ac);
var link=new Element("a",{href:url+"?ac="+encodeURIComponent(this.getToken()),title:_2b1}).addClassName(_2ae.toLowerCase()+"Item").update(item);
return link;
}
}
catch(e){
LFM.warn(_2ae,e);
}
}
},buildSearchLink:function(_2b3){
var _2b4=this.form.action+"?"+this.form.serialize();
var link=new Element("a",{href:_2b4}).addClassName("viewAll");
return new Element("span").addClassName("moduleOptions").update(_2b3).wrap(link);
},setOptions:function(_2b6){
_2b6=_2b6||{};
this.options=Object.extend({method:"get",onShow:function(_2b7,_2b8){
if(!_2b8.style.position||_2b8.style.position=="absolute"){
_2b8.style.position="absolute";
Position.clone(_2b7,_2b8,{setHeight:false,setWidth:false,offsetTop:_2b7.offsetHeight});
}
Effect.Appear(_2b8,{duration:0.15});
}},_2b6);
},markNext:function(){
if(this.index===null){
this.index=0;
}else{
if(this.index<this.entryCount-1){
this.index++;
}
}
var _2b9=this.getCurrentEntry();
if(_2b9){
window.status=_2b9.down("a").href;
}else{
window.status="";
}
},markPrevious:function(){
if(this.index>0){
this.index--;
}else{
this.index=null;
}
var _2ba=this.getCurrentEntry();
if(_2ba){
window.status=_2ba.down("a").href;
}else{
window.status="";
}
},getEntry:function(_2bb){
if(_2bb!==null){
return this.update.down("li.item",_2bb);
}
},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(_2be,list){
var link;
var _2c1=_2be.res?_2be.res.type:_2be.restype;
if(_2c1){
link=this.buildItemLink(_2be);
}else{
link=this.buildSearchLink(_2be);
}
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(_2c5){
response=new LFM.Ajax.Response(_2c5);
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 _2cc=this.getToken();
if(_2cc.length>=this.options.minChars&&_2cc!=this.lastToken){
this.startIndicator();
}
},onSubmit:function(e){
var _2ce=this.form.serialize().toQueryParams();
var _2cf=this.getToken();
LFM.Omniture.prepareEvar("SearchLength",_2cf.length);
if(this.options.enabled){
LFM.Omniture.prepareEvar("SearchType","multicomplete");
}else{
if(_2ce.m){
LFM.Omniture.prepareEvar("SearchType",_2ce.m);
}
}
LFM.Omniture.prepareEvar("HeaderSearchAction","Search");
LFM.Omniture.trackEvents("HeaderSearch");
},onObserverEvent:function(){
this.changed=false;
var _2d0=this.getToken();
if(_2d0.length>=this.options.minChars){
if(_2d0!=this.lastToken&&_2d0!=this.element.getAttribute("placeholder")){
this.getUpdatedChoices();
}else{
this.render();
}
}else{
this.active=false;
this.hide();
}
this.lastToken=_2d0;
this.oldElementValue=this.element.value;
},getToken:function(){
return $F(this.element);
},processResults:function(_2d1){
var list=new Element("ul");
if(_2d1){
this.urls={};
_2d1.each(function(_2d3,_2d4){
this.addLinkedItem(_2d3,list);
},this);
}
this.addViewAll(list,_2d1.length);
return list;
},addViewAll:function(list,_2d6){
this.addLinkedItem(LFM.String.siteSearchViewAll.replace("QUERY",this.getToken()),list);
this.entryCount=_2d6+1;
},onComplete:function(_2d7){
if(this.changed||!this.hasFocus){
return false;
}
var _2d8=new Array,_2d9=0;
try{
var _2da=_2d7.responseText.evalJSON();
_2d8=_2da.response.docs;
}
catch(err){
LFM.warn("JSON error: "+_2d7.responseText);
}
if(this.personalMatches&&this.personalMatches.length){
var _2db=Math.min(this.personalMatches.length,3);
_2d8=this.personalMatches.slice(0,_2db).concat(_2d8.slice(0,10-_2db));
}
_2d9=_2d8.length;
var list=this.processResults(_2d8);
this.updateChoices(list,_2d9);
},updateChoices:function(list,_2de){
this.update.update(list);
var _2df=new Element("p",{"class":"header"});
if(_2de){
_2df.update(LFM.String.siteSearchSuggestions);
}else{
_2df.update(LFM.String.siteSearchNoSuggestions).addClassName("empty");
}
this.update.insert({"top":_2df});
if(LFM.Session.loggedIn&&!this.personalData){
var _2e0=new Element("div").addClassName("message messageWarn").update(LFM.String.autocompletePersonalDataDown);
this.update.insert({"bottom":_2e0});
}
this.update.select("li.item a").each(function(link,_2e2){
link.autocompleteIndex=_2e2;
},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(_2e3){
var _2e4=this.buildArtistImageURL(_2e3);
var _2e5="<span class=\"img\"><span><img src=\""+_2e4+"\" width=\"34\" height=\"34\" /></span></span>";
return _2e5+"<strong class=\"artist\">"+_2e3.artist.truncate(25)+"</strong>";
},buildTrack:function(_2e6){
var _2e7=this.buildArtistImageURL(_2e6);
var _2e8="<span class=\"img\"><span><img src=\""+_2e7+"\" width=\"34\" height=\"34\" /></span></span>";
var _2e9=_2e6.duration?" <small class=\"time\"> ("+LFM.timeFormat(_2e6.duration)+")</small>":"";
return _2e8+"<strong class=\"track\">"+_2e6.track.truncate(20)+"</strong>"+_2e9+"<br>"+_2e6.artist.truncate(25);
},buildTag:function(_2ea){
var icon="<img width=\"20\" height=\"20\" src=\""+LFM.Session.staticHost+"/flatness/icons/activity/tagged.png\">";
return icon+"<strong class=\"tag\">"+_2ea.tag.truncate(25)+"</strong>";
},processResults:function(_2ec,list){
var list=new Element("ul");
if(_2ec){
this.urls={};
var _2ee=this.groupResults(_2ec);
var _2ef,_2f0,_2f1,_2f2;
this.resTypeGroups.each(function(_2f3,_2f4){
if(_2ee[_2f3]){
_2ef=new Element("li");
_2f2=(_2f3==LFM.resTypes.USER)?LFM.String.resTypePlural["friends"]:LFM.String.resTypePlural[_2f3];
_2f0=new Element("h3").update(_2f2).addClassName(LFM.resTypeLookup[_2f3].toLowerCase());
_2f1=new Element("ul");
_2ee[_2f3].each(function(_2f5,_2f6){
this.addLinkedItem(_2f5,_2f1);
},this);
_2ef.insert(_2f0);
_2ef.insert(_2f1);
list.insert(_2ef);
}
},this);
}
this.addViewAll(list,_2ec.length);
return list;
},groupResults:function(_2f7){
var _2f8={},_2f9;
_2f7.each(function(_2fa,_2fb){
_2f9=_2fa.res?_2fa.res.type:_2fa.restype;
if(!_2f8[_2f9]){
_2f8[_2f9]=[];
}
_2f8[_2f9].push(_2fa);
},this);
return _2f8;
}})});
LFM.set("Ajax",{SideGroupedMulticompleter:Class.create(LFM.Ajax.GroupedMulticompleter,{init:function(){
this.update.addClassName("grouped sidegrouped");
},processResults:function(_2fc,list){
var _2fe=new Element("table",{cellspacing:0,cellpadding:0,border:0});
var _2ff=new Element("tbody");
var _300=0;
if(_2fc){
this.urls={};
var _301=this.groupResults(_2fc);
var _302,_303,_304,_305;
this.resTypeGroups.each(function(_306,_307){
if(_301[_306]){
_300++;
_302=new Element("tr");
if(_300%2==0){
_302.addClassName("alt");
}
_305=(_306==LFM.resTypes.USER)?LFM.String.resTypePlural["friends"]:LFM.String.resTypePlural[_306];
_303=new Element("h3").update(_305).addClassName(LFM.resTypeLookup[_306].toLowerCase());
_304=new Element("ul");
_301[_306].each(function(_308,_309){
this.addLinkedItem(_308,_304);
},this);
_302.insert(new Element("th").update(_303));
var _30a=new Element("td").update(_304);
if(_300==1){
_30a.addClassName("first");
}
_302.insert(_30a);
_2ff.insert(_302);
}
},this);
}
var _30b=new Element("tr");
if(_300%2==0){
_30b.addClassName("alt");
}
var _30c=new Element("ul");
this.addViewAll(_30c,_2fc.length);
_30b.insert(new Element("th"));
_30b.insert(new Element("td",{"class":"viewAll"}).update(_30c));
_2ff.insert(_30b);
_2fe.update(_2ff);
return _2fe;
}})});


