var __pageLoaded=false;function init(){if(window.top.lastSelected!=null){lastSelected.removeClassName("selected");}runLFs();initCtrls();initKeys();__pageLoaded=true;removeInterence.defer();}Event.observe(window,"load",function(){init();});function removeInterence(){var B=$("player");if(!B){return ;}B.siblings().each(function(A){A.remove();});$("playlist").siblings().each(function(A){A.remove();});}function runLFs(){lfs.each(function(C){try{C();}catch(D){}});lfs=[];}function getCookie(C){var D=document.cookie.match(C+"=(.*?)(;|$)");return D?unescape(D[1]):null;}function isChild(C,D){return $(D).ancestors().indexOf(C)!=-1;}function callServer(F,G,H,E){completefn=function(B,C){var A=parseInt(B.responseText);B.resCode=A;if(A==0){(G||Prototype.emptyFunction)(B,C,E);}else{(H||Prototype.emptyFunction)(B,C,E);}};new Ajax.Request(ctx+"ajax",{parameters:F,onComplete:completefn});}function generalError(E,F,D){if(D.container){showErrorBox(D,"error","responseText:"+E.responseText);}}function enqueueSongs(F,G){G=G==null?false:G;var H=$("player");var E={};F.each(function(A,B){E[B]={id:A,score:getSongScore(A)};});E.length=F.length;playMenuSequence([{id:"menu_nowPlaying",type:"flash"},{id:"menu_nowPlaying",type:"jump"}]);H.enqueueSongs(E,G);}function enqueueSong(E,F){F=F==null?false:F;playMenuSequence([{id:"menu_nowPlaying",type:"flash"},{id:"menu_nowPlaying",type:"jump"}]);var D=$("player");D.enqueueSong(E,getSongScore(E),F);}function playItNow(D){playMenuSequence([{id:"menu_nowPlaying",type:"flash"},{id:"menu_nowPlaying",type:"jump"}]);var C=$("player");C.playItNow(D,getSongScore(D));return false;}function playPlaylist(F,D){playMenuSequence([{id:"menu_nowPlaying",type:"flash"},{id:"menu_nowPlaying",type:"jump"}]);var E=$("player");E.playPlaylist(F,D);}function updateScore(E,F){var D=$("player");D.updateScore(E,F);}function broadcastScore(D,C){setSongScore(D,C);}var isSongPlaying=false;function broadcastSongChange(E,F,D){isSongPlaying=!!F;if(!F){$("content").readAttribute("title");}else{document.title="cherrypeel.com - now playing "+F.toLowerCase()+" - "+D.toLowerCase();}}function fltrace(B){if(window.console){console.log(B);}}function makePlaylistCall(E,D){var F=$("playlist");F.interSwfCall(E,D);}function makePlayerCall(E,D){var F=$("player");F.interSwfCall(E,D);}function nextSong(){$("player").nextSong();}function prevSong(){$("player").prevSong();}function togglePlay(){$("player").togglePlay();}function getErrorText(B){return $(B).select("p.error_text").first();}function showError(C,D){C.update(D);C.show();}function getInfoBox(B){return __getBox(B,"info_box","error_box");}function getErrorBox(B){return __getBox(B,"error_box","info_box");}function __getBox(G,H,I){var F=$(G).select("div."+H).first();if(!F){F=$(G).select("div."+I).first();if(F){F.toggleClassName(H).toggleClassName(I);}}if(!F){return ;}var J=F.down("img");if(J&&Prototype.Browser.IE){J.remove();}return F;}function showInfoBox(F,G,H,I,J){return __showBox(false,F,G,H,I,J);}function showErrorBox(F,G,H,I,J){return __showBox(true,F,G,H,I,J);}function __showBox(L,P,N,J,R,K){var O=L?getErrorBox(P):getInfoBox(P);var Q=O.down("h2");if(Q){Q.update(N);}var M=O.down("p");if(M){M.update(J);}Effect.Appear(O,{duration:0.7,afterFinish:K||Prototype.emptyFunction});if(R){Effect.Fade(O,{delay:0.7+R,duration:0.7});}_scrollTo(O);return O;}function hideBox(C){var D=getErrorBox(C);if(D){D.hide();}}function formatErrorSentence(J,I){if(J.length==1){return J[0]+" is "+I+".";}var H="";var F=J.length;for(var G=0;G<F;G++){if(G==F-1){H+="and "+J[G]+" are "+I+".";}else{if(G==F-2){H+=J[G]+" ";}else{H+=J[G]+", ";}}}return H;}function clearFormErrors(B){$(B).getElements().invoke("removeClassName","error");}function _scrollTo(F,D){F=$(F);var E=F.cumulativeOffset();window.top.scrollTo(E[0],E[1]);}currentUrl="home.jsp";function setContent(C,D){if(Object.isElement(C)){C=$(C).readAttribute("href");C=C.gsub("/link/","/");}if(C.indexOf("http://")!=-1){C=C.substr(C.indexOf("/",7));}currentUrl=C.split("///").join("?").split("//").join("&");new Ajax.History.Updater("contentframeContainer",C,{evalScripts:true,method:"get",history:{cache:false,id:"p",state:C.split("?").join("///").split("&").join("//")},onComplete:function(){if(window.pageTracker){pageTracker._trackPageview(C);}var A=$("content");initCtrls(A);initLightboxes(A);resizeContent();setSidebarVis();onContentNavigate(C);$("logo").scrollTo();$("footer").show();}});return false;}function reloadContent(){setContent(currentUrl);}function getFrameDocument(F,E){var H=$(F);var G=H.contentWindow||H.contentDocument;if(G.document&&!E){G=G.document;}return G;}function onContentNavigate(G){var H=G.split(ctx).last();H=H.sub(".jsp","");var I=H.split("/");var F=I.first();$("menubar").select("td.active").each(function(A){A.removeClassName("active");});var J=$("mnu"+F);if(J){J.addClassName("active").blur();}if(!isSongPlaying){document.title=$("content").readAttribute("title");}$("content").writeAttribute("title","");}function initLightboxes(D){lbox=$(D).select(".lbOn");var C=lbox.length;for(i=0;i<C;i++){valid=new lightbox(lbox[i]);}}function resizeContent(){var H=getWindowScroll();var I=$("content");var J=$("sidebar");I.setStyle({"height":"auto"});var N=I.cumulativeOffset();var K=J.cumulativeOffset();var M=Math.max(I.getHeight(),J.getHeight());var L=H.h-K.top;if(M<L){I.setStyle({"height":L+"px"});}}function showRegisterTease(){sendVisualNotification("please log in or register to use this feature");return false;}smdivs={menu_playlists:"playlistbar",menu_nowPlaying:"nowplayingbar",menu_genres:"genresbar",menu_invite:"invitebar",menu_friends:"friendsbar",menu_submit:"submitbar"};function onSideMenuPress(C){if($(C).hasClassName("active")){return false;}var D=C.up("tr");showSidebar(D);return false;}function getSelSidebar(){return $("sideMenu").select("tr.active")[0];}function showSidebar(F){var I=smdivs[F.id];for(var J in smdivs){if(smdivs[J]==I){continue;}if(!$(J)||$(J).hasClassName("inactive")){continue;}if(!$(J)){continue;}$(J).removeClassName("active");var H=$(smdivs[J]);if(J=="menu_nowPlaying"){if(H.getStyle("textIndent")!="-9000px"){hidePlaylist();}}else{H.hide();}}var G=$(I);if(F.id=="menu_nowPlaying"){if(G.__oDim){showPlaylist();}}else{G.show();}if(F.addClassName){F.addClassName("active");}}function playMenuSequence(I){if(window!=window.top){window.top.playMenuSequence(I);return false;}var L=0;var H=I.length;for(var M=0;M<H;M++){var K=I[M];var J;if(K.time){L=K.time;}switch(K.type){case"jump":var N=getSelSidebar();J=function(){showSidebar($(arguments.callee.s.id));};J.s=K;setTimeout(J,L);if(K.duration){J=function(){showSidebar(arguments.callee.curSel);new Effect.Highlight(arguments.callee.curSel,{restorecolor:"#FFFFFF",duration:1});};J.curSel=N;setTimeout(J,L+K.duration);}break;case"flash":J=function(){new Effect.Highlight(arguments.callee.s.id,{duration:1});};J.s=K;setTimeout(J,L);break;case"func":J=function(){arguments.callee.s.func.apply(window,arguments.callee.s.args);};J.s=K;setTimeout(J,L);break;}}return false;}function togglePlayer(){var B=window.top.$("playerContainer");if(B.getStyle("textIndent")!="-9000px"){B.__oDim=B.getDimensions();B.setStyle({"textIndent":"-9000px","width":"0px","height":"0px"});hidePlaylist();}else{B.setStyle({"textIndent":"0px","width":B.__oDim.width+"px","height":B.__oDim.height+"px"});showPlaylist();}}function hidePlaylist(){var B=window.top.$("nowplayingbar");if(B.getStyle("textIndent")!="-9000px"){if(Prototype.Browser.WebKit){B.__oDim=true;B.setStyle({"position":"static","textIndent":"-9000px"});}else{B.__oDim=B.getDimensions();B.setStyle({"textIndent":"-9000px","width":"0px","height":"0px"});}}else{B.__wasHidden=true;}}function showPlaylist(){var B=window.top.$("nowplayingbar");if(B.__wasHidden){B.__wasHidden=false;}else{if(Prototype.Browser.WebKit){B.setStyle({"position":"absolute","textIndent":"0px"});}else{B.setStyle({"textIndent":"0px","width":B.__oDim.width+"px","height":B.__oDim.height+"px"});}}}function enableForm(E,D,F){E.getElements().each(function(A){if(D){A.enable().removeClassName("disbl");
if(!F){A.clear();}}else{if(!F){A.clear();}A.disable().addClassName("disbl");}});}function observeOnce(F,G,H){var E=null;E=function(A){Event.stopObserving(F,G,E);H(A);};Event.observe(F,G,E);}function sendVisualNotification(K,J,L){$("ntfMessage").update(K);var G=$("ntfContainer");if(!J){J=3;}var H=$("notifier");if(L){if(H.hasClassName("info")){H.addClassName("error").removeClassName("info");}}else{if(H.hasClassName("error")){H.removeClassName("error").addClassName("info");}}if(!isIE6()){Effect.Appear(H,{duration:0.5,afterFinish:function(){if(J!=-1){Effect.Fade(H,{delay:J,duration:0.5});}}});}else{if(L){H.setStyle({"background-image":"url('../images/notifier_error_bg.png')"});}else{H.setStyle({"background-image":"url('../images/notifier_info_bg.png')"});}H.show();var I=function(){H.hide();};I.delay(J);}}function initKeys(){var B=0;document.observe("keydown",function(A){var F=A.element();if(F.nodeName!="HTML"&&F.nodeName!="A"&&F.visible()){return ;}var E=false;if(!B){switch(A.keyCode){case 32:togglePlay();E=true;break;case Event.KEY_LEFT:prevSong();E=true;break;case Event.KEY_RIGHT:nextSong();E=true;break;case 224:case 17:case 18:B=2;break;}if(E){A.stop();}}else{B--;}});document.observe("keyup",function(A){var D=A.element();if(D.nodeName!="HTML"&&D.nodeName!="A"&&D.visible()){return ;}switch(A.keyCode){case 224:case 17:case 18:B=0;break;default:break;}});}function insertYesNo(L,P,K,R,O){var N=$(L);L=N.identify();var M="__"+L+"__yes_no";var J="<div id='"+M+"' style='display: inline;'>";if(K!=null){J+="<span class='error_text'>"+K+"</span> ";}J+="<a id='__"+L+"_y' href='#' class='bylink'>yes</a> ";J+="<a id='__"+L+"_n' href='#' class='bylink'>no</a>";J+="</div>";N.insert({after:J});var Q=$(M);observeOnce("__"+L+"_y","click",function(A){Effect.Appear(N,{duration:0.5});Q.remove();if(R){R(P);}});observeOnce("__"+L+"_n","click",function(A){Effect.Appear(N,{duration:0.5});Q.remove();if(O){O(P);}});N.hide();return false;}function checkAllBoxes(F,G,E){var H="input[type='checkbox']";H+=!E?"":"."+E;$(F).select(H).each(function(A){A.checked=G;});return false;}function watchMaxLength(F,D){var F=$(F);var E=function(A){var B=$F(F);if(B.length>D){F.setValue(B.truncate(D,""));}};Event.observe(F,"keyup",E);Event.observe(F,"change",E);}function addInputHint(D,C){D.resetInputHint=function(){D=$(D);D.setValue(C);D.addClassName("inputhint");observeOnce(D,"focus",function(A){D.removeClassName("inputhint");D.setValue("");});};D.resetInputHint();}function initCtrls(J){if(!J){Form.Element.Serializers.textarea=function(B,A){if(A===undefined){return $(B).hasClassName("inputhint")?"":B.value;}B.value=A;};}var I=(J?$(J):$("earshere")).select("input[inputhint], textarea[maxlength],textarea[inputhint]");var H=I.length;for(var N=0;N<H;N++){var L=I[N];var M=L.readAttribute("maxlength");if(M){watchMaxLength(L,M);}var K=L.readAttribute("inputhint");if(K){addInputHint(L,K);}}}function getWindowScroll(w){if(!w){w=window;}var T,L,W,H;with(w.document){if(w.document.documentElement&&documentElement.scrollTop){T=documentElement.scrollTop;L=documentElement.scrollLeft;}else{if(w.document.body){T=body.scrollTop;L=body.scrollLeft;}}if(w.innerWidth){W=w.innerWidth;H=w.innerHeight;}else{if(w.document.documentElement&&documentElement.clientWidth){W=documentElement.clientWidth;H=documentElement.clientHeight;}else{W=body.offsetWidth;H=body.offsetHeight;}}}return{t:T,l:L,w:W,h:H};}function highlightLogin(){if(window!=window.top){window.top.highlightLogin();return false;}new Effect.Highlight("inlinelogin",{duration:1});$("topmenu").scrollTo();$("inlinelogin").down('input[type="text"]').focus();sendVisualNotification("please log in first",2,true);return false;}function doErrorHighlight(D,C){if(C==undefined){C=1;}new Effect.Highlight(D,{duration:C,startcolor:"#ECA29F",endcolor:"#F1DDDD"});}function grow(D,C){if(C.w){D.setStyle({width:(D.getWidth()+C.w)+"px"});}if(C.h){D.setStyle({height:(D.getHeight()+C.h)+"px"});}}function hideSongItem(B){$("vi"+B).hide();}function updatePoints(I,K){var H=window;var L=H.$("score"+I);if(L){var J=L.innerHTML;var N=J.indexOf(" ");if(N>-1){J=J.substring(0,N);}var J=parseInt(J)+K;var M=" point";if(J!=1&&J!=-1){M+="s";}L.innerHTML=J+M;L.className="highlight";}}function privateVote(){sendVisualNotification("this song is not published - voting is not allowed");}function updateArrows(H,J){if(H&&J!=undefined){var L=window;var G=L.$("arrows"+H);var I=G.select(".downmod, .down").first();var K=G.select(".upmod, .up").first();if(!K){return ;}if(J>0){updatePoints(H,I.hasClassName("downmod")?2:1);K.className="arrow upmod";I.className="arrow down";}else{if(J<0){updatePoints(H,K.hasClassName("upmod")?-2:-1);K.className="arrow up";I.className="arrow downmod";}else{if(J==0){updatePoints(H,K.hasClassName("upmod")?-1:1);K.className="arrow up";I.className="arrow down";}}}}}function setSongScore(D,C){updateArrows(D,C);}function getSongScore(M){var L=window;var K=L.$("arrows"+M);if(!K){var N=L.$("earshere").select("ul li[eh_info]");var J=N.length;for(var R=0;R<J;R++){var Q=N[R];if(Q.eh_info.id==M){return Q.eh_info.score;}}return 0;}var P=K.select(".downmod, .down").first();var O=K.select(".upmod, .up").first();if(!O){return 0;}if(O.hasClassName("upmod")){return 1;}else{if(P.hasClassName("downmod")){return -1;}}return 0;}function flash(H,I,K,J,G,L){if(!I){I=1;}if(!K){K=3;}if(!G){G="#F1BC5C";}if(!J){J=1;}if(!L){L="#FFFFFF";}new Effect.Highlight(H,{delay:K,duration:J*I,startcolor:L,endcolor:G,restorecolor:L,transition:function(B,A){return Effect.Transitions.pulse(A,B);}.bind(this,I)});}function vempty(B){return B.strip().length==0;}function vnotempty(B){return !vempty(B);}function vregex(D,C){return(new RegExp(C)).exec(D);}function vnumber(B){return !isNaN(B);}function vint(B){return vnumber(B)&&parseFloat(B)==parseInt(B);}function vpass(B){return vregex(B,".{3,20}");}function vuser(B){return vregex(B,"^[A-Za-z0-9-_]{3,20}$");}function vperma(B){return vregex(B,"^[A-Za-z0-9-_]{3,255}$");}function vemail(C){var D=/^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;return D.test(C);}function vurl(B){return/^(\w+:\/\/)?(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+|localhost)(:(\d+))?\/?/i.test(B);}function vascii(G){var E=G.length;for(var H=0;H<E;H++){var F=G.charCodeAt(H);if(F>127||F<31){return H;}}return -1;}function vote(I,M,L){var H=$("arrows"+I);var J=H.select(".downmod, .down").first();var N=H.select(".upmod, .up").first();var K;if(M>0&&N.hasClassName("upmod")||M<0&&J.hasClassName("downmod")){K=0;}else{if(M>0){K=1;}else{if(M<0){K=-1;}}}updateArrows(I,K);updateScore(I,K);switch(L){case"s":L="song";break;case"c":L="comment";break;case"a":L="artist";break;case"p":L="playlist";break;}callServer({op:"vote",id:I,type:L,score:K});}function hideSong(B){hideSongItem(B);_hideSong(B);}function _hideSong(B){callServer({op:"hide",id:B});}function unhide(B){hideSongItem(B);_unhide(B);}function _unhide(B){callServer({op:"unhide",id:B});}function save(E,F){if(F==null){F="save";}var D=$("save"+E);D.update("earmarked");_save(E,F);}function _save(D,C){callServer({op:C,id:D});}function unsave(D,C){if(C==null){C="unsave";}hideSongItem(D);_save(D,C);}function doComment(J,K,H){if(!vcomment(J)){return false;}var I={op:$F(J.op)};var L=J.down("textarea");if(L){I.txt=$F(L);}if(J.thread){I.thread=$F(J.thread);}if(J.commentid){I.commentid=$F(J.commentid);}if(J.parentid){I.parentid=$F(J.parentid);}if(J.drone){I.drone=$F(J.drone);}var G=$(J).down("button");if(G){G.disabled=true;}callServer(I,function(B,C,A){if(G){G.disabled=false;}if(K){K(B,C,A);}},function(B,C,A){if(G){G.disabled=false;}if(H){H(B,C,A);}},J);return false;}function replyPrompt(G,J){var I=$("replyform");if(!J){I.hide();}else{var H=$("vi"+G);var F=H.immediateDescendants().last().immediateDescendants().last();if(F.hasClassName("comments")){F=F.previous();}if(I.txt){$(I.txt).setValue("");}if(I.reptxt){$(I.reptxt).setValue("");}$(I.parentid).setValue(G);F.insert({after:I});I.show();if(I.txt){$(I.txt).focus();}if(I.reptxt){$(I.reptxt).focus();}}return false;
}function editCommentForm(D,C){$("ctext"+D)[C?"hide":"show"]();$("sli"+D)[C?"hide":"show"]();$("editform"+D)[!C?"hide":"show"]();if(C){$("editform"+D).down("textarea").focus();}return false;}function delCommentPrompt(C){var D=function(A){doComment(A,onDeleteComment);};insertYesNo($(C).down("a"),C,"are you sure?",D);return false;}function onPostComment(F,D,E){E.txt.resetInputHint();new Ajax.Updater("commentListing",ctx+"assets/includes/comment_item_template.jsp",{parameters:{id:D.id,hidden:true},evalScripts:true,insertion:Insertion.Top,onComplete:function(){Effect.Appear($("vi"+D.id),{duration:0.6});sendVisualNotification("comment added");}});}function onEditComment(H,E,G){var F=E.id;editCommentForm(F,false);$("ctext"+F).update(E.text);sendVisualNotification("comment edited");}function onReplyComment(K,L,J){var H=L.parentid;var I=$("vi"+H);var G=I.down(".comments");replyPrompt(null,false);new Ajax.Updater(G,ctx+"assets/includes/comment_item_template.jsp",{parameters:{"id":L.id,"hidden":true},evalScripts:true,insertion:Insertion.Top,onComplete:function(){Effect.Appear($("vi"+L.id),{duration:0.6});sendVisualNotification("comment added");}});}function onDeleteComment(M,N,L){var I=N.id;var K=$("vi"+I);var H=K.down(".comments");if(!H){K.remove();}else{var J=new Element("div");J.addClassName("songlinktext");J.update('<div class="commenttext deleted"><em>comment deleted</em></div>');J.insert({bottom:H});K.update(J);}sendVisualNotification("comment deleted");}function vcomment(E){hideBox(E);var F=null;if(E.txt){var D=$F(E.txt).strip();if(!D.length){F="please enter a comment";}else{if(D.length>15000){F="comment is too long";}}}if(F){showErrorBox(E,"error",F,4.5);}return F==null;}function beginMailCheck(){setInterval("checkMail()",240000);checkMail();}function checkMail(){callServer({op:"cmail"},onCheckMail);}function onCheckMail(D,C){if(C.hasMail){showUnread(true);flash("mailflash",6,3);}else{showUnread(false);}}function showUnread(B){if(window!=window.top){window.top.showUnread(B);return ;}if(B){$("mail").hide();$("newmail").show();}else{$("mail").show();$("newmail").hide();}}function clearInputHint(B){B.value="";B.style.color="black";B.onfocus=null;}function reply(B){$("replyform"+B).show();$("commentreply"+B).focus();}function report(H){if(!vreport(H)){return false;}$(H.submit).disable();var E=$F(H.id);var G=$F("reasonlist");var F;switch(G){case"inappropriate":case"copyrightinfringe":F=$F(H.inappropriate_reason);break;case"badgenre":F="should be genre "+$F(H.genre);break;case"badinfo":F="should be "+$F(H.title)+" - "+$F(H.artist);break;}callServer({op:"report",reason:G,id:E,msg:F},onReport,onReport,H);return false;}function vreport(C){var D=$F("reasonlist");if(D=="-1"){return false;}switch(D){case"inappropriate":case"copyrightinfringe":if($F(C.inappropriate_reason).strip().length==0){sendVisualNotification("please enter a description for your report",5,true);return false;}break;case"badgenre":if(C.genre.selectedIndex==0){sendVisualNotification("please enter the correct genre for this content",5,true);return false;}break;case"badinfo":if(vempty($F(C.title))&&vempty($F(C.artist))){sendVisualNotification("please supply the correct information",5,true);return false;}break;}return true;}function onReport(E,F,D){$(D.submit).enable();$("lbContent").__lb__.deactivate();sendVisualNotification("content was successfully reported",5);}function logout(){$("outform").submit();reloadContent();}function filterGenres(F){hideBox(F);var E="ajax=1&op=genchange&";var D=$("genres");D.select("input[type='checkbox']").each(function(A){if(!A.checked){return ;}E+="g="+A.value+"&";});if(E.length==0){showErrorBox(F,"error","please select at least one genre");return ;}callServer(E,onFilterGenre,onFilterGenre);return false;}function onFilterGenre(B){reloadContent(true);sendVisualNotification("genres changed");}function submitFPass(C){hideBox(C);var D=$F(C.fpassid);if(!vnotempty(D)){showErrorBox(C,"error","please enter a username or email address");return false;}params={op:"fpassv",id:D};callServer(params,function(A){showInfoBox(C,"email sent","an email has been sent to your email address describing how to obtain a new password");},function(A){switch(A.resCode){case 1:showErrorBox(C,"account not found","no account could be found matching the information you provided");break;case 3:case 5:showErrorBox(C,"error","an error occurred while attempting to reset your password. please try again later");break;}});return false;}function submitChangePass(E){hideBox(E);var F=$F(E.passwd);var H=$F(E.passwd2);if(!vpass(F)){showErrorBox(E,"error","invalid password (between 3-20 characters)");return false;}if(F!=H){showErrorBox(E,"error","passwords do not match");return false;}var G={op:"cpass",passwd:F,code:$F(E.code)};callServer(G,function(A){sendVisualNotification("password changed",3);setContent(ctx+"login");},function(A){switch(A.resCode){case 1:showErrorBox(E,"invalid link","the link that you followed was invalid or incomplete. try copying and pasting the full link into the address bar.");break;case 3:case 5:showErrorBox(E,"error","an error occurred while attempting to change your password. please try again later");break;}});return false;}function updatePL(J,G,H){G.id=J;var F=Object.toJSON(G);var I={ajax:1,op:"pledit",pl:F};callServer(I,H,H,G);}function submitPlaylistDestForm(){var D=lastAddSongId;if($("playlistDest_new").visible()){var C=$("destPlaylistName").value;addPlaylist(C,function(A){addSongToPlaylist(A,D);});}else{addSongToPlaylist($F("destPlaylistCbo"),D);}}function addPlaylist(E,F){var H=$("addplerror");H.update("");H.hide();var G={ajax:1,op:"pladd",name:E};completefn=function(B){var C=B.responseText;if(C&&C.length>0){var A=C.split(" ");C=parseInt(A[0]);if(C==0){F(A[1],A[2]);}else{if(C==4){H.update("name taken");H.show();$("addingPl").hide();$("addPlForm").show();}else{if(C==5){alert("unspecified error");}else{if(C==2){alert("insufficient permissions");}else{if(C==3){alert("parameters bad");}}}}}}};callServer(G,completefn,completefn);}function addSongToPlaylist(O,J,K){var L={ajax:1,op:"pladds",plid:O,sid:J};var I=this;var P=$A(arguments).slice(3);var M=function(A){if(K){K.apply(I,P);}sendVisualNotification("song added to playlist",3);};var N=function(B){var A="";switch(B.resCode){case 1:A="song not found";break;case 2:case 3:A="an error occurred while adding the song";break;case 4:A="that song already exists in the playlist";if(K){K.apply(I,P);}break;}sendVisualNotification(A,4,true);};callServer(L,M,N);}function delPlaylistFromList(B){delPlaylist(B,function(A){playMenuSequence([{id:"menu_playlists",type:"jump"},{id:"playlistbar",type:"flash"},{type:"func",func:function(){window.top.Effect.Fade(window.top.$("pl"+A));},args:[],time:800}]);delete userpls[A.toString()];reloadContent();});}function delPlaylist(E,F){var D={ajax:1,op:"pldel",id:E};completefn=function(B){var C=B.responseText;if(C&&C.length>0){var A=C.split(" ");C=parseInt(A[0]);if(C==0){F(E);}else{if(C==1){alert("unspecified error");}else{if(C==2){alert("insufficient permissions");}else{if(C==3){alert("parameters bad");}}}}}};callServer(D,completefn,completefn);}var addPLCallback;function showAddPlaylistForm(F){if(window!=window.top){window.top.showAddPlaylistForm(F);return ;}addPLCallback=F;var E=$("addPl");if(E.visible()){return ;}$("addPlaylist_on").toggle();$("addPlaylist").toggle();var H=$("plname");H.value="";var G=$("playlists");G.insert({top:E});E.show();new Effect.Highlight("addPl",{duration:1,afterFinish:function(){H.activate();}});}function submitAddPlaylistForm(G){var H=$F("plname");var F=getErrorText(G);F.hide();if(H.strip().length==0){F.innerHTML="please enter a playlist name";F.show();setTimeout(function(){Effect.Fade(F,{duration:1});},1500);return ;}addPlaylist(H,function(A,B){cancelPlaylistForm();addPlaylistToList(A,H,B);if(addPLCallback){addPLCallback(A);}reloadContent.defer();});$("addPlForm").hide();var E=$("addingPl");E.show();E.select(".name").each(function(A){A.innerHTML=H;});}function cancelPlaylistForm(){$("addPlForm").show();
$("addPl").hide();$("addingPl").hide();$("addPlaylist_on").toggle();$("addPlaylist").toggle();var B=$("addplerror");B.update("");B.hide();document.fire("eh:plCancelled");}function addPlaylistToList(G,F,H){var J=$("playlists");J.insert({top:'<div id="pl'+G+'" class="pl"><a href="#" onclick="return false;" class="listItem plm">'+F+"</a></div>"});J.down("a").writeAttribute("id","pln"+G);var I=$("pl"+G);I.eh_info={id:G,l:H,pub:false};Event.observe.defer(J,"click",function(A){plmenu.show(A);});userpls[G.toString()]={n:F};if(!isIE6()){I.hide();Effect.Appear("pl"+G,{duration:1,afterFinish:function(){new Effect.Highlight("pl"+G,{duration:0.5});}});}}function isIE6(){return Prototype.Browser.IE&&parseInt(Client.version)==6;}var Client={browser:false,OS:false,version:false,current_place:0,current_string:"",detect:navigator.userAgent.toLowerCase(),load:function(){if(Client.check("konqueror")){Client.browser="Konqueror";Client.OS="Linux";}else{$H({safari:"Safari",omniweb:"OmniWeb",opera:"Opera",webtv:"WebTV",icab:"iCab",msie:"Internet Explorer"}).each(function(B){if(!Client.browser&&Client.check(B[0])){Client.browser=B[1];}});}if(!Client.browser&&!Client.check("compatible")){Client.browser="Netscape Navigator";Client.version=Client.detect.charAt(8);}if(!Client.version){Client.version=Client.detect.charAt(Client.current_place+Client.current_string.length);}if(!Client.OS){$H({linux:"Linux",x11:"Unix",mac:"Mac",win:"Windows"}).each(function(B){if(!Client.OS&&Client.check(B[0])){Client.OS=B[1];}});if(!Client.OS){Client.OS="unknown";}}},check:function(B){Client.current_string=B;Client.current_place=Client.detect.indexOf(B)+1;return Client.current_place;}};Client.load();var detect=navigator.userAgent.toLowerCase();var OS,browser,version,total,thestring;function getBrowserInfo(){if(checkIt("konqueror")){browser="Konqueror";OS="Linux";}else{if(checkIt("safari")){browser="Safari";}else{if(checkIt("omniweb")){browser="OmniWeb";}else{if(checkIt("opera")){browser="Opera";}else{if(checkIt("webtv")){browser="WebTV";}else{if(checkIt("icab")){browser="iCab";}else{if(checkIt("msie")){browser="Internet Explorer";}else{if(!checkIt("compatible")){browser="Netscape Navigator";version=detect.charAt(8);}else{browser="An unknown browser";}}}}}}}}if(!version){version=detect.charAt(place+thestring.length);}if(!OS){if(checkIt("linux")){OS="Linux";}else{if(checkIt("x11")){OS="Unix";}else{if(checkIt("mac")){OS="Mac";}else{if(checkIt("win")){OS="Windows";}else{OS="an unknown operating system";}}}}}}function checkIt(B){place=detect.indexOf(B)+1;thestring=B;return place;}Event.observe(window,"load",function(){initialize();getBrowserInfo();},false);var lightbox=Class.create();lightbox.keyEventsAdded=false;lightbox.prototype={yPos:0,xPos:0,initialize:function(B){this.content=B.href;this.doc=window.top;if(Object.isElement(B)){Event.observe(B,"click",this.activate.bindAsEventListener(this),false);B.onclick=function(){return false;};}if(!lightbox.keyEventsAdded){Event.observe(this.doc,"keypress",this.onKeyPress.bindAsEventListener(this),false);lightbox.keyEventsAdded=true;}},onKeyPress:function(B){if(B.keyCode==Event.KEY_ESC){this.deactivate();}},activate:function(){if(browser=="Internet Explorer"){this.getScroll();this.prepareIE("100%","hidden");this.setScroll(0,0);this.hideSelects("hidden");}this.doc.togglePlayer();this.displayLightbox("block");},prepareIE:function(C,D){bod=this.doc.$("earshere");bod.setStyle({height:C,overflow:D});htm=$$("html")[0];htm.setStyle({height:C,overflow:D});},hideSelects:function(B){selects=$$("select");for(i=0;i<selects.length;i++){selects[i].style.visibility=B;}},getScroll:function(){if(self.pageYOffset){this.yPos=self.pageYOffset;}else{if(this.doc.documentElement&&this.doc.documentElement.scrollTop){this.yPos=this.doc.documentElement.scrollTop;}else{if(this.doc.body){this.yPos=this.doc.body.scrollTop;}}}},setScroll:function(C,D){this.doc.scrollTo(C,D);},displayLightbox:function(){var F=this.doc.$("overlay");F.show();var I=this.content.split("/");var J=I[I.length-1];if(J.indexOf("#")){J=J.substr(J.indexOf("#"));}if(J.charAt(0)=="#"){var I=J.split("?");J=I[0];var G={};if(I.length>1){G=I[1].toQueryParams();}var H=this.doc.$(J.substr(1));H.writeAttribute("__origParent",H.up().identify());H.writeAttribute("__wasVis",H.visible());this.setContent(H,G);}else{this.loadInfo();}},loadInfo:function(){fltrace("loadinfo");var B=new Ajax.Request(this.content,{method:"post",parameters:"",onComplete:this.processInfo.bindAsEventListener(this)});},processInfo:function(B){this.setContent(B.responseText);},setContent:function(content,params){info="<div id='lbContent'></div>";this.doc.$("lbLoadMessage").insert({before:info});this.doc.$("lbContent").insert({top:content});var block=this.doc.$("lbContent").down();block.show();if(block.hasAttribute("onshow")){var runHandler=function(jscode,params){eval(jscode);}.bind(block,block.readAttribute("onshow"),params);runHandler();}var lb=this.doc.$("lightbox");lb.className="done";lb.show();this.resize();this.actions();},resize:function(){var J=this.doc.$("lbContent");J["__lb__"]=this;var G=J.down(".fragment");if(!G){return ;}var F=G.getStyle("width");var I=G.getStyle("height");var H=this.doc.$("lightbox");H.setStyle({width:F,height:I});},actions:function(){lbActions=this.doc.$("lbContent").select(".lbAction");for(i=0;i<lbActions.length;i++){Event.observe(lbActions[i],"click",this[lbActions[i].rel].bindAsEventListener(this),false);lbActions[i].onclick=function(){return false;};}},insert:function(D){link=Event.element(D).parentNode;Element.remove(this.doc.$("lbContent"));var C=new Ajax.Request(link.href,{method:"post",parameters:"",onComplete:this.processInfo.bindAsEventListener(this)});},deactivate:function(){var J=this.doc.$("lbContent");if(!J){return ;}J.select(".observed").each(function(A){A.stopObserving();if(A.onstopobserving){A.onstopobserving();}});var G=J.down();G.select(".lbAction").invoke("stopObserving","click");if(G.hasAttribute("__origParent")){this.doc.$(G.readAttribute("__origParent")).insert({bottom:G});if(!G.readAttribute("__wasVis")){G.hide();}}J.remove();if(browser=="Internet Explorer"){this.setScroll(0,this.yPos);this.prepareIE("auto","auto");this.hideSelects("visible");}var F=this.doc.$("overlay");var H=F.getOpacity();F.hide();var I=this.doc.$("lightbox");I.hide();this.doc.togglePlayer();}};function initialize(){addLightboxMarkup();lbox=$$(".lbOn");var B=lbox.length;for(i=0;i<B;i++){valid=new lightbox(lbox[i]);}}function addLightboxMarkup(){if(window!=window.top){return ;}b=$("earshere");o=new Element("div");o.writeAttribute({id:"overlay"});$(o).setStyle({display:"none"});lb=new Element("div");lb.writeAttribute({id:"lightbox"});lb.addClassName("loading");$(lb).setStyle({display:"none"});lb.update('<div id="lbLoadMessage">'+"<p>Loading</p>"+"</div>");b.insert({bottom:o});b.insert({bottom:lb});o.setOpacity(0.8);}if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(R,O,Q,M,U,T,W,X,N,S){if(!document.getElementById){return ;}this.DETECT_KEY=S?S:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(R){this.setAttribute("swf",R);}if(O){this.setAttribute("id",O);}if(Q){this.setAttribute("width",Q);}if(M){this.setAttribute("height",M);}if(U){this.setAttribute("version",new deconcept.PlayerVersion(U.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(T){this.addParam("bgcolor",T);}var P=W?W:"high";this.addParam("quality",P);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var V=(X)?X:window.location;this.setAttribute("xiRedirectUrl",V);this.setAttribute("redirectUrl","");
if(N){this.setAttribute("redirectUrl",N);}};deconcept.SWFObject.prototype={useExpressInstall:function(B){this.xiSWFPath=!B?"expressinstall.swf":B;this.setAttribute("useExpressInstall",true);},setAttribute:function(C,D){this.attributes[C]=D;},getAttribute:function(B){return this.attributes[B];},addParam:function(D,C){this.params[D]=C;},getParams:function(){return this.params;},addVariable:function(D,C){this.variables[D]=C;},getVariable:function(B){return this.variables[B];},getVariables:function(){return this.variables;},getVariablePairs:function(){var E=new Array();var F;var D=this.getVariables();for(F in D){E[E.length]=F+"="+D[F];}return E;},getSWFHTML:function(){var L="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}L='<embed type="application/x-shockwave-flash" src="'+this.getAttribute("swf")+'" width="'+this.getAttribute("width")+'" height="'+this.getAttribute("height")+'" style="'+this.getAttribute("style")+'"';L+=' id="'+this.getAttribute("id")+'" name="'+this.getAttribute("id")+'" ';var H=this.getParams();for(var I in H){L+=[I]+'="'+H[I]+'" ';}var J=this.getVariablePairs().join("&");if(J.length>0){L+='flashvars="'+J+'"';}L+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}L='<object id="'+this.getAttribute("id")+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+this.getAttribute("width")+'" height="'+this.getAttribute("height")+'" style="'+this.getAttribute("style")+'">';L+='<param name="movie" value="'+this.getAttribute("swf")+'" />';var K=this.getParams();for(var I in K){L+='<param name="'+I+'" value="'+K[I]+'" />';}var G=this.getVariablePairs().join("&");if(G.length>0){L+='<param name="flashvars" value="'+G+'" />';}L+="</object>";}return L;},write:function(F){if(this.getAttribute("useExpressInstall")){var D=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(D)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var E=(typeof F=="string")?document.getElementById(F):F;E.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var G=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var F=navigator.plugins["Shockwave Flash"];if(F&&F.description){G=new deconcept.PlayerVersion(F.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var J=1;var I=3;while(J){try{I++;J=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+I);G=new deconcept.PlayerVersion([I,0,0]);}catch(H){J=null;}}}else{try{var J=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(H){try{var J=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");G=new deconcept.PlayerVersion([6,0,21]);J.AllowScriptAccess="always";}catch(H){if(G.major==6){return G;}}try{J=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(H){}}if(J!=null){G=new deconcept.PlayerVersion(J.GetVariable("$version").split(" ")[1].split(","));}}}return G;};deconcept.PlayerVersion=function(B){this.major=B[0]!=null?parseInt(B[0]):0;this.minor=B[1]!=null?parseInt(B[1]):0;this.rev=B[2]!=null?parseInt(B[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(B){if(this.major<B.major){return false;}if(this.major>B.major){return true;}if(this.minor<B.minor){return false;}if(this.minor>B.minor){return true;}if(this.rev<B.rev){return false;}return true;};deconcept.util={getRequestParameter:function(G){var F=document.location.search||document.location.hash;if(G==null){return F;}if(F){var H=F.substring(1).split("&");for(var E=0;E<H.length;E++){if(H[E].substring(0,H[E].indexOf("="))==G){return H[E].substring((H[E].indexOf("=")+1));}}}return"";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var F=document.getElementsByTagName("OBJECT");for(var E=F.length-1;E>=0;E--){F[E].style.display="none";for(var D in F[E]){if(typeof F[E][D]=="function"){F[E][D]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(B){return document.all[B];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;function vsongmenu(C,D){C.options.menuItems.each(function(A){if(!A.dl){return ;}var B=$(D).up(".song").eh_info.dl;var F=$(A.element).hasClassName("disabled");if((!B&&F)||(B&&!F)){return ;}A.element.toggleClassName("disabled");});}function addPlPlayLinks(){var J=[{name:"play now",callback:function(A){id=$(A).up(".song").eh_info.id;playPlaylist(id,true);}},{name:"add to current playlist",callback:function(A){id=$(A).up(".song").eh_info.id;playPlaylist(id);}},{separator:true},{name:"view",callback:function(A){F=$(A).up(".song").eh_info.l;setContent(ctx+"playlist/"+F);}}];var H=$("pls").immediateDescendants().findAll(function(A){return A.hasClassName("song");});var F=H.length;for(var I=0;I<F;I++){var G=H[I];G["eh_info"]=G.readAttribute("eh_info").evalJSON();}new Proto.Menu({selector:".title3",className:"fmenu",menuItems:J,validator:null,documents:[document,window.top.document]});}function addPlayLinks(H,I){var K=[{name:"play now",callback:function(A){playItNow($(A).up(".song").eh_info.id);}},{name:"add to current playlist",callback:function(A){enqueueSong($(A).up(".song").eh_info.id);}},{separator:true},{name:'<img src="'+ctx+'assets/images/up_m.gif" style="float: right"/>vote up',callback:function(A){if(!I){highlightLogin();return ;}vote($(A).up(".song").eh_info.id,1,"s","song");}},{name:'<img src="'+ctx+'assets/images/dn_m.gif" style="float: right"/>vote down',callback:function(A){if(!I){highlightLogin();return ;}vote($(A).up(".song").eh_info.id,-1,"s","song");}},{separator:true},{name:"song's page",callback:function(A){setContent(ctx+"comments/"+$(A).up(".song").eh_info.id);}},{separator:true},{name:"download",dl:true,callback:function(A){window.top.location.href=ctx+"mp3?id="+($(A).up(".song").eh_info.id)+"&download=true";}}];var L=$(H).immediateDescendants().findAll(function(A){return A.hasClassName("song");});var N=L.length;for(var M=0;M<N;M++){var J=L[M];J["eh_info"]=J.readAttribute("info").evalJSON();J.writeAttribute("info","");}if(L[0].hasClassName("comment")){K.splice(2,2);}new Proto.Menu({selector:".title",className:"fmenu",menuItems:K,validator:vsongmenu,documents:[document,window.top.document]});}function addSongPlLinks(){var D=[{name:"which playlist?",title:true}];var F=userpls;var E=true;for(k in F){E=false;D.push({id:k,name:F[k].n,callback:function(A,B){var C=B.id,H=$(A).up(".song").eh_info.id;addSongToPlaylist(C,H,null);playMenuSequence([{id:"menu_playlists",type:"flash"},{id:"menu_playlists",type:"jump"},{id:"pl"+C,type:"flash",time:800}]);}});}D.push({separator:true});D.push({name:"current playlist",callback:function(A,B){var C=$(A).up(".song").eh_info.id;enqueueSong(C);}});D.push({separator:true});D.push({name:"new playlist...",callback:function(B,C){var H=$(B).up(".song").eh_info.id;var A=function(G){addSongToPlaylist(G,H);
};playMenuSequence([{id:"menu_playlists",type:"flash"},{id:"menu_playlists",type:"jump"},{type:"func",func:showAddPlaylistForm,args:[A],time:800}]);}});new Proto.Menu({selector:".addtopl",className:"fmenu",menuItems:D,validator:null,documents:[document,window.top.document]});}function addVoteTooltips(){var B=$("songList");if(!B){return ;}B.select(".arrow").each(function(A){if(A.hasClassName("upmod")||A.hasClassName("up")){A.writeAttribute("title","vote song up");}else{A.writeAttribute("title","vote song down");}});}Element.addMethods({__extend:function(C,D){return Object.extend($(C),D);}});if(!Proto){var Proto={};}var documents=window;Proto.Menu=Class.create();Proto.Menu.prototype={MAX_X:1000,initialize:function(D){this.options=Object.extend({selector:".contextmenu",className:".protoMenu",pageOffset:25,fade:true,validator:null,documents:[document]},D||{});this.options.fade=this.options.fade&&Effect;this.container=Builder.node("div",{className:this.options.className,style:"display:none;"});this.updateItems();$(document.body).appendChild(this.container);var C=this;this.options.documents.each(function(A){Event.observe(A,"click",function(B){this.container.hide();}.bind(C));});$$(this.options.selector).invoke("observe","click",function(A){this.show(A);}.bind(this));},updateItems:function(){$(this.container).update();this.options.menuItems.each(function(C){var D=null;if(C.separator){D=Builder.node("div",{className:"separator"});}else{if(C.title){D=Builder.node("div",{className:"title"},C.name);}else{D=new Element("a",{"class":C.disabled?"disabled":"",href:"#",title:C.name}).update(C.name);Object.extend(D,{_callback:C.callback});D.observe("click",this.onClick.bind(this));}}D.eh_item=C;this.container.appendChild(D);C.element=D;}.bind(this));},show:function(I){Event.stop(I);if(this.options.menuItems.length==0){return ;}var L=Event.element(I);this.clickedElement=L;if(this.options.validator){this.options.validator(this,L);}ptX=Event.pointerX(I),ptY=Event.pointerY(I);var J=this.getScrollOffsets();var N=this.container.getWidth();var M=this.container.getHeight();var K=this.getWindowWidth();var H=J.top+this.getWindowHeight();this.container.setStyle({left:((ptX+N>K)?ptX-N:ptX)+"px",top:((ptY+M>H)?ptY-M:ptY)+"px"}).hide();this.options.fade?Effect.Appear(this.container,{duration:0.2}):this.container.show();},onClick:function(D){Event.stop(D);var C=Event.element(D);this.container.hide();if(C._callback&&!C.hasClassName("disabled")){C._callback(this.clickedElement,C.eh_item);}},getScrollOffsets:function(){return{left:window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft,top:window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop};},getWindowHeight:function(){var B;if(navigator.appVersion.indexOf("MSIE")>0){B=document.body.clientHeight;}else{B=window.innerHeight;}return B;},getWindowWidth:function(){var B;if(navigator.appVersion.indexOf("MSIE")>0){B=document.body.clientWidth;}else{B=window.innerWidth;}return B;}};function addGroup(C,D){if(!vGroupProps(C)){return false;}return __addOrEditGroup("grpadd",getGroupObj(C),D);}function editGroup(C,D){if(!vGroupProps(C)){return false;}return __addOrEditGroup("grpedit",getGroupObj(C),D);}function __addOrEditGroup(F,E,G){E=Object.toJSON(E);var H="ajax=1&op="+F+"&grp="+E;new Ajax.Request(ctx+"ajax",{method:"post",parameters:H,onComplete:G});return false;}function getGroupObj(B){return{name:$F(B.name),description:$F(B.description),website:$F(B.website),access:$F("accessOpen"),showRelated:$F(B.showRelated),enableComments:$F(B.enableComments)};}function vGroupProps(H){H=$(H);hideBox(H);var E=$F(H.name);var G=$F(H.description);var F=[];if(E.strip().length==0){F.push("name");}if(G.strip().length==0){F.push("description");}if(F.length>0){showErrorBox(H,"please fill in all of the required fields",formatErrorSentence(F,"required"));return false;}return true;}function showAddFriend(){var B=$("addF");if(B.visible()){return ;}hideBox("addF");$("addFriend_on").toggle();$("addFriend").toggle();$("fname").clear();$("friends").insert({"top":B});B.show();if(!isIE6()){new Effect.Highlight(B,{duration:1,afterFinish:function(){$("fname").activate();}});}return false;}function cancelAddFriend(){$("addFForm").show();$("addF").hide();$("addingF").hide();$("addFriend_on").toggle();$("addFriend").toggle();hideBox("addF");return false;}function submitAddFriend(){hideBox("addF");var D=$F("fname");if(!vuser(D)){showErrorBox("addF","error","that is not a valid user name",4);return false;}addFriend(null,D,function(A,B){cancelAddFriend();onAddFriend(A,B);},function(A,B){cancelAddFriend();showAddFriend();switch(A.responseText){case"1":showErrorBox("addF","error","there is no user with that name",4);break;case"4":showErrorBox("addF","error","you are already friends with that person",4);break;default:showErrorBox("addF","error","an error occurred while adding the friend",4);break;}});$("addFForm").hide();var C=$("addingF");C.show();C.down(".name").update(D);return false;}function addFriend(J,F,G,I){var H={op:"fradd"};if(F){H["name"]=F;}if(J){H["id"]=J;}callServer(H,G,I);sendVisualNotification(F+" added as a friend");return false;}function removeFriend(C,D){callServer({op:"frdel",id:C},D);sendVisualNotification("friend removed");return false;}function onAddFriend(D,C){addFriendToSidebar(C.id,C.name);playMenuSequence([{id:"menu_friends",type:"flash"},{id:"menu_friends",type:"jump",duration:4000}]);}function onRemoveFriend(D,C){playMenuSequence([{id:"menu_friends",type:"flash"},{id:"menu_friends",type:"jump",duration:3000}]);removeFriendFromSidebar(C.id,C.name);}function addFriendToSidebar(D,C){if(window!=window.top){window.top.addFriendToSidebar(D,C);return ;}$("friends").insert({bottom:'<div id="f'+D+'" class="frnd"><a href="#" onclick="return false;" '+'class="listItem plm">'+C.toLowerCase()+"</a></div>"});$("f"+D).eh_info={id:D,n:C};$("f"+D).down(".plm").observe("click",function(A){fmenu.show(A);});if(!isIE6()){$("f"+D).hide();Effect.Appear("f"+D,{duration:1,afterFinish:function(){new Effect.Highlight("f"+D,{duration:0.8});}});}}function removeFriendFromSidebar(B){if(window!=window.top){window.top.removeFriendFromSidebar(B);return ;}if(isIE6()){$("f"+B).remove();}else{Effect.Fade("f"+B,{duration:1.5,afterFinish:function(A){$("f"+B).remove();}});}}function share(E,F,H){if(!vmessage(E)){grow($("share").up("",1),{h:getErrorBox(E).getHeight()});return false;}$(E.submit).disable();var G={op:"share",id:$F(E.id),type:$F(E.type),name:$F(E.name),email:$F(E.email),message:$F(E.message)};callServer(G,F,H,E);return false;}function sendMessage(E,F,H){if(!vmessage(E)){grow($(E).up("",2),{h:getErrorBox(E).getHeight()});return false;}$(E.submit).disable();var G={ajax:1,subject:$F(E.subject),message:$F(E.message)};if(E.to){G["to"]=$F(E.to);}if(E.convo){G["convo"]=$F(E.convo);}if(E.email){G["email"]=$F(E.email);}if(E.feeling){G.message+="                                       feeling: "+$F($(E.feeling));}if(E.op&&$F(E.op)=="feedback"&&E.email){G.message+=", email: "+$F(E.email);}G["op"]=E.op?$F(E.op):"msg";callServer(G,F,H,E);return false;}function vmessage(M){hideBox(M);var N=[];var J=[];if(M.to){var K=$F(M.to);if(!vnotempty(K)){N.push("to");}}if(M.name){var P=$F(M.name);if(!vnotempty(P)){N.push("your name");}}if(M.email){var I=$F(M.email);if(!vnotempty(I)){N.push("email");}else{if(!vemail(I)){J.push("please enter a valid email address");}}}if(M.subject){var O=$F(M.subject);if(!vnotempty(O)){N.push("subject");}}if(M.message){var L=$F(M.message);if(!vnotempty(L)){N.push("message");}}if(N.length>0){J.push(formatErrorSentence(N,"required"));}if(J.length>0){showErrorBox(M,"please fill in all of the required fields",J.join("<br/>"));return false;}return true;}function onMessageSent(F,D,E){$(E.submit).enable();$("lbContent").__lb__.deactivate();sendVisualNotification("message sent",5);}function onFailedMessage(F,G,H){$(H.submit).enable();var E=F.responseText.split(" ").first();if(E=="1"){showErrorBox(H,"error","that user doesn't exist");
}else{if(E=="5"){showErrorBox(H,"error","an error occurred while sending the message");}}growAncestor($(H).up(),"marker",1);}function deleteConvo(B){callServer({op:"condel",id:B},onDeleteConvo,onFailedDelete,B);return false;}function onDeleteConvo(G,H,F){var E=$("convo"+F);if(E){Effect.Fade(E);}sendVisualNotification("conversation deleted");}function onFailedDelete(F,D,E){}function markMessagesRead(B){callServer({op:"msgread"},onMessagesRead,null,B);}function onMessagesRead(F,D,E){E.select(".unread").invoke("removeClassName","unread");$("mailflash").hide();$("mail").show();}function updateProfile(C){if(!vprofile(C)){return false;}var D=$H($(C).serialize(true));D.each(function(A){if(!A.value.length){D.unset(A.key);}});updateUser(D.id,D,function(B,F,A){sendVisualNotification("profile successfully updated");setContent(ctx+"user/"+A.userName);},generalError,{container:C,userName:D.get("userName")});return false;}function vprofile(G){var F=[],H=[];G=$(G);var E=$F(G.age);if(vnotempty(E)){if(!vint(E)){F.push("age must be a whole number (no decimal space)");}}if(H.length>0){F.push(formatErrorSentence(H,"required"));}if(F.length>0){showErrorBox(G,"error",F.join("<br/>"));}return F.length==0;}function updateOptions(D){if(!voptions(D)){return false;}var C={};C.id=$F(D.id);C.publicVotes=D.publicVotes.checked;C.hideLiked=D.hideLiked.checked;C.hideDisliked=D.hideDisliked.checked;C.visibleThreshold=parseInt($F(D.visibleThreshold));C.notifiedForMessage=D.notifiedForMessage.checked;C.notifiedForFriendMessage=D.notifiedForFriendMessage.checked;C.notifiedForFriendSubmission=D.notifiedForFriendSubmission.checked;C.notifiedForSongComment=D.notifiedForSongComment.checked;C.notifiedForCommentReply=D.notifiedForCommentReply.checked;C.notifiedForNewFan=D.notifiedForNewFan.checked;C.showSystemAlertsInInbox=D.showSystemAlertsInInbox.checked;updateUser(C.id,C,function(){var A=showInfoBox(D,"updated","your preferences were updated",4);reloadContent.delay(1,true);},generalError,{container:D});return false;}function voptions(C){hideBox(C);var D=$F(C.visibleThreshold);if(!vint(D)){showErrorBox(C,"error","visible threshold must be a number");return false;}return true;}function updateUser(M,I,J,L,N){I.id=M;var H=Object.toJSON(I);var K={ajax:1,op:"uedit",user:H};N.__delta=I;callServer(K,J,L,N);}var Tooltip=Class.create();Tooltip.prototype={MAX_X:1000,initialize:function(F,E){var D=Object.extend({default_css:false,margin:"0px",padding:"5px",backgroundColor:"#d6d6fc",delta_x:5,delta_y:5,zindex:2300,reparent:true},arguments[1]||{});this.element=$(F);this.options=D;if(this.options.reparent){$("earshere").insert({bottom:$(E)});}this.tt=$(E);this.tt.__tt=this;this.element.onstopobserving=this.kill.bindAsEventListener(this);this.tt.hide();this.eventMouseOver=this.showTooltip.bindAsEventListener(this);this.eventMouseOut=this.hideTooltip.bindAsEventListener(this);this.registerEvents();},destroy:function(){this.element.stopObserving("mouseover",this.eventMouseOver);this.element.stopObserving("mouseout",this.eventMouseOut);},kill:function(){if(this.options.reparent){this.tt.hide();}},registerEvents:function(){this.element.observe("mouseover",this.eventMouseOver);this.element.observe("mouseout",this.eventMouseOut);},showTooltip:function(K){K.stop();var L=K.pointerX();var G=K.pointerY();var I=this.tt.getDimensions();var J=I.width;var H=I.height;if((J+L)>=(getWindowScroll().w-this.options.delta_x)){L=L-J;L=L-this.options.delta_x;}else{L=L+this.options.delta_x;}if((H+G)>=(this.getWindowHeight()-this.options.delta_y)){G=G-H;G=G-this.options.delta_y;}else{G=G+this.options.delta_y;}this.setStyles(L,G);this.tt.show();},setStyles:function(C,D){this.tt.setStyle({position:"absolute",top:D+"px",left:C+"px",zIndex:this.options.zindex});if(this.options.default_css){this.tt.setStyle({margin:this.options.margin,padding:this.options.padding,backgroundColor:this.options.backgroundColor,zIndex:this.options.zindex});}},hideTooltip:function(B){this.tt.hide();},getWindowHeight:function(){var B;if(navigator.appVersion.indexOf("MSIE")>0){B=document.body.clientHeight;}else{B=window.innerHeight;}return B;},getWindowWidth:function(){var B;if(navigator.appVersion.indexOf("MSIE")>0){B=document.body.clientWidth;}else{B=window.innerWidth;}return B;}};function selectPlaylist(E){var F=window.top.lastSelected;var D=window.top.$("pl"+E);if(D==null){return ;}D=D.down();if(F!=null){F.removeClassName("selected");}window.top.lastSelected=D;if(D!=null){D.addClassName("selected");}D.blur();}var lastEditor;function makePlaylistEditable(F,E,D){selectPlaylist(F.id);Sortable.create(D,{ghosting:false,constraint:false,handle:"handle",containment:[D],dropOnEmpty:true,onUpdate:function(A){$("saveCommand").show();updatePLIndexes();new Effect.Highlight("saveCommand",{duration:1});}});$(D).select(".handle").each(function(A){A.title="drag song to change position";});if(lastEditor!=null){lastEditor.dispose();}lastEditor=new Ajax.InPlaceEditor(E,ctx+"ajax",{okLink:true,okButton:false,clickToEditText:"click to rename",callback:function(C,B){var H=$H({id:F.id,name:B});var A={op:"pledit",pl:H.toJSON()};return A;},onComplete:function(A,B){window.top.$("pln"+F.id).update(B.innerHTML.toLowerCase());sendVisualNotification("name changed",3);}});}function delSong_yes(B){remFromPL(B.plId,B.songId);}function remFromPL(F,E){var D=$("song_"+E);Effect.Shrink("song_"+E,{afterFinish:function(){D.remove();updatePL(F,{songs:songIdsForPL(F)},onRemoveSong);},duration:2,direction:"top-left"});}function songIdsForPL(F){var G=Sortable.serialize("playlistSongs");var H=G.split("playlistSongs[]=");var E=[];H.each(function(A){if(A.strip().length!=0){E.push(parseInt(A));}});return E;}function updatePLIndexes(){var C=songIdsForPL();var D=1;C.each(function(A){var B=$("song_"+A).getElementsByClassName("number")[0];B.update(D++);});}function onSaveSongs(){$("saveCommand").hide();sendVisualNotification("playlist saved",3);}function onRemoveSong(){sendVisualNotification("song removed",3);updatePLIndexes();}function onPublish(F,D,E){$("publishCommand").hide();$("unpublishCommand").show();$("pl"+E.id).eh_info.pub=true;sendVisualNotification("playlist published",3);}function onUnpublish(F,D,E){$("unpublishCommand").hide();$("publishCommand").show();$("pl"+E.id).eh_info.pub=false;sendVisualNotification("playlist unpublished",3);}function login(H){if(!vlogin(H)){return false;}var F=H.op.value;var G=getErrorText(H);if(!vuser($F(H.user))){G.innerHTML="invalid username<br/>(no spaces, between 3-20 characters)";return false;}if(F=="reg"&&!vemail($F(H.email))){G.innerHTML="invalid email";return false;}if(!vpass($F(H.passwd))){G.innerHTML="invalid password (between 3-20 characters)";return false;}if(F=="reg"&&$F(H.passwd)!=$F(H.passwd2)){G.innerHTML="passwords don't match";return false;}if(Ajax.getTransport()){params={ajax:1,op:F,user:$F(H.user),passwd:encodeURIComponent($F(H.passwd))};if(H.ic){params.ic=$F(H.ic);}if(H.email){params.email=$F(H.email);}if(H.rememberMe){params.rememberMe=$F(H.rememberMe);}var E=function(A){var C=A.responseText;if(C&&C.length>0){C=parseInt(C);if(C==0){if(H.url){var B=$F(H.url);if(B==location.pathname){location.reload(true);}else{location.href=B;}}else{location.reload(true);}}else{if(C==1){showErrorBox(H,"could not log in",'invalid username or password - <a href="mailto: support@cherrypeel.com">contact support</a>',2);}else{if(C==2){showErrorBox(H,"sorry","that username or email is not available",2);}else{if(C==4){showErrorBox(H,"sorry","that username or email is not available",2);}}}}}};new Ajax.Request(ctx+"login",{method:"post",parameters:params,onComplete:E});return false;}else{return true;}}function vlogin(H){var F=[];var E=[];clearFormErrors($(H));hideBox(H);var G=$F(H.op);if(!vuser($F(H.user))){F.push("invalid username<br/>(no spaces, between 3-20 characters)");E.push(H.user);}if(G=="reg"&&!vemail($F(H.email))){F.push("invalid email");E.push(H.email);}if(!vpass($F(H.passwd))){F.push("invalid password (between 3-20 characters)");E.push(H.passwd);}if(G=="reg"&&$F(H.passwd)!=$F(H.passwd2)){F.push("passwords don't match");
E.push(H.passwd);E.push(H.passwd2);}if(F.length==0){return true;}E.invoke("addClassName","error");showErrorBox(H,"whoops!",F.join("<br/>"),null,null);return false;}function setActivity(C){var D=$("activityblurb").firstDescendant();D.update(C);if(!isIE6()&&C.length>0){D.setOpacity(0);Effect.Appear(D,{duration:0.4,to:0.99999});}}function addActivityHovers(){$("welcome").select(".activities > a").each(function(C){var D=activities[C.readAttribute("id").substr(1)];C.observe("mouseover",function(A){setActivity(D);C.addClassName("active");});C.observe("mouseout",function(A){setActivity("");C.removeClassName("active");});});}function showReg(B){$("welcome").select(".reghide").invoke(B?"hide":"show");$("welcome").select(".regshow").invoke(B?"show":"hide");B?$("register").show():$("register").hide();enableForm($("register").select("form").first(),B,true);if(B&&$("user")){$("user").focus();}}var HelpTip=Class.create({initialize:function(F,E,D){this.element=$(F);this.content=$(E);this.options=Object.extend({width:300,position:"b",img:null,className:"helptip",offsetX:2,offsetY:2,pointerShift:0,zIndex:2300,closeButtonClass:"helptipx",hideDelegate:function(A){Effect.Fade(A,{duration:0.5});},dismissHandler:null},D||{});this.buildTip();},buildTip:function(){var L=this.options.position=="b"||this.options.position=="t";var N=!L;var I=this.tip=new Element("table",{className:this.options.className});I.setStyle({width:this.options.width+(N?12:0)+"px"});var M=null;if(N){I.insert(M=new Element("tr"));}var O=new Element("td",{className:"tt box"}).insert(this.content);if(L){I.insert(new Element("tr").insert(O));}else{O.setStyle({width:this.options.width+"px"});M.insert(O);}this.content.show();var J=L?" v":" h";var K=new Element("td",{className:"tp"+J}).update('<img src="'+this.imgSrc()+'" class="tp'+J+'"'+(this.options.pointerShift!=0?' style="margin-left: '+(this.options.pointerShift+12)+'px"':"")+"/>");if(L){K=new Element("tr").insert(K);this.options.position=="b"?I.insert({top:K}):I.insert({bottom:K});}else{this.options.position=="r"?M.insert({top:K}):M.insert({bottom:K});}this.element.up("body").insert(I.hide());I.select("."+this.options.closeButtonClass).invoke("observe","click",(function(){this.hide();if(this.options.dismissHandler){this.options.dismissHandler(this);}}).bind(this));if(!Prototype.Browser.IE){var P=this.shadow=new Element("div");P.setStyle({width:this.tip.getWidth()+"px",height:(this.tip.getHeight()-12)+"px"});P.setStyle({backgroundColor:"#000000"});P.setOpacity(0.4);this.element.up("body").insert(this.shadow.hide());}},imgSrc:function(){if(this.options.img){return this.options.img;}var B="";switch(this.options.position){case"b":B="tip_pointer_b.png";break;case"t":B="tip_pointer_t.png";break;}return B;},show:function(){var J=this.element.cumulativeOffset();var H=this.element.getDimensions();var I=this.tip.getDimensions();var F,G;if(this.options.position=="b"||this.options.position=="t"){F=J[0]-this.options.pointerShift;G=J[1]+(this.options.position=="b"?H.height+this.options.offsetY:(-I.height-this.options.offsetY));}else{F=J[0]+(this.options.position=="r"?H.width+this.options.offsetX:(-I.width-this.options.offsetX));G=J[1]-this.options.pointerShift;}this.tip.setStyle({position:"absolute",top:G+"px",left:F+"px",zIndex:this.options.zIndex}).show();if(!Prototype.Browser.IE){this.shadow.setStyle({position:"absolute",top:(G+18)+"px",left:(F+6)+"px",zIndex:this.options.zIndex-1}).show();}},hide:function(){this.options.hideDelegate(this.tip);if(!Prototype.Browser.IE){this.shadow.hide();}}});var jimAuld={};jimAuld.utils={};jimAuld.utils.cookies={get:function(H){var J,K,G,I,L;J=window.top.document.cookie.indexOf(H+"=");if(J<0){L=null;}else{K=window.top.document.cookie.indexOf(H+"=")+H.length+1;G=window.top.document.cookie.indexOf(";",K);if(G==-1){G=window.top.document.cookie.length;}I=window.top.document.cookie.substring(K,G);L=(I=="")?null:unescape(I);}return L;},set:function(U,S,X,Q,N,P){var M,W,R,O,T,V;if(!X||typeof X!="number"){M="";}else{W=new Date();W.setTime(W.getTime()+(X*60*60*1000));R=W.toGMTString();M="; expires="+R;}Q=(!Q||Q==""||Q==null)?"/":Q;O="; path="+Q;N=(!N||N==""||N==null)?window.location.hostname:N;T="; domain="+N;V=(P===true)?"; secure":"";S=escape(S);window.top.document.cookie=U+"="+S+M+O+";";},del:function(E,F,D){F=(!F||!F.length)?"":F;D=(!D||!D.length)?"":D;jimAuld.utils.cookies.set(E,"",-8760,F,D);},test:function(){var D;jimAuld.utils.cookies.set("cT","acc");var C=jimAuld.utils.cookies.get("cT");if(C=="acc"){jimAuld.utils.cookies.del("cT");D=true;}else{D=false;}return D;}};var currentUpload;var origContentSrc;function resetSubmit(){$("tosAgree").show();$("disclaimAgree").checked=false;$("mp3").show().clear().disable();hideBox("submitbar");$("mp3filename").hide();$("mp3pi").hide();$("mp3success").hide();$("mp3failure").hide();$("mp3actions").hide();$("mp3maxsize").show();return false;}function cancelSubmit(){callServer({op:"upcancel",id:currentUpload.__id__});resetSubmit();if(currentUrl.indexOf(currentUpload.__id__)!=-1){setContent(origContentSrc);}currentUpload=null;origContentSrc=null;return false;}function showSongDetails(E){var F=origContentSrc=currentUrl;fltrace(F);if(F.indexOf("/songs")!=-1){F=F.replace(ctx,"");var D=F.replace(/(\/songs(\/intro)?\/?|artist\/)/gi,"");setContent(ctx+"upload/"+D+"/"+E);}else{setContent(ctx+"upload/"+E);}return false;}function submitSongDetails(B){if(!vsubmit(B)){return false;}B.select("input[type='submit']").first().disable();$("submitpi").show();callServer(B.serialize(),$F(B.op)=="sdetails"?onSongUploadSuccess:onSongEditSuccess,onSongFailure);return false;}function onSongUploadSuccess(F,D){var E=origContentSrc;if(E.indexOf("/songs/")!=-1){setContent(E);}else{setContent(ctx+"new?nc=1");}$("submitpi").hide();setTimeout(function(){sendVisualNotification(D.name+" - "+D.artist.name+" was successfully added",4);},1000);window.top.resetSubmit();}function onSongEditSuccess(D,C){setTimeout(function(){sendVisualNotification(C.name+" - "+C.artist.name+" was successfully edited",4);},1000);$("submitpi").hide();origContentSrc=window.top.origContentSrc;setContent(origContentSrc);}function onSongFailure(G,H){$("pform").select("input[type='submit']").first().enable();$("submitpi").hide();var F=G.responseText;switch(F){case"2":showErrorBox("pform","this artist isn't yours","you are not allowed to submit music to this band. if you are "+"the artist, please <a href='mailto:support@earshere.com'>contact support</a> and we will resolve the issue",4);break;case"9":showErrorBox("pform","validation error","you did not fill in the correct letters. please try again",4);new Effect.Highlight("captcha",{duration:2});var E=$("captchaImg");E.src=E.src+"?"+(new Date()).getTime();break;default:showErrorBox("pform","error","we were not able to complete your request. please try again",4);break;}}function showCustomArtistName(C,D){if(!D){D="";}$("artist").replace('<input type="text" id="artist" name="artist" class="long" value="'+D+'"/>');$(C).remove();return false;}function performUpload(M){var J=$(M);var P=J.parentNode;J.hide();$("mp3maxsize").hide();Effect.Fade("tosAgree",{delay:0.5,duration:1});var K;var N=$F(J);var L=N.indexOf("/");if(L!=-1){K=N.split("/");}else{L=N.indexOf(BSLASH);if(L!=-1){K=N.split(BSLASH);}}if(K!=undefined){N=K[K.length-1];}var I=$("mp3filename");I.down(".strong").update(N);I.show();$("mp3pi").show();startSubmitPulse();var O=function(A){Event.stopObserving($("uploadframe"),"load",arguments.callee.__func);var E=getFrameDocument("uploadframe");var B=E.body.innerHTML.stripTags().evalJSON();var F="javascript: window.parent.decodeResponse(document.body.innerHTML); void(0);";$("uploadframe").src=F;$("mp3pi").hide();stopSubmitPulse();if(B.__success__){playMenuSequence([{id:"menu_submit",type:"flash"},{id:"menu_submit",type:"jump"},{id:"mp3file",type:"flash",time:800}]);$("mp3success").show();var D=$("mp3actions");D.show();var C=D.down(".complete");if(window.__lastCompleteHandler){C.stopObserving("click",__lastCompleteHandler);
}__lastCompleteHandler=(function(G){G.stop();return showSongDetails(B.__id__);}).bindAsEventListener(this);C.observe("click",__lastCompleteHandler);}else{$("mp3failure").show();if(B.__code__=="7"){showErrorBox($("submitbar"),"song problems!","sorry. we encountered errors while working with that song. please try another.");}else{if(B.__code__=="6"){showErrorBox($("submitbar"),"that song is too big","sorry. we currently only allow songs up to 15 megabytes in size.");}}}};O.__func=O;Event.observe("uploadframe","load",O);M.form.submit();}function vsubmit(J){var L=$("pform");hideBox(L);clearFormErrors(J);var M=[];var N=[];var K=$A([]);var Q=$F(J.artist);var P=$F(J.title);var R=J.genre.options[J.genre.selectedIndex].text;var O;if(Q.strip().length==0){M.push("artist");K.push(J.artist);}else{if(-1!=(O=vascii(Q))){N.push("invalid characters in artist name (<b>"+Q.charAt(O)+"</b>). international characters are not allowed.");K.push(J.artist);}}if(P.strip().length==0){M.push("title");K.push(J.title);}else{if(-1!=(O=vascii(P))){N.push("invalid characters in title (<b>"+P.charAt(O)+"</b>). international characters are not allowed.");K.push(J.title);}}if(R.strip().length==0){M.push("genre");K.push(J.genre);}if(M.length>0){N.push(formatErrorSentence(M,"required"));}K.invoke("addClassName","error");if(N.length>0){showErrorBox(L,"please fill in all of the required fields",N.join("<br/>"));return false;}return true;}function decodeResponse(B){B=B.stripTags();currentUpload=B.evalJSON();return ;}var seh={};seh.MAX_CONTENT_WIDTH=650;seh.RIGHT_BAR_WIDTH=800;seh.Page=Class.create({initialize:function(B){this.wnd=B;this.wnd["seh:page"]=this;},canSubmit:function(E){if(this._blockSubmit){return false;}var F=E.element();var D=$(F)["seh:control"];return D?D.canFormSubmit(E):true;},blockSubmit:function(B){this._blockSubmit++;},unblockSubmit:function(B){this._blockSubmit--;},focusElement:function(E,D){var F=$(E);(function(){F.focus();}).defer();return false;},errorOn:function(E,D){var F=$(E);F.addClassName("error");if(!F["seh:oldtitle"]){F["seh:oldtitle"]=F.readAttribute("title");}F.writeAttribute("title",D);this.focusElement(F,true);},clearErrorOn:function(D){var C=$(D);C.removeClassName("error");if(C["seh:oldtitle"]){C.writeAttribute("title",C["seh:oldtitle"]);delete C["seh:oldtitle"];}},formatFieldValues:function(C,D){if(!D){D=NEWLINE;}if(Object.isElement(C)){C=[C];}else{C=$A(C);}return C.invoke("getValue").without("").join(D);}});seh.HomePage=Class.create(seh.Page,{initialize:function($super,E,F){$super(E);this.faList=F;this.fa=0;this.blocked=false;this.isFACollapsed=false;if(jimAuld.utils.cookies.get("collapseFA")==null){jimAuld.utils.cookies.set("collapseFA",false,24*7*52);}else{var D=jimAuld.utils.cookies.get("collapseFA")=="true";if(D){this.toggleFA(true);}this.isFACollapsed=D;}$("nextFA").hide();if(this.faList.length==1){$("prevFA").hide();}this.hidePrev=this.hideNext=false;},nextFA:function(){if(this.fa==0||this.blocked){return false;}this.setFA(this.fa-1);if(this.fa==0){this.hideNext=true;}$("prevFA").show();this.blocked=true;return false;},prevFA:function(){if(this.fa+1==this.faList.length||this.blocked){return false;}this.setFA(this.fa+1);if(this.fa+1==this.faList.length){this.hidePrev=true;}$("nextFA").show();this.blocked=true;return false;},setFA:function(D){this.fa=D;var C=this;new Ajax.Updater("featuredArtistHolder","assets/includes/featured_artist.jsp?id="+this.faList[D]+"&incJs=false&collapsed="+this.isFACollapsed,{onComplete:function(H){C.blocked=false;if(C.hidePrev){$("prevFA").hide();C.hidePrev=false;}if(C.hideNext){$("nextFA").hide();C.hideNext=false;}if(C.isFACollapsed){var I=$("featuredArtist").down(".photo");var J=I.getWidth();var B=I.getHeight();var A=60/B;I.setStyle({width:Math.round(J*A)+"px",height:"60px"});}},evalScripts:true});},toggleFA:function(F){var I=$("featuredArtist").down(".photo");if(this.isFACollapsed){$("single").setStyle({"margin-bottom":"10px"});$("featuredArtistHolder").select(".collapsable").invoke("show");I.setStyle({width:null,height:null});}else{$("single").setStyle({"marginBottom":"0px"});$("featuredArtistHolder").select(".collapsable").invoke("hide");var J=I.getWidth();var H=I.getHeight();var G=60/H;I.setStyle({width:Math.round(J*G)+"px",height:"60px"});}this.isFACollapsed=!this.isFACollapsed;resizeContent();if(!F){jimAuld.utils.cookies.set("collapseFA",this.isFACollapsed,24*7*52);}$("featuredArtist").down("div.boxControls > a").update(this.isFACollapsed?'maximize <img src="'+ctx+'assets/images/maximize_fa.gif"/>':'minimize <img src="'+ctx+'assets/images/minimize_fa.gif"/>');this.isFACollapsed?$("featuredArtist").addClassName("collapsed"):$("featuredArtist").removeClassName("collapsed");return false;}});seh.ArtistPage=Class.create(seh.Page,{initialize:function($super,E,D,F){this.artistName=D;this.ownerName=F;},contactArtist:function(){if(this.ownerName==null){return false;}var B=new window.parent.lightbox({href:ctx+"assets/includes/compose_message.jsp?name="+this.ownerName});B.activate();return false;}});seh.ArtistRegPage=Class.create(seh.Page,{initialize:function($super,I,K){$super(I);this.isEditMode=K;var L='<div class="little"><span style="float:right;"><a href="#" onclick="$(this).up(\'div\').remove(); return false;">remove</a></span> <a href="#{url}" target="_blank" tabindex="0">#{value}</a><input type="hidden" name="website" value="#{escapedValue}"/></div>';this.websites=new seh.TextFieldMultiInput([{isElement:true,value:I.$("website")},{isElement:false,value:" - "},{isElement:true,value:I.$("websiteDesc")}],I.$("websites"),{addPosition:"bottom",templateText:L,addOnBlur:false,subObjectDelegate:function(B){var A=B.value.strip().split("-")[0];if(A.search(/\w+:\/\//)!=0){A="http://"+A;}else{B.value=B.value.sub(/\w+:\/\//,"",1);}B.url=A;return B;},validateBlank:true,validateDelegate:this.validateWebsite.bind(this),onAddItem:function(){$("websites").show();},onClear:null});var J='<div class="little"><span style="float:right;"><a href="#" onclick="$(this).up(\'div\').remove(); return false;" tabindex="0">remove</a></span>#{value}<input type="hidden" name="influences" value="#{escapedValue}"/></div>';this.influences=new seh.TextFieldMultiInput(I.$("influences"),I.$("influencesList"),{addPosition:"bottom",templateText:J,addOnBlur:false,validateBlank:true,onAddItem:function(){$("influencesList").show();},onClear:null});var M='<div class="little"><span style="float:right;"><a href="#" onclick="$(this).up(\'div\').remove(); return false;" tabindex="0">remove</a></span>#{value}<input type="hidden" name="similarBands" value="#{escapedValue}"/></div>';this.similarBands=new seh.TextFieldMultiInput(I.$("similarBands"),I.$("similarBandsList"),{addPosition:"bottom",templateText:M,addOnBlur:false,validateBlank:true,onAddItem:function(){$("similarBandsList").show();},onClear:null});this.uploader=new seh.Uploader(I.$("image"),I.$("uploadframe"),{onBegin:this.onUploadBegin.bind(this),onFailure:this.onUploadFailure.bind(this),onSuccess:this.onUploadSuccess.bind(this)});this.submit=I.$("submitBtn");this.submit.observe("click",this.submitForm.bindAsEventListener(this));var N=this;var H=function(){N.checkPermalink();};H=H.bind(this);I.$("permalink").observe("blur",H);I.$("artist").observe("blur",H);I.$("artist").observe("keyup",this.updatePermalink.bindAsEventListener(this));if(!this.isEditMode){this.focusElement($("artist"));}},updatePermalink:function(D){var C=this.generatePermalink($("artist").getValue());$("permalink").setValue(C);},generatePermalink:function(B){B=B.toLowerCase().replace(/(\s+|\.)/g,"");B=B.replace(/&/g,"and");B=B.replace(/[^\w\d_]/g,"");return B;},checkPermalink:function(E){var D=$F($("permalink"));if(D.strip().length==0){return ;}var F={op:"chkurl",name:D};callServer(F,E||this.onCheck.bind(this),null);return false;},onCheck:function(G,E,F){var H=E.taken;$("permaState").show();if(H){$("permaA").hide();$("permaNA").show();$("permalink").addClassName("error");}else{$("permaA").show();$("permaNA").hide();$("permalink").removeClassName("error");
}},onUploadBegin:function(C,D){this.upform=C.fi.form;$(this.upform).select("img.prog").first().show();this.blockSubmit(this);$("uppingimg").show();$("submitpi").show();$("submitBtn").disable();},onUploadSuccess:function(K,L){this.unblockSubmit(this);this.upform.select("img.icon").invoke("hide");$("uppingimg").hide();$("submitpi").hide();$("submitBtn").enable();var I=this.upform.select("img.good").first().show();Effect.Fade(I,{delay:2});this.imageId=L.__id__;var J=new Element("img",{src:ctx+"media?id="+L.__id__});J.hide();var G=this.wnd.$$("div.imgframe").first();G.update(J);var H={};H.handler=function(){J.setStyle({marginTop:((G.getHeight()-J.getHeight())/2)+"px"});J.show();J.stopObserving("load",H.handler);};J.observe("load",H.handler);},onUploadFailure:function(F,D){this.unblockSubmit(this);this.upform.select("img.icon").invoke("hide");$("uppingimg").hide();$("submitpi").hide();$("submitBtn").enable();var E=this.upform.select("img.fail").first().show();Effect.Fade(E,{delay:2,afterFinish:function(){F.fi.clear();}});},submitForm:function(E,F){this.forceSubmit=!!F;if(E){E.stop();if(!this.canSubmit(E)){return ;}}var D=this.submit.form;if(!this.validateForm(D)){return ;}if(this.isEditMode){this.finishSubmitForm();}else{this.checkPermalink(this.onValidatePermalink.bind(this));}},onValidatePermalink:function(F,D,E){this.onCheck(F,D,E);if(D.isTaken){showErrorBox($("pform"),"that URL has already been taken",'the URL you chose has already been claimed. how about "suggestion"',null);return ;}this.finishSubmitForm();},finishSubmitForm:function(){var K=this.submit.form;var L=this.forceSubmit;var I={op:this.isEditMode?"artedit":"artadd"};if(L){I.force=true;}if($F($("website")).strip().length!=0){this.websites.submitValue();}var H={};if(!this.isEditMode){H.name=$("artist").getValue();H.permalink=$F(K.permalink);}else{H.id=$F(K.id);}H.location=$F(K.location);var J=this.formatFieldValues(K.website);if(vnotempty(J)){H.websites=J;}H.genre=K.genre.options[K.genre.selectedIndex].value;H.signedStatus=K.signedStatus.selectedIndex!=0?$F(K.signedStatus):"UNKNOWN";if(vnotempty($F(K.subgenre))){H.subgenre=$F(K.subgenre);}var N=this.formatFieldValues(K.similarBands);if(vnotempty(N)){H.similarBands=N;}else{H.similarBands="";}var M=this.formatFieldValues(K.influences);if(vnotempty(M)){H.influences=M;}else{H.influences="";}if(vnotempty($F(K.description))){H.description=$F(K.description);}if(this.imageId){H.imageId=this.imageId;}I.artist=Object.toJSON(H);callServer(I,this.onSubmitSuccess.bind(this),this.onSubmitFailure.bind(this));},onSubmitSuccess:function(F,D,E){if(this.isEditMode){sendVisualNotification("band successfully edited");setContent(ctx+"artist/"+$("permalink").getValue());}else{$("menu_submit").show();sendVisualNotification("band successfully added");setContent(ctx+"artist/"+$("permalink").getValue()+"/bandmembers/intro");new Ajax.Updater("topmenu",ctx+"assets/includes/topmenu.jsp?onlyMenu=1",{evalScripts:true});}},onSubmitFailure:function(O,T,R){var S=false;switch(O.resCode){case 2:S=true;error="you aren't allowed to be doing whatever you just tried. are you sure you're logged in?";break;case 4:var L=T;var K=L.hasOwner;var M=L.numSongs;var N=$F($("artist"));if(K){showInfoBox($("pform"),"that band name has been taken","someone has already claimed ownership to <strong>"+N+"</strong>. if you "+"believe that they are in the wrong, you can <a href='mailto:support@cherrypeel.com'>contact support</a>"+"</p><p>here is the band's page: <a href='"+ctx+"artist/"+L.id+"'>"+N+"</a>");}else{var Q=showInfoBox($("pform"),"claim ownership?","<strong>"+N+"</strong> already exists on "+"cherrypeel, but it belongs to no one. Would you like to take ownership?</p><p>"+"<button class='button yes'>yes</button>&nbsp;&nbsp;<button class='button no'>no</button>");var P=this;Q.down("button.yes").observe("click",function(){P.submitForm(null,true);});Q.down("button.no").observe("click",function(){setContent("hot");});}break;case 1:case 5:error="an error occurred on the server. please try again later.";break;}showErrorBox($("pform"),"error creating artist",error,null,function(){if(S){location.reload.delay(1,true);}});},validateForm:function(S){var P=[];var M=[];var K=[];var L=$("artist");clearFormErrors(S);hideBox($("pform"));L.removeClassName("error");if(!this.isEditMode){var R=L.getValue();if(vempty(R)){M.push("band name");K.push($("artist"));}else{if(-1!=(idx=vascii(R))){P.push("invalid characters in artist name (<b>"+R.charAt(idx)+"</b>). international characters are not allowed.");K.push($("artist"));}}var Q=$("permalink").getValue();var O=Q.strip().length;if(O<3){P.push("URL must be at least 3 characters");K.push($("permalink"));}else{if(!vperma(Q)){P.push("invalid characters in URL. a-z, 0-9, _ and - are the only characters allowed.");K.push($("permalink"));}}}if(vempty($F(S.location))){M.push("location");K.push(S.location);}var N=$("website");if(vnotempty($F(N))&&!vurl($F(N))){P.push("invalid website url");K.push(N);}var T=S.genre.options[S.genre.selectedIndex].text;if(vempty(T)){M.push("genre");K.push(S.genre);}if(M.length>0){P.push(formatErrorSentence(M,"required"));}if(P.length>0){showErrorBox($("pform"),"please fill in the form completely",P.join("<br/>"),null);K.invoke("addClassName","error");return false;}return true;},validateWebsite:function(E){var D=$("website");this.clearErrorOn(D);var F=vurl(E);if(!F){this.errorOn(D,"invalid url");}return F;}});seh.ArtistBandMemberPage=Class.create(seh.Page,{initialize:function($super,G,E,F,H){$super(G);this.userInfo=E;this.artistInfo=F;this.bandMembers=H;$("name").observe("keyup",this.onNameChange.bindAsEventListener(this));this.autocomplete=new Ajax.Autocompleter("uname","unameChoices",ctx+"ajax",{paramName:"name",parameters:"op=uac&html=1",onKeyPress:function(A){if(A.keyCode==Event.KEY_RETURN){}}});this.listTemplate=new Template('<div id="bm#{id}"><a href="#" onclick="return page.setBandMember(#{id});">#{name} - #{role}</a> <br/> <a class="bylink" href="#" onclick="return page.removeBandMember(#{id});">remove</a></div>');},showInvite:function(){playMenuSequence([{type:"jump",id:"menu_invite"},{type:"flash",id:"invitebar"}]);return false;},showAddMemberForm:function(){this.isNew=true;$("addMem").show();$("addMemLink").hide();$("memTitle").update("new band member profile");this.clearForm();return false;},getForm:function(){return $("addMem").down("form");},clearForm:function(){$("name").clear();$("uname").clear();$("role").clear();$("isAdmin").checked=false;$("userLinkVisible").checked=true;},submitBandMember:function(H,F){var G=[];var E=[];hideBox(H);clearFormErrors(H);if(vempty($F(H.name))){G.push("name");E.push(H.name);}if(vempty($F(H.role))){G.push("role");E.push(H.role);}if(G.length>0){E.invoke("addClassName","error");showErrorBox(H,"required fields",formatErrorSentence(G,"required"));E.first().focus();return false;}this.tempBandMember=F.toQueryParams("&");F+="&op="+(this.isNew?"bmadd":"bmedit");if(this.isNew){callServer(F,this.onAddSuccess.bind(this),this.onSubmitFailure.bind(this),H);}else{F+="&id="+this.bandMemberId;this.tempBandMember.id=this.bandMemberId;callServer(F,this.onEditSuccess.bind(this),this.onSubmitFailure.bind(this),H);}$(H).select("input[type=submit]").invoke("disable");H.select(".pi").invoke("show");return false;},onComplete:function(B){B.select(".pi").invoke("hide");B.select("input[type=submit]").invoke("enable");},onAddSuccess:function(H,J,F){this.onComplete(F);sendVisualNotification("band member added");var G=this.tempBandMember;this.bandMembers[J.id]=G;$("bandMembers").insert({bottom:this.listTemplate.evaluate({id:J.id,name:G.name,role:G.role})});flash($("bm"+J.id),1,0.2,null,"#ffff99","#FCFCFC");var I=$("bandMembers").down(".none");if(I){I.hide();}$("addMem").hide();$("addMemLink").show();},onEditSuccess:function(I,J,F){this.onComplete(F);sendVisualNotification("band member edited");var G=this.tempBandMember.id;var H=this.tempBandMember;this.bandMembers[G]=H;Element.replace($("bm"+G),this.listTemplate.evaluate({id:H.id,name:H.name,role:H.role}));
flash($("bm"+H.id),1,0.2,null,"#ffff99","#FCFCFC");$("addMem").hide();},removeBandMember:function(B){callServer("op=bmdel&id="+B,this.onDelete.bind(this),null,B);if(!this.isNew&&this.bandMemberId==B){$("addMem").hide();$("addMemLink").show();}},onDelete:function(E,F,D){$("bm"+D).remove();},onSubmitFailure:function(E,F,D){this.onComplete(D);},onNameChange:function(B){if(this.isNew){return ;}$("memTitle").update("band member profile - "+$("name").getValue());},setBandMember:function(C){this.isNew=false;this.bandMemberId=C;$("addMem").show();$("addMemLink").show();var D=this.bandMembers[C];$("uname").setValue(D.user);$("name").setValue(D.name);$("role").setValue(D.role);$("isAdmin").checked=D.isAdmin;$("userLinkVisible").checked=D.userLinkVisible;$("memTitle").update("band member profile - "+$("name").getValue());}});seh.ArtistSongPage=Class.create(seh.Page,{initialize:function($super,J,I,G,H){$super(J);this.permalink=I;this.canPublish=G;this.hasPublished=H;var F=$("bandsongs");if(!F){return ;}this.songs=F.select("li").select(function(A){return A.identify()!="songMenu";});},showSubmit:function(){playMenuSequence([{type:"jump",id:"menu_submit"},{type:"flash",id:"submitbar"}]);return false;},publishSong:function(D,C){if(!confirm("Are you sure you want to "+(C?"":"un")+"publish this song?")){return false;}callServer({op:"spub",flag:C,id:D},this.onPublish.bind(this),this.onPublishFailure.bind(this),{id:D,flag:C});if(C){this.hasPublished=true;}return false;},onPublish:function(E,F,D){reloadContent(true);},onPublishFailure:function(E,F,D){},deleteSong:function(D,C){if(!confirm("Are you sure you want to delete "+C)){return false;}callServer({op:"sdel",flag:true,id:D},this.onDelete.bind(this),this.onDeleteFailure.bind(this),{id:D});return false;},onDelete:function(E,F,D){reloadContent(true);},onDeleteFailure:function(E,F,D){},toggleAutopublish:function(H){var G=$("supportsAutopublish").checked;var E={id:H,supportsAutopublish:G};var F={op:"artedit",artist:Object.toJSON(E)};callServer(F);},gotoNextStep:function(){if(!this.hasPublished&&!confirm("No songs have been published. Do you want to continue? Click 'Publish' beside the desired song to get it on the charts.")){return false;}setContent(ctx+"artist/"+this.permalink+"/banners");return false;}});seh.ArtistBannerPage=Class.create(seh.Page,{initialize:function($super,B){$super(B);this.accordion=new seh.Accordion($("promoteAccordion"),{titleCls:"likeh1",containerCls:"promoteItem",contentCls:"promoteItemContent",hideContentCls:"hideOnOpen",singleOpen:true,onOpen:function(D,A){resizeContent();}});},showInvite:function(){playMenuSequence([{id:"menu_invite",type:"jump"},{id:"invitebar",type:"flash"}]);$("invitebar").scrollTo();return false;}});seh.UserDetailsPage=Class.create(seh.Page,{initialize:function($super,B){$super(B);this.uploader=new seh.Uploader(B.$("image"),B.$("uploadframe"),{onBegin:this.onUploadBegin.bind(this),onFailure:this.onUploadFailure.bind(this),onSuccess:this.onUploadSuccess.bind(this)});},onUploadBegin:function(C,D){this.upform=C.fi.form;$(this.upform).select("img.prog").first().show();this.blockSubmit(this);$("uppingimg").show();$("submitpi").show();$("submitBtn").disable();},onUploadSuccess:function(K,L){this.unblockSubmit(this);this.upform.select("img.icon").invoke("hide");$("uppingimg").hide();$("submitpi").hide();$("submitBtn").enable();var I=this.upform.select("img.good").first().show();Effect.Fade(I,{delay:2});this.imageId=L.__id__;var J=new Element("img",{src:ctx+"media?id="+L.__id__});J.hide();var G=this.wnd.$$("div.imgframe").first();G.update(J);var H={};H.handler=function(){J.setStyle({marginTop:((G.getHeight()-J.getHeight())/2)+"px"});J.show();J.stopObserving("load",H.handler);};J.observe("load",H.handler);},onUploadFailure:function(F,D){this.unblockSubmit(this);this.upform.select("img.icon").invoke("hide");$("uppingimg").hide();$("submitpi").hide();$("submitBtn").enable();var E=this.upform.select("img.fail").first().show();Effect.Fade(E,{delay:2,afterFinish:function(){F.fi.clear();}});},getControls:function(){var B=$("userPrefs").select("input").concat($("userPrefs").select("textarea"));return B.inject({},function(A,D){A[D.getAttribute("name")]=D;});},submit:function(){var C=this.getControls();if(!vprofile(C)){return false;}var D=$H($(C).serialize(true));D.each(function(A){if(!A.value.length){D.unset(A.key);}});updateUser(D.id,D,function(B,F,A){sendVisualNotification("profile successfully updated");setContent(ctx+"user/"+A.userName);},generalError,{container:C,userName:D.get("userName")});return false;},validate:function(){var E=[],F=[];f=$(f);var D=$F(f.age);if(vnotempty(D)){if(!vint(D)){E.push("age must be a whole number (no decimal space)");}}if(F.length>0){E.push(formatErrorSentence(F,"required"));}if(E.length>0){showErrorBox(f,"error",E.join("<br/>"));}return E.length==0;}});seh.Control=Class.create({initialize:function(B){$(B)["seh:control"]=this;this.element=$(B);},canFormSubmit:function(B){return true;},getPage:function(){return window["seh:page"];},blockSubmit:function(C){var D=this.getPage();if(!D){return ;}C?D.blockSubmit():D.unblockSubmit();}});seh.ToFitTextArea=Class.create(seh.Control,{initialize:function($super,B){$super(B);this.timer=new PeriodicalExecuter(this.onTimer.bind(this),0.3);this.timer.stop();B.observe("focus",this.onFocus.bindAsEventListener(this));B.observe("blur",this.onBlur.bindAsEventListener(this));},onFocus:function(B){this.timer.registerCallback();},onBlur:function(B){this.timer.stop();},onTimer:function(){if(!this.lastVal||this.lastVal!=this.getValue()){this.element.setStyle({"height":null});this.element.setAttribute("rows",this.countLines());this.lastVal=this.getValue();}},countLines:function(){var H=this.element.value;var I=parseInt(this.element.getAttribute("cols"));var F=H.split(NEWLINE);var G=F.length;var J=Math.ceil(H.length/I);return G>J?G:J;},getValue:function(){return this.element.getValue();}});seh.InviteFriendControl=Class.create(seh.Control,{initialize:function($super,C){$super(C);this.SEPARATORS=[",",";",NEWLINE," "];var D=this.form=C.down("form");this.name=$(D.name);this.email=new seh.ToFitTextArea($(D.email));this.message=$(D.message);this.button=D.down("input.button");new Tooltip("invEmailImg","invEmail");$(this.email.element).setAttribute("wrap","soft");D.reset();D.observe("submit",this.onFormSubmit.bindAsEventListener(this));},onFormSubmit:function(B){B.stop();this.submit();},submit:function(){var L=this.form;var O=$F(L.name);var J=$F(L.email);var M=$F(L.message);var P=null;for(var N=0;N<this.SEPARATORS.length;N++){P=this.SEPARATORS[N];if(J.indexOf(P)!=-1){break;}}if(P==null){J=[J];}else{J=J.split(P).invoke("strip");}hideBox(L);var K=[];if(O.strip().length==0){K.push("name");}if(J.length==1&&J[0].strip().length==0){K.push("email");}if(M.strip().length==0){K.push("message");}if(K.length!=0){showErrorBox(L,"please fill in all of the required fields",formatErrorSentence(K,"required"));}for(var N=0;N<J.length;N++){var I=J[N];if(!vemail(I)){showErrorBox(L,"error",I+" is not a valid email address");}}if(this.button){this.button.disable();}params={ajax:1,op:"invite",name:O,emails:J,message:M};callServer(params,this.onInviteSuccess.bind(this),this.onInviteFailure.bind(this));},onInviteSuccess:function(E,D){if(this.button){this.button.enable();}var F=E.responseText;sendVisualNotification($F(this.form.email)+" invited");this.form.reset();},onInviteFailure:function(D,C){if(this.button){this.button.enable();}showErrorBox(this.form,"error","an error occurred while sending the invite. please try again.",3);}});seh.Accordion=Class.create(seh.Control,{initialize:function($super,D,F){$super(D);this.container=$(D);this.options=Object.extend({singleOpen:true,onOpen:Prototype.K},F||{});var E=this.titles=[];this.containers=this.container.select("."+F.containerCls);this.titleToContainer=this.containers.inject({},function(C,B){var A=B.select("."+F.titleCls).first();C[A.identify()]=B;E.push(A);return C;});this.titles.invoke("observe","click",this.onTitleClick.bindAsEventListener(this));
},onTitleClick:function(B){this.showParent(Event.element(B));},showParent:function(H){var E=H.up("."+this.options.containerCls);var G=E.down("."+this.options.contentCls);var F=E.down("."+this.options.hideContentCls);if(G==this.lastContent){return ;}if(this.options.singleOpen&&this.lastContent){if(this.lastContent.getAttribute("cp.isOpen")){this.close(this.lastContent);if(this.lastHideContent){this.lastHideContent.show();}}}this.open(G,F);H.scrollTo();},open:function(C,D){C.setAttribute("cp.isOpen",true);C.show();if(D){D.hide();}this.lastContent=C;this.lastHideContent=D;this.options.onOpen(this,C);},close:function(B){B.setAttribute("cp.isOpen",false);B.hide();}});seh.SongList=Class.create(seh.Control,{initialize:function($super,D,C){$super(D);this.list=$(D);this.options=Object.extend({showHiddenLinks:true},C||{});this.prepare();},prepare:function(){if(!this.options.showHiddenLinks){return ;}var J=this.list.immediateDescendants();var F=J.length+1;var G=0;while(--F){var H=J[F-1];if(H.visible()){if(!G){continue;}H.insert({after:"<li><a href='#' class='reveal'>"+G+" hidden item"+(G>1?"s":"")+" [+]</a></li>"});var I=H.next();I.down("a").observe("click",function(A,B){B.nextSiblings().each(function(C){if(C.visible()){throw $break;}Effect.Appear(C,{duration:1});});B.hide();A.stop();}.bindAsEventListener(this,I));G=0;}else{G++;}}}});seh.Sidebar=Class.create(seh.Control,{initialize:function($super,B){$super(B);this.sidebar=$("sidebar");this.iniPos=this.sidebar.cumulativeOffset();Event.observe(window,"scroll",this.onScroll.bindAsEventListener(this));},onScroll:function(B){if(this.fx!=null){this.updateFx();return ;}else{if(this.timeoutId!=null){return ;}}this.timeoutId=this.beginFx.bind(this).delay(0.2);},beginFx:function(){this.timeoutId=null;var C=getWindowScroll();var D;if(C.t<=this.iniPos.top){D=this.iniPos.top;}else{D=C.t;}this.fx=new Effect.Move(this.sidebar,{x:this.iniPos.left,y:D,duration:0.8,mode:"absolute",afterFinish:this.onFxComplete.bind(this)});},updateFx:function(){this.fx.cancel();this.beginFx();},onFxComplete:function(){this.fx=null;}});seh.Uploader=Class.create(seh.Control,{initialize:function($super,E,F,D){$super(E);this.fi=$(E);this.upfrm=$(F);this.options=Object.extend({onBegin:Prototype.emptyFunction,onComplete:Prototype.emptyFunction,onSuccess:Prototype.emptyFunction,onFailure:Prototype.emptyFunction,uploadOnChange:true},(D||{}));if(this.options.uploadOnChange){this.fi.observe("change",this.performUpload.bindAsEventListener(this));}this.fi.clear();},performUpload:function(){var D={completeUpload:this.completeUpload};D.handler=D.completeUpload.bindAsEventListener(this,D);this.upfrm.observe("load",D.handler);var C=this.getFileName();this.fi.form.submit();this.options.onBegin(this,C);},completeUpload:function(F,E){this.upfrm.stopObserving("load",E.handler);var D=getFrameDocument(this.upfrm).body.innerHTML.stripTags().evalJSON();this.options.onComplete(this,D);if(D.__success__){this.options.onSuccess(this,D);}else{this.options.onFailure(this,D);}},getFileName:function(){var D=$F(this.fi);var E;var F=D.indexOf("/");if(F!=-1){E=D.split("/");}else{F=D.indexOf(BSLASH);if(F!=-1){E=D.split(BSLASH);}}return(E!=undefined)?E[E.length-1]:D;}});seh.TextFieldMultiInput=Class.create(seh.Control,{initialize:function($super,G,I,J){$super(G);if(Object.isArray(G)){for(var H=0;H<G.length;H++){var F=G[H];if(F.isElement){F.value=$(F.value);F.value["seh:control"]=this;}}}else{G=[{isElement:true,value:$(G)}];G[0].value["seh:control"]=this;}this.inputs=G;this.ul=$(I);this.options=Object.extend({addOnBlur:true,addOnCharacters:[],addOnEnter:true,templateText:"#{value}",subObjectDelegate:null,addPosition:"bottom",addDelegate:null,validateBlank:true,validateDelegate:null,onAddItem:null,onClear:null},J||{});this.template=new Template(this.options.templateText);this.inputs.each((function(A){if(!A.isElement){return ;}var B=A.value;B.observe("focus",this.onFocus.bindAsEventListener(this));B.observe("blur",this.onBlur.bindAsEventListener(this));if(this.options.addOnEnter){B.observe("keydown",this.onKeyDown.bindAsEventListener(this));}if(this.options.addOnCharacters&&this.options.addOnCharacters.length>0){B.observe("change",this.onChange.bindAsEventListener(this));}}).bind(this));},canFormSubmit:function(B){return this.options.addOnEnter?false:true;},onChange:function(C){var D=String.fromCharCode(C.keyCode);if(this.options.addOnCharacters.indexOf(D)==-1){return ;}this.submitValue();},onKeyDown:function(B){if(B.keyCode!=Event.KEY_RETURN){return ;}B.stop();this.submitValue();},onFocus:function(B){this.blockSubmit(true);},onBlur:function(B){if(this.options.addOnBlur){this.submitValue();}this.blockSubmit(false);},getValue:function(){var B="";this.inputs.each(function(A){if(A.isElement){B+=$F(A.value);}else{B+=A.value;}});return B;},submitValue:function(G){var I=false;if(!G){G=this.getValue();I=true;}if(this.options.validateBlank&&G.strip().length==0){return ;}if(this.options.validateDelegate&&!this.options.validateDelegate(G)){return ;}if(I){this.inputs.filter(function(A){return A.isElement;}).pluck("value").invoke("clear");(this.options.onClear||Prototype.emptyFunction)(this,this.input);}if(!this.options.addDelegate){var J={value:G,escapedValue:G.sub('"','"')};J=this.options.subObjectDelegate?this.options.subObjectDelegate(J):J;var F=this.template.evaluate(J);var H={};H[this.options.addPosition]=F;this.ul.insert(H);}else{this.options.addDelegate(this,G);}(this.options.onAddItem||Prototype.emptyFunction)(this,G);}});window.lastSelected=null;window.cfcMargin=null;function setSidebarVis(){var C=$("contentframeContainer");var D=$("sidebar");if($("content").readAttribute("nosidebar")){if(!cfcMargin){cfcMargin=C.getStyle("marginLeft");}C.setStyle({"marginLeft":"10px"});D.hide();}else{C.setStyle({"marginLeft":cfcMargin});D.show();}}addLF(function(B){initReportReasons();addRssMenu();if(window["console"]===undefined){window.console={log:Prototype.emptyFunction};}watchScroll();});function initReportReasons(){reasons=$("reportreasons");reasons.writeAttribute("onshow","$(this).down('form').reset();$(this).select('div.reasonform').invoke('hide');$(this).down('form').id.setValue(params.id);");reasons.select("div.reasonform").invoke("hide");var B=$("reasonlist");new Form.Element.EventObserver(B,function(A){var E=$F(A);reasons.select("div.reasonform").invoke("hide");var F=reasons.select("div."+E).first();if(F){F.show();}}.bind(this));}function addRssMenu(){flinks=[{name:"featured artist feed",callback:function(B){window.location.href="http://feeds.feedburner.com/Cherrypeel-FeaturedArtists";}},{name:"popular songs feed",callback:function(B){window.location.href="http://feeds.feedburner.com/Cherrypeel-PopularSongs";}},{name:"new songs feed",callback:function(B){window.location.href="http://feeds.feedburner.com/Cherrypeel-NewSongs";}},{name:"top songs feed",callback:function(B){window.location.href="http://feeds.feedburner.com/Cherrypeel-TopSongs";}}];fmenu=new Proto.Menu({selector:"#rssMenu",className:"fmenu",menuItems:flinks,validator:null,documents:[document]});}function watchScroll(){new seh.Sidebar($("sidebar"));}var _pulser;function startSubmitPulse(){if(_pulser){stopSubmitPulse();}var B=$("menu_submit").down("td");_pulser=new PeriodicalExecuter(pulseSubmit.bind(this,B),1.7);pulseSubmit(B);}function pulseSubmit(C,D){flash(C,1,0,1.6,"#FFFF99");}function stopSubmitPulse(){if(!_pulser){return ;}_pulser.stop();_pulser=null;}Prototype.X={Version:"0.1.2",Required:{Prototype:"1.6.0",Scripty:"1.8.0"},Require:function(){if(typeof Prototype=="undefined"||typeof Element=="undefined"||typeof Element.Methods=="undefined"||this.convertVersionString(Prototype.Version||0)<this.convertVersionString(this.Required.Prototype)){throw ("Prototype.Xtensions require Prototype.js >= "+this.Required.Prototype);}if(typeof Scriptaculous=="undefined"||typeof Effect=="undefined"||this.convertVersionString(Scriptaculous.Version||0)<this.convertVersionString(this.Required.Scripty)){throw ("Prototype.Xtensions require Scriptaculous >= "+this.Required.Scripty);
}},convertVersionString:function(C){var D=C.replace(/_.*|\./g,"");D=parseInt(D+"0".times(4-D.length));return C.indexOf("_")>-1?D-1:D;}};Prototype.X.Require();Prototype.X.Registry={};(function(){var F=navigator;var G=ua=navigator.userAgent;var H=F.appVersion;var E=parseFloat(H);Prototype.X.Browser={IE:(Prototype.Browser.IE)?parseFloat(H.split("MSIE ")[1])||0:0,Firefox:(Prototype.Browser.Gecko)?parseFloat(ua.split("Firefox/")[1])||0:0,Camino:(Prototype.Browser.Gecko)?parseFloat(ua.split("Camino/")[1])||0:0,Flock:(Prototype.Browser.Gecko)?parseFloat(ua.split("Flock/")[1])||0:0,Opera:(Prototype.Browser.Opera)?E:0,AIR:(ua.indexOf("AdobeAIR")>=0)?1:0,Mozilla:(Prototype.Browser.Gecko||!this.Khtml)?E:0,Khtml:(H.indexOf("Konqueror")>=0&&this.safari)?E:0,Safari:(function(){var A=Math.max(H.indexOf("WebKit"),H.indexOf("Safari"),0);return(A)?(parseFloat(H.split("Version/")[1])||((parseFloat(H.substr(A+7))>=419.3)?3:2)||2):0;})()};})();$unixTime=function(C){var D=new Date();D=D.getTime();if(C==true){D=D/1000;}return D;};Object.extend(String.prototype,{ucfirst:function(){return this.charAt(0).toUpperCase()+this.substring(1);}});Object.extend(Number.prototype,{minute:function(){return this*60;},hour:function(){return this*3600;},day:function(){return this*86400;},week:function(){return this*604800;},month:function(){return this*2629743.83;},year:function(){return this*31556926;},time:function(){return(this.toMs())+$unixTime();},toSeconds:function(){return this*1000;},toMs:function(){return this/1000;}});Object.extend(Class,{accessors:{createAccessors:function(D,C){var C=(!Object.isArray(C))?Object.keys(C):C;C.each(function(A){var B=(A.camelize()).ucfirst();(function(H,G){G["get"+B]=function(){return D[H];};G["set"+B]=function(E){D[H]=E;return G;};})(A,this);},this);},setOptions:function(H,F,G){var E=(Object.isUndefined(G))?false:G;if(!H){H={};}Object.extend(H,F||{});if(G){this.createAccessors(H,H);}}}});var History={__altered:false,__currentHash:null,__previousHash:null,__iframe:false,__title:false,init:function(){var C=this;var D=location.hash.substring(1);this.hash=$H(D.toQueryParams());this.__currentHash=D;this.__previousHash=D;this.__title=document.title;if(Prototype.Browser.IE&&Prototype.X.Browser.IE<8){document.observe("dom:loaded",function(A){if(!$("px-historyframe")){History.__iframe=new Element("iframe",{name:"px-historyframe",id:"px-historyframe",src:"",width:"0",height:"0",style:{visibility:"hidden"}});document.body.appendChild(History.__iframe);History.setHashOnIframe(C.hash.toQueryString());}});}},set:function(D,C){this.__previousHash=this.hash.toQueryString();this.hash.set(D,C);this.apply();},get:function(B){return this.hash.get(B);},unset:function(B){this.hash.unset(B);this.apply();},update:function(){this.__previousHash=this.hash.toQueryString();var D=window.location.hash.substring(1);if(Prototype.Browser.IE&&Prototype.X.Browser.IE<8&&this.__iframe){var C=this.getHashOnIframe();if(C!=D){D=C;}}this.hash=$H(D.toQueryParams());this.__currentHash=this.hash.toQueryString();},apply:function(){var B=this.hash.toQueryString();B=B.split("%2F").join("/");window.location.hash=B;if(Prototype.Browser.IE&&Prototype.X.Browser.IE<8&&this.__iframe){if(this.__currentHash!=B){this.setHashOnIframe(B);}else{if(B!=this.getHashOnIframe()){this.setHashOnIframe(B);}}}},isAltered:function(){if(this.__altered==true){return true;}this.__altered=false;return(History.__currentHash!=History.__previousHash);},setHashOnIframe:function(E){try{var F=History.__iframe.contentWindow.document;F.open();F.write('<html><body id="history">'+E+"</body></html>");F.close();}catch(D){}},getHashOnIframe:function(){var B=this.__iframe.contentWindow.document;if(B&&B.body.id=="history"){return B.body.innerText;}else{return this.hash.toQueryString();}},setTitle:function(B){if(document.title){document.title=B;}},getTitle:function(){return this.__title;}};History.init();History.Registry={hash:new Hash(),set:function(B){if(typeof (B)!="object"){throw ("History.Registry.set : $config must be an javascript object");}if(!B.id||!Object.isString(B.id)){throw ("History.Registry.set : $config.id must be an string");}if(!B.onStateChange||!Object.isFunction(B.onStateChange)){throw ("History.Registry.set : $config.onStateChange "+"must be an javascript callback function");}if(!B.defaultValue||!Object.isString(B.defaultValue)){B.defaultValue="";}this.hash.set(B.id,B);},get:function(B){return this.hash.get(B);},unset:function(B){this.hash.unset(B);}};History.Observer={delay:0.2,interval:null,started:false,start:function(){if(this.started){return ;}this.interval=new PeriodicalExecuter(History.Observer.dispatch,this.delay);this.started=true;},stop:function(){if(!this.started){return ;}this.interval.stop();this.started=false;},dispatch:function(){History.update();if(History.isAltered()){History.hash.each(function(D){var C=History.Registry.get(D.key);if(C){C.onStateChange.bind(History)(D.value);}});}}};Ajax.History={types:["Request","Updater"],observe:function(N,J,L,O){var P=Ajax.History.Registry.get(J);var I=0;var M=false;if(this.types.indexOf(N)==-1){throw ("Ajax.History.observer() -> type "+N+" is invalid !");}if(P==undefined){I=(O.history.state)?O.history.state:0;var K=new Hash();K.set(I,O);Ajax.History.Registry.set(J,K);}else{I=(O.history.state)?O.history.state:this.getCurrentVersion(J);P.set(I,O);}this.addCallback(N,J);return I;},addCallback:function(C,D){History.Observer.start();History.__altered=true;if(!Object.isUndefined(History.Registry.get(D))){return ;}History.Registry.set({id:D,onStateChange:function(A){var F=Ajax.History.Registry.get(D).get(A.toString());var B=null;if(Object.isUndefined(F)){return ;}if(F.history.cache==true&&F.history.__request){new Ajax.Cache(F.history.__request);}else{if(C=="Request"){B=new Ajax.Request(F.history.__url,F);}else{if(C=="Updater"){B=new Ajax.Updater(F.container,F.history.__url.split("///").join("?").split("//").join("&"),F);}}F.history.__request=B;}History.__altered=false;if(Object.isFunction(F.history.onStateChange)){F.history.onStateChange(A);}}});},getCurrentVersion:function(D){var C=Ajax.History.Registry.get(D);return Object.isUndefined(C)?0:C.keys().length;}};Ajax.History.Registry=new Hash();Ajax.History.Features={id:null,state:false,cache:false,onStateChange:null,__url:null,__request:null};Ajax.History.Request=Class.create({initialize:function(I,F){this.options={};Object.extend(this.options,F);if(this.options.history){var H=Object.clone(Ajax.History.Features);Object.extend(H,this.options.history);this.options.history=H;this.options.history.__url=I;if(Object.isUndefined(F.history.id)){throw ("Ajax.History.Request error : you must define historyId");}else{var G=this.options.history.id;}var J=Ajax.History.observe("Request",G,I,this.options);History.set(G,J);}else{return new Ajax.Request(I,this.options);}}});Ajax.History.Updater=Class.create({initialize:function(I,K,G){this.options={};Object.extend(this.options,G);if(this.options.history){var J=Object.clone(Ajax.History.Features);Object.extend(J,this.options.history);this.options.history=J;this.options.history.__url=K;if(Object.isUndefined(G.history.id)){var H=(Object.isString(I))?I:I.id;}else{var H=this.options.history.id;}this.options.container=I;var L=Ajax.History.observe("Updater",H,K,this.options);History.set(H,L);}else{return new Ajax.Updater(I,K,this.options);}}});Ajax.Cache=Class.create(Ajax.Base,{_complete:false,initialize:function($super,B){$super(B.options);B._complete=false;this.transport=B.transport;this.request(B.url);return this;},request:function(H){this.url=H;this.method=this.options.method;var F=Object.clone(this.options.parameters);try{var E=new Ajax.Response(this);if(this.options.onCreate){this.options.onCreate(E);}Ajax.Responders.dispatch("onCreate",this,E);if(this.options.asynchronous){this.respondToReadyState.bind(this).defer(1);}this.onStateChange();}catch(G){this.dispatchException(G);}}});Object.extend(Ajax.Cache.prototype,{respondToReadyState:Ajax.Request.prototype.respondToReadyState,onStateChange:Ajax.Request.prototype.onStateChange,success:Ajax.Request.prototype.getStatus,getStatus:Ajax.Request.prototype.getStatus,isSameOrigin:Ajax.Request.prototype.isSameOrigin,getHeader:Ajax.Request.prototype.getHeader,evalResponse:Ajax.Request.prototype.evalResponse,dispatchException:Ajax.Request.prototype.dispatchException});
Ajax.Request=Class.create(Ajax.Request,{initialize:function($super,D,C){$super(D,C);return this;}});Ajax.Request.Events=["Uninitialized","Loading","Loaded","Interactive","Complete"];Ajax.Updater=Class.create(Ajax.Updater,{initialize:function($super,D,E,F){$super(D,E,F);return this;}});