var MiniMail=Class.create();MiniMail.prototype={initialize:function(G){var W=this;var K={pageSize:3,start:0,total:0,bodyMaxLength:4096,secondLevel:false,label:"inbox",conversationId:null,unreadOnly:false,nextPage:function(){W.options.start+=W.options.pageSize;if(W.options.start>W.options.total){W.options.lastPage() }},prevPage:function(){W.options.start-=W.options.pageSize;if(W.options.start<0){W.options.start=0}},firstPage:function(){W.options.start=0},lastPage:function(){W.options.start=W.options.total-W.options.total%W.options.pageSize-(W.options.total%W.options.pageSize==0?W.options.pageSize:0)},reset:function(){W.options.start=0; W.options.unreadOnly=false}};W.options=Object.extend(K,G||{});W.element=$("minimail");if(W.options.secondLevel){W.element.addClassName("second-level-auth")}W.updateTarget=W.element.down(".minimail-contents");$("message-compose").observe("submit",Event.stop);var P=function(f){return $(f).up(".message-item").id.substring(4) };var F=function(f){W.updateTarget.setStyle({visibility:"hidden"});X(f,"error",20000)};var I=function(f,h){var g=function(i,j){return function(l,k){if(403==l.status){F(l.responseText);return }if(k&&(!!k.errorMessage||!!k.subjectError||!!k.bodyError)){if(!!$("message-subject")){if(!!k.subjectError){$("message-subject").addClassName("error") }else{$("message-subject").removeClassName("error")}}if(!!$("message-body")){if(!!k.bodyError){$("message-body").addClassName("error")}else{$("message-body").removeClassName("error")}}X([k.errorMessage||null,k.subjectError||null,k.bodyError||null].compact().join("
"),"error");W.updateTarget.select(".navigation .progress").invoke("update",""); if(typeof j=="function"){j()}return }$("message-compose").hide();W.updateTarget.update(l.responseText);W.updateTarget.select(".navigation .progress").invoke("update","");if(k){W.options.total=k.totalMessages}if(typeof i=="function"){i()}if(k&&k.message){X(k.message)}if(W.element.down("div.re-auth")!=null){W.element.addClassName("second-level-auth") }Rounder.init()}};h.onComplete=g(h.onComplete,h.onError);W.updateTarget.select(".navigation .progress").each(Element.wait);new Ajax.Request(f,h)};var d=function(f){W.options.label=f;W.options.reset();I(habboReqPath+"/minimail/loadMessages",{parameters:{label:W.options.label}})};var Z=function(g){g.apply(this);I(habboReqPath+"/minimail/loadMessages",{parameters:{label:W.options.label,start:W.options.start,conversationId:W.options.conversationId,unreadOnly:W.options.unreadOnly}}) };var R=function(){var j=$("message-subject");var i=$("message-body");var g=function(k,l){if(!k(l)){l.addClassName("error");return false}else{l.removeClassName("error")}return true};var h=g(function(k){return W.recipientInput.bits.size()>0},W.recipientInput.holder);var f=g(function(k){return k.value.length>0 },j);return h&&f&&L(i)};var L=function(f){if(f.value.length==0){return confirm(L10N.get("minimail.empty_body.confirm"))}return true};var V=function(f){var h=W.recipientInput.bits.values().join(",");if(!R()){return }var i=$("message-subject");var g=$("message-body");I(habboReqPath+"/minimail/sendMessage",{parameters:{recipientIds:h,subject:i.value,body:g.value},onComplete:W.options.reset}) };var M=[];var Y=function(f,h){var g=$("msg-"+h);$(f).next().toggle();if($(f).next().visible()){var i=g.down("div.message-body").down("div");Element.wait(i);new Ajax.Request(habboReqPath+"/minimail/loadMessage",{method:"get",parameters:{messageId:h,label:W.options.label},onComplete:function(k,j){if(k.status==403){F(k.responseText); return }i.update(k.responseText)}});g.addClassName("opened");if(g.hasClassName("unread")){$(g).down(".message-preview").morph("background-color: #DCDCDC",{duration:4});$(g).down(".message-body").morph("background-color: #DCDCDC",{duration:4});$(g).down(".message-body-bottom").morph("background-color: #DCDCDC",{duration:4}) }}else{g.removeClassName("opened");g.removeClassName("unread").addClassName("read")}if($("msg-"+h).visible()&&$(f).getAttribute("status")=="unread"&&M.indexOf(h)==-1){M.push(h);$$(".minimail-unread").each(function(j){var k=parseInt(j.down("b").innerHTML);k--;if(k>0){j.down("b").update(k)}else{j.remove() }})}};var A=function(i,g){var h=$(i).up(2).next("div");var f=h.down("textarea");Q(f);Utils.limitTextarea(f,W.options.bodyMaxLength);$(i).up(2).hide();h.show();$(f).focus();$(i).up(".contents").addClassName("replying")};var Q=function(g){if(!g.hasClassName("bbcode-enabled")){var h=new Control.TextArea.ToolBar.BBCode(g); var f={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")]}; h.addColorSelect(L10N.get("bbcode.colors.label"),f,false);h.addHabboLinkTools();g.addClassName("bbcode-enabled")}};var O=function(f){$(f).up(2).hide();$(f).up(2).previous("div").show();$(f).up(".contents").removeClassName("replying")};var D=function(h,g){var f=$(h).up(2).down("textarea");if(L(f)){I(habboReqPath+"/minimail/sendMessage",{parameters:{messageId:g,body:f.value},onComplete:W.options.reset}) }};var b=function(f,g){var g=g||P(f);$(f).up(3).remove();if(W.options.total-W.options.start==1){W.options.prevPage()}I(habboReqPath+"/minimail/deleteMessage",{parameters:{messageId:g,start:W.options.start,label:W.options.label,conversationId:W.options.conversationId}})};var J=function(f,g){var g=g||P(f);$(f).up(3).remove(); if(W.options.total-W.options.start==1){W.options.prevPage()}I(habboReqPath+"/minimail/undeleteMessage",{parameters:{messageId:g,start:W.options.start,label:W.options.label}})};var H={loading:false,loaded:false};var U=function(f,g){$("message-list").hide();$(f).update(L10N.get("minimail.cancel"));if(W.options.friendCount==0){$("message-compose").show(); return }if(!!Cookie.get("friendlist")){Cookie.erase("friendlist");H.loaded=false}if(!H.loaded&&!H.loading){var h=$("message-compose-wait");h.wait();h.setStyle({height:$("message-list").getHeight()+"px"});Q($("message-compose").down("textarea"));E(function(){h.hide();Utils.limitTextarea("message-body",W.options.bodyMaxLength); B(g)})}else{B(g)}};var C=function(f){$("message-compose").hide();$("message-list").show();$(f).update(L10N.get("minimail.compose"));if(!!W.recipientInput){W.recipientInput.hideInstructions()}W.recipientInput.clear()};var B=function(g){if(!!g){g.split(",").each(function(k){var j=W.recipientInput.bits.values(); var i=W.recipientInput.data.find(function(l){return l.id==k&&j.indexOf(parseInt(k))<0});if(!!i){W.recipientInput.add(i)}})}var h=$("message-subject");var f=$("message-body");h.removeClassName("error");h.value="";f.removeClassName("error");f.value="";$("message-compose").select(".preview-area-container").invoke("remove"); $("message-compose").show();if(!g){W.recipientInput.clear()}};var E=function(f){H.loading=true;new Ajax.Request(habboReqPath+"/minimail/recipients",{method:"get",onComplete:function(g){if(g.status==403){F(g.responseText);return }H.loading=false;if(!W.recipientInput){W.recipientInput=new AutocompleteList("message-recipients","message-recipients-auto",{data:g.responseText.evalJSON(true),maxLength:32,maxRecipients:W.options.maxRecipients||10,maxRecipientsReachedCallback:function(){$("message-subject").focus() },onInputFocus:function(h){h.autoShow()},onInputBlur:function(h){(h.lastinput||h.maininput.retrieveData("input")).clear();h.hideInstructions()}})}else{W.recipientInput.data=g.responseText.evalJSON(true)}H.loaded=true;if(!!f){f()}}})};var S=function(g,f,h){W.options.label="conversation";W.options.conversationId=h; W.options.reset();I(habboReqPath+"/minimail/loadMessages",{parameters:{label:W.options.label,messageId:f,conversationId:h}})};var e=function(){W.updateTarget.select(".navigation .progress").each(Element.wait);I(habboReqPath+"/minimail/emptyTrash",{})};var X=function(j,i,f){var h="notification "+(i||"");var g=new Element("div",{className:h}); g.update(j);$("minimail").appendChild(g);var k=window.setTimeout(function(){Effect.Fade(g,{afterFinish:function(){try{g.remove()}catch(l){}}})},f||2000);g.observe("click",function(l){window.clearTimeout(k);g.remove()})};var T=function(g,i){Overlay.show();var h=function(){if(!!$("minimail-report")){$("minimail-report").remove() }Overlay.hide()};var j=function(){h();if(H.loaded){E()}};var f=Dialog.createDialog("minimail-report",L10N.get("minimail.report.title"),false,false,false,h);Dialog.moveDialogToCenter(f);Dialog.setAsWaitDialog(f);f.observe("click",Event.delegate({"a.cancel-report > *":function(k){Event.stop(k);h()},"a.send-report > *":function(k){Event.stop(k); Dialog.setAsWaitDialog(f);I(habboReqPath+"/minimail/report",{parameters:{messageId:i,start:W.options.start,label:W.options.label},onComplete:j,onError:j})}}));new Ajax.Request(habboReqPath+"/minimail/confirmReport",{parameters:{messageId:i},onComplete:function(k){Dialog.setDialogBody(f,k.responseText)}})};var N=function(h){var i=h.up(2); var f=i.down("textarea");var j;var g=i.select(".preview-area");if(g.size()>0){j=g.first()}else{j=new Element("div",{className:"preview-area"});i.insert(j)}j.wait();new Ajax.Request(habboReqPath+"/minimail/preview",{parameters:{body:f.value},onComplete:function(k){j.update(k.responseText);if(!j.hasClassName("rounded-done")){Rounder.addCorners(j,4,4,"preview-area-container") }}})};Event.observe(W.element,"click",Event.delegate({".labels a":function(f){Event.stop(f);d(Event.element(f).getAttribute("label"))},".labels a *":function(f){Event.stop(f);d(Event.element(f).up("*[label]").getAttribute("label"))},".compose > *":function(f){Event.stop(f);if($("message-compose").visible()){C(Event.element(f)) }else{U(Event.element(f))}},".message-preview":function(f){Event.stop(f);Y(Event.element(f),P(Event.element(f)))},".message-preview > *":function(f){Event.stop(f);Y(Event.element(f).up(),P(Event.element(f)))},".navigation .oldest":function(f){Event.stop(f);Z(W.options.lastPage)},".navigation .older":function(f){Event.stop(f); Z(W.options.nextPage)},".navigation .newest":function(f){Event.stop(f);Z(W.options.firstPage)},".navigation .newer":function(f){Event.stop(f);Z(W.options.prevPage)},".related-messages":function(f){Event.stop(f);S(this,P(Event.element(f)),Event.element(f).id.substring(4))},".send > *":function(f){Event.stop(f); V(Event.element(f))},".reply > *":function(f){Event.stop(f);A(this,P(Event.element(f)))},".delete > *":function(f){Event.stop(f);b(this,P(Event.element(f)))},".undelete > *":function(f){Event.stop(f);J(this,P(Event.element(f)))},".send-reply > *":function(f){Event.stop(f);D(this,P(Event.element(f)))},".cancel-reply > *":function(f){Event.stop(f); O(this)},".unread-only":function(f){W.options.unreadOnly=Event.element(f).checked;I(habboReqPath+"/minimail/loadMessages",{parameters:{label:W.options.label,unreadOnly:W.options.unreadOnly}})},".empty-trash":function(f){Event.stop(f);e()},".report":function(f){Event.stop(f);T(Event.element(f),P(Event.element(f))) },".preview > *":function(f){Event.stop(f);N(Event.element(f))}}));HashHistory.observe("mail/.*",function(g){window.focus();W.element.scrollTo();var f=g.split("/");if(f[1]=="compose"){U(W.element.select(".compose b").first(),f[2])}else{if(f[1]=="inbox"){d("inbox")}}})}};var PrettyDate={};PrettyDate.prettifyDates=function(){var A=function(E){var C=new Date((E||"").replace(/-/g,"/").replace(/[TZ]/g," ")),D=((new Date().getTime()+new Date().getTimezoneOffset()*60000-C.getTime())/1000),B=Math.floor(D/86400); if(isNaN(B)||B<0||B>=31){return }return B==0&&(D<60&&L10N.get("date.pretty.just_now")||D<120&&L10N.get("date.pretty.one_minute_ago")||D<3600&&L10N.get("date.pretty.minutes_ago",Math.floor(D/60))||D<7200&&L10N.get("date.pretty.one_hour_ago")||D<86400&&L10N.get("date.pretty.hours_ago",Math.floor(D/3600)))||B==1&&L10N.get("date.pretty.yesterday")||B<7&&L10N.get("date.pretty.days_ago",B)||B==7&&L10N.get("date.pretty.one_week_ago")||B<31&&L10N.get("date.pretty.weeks_ago",Math.ceil(B/7)) };$$(".message-tstamp").each(function(B){var C=A(B.getAttribute("isotime"));if(C){B.update(C)}})};HabboView.add(function(){setInterval(PrettyDate.prettifyDates,30000)}); /* Copyright: InteRiders - Distributed under MIT - Keep this message! */ var ResizableTextbox=Class.create({options:$H({minWidth:72,maxWidth:500,step:12}),initialize:function(B,A){var C=this; this.options.update(A);this.el=$(B);this.width=this.el.offsetWidth;this.el.observe(Prototype.Browser.IE?"keydown":"keypress",function(){var D=C.options.get("step")*$F(this).length;if(DC.options.get("maxWidth")){D=C.options.get("maxWidth")}this.setStyle({width:D+"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(B,A){this.options.update(A); this.element=$(B).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(C){C.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(A){if(!this.current){return }if(this.current.retrieveData("type")=="box"&&A.keyCode==Event.KEY_BACKSPACE){A.stop() }}.bind(this));document.observe("keyup",function(A){A.stop();if(!this.current){return }switch(A.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(C,A){var D=this.options.get("className")+"-"+this.count++;var B=this.createBox($pick(A,C),{id:D});(this.current||this.maininput).insert({before:B});B.observe("click",function(E){E.stop(); this.focus(B)}.bind(this));this.bits.set(D,C.id);if(this.options.get("extrainputs")&&(this.options.get("startinput")||B.previous())){this.addSmallInput(B,"before")}return B},addSmallInput:function(C,B){var A=this.createInput({"class":"smallinput"});C.insert({}[B]=A);A.cacheData("small",true);this.makeResizable(A); if(this.options.get("hideempty")){A.hide()}return A},dispose:function(A){this.bits.unset(A.id);if(A.previous()&&A.previous().retrieveData("small")){A.previous().remove()}if(this.current==A){this.focus(A.next())}A.remove();return this},focus:function(B,A){if(!this.current){B.fire("focus")}else{if(this.current==B){return this }}this.blur();B.addClassName(this.options.get("className")+"-"+B.retrieveData("type")+"-focus");if(B.retrieveData("small")){B.setStyle({display:"block"})}if(B.retrieveData("type")=="input"){if(!!this.options.get("onInputFocus")){this.options.get("onInputFocus")(this)}if(!A){this.callEvent(B.retrieveData("input"),"focus") }}else{B.fire("onBoxFocus")}this.current=B;return this},blur:function(B){if(!this.current){return this}if(this.current.retrieveData("type")=="input"){var A=this.current.retrieveData("input");if(!B){this.callEvent(A,"blur")}if(!!this.options.get("onInputBlur")){this.options.get("onInputBlur")(this)}}else{this.current.fire("onBoxBlur") }if(this.current.retrieveData("small")&&!A.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(B,A){return new Element("li",A).addClassName(this.options.get("className")+"-box").update(B).cacheData("type","box") },createInput:function(B){var A=new Element("li",{"class":this.options.get("className")+"-input"});var D=new Element("input",Object.extend(B,{type:"text"}));D.setAttribute("autocomplete","off");if(!!this.options.get("maxLength")){D.setAttribute("maxlength",this.options.get("maxLength"))}D.observe("click",function(E){E.stop() }).observe("focus",function(E){if(!this.isSelfEvent("focus")){this.focus(A,true)}}.bind(this)).observe("blur",function(){if(!this.isSelfEvent("blur")){this.blur(true)}}.bind(this)).observe("keydown",function(E){this.cacheData("lastvalue",this.value).cacheData("lastcaret",this.getCaretPosition())});var C=A.cacheData("type","input").cacheData("input",D).insert(D); return C},callEvent:function(B,A){this.events.set(A,B);B[A]()},isSelfEvent:function(A){return(this.events.get(A))?!!this.events.unset(A):false},makeResizable:function(A){var B=A.retrieveData("input");B.cacheData("resizable",new ResizableTextbox(B,Object.extend(this.options.get("resizable"))));return this },checkInput:function(){var A=this.current.retrieveData("input");return(!A.retrieveData("lastvalue")||(A.getCaretPosition()===0&&A.retrieveData("lastcaret")===0))},move:function(B){var A=this.current[(B=="left"?"previous":"next")]();if(A&&(!this.current.retrieveData("input")||((this.checkInput()||B=="right")))){this.focus(A) }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(A){this.dispose($(A)) }.bind(this))}});Element.addMethods({getCaretPosition:function(){if(this.createTextRange){var A=document.selection.createRange().duplicate();A.moveEnd("character",this.value.length);if(A.text===""){return this.value.length}return this.value.lastIndexOf(A.text)}else{return this.selectionStart}},cacheData:function(B,A,C){if(Object.isUndefined(this[$(B).identify()])||!Object.isHash(this[$(B).identify()])){this[$(B).identify()]=$H() }this[$(B).identify()].set(A,C);return B},retrieveData:function(B,A){return this[$(B).identify()].get(A)},filter:function(H,G){var I=[];for(var J=0,F=this.length;J=this.loptions.get("autocomplete").minchars)){this.resultsshown=true; this.hideInstructions();this.autoresults.show();this.autoresults.update("");var D=new RegExp(B,"i");var A=this.bits.values();this.data.filter(function(F){return A.indexOf(F.id)==-1}).filter(function(F){if(E){return F}else{return F?D.test(F.name):false}}).each(function(F,H){C++;if(H>=this.loptions.get("autocomplete").maxresults){return }var I=this;var G=new Element("li");if(F.pic){G.setStyle({backgroundImage:"url("+F.pic+")"})}G.observe("click",function(J){J.stop();I.autoAdd(this)}).observe("mouseover",function(){I.autoFocus(this)}).update(this.autoHighlight(F.name,B));this.autoresults.insert(G);G.cacheData("result",F);if(H==0){this.autoFocus(G) }},this)}if(C==0){this.autoHide();this.showInstructions()}else{if(C>this.options.get("results")){this.autoresults.setStyle({height:(this.options.get("results")*24)+"px"})}else{this.autoresults.setStyle({height:(C?(C*24):0)+"px"})}}return this},autoHighlight:function(B,A){if(!!A){return B.gsub(new RegExp(A,"i"),function(C){return""+C[0]+"" })}else{return B}},autoHide:function(){this.resultsshown=false;this.autoresults.hide();return this},autoFocus:function(A){if(!A){return }if(this.autocurrent){this.autocurrent.removeClassName("auto-focus")}this.autocurrent=A.addClassName("auto-focus");return this},autoMove:function(A){if(!this.resultsshown){return }this.autoFocus(this.autocurrent[(A=="up"?"previous":"next")]());this.autoresults.scrollTop=this.autocurrent.positionedOffset()[1]-this.autocurrent.getHeight();return this},autoAdd:function(C){var A=C.retrieveData("result");if(!C||!A){return }this.add(A);delete this.data[this.data.indexOf(Object.toJSON(A))]; this.autoHide();var B=this.lastinput||this.maininput.retrieveData("input");B.clear().focus();this.showInstructions();return this},createInput:function($super,C){var A=$super(C);var B=A.retrieveData("input");B.setAttribute("tabindex","1");B.observe("keydown",function(D){this.dosearch=false;switch(D.keyCode){case Event.KEY_UP:D.stop(); return this.autoMove("up");case Event.KEY_DOWN:if(this.resultsshown||B.value!=""){D.stop();return this.autoMove("down")}case Event.KEY_TAB:if(!this.resultsshown){break}case Event.KEY_RETURN:D.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));B.observe("keyup",function(D){switch(D.keyCode){case Event.KEY_UP:case Event.KEY_RETURN:case Event.KEY_ESC:break; case Event.KEY_DOWN:if(!this.resultsshown&&B.value==""){this.autoShow(B.value,true)}break;default:if(this.dosearch){this.autoShow(B.value)}}}.bind(this));B.observe(Prototype.Browser.IE?"keydown":"keypress",function(D){this.autoenter=false}.bind(this));if(Prototype.Browser.Gecko){new Form.Element.Observer(B,0.2,function(D,E){if(this.dosearch){this.autoShow(B.value) }}.bind(this))}return A},createBox:function($super,C,B){var A=$super(C.name,B);A.observe("mouseover",function(){this.addClassName("bit-hover")}).observe("mouseout",function(){this.removeClassName("bit-hover")});return A},add:function($super,D,B){var C=$super(D,B);if(D.pic){C.setStyle({backgroundImage:"url("+D.pic+")"}) }if(this.options.get("maxRecipients")>0&&this.bits.size()>=this.options.get("maxRecipients")){this.maxRecipientsReached=true;this.hideInstructions();var A=this.lastinput||this.maininput.retrieveData("input");A.hide();if(!!this.options.get("maxRecipientsReachedCallback")){this.options.get("maxRecipientsReachedCallback")() }}return C},dispose:function($super,B){$super(B);if(this.options.get("maxRecipients")==0||this.bits.size()