var myMusic=new music();function music(){var D=[];var C=-1;var B=null;function A(F){var G=D[F];C=F;B=G;mySound.playAudio(G.URL);document.fire("song:playing",{"song":G})}function E(){var H="";D.each(function(J,I){H+="<tr id='song_"+J.ID+"'>";H+="<td class='index' onclick='myMusic.play("+J.ID+")'>"+(I+1)+".</td>";H+="<td class='name' onclick='myMusic.play("+J.ID+")'>"+J.Name+"</td>";H+="<td class='duration' onclick='myMusic.play("+J.ID+")'>"+J.DurationString+"</td>";H+="<td><a href='"+J.URL+"' onclick='myUI.incDwn("+J.ID+")'><img src='http://cosmicrhadio.com/Assets/CosmicRhadio/images/download-14.png' alt='Download' title='Download' /></a></td>";H+="</tr>";if(B!=null&&J.ID==B.ID){C=I}});if(Prototype.Browser.IE){var G=$("main").select("table thead")[0].innerHTML;$("main").innerHTML="<table cellspacing='0'><thead>"+G+"</thead><tbody>"+H+"</tbody></table>";myUI.hookTableEvents()}else{var F=$("main").select("table tbody")[0];F.innerHTML=H}if(B!=null){document.fire("songs:repaint",{"song":B})}}this.setSongs=function(F){D=F};this.sortByName=function(F){D.sort(function(H,G){if(H.Name>G.Name){return(F?1:-1)}if(G.Name>H.Name){return(F?-1:1)}else{return 0}});E()};this.sortByShuffle=function(){D.sort(function(G,F){return 0.5-Math.random()});E()};this.sortByRelease=function(){D.sort(function(G,F){if(G.DefaultSortIndex>F.DefaultSortIndex){return 1}else{if(F.DefaultSortIndex>G.DefaultSortIndex){return -1}else{return 0}}});E()};this.play=function(I){for(var G=0,F=D.length;G<F;G++){var H=D[G];if(H.ID==I){A(G);break}}};this.playPause=function(){if(C<0){A(0)}else{mySound.playPause()}};this.prev=function(){if(C>0){A(C-1)}else{A(D.length-1)}};this.next=function(){if(C<D.length-1){A(C+1)}else{A(0)}};this.getPlayingSong=function(){return B}}