function PACSetArtistAlbumRequest(E,G){if(E<=0||G<=0){return window.location.href}var C=window.location.href.replace("?","&").replace(/#/g,"").split("&");var F="";var B=false;var A=false;for(var D=0;D<C.length;D++){if(B==false&&C[D].indexOf("artistid=")>=0){F+=(fplpg.isFersfulUrls&&!B&&!A?"?":"&")+"artistid="+E;B=true}else{if(A==false&&C[D].indexOf("playlistid=")>=0){F+=(fplpg.isFersfulUrls&&!B&&!A?"?":"&")+"&playlistid="+G;A=true}else{if(C[D].indexOf("artistid=")<0&&C[D].indexOf("playlistid=")<0){if(D>0){F+="&"}F+=C[D]}}}}if(F.indexOf("artistid=")<0){F+="&artistid="+E}if(F.indexOf("playlistid=")<0){F+="&playlistid="+G}return F}function PACFixLocation(){var F=0;var A=false;if((F=window.location.href.indexOf("music.celebritypromo"))>0){F+=20;A=false}else{if((F=window.location.href.indexOf("music/featured-playlists"))>0){F+=24;A=true}}if(F>0){var C=window.location.href.substr(0,F)+(A?"/":"&");var E=window.location.href.substr(F);if(A){if((F=E.lastIndexOf("#"))>=0){C+=E.substr(F).replace(/#\//,"").replace(/#/,"")}}else{var D=E.lastIndexOf("artistid=");var B=E.lastIndexOf("playlistid=");if(D<=0&&B<=0){return}if(D>B){C+=E.substr(B)}else{C+=E.substr(D)}}window.location.href=C}}fplpg={isFersfulUrls:false,Init:function(A){this.isFersfulUrls=A},topModalWindow:{parent:"body",windowId:"topmodalwindowid",close:function(){$(".top-modal-overlay").remove()},open:function(D,C,B,A){$(this.parent).append('<div class="top-modal-overlay" style="width:'+B+"px; height:"+A+"px; margin-top:"+D+"px; margin-left:"+C+'px; "></div>')}},cache:{playlists:new Array(),lease:new Date(),morePlaylistNumber:0,functionName:"",thePageUrl:"",PreInit:function(B,A){this.functionName=B;this.thePageUrl=A},Init:function(lease,mainPlaylist,morePlaylists){if(this.morePlaylistNumber>0&&morePlaylists!=null&&this.morePlaylistNumber!=morePlaylists.length){document.forms.aspnetForm.action=PACSetArtistAlbumRequest(mainPlaylist.Id,mainPlaylist.PlaylistId);document.forms.aspnetForm.submit()}this.morePlaylistNumber=morePlaylists.length;this.lease=lease;this.playlists=new Array();var buyOptUrl=null;var buyOptMarkup=null;try{var buyOpt=eval("("+mainPlaylist.BuyOptions+")");if(buyOpt==null){buyOptMarkup=" ";buyOptUrl=" "}else{buyOptMarkup=buyOpt.markup.replace("&$B1B$&","{").replace("&$B1E$&","}");buyOptUrl=buyOpt.url}}catch(Error){buyOptMarkup=" ";buyOptUrl=" "}this.Add(new PlayList(mainPlaylist.OnDate,mainPlaylist.Id,mainPlaylist.Name,mainPlaylist.Url,mainPlaylist.ImageUrl,mainPlaylist.PlaylistId,mainPlaylist.PlaylistName,mainPlaylist.PlaylistSongCount,mainPlaylist.PlaylistCreateDate,mainPlaylist.PlaylistDesc,mainPlaylist.SongsBy,buyOptMarkup,buyOptUrl));this.AddList(morePlaylists)},Add:function(A){if(this.Find(A.id,A.plId,A.onDate)!=null){return}this.playlists[this.playlists.length]=A},AddList:function(newPlaylists){for(var i=0;i<newPlaylists.length;i++){if(this.Find(newPlaylists[i].Id,newPlaylists[i].PlaylistId,newPlaylists[i].OnDate)!=null){continue}var buyOptUrl=null;var buyOptMarkup=null;try{var buyOpt=eval("("+newPlaylists[i].BuyOptions+")");if(buyOpt==null){buyOptMarkup=" ";buyOptUrl=" "}else{buyOptMarkup=buyOpt.markup.replace("&$B1B$&","{").replace("&$B1E$&","}");buyOptUrl=buyOpt.url}}catch(Error){buyOptMarkup=" ";buyOptUrl=" "}this.playlists[this.playlists.length]=new PlayList(newPlaylists[i].OnDate,newPlaylists[i].Id,newPlaylists[i].Name,newPlaylists[i].Url,newPlaylists[i].ImageUrl,newPlaylists[i].PlaylistId,newPlaylists[i].PlaylistName,newPlaylists[i].PlaylistSongCount,newPlaylists[i].PlaylistCreateDate,newPlaylists[i].PlaylistDesc,newPlaylists[i].SongsBy,buyOptMarkup,buyOptUrl)}},Find:function(C,D,A){if(!this.playlists){return null}for(var B=0;B<this.playlists.length;B++){if(this.playlists[B].id==C&&this.playlists[B].plId==D&&this.playlists[B].onDate==A){return this.playlists[B]}}return null},FindOnDate:function(B){if(!this.playlists){return null}var A=new Array();for(var C=0;C<this.playlists.length;C++){if(this.playlists[C].onDate==B){A[A.length]=this.playlists[C]}}return A},FindMainPlaylist:function(D,E,A){if(!this.playlists){return null}var C=this.FindOnDate(A);if(C==null){return null}for(var B=0;B<C.length;B++){if(C[B].id==D&&C[B].plId==E&&C[B].onDate==A){return C[B]}}return null},FindOtherPlaylists:function(E,F,B){if(!this.playlists){return null}var D=this.FindOnDate(B);var A=new Array();if(D==null){return}for(var C=0;C<D.length;C++){if(D[C].id!=E||D[C].plId!=F||D[C].onDate!=B){A[A.length]=D[C]}}return A}}};function PlayList(C,D,A,B,K,H,F,J,G,L,I,M,E){this.onDate=C;this.id=D;this.name=A;this.url=B;this.imageUrl=K;this.plId=H;this.plName=F;this.plSongCount=J;this.plCreateDate=G;this.plDesc=L;this.plSongsBy=I;this.buyOptMarkup=M;this.buyOptUrl=E}function OnFeaturedPlayistClick(request){if(!request){return}if(request.Id==0||request.PlaylistId==0){return}document.forms.aspnetForm.action=PACSetArtistAlbumRequest(request.Id,request.PlaylistId).replace(/#/,"");location.hash=(fplpg.isFersfulUrls?"#?":"#&")+"artistid="+request.Id+"&playlistid="+request.PlaylistId;fplpg.topModalWindow.open("0","0","100%","100%");if(fplpg.cache&&fplpg.cache.playlists!=null&&fplpg.cache.Find(request.Id,request.PlaylistId,request.OnDate)==null){fplpg.cache.lease=""}$.ajax({type:"POST",url:"/Modules/MusicV2/Services/CelebrityPromoService.ashx?caller="+fplpg.cache.functionName+"&leaseTime="+fplpg.cache.lease+"&isCurrentPlaylist="+request.IsCurrentPlaylist+"&onDate="+request.OnDate+"&artistId="+request.Id+"&playlistId="+request.PlaylistId,data:"",contentType:"text/plain; charset=utf-8",dataType:"text",timeout:5000,error:function(XMLHttpRequest,textStatus,errorThrown){fplpg.topModalWindow.close()},success:function(respond){fplpg.topModalWindow.close();if(!respond){return}respond=eval("("+respond+")");if(!respond){return}if(respond.IsFullUpdate==true){fplpg.cache.Init(respond.LeaseExpired,respond.MainPlaylist,respond.MorePlaylists);UpdatePlaylistsUI(respond.MainPlaylist.Id,respond.MainPlaylist.PlaylistId,respond.MainPlaylist.OnDate,respond.IsCurrentPlaylist)}else{UpdatePlaylistsUI(request.Id,request.PlaylistId,request.OnDate,request.IsCurrentPlaylist)}},cache:false})}function UpdatePlaylistsUI(B,H,A,E){fplpg.topModalWindow.close();var J=fplpg.cache.FindMainPlaylist(B,H,A);var I=fplpg.cache.FindOtherPlaylists(B,H,A);if(J==null||I==null){return}try{document.getElementById("shell").load_playlist(J.id,J.plId)}catch(G){}$("#fplmplatag").attr("href",J.url);$("#fplmplimgtag").attr("src",J.imageUrl);$("#fplmplcnttag").html(J.plName+" ("+J.plSongCount+")");$("#fplmpldatetag").html(J.plCreateDate);$("#fplmpla2tag").attr("href",J.url).html(J.name);$("#fplmpldscrtag").html(J.plDesc);$(".ClsPurchaseBtn").html(J.buyOptMarkup==null?"&nbsp;":J.buyOptMarkup);if(J.buyOptMarkup&&MySpace.Beacon&&!MySpace.Application.keyDisabled("DWBeaconAJAXMusicBuyButton")){var C=J.buyOptMarkup.replace(/^\s*/,"").replace(/\s*$/,"");if(C!==""){MySpace.Beacon.Request({d_buypl:H})}}try{purchasePlaylistUrl.amazon=J.buyOptUrl}catch(G){}for(var F in I){try{var D=new Function('OnFeaturedPlayistClick(eval({"IsCurrentPlaylist":'+E+',"OnDate":"'+I[F].onDate+'","Id":'+I[F].id+',"PlaylistId":'+I[F].plId+"}))");document.getElementById("fploplclicktag"+F).onclick=D;document.getElementById("fploplclick2tag"+F).onclick=D}catch(G){continue}$("#fploplimgtag"+F).attr("src",I[F].imageUrl);$("#fploplcnttag"+F).html(I[F].plName+" ("+I[F].plSongCount+")");$("#fplopldatetag"+F).html(I[F].plCreateDate);$("#fploplatag"+F).attr("href",I[F].url).html(I[F].name);$("#fploplsongktag"+F).html(I[F].plSongsBy);$("#fploplah1tag"+F).attr("href",fplpg.cache.thePageUrl+(fplpg.isFersfulUrls?"?":"&")+"artistid="+I[F].id+"&playlistid="+I[F].plId);$("#fploplah2tag"+F).attr("href",$("#fploplah1tag"+F).attr("href"))}}function InitPageCache(jsonrespond,functionName,thePageUrl){try{var respond=eval(jsonrespond);if(!respond){return}fplpg.cache.PreInit(functionName,thePageUrl);fplpg.cache.Init(respond.LeaseExpired,respond.MainPlaylist,respond.MorePlaylists)}catch(Error){}}function PACOnDateExpandedCheck(){var C=0;var A=0;for(var B=0;B<pacTotalRecords;B++){try{if(document.getElementById("pacOnDate"+B).style.height=="24px"){C++}}catch(D){}}if(document.getElementById("pacOnDateParent0").style.display=="none"){A=1}if(C==0+A){document.getElementById("pacExpandAll").style.cursor="pointer";document.getElementById("pacExpandAll").style.color="rgb(7,102,182)";document.getElementById("pacCollapseAll").style.cursor="text";document.getElementById("pacCollapseAll").style.color="#aaa";document.getElementById("pacExpandCollapseSeparator").style.color="#aaa"}else{if(C==pacDatedRecords){document.getElementById("pacExpandAll").style.cursor="text";document.getElementById("pacExpandAll").style.color="#aaa";document.getElementById("pacCollapseAll").style.cursor="pointer";document.getElementById("pacCollapseAll").style.color="rgb(7,102,182)";document.getElementById("pacExpandCollapseSeparator").style.color="#aaa"}else{document.getElementById("pacExpandAll").style.cursor="pointer";document.getElementById("pacExpandAll").style.color="rgb(7,102,182)";document.getElementById("pacCollapseAll").style.cursor="pointer";document.getElementById("pacCollapseAll").style.color="rgb(7,102,182)";document.getElementById("pacExpandCollapseSeparator").style.color="rgb(7,102,182)"}}}function PACExpandAll(B){for(var A=0;A<pacTotalRecords;A++){try{PACOnDateClick(A,B)}catch(C){}}PACOnDateExpandedCheck()}function PACRestoreExpanded(A){if(!A){return}var C=A.split(",");for(var B=0;B<C.length;B++){PACOnDateClick(C[B],"EAll")}}function PACOnDateClick(G,E){var D=document.getElementById("pacOnDate"+G);var C=document.getElementById("pacOnDateParent"+G);if(G==0&&document.getElementById("pacOnDateParent0").style.display=="none"){return}if(E=="CAll"||E!="EAll"&&E!="CAll"&&D.style.height=="24px"){D.style.height="18px";C.style.marginBottom="0px";document.getElementById("pacImgDD"+G).style.display="none";document.getElementById("pacImgDR"+G).style.display="block";if(C.childNodes){for(var B=0;B<C.childNodes.length;B++){if(C.childNodes[B].id!="pacOnDate"+G){try{C.childNodes[B].style.display="none"}catch(F){}}}}}else{if(E=="EAll"||E!="EAll"&&E!="CAll"){D.style.height="24px";C.style.marginBottom="10px";document.getElementById("pacImgDD"+G).style.display="block";document.getElementById("pacImgDR"+G).style.display="none";if(C.childNodes){for(var A=0;A<C.childNodes.length;A++){try{if(C.childNodes[A]&&C.childNodes[A].id.indexOf("pacOnDateContent")>=0){C.childNodes[A].style.display="inline"}else{C.childNodes[A].style.display="block"}}catch(F){}}}}}if(E!="EAll"&&E!="CAll"){PACOnDateExpandedCheck()}}function PACOnShowDateClick(A,E,C,D){if(!(E&&E.length>0)){return}document.getElementById("isCurrentPlaylist").value=A;document.getElementById("requestedDate").value=E;for(var B=0;B<pacTotalRecords;B++){try{if(document.getElementById("pacOnDate"+B).style.height=="24px"){if(document.getElementById("expandedMonths").value.length>0){document.getElementById("expandedMonths").value+=","+B}else{document.getElementById("expandedMonths").value=B}}}catch(F){}}document.forms.aspnetForm.action=PACSetArtistAlbumRequest(C,D);document.forms.aspnetForm.submit()}function PACHideCurrentPlaylist(A){if(A=="True"&&document.getElementById("pacOnDateParent0")){document.getElementById("pacOnDateParent0").style.display="none"}};
