function showLyrics(id)
{document.getElementById(id).style.display=document.getElementById(id).style.display==''?'none':'';return false;}
function GetSongLink(name,p,song_id)
{var link="http://";if(p==3)
link+="profile";else
link+="artists";return link+"."+cfg_ug_serv+"/"+escape(name)+"/music/"+song_id+'/';}
function OnInit()
{for(n in SongsNLinks)
{var ahrefs=document.getElementById('mp3_table_'+n).getElementsByTagName('a');ahrefs[0].n=n;ahrefs[0].onclick=function()
{callExternalInterface(this.n,true);return false;};for(var i=0,len=ahrefs.length;i<len;i++)if(ahrefs[i].getAttribute("comment_on"))
{ahrefs[i].n=n;ahrefs[i].onclick=function()
{return CommentOn(SongsNLinks[this.n],SongsData[this.n][2]);};}}}
function TrackInfo()
{Show['TI']=Show['TI']?0:1;var style=Show['TI']?'':'elm_disp_none';for(i=0;i<SongsData.length;i++){if(document.getElementById('mp3_table_'+i).rows[2]&&document.getElementById('mp3_table_'+i).rows[2].className!='lyrics_tr')
{document.getElementById('mp3_table_'+i).rows[1].className=style;}}
document.getElementById('track_info_link').innerHTML=Show['TI']?"Hide tracks info":"Show tracks info";return false;}
function ViewAllComments()
{window.open(GetSongLink(profile.name,profile.p,comment_on_id),"_blank","height=400,width=600,status=yes,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes");return false;}
function CommentOn(id,name)
{document.getElementById("comments_div").className='';document.getElementById("main_comments_table").className='info';document.getElementById("comment_on_name").innerHTML=htmlspecialchars(name);document.getElementById("comment_on_all_link").onclick=ViewAllComments;comment_on_id=id;document.location="#comments_div";return false;}
function PostComment()
{if(!is_loged_in)return ShowError(errors['login_comment'],"comm_ta");if(is_banned)return ShowError(errors['banned'],"comm_ta");if(is_ug_banned)return OnUgBanned();var req=new JsHttpRequest();var text=document.getElementById('comm_ta').value;var rate=document.getElementById('rate').value;if(!text.textLength()&&rate==0)return ShowError(errors['textorrate_comment'],"comm_ta");if(text.textLength()>1024)return ShowError('Field \"Post a comment\" is too long. 1024 characters max. You entered '+text.textLength(),'comm_ta');doit=function()
{req.onreadystatechange=function()
{if(req.readyState==4)
{if(req.responseJS)
{if(text.textLength())
{comments=req.responseJS.comments;BuildCommentsTable();document.getElementById('comm_ta').value="";}
if(rate!=0&&req.responseJS.rate)
{document.getElementById('rate').value=0;document.getElementById("rate_img_"+comment_on_id).src="/i/r"+Math.round(req.responseJS['rate'])+"_m.gif";setRatingForPlayer(comment_on_id,Math.round(req.responseJS['rate']));}}
else alert(req.responseText);}};req.caching=false;req.open('POST',"/manage_comments.php",true);if(text.trim().length)
{var ids=category!='all'?SongsNLinks:false;req.send({p:comment_on_id,adding:'1',section:'song',text:text,rate:rate,return_comm:'1',ids:ids});}
else
{req.send({p:comment_on_id,adding:'1',section:'song',rate:rate});}};if(text.trim().length)
{document.getElementById("main_comments_table").className='info';document.getElementById("main_comments_table").style.paddingTop="";document.getElementById("cd").className='';document.getElementById("comments_div").className='elm_disp_none';ShowLoadingMsg(document.getElementById('comments_list'));if(is_ie)setTimeout("doit()",100);else doit();}
else doit();HideError();}
function BuildCommentsTable()
{var str="";str+="<table cellpadding=2 cellspacing=0 width=100%>";str+="<tr>";str+="<td class=b3><i>If you want to see all comments on particular song, click on the <u>comment</u> link from that song.</i></td>";str+="</tr>";if(comments.length)
{for(var i=0;i<comments.length;i++)
{var row=comments[i];if(profile.p==3)var hl=row.profileid==profile.id?"a":"";if(profile.p==22)var hl=row.is_god?"a":(row.is_mod?"m":"");if(profile.p==4)var hl=row.is_member?"a":"";str+="<tr>";str+="<td><div class=cmt "+(i==comments.length-1?"style=\"border-bottom:0\"":"")+">";str+="<font class=smp><a href="+row.link+" class=sp";if(hl)str+=" style=\"padding:3px 5px;background:#FFC600;color:#000\"";str+="><span id='u_"+i+"'>"+row.username+"</span></a>";if(hl)str+="<span style=\"padding:3px 5px;background:orange;color:#000;border-left:solid 1px #000\">"+hl+"</span>";str+=" <span id='d_"+i+"'>"+row.date+"</span> wrote on <b><font color=#777777><span id='song_name_"+i+"'>"+htmlspecialchars(SongsData[SongsIdLinks[row.comment_on]][2])+"</span></b></font> track:</font><p class=p2><span id='t_"+i+"'>"+row.text+"</span></p><p style='margin-top:10px'><font class=smp><a href='' class=smp onclick='return insComm("+i+",null,"+row.comment_on+");'>quote</a></div>";str+="</td>";str+="</tr>";}}
str+="</table>";document.getElementById('comments_list').innerHTML=str;}