var cplpdMethods={modalWindow:{parent:"body",windowId:null,content:null,width:null,height:null,close:function(){$(".modal-window").remove();$(".modal-overlay").remove()},open:function(C,B){var A="";A+='<div class="modal-overlay"></div>';A+='<div id="'+this.windowId+'" class="modal-window" style="width:'+this.width+"px; height:"+this.height+"px; margin-top:"+C+"px; margin-left:"+B+'px;">';A+=this.content;A+="</div>";$(this.parent).append(A);$(".modal-window").append('<a class="close-window"></a>');$(".close-window").click(function(){cplpdMethods.modalWindow.close()})}},CopyPlaylist:function(A,F,D,H,G,C,E,I,J,B){if(F=="-1"){MySpaceMusic.EnforceLogin()}else{cplpdVars.initializeVars(D,H,G,C);cplpdMethods.OpenModalWindow(A,E,I,J,B)}return false},CreatePlaylist:function(A){window.location.href=A},OnGetTokenSuccess:function(A){MyMusic.WebSvrManager.token=A;cplpdVars.playlistsResult=new Array();cplpdVars.cmplContent=document.getElementById(cplpdVars.parentDiv).innerHTML;document.getElementById(cplpdVars.parentDiv).innerHTML="";MySpace.Web.Modules.MusicV2.Services.MyMusic.GetPlayLists(cplpdVars.userId,cplpdVars.playlistType,cplpdMethods.GetPlaylistOnSuccess,MusicCommon.PlaylistManager.ManagePlaylistOnFailure)},OnGetTokenFalure:function(A){alret(A)},OpenModalWindow:function(F,D,E,A,B){cplpdMethods.modalWindow.windowId=F;cplpdMethods.modalWindow.width=E;cplpdMethods.modalWindow.height=D;cplpdMethods.modalWindow.content=cplpdVars.cmplContent;cplpdMethods.modalWindow.open(A,B);document.getElementById(cplpdVars.ddlAllPlaylistsId).options.length=0;document.getElementById(cplpdVars.ddlAllPlaylistsId).options[0]=new Option(cplpdVars.choosePlaylistText,0,false);for(var C=0;C<cplpdVars.playlistsResult.length;C++){if(!cplpdVars.playlistsResult[C]){continue}if(cplpdVars.playlistsResult[C].Name==null){cplpdVars.playlistsResult[C].Name=""}document.getElementById(cplpdVars.ddlAllPlaylistsId).options[C+1]=new Option(cplpdVars.playlistsResult[C].Name.replace(/%20/g," "),cplpdVars.playlistsResult[C].Id,false)}if(document.getElementById(cplpdVars.ddlAllPlaylistsId).options&&document.getElementById(cplpdVars.ddlAllPlaylistsId).options.length>1){document.getElementById(cplpdVars.ddlAllPlaylistsId).selectedIndex=0}cplpdMethods.OnCreateNewTextBoxEnter(false);cplpdMethods.UpdateUI()},GetPlaylistOnSuccess:function(A,B){if(!A){return}cplpdVars.playlistsResult=A;MusicCommon.General.CloseProgress()},OnSavePlayList:function(){if(document.getElementById(cplpdVars.saveButton).disabled){return}if(cplpdVars.radioAddChecked=="true"){MySpace.Web.Modules.MusicV2.Services.MusicCommonService.CopyPlaylistToExistingMyPlaylist(cplpdVars.artistId,cplpdVars.sourcePlaylistId,cplpdVars.userId,document.getElementById(cplpdVars.ddlAllPlaylistsId)[document.getElementById(cplpdVars.ddlAllPlaylistsId).selectedIndex].value,MusicCommon.PlaylistManager.CopyPlaylistOnSuccess,MusicCommon.PlaylistManager.ManagePlaylistOnFailure)}else{MySpace.Web.Modules.MusicV2.Services.MusicCommonService.CopyPlaylistToNewMyPlaylist(cplpdVars.artistId,cplpdVars.sourcePlaylistId,cplpdVars.userId,document.getElementById(cplpdVars.newPlaylistEnterId).value,"",cplpdVars.makeItPrivate,MusicCommon.PlaylistManager.CopyPlaylistOnSuccess,MusicCommon.PlaylistManager.ManagePlaylistOnFailure)}MusicCommon.General.CloseProgress();cplpdMethods.modalWindow.close()},OnCreateNewTextBoxEnter:function(A){if(A){if(document.getElementById(cplpdVars.newPlaylistEnterId).value==cplpdVars.createPlaylistText){document.getElementById(cplpdVars.newPlaylistEnterId).value=""}}else{if(document.getElementById(cplpdVars.newPlaylistEnterId).value.length==0){document.getElementById(cplpdVars.newPlaylistEnterId).value=cplpdVars.createPlaylistText}}},OnMakeItPrivateClick:function(){if(cplpdVars.makeItPrivate=="true"){cplpdVars.makeItPrivate="false"}else{cplpdVars.makeItPrivate="true"}cplpdMethods.UpdateUI()},OnSelectChoiceClick:function(A){cplpdVars.radioAddChecked=A;cplpdMethods.UpdateUI()},OnSaveHover:function(A){if(A&&(cplpdVars.radioAddChecked=="true"&&document.getElementById(cplpdVars.ddlAllPlaylistsId).selectedIndex!=0||cplpdVars.radioAddChecked!="true"&&document.getElementById(cplpdVars.newPlaylistEnterId).value.length>0)){document.getElementById(cplpdVars.saveButton).style.backgroundImage="url("+cplpdVars.saveButtonImgEnabled+")"}else{document.getElementById(cplpdVars.saveButton).style.backgroundImage="url("+cplpdVars.saveButtonImgDisabled+")"}},UpdateUI:function(){if(!document.getElementById(cplpdVars.saveButton)||!document.getElementById(cplpdVars.ddlAllPlaylistsId)||!document.getElementById(cplpdVars.newPlaylistEnterId)||!document.getElementById(cplpdVars.makePlaylistPrivate)||!document.getElementById(cplpdVars.copyPlaylistChoice)||!document.getElementById(cplpdVars.newPlaylistChoice)){return}if(cplpdVars.radioAddChecked=="true"){if(document.getElementById(cplpdVars.ddlAllPlaylistsId).selectedIndex==0){document.getElementById(cplpdVars.saveButton).disabled=true;document.getElementById(cplpdVars.saveButton).style.cursor="default"}else{document.getElementById(cplpdVars.saveButton).disabled=false;document.getElementById(cplpdVars.saveButton).style.cursor="pointer"}}else{if(document.getElementById(cplpdVars.newPlaylistEnterId).value.length==0||document.getElementById(cplpdVars.newPlaylistEnterId).value==cplpdVars.createPlaylistText){document.getElementById(cplpdVars.saveButton).disabled=true;document.getElementById(cplpdVars.saveButton).style.cursor="default"}else{document.getElementById(cplpdVars.saveButton).disabled=false;document.getElementById(cplpdVars.saveButton).style.cursor="pointer"}}if(cplpdVars.makeItPrivate=="true"){document.getElementById(cplpdVars.makePlaylistPrivate).style.backgroundImage="url("+cplpdVars.privatePlaylistImgEnabled+")"}else{document.getElementById(cplpdVars.makePlaylistPrivate).style.backgroundImage="url("+cplpdVars.privatePlaylistImgDisabled+")"}document.getElementById(cplpdVars.ddlAllPlaylistsId).disabled=(cplpdVars.radioAddChecked!="true");document.getElementById(cplpdVars.newPlaylistEnterId).disabled=(cplpdVars.radioAddChecked=="true");if(cplpdVars.radioAddChecked=="true"){document.getElementById(cplpdVars.copyPlaylistChoice).style.backgroundImage="url("+cplpdVars.checboxImgChecked+")";document.getElementById(cplpdVars.newPlaylistChoice).style.backgroundImage="url("+cplpdVars.checboxImgUnchecked+")"}else{document.getElementById(cplpdVars.copyPlaylistChoice).style.backgroundImage="url("+cplpdVars.checboxImgUnchecked+")";document.getElementById(cplpdVars.newPlaylistChoice).style.backgroundImage="url("+cplpdVars.checboxImgChecked+")"}}};