MSG.post_delete_confirm="Do you want to delete this post?\n("+_MSG.cannot_undo+")";MSG.tag_add_empty="Enter at least one keyword tag";MSG.tag_too_many="Sorry, you cannot enter more than 50 tags";MSG.tag_add_nok="Sorry, this tag is invalid";MSG.tag_del_confirm="Do you really want to remove the tag %s?";MSG.tag_too_spaces="You are about to add %d tag(s):<ul><li>%s</li></ul>If this is not what you want, please use syntax:\n<b><span style='color:red'>&quot;</span>%s<span style='color:red'>&quot;</span></b>";var init_tools=function(a){var b=init_tools_menu(true);if(!b){return}b.fave_post=function(c){if(b.is_faving){return}b.is_faving=true;$("fave_post").style.display="none";$("unfave_post").style.display="block";IOL.API.request("post.set.vote",{fave:1,post_id:a},b)};b.unfave_post=function(c){if(b.is_faving){return}b.is_faving=true;$("fave_post").style.display="block";$("unfave_post").style.display="none";IOL.API.request("post.set.vote",{fave:0,post_id:a},b)};b.post_set_vote_onApi=function(f,d,c,e){b.is_faving=false;if(f){}else{if(e.fave){$("fave_post").style.display="block";$("unfave_post").style.display="none"}else{$("fave_post").style.display="none";$("unfave_post").style.display="block"}modal.complain(d,{},1)}};b.delete_post=function(c){if(!confirm(MSG.post_delete_confirm)){return false}IOL.API.request("post.del",{post_id:a},b)};b.post_del_onApi=function(g,e,d,f){if(g){var c="?c=1&s=post.del&post_id="+f.post_id;document.location="/blog/"+glob_u.user_id+"/home"+c}else{modal.complain(e,"",1)}}};function init_keyword_tags(b){var a=$("keyword_tags");if(!a){return}a.select("a.trash").each(function(d){d.title=a.getAttribute("deltag")});a.add_tag=function(e,g){var d=e.trim();var f=d.split(/\s/);if(!d.match(/\"/)&&!d.match(/\,/)&&f.length>2&&!g){msg=MSG.tag_too_spaces.replace("%d",f.length).replace("%s",f.join("</li><li>")).replace("%s",d);return modal.say(msg,{icon:"warn",width:300},{label:_MSG.goahead,onclick:function(){a.add_tag(e,true)}},{label:_MSG.cancel})}if(d){var h={keywords:d,post_id:b};if(window.glob_group){h.group_id=glob_group.group_id
}IOL.API.request("post.add.tag",h,a)}else{alert(MSG.tag_add_empty)}return false};a.post_add_tag_onApi=function(l,m,g,f){if(l){var j=m.keywords;if(j.length){for(var h=0;h<j.length;h++){var e=j[h].keyword_id;if(!$("keyword_tag_"+e)){var n=$("keyword_tags").getAttribute("deltag");var d=document.createElement("dt");d.id="keyword_tag_"+e;d.innerHTML='&bull; <a href="/tag/'+glob_user.folder+"/keyword/"+e+'">'+j[h].title+'</a> <a href="#" onclick="$(\'keyword_tags\').del_tag('+e+');return false;" class="trash" title="'+n+'">[x]</a>';$("keyword_tags").appendChild(d)}}}if(c){c.keywords.value="";c.keywords.focus()}}else{if(m.error.id==2){modal.say(MSG.tag_add_nok,{icon:"nok"},1)}else{if(m.error.id==3){modal.say(MSG.tag_too_many,{icon:"nok"},1)}else{modal.complain(m,{},1)}}}};a.del_tag=function(d){var e=$("keyword_tag_"+d).select("a")[0].innerHTML;if(confirm(MSG.tag_del_confirm.replace("%s",'"'+e+'"'))){var f={keyword_id:d,post_id:b};if(window.glob_group){f.group_id=glob_group.group_id}IOL.API.request("post.del.tag",f,a)}};a.post_del_tag_onApi=function(g,f,d,h){if(g){var e=h.keyword_id;$("keyword_tags").removeChild($("keyword_tag_"+e))}else{modal.complain(f,{},1)}};var c=$("keyword_tags_form");if(c){c.onsubmit=function(){a.add_tag(this.keywords.value);return false}}}profile_tags_autocompleter=Class.create(Autocompleter.Base,{initialize:function(b,a){this.element=$("profile_tags_form").select("input")[0];this.update=$("profile_tags_form").select("div")[0];this.tip=$("profile_tags_form").select("div")[1];this.nok=$("profile_tags_form").select("div")[2];this.tags=$("profile_tags");this.baseInitialize(this.element,this.update,a);Event.observe(this.element,"focus",function(){this.tip.clonePosition(this.element,{setHeight:false,offsetTop:this.element.offsetHeight-1});this.nok.clonePosition(this.element,{setHeight:false,offsetTop:this.element.offsetHeight-1});this.element.addClassName("on");this.tip.show();this.nok.hide()}.bind(this));Event.observe(this.element,"blur",function(){this.element.clear();this.element.removeClassName("on");
this.tip.hide();this.nok.hide()}.bind(this));Event.observe(this.element,"keyup",function(){if(this.element.value.blank()){this.nok.hide();this.tip.show()}}.bind(this));this.options.afterUpdateElement=function(d,c){$("profile_tags").add_tag(c.getAttribute("item"));$("profile_tags_form").select("input")[0].value="";$("profile_tags_form").select("input")[0].blur()}},startIndicator:function(){this.element.addClassName("processing")},stopIndicator:function(){this.element.removeClassName("processing")},getUpdatedChoices:function(){this.startIndicator();if(!this.data){return IOL.API.request("user.get.network",{},this)}this.stopIndicator();this.setValues();this.updateChoices(this.setValues())},user_get_network_onApi:function(g,c,a,f){if(g){c.network[c.network.length]=glob_u;this.data=[];for(var d=0;d<c.network.length;d++){var b=c.network[d];if(!Data.user[b.user_id]){Data.user[b.user_id]=b}var e={value:_pi(b.user_id),label:b.title,icon:b.doc_url};this.data.push(e)}this.element.focus();this.getUpdatedChoices()}else{modal.complain(c,{},1);this.stopIndicator();this.element.clear();$("profile_tags_form").style.display="none"}},accentInsensitive:function(a){return a.replace(/([\?\.\*\\\+\-\_\=\[\]\{\}\(\)])/g,"\\$1").replace(/a/ig,"[aàáâãäå]").replace(/e/ig,"[eèéêë]").replace(/i/ig,"[iìíîï]").replace(/o/ig,"[oòóôõöø]").replace(/u/ig,"[uùúûü]").replace(/y/ig,"[yÿ]").replace(/c/ig,"[cç]").replace(/n/ig,"[nñ]").strip()},setValues:function(){var b=this.accentInsensitive(this.element.value);if(!b){return("<ul></ul>")}var a=new RegExp("(^|\\s)"+b,"i");var d=[];for(var e=0;e<this.data.length;e++){var g=this.data[e];if(g&&a.test(g.label)){d.push(g)}}if(d.length){var f="";for(var e=0;e<d.length;e++){var g=d[e];var c=g.label.gsub(a,function(h){if(h[0][0]==" "){return" <em>"+h[0].substr(1)+"</em>"}else{return"<em>"+h[0]+"</em>"}});f+='<li item="'+g.value+'"><img src="'+g.icon+'" width="25" height="25" alt=""/> '+c+"</li>"}this.nok.hide();this.tip.hide();return("<ul>"+f+"</ul>")}else{this.tip.hide();this.nok.show();return("<ul></ul>")}},setOptions:function(a){this.options=Object.extend({width:0,debug:false,frequency:0.1,minChars:1,autoSubmit:false,inputClass:""},a||{})
}});function init_profile_tags(b){var a=$("profile_tags");if(!a){return}var c=$("profile_tags_form");if(c){c.onsubmit=function(){return false}}a.select("a.trash").each(function(d){d.title=a.getAttribute("deltag")});a.add_tag=function(d){var e={profile_id:d,post_id:b};if(window.glob_group){e.group_id=glob_group.group_id}IOL.API.request("post.add.tag",e,a)};a.post_add_tag_onApi=function(g,f,d,i){if(g){var k=i.profile_id;var e=Data.user[i.profile_id];if(!$("profile_tag_"+k)){var j=$("profile_tags").getAttribute("deltag");var h=document.createElement("dt");h.id="profile_tag_"+k;h.innerHTML='&bull; <img src="'+e.doc_url+'" align="absmiddle" class="buddy" alt="" style="width:17px;height:17px"/> <a href="/tag/'+glob_user.folder+"/profile/"+k+'">'+e.title+'</a> <a href="#" onclick="$(\'profile_tags\').del_tag('+k+');return false;" class="trash" title="'+j+'">[x]</a>';$("profile_tags").appendChild(h)}}else{if(f.error.id==2){modal.say(MSG.tag_add_nok,{icon:"nok"},1)}else{if(f.error.id==3){modal.say(MSG.tag_too_many,{icon:"nok"},1)}else{modal.complain(f,{},1)}}}};a.del_tag=function(d){var e=$("profile_tag_"+d).select("a")[0].innerHTML;if(confirm(MSG.tag_del_confirm.replace("%s",'"'+e+'"'))){var f={profile_id:d,post_id:b};if(window.glob_group){f.group_id=glob_group.group_id}IOL.API.request("post.del.tag",f,a)}};a.post_del_tag_onApi=function(g,f,d,h){if(g){var e=h.profile_id;$("profile_tags").removeChild($("profile_tag_"+e))}else{modal.complain(f,{},1)}}}var post_props=Class.create();post_props.prototype.initialize=function(d){if(!$("post_props")){return}this.post_id=d;this.post=Data.post[d];this.window_div=$("post_props");this.window_div.obj=this;this.tabs=["share","license"];this.debug_level=800;this.debug_scope="post_tools";this.post_props=["share","com","tag","tagme","license","trk"];this.show_post_props();for(var c=0;c<this.tabs.length;c++){var b=this.tabs[c];var e=$("post_props_tab_"+b);e.tab=b;var a=this;Event.observe(e,"click",function(g){var f=Event.element(g);a.show_tab(f.tab,f);Event.stop(g)})}};post_props.prototype.init_window=function(){if(this.win){return
}this.overlay=new overlay();this.win=new win(this.window_div,{zindex:2000})};post_props.prototype.open=function(){this.hide_selects_textareas(1);this.init_window();this.overlay.show();var a=this.post;this.post_props.each(function(c){try{$(c+"_"+a[c]).checked="true"}catch(b){}});check_share("share",a.share,1);this.win.show();this.is_shown=true;IOL.debug("open","",this)};post_props.prototype.close=function(){var a=this;a.hide_selects_textareas(0);a.win.hide();a.overlay.hide();a.is_shown=false;IOL.debug("close","",this)};post_props.prototype.save=function(){var a=document.fprops;var b={post_id:this.post_id,share:a.share.value,com:_form_radio_get_value(a.com),tag:_form_radio_get_value(a.tag),tagme:_form_radio_get_value(a.tagme),license:_form_radio_get_value(a.license),trk:_form_radio_get_value(a.trk)};modal.say(_MSG.saving,{icon:"wait"});IOL.API.request("post.set",b,this)};post_props.prototype.post_set_onApi=function(e,b,a,d){if(e){modal.say(_MSG.saved,{timeout:500});for(var c in d){Data.post[this.post_id][c]=d[c]}this.show_post_props();this.close()}else{modal.complain(b,{},1);this.close()}};post_props.prototype.show_tab=function(c,d){for(var b=0;b<this.tabs.length;b++){var a=this.tabs[b];$("post_props_interface_"+a).style.display=(a==c)?"block":"none";$("post_props_tab_"+a).className=(a==c)?"on":""}if(d){d.blur()}this.tab=c};post_props.prototype.show_post_props=function(){var a=this.post;var b=(a.share*1>15)?15:a.share*1;this.post_props.each(function(f){var g=$("post_"+f);var c=a[f]*1;if(g){try{g.innerHTML=$("post_"+f+"_"+c).innerHTML;g.style.display=(c<b||f=="share"||f=="license")?"block":"none"}catch(d){IOL.debug("invalid post prop : "+f+"="+c,"err")}}})};post_props.prototype.hide_selects_textareas=function(b){var a=$A(document.getElementsByTagName("SELECT"));var c=$A(document.getElementsByTagName("TEXTAREA"));var d=$A(document.getElementsByTagName("IFRAME"));a.each(function(f){f.style.visibility=(b)?"hidden":"visible"});c.each(function(f){f.style.visibility=(b)?"hidden":"visible"});d.each(function(f){f.style.visibility=(b)?"hidden":"visible"
})};