").appendTo(d);c.deleted||$("").click(r(c.message_id,v)).appendTo(d.find("div:last").append(" – "));for(var m=0;m – ");y.find("a").text(g.username);var w=$(''),b=$("");g.html?b.html(g.html):b.text(g.text);var C;C=g.user_id>0?$(" this flag is noise").find("input").css({"marginLeft":10,"verticalAlign":"bottom"}).end().attr("title","If this box is checked, dismissing the flag will show a notification to the flagger that moderator flags are reserved for serious issues."):$([]),v.append($("").append(w,b,y,C).data("flag_id",g.flag_id))}}}}$(e).click(function(e){e.stopPropagation(),e.preventDefault();var n=popUp(e.pageX,e.pageY).css({"width":"auto","maxWidth":600,"minWidth":300}).addClass("flags-popup").append("
Loading flags
");$.getJSON(t,function(e){s(e,n)})})}function roomAccessControl(e,t){function n(e){$("").addClass("dropdown-button button change-user-access").attr("href","#").css({"position":"absolute","bottom":2,"left":2}).appendTo(e).append("")}function i(t){var n=$("").attr("action","/rooms/setuseraccess/"+e).attr("method","post").append($("").attr("type","hidden").attr("name","fkey").val(a));return void 0!=t&&$("").attr("type","hidden").attr("name","aclUserId").val(t).appendTo(n),n}function o(e){var t=$("#add-user-search-result");t.empty().append($("").attr("src",IMAGE("ajax-loader.gif"))),$("#add-user-search-result").load("/users",{"filter":e.toLowerCase(),"mini":!0,"nofade":!0},function(e,t){"success"==t&&(accessType=$("#add-user-search-result").closest(".access-section").attr("id").replace("access-section-",""),$("#add-user-search-result .usercard").each(function(){n(this)}))})}var a=$("input[name='fkey']").attr("value"),r={"remove":"no special access","read-only":"read access","read-write":"write access","moderation":"moderator","owner":"owner"},s={"read-only":"grant read access","read-write":"grant write access","moderation":"make moderator","owner":"make owner"},c=!1;$(document).on("click","*",function(e){c||(0==$(e.target).closest(".popup").length&&$(".popup").remove(),c=!0,setTimeout(function(){c=!1},0))}),$(".usercard").each(function(){n(this)}),$(document).on("click",".change-user-access",function(t){t.preventDefault();var n=$(this).closest(".usercard").attr("id").replace(/(?:access-)?user-/,""),o=$(this).closest(".access-section").attr("id").replace("access-section-",""),s=$(this).closest(".usercard"),c=s.position();c.left+=20,c.top+=38,c.position="absolute";var l=$("").addClass("popup").css(c).hide().insertBefore($(this).closest(".usercard"));if($("").text("Access for "+$(this).closest(".usercard").find(".username").text()).appendTo(l),window.userKeys&&n in userKeys){var u=userKeys[n],d=$("").appendTo(l);u?(d.text("Key: "+u),l.css({"width":"auto"})):d.text("Key: none"),$("").attr("action","/rooms/makeFeedKey").attr("method","post").append($("").attr("type","hidden").attr("name","fkey").val(a)).append($("").attr("type","hidden").attr("name","userId").val(n)).append($("").attr("type","hidden").attr("name","roomId").val(e)).append($("").attr("type","submit").val("create new key").addClass("button")).appendTo(d)}var f=i(n).appendTo(l),h=$(this).closest("#add-user-search-result").length;for(u in r){var p=u==o;if(p||"moderation"!=u){var m=u+"-radio";$('').attr("id",m).val(u).prop("checked",p).appendTo(f),$("").attr("for",m).text(" "+r[u]).css("font-weight",p&&!h?"bold":"normal").appendTo(f),$(" ").appendTo(f)}}$('').appendTo(f),$('cancel').click(function(){l.remove()}).appendTo(f),l.slideDown(200)}),$(document).on("click",".add-user-button",function(){accessType=$(this).closest(".access-section").attr("id").replace("access-section-","");var e=$("").addClass("popup").css({"width":735,"position":"absolute","right":100,"top":20,"overflow":"visible"}).appendTo($(this).closest(".access-section"));$("").text("Add a new user to the "+r[accessType]+" list").appendTo(e);var n=i().appendTo(e);$('').val(accessType).appendTo(n),t||$("
Please note, you can only add users in the following cases:
They have already visited "+location.hostname+".
They have sufficient reputation to talk in chat (>20 reputation).
").appendTo(n);{var a=$('
If you have it, enter the user id or the user\'s profile URL here:
').appendTo(n),c=a.find(".button"),l=$("
Otherwise"+(t?", if they have already visited "+location.hostname+" before, you can":"")+" search for their user name:
").appendTo(e),u=$("").attr("type","text").appendTo(l).bind("change keyup click",function(){$(this).val()?c.css("visibility","hidden"):c.css("visibility","visible")});$("").attr("id","add-user-search-result").appendTo(e)}$('').appendTo(e),$('cancel').click(function(){e.remove()}).appendTo(e),u.keyup(function(e){13==e.which&&o(u.val())}).typeWatch({"callback":o,"wait":500,"captureLength":2})})}function SymmetricList(e,t){$(".subtabs a",e).click(function(n){n.preventDefault();var i=$(this),o=$("").attr("src",IMAGE("ajax-loader.gif")).css("float","left").prependTo(e.find(".subtabs"));t.load(i.attr("href"),function(){initCycling(),o.remove(),e.find(".subtabs a").removeClass("youarehere"),i.addClass("youarehere")})})}function InitUserIndex(e,t,n,i){InitIndexPage(e,t,n,i,"filter users","/users","#userlist",".username, .user-message-info")}function InitRoomIndex(e,t,n,i,o,a){function r(){var e=$(this),t=e.closest(".roomcard, .roomcard-xxl").attr("id").replace("room-","");e.toggleClass("favorite-room"),$.post("/rooms/favorite",fkey({"roomId":t}),function(t){t&&(t.isFavorite?e.addClass("favorite-room"):e.removeClass("favorite-room"))})}function s(){"invited"==e&&$("#roomlist .roomcard").append($("").addClass("btn-delete").addClass("cancel-invite").attr("title","ignore this invite"))}function c(e){e.animate({"opacity":0,"width":"0px","height":"0px"},800,function(){e.remove()})}if(initCycling(),cycle(),doEllipsis(),arguments.length>0){var l={};o&&(l.nohide=!0),a&&a.length&&(l.host=a),InitIndexPage(e,t,n,i,"filter rooms","/rooms","#roomlist",".room-name, .room-description, .room-header .tag",s,l),$(".join-link").click(function(){return $.post($(this).attr("href"),fkey({"quiet":!0}),function(e){window.location=e}),!1})}s(),$(document).on("click",".favorite-room-vote",r),$(document).on("click",".cancel-invite",function(){var e=$(this).closest(".roomcard");$.post("/users/cancel-invite",fkey({"roomid":e.attr("id").replace("room-","")}),function(){c(e)})}),$(document).on("click","#site-select",function(e){return selectStackSite(e,0,!1,function(e){location.href=$("#site-select").attr("href")+"&host="+encodeURIComponent(e)}),!1})}function initCycling(){$(".cycle").each(function(){var e=$(this),t=e.children();if(e.removeClass("cycle"),!(t.length<2)){e.addClass("cycling");var n=-1;t.each(function(){var e=$(this),t=-1==n;n=Math.max(n,e.height()),e.css({"position":"absolute","opacity":t?1:0,"zIndex":t?1:0})}),e.css({"height":n})}})}function cycle(){setInterval(function(){var e;try{e=$(".cycling:hover")}catch(t){e=$([])}$(".cycling").each(function(){var t,n,i=$(this);if(!(e.filter(i).length>0)){var o=i.children();o.each(function(){var e=$(this);e.css("opacity")>.5?t=e:t&&!n&&(n=e)}),n||(n=o.eq(0)),n.height()>i.height()&&i.animate({"height":n.height()},1e3),t.animate({"opacity":0},1e3).css("z-index",0),n.animate({"opacity":1},1e3).css("z-index",1)}})},5e3)}function InitIndexPage(e,t,n,i,o,a,r,s,c,l){function u(){var e=$("#search").val();return e==o?"":e}var d=$("#search").val();""==d?$("#search").val(o).addClass("watermark"):$(s).highlight(d).removeClass("watermark");var f=function(){var o=u(),f={"tab":e,"sort":t,"filter":o,"pageSize":n,"page":o==d?i:void 0};if(l)for(var h in l)f[h]=l[h];$(r).load(a,f,function(e,t){if("success"==t){initCycling(),doEllipsis();var n=$(s);o&&o.length>0&&n.length>0&&n.highlight(o),c&&c()}})};$("#search").keyup(function(e){13==e.which&&f()}).typeWatch({"callback":f,"wait":500,"captureLength":2}),$("#search").focus(function(){$(this).val()==o&&$(this).val("").removeClass("watermark")}).blur(function(){""==$(this).val()&&$(this).val(o).addClass("watermark")}),setInterval(function(){f()},6e4)}function initScheduleInfo(e,t,n){function i(e){return $(e).closest(".meeting").attr("id").replace("meeting-","")}function o(e){var t=e.find(".attendees .usercard").length;e.find("span.attendee-count").text(0==t?"No users have":1==t?"One user has":t+" users have")}$(function(){var a=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];$(".local-time-placeholder").each(function(){var e,t,n,i=$(this).removeClass("local-time-placeholder"),o=parseInt(i.attr("data-time"));isFinite(o)&&(e=new Date(1e3*o),n=e.getMinutes(),t=e.getHours()+":"+(10>n?"0":"")+n,i.text(" (in your timezone, that's "+t+" on "+a[e.getDay()]+")"))}),t&&($("#firstTime").timePicker({"step":15}),$(".meeting .btn-delete").click(function(){var t=$(this).closest(".meeting"),n=t.find(".icon");confirm("This will delete this item from the schedule; are you sure?\n\nIf there is a corresponding event in the parent site, it will not be removed automatically.")&&$.post("/rooms/schedule/delete/"+e,fkey({"meetingId":i(this)}),function(){n.length&&0==t.next(".meeting").find(".calendar").length&&n.prependTo(t.next(".meeting")),t.slideUp(function(){t.remove()})})})),$(".sched-reg").click(function(){var t=$(this),n=t.closest(".meeting"),a=n.find(".sched-unreg");n.find(".ajax-loader").show(),$.post("/rooms/schedule/reg/"+e,fkey({"meetingId":i(this)}),function(e){var i=n.find(".attendees");if(0==i.length){var r=n.find(".meeting-info");i=$('').appendTo(r),$('').appendTo(r)}$(e).hide().appendTo(i).slideDown(),n.find(".ajax-loader").hide(),t.hide(),a.show(),o(n)})}),$(".sched-unreg").click(function(){var t=$(this),a=t.closest(".meeting"),r=a.find(".sched-reg"),s=a.attr("id")+"-user-"+n;a.find(".ajax-loader").show(),$.post("/rooms/schedule/unreg/"+e,fkey({"meetingId":i(this)}),function(){$("#"+s).slideUp(function(){$(this).remove(),o(a)}),a.find(".ajax-loader").hide(),t.hide(),r.show()})})})}function initSearchScreen(e){$("#user").autocomplete("/users/search",{"formatItem":function(e){return $.parseJSON(String(e)).dn},"formatResult":function(e){return $.parseJSON(String(e)).id},"max":20}),$("#room").autocomplete("/rooms/search",{"formatItem":function(e){return $.parseJSON(String(e)).name},"formatResult":function(e){return $.parseJSON(String(e)).id}}),$(".searchroom .btn-delete").click(function(){$(".searchroom").remove(),$("#room").val("").removeClass("hidden")}),$(".searchuser .btn-delete").click(function(){$(".searchuser").remove(),$("#user").val("").removeClass("hidden")}),e&&$("#q").focus()}function doEllipsis(){var e="div.roomcard > .room-header > .room-description, div.usercard-mini > .user-header > .user-message-info";$(e).each(function(){Ellipsis($(this))})}function Ellipsis(e){var t=e.height(),n=e.text(),i=$("").text(n);if(e.empty().append(i),i.height()<=t)return i.remove(),e.text(n),void 0;for(var o,a,r=0,s=n.length;s>r;)o=Math.round((r+s)/2),a=n.substr(0,o),i.text(a+"…"),i.height()<=t?r=o:s=o-1;a=n.substr(0,r),i.remove(),e.text(a+"…")}function initBasicPage(e,t,n,i){if(initSearchBox(),notify=Notifier().notify,n&¬ify(n),i&&!$.cookie("x")){var o=notify("Welcome to "+e+" chat! You'll need "+t+" reputation to talk here. This site is moderated by the community, so please be respectful of your fellow "+e+' users. And while you\'re at it, check out the FAQ!');o.find("a").add(".notify-close-info").click(function(){$.cookie("x","0",{"expires":90,"path":"/"})})}return{"notify":notify}}window.CHAT={"RoomUsers":{}},/^#nonewmob;/.test(location.hash)&&(location.hash=location.hash.substr(10),location.hash.length<=1&&window.history&&window.history.replaceState&&history.replaceState(null,null,location.href.replace(/#$/,""))),function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery"],e):"undefined"!=typeof module&&module.exports?module.exports=e(require("jquery")):e(jQuery)}(function(e){"use strict";function t(t){return!t.nodeName||-1!==e.inArray(t.nodeName.toLowerCase(),["iframe","#document","html","body"])}function n(t){return e.isFunction(t)||e.isPlainObject(t)?t:{"top":t,"left":t}}var i=e.scrollTo=function(t,n,i){return e(window).scrollTo(t,n,i)};return i.defaults={"axis":"xy","duration":0,"limit":!0},e.fn.scrollTo=function(o,a,r){"object"==typeof a&&(r=a,a=0),"function"==typeof r&&(r={"onAfter":r}),"max"===o&&(o=9e9),r=e.extend({},i.defaults,r),a=a||r.duration;var s=r.queue&&1=p[a]?0:Math.min(p[a],v)),!e&&1").attr("src",c.image)[0]),i.placeholder&&s.src&&(s.src=c.found?c.image:i.notFound||s.src),i.onComplete&&i.onComplete(c),c.done")).load(o).error(o).bind("abort",o).each(a)};t.gap=14,t.cache=[],t.defaults={"threshold":2,"base":"","ext":"","replace":""},e.fn.preload=function(e){return t(this,e),this},function(){var t=(e.fn.preload,e.preload);e.fn.preload=function(){try{return t.apply(this,arguments)}catch(e){return this}},e.preload=function(){try{t.apply(this,arguments)}catch(e){}}}()}(jQuery),function(e){e.fn.typeWatch=function(t){function n(t,n){var i=e(t.el).val();(i.length>o.captureLength&&i.toUpperCase()!=t.text||n&&i.length>o.captureLength)&&(t.text=i.toUpperCase(),t.cb(i))}function i(t){if("TEXT"==t.type.toUpperCase()||"TEXTAREA"==t.nodeName.toUpperCase()){var i={"timer":null,"text":e(t).val().toUpperCase(),"cb":o.callback,"el":t,"wait":o.wait};o.highlight&&e(t).focus(function(){this.select()});var a=function(e){var t=i.wait,o=!1;13==e.keyCode&&"TEXT"==this.type.toUpperCase()&&(t=1,o=!0);var a=function(){n(i,o)};clearTimeout(i.timer),i.timer=setTimeout(a,t)};e(t).keydown(a)}}var o=e.extend({"wait":750,"callback":function(){},"highlight":!0,"captureLength":2},t);return this.each(function(){i(this)})}}(jQuery),function(e){var t;t=Array.prototype.indexOf?function(e,t){return e.indexOf(t)}:function(e,t){for(var n=e.length,i=0;n>i;i++)if(i in e&&e[i]===t)return i;return-1};var n={},i=function(e){return this instanceof i?(this.forEach="function"==typeof e?s(e):e.constructor===Array?c(e):l(e),void 0):new i(e)},o=function(e){return e instanceof i?e:new i(e)},a=function(){throw n},r=function(e){this.message=e,this.name="IterationError"};r.prototype=Error.prototype;var s=function(e){return function(t,i){var s=!1,c=0,l=function(e){if(s)throw new r("yield after end of iteration");var n=t.call(i,e,c,a);return c++,n},u=function(e){o(e).forEach(function(e){l(e)})};try{e(l,u,a)}catch(d){if(d!==n)throw d}finally{s=!0}}},c=function(e){return s(function(t){for(var n=e.length,i=0;n>i;i++)i in e&&t(e[i])})},l=function(e){return s(function(t){for(var n in e)e.hasOwnProperty(n)&&t([n,e[n]])})},u=function(e){return"string"==typeof e?function(t){return t[e]}:e};i.prototype={"toArray":function(){var e=[];return this.forEach(function(t){e.push(t)}),e},"filter":function(e,t){var n=this;return e=u(e),new i(function(i){n.forEach(function(n){e.call(t,n)&&i(n)})})},"take":function(e){var t=this;return new i(function(n){t.forEach(function(t,i,o){i>=e&&o(),n(t)})})},"skip":function(e){var t=this;return new i(function(n){t.forEach(function(t,i){i>=e&&n(t)})})},"map":function(e,t){var n=this;return e=u(e),new i(function(i){n.forEach(function(n){i(e.call(t,n))})})},"zipWithArray":function(e,t){"undefined"==typeof t&&(t=function(e,t){return[e,t]});var n=this;return new i(function(i){var o=e.length,a=0;n.forEach(function(n,r,s){for(;!(r+a in e)&&o>r+a;)a++;r+a>=o&&s(),i(t(n,e[r+a]))})})},"reduce":function(e,t){var n,i;return arguments.length<2?n=!0:(n=!1,i=t),this.forEach(function(t){n?(i=t,n=!1):i=e(i,t)}),i},"and":function(e){var t=this;return new i(function(n,i){i(t),i(e)})},"takeWhile":function(e){var t=this;return e=u(e),new i(function(n){t.forEach(function(t,i,o){e(t)?n(t):o()})})},"skipWhile":function(e){var t=this;return e=u(e),new i(function(n){var i=!0;t.forEach(function(t){i=i&&e(t),i||n(t)})})},"all":function(e){var t=!0;return e=u(e),this.forEach(function(n,i,o){(e?e(n):n)||(t=!1,o())}),t},"any":function(e){var t=!1;return e=u(e),this.forEach(function(n,i,o){(e?e(n):n)&&(t=!0,o())}),t},"first":function(){var e;return this.forEach(function(t,n,i){e=t,i()}),e},"groupBy":function(e){var n=this;return e=u(e),new i(function(o,a){var r=[],s=[];n.forEach(function(n){var i=e(n),o=t(r,i);-1===o?(r.push(i),s.push([n])):s[o].push(n)}),a(new i(r).zipWithArray(s,function(e,t){var n=new i(t);return n.key=e,n}))})},"evaluated":function(){return new i(this.toArray())},"except":function(e){return this.filter(function(t){return t!==e})},"sortBy":function(e){var t=this;return e=u(e),new i(function(n){var o=t.toArray(),a=f(0,o.length).toArray(),r=i(o).map(e).toArray();a.sort(function(e,t){var n=r[e],i=r[t];if(typeof n==typeof i){if(n===i)return t>e?-1:1;if(i>n)return-1;if(n>i)return 1}throw new TypeError("cannot compare "+n+" and "+i)}),new i(a).forEach(function(e){n(o[e])})})},"count":function(){var e=0;return this.forEach(function(){e++}),e}};var d=function(e,t){var n=e;return"undefined"==typeof t&&(t=1),new i(function(e){for(;;)e(n),n+=t})},f=function(e,t){return d(e,1).take(t)},h=e.Generator;e.Generator=i,i.BreakIteration=n,i.Count=d,i.Range=f,i.IterationError=r,i.noConflict=function(){return e.Generator=h,i}}(this);var moderatorTools=function(e){var t={},n=function(){$(document).on("click",".quick-unmod",function(){var e,t,n=$(this).closest("tr");n.length?(e=n.attr("id").replace("fl-",""),n.prev().hasClass("monologue-row")&&(0==n.next().length||n.next().hasClass("monologue-row"))&&(t=n.prev())):(n=$(this).closest("li"),e=n.data("flag_id"),1==n.closest("ul").find("li").length&&(t=n.closest(".flagged-message")));var i="",o="";n.find("input[name=noise]").prop("checked")&&(i="?noise=true",o=" and notify the flagger that moderator flags should only be used for serious issues"),confirm("Dismiss this flag"+o+"?")&&$.post("/flags/"+e+"/clear"+i,fkey(),function(){n.remove(),t&&t.remove()})})};return t.initFlagSupport=function(t,i,o){$(document).on("click",".reflag,.counterflag,.mehflag",function(n){n.preventDefault();var i,o,a=$(this),r=a.closest("tr");r.length?(o=r.prev("tr").attr("id").replace("msg-",""),i=a.closest("td")):(r=a.closest(".flagged-message"),o=r.data("message_id"),i=a.parent());var s=a.hasClass("reflag")?"flag":a.hasClass("counterflag")?"counter-flag":"meh-flag";if(!t||"meh-flag"==s||confirm("Please note that since you're a moderator, your vote is binding. Continue?")){var c=$("").attr("src",IMAGE("progress-dots.gif")).appendTo(i),l=function(t){if("ok"==t)r.fadeOut(function(){$(this).remove()});else{var n=t||GENERIC_ERROR;e&&n&&e(n),c.remove()}},u=function(t){c.remove(),e&&e(t)};messageActionById(o,s,null,l,u)}}),BindFlagListPopup("#flag-count, .global-flags:not(.mod-flag)","/admin/flagged?json=true&show=new","/admin/flagged?show=all",e,o),BindFlagListPopup("#modflag-count, .global-flags.mod-flag","/admin/flagged-moderator?json=true","/admin/flagged-moderator",e),t&&n()},t};$.fn.fadeOutAndRemove=function(){return this.each(function(){var e=$(this);e.fadeOut("fast",function(){e.trigger("removing").remove()})})},GENERIC_ERROR="An error occurred performing this action",$(function(){function e(e,n,i){return t.is(":empty")?(t.html(e),t.append($("").find("button").text(n||"Ok").data("set-pref",i||-1).end()),void 0):(queue.push(Array.prototype.slice.call(arguments)),void 0)
}CHAT.inputHint={"show":e};var t=$(".input-hint");queue=[],"absolute"!=t.css("position")&&t.remove(),t.on("click",".dismiss-input-hint",function(){var n=parseInt($(this).data("set-pref"),10);t.empty(),queue.length&&e.apply(null,queue.shift()),n>0&&$.post("/users/set-pref/"+n,fkey())})}),$(function(){var e=function(e){$.post("/mobile/"+e).done(function(){window.location.reload(!0)})};window.CHAT.switchMobile=e,$(".mobile-on").click(function(){return e("on"),!1}),$(".mobile-off").click(function(){return e("off"),!1})}),function(e){e.fn.extend({"autocomplete":function(t,n){var i="string"==typeof t;return n=e.extend({},e.Autocompleter.defaults,{"url":i?t:null,"data":i?null:t,"delay":i?e.Autocompleter.defaults.delay:10,"max":n&&!n.scroll?10:150,"noRecord":"No Records."},n),n.highlight=n.highlight||function(e){return e},n.formatMatch=n.formatMatch||n.formatItem,this.each(function(){new e.Autocompleter(this,n)})},"result":function(e){return this.bind("result",e)},"search":function(e){return this.trigger("search",[e])},"flushCache":function(){return this.trigger("flushCache")},"setOptions":function(e){return this.trigger("setOptions",[e])},"unautocomplete":function(){return this.trigger("unautocomplete")}}),e.Autocompleter=function(t,n){function i(){var i=T.selected();if(!i)return!1;var o=i.result;if(w=o,n.multiple){var r=a(y.val());if(r.length>1){var s,c=n.multipleSeparator.length,u=e(t).selection().start,d=0;e.each(r,function(e,t){return d+=t.length,d>=u?(s=e,!1):(d+=c,void 0)}),r[s]=o,o=r.join(n.multipleSeparator)}o+=n.multipleSeparator}return y.val(o),l(),y.trigger("result",[i.data,i.value]),!0}function o(e,t){if(v==p.DEL)return T.hide(),void 0;var i=y.val();(t||i!=w)&&(w=i,i=r(i),i.length>=n.minChars?(y.addClass(n.loadingClass),n.matchCase||(i=i.toLowerCase()),d(i,u,l)):(h(),T.hide()))}function a(t){return t?n.multiple?e.map(t.split(n.multipleSeparator),function(n){return e.trim(t).length?e.trim(n):null}):[e.trim(t)]:[""]}function r(i){if(!n.multiple)return i;var o=a(i);if(1==o.length)return o[0];var r=e(t).selection().start;return o=r==i.length?a(i):a(i.replace(i.substring(r),"")),o[o.length-1]}function s(i,o){n.autoFill&&r(y.val()).toLowerCase()==i.toLowerCase()&&v!=p.BACKSPACE&&(y.val(y.val()+o.substring(r(w).length)),e(t).selection(w.length,w.length+o.length))}function c(){clearTimeout(g),g=setTimeout(l,200)}function l(){T.visible();T.hide(),clearTimeout(g),h(),n.mustMatch&&y.search(function(e){if(!e)if(n.multiple){var t=a(y.val()).slice(0,-1);y.val(t.join(n.multipleSeparator)+(t.length?n.multipleSeparator:""))}else y.val(""),y.trigger("result",null)})}function u(e,t){t&&t.length&&C?(h(),T.display(t,e),s(e,t[0].value),T.show()):l()}function d(i,o,a){n.matchCase||(i=i.toLowerCase());var s=b.load(i);if(s)if(s.length)o(i,s);else{var c=n.parse&&n.parse(n.noRecord)||f(n.noRecord);o(i,c)}else if("string"==typeof n.url&&n.url.length>0){var l={"timestamp":+new Date};e.each(n.extraParams,function(e,t){l[e]="function"==typeof t?t():t}),e.ajax({"mode":"abort","port":"autocomplete"+t.name,"dataType":n.dataType,"url":n.url,"data":e.extend({"q":r(i),"limit":n.max},l),"success":function(e){var t=n.parse&&n.parse(e)||f(e);b.add(i,t),o(i,t)}})}else T.emptyList(),null!=m?m():a(i)}function f(t){for(var i=[],o=t.split("\n"),a=0;a1&&!T.visible()&&o(0,!0)}).bind("search",function(){function t(e,t){var i;if(t&&t.length)for(var o=0;o1?arguments[1]:null;e.each(a(y.val()),function(e,n){d(n,t,t)})}).bind("flushCache",function(){b.flush()}).bind("setOptions",function(){e.extend(!0,n,arguments[1]),"data"in arguments[1]&&b.populate()}).bind("unautocomplete",function(){T.unbind(),y.unbind(),e(t.form).unbind(".autocomplete")})},e.Autocompleter.defaults={"inputClass":"ac_input","resultsClass":"ac_results","loadingClass":"ac_loading","minChars":1,"delay":400,"matchCase":!1,"matchSubset":!0,"matchContains":!1,"cacheLength":100,"max":1e3,"mustMatch":!1,"extraParams":{},"selectFirst":!0,"formatItem":function(e){return e[0]},"formatMatch":null,"autoFill":!1,"width":0,"multiple":!1,"multipleSeparator":" ","inputFocus":!0,"clickFire":!1,"highlight":function(e,t){return e.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)("+t.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi,"\\$1")+")(?![^<>]*>)(?![^&;]+;)","gi"),"$1")},"scroll":!0,"scrollHeight":180,"scrollJumpPosition":!0},e.Autocompleter.Cache=function(t){function n(e,n){t.matchCase||(e=e.toLowerCase());var i=e.indexOf(n);return"word"==t.matchContains&&(i=e.toLowerCase().search("\\b"+n.toLowerCase())),-1==i?!1:0==i||t.matchContains}function i(e,n){s>t.cacheLength&&a(),r[e]||s++,r[e]=n}function o(){if(!t.data)return!1;var n={},o=0;t.url||(t.cacheLength=1),n[""]=[];for(var a=0,r=t.data.length;r>a;a++){var s=t.data[a];s="string"==typeof s?[s]:s;var c=t.formatMatch(s,a+1,t.data.length);if("undefined"!=typeof c&&c!==!1){var l=c.charAt(0).toLowerCase();n[l]||(n[l]=[]);var u={"value":c,"data":s,"result":t.formatResult&&t.formatResult(s)||c};n[l].push(u),o++0){var c=r[a];e.each(c,function(e,t){n(t.value,i)&&o.push(t)})}return o}if(r[i])return r[i];if(t.matchSubset)for(var l=i.length-1;l>=t.minChars;l--){var c=r[i.substr(0,l)];if(c){var o=[];return e.each(c,function(e,t){n(t.value,i)&&(o[o.length]=t)}),o}}return null}}},e.Autocompleter.Select=function(t,n,i,o){function a(){$&&(h=e("").hide().addClass(t.resultsClass).css("position","absolute").appendTo(document.body).hover(function(){e(this).is(":visible")&&n.focus(),o.mouseDownOnSelect=!1}),p=e("