function PACSetArtistAlbumRequest(E,G){if(E<=0||G<=0){return window.location.href}var C=window.location.href.replace(/#/,"").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+="&artistid="+E;B=true}else{if(A==false&&C[D].indexOf("playlistid=")>=0){F+="&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 A=window.location.href.split("&");var C=0;var D=0;for(var B=A.length-1;B>=0;B--){if(C==0&&A[B].indexOf("artistid=")>=0){C=A[B].split("=")[1]}else{if(D==0&&A[B].indexOf("playlistid=")>=0){D=A[B].split("=")[1]}}}if(C>0||D>0){location.href=PACSetArtistAlbumRequest(C,D)}}fplpg={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(C,A,B){if(this.morePlaylistNumber>0&&B!=null&&this.morePlaylistNumber!=B.length){document.forms.aspnetForm.action=PACSetArtistAlbumRequest(A.Id,A.PlaylistId);document.forms.aspnetForm.submit()}this.morePlaylistNumber=B.length;this.lease=C;this.playlists=new Array();this.Add(new PlayList(A.OnDate,A.Id,A.Name,A.Url,A.ImageUrl,A.PlaylistId,A.PlaylistName,A.PlaylistSongCount,A.PlaylistCreateDate,A.PlaylistDesc,A.SongsBy));this.AddList(B)},Add:function(A){if(this.Find(A.id,A.plId,A.onDate)!=null){return}this.playlists[this.playlists.length]=A},AddList:function(A){for(var B=0;B<A.length;B++){if(this.Find(A[B].Id,A[B].PlaylistId,A[B].OnDate)!=null){continue}this.playlists[this.playlists.length]=new PlayList(A[B].OnDate,A[B].Id,A[B].Name,A[B].Url,A[B].ImageUrl,A[B].PlaylistId,A[B].PlaylistName,A[B].PlaylistSongCount,A[B].PlaylistCreateDate,A[B].PlaylistDesc,A[B].SongsBy)}},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,J,G,E,I,F,K,H){this.onDate=C;this.id=D;this.name=A;this.url=B;this.imageUrl=J;this.plId=G;this.plName=E;this.plSongCount=I;this.plCreateDate=F;this.plDesc=K;this.plSongsBy=H;this.ToString=function(){return"Artist("+this.id+") "+this.name+" Playlists("+this.plId+") "+this.plName}}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="#&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,G,A,D){fplpg.topModalWindow.close();var I=fplpg.cache.FindMainPlaylist(B,G,A);var H=fplpg.cache.FindOtherPlaylists(B,G,A);if(I==null||H==null){return}try{document.getElementById("shell").load_playlist(I.id,I.plId)}catch(F){}$("#fplmplatag").attr("href",I.url);$("#fplmplimgtag").attr("src",I.imageUrl);$("#fplmplcnttag").html(I.plName+" ("+I.plSongCount+")");$("#fplmpldatetag").html(I.plCreateDate);$("#fplmpla2tag").attr("href",I.url).html(I.name);$("#fplmpldscrtag").html(I.plDesc);for(var E in H){try{var C=new Function('OnFeaturedPlayistClick(eval({"IsCurrentPlaylist":'+D+',"OnDate":"'+H[E].onDate+'","Id":'+H[E].id+',"PlaylistId":'+H[E].plId+"}))");document.getElementById("fploplclicktag"+E).onclick=C;document.getElementById("fploplclick2tag"+E).onclick=C}catch(F){continue}$("#fploplimgtag"+E).attr("src",H[E].imageUrl);$("#fploplcnttag"+E).html(H[E].plName+" ("+H[E].plSongCount+")");$("#fplopldatetag"+E).html(H[E].plCreateDate);$("#fploplatag"+E).attr("href",H[E].url).html(H[E].name);$("#fploplsongktag"+E).html(H[E].plSongsBy);$("#fploplah1tag"+E).attr("href",fplpg.cache.thePageUrl+"&artistid="+H[E].id+"&playlistid="+H[E].plId);$("#fploplah2tag"+E).attr("href",$("#fploplah1tag"+E).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"}};