MSG.Comment="Comment";MSG.Comments="Comments";MSG.comment_confirm_delete="Delete this comment?\n(this operation cannot be cancelled)";MSG.comment_says="says:";MSG.comment_replies="replies:";MSG.comment_permalink="permalink";MSG.comment_no_text="This comment is empty or contains pure HTML.\nOne or many words are requested in a valid comment";MSG.commment_group="Hello %user%, I'm an admin of the group %s. It would be great if you would add this doc to our group. Thank you!";function init_comment(b,e){var d=$("comment");if(!d){return}if($(document.fcomment)&&$(document.fcomment.comment)){new autoGrowTextarea(document.fcomment.comment)}d.preview=function(){var f=$("comment_content").value.trim();if(f!=""){d.please_wait(1);var g={preview:1,callback:"preview"};g[b+"_id"]=e;g.content=f;IOL.API.request(b+".add.comment",g,d)}};d.preview_onApi=function(i,g,f,h){d.please_wait(0);if(i){$("comment_preview").innerHTML=g.comment.content.nl2br();$("comment_preview").originalHTML=g.comment.content.nl2br();if(d.treat_timecodes){timecodes_replace($("comment_preview"))}$("comment_preview").style.display="block"}else{if(g.error.id==4){modal.say(MSG.comment_no_text,{icon:"warn"},1)}else{modal.complain(g,{},1)}}};d.post=function(){var f=$("comment_content").value.trim();if(f!=""){d.please_wait(1);var g={};g[b+"_id"]=e;g.content=f;g.callback="post";if(window.glob_group){g.group_id=glob_group.group_id}if(d.comment_id){g.comment_id=d.comment_id}if(d.comment_ref_id){g.comment_ref_id=d.comment_ref_id}IOL.API.request(b+".add.comment",g,d)}};d.post_onApi=function(m,p,i,h){d.please_wait(0);if(m){$("comment_content").value="";d.comment_id=0;d.comment_ref_id=0;var g=p.comment.comment_id;var k=p.comment.content;if($("comment_"+g)){h.comment_id=g}var f=document.createElement("div");f.id="comment_"+g;f.className="comment comment-my";var q=(h.comment_ref_id)?MSG.comment_replies:MSG.comment_says;var n=(glob_u.is_pro=="1")?' <sup class="pro">pro</sup>':"";f.innerHTML='<a name="comment'+g+'"></a><table><tr valign="top"><td style="width:60px"><a href="/home/'+glob_u.folder+'"><img src="'+glob_u.doc_url+'" width="50" height="50" alt="" class="buddy"/></a></td><td><h5><a href="/home/'+glob_u.folder+'" id="comment_'+g+'_author">'+glob_u.title+n+"</a> "+q+'</h5><div class="content" id="comment_'+g+'_content">'+k.nl2br()+'</div><small class="details">( <a href="'+p.comment.url+'">'+MSG.comment_permalink+'</a> / <a href="#commentform" onclick="$(\'comment\').modify('+g+');return false;">'+_MSG.edit+'</a> / <a href="#" onclick="$(\'comment\').del('+g+'); return false;">'+_MSG.suppress+"</a> )</small></td></tr></table>";
if(!Data.comment[g]){Data.comment[g]={};Data.comment[g].comment_ref_id=h.comment_ref_id;if(h.comment_ref_id){Data.comment[g].level=Data.comment[h.comment_ref_id].level+1}else{Data.comment[g].level=0}}$("comments_h3").style.display="block";if($("comment_be_the_first")){$("comment_be_the_first").style.display="none"}if(h.comment_id){$("comment_"+h.comment_id+"_content").innerHTML=k.nl2br();f=$("comment_"+h.comment_id)}else{if(h.comment_ref_id){var l=$("comments");var o=$("comment_"+h.comment_ref_id);l.insertBefore(f,o.nextSibling);var j=f.getElementsByTagName("table").item(0);j.style.marginLeft=(Data.comment[g].level<=5)?(Data.comment[g].level)*10+"px":"50px";Comment_ids.push(g);Comment_count++}else{$("comments").appendChild(f);Comment_ids.push(g);Comment_count++}}new Effect.Highlight(f);$("comment_"+g+"_content").originalHTML=k.nl2br();if(d.treat_timecodes){timecodes_replace($("comment_"+g+"_content"))}d.release_form();d.refresh_count()}else{if(p.error.id==4){modal.say(MSG.comment_no_text,{icon:"warn"},1)}else{modal.complain(p,{},1)}}};d.reply=function(f){this.place_form(f,1);setTimeout(function(){$("comment_content").focus()},500);d.comment_id=0;d.comment_ref_id=f};d.modify=function(f){$("comment_content").value=$("comment_"+f+"_content").originalHTML.br2nl();$("comment_7days").style.display="block";d.setcursor();this.place_form(f,2);setTimeout(function(){$("comment_content").focus()},500);d.comment_id=f;d.comment_ref_id=0};d.del=function(f){if(confirm(MSG.comment_confirm_delete)){var g={};g.comment_id=f;g.callback="del";if(window.glob_group){g.group_id=glob_group.group_id}IOL.API.request(b+".del.comment",g,d)}};d.del_onApi=function(i,g,f,h){if(i){$("comment_"+h.comment_id).innerHTML="";$("comment_"+h.comment_id).style.display="none";Comment_ids.splice(Comment_ids.indexOf(h.comment_id),1);Comment_count--;d.refresh_count()}else{modal.complain(g,{},1)}};d.refresh_count=function(){$("comments_h3").select("span")[0].update(Comment_count+" "+((Comment_count>1)?MSG.Comments:MSG.Comment))};d.place_form=function(i,k){var f=$("comment_"+i);
var g=$("comment_form");var l=$("comments");l.insertBefore(g,f.nextSibling);$A(g.getElementsByTagName("h3")).each(function(p,o){p.style.display=(o==k)?"block":"none"});$("comment_preview").style.display="none";document.fcomment.bcancel.style.visibility="visible";var n=_find_y(g);var h=_find_page_size();var j=h[3];var m=h[5];if((j>0)&&(n-m)>(j/2)){_scroll_window_y((n-m)-(j/2))}else{f.scrollTo()}};d.release_form=function(){var g=$("comment_form");var f=$("comments");f.parentNode.insertBefore(g,f.nextSibling);$("comment_preview").style.display="none";$("comment_7days").style.display="none";$A(g.getElementsByTagName("h3")).each(function(j,h){j.style.display=(h==0)?"block":"none"});document.fcomment.bcancel.style.visibility="hidden"};d.cancel=function(){d.comment_ref_id=0;d.comment_id=0;$("comment_content").value="";d.release_form()};d.please_wait=function(f){if(f){$("comment_butt").style.display="none";$("comment_wait").style.display="block";document.fcomment.comment.disabled=true;document.fcomment.comment.addClassName("disabled")}else{$("comment_butt").style.display="block";$("comment_wait").style.display="none";document.fcomment.comment.disabled=false;document.fcomment.comment.removeClassName("disabled")}};d.show_groups=function(){$("comment_group_link").hide();if(!$("comment_groups").is_ready){$("comment_group_wait").show();IOL.API.request("group.search",{stp:100,rel:3,callback:"show_groups"},d)}else{$("comment_group_div").show()}};d.hide_groups=function(){$("comment_group_link").show();$("comment_group_wait").hide();$("comment_group_div").hide()};d.show_groups_onApi=function(n,g,f,m){if(n){var l=$("comment_groups");var k=g.groups;for(var j=0;j<k.length;j++){var h=document.createElement("option");h.value=k[j].group_id;h.appendChild(document.createTextNode(k[j].title));l.appendChild(h);Data.group[k[j].group_id]=k[j]}$("comment_group_wait").hide();$("comment_group_div").show();l.is_ready=true}else{$("comment_group_link").show();$("comment_group_wait").hide();modal.say(_MSG.failed,{icon:"nok"},1)}};d.select_group=function(i){var h=$("comment_content");
var l=h.value.trim();var g=i.options[i.selectedIndex].value;var f=i.group_id;if(f&&g!=f){var j=Data.group[f];var k=MSG.commment_group.replace("%user%",glob_user.title).replace("%s",'<a href="/group/'+j.folder+'">'+j.title+"</a>");if(l.indexOf(k)>=0){l=l.replace(k,"").trim();if(!g){h.value=l}}}if(g){var j=Data.group[g];var k=MSG.commment_group.replace("%user%",glob_user.title).replace("%s",'<a href="/group/'+j.folder+'">'+j.title+"</a>");h.value=(l!="")?k+"\n"+l:k;i.group_id=g}};d.setcursor=function(){el=$("comment_content");el.focus();if(el.value&&el.value.length){if(el.setSelectionRange){el.focus();el.setSelectionRange(el.value.length,el.value.length)}else{if(el.createTextRange){var f=el.createTextRange();f.moveStart("character",el.value.length);f.moveEnd("character",0);f.select()}}}};if(b=="doc"&&Data.doc[e].embed.match(/flv|mp3/)&&typeof window.timecodes_replace=="function"){d.treat_timecodes=true}var c=$A($("comments").getElementsByTagName("div"));for(var a=0;a<c.length;a++){if(c[a].className=="content"){c[a].originalHTML=c[a].innerHTML;if(d.treat_timecodes){timecodes_replace(c[a])}}}};