function GetSkillLink(name,skill_id)
{return"http://profile."+cfg_ug_serv+"/"+escape(name)+"/skills/"+skill_id+'/';}
function OnInit()
{for(n in SongsNLinks)
{var ahrefs=document.getElementById('mp3_table_'+n).getElementsByTagName('a');ahrefs[0].n=n;ahrefs[0].onclick=function()
{GetKudos(SongsNLinks[this.n]);callExternalInterface(this.n,true);return false;};ahrefs[2].n=ahrefs[1].n=n;ahrefs[2].onclick=ahrefs[1].onclick=function()
{GetKudos(SongsNLinks[this.n]);return CommentOn(SongsNLinks[this.n],SongsData[this.n][2]);};}}
function KudosReady(req,params)
{kudos=req.responseJS.kudos;ShowKudos(params.id);}
function ShowKudos(id)
{if(kudos.length>0)
{var str="";for(i in kudos)str+="<a class=sm href=\""+kudos[i]['profile_link']+"\">"+kudos[i]['username']+"</a> ("+kudos[i]['kudo']+")<br>";document.getElementById('kudos_td').innerHTML=str;document.getElementById('kudos_table').className='info_more';document.getElementById('kudos_name').innerHTML="Who gave a Kudo :";}
else
{document.getElementById('kudos_td').innerHTML="";document.getElementById('kudos_table').className='info_more elm_disp_none';}}
function GetKudos(id)
{AjaxQuery("/ajax.get_kudos.php",KudosReady,{id:id});}
function ViewAllComments()
{window.open(GetSkillLink(profile.name,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("comment_on_name").innerHTML=htmlspecialchars(name);document.getElementById("main_comments_table").className='info';document.getElementById("comment_on_all_link").onclick=ViewAllComments;comment_on_id=id;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;var kudo=document.getElementById('kudo').value;if(!text.textLength()&&rate==0&&kudo==0)return ShowError(errors.trk_comment,"comm_ta");req.onreadystatechange=function()
{if(req.readyState==4)
{if(req.responseJS)
{if(text.trim().length)
{comments=req.responseJS.comments;BuildCommentsTable();}
if(rate!=0&&req.responseJS.rate)
{document.getElementById("rate_"+comment_on_id).innerHTML=req.responseJS.rating_str;setRatingForPlayer(comment_on_id,Math.round(req.responseJS['rate']/2));}
if(kudo&&req.responseJS.kudos)
{for(i=0;i<kudos.length&&kudos[i]['id']!=req.responseJS.kudos.id;i++);kudos[i]=Array();kudos[i]=req.responseJS.kudos;ShowKudos(comment_on_id);}
document.getElementById('comm_ta').value="";document.getElementById('rate').value=0;document.getElementById('kudo').value=0;}
else alert(req.responseText);}};req.caching=false;req.open('POST',"/manage_comments.php",true);doit=function()
{if(text.trim().length)
req.send({p:comment_on_id,adding:'1',section:'skill',text:text,rate:rate,kudo:kudo,return_comm:'1'});else
req.send({p:comment_on_id,adding:'1',section:'skill',rate:rate,kudo:kudo});};if(text.trim().length)
{document.getElementById("main_comments_table").style.paddingTop="";document.getElementById("main_comments_table").className='info';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 skill, click on the <u>comment</u> link from that skill.</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;}