
function DiscographyEnhancer(enableLogging){this.loggingEnabled=Boolean(enableLogging);this.log("DiscographyEnhancer instantiated");}
DiscographyEnhancer.prototype.itunesImageHtml='<img src="/images/itunes_btn.gif" alt="iTunes" title="get album from iTunes" border="0" />';DiscographyEnhancer.prototype.buyLinkClass="buyLink";DiscographyEnhancer.prototype.itunesUrl="phobos.apple.com";DiscographyEnhancer.prototype.expandLinkHtml='show lyrics';DiscographyEnhancer.prototype.collapseLinkHtml='hide lyrics';DiscographyEnhancer.prototype.collapsedLyricsContainerClass="collapsed";DiscographyEnhancer.prototype.lyricsContainerClass="lyricsContainer";DiscographyEnhancer.prototype.lyricsControllerClass="lyricsController";DiscographyEnhancer.prototype.audioPlayerClass="de_audioPlayer";DiscographyEnhancer.prototype.audioPlayerVariables=[];DiscographyEnhancer.prototype.audioPlayerSwfPath="/fws/singleMp3Player/echo_single_mp3_button_with_preloader.swf";DiscographyEnhancer.prototype.audioPlayerSwfWidth=109;DiscographyEnhancer.prototype.audioPlayerSwfHeight=19;DiscographyEnhancer.prototype.leopardStripeElligibiltyClass="leopardMe";DiscographyEnhancer.prototype.leopardStripingAltClass="ls_alt";DiscographyEnhancer.prototype.stripeEvens=false;DiscographyEnhancer.prototype.hoverElligibilityClass="hover";DiscographyEnhancer.prototype.hoverStateClass="over";DiscographyEnhancer.prototype.log=function(str){if(this.loggingEnabled){try{console.log(str);}catch(e){}}};DiscographyEnhancer.prototype.sanitizeLinks=function(){var de=this;$("a."+this.buyLinkClass).each(function(i){var link=$(this);var linkHref=$(this).attr("href")||"";if(linkHref.length==0){de.log("Removing empty a.buyLink");link.replaceWith("");return;}
if(linkHref.indexOf("http://")==-1){$(this).attr("href","http://"+linkHref);}
if(linkHref.indexOf(de.itunesUrl)!=-1){link.html(de.itunesImageHtml);}
link.attr("target","_blank");});};DiscographyEnhancer.prototype.collapseAllLyrics=function(){var de=this;$("."+de.lyricsContainerClass).each(function(i){$(this).hide();$(this).addClass(de.collapsedLyricsContainerClass);});};DiscographyEnhancer.prototype.createExpandLyricsLinks=function(){this.log("createExpandLyricsLinks called (setting up lyrics show/hide functionality)");var de=this;$("."+this.lyricsControllerClass).each(function(i){de.log("Lyrics controller found, number "+i+" "+this.className);var lc=$(this);var targetLyricsContainer=$("."+de.collapsedLyricsContainerClass).get(i);de.log(typeof(targetLyricsContainer));if($(targetLyricsContainer).html()&&$(targetLyricsContainer).html().length){de.log("Enabled hiding and showing of the lyrics for lyrics controller "+i+".");lc.html('<a href="#">'+de.expandLinkHtml+'</a>');$(lc.children("a").get(0)).click(function(){de.toggleLyricsContainer(targetLyricsContainer,this);return false;});}else{lc.empty();}});};DiscographyEnhancer.prototype.toggleLyricsContainer=function(targ,caller){targ=$(targ);caller=$(caller);if(targ.hasClass(this.collapsedLyricsContainerClass)){caller.html(this.collapseLinkHtml);targ.removeClass(this.collapsedLyricsContainerClass);this.expandLyrics(targ);}else{caller.html(this.expandLinkHtml);targ.addClass(this.collapsedLyricsContainerClass);this.collapseLyrics(targ);}};DiscographyEnhancer.prototype.setupLyricsControls=function(){this.collapseAllLyrics();this.createExpandLyricsLinks();};DiscographyEnhancer.prototype.expandLyrics=function(jqObj){jqObj.fadeIn("slow");};DiscographyEnhancer.prototype.collapseLyrics=function(jqObj){jqObj.fadeOut("slow");};DiscographyEnhancer.prototype.players=[];DiscographyEnhancer.prototype.stopTracks=function(track){this.log("Stopping all tracks but "+track);for(var i=0;i<this.players.length;i++){if(this.players[i]!=track){this.thisMovie(this.players[i]).stopTrack();}}};DiscographyEnhancer.prototype.thisMovie=function(movieName){if(navigator.appName.indexOf("Microsoft")!=-1){return window[movieName];}else{return document[movieName];}};DiscographyEnhancer.prototype.buildPlayers=function(){var de=this;de.log("Building Flash audio players...");$("."+this.audioPlayerClass).each(function(i){var ap=$(this);if(ap.attr("title")!=undefined&&ap.attr("title")!=null){this.id="player"+i;var track="p"+i;de.players.push(track);de.log("Building player "+track+" for URL "+ap.attr("title")+".");var fo=new SWFObject(de.audioPlayerSwfPath,track,de.audioPlayerSwfWidth,de.audioPlayerSwfHeight,"7","#ffffff");fo.addVariable("mp3",ap.attr("title"));fo.addVariable("trackNum",track);fo.addParam("wmode","transparent");fo.addParam("allowScriptAccess","always");for(var i in de.audioPlayerVariables){fo.addVariable(de.audioPlayerVariables[i].param,de.audioPlayerVariables[i].value);}
fo.write(this.id);ap.attr("title","");}});de.log(this.players.length+" players added. ("+this.players.join(",")+").");};DiscographyEnhancer.prototype.addStriping=function(){var de=this;$("."+this.leopardStripeElligibiltyClass).each(function(i){var container=$(this);var stripeDecider;if(de.stripeEvens){stripeDecider=function(c){if(c%2==1){return true;}else{return false;}}}else{stripeDecider=function(c){if(c%2==0){return true;}else{return false;}}}
if(stripeDecider(i)){de.log("Adding striping to row "+i+".");container.addClass(de.leopardStripingAltClass);}});};DiscographyEnhancer.prototype.addHovering=function(){var de=this;$("."+this.hoverElligibilityClass).each(function(i){$(this).hover(function(){de.doHover($(this));},function(){de.doUnhover($(this));});});};DiscographyEnhancer.prototype.doHover=function(jqObj){jqObj.addClass(this.hoverStateClass);};DiscographyEnhancer.prototype.doUnhover=function(jqObj){jqObj.removeClass(this.hoverStateClass);};