var highlightCloud=Class.create({initialize:function(b,a){this.input=$(a);this.div=$(b);this.tags=this.div.select("a");if(!this.input||!this.div||!this.tags){return}this.words=new Array();this.links=new Array();this.tags.each(function(c){this.words.push(c.innerHTML);this.links.push(c)},this);this.input.disabled=false;this.input.observe("keyup",this.highlight.bind(this));this.input.focus()},highlight:function(f){if(this.is_working){return setTimeout(function(){this.highlight()}.bind(this),300)}this.is_working=true;var b=this.input.value.insensitivePattern();var a=new RegExp("(^|\\s)"+b,"i");for(var d=0;d<this.words.length;d++){var c=this.words[d];if(b&&a.test(c)){this.links[d].addClassName("cloudsearch")}else{if(this.links[d].hasClassName("cloudsearch")){this.links[d].removeClassName("cloudsearch")}}}this.is_working=false}});function replaceProfileInit(){function a(){var b={focusOnReady:true,onComplete:function(d,c){var e=c.getAttribute("item");replaceProfileDone(e)}};new networkAutocompleter(document.fp.q,$("memberchoices"),b)}Effect.BlindUp($("tag_replace"));Effect.BlindDown($("tag_profile"),{afterFinish:function(){a()}})}function replaceProfileDone(c){document.fp.profile_id.value=c;document.fp.q.value="";var b=$("profile_tag_found").select("img")[0];var a=$("profile_tag_found").select("h3")[0];b.src=Data.user[c].doc_url;a.update(Data.user[c].title);$("profile_tag_search").hide();$("profile_tag_found").show()}function replaceProfileRetry(){document.fp.profile_id.value="";document.fp.q.value="";var b=$("profile_tag_found").select("img")[0];var a=$("profile_tag_found").select("h3")[0];b.src=URL.L+"/z.gif";a.update("");$("profile_tag_search").show();$("profile_tag_found").hide();document.fp.q.focus()}var networkAutocompleter=Class.create(Autocompleter.Base,{initialize:function(a,c,b){this.input=$(a);this.update=$(c).select("div")[0];this.tip=$(c).select("div")[1];this.nok=$(c).select("div")[2];if(b.onComplete){b.afterUpdateElement=b.onComplete;delete (b.onComplete)}this.options=b;this.baseInitialize(this.input,this.update,this.options);
Event.observe(this.input,"focus",function(){this.tip.clonePosition(this.input,{setHeight:false,offsetTop:this.input.offsetHeight-1});this.nok.clonePosition(this.input,{setHeight:false,offsetTop:this.input.offsetHeight-1});this.input.addClassName("on");this.tip.show();this.nok.hide()}.bind(this));Event.observe(this.input,"blur",function(){this.input.clear();this.input.removeClassName("on");this.tip.hide();this.nok.hide()}.bind(this));Event.observe(this.input,"keyup",function(){if(this.input.value.blank()){this.nok.hide();this.tip.show()}}.bind(this));if(this.input.disabled==true){this.input.disabled=false}if(b.focusOnReady){this.input.focus()}this.input.isready="true"},startIndicator:function(){this.input.addClassName("processing")},stopIndicator:function(){this.input.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.input.focus();this.getUpdatedChoices()}else{modal.complain(c,{},1);this.stopIndicator();this.input.clear()}},setValues:function(){var b=this.input.value.insensitivePattern();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||{})
}});