/*! Copyright: InteRiders <http://interiders.com/> - Distributed under MIT - Keep this message! */
var ResizableTextbox=Class.create({options:$H({minWidth:72,maxWidth:500,step:12}),initialize:function(d,b){var e=this;this.options.update(b);this.el=$(d);this.width=this.el.offsetWidth;this.el.observe(Prototype.Browser.IE?"keydown":"keypress",function(){var f=e.options.get("step")*$F(this).length;
if(f<e.options.get("minWidth")){f=e.options.get("minWidth")}if(f>e.options.get("maxWidth")){f=e.options.get("maxWidth")}this.setStyle({width:f+"px"})}).observe("keydown",function(){this.cacheData("rt-value",$F(this).length)})}});var TextboxList=Class.create({options:$H({resizable:{},className:"bit",separator:"###",extrainputs:true,startinput:true,hideempty:true,fetchFile:undefined,results:10,wordMatch:false}),initialize:function(d,b){this.options.update(b);
this.element=$(d).hide();this.bits=new Hash();this.events=new Hash();this.count=0;this.current=false;this.maininput=this.createInput({"class":"maininput"});this.holder=new Element("ul",{"class":"tbl-holder"}).insert(this.maininput);this.element.insert({before:this.holder});this.holder.observe("click",function(e){e.stop();
if(this.maininput!=this.current){this.focus(this.maininput)}}.bind(this));this.makeResizable(this.maininput);this.setEvents()},setEvents:function(){document.observe(Prototype.Browser.IE?"keydown":"keypress",function(b){if(!this.current){return}if(this.current.retrieveData("type")=="box"&&b.keyCode==Event.KEY_BACKSPACE){b.stop()
}}.bind(this));document.observe("keyup",function(b){b.stop();if(!this.current){return}switch(b.keyCode){case Event.KEY_LEFT:return this.move("left");case Event.KEY_RIGHT:return this.move("right");case Event.KEY_DELETE:case Event.KEY_BACKSPACE:return this.moveDispose()}}.bind(this)).observe("click",function(){document.fire("blur")
}.bindAsEventListener(this))},update:function(){this.element.value=this.bits.values().join(this.options.get("separator"));return this},add:function(e,b){var f=this.options.get("className")+"-"+this.count++;var d=this.createBox($pick(b,e),{id:f});(this.current||this.maininput).insert({before:d});d.observe("click",function(g){g.stop();
this.focus(d)}.bind(this));this.bits.set(f,e.id);if(this.options.get("extrainputs")&&(this.options.get("startinput")||d.previous())){this.addSmallInput(d,"before")}return d},addSmallInput:function(e,d){var b=this.createInput({"class":"smallinput"});e.insert({}[d]=b);b.cacheData("small",true);this.makeResizable(b);
if(this.options.get("hideempty")){b.hide()}return b},dispose:function(b){this.bits.unset(b.id);if(b.previous()&&b.previous().retrieveData("small")){b.previous().remove()}if(this.current==b){this.focus(b.next())}b.remove();return this},focus:function(d,b){if(!this.current){d.fire("focus")}else{if(this.current==d){return this
}}this.blur();d.addClassName(this.options.get("className")+"-"+d.retrieveData("type")+"-focus");if(d.retrieveData("small")){d.setStyle({display:"block"})}if(d.retrieveData("type")=="input"){if(!!this.options.get("onInputFocus")){this.options.get("onInputFocus")(this)}if(!b){this.callEvent(d.retrieveData("input"),"focus")
}}else{d.fire("onBoxFocus")}this.current=d;return this},blur:function(d){if(!this.current){return this}if(this.current.retrieveData("type")=="input"){var b=this.current.retrieveData("input");if(!d){this.callEvent(b,"blur")}if(!!this.options.get("onInputBlur")){this.options.get("onInputBlur")(this)}}else{this.current.fire("onBoxBlur")
}if(this.current.retrieveData("small")&&!b.get("value")&&this.options.get("hideempty")){this.current.hide()}this.current.removeClassName(this.options.get("className")+"-"+this.current.retrieveData("type")+"-focus");this.current=false;return this},createBox:function(d,b){return new Element("li",b).addClassName(this.options.get("className")+"-box").update(d).cacheData("type","box")
},createInput:function(d){var b=new Element("li",{"class":this.options.get("className")+"-input"});var f=new Element("input",Object.extend(d,{type:"text"}));f.setAttribute("autocomplete","off");if(!!this.options.get("maxLength")){f.setAttribute("maxlength",this.options.get("maxLength"))}f.observe("click",function(g){g.stop()
}).observe("focus",function(g){if(!this.isSelfEvent("focus")){this.focus(b,true)}}.bind(this)).observe("blur",function(){if(!this.isSelfEvent("blur")){this.blur(true)}}.bind(this)).observe("keydown",function(g){this.cacheData("lastvalue",this.value).cacheData("lastcaret",this.getCaretPosition())});var e=b.cacheData("type","input").cacheData("input",f).insert(f);
return e},callEvent:function(d,b){this.events.set(b,d);d[b]()},isSelfEvent:function(b){return(this.events.get(b))?!!this.events.unset(b):false},makeResizable:function(b){var d=b.retrieveData("input");d.cacheData("resizable",new ResizableTextbox(d,Object.extend(this.options.get("resizable"))));return this
},checkInput:function(){var b=this.current.retrieveData("input");return(!b.retrieveData("lastvalue")||(b.getCaretPosition()===0&&b.retrieveData("lastcaret")===0))},move:function(d){var b=this.current[(d=="left"?"previous":"next")]();if(b&&(!this.current.retrieveData("input")||((this.checkInput()||d=="right")))){this.focus(b)
}return this},moveDispose:function(){if(this.current.retrieveData("type")=="box"){return this.dispose(this.current)}if(this.checkInput()&&this.bits.keys().length&&this.current.previous()){return this.focus(this.current.previous())}},clear:function(){this.bits.keys().each(function(b){this.dispose($(b))
}.bind(this))}});Element.addMethods({getCaretPosition:function(){if(this.createTextRange){var b=document.selection.createRange().duplicate();b.moveEnd("character",this.value.length);if(b.text===""){return this.value.length}return this.value.lastIndexOf(b.text)}else{return this.selectionStart}},cacheData:function(d,b,e){if(Object.isUndefined(this[$(d).identify()])||!Object.isHash(this[$(d).identify()])){this[$(d).identify()]=$H()
}this[$(d).identify()].set(b,e);return d},retrieveData:function(d,b){return this[$(d).identify()].get(b)},filter:function(e,d){var f=[];for(var g=0,b=this.length;g<b;g++){if(e.call(d,this[g],g,this)){f.push(this[g])}}return f}});function $pick(){for(var d=0,b=arguments.length;d<b;d++){if(!Object.isUndefined(arguments[d])){return arguments[d]
}}return null}var LinkTool=Class.create();LinkTool.prototype={initialize:function(b,d){this.elements=Object.extend({button:$("linktool-find"),input:$("linktool-query"),results:$("linktool-results"),scopeButtons:$$(".linktool-scope")},d||{});this.textarea=b;this.elements.results.hide();Event.observe(this.elements.button,"click",this.search.bind(this));
Event.observe(this.elements.input,Prototype.Browser.IE?"keydown":"keypress",function(f){if(f.keyCode==Event.KEY_RETURN){this.search(f)}}.bind(this));Event.observe(this.elements.results,"click",function(g){var f=g.findElement("a");if(f&&f.hasClassName("linktool-result")){g.stop();this.addLink(f.readAttribute("type"),f.readAttribute("value"),f.readAttribute("title"))
}}.bind(this));this.elements.scopeButtons.invoke("observe","click",function(f){if(!!$F(this.elements.input)&&this.elements.results.visible()){this.search()}}.bind(this))},addLink:function(b,d,e){if(!this.textarea.getSelection()||this.textarea.getSelection()==""){this.textarea.replaceSelection("["+b+"="+d+"]"+e+"[/"+b+"]")
}else{this.textarea.wrapSelection("["+b+"="+d+"]","[/"+b+"]")}this.elements.results.hide()},search:function(f){if(!!f){Event.stop(f)}this.elements.results.setStyle({display:"block"});var d=$F(this.elements.input);if(!!d){this.elements.input.removeClassName("error");this.elements.results.wait();var b=1;
this.elements.scopeButtons.each(function(e){if(e.checked){b=e.value}});new Ajax.Updater(this.elements.results,habboReqPath+"/myhabbo/linktool/search",{method:"get",parameters:{query:d,scope:b}})}else{this.elements.input.addClassName("error")}}};var AutocompleteList=Class.create(TextboxList,{loptions:$H({autocomplete:{maxresults:10,minchars:1}}),initialize:function($super,e,g,b,f){$super(e,b);
this.data=b.data;this.autoholder=$(g);this.autoholder.observe("mouseover",function(){this.curOn=true}.bind(this)).observe("mouseout",function(){this.curOn=false}.bind(this));this.autoresults=this.autoholder.select("ul").first();var d=this.autoresults.select("li");d.each(function(h){this.add({id:h.readAttribute("value"),name:h.innerHTML})
},this)},autoShow:function(d,g){var e=0;if(!!g||(!!d&&!!d.strip()&&!!d.length&&d.length>=this.loptions.get("autocomplete").minchars)){this.resultsshown=true;this.hideInstructions();this.autoresults.show();this.autoresults.update("");var f=new RegExp(d,"i");var b=this.bits.values();this.data.filter(function(h){return b.indexOf(h.id)==-1
}).filter(function(h){if(g){return h}else{return h?f.test(h.name):false}}).each(function(h,j){e++;if(j>=this.loptions.get("autocomplete").maxresults){return}var k=this;var i=new Element("li");if(h.pic){i.setStyle({backgroundImage:"url("+h.pic+")"})}i.observe("click",function(l){l.stop();k.autoAdd(this)
}).observe("mouseover",function(){k.autoFocus(this)}).update(this.autoHighlight(h.name,d));this.autoresults.insert(i);i.cacheData("result",h);if(j==0){this.autoFocus(i)}},this)}if(e==0){this.autoHide();this.showInstructions()}else{if(e>this.options.get("results")){this.autoresults.setStyle({height:(this.options.get("results")*24)+"px"})
}else{this.autoresults.setStyle({height:(e?(e*24):0)+"px"})}}return this},autoHighlight:function(d,b){if(!!b){return d.gsub(new RegExp(b,"i"),function(e){return"<em>"+e[0]+"</em>"})}else{return d}},autoHide:function(){this.resultsshown=false;this.autoresults.hide();return this},autoFocus:function(b){if(!b){return
}if(this.autocurrent){this.autocurrent.removeClassName("auto-focus")}this.autocurrent=b.addClassName("auto-focus");return this},autoMove:function(b){if(!this.resultsshown){return}this.autoFocus(this.autocurrent[(b=="up"?"previous":"next")]());this.autoresults.scrollTop=this.autocurrent.positionedOffset()[1]-this.autocurrent.getHeight();
return this},autoAdd:function(e){var b=e.retrieveData("result");if(!e||!b){return}this.add(b);delete this.data[this.data.indexOf(Object.toJSON(b))];this.autoHide();var d=this.lastinput||this.maininput.retrieveData("input");d.clear().focus();this.showInstructions();return this},createInput:function($super,e){var b=$super(e);
var d=b.retrieveData("input");d.setAttribute("tabindex","1");d.observe("keydown",function(f){this.dosearch=false;switch(f.keyCode){case Event.KEY_UP:f.stop();return this.autoMove("up");case Event.KEY_DOWN:if(this.resultsshown||d.value!=""){f.stop();return this.autoMove("down")}case Event.KEY_TAB:if(!this.resultsshown){break
}case Event.KEY_RETURN:f.stop();if(!this.autocurrent){break}if(this.resultsshown){this.autoAdd(this.autocurrent)}this.autocurrent=false;this.autoenter=true;break;case Event.KEY_ESC:this.autoHide();if(this.current&&this.current.retrieveData("input")){this.current.retrieveData("input").clear()}break;default:this.dosearch=true
}}.bind(this));d.observe("keyup",function(f){switch(f.keyCode){case Event.KEY_UP:case Event.KEY_RETURN:case Event.KEY_ESC:break;case Event.KEY_DOWN:if(!this.resultsshown&&d.value==""){this.autoShow(d.value,true)}break;default:if(this.dosearch){this.autoShow(d.value)}}}.bind(this));d.observe(Prototype.Browser.IE?"keydown":"keypress",function(f){this.autoenter=false
}.bind(this));if(Prototype.Browser.Gecko){new Form.Element.Observer(d,0.2,function(f,g){if(this.dosearch){this.autoShow(d.value)}}.bind(this))}return b},createBox:function($super,e,d){var b=$super(e.name,d);b.observe("mouseover",function(){this.addClassName("bit-hover")}).observe("mouseout",function(){this.removeClassName("bit-hover")
});return b},add:function($super,f,d){var e=$super(f,d);if(f.pic){e.setStyle({backgroundImage:"url("+f.pic+")"})}if(this.options.get("maxRecipients")>0&&this.bits.size()>=this.options.get("maxRecipients")){this.maxRecipientsReached=true;this.hideInstructions();var b=this.lastinput||this.maininput.retrieveData("input");
b.hide();if(!!this.options.get("maxRecipientsReachedCallback")){this.options.get("maxRecipientsReachedCallback")()}}return e},dispose:function($super,d){$super(d);if(this.options.get("maxRecipients")==0||this.bits.size()<this.options.get("maxRecipients")){this.maxRecipientsReached=false;this.showInstructions();
var b=this.lastinput||this.maininput.retrieveData("input");b.show()}},showInstructions:function(){if(!this.maxRecipientsReached){this.autoholder.select(".default").first().show()}},hideInstructions:function(){this.autoholder.select(".default").first().hide()}});if(typeof(Object.Event)=="undefined"){Object.Event={eventHandlers:{},observe:function(d,b){if(!this.eventHandlers[d]){this.eventHandlers[d]=$A([])
}this.eventHandlers[d].push(b)},stopObserving:function(d,b){this.eventHandlers[d]=this.eventHandlers[d].without(b)},fireEvent:function(b){if(this.eventHandlers[b]){this.eventHandlers[b].each(function(d){d(this)}.bind(this))}}};Object.Event.createEvent=Object.Event.fireEvent}if(typeof(Control)=="undefined"){Control={}
}Control.TextArea=Class.create();Object.extend(Control.TextArea.prototype,Object.Event);Object.extend(Control.TextArea.prototype,{onChangeTimeoutLength:500,textarea:false,onChangeTimeout:false,initialize:function(b){this.textarea=$(b);$(this.textarea).observe("keyup",this.doOnChange.bindAsEventListener(this));
$(this.textarea).observe("paste",this.doOnChange.bindAsEventListener(this));$(this.textarea).observe("input",this.doOnChange.bindAsEventListener(this))},doOnChange:function(b){if(this.onChangeTimeout){window.clearTimeout(this.onChangeTimeout)}this.onChangeTimeout=window.setTimeout(function(){this.createEvent("change")
}.bind(this),this.onChangeTimeoutLength)},getValue:function(){return this.textarea.value},getSelection:function(){if(typeof(document.selection)!="undefined"){return document.selection.createRange().text}else{if(typeof(this.textarea.setSelectionRange)!="undefined"){return this.textarea.value.substring(this.textarea.selectionStart,this.textarea.selectionEnd)
}else{return false}}},replaceSelection:function(d){if(typeof(document.selection)!="undefined"){this.textarea.focus();var b=document.selection.createRange();b.text=d;b.collapse(false);b.select()}else{if(typeof(this.textarea.setSelectionRange)!="undefined"){selection_start=this.textarea.selectionStart;
this.textarea.value=this.textarea.value.substring(0,selection_start)+d+this.textarea.value.substring(this.textarea.selectionEnd);this.textarea.setSelectionRange(selection_start+d.length,selection_start+d.length)}}this.doOnChange();this.textarea.focus()},wrapSelection:function(b,d){this.replaceSelection(b+this.getSelection()+d)
},insertBeforeSelection:function(b){this.replaceSelection(b+this.getSelection())},insertAfterSelection:function(b){this.replaceSelection(this.getSelection()+b)},injectEachSelectedLine:function(e,b,d){this.replaceSelection((b||"")+$A(this.getSelection().split("\n")).inject([],e).join("\n")+(d||""))},insertBeforeEachSelectedLine:function(e,b,d){this.injectEachSelectedLine(function(g,f){g.push(e+f);
return g},b,d)}});Control.TextArea.ToolBar=Class.create();Object.extend(Control.TextArea.ToolBar.prototype,{textarea:false,toolbar:false,initialize:function(b,d){this.textarea=b;if(d){this.toolbar=$(d)}else{this.toolbar=$(document.createElement("ul"));this.textarea.textarea.parentNode.insertBefore(this.toolbar,this.textarea.textarea)
}},attachButton:function(b,d){b.onclick=function(){return false};$(b).observe("click",d.bindAsEventListener(this.textarea))},addButton:function(b,e,d){c=document.createElement("li");c.className="control-button";link=document.createElement("a");link.href="#";this.attachButton(link,e);c.appendChild(link);
if(d){for(a in d){link[a]=d[a]}}if(b){span=document.createElement("span");span.innerHTML=b;link.appendChild(span)}this.toolbar.appendChild(c)}});Control.TextArea.ToolBar.BBCode=Class.create();Object.extend(Control.TextArea.ToolBar.BBCode.prototype,{textarea:false,toolbar:false,options:{preview:false},initialize:function(b,d){this.textarea=new Control.TextArea(b);
this.toolbar=new Control.TextArea.ToolBar(this.textarea);this.toolbar.toolbar.addClassName("bbcode_toolbar");if(d){for(o in d){this.options[o]=d[o]}}this.toolbar.addButton("Bold",function(){this.wrapSelection("[b]","[/b]")},{id:"bbcode_bold_button"});this.toolbar.addButton("Italics",function(){this.wrapSelection("[i]","[/i]")
},{id:"bbcode_italics_button"});this.toolbar.addButton("Underline",function(){this.wrapSelection("[u]","[/u]")},{id:"bbcode_underline_button"});this.toolbar.addButton("Quote",function(){this.wrapSelection("[quote]","[/quote]")},{id:"bbcode_quote_button"});this.toolbar.addButton("Small size",function(){this.wrapSelection("[size=small]","[/size]")
},{id:"bbcode_smallsize_button"});this.toolbar.addButton("Large size",function(){this.wrapSelection("[size=large]","[/size]")},{id:"bbcode_largesize_button"});this.toolbar.addButton("Code",function(){this.wrapSelection("[code]","[/code]")},{id:"bbcode_code_button"});this.toolbar.addButton("Link",function(){var f=this.getSelection();
var g=f;var h="http://";var e=f.match(/^\s*(\w+:\/*)?([^\(\)\?&"'\s]*)([^:\(\)"'\s]*).*/);if(e!=null){f=e[2]+e[3];g=e[2];if(f.search(/\./)==-1){h="";f=e[2]}f=f.replace(/\[.*?\]/g,"")}this.replaceSelection("[url="+h+f+"]"+g+"[/url]")},{id:"bbcode_link_button"})},addColorSelect:function(i,e,g){var d=document.createElement("select");
if(g){var j=170;if(navigator.appVersion.match(/\bMSIE\b/)){j+=4}d.style.width=(Element.getDimensions(this.textarea.textarea).width-j-3)+"px"}Event.observe(d,"change",function(l){Event.stop(l);if(d.selectedIndex==0){return}var k=Event.element(l).value;d.selectedIndex=0;this.textarea.wrapSelection("[color="+k+"]","[/color]")
}.bind(this));var h=document.createElement("option");h.innerHTML=i;d.appendChild(h);d.selectedIndex=0;for(var f in e){h=document.createElement("option");h.innerHTML=e[f][1];h.style.color=e[f][0];h.value=f;d.appendChild(h)}var b=new Element("li",{className:"control-button"});b.appendChild(d);this.toolbar.toolbar.appendChild(b)
},addHabboLinkTools:function(){var b=new Element("li",{className:"linktools"});var d=new Element("div");d.insert(L10N.get("linktool.find.label")+" ");var f=function(i,l,k){var j={name:"linktool-scope",type:"radio",value:l};if(k){j.checked="checked"}d.appendChild(new Element("input",j));d.insert(i+" ")
};f(L10N.get("linktool.scope.habbos"),1,true);f(L10N.get("linktool.scope.rooms"),2);f(L10N.get("linktool.scope.groups"),3);var e=new Element("input",{name:"linktool-query",type:"text",size:20});d.appendChild(e);b.appendChild(d);b.insert(" ");var h=new Element("a",{href:"#",className:"new-button search-icon"});
h.appendChild(new Element("b")).appendChild(new Element("span"));h.appendChild(new Element("i"));b.appendChild(h);var g=new Element("div",{className:"linktool-results"});b.appendChild(g);new LinkTool(this.textarea,{button:h,input:e,results:g,scopeButtons:b.select('input[name="linktool-scope"]')});this.toolbar.toolbar.appendChild(b)
}});var MiniMail=Class.create();MiniMail.prototype={initialize:function(i){var B=this;var n={pageSize:3,start:0,total:0,bodyMaxLength:4096,label:"inbox",conversationId:null,unreadOnly:false,nextPage:function(){B.options.start+=B.options.pageSize;if(B.options.start>B.options.total){B.options.lastPage()
}},prevPage:function(){B.options.start-=B.options.pageSize;if(B.options.start<0){B.options.start=0}},firstPage:function(){B.options.start=0},lastPage:function(){B.options.start=B.options.total-B.options.total%B.options.pageSize-(B.options.total%B.options.pageSize==0?B.options.pageSize:0)},reset:function(){B.options.start=0;
B.options.unreadOnly=false}};B.options=Object.extend(n,i||{});B.element=$("minimail");B.updateTarget=B.element.down(".minimail-contents");$("message-compose").observe("submit",Event.stop);var u=function(I){return $(I).up(".message-item").id.substring(4)};var h=function(I){B.updateTarget.setStyle({visibility:"hidden"});
C(I,"error",20000)};var l=function(I,K){var J=function(L,M){return function(O,N){if(403==O.status){h(O.responseText);return}if(N&&(!!N.errorMessage||!!N.subjectError||!!N.bodyError)){if(!!$("message-subject")){if(!!N.subjectError){$("message-subject").addClassName("error")}else{$("message-subject").removeClassName("error")
}}if(!!$("message-body")){if(!!N.bodyError){$("message-body").addClassName("error")}else{$("message-body").removeClassName("error")}}C([N.errorMessage||null,N.subjectError||null,N.bodyError||null].compact().join("<br />"),"error");B.updateTarget.select(".navigation .progress").invoke("update","");if(typeof M=="function"){M()
}return}$("message-compose").hide();B.updateTarget.update(O.responseText);B.updateTarget.select(".navigation .progress").invoke("update","");if(N){B.options.total=N.totalMessages}if(typeof L=="function"){L()}if(N&&N.message){C(N.message)}Rounder.init()}};K.onComplete=J(K.onComplete,K.onError);B.updateTarget.select(".navigation .progress").each(Element.wait);
new Ajax.Request(I,K)};var G=function(I){B.options.label=I;B.options.reset();l("/minimail/loadMessages",{parameters:{label:B.options.label}})};var E=function(I){I.apply(this);l("/minimail/loadMessages",{parameters:{label:B.options.label,start:B.options.start,conversationId:B.options.conversationId,unreadOnly:B.options.unreadOnly}})
};var w=function(){var M=$("message-subject");var L=$("message-body");var J=function(N,O){if(!N(O)){O.addClassName("error");return false}else{O.removeClassName("error")}return true};var K=J(function(N){return B.recipientInput.bits.size()>0},B.recipientInput.holder);var I=J(function(N){return N.value.length>0
},M);return K&&I&&q(L)};var q=function(I){if(I.value.length==0){return confirm(L10N.get("minimail.empty_body.confirm"))}return true};var A=function(I){var K=B.recipientInput.bits.values().join(",");if(!w()){return}var L=$("message-subject");var J=$("message-body");l("/minimail/sendMessage",{parameters:{recipientIds:K,subject:L.value,body:J.value},onComplete:B.options.reset})
};var r=[];var D=function(I,K){var J=$("msg-"+K);$(I).next().toggle();if($(I).next().visible()){var L=J.down("div.message-body").down("div");Element.wait(L);new Ajax.Request("/minimail/loadMessage",{method:"get",parameters:{messageId:K,label:B.options.label},onComplete:function(N,M){if(N.status==403){h(N.responseText);
return}L.update(N.responseText)}});J.addClassName("opened");if(J.hasClassName("unread")){$(J).down(".message-preview").morph("background-color: #DCDCDC",{duration:4});$(J).down(".message-body").morph("background-color: #DCDCDC",{duration:4});$(J).down(".message-body-bottom").morph("background-color: #DCDCDC",{duration:4})
}}else{J.removeClassName("opened");J.removeClassName("unread").addClassName("read")}if($("msg-"+K).visible()&&$(I).getAttribute("status")=="unread"&&r.indexOf(K)==-1){r.push(K);$$(".minimail-unread").each(function(M){var N=parseInt(M.down("b").innerHTML);N--;if(N>0){M.down("b").update(N)}else{M.remove()
}})}};var b=function(L,J){var K=$(L).up(2).next("div");var I=K.down("textarea");v(I);Utils.limitTextarea(I,B.options.bodyMaxLength);$(L).up(2).hide();K.show();$(I).focus();$(L).up(".contents").addClassName("replying")};var v=function(J){if(!J.hasClassName("bbcode-enabled")){var K=new Control.TextArea.ToolBar.BBCode(J);
var I={red:["#d80000",L10N.get("bbcode.colors.red")],orange:["#fe6301",L10N.get("bbcode.colors.orange")],yellow:["#ffce00",L10N.get("bbcode.colors.yellow")],green:["#6cc800",L10N.get("bbcode.colors.green")],cyan:["#00c6c4",L10N.get("bbcode.colors.cyan")],blue:["#0070d7",L10N.get("bbcode.colors.blue")],gray:["#828282",L10N.get("bbcode.colors.gray")],black:["#000000",L10N.get("bbcode.colors.black")]};
K.addColorSelect(L10N.get("bbcode.colors.label"),I,false);K.addHabboLinkTools();J.addClassName("bbcode-enabled")}};var t=function(I){$(I).up(2).hide();$(I).up(2).previous("div").show();$(I).up(".contents").removeClassName("replying")};var f=function(K,J){var I=$(K).up(2).down("textarea");if(q(I)){l("/minimail/sendMessage",{parameters:{messageId:J,body:I.value},onComplete:B.options.reset})
}};var F=function(I,J){var J=J||u(I);$(I).up(3).remove();if(B.options.total-B.options.start==1){B.options.prevPage()}l("/minimail/deleteMessage",{parameters:{messageId:J,start:B.options.start,label:B.options.label,conversationId:B.options.conversationId}})};var m=function(I,J){var J=J||u(I);$(I).up(3).remove();
if(B.options.total-B.options.start==1){B.options.prevPage()}l("/minimail/undeleteMessage",{parameters:{messageId:J,start:B.options.start,label:B.options.label}})};var j={loading:false,loaded:false};var z=function(I,J){$("message-list").hide();$(I).update(L10N.get("minimail.cancel"));if(B.options.friendCount==0){$("message-compose").show();
return}if(!!Cookie.get("friendlist")){Cookie.erase("friendlist");j.loaded=false}if(!j.loaded&&!j.loading){var K=$("message-compose-wait");K.wait();K.setStyle({height:$("message-list").getHeight()+"px"});v($("message-compose").down("textarea"));g(function(){K.hide();Utils.limitTextarea("message-body",B.options.bodyMaxLength);
d(J)})}else{d(J)}};var e=function(I){$("message-compose").hide();$("message-list").show();$(I).update(L10N.get("minimail.compose"));if(!!B.recipientInput){B.recipientInput.hideInstructions();B.recipientInput.clear()}};var d=function(J){if(!!J){J.split(",").each(function(N){var M=B.recipientInput.bits.values();
var L=B.recipientInput.data.find(function(O){return O.id==N&&M.indexOf(parseInt(N))<0});if(!!L){B.recipientInput.add(L)}})}var K=$("message-subject");var I=$("message-body");K.removeClassName("error");K.value="";I.removeClassName("error");I.value="";$("message-compose").select(".preview-area-container").invoke("remove");
$("message-compose").show();if(!J){B.recipientInput.clear()}};var g=function(I){j.loading=true;new Ajax.Request("/minimail/recipients",{method:"get",onComplete:function(J){if(J.status==403){h(J.responseText);return}j.loading=false;if(!B.recipientInput){B.recipientInput=new AutocompleteList("message-recipients","message-recipients-auto",{data:J.responseText.evalJSON(true),maxLength:32,maxRecipients:B.options.maxRecipients||10,maxRecipientsReachedCallback:function(){$("message-subject").focus()
},onInputFocus:function(K){K.autoShow()},onInputBlur:function(K){(K.lastinput||K.maininput.retrieveData("input")).clear();K.hideInstructions()}})}else{B.recipientInput.data=J.responseText.evalJSON(true)}j.loaded=true;if(!!I){I()}}})};var x=function(J,I,K){B.options.label="conversation";B.options.conversationId=K;
B.options.reset();l("/minimail/loadMessages",{parameters:{label:B.options.label,messageId:I,conversationId:K}})};var H=function(){B.updateTarget.select(".navigation .progress").each(Element.wait);l("/minimail/emptyTrash",{})};var C=function(M,L,I){var K="notification "+(L||"");var J=new Element("div",{className:K});
J.update(M);$("minimail").appendChild(J);var N=window.setTimeout(function(){Effect.Fade(J,{afterFinish:function(){try{J.remove()}catch(O){}}})},I||2000);J.observe("click",function(O){window.clearTimeout(N);J.remove()})};var y=function(J,L){Overlay.show();var K=function(){if(!!$("minimail-report")){$("minimail-report").remove()
}Overlay.hide()};var M=function(){K();if(j.loaded){g()}};var I=Dialog.createDialog("minimail-report",L10N.get("minimail.report.title"),false,false,false,K);Dialog.moveDialogToCenter(I);Dialog.setAsWaitDialog(I);I.observe("click",Event.delegate({"a.cancel-report > *":function(N){Event.stop(N);K()},"a.send-report > *":function(N){Event.stop(N);
Dialog.setAsWaitDialog(I);l("/minimail/report",{parameters:{messageId:L,start:B.options.start,label:B.options.label},onComplete:M,onError:M})}}));new Ajax.Request("/minimail/confirmReport",{parameters:{messageId:L},onComplete:function(N){Dialog.setDialogBody(I,N.responseText)}})};var s=function(K){var L=K.up(2);
var I=L.down("textarea");var M;var J=L.select(".preview-area");if(J.size()>0){M=J.first()}else{M=new Element("div",{className:"preview-area"});L.insert(M)}M.wait();new Ajax.Request("/minimail/preview",{parameters:{body:I.value},onComplete:function(N){M.update(N.responseText);if(!M.hasClassName("rounded-done")){Rounder.addCorners(M,4,4,"preview-area-container")
}}})};var p=function(I){if(!!window.HabbletLoader){HabbletLoader.openLink(I)}else{window.location.href=I.href}};Event.observe(B.element,"click",Event.delegate({".labels a":function(I){Event.stop(I);G(Event.element(I).getAttribute("label"))},".labels a *":function(I){Event.stop(I);G(Event.element(I).up("*[label]").getAttribute("label"))
},".compose > *":function(I){Event.stop(I);if($("message-compose").visible()){e(Event.element(I))}else{z(Event.element(I))}},".message-preview":function(I){Event.stop(I);D(Event.element(I),u(Event.element(I)))},".message-preview > *":function(I){Event.stop(I);D(Event.element(I).up(),u(Event.element(I)))
},".navigation .oldest":function(I){Event.stop(I);E(B.options.lastPage)},".navigation .older":function(I){Event.stop(I);E(B.options.nextPage)},".navigation .newest":function(I){Event.stop(I);E(B.options.firstPage)},".navigation .newer":function(I){Event.stop(I);E(B.options.prevPage)},".related-messages":function(I){Event.stop(I);
x(this,u(Event.element(I)),Event.element(I).id.substring(4))},".send > *":function(I){Event.stop(I);A(Event.element(I))},".reply > *":function(I){Event.stop(I);b(this,u(Event.element(I)))},".delete > *":function(I){Event.stop(I);F(this,u(Event.element(I)))},".undelete > *":function(I){Event.stop(I);m(this,u(Event.element(I)))
},".send-reply > *":function(I){Event.stop(I);f(this,u(Event.element(I)))},".cancel-reply > *":function(I){Event.stop(I);t(this)},".unread-only":function(I){B.options.unreadOnly=Event.element(I).checked;l("/minimail/loadMessages",{parameters:{label:B.options.label,unreadOnly:B.options.unreadOnly}})},".empty-trash":function(I){Event.stop(I);
H()},".report":function(I){Event.stop(I);y(Event.element(I),u(Event.element(I)))},".preview > *":function(I){Event.stop(I);s(Event.element(I))},"a.bbcode-home-link":function(I){Event.stop(I);p(Event.element(I))},"a.bbcode-home-link *":function(I){Event.stop(I);p(Event.element(I))},"a.bbcode-group-link":function(I){Event.stop(I);
p(Event.element(I))},"a.bbcode-group-link *":function(I){Event.stop(I);p(Event.element(I))},"a.bbcode-url-link":function(I){Event.stop(I);p(Event.element(I))},"a.bbcode-url-link *":function(I){Event.stop(I);p(Event.element(I))}}));var k=function(J){window.focus();B.element.scrollTo();var I=J.split("/");
if(I[1]=="compose"){z(B.element.select(".compose b").first(),I[2])}else{if(I[1]=="inbox"){G("inbox")}}};HashHistory.observe("mail/.*",k);__minimail__sendmsg__=k}};var PrettyDate={};PrettyDate.prettifyDates=function(){var b=function(g){var e=new Date((g||"").replace(/-/g,"/").replace(/[TZ]/g," ")),f=((new Date().getTime()+new Date().getTimezoneOffset()*60000-e.getTime())/1000),d=Math.floor(f/86400);
if(isNaN(d)||d<0||d>=31){return}return d==0&&(f<60&&L10N.get("date.pretty.just_now")||f<120&&L10N.get("date.pretty.one_minute_ago")||f<3600&&L10N.get("date.pretty.minutes_ago",Math.floor(f/60))||f<7200&&L10N.get("date.pretty.one_hour_ago")||f<86400&&L10N.get("date.pretty.hours_ago",Math.floor(f/3600)))||d==1&&L10N.get("date.pretty.yesterday")||d<7&&L10N.get("date.pretty.days_ago",d)||d==7&&L10N.get("date.pretty.one_week_ago")||d<31&&L10N.get("date.pretty.weeks_ago",Math.ceil(d/7))
};$$(".message-tstamp").each(function(e){var f=b(e.getAttribute("isotime"));if(f){e.update(f)}})};HabboView.add(function(){setInterval(PrettyDate.prettifyDates,30000)});__minimail__defined__=true;