var Utils={_getViewportScrollY:function(){var scrollY=0;
if(document.documentElement&&document.documentElement.scrollTop){scrollY=document.documentElement.scrollTop
}else{if(document.body&&document.body.scrollTop){scrollY=document.body.scrollTop
}else{if(window.pageYOffset){scrollY=window.pageYOffset
}else{if(window.scrollY){scrollY=window.scrollY
}}}}return scrollY
},_getPageSize:function(){var xScroll,yScroll;
if(window.innerHeight&&window.scrollMaxY){xScroll=document.body.scrollWidth;
yScroll=window.innerHeight+window.scrollMaxY
}else{if(document.body.scrollHeight>document.body.offsetHeight){xScroll=document.body.scrollWidth;
yScroll=document.body.scrollHeight
}else{xScroll=document.body.offsetWidth;
yScroll=document.body.offsetHeight
}}var windowWidth,windowHeight;
if(self.innerHeight){windowWidth=self.innerWidth;
windowHeight=self.innerHeight
}else{if(document.documentElement&&document.documentElement.clientHeight){windowWidth=document.documentElement.clientWidth;
windowHeight=document.documentElement.clientHeight
}else{if(document.body){windowWidth=document.body.clientWidth;
windowHeight=document.body.clientHeight
}}}if(yScroll<windowHeight){pageHeight=windowHeight
}else{pageHeight=yScroll
}if(xScroll<windowWidth){pageWidth=windowWidth
}else{pageWidth=xScroll
}var arrayPageSize=[pageWidth,pageHeight,windowWidth,windowHeight];
return arrayPageSize
},limitTextarea:function(id,maxLength,limitCallback){new Form.Element.Observer($(id),0.1,function(e){var f=$(id);
if(!f){return 
}if(maxLength<0){return 
}if(limitCallback){limitCallback(f.value.length>=maxLength)
}if(f.value.length>maxLength){f.value=f.value.substring(0,maxLength);
f.scrollTop=f.scrollHeight
}})
},closeHabboAndOpenMainWindow:function(link){if(window.opener!=null&&!window.opener.closed){window.opener.location.href=link.href;
window.opener.focus()
}else{var habboMainWindow=window.open(link.href,"_blank","toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=800,height=600");
habboMainWindow.focus()
}window.close()
}};
if(window.Prototype){Object.extend(Element,{wait:function(el,height){var style=(height&&height>0)?"padding: "+(height-6)/2+"px 0":"";
var div=Builder.node("div",{className:"progressbar",style:style},[Builder.node("img",{src:habboStaticFilePath+"/images/progress_bubbles.gif",width:"29",height:"6",alt:""})]);
el.innerHTML=Builder.node("p",[div]).innerHTML
}})
}var Cookie={set:function(name,value,daysToExpire){var expire="";
if(daysToExpire!=undefined){var d=new Date();
d.setTime(d.getTime()+(86400000*parseFloat(daysToExpire)));
expire="; expires="+d.toGMTString()
}return(document.cookie=escape(name)+"="+escape(value||"")+"; path=/"+expire)
},get:function(name){var cookie=document.cookie.match(new RegExp("(^|;)\\s*"+escape(name)+"=([^;\\s]*)"));
return(cookie?unescape(cookie[2]):null)
},append:function(name,value,daysToExpire,separator){var oldValue=Cookie.get(name);
if(!!oldValue){value=oldValue+(separator||"|")+value
}return Cookie.set(name,value,daysToExpire)
},erase:function(name){var cookie=Cookie.get(name)||true;
Cookie.set(name,"",-1);
return cookie
},accept:function(){if(typeof navigator.cookieEnabled=="boolean"){return navigator.cookieEnabled
}Cookie.set("_test","1");
return(Cookie.erase("_test")==="1")
}};
var HabboClientUtils={init:function(){Event.observe(window,"load",resizeWin);
Event.observe(window,"error",function(e){Event.stop(e);
return true
});
Event.observe(window,"unload",clearOpener);
ensureOpenerIsLoggedIn();
addClientUnloadHook();
Event.observe(document,"keypress",function(e){if(e.keyCode==Event.KEY_BACKSPACE){Event.stop(e)
}})
},cacheCheck:function(){new Ajax.Request(habboReqPath+"/cacheCheck",{onComplete:function(req){if(req.responseText!="true"){window.location.href=habboReqPath+"/client?"+new Date().getTime()
}}});
if(determineSWVersion()=="undefined"){log(50)
}},extWrite:function(str){document.write(str)
}};
var ShockwaveInstallation={init:function(){ShockwaveInstallation.startSwDetectionTimer();
var shockwaveCookie=Cookie.get("shockwave_install");
if(shockwaveCookie){Cookie.erase("shockwave_install");
ShockwaveInstallation.startSwInstallation()
}else{Cookie.set("shockwave_install","install","1")
}},swDetectionCheck:function(){if(determineSWVersion()=="undefined"){if(Cookie.get("shockwave_install")){Cookie.erase("shockwave_install")
}document.location=habboReqPath+"/client_popup/install_shockwave"
}else{if(ShockwaveInstallation.getSwVersionNumber()<10){document.location=habboReqPath+"/client_popup/upgrade_shockwave"
}}},getSwVersionNumber:function(){var versionString=determineSWVersion();
if(versionString!="undefined"){var versionIndex=versionString.indexOf(".");
var versionNumber=versionString.substring(versionIndex-2,versionIndex+2);
return parseFloat(versionNumber)
}return 0
},shockwaveDetected:function(){var shockwaveVersion=determineSWVersion();
if(shockwaveVersion!="undefined"&&ShockwaveInstallation.getSwVersionNumber()>=10){if(Cookie.get("shockwave_install")){Cookie.erase("shockwave_install")
}document.location=habboReqPath+"/client"
}},embedInstallationMovie:function(){var embedMovie="<OBJECT classid=\"clsid:166B1BCA-3F9C-11CF-8075-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=10,2,0,021\" ID=swdetect WIDTH=310 HEIGHT=200><PARAM NAME=src VALUE=\""+habboStaticFilePath+"/shockwave/swdetect.dcr\"><PARAM NAME=swStretchStyle VALUE=none><PARAM NAME=swRemote VALUE='swSaveEnabled=\"true\" swVolume=\"true\" swRestart=\"true\" swPausePlay=\"true\" swFastForward=\"true\" swContextMenu=\"true\"'>\n<EMBED SRC=\""+habboStaticFilePath+"/shockwave/swdetect.dcr\" bgColor=#FFFFFF WIDTH=310 HEIGHT=200 swStretchStyle=none swRemote='swSaveEnabled=\"true\" swVolume=\"true\" swRestart=\"true\" swPausePlay=\"true\" swFastForward=\"true\" swContextMenu=\"true\"' TYPE=\"application/x-director\" PLUGINSPAGE=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveDirector\"></EMBED></OBJECT>";
$("swdetection").innerHTML=embedMovie
},startSwInstallation:function(){$("shockwave-install-button").style.display="none";
$("shockwave-install-progressbar").style.display="block";
ShockwaveInstallation.embedInstallationMovie()
},startSwDetectionTimer:function(){ShockwaveInstallation.shockwaveDetected();
setTimeout(ShockwaveInstallation.startSwDetectionTimer,3000)
},installComplete:function(){if(Cookie.get("shockwave_install")){Cookie.erase("shockwave_install")
}document.location=habboReqPath+"/client"
}};
var HabboClient={openShortcut:function(link,shortcut){if(document.habboLoggedIn){new Ajax.Request("/client/shortcut",{parameters:{shortcut:shortcut}})
}openOrFocusHabbo(link)
}};
var habboClientOpening=false;
function openOrFocusHabbo(link){if(habboClientOpening){return 
}habboClientOpening=true;
var targetUrl=(link.href?link.href:link);
var win=openEmptyHabboWindow("client");
var isHabboClient=false;
try{isHabboClient=(win.habboClient&&win.document.habboLoggedIn==true)
}catch(error){}if(isHabboClient){win.focus();
if(win.updateHabboCount){win.updateHabboCount($("topbar-count").innerHTML)
}}else{win.location.href=targetUrl;
win.focus()
}habboClientOpening=false;
if(window.location.href.indexOf("/register/welcome")!=-1){window.location.href=habboReqPath+"/me"
}}function _openHabboWindow(url,target){return window.open(url,target,"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=740,height=597")
}function openEmptyHabboWindow(target){return _openHabboWindow("",target)
}function openOrFocusHelp(link){var targetUrl=(link.href?link.href:link);
var win=openEmptyHabboWindow("habbohelp");
var isHabboHelp=false;
try{isHabboHelp=(win.habboHelp)
}catch(error){}if(isHabboHelp){win.focus()
}else{win.location.href=targetUrl;
win.focus()
}}function ensureOpenerIsLoggedOut(){try{if(window.opener!=null&&window.opener.document.habboLoggedIn!=null){if(window.opener.document.habboLoggedIn==true){window.opener.location.replace(window.opener.location.href)
}}}catch(error){}}function ensureOpenerIsLoggedIn(){try{if(window.opener!=null){if(window.opener.document.logoutPage!=null&&window.opener.document.logoutPage==true){window.opener.location.href="/"
}else{if(window.opener.document.habboLoggedIn!=null&&window.opener.document.habboLoggedIn==false){window.opener.location.replace(window.opener.location.href)
}}}}catch(error){}}function roomForward(link,targetId,roomType){var targetUrl=(link.href?link.href:link);
var isHabboClient=false;
try{isHabboClient=window.habboClient
}catch(error){}if(isHabboClient){window.location.href=targetUrl;
return 
}if(document.habboLoggedIn){new Ajax.Request("/components/roomNavigation",{method:"get",parameters:"targetId="+targetId+"&roomType="+roomType+"&move=true"},false)
}openOrFocusHabbo(targetUrl)
}function resizeWin(){if(!document.all||screen.height>600){if(document.all){document.all["client-topbar"].style.display="block"
}else{if(document.getElementById){document.getElementById("client-topbar").style.display="block"
}}}if(window.opener!=null){var pageSize=Utils._getPageSize();
if(document.all){if(typeof document.body.style.maxHeight=="undefined"){pageSize[0]=720;
pageSize[1]+=35
}else{pageSize[0]=750;
pageSize[1]+=55
}}window.resizeTo(pageSize[0],pageSize[1]);
window.setTimeout(function(){var newSize=Utils._getPageSize();
window.resizeBy(newSize[0]-newSize[2],newSize[1]-newSize[3])
},500)
}}var HabboCounter={init:function(refreshFrequency){this.refreshFrequency=refreshFrequency;
this.start();
this.lastValue="0"
},start:function(){new PeriodicalExecuter(this.onTimerEvent.bind(this),this.refreshFrequency)
},onTimerEvent:function(){new Ajax.Request("../components/updateHabboCount.cfm",{onSuccess:function(response,obj){if(obj&&typeof obj.habboCountText!="undefined"&&this.lastValue!=obj.habboCountText){new Effect.Fade("habboCountUpdateTarget",{duration:0.5,afterFinish:function(){Element.update("habboCountUpdateTarget",obj.habboCountText);
new Effect.Appear("habboCountUpdateTarget",{duration:0.5})
}});
this.lastValue=obj.habboCountText
}}})
}};
function addClientUnloadHook(){if(habboClient==true&&determineSWVersion()!="undefined"){Event.observe(window,"unload",function(){new Ajax.Request(habboReqPath+"/account/unloadclient",{asynchronous:false})
})
}}function determineSWVersion(){if(navigator.plugins){navigator.plugins.refresh(false)
}if(navigator.mimeTypes&&navigator.mimeTypes["application/x-director"]&&navigator.mimeTypes["application/x-director"].enabledPlugin){if(navigator.plugins&&navigator.plugins["Shockwave for Director"]&&(tVersionIndex=navigator.plugins["Shockwave for Director"].description.indexOf("."))!=-1){return navigator.plugins["Shockwave for Director"].description.substring(tVersionIndex-2,tVersionIndex+2)
}}else{try{var swControl=new ActiveXObject("SWCtl.SWCtl");
if(swControl){return swControl.ShockwaveVersion("")
}}catch(e){}}return"undefined"
}function clearOpener(){if(window.opener&&window.opener.openedHabbo){window.opener.openedHabbo=null
}}var ClientMessageHandler={call:function(msg,data){if(msg){var msgArray=msg.split(/,+/).without("").uniq();
msgArray.each(function(msg){if(msg.length>0&&typeof ClientMessageHandler[msg]=="function"){try{ClientMessageHandler[msg].apply(null,[data])
}catch(e){}}})
}},googleClientKeepAlive:null,googleLastTrackingCall:0,google:function(data){if(!ClientMessageHandler.googleClientKeepAlive){ClientMessageHandler.googleClientKeepAlive=window.setInterval(function(){var now=new Date().getTime();
if(ClientMessageHandler.googleLastTrackingCall<now-15*60*1000){ClientMessageHandler.google("/client/keepalive");
ClientMessageHandler.googleLastTrackingCall=now
}},10*60*1000)
}var cleanedData=data.replace(/^(.*?\/){3}/,"/").replace(/^\/client(?=\/)/,"");
if(window.pageTracker){pageTracker._trackPageview("/client"+cleanedData)
}},nielsen:function(data){ClientMessageHandler.url("http://secure-dk.imrworldwide.com/cgi-bin/m?ci=Habbohotel&cg=0&si="+data)
},customjs:function(data){if(ClientMessageHandler.custom){ClientMessageHandler.custom(data)
}},url:function(data){var img=new Image(1,1);
img.src=data
},hello:function(data){alert(data)
},clientInit:function(params){ClientInitTimer.stop();
if(params){var version=determineSWVersion();
if(version!="undefined"){params.javascriptVersion=version
}new Ajax.Request(habboReqPath+"/clientlog/init",{method:"post",parameters:params})
}}};
var ClientInitTimer={timeoutId:null,hasClientLoadingFailed:false,start:function(timeoutDelay){ClientInitTimer.timeoutId=setTimeout(ClientInitTimer.timeout,timeoutDelay)
},stop:function(){clearTimeout(ClientInitTimer.timeoutId)
},timeout:function(){var params="?error=client_timeout";
var version=determineSWVersion();
if(version!="undefined"){params+="&version="+encodeURIComponent(version)
}if(ClientInitTimer.hasClientLoadingFailed){document.location="/client_failed_again"+params
}else{document.location="/client_failed"+params
}}};
function log(step){new Ajax.Request(habboReqPath+"/clientlog/update",{parameters:{step:step}})
}var L10N=function(){var _values=[];
return{put:function(key,value){_values[key]=value
},get:function(key){return _values[key]||key
}}
}();
var ListPaging=Class.create();
ListPaging.prototype={setOptions:function(options){this.options=this.options||{};
Object.extend(this.options,options||{})
},initialize:function(){this.pageNumber=1;
this.bindElementsAndEvents()
},bindElementsAndEvents:function(){this.contentElement=$(this.options.contentElementId);
this.pagingElement=$(this.options.pagingElementId);
if(this.pagingElement){this.pagingElement.onclick=this._processClick.bindAsEventListener(this)
}},_processClick:function(e){var clickedElement=Event.element(e);
if(clickedElement.nodeName.toLowerCase()=="a"&&clickedElement.className==this.options.pagingListLinkClass){Event.stop(e);
this._findPage(e)
}},_findPage:function(e){var clickedElement=Event.element(e);
var pageNumber=parseInt($F("pageNumber"));
var totalPages=parseInt($F("totalPages"));
var targetPageNumber=1;
if(clickedElement.id=="list-first"){targetPageNumber=1
}else{if(clickedElement.id=="list-previous"){targetPageNumber=pageNumber-1
}else{if(clickedElement.id=="list-next"){targetPageNumber=pageNumber+1
}else{if(clickedElement.id=="list-last"){targetPageNumber=totalPages
}}}}this._processSearch(targetPageNumber)
},_processSearch:function(targetPageNumber){var self=this;
new Ajax.Updater(this.contentElement,habboReqPath+this.options.searchUrl,{method:"post",parameters:"pageNumber="+encodeURIComponent(targetPageNumber),onComplete:function(){self.bindElementsAndEvents()
}})
}};
var QuickMenuListPaging=Class.extend(ListPaging,{initialize:function(contentElementId,targetUrl){this.setOptions({searchUrl:targetUrl,contentElementId:"qtab-container-"+contentElementId,pagingElementId:"qtab-"+contentElementId+"-list-paging",pagingListLinkClass:"qtab-"+contentElementId+"-list-paging-link"});
this.parent()
}});
var HabbletPaging=Class.extend(ListPaging,{initialize:function(targetUrl){this.setOptions({searchUrl:targetUrl});
this.parent()
},_findPage:function(e){var clickedElement=Event.element(e);
var pageNumber=parseInt($F(this.options.contentElementId+"-pageNumber"));
var totalPages=parseInt($F(this.options.contentElementId+"-totalPages"));
var targetPageNumber=1;
if(clickedElement.id==this.options.contentElementId+"-list-first"){targetPageNumber=1
}else{if(clickedElement.id==this.options.contentElementId+"-list-previous"){targetPageNumber=pageNumber-1
}else{if(clickedElement.id==this.options.contentElementId+"-list-next"){targetPageNumber=pageNumber+1
}else{if(clickedElement.id==this.options.contentElementId+"-list-last"){targetPageNumber=totalPages
}else{if(clickedElement.id.indexOf(this.options.contentElementId+"-list-page-")!=-1){targetPageNumber=clickedElement.id.substring(this.options.contentElementId.length+11)
}}}}}this._processSearch(targetPageNumber)
}});
var HabbletGroupPaging=Class.extend(HabbletPaging,{initialize:function(targetUrl){this.setOptions({contentElementId:"groups-habblet-list-container",pagingElementId:"groups-habblet-list-container-list-paging",pagingListLinkClass:"groups-habblet-list-container-list-paging-link"});
this.parent(targetUrl)
}});
var HabbletFriendsPaging=Class.extend(HabbletPaging,{initialize:function(targetUrl){this.setOptions({contentElementId:"friends-habblet-list-container",pagingElementId:"friends-habblet-list-container-list-paging",pagingListLinkClass:"friends-habblet-list-container-list-paging-link"});
this.parent(targetUrl)
}});
var HabbletSearchPaging=Class.extend(HabbletPaging,{initialize:function(targetUrl){this.setOptions({contentElementId:"avatar-habblet-list-container",pagingElementId:"avatar-habblet-list-container-list-paging",pagingListLinkClass:"avatar-habblet-list-container-list-paging-link"});
this.parent(targetUrl)
},_processSearch:function(targetPageNumber){var searchString=$F("avatar-habblet-search-string");
var self=this;
new Ajax.Updater(this.contentElement,habboReqPath+this.options.searchUrl,{method:"post",parameters:"pageNumber="+encodeURIComponent(targetPageNumber)+"&searchString="+encodeURIComponent(searchString),onComplete:function(){self.bindElementsAndEvents()
}})
}});
var HabboSearchHabblet=Class.create();
HabboSearchHabblet.prototype={minSearchLength:0,maxSearchLength:0,initialize:function(minSearchLength,maxSearchLength){this.maxSearchLength=maxSearchLength;
this.minSearchLength=minSearchLength;
this.habbletPaging=new HabbletSearchPaging("/habblet/habbosearchcontent");
var self=this;
Event.observe("avatar-habblet-search-button","click",function(e){Event.stop(e);
self._processSearch(e)
});
Event.observe("avatar-habblet-search-string","keypress",function(e){if(e.keyCode==Event.KEY_RETURN){self._processSearch(e)
}});
Utils.limitTextarea("avatar-habblet-search-string",this.maxSearchLength,function(limitReached){var errorContainer=$("habbo-search-error-container");
if(limitReached&&!Element.visible(errorContainer)){$("habbo-search-error").innerHTML=L10N.get("habblet.search.error.search_string_too_long");
Element.show(errorContainer)
}else{if(!limitReached){Element.hide(errorContainer)
}}})
},_processSearch:function(e){var searchString=$F("avatar-habblet-search-string");
searchString=searchString.replace(/[%?_]/g,"").replace(/^\s+|\s+$/g,"");
if(this._isValidSearchString(searchString)){Element.wait($("avatar-habblet-list-container"));
var self=this;
new Ajax.Updater("avatar-habblet-list-container",habboReqPath+"/habblet/habbosearchcontent",{method:"post",parameters:"searchString="+encodeURIComponent(searchString),onComplete:function(){self.habbletPaging.bindElementsAndEvents()
}})
}else{Element.show($("habbo-search-error-container"))
}},_isValidSearchString:function(searchString){if(searchString.length<this.minSearchLength){$("habbo-search-error").innerHTML=L10N.get("habblet.search.error.search_string_too_short");
return false
}else{if(searchString.length>this.maxSearchLength){$("habbo-search-error").innerHTML=L10N.get("habblet.search.error.search_string_too_long")
}}return true
}};
var HighscoreHabblet=Class.create();
HighscoreHabblet.prototype={initialize:function(habbletId){this.habbletId=habbletId;
this.containerEl=$("highscores-habblet-list-container-"+habbletId);
this._setupPaging();
this._setupGameLinks()
},_setupPaging:function(){if($("habblet-paging-"+this.habbletId)){var self=this;
Event.observe($("habblet-paging-"+this.habbletId),"click",function(e){Event.stop(e);
self._handlePagingClick(e)
})
}},_handlePagingClick:function(e){var el=Event.findElement(e,"a");
if(Element.hasClassName(el,"list-paging-link")){var pageNumber=$F(this.habbletId+"-pageNumber");
var gameId=$F(this.habbletId+"-gameId");
switch(el.id.split("-").last()){case"next":pageNumber++;
break;
case"previous":pageNumber--;
break
}this._updateContent(pageNumber,gameId)
}},_setupGameLinks:function(){var self=this;
Event.observe($("highscores-habblet-games-"+this.habbletId),"click",function(e){Event.stop(e);
self._handleGameLinkClick(e)
})
},_handleGameLinkClick:function(e){var el=Event.findElement(e,"a");
if(Element.hasClassName(el,"highscores-habblet-game-link")){var gameId=el.id.split("-").last();
this._updateContent(0,gameId)
}},_updateContent:function(pageNumber,gameId){var self=this;
new Ajax.Updater(this.containerEl,habboReqPath+"/habblet/personalhighscores",{method:"post",parameters:{pageNumber:pageNumber,gameId:gameId,hid:this.habbletId},onComplete:function(){self._setupPaging();
self._setupGameLinks()
}})
}};
var InviteFriendHabblet=Class.create();
InviteFriendHabblet.prototype={initialize:function(maxMessageLength){var self=this;
Event.observe("send-friend-invite-button","click",function(e){Event.stop(e);
self._sendInvite()
});
Utils.limitTextarea("invitation_message",maxMessageLength,function(limitReached){var errorElem=$("invitation_message_error");
if(limitReached&&!Element.visible(errorElem)){var elem=$$("#invitation_message_error .rounded").first();
elem.innerHTML=L10N.get("invitation.error.message_too_long");
Element.show(errorElem)
}else{if(!limitReached){Element.hide(errorElem)
}}});
for(var i=1;
i<4;
i++){Event.observe($("invitation_recipient"+i),"focus",function(e){var element=Event.element(e);
if(element&&element.value==L10N.get("invitation.form.recipient")){element.value=""
}});
Event.observe($("invitation_recipient"+i),"blur",function(e){var element=Event.element(e);
if(element&&element.value==""){element.value=L10N.get("invitation.form.recipient")
}})
}},_sendInvite:function(){var message=encodeURIComponent($("invitation_message").value);
for(var i=1;
i<4;
i++){if($("invitation_recipient"+i).value!=L10N.get("invitation.form.recipient")){message+="&recipientEmails="+encodeURIComponent($("invitation_recipient"+i).value)
}}new Ajax.Updater("friend-invitation-habblet-container",habboReqPath+"/habblet/ajax/mgmsendinvite",{method:"post",parameters:"message="+message,evalScripts:true,onComplete:function(req,jsonObj){if(jsonObj=="success"){for(var i=1;
i<4;
i++){$("invitation_recipient"+i).value=L10N.get("invitation.form.recipient")
}}}})
}};
var PurseHabblet=Class.create();
PurseHabblet.prototype={initialize:function(){var self=this;
var eventHandler=function(e){Event.stop(e);
self._redeemVoucher()
};
Event.observe("voucher-form","submit",eventHandler);
Event.observe("purse-redeemcode-button","click",eventHandler)
},_redeemVoucher:function(){var self=this;
new Ajax.Request(habboReqPath+"../habblet/ajax/redeemvoucher.cfm",{method:"post",parameters:{voucherCode:$F("purse-habblet-redeemcode-string")},onComplete:function(req){var form=$("voucher-form");
form.innerHTML=req.responseText;
document.getElementsByClassName("rounded",form).each(function(el){Rounder.addCorners(el,8,8)
});
var eventHandler=function(e){Event.stop(e);
self._redeemVoucher()
};
Event.observe("purse-redeemcode-button","click",eventHandler)
}})
}};
var ActiveHabbosHabblet=Class.create();
ActiveHabbosHabblet.prototype={numberOfRows:3,numberOfColumns:6,horizontalSpace:62,verticalSpace:45,numberOfImages:18,initialize:function(){this._positionPlaceHolderImages()
},generateRandomImages:function(){var elements=document.getElementsByClassName("active-habbo-image",$("homes-habblet-list-container"));
var displayedElements=[];
var index=0;
while(displayedElements.length<elements.length){var randomNumber=Math.floor(Math.random()*elements.length);
var displayElement=elements[randomNumber];
var placeholder=$("active-habbo-image-placeholder-"+index);
if(displayedElements.indexOf(randomNumber)==-1){$("imagemap-area-"+index).href=$("active-habbo-url-"+randomNumber).value;
this._addToolTip(index,$("active-habbo-data-"+randomNumber));
this._placeImage(placeholder,displayElement);
displayedElements.push(randomNumber);
index++
}if(index==this.numberOfImages){break
}}},_placeImage:function(placeholder,displayElement){window.setTimeout(function(){placeholder.style.backgroundImage="url("+displayElement.value+")"
},Math.floor(Math.random()*700))
},_addToolTip:function(index,content){new Tip("imagemap-area-"+index,content.innerHTML,{className:"bubbletip",title:" ",target:$("active-habbo-image-placeholder-"+index),hook:{target:"topRight",tip:"bottomRight"},offset:{x:85,y:40}})
},_positionPlaceHolderImages:function(){var elements=document.getElementsByClassName("active-habbo-image-placeholder",$("homes-habblet-list-container"));
var top=10;
var left=50;
var index=0;
for(var y=0;
y<this.numberOfRows;
y++){for(var x=0;
x<this.numberOfColumns;
x++){var placeholder=elements[index];
if(placeholder){placeholder.style.left=left+"px";
placeholder.style.top=top+"px";
left=left+this.horizontalSpace;
index=index+1
}}if(y%2<1){left=20
}else{left=50
}top=top+this.verticalSpace
}elements.each(function(element){element.style.display="block"
})
}};
var RoomSelectionHabblet={initClosableHabblet:function(){$("habblet-close-roomselection").observe("click",function(e){RoomSelectionHabblet.showConfirmation()
})
},hideHabblet:function(){new Ajax.Request(habboReqPath+"/habblet/ajax/roomselectionHide");
Effect.Fade("roomselection",{afterFinish:function(){$("roomselection").remove()
}})
},showConfirmation:function(){Overlay.show();
var dialog=Dialog.createDialog("roomselection-dialog",L10N.get("roomselection.hide.title"),false,false,false,RoomSelectionHabblet.hideConfirmation);
Dialog.setAsWaitDialog(dialog);
Dialog.makeDialogDraggable(dialog);
Dialog.moveDialogToCenter(dialog);
new Ajax.Request(habboReqPath+"/habblet/ajax/roomselectionConfirm",{onComplete:function(req){$("roomselection-dialog-body").update(req.responseText);
$("roomselection-cancel").observe("click",function(e){Event.stop(e);
RoomSelectionHabblet.hideConfirmation()
});
if(!!$("roomselection-hide")){$("roomselection-hide").observe("click",function(e){Event.stop(e);
RoomSelectionHabblet.hideConfirmation();
RoomSelectionHabblet.hideHabblet()
})
}}})
},hideConfirmation:function(){$("roomselection-dialog").remove();
Overlay.hide()
},create:function(clientUrl,id){var isHabboClient=false;
try{isHabboClient=window.habboClient
}catch(e){}if(isHabboClient){window.location.href=clientUrl;
return false
}if(document.habboLoggedIn){new Ajax.Request(habboReqPath+"/habblet/ajax/roomselectionCreate",{parameters:{roomType:id}})
}openOrFocusHabbo(clientUrl);
if($("roomselection-plp-intro")){$("roomselection-plp","habblet-close-roomselection").invoke("hide");
$("roomselection-plp-intro").update(L10N.get("roomselection.old_user.done"))
}return false
}};
var GiftQueueHabblet={init:function(time){GiftQueueHabblet.container=$("gift-countdown");
if(!!GiftQueueHabblet.container){GiftQueueHabblet.time=time;
GiftQueueHabblet.update();
GiftQueueHabblet.timer=window.setInterval(GiftQueueHabblet.update,1000)
}},update:function(){GiftQueueHabblet.time--;
var mins=Math.floor(GiftQueueHabblet.time/60);
var hours=Math.floor(mins/60);
mins-=(hours*60);
var secs=GiftQueueHabblet.time-(hours*60*60)-(mins*60);
if(hours==0&&mins==0&&secs==0){window.clearInterval(GiftQueueHabblet.timer);
GiftQueueHabblet.reload()
}else{var result="";
if(hours<10){result+="0"
}result+=L10N.get("time.hours").replace("{0}",hours)+" ";
if(mins<10){result+="0"
}result+=L10N.get("time.minutes").replace("{0}",mins)+" ";
if(secs<10){result+="0"
}result+=L10N.get("time.seconds").replace("{0}",secs);
GiftQueueHabblet.container.update(result)
}},reload:function(){new Ajax.Request(habboReqPath+"/habblet/ajax/nextgift",{onComplete:function(req,json){$("gift-container").update(req.responseText);
GiftQueueHabblet.init(parseInt(json))
}})
}};
var HabbletTabber=function(){var _load=function(url,el,selectedHeight){if(url.indexOf("?")==-1){url+="?"
}else{url+="&"
}url+="first=true";
Element.wait(el,selectedHeight);
new Ajax.Updater(el,url,{method:"post",evalScripts:true})
};
return{init:function(){document.getElementsByClassName("box-tabs",$("content")).each(function(el){Event.observe(el,"click",HabbletTabber.onclickHandler);
document.getElementsByClassName("selected",el).each(function(tab){document.getElementsByClassName("tab-ajax",$(tab.id+"-content")).each(function(el){_load(el.href,el.parentNode)
})
})
})
},onclickHandler:function(e){var tab=Event.findElement(e,"li");
if(tab&&tab.id&&(!tab.className||!Element.hasClassName(tab,"selected"))){var selectedHeight=0;
document.getElementsByClassName("selected",tab.parentNode).each(function(el){el.className="";
selectedHeight=$(el.id+"-content").getHeight();
Element.hide(el.id+"-content")
});
Element.addClassName(tab,"selected");
document.getElementsByClassName("tab-ajax",$(tab.id+"-content")).each(function(el){_load(el.href,el.parentNode,selectedHeight)
});
Element.show(tab.id+"-content");
Event.stop(e)
}else{var url=Event.element(e).href;
if(url.substring(url.length-1)=="#"){Event.stop(e)
}}}}
}();
HabboView.add(HabbletTabber.init);
var TagHelper=Class.create();
TagHelper.initialized=false;
TagHelper.init=function(loggedInAccountId){if(TagHelper.initialized){return 
}TagHelper.initialized=true;
TagHelper.loggedInAccountId=loggedInAccountId;
TagHelper.bindEventsToTagLists()
};
TagHelper.addFormTagToMe=function(){var addTagInput=$("add-tag-input");
TagHelper.addThisTagToMe($F(addTagInput),true);
Form.Element.clear(addTagInput)
};
TagHelper.bindEventsToTagLists=function(){var fn=function(e){TagHelper.tagListClicked(e,TagHelper.loggedInAccountId)
};
$$(".tag-list.make-clickable").each(function(element){Event.observe(element,"click",fn);
Element.removeClassName(element,"make-clickable")
})
};
TagHelper.setTexts=function(options){TagHelper.options=options
};
TagHelper.tagListClicked=function(e){var element=Event.element(e);
var addTag=Element.hasClassName(element,"tag-add-link");
var removeTag=Element.hasClassName(element,"tag-remove-link");
if(addTag||removeTag){var rowHolder=Element.up(element,".tag-list li");
if(!rowHolder){return 
}var tagName=TagHelper.findTagNameForContainer(rowHolder);
Event.stop(e);
if(addTag){TagHelper.addThisTagToMe(tagName,true)
}else{TagHelper.removeThisTagFromMe(tagName)
}}};
TagHelper.findTagNameForContainer=function(container){var tagLink=Element.down(container,".tag");
if(!tagLink){return null
}return tagLink.innerHTML.strip()
};
TagHelper.addThisTagToMe=function(tagName,tagListHabblet){new Ajax.Request("../myhabbo/tag/add.cfm",{parameters:"accountId="+encodeURIComponent(TagHelper.loggedInAccountId)+"&tagName="+encodeURIComponent(tagName),onSuccess:function(transport){var tagMsgCode=transport.responseText;
if(tagMsgCode=="valid"&&tagListHabblet){$$(".tag-list li").each(function(element){if(TagHelper.findTagNameForContainer(element)==tagName){var targetImg=Element.down(element,".tag-add-link");
var el=$$(".tag-remove-link").first();
targetImg.title=el?el.title:"";
targetImg.removeClassName("tag-add-link").addClassName("tag-remove-link")
}})
}else{if(tagMsgCode=="taglimit"){Dialog.showInfoDialog("tag-error-dialog",TagHelper.options.tagLimitText,TagHelper.options.buttonText,null)
}else{if(tagMsgCode=="invalidtag"){Dialog.showInfoDialog("tag-error-dialog",TagHelper.options.invalidTagText,TagHelper.options.buttonText,null)
}}}if(tagMsgCode=="valid"||tagMsgCode==""){if(tagListHabblet){TagHelper.reloadMyTagsList()
}else{TagHelper.reloadSearchBox(tagName,1)
}}}})
};
TagHelper.reloadSearchBox=function(tagName,page){new Ajax.Updater($("tag-search-habblet-container"),"../habblet/ajax/tagsearch.cfm",{method:"post",parameters:"tag="+tagName+"&pageNumber="+page,evalScripts:true})
};
TagHelper.removeThisTagFromMe=function(tagName){new Ajax.Request("../myhabbo/tag/remove.cfm",{parameters:"accountId="+encodeURIComponent(TagHelper.loggedInAccountId)+"&tagName="+encodeURIComponent(tagName),onSuccess:function(transport){var iconChangeFn=function(t){$$(".tag-list li").each(function(element){if(TagHelper.findTagNameForContainer(element)==tagName){var targetImg=Element.down(element,".tag-remove-link");
var first=$$(".tag-add-link").first();
if(first){targetImg.title=first.title||"";
targetImg.removeClassName("tag-remove-link").addClassName("tag-add-link")
}}})
};
TagHelper.reloadMyTagsList({onSuccess:iconChangeFn})
}})
};
TagHelper.reloadMyTagsList=function(extraOptions){var options={evalScripts:true};
Object.extend(options,extraOptions);
new Ajax.Updater($("my-tags-list"),"../habblet/mytagslist.cfm",options)
};
TagHelper.matchFriend=function(){var friend=$F("tag-match-friend");
if(friend){new Ajax.Updater($("tag-match-result"),habboReqPath+"/habblet/ajax/tagmatch",{parameters:{friendName:friend},onComplete:function(r){var elem=$("tag-match-value");
if(elem){var result=parseInt(elem.innerHTML,10);
if(typeof TagHelper.CountEffect=="undefined"){$("tag-match-value-display").innerHTML=result+" %";
Element.show("tag-match-slogan")
}else{var duration;
if(result>0){duration=1.5
}else{duration=0.1
}new TagHelper.CountEffect("tag-match-value-display",{duration:duration,transition:Effect.Transitions.sinoidal,from:0,to:result,afterFinish:function(){Effect.Appear("tag-match-slogan",{duration:1})
}})
}}}})
}};
var TagFight=Class.create();
TagFight.init=function(){if($F("tag1")&&$F("tag2")){TagFight.start()
}else{return false
}};
TagFight.start=function(){$("fightForm").style.display="none";
$("tag-fight-button").style.display="none";
$("fightanimation").src="../images/tagfight/tagfight_loop.gif";
$("fight-process").style.display="block";
setTimeout("TagFight.run()",3000)
};
TagFight.run=function(){new Ajax.Updater("fightResults","../habblet/ajax/tagfight.cfm",{method:"post",parameters:"tag1="+$F("tag1")+"&tag2="+$F("tag2"),onComplete:function(){$("fight-process").style.display="none";
$("fightForm").style.display="none";
$("tag-fight-button-new").style.display="block"
}})
};
TagFight.newFight=function(){$("fight-process").style.display="none";
$("fightForm").style.display="block";
$("fightResultCount").style.display="none";
$("tag-fight-button").style.display="block";
$("tag-fight-button-new").style.display="none";
$("fightanimation").src=habboStaticFilePath+"../images/tagfight/tagfight_start.gif";
$("tag1").value="";
$("tag2").value=""
};
var Dialog={moveDialogToCenter:function(dialog){var topPos=Position.cumulativeOffset(document.body);
var dim=Element.getDimensions(dialog);
var pageSize=Utils._getPageSize();
var x=0,y=0;
x=Math.round(pageSize[2]/2)-Math.round(dim.width/2);
if($("ad_sidebar")){var adPos=Position.cumulativeOffset($("ad_sidebar"));
if(x+dim.width>adPos[0]){x=adPos[0]-dim.width
}}if(x<0){x=0
}y=Utils._getViewportScrollY()+80;
if(y+dim.height>pageSize[1]){y=pageSize[1]-dim.height
}if(y<topPos[1]){y=topPos[1]+20
}dialog.style.left=x+"px";
dialog.style.top=y+"px"
},createDialog:function(dialogId,header,dialogZIndex,dialogLeft,dialogTop,exitCallback,tabs){if(!dialogId){return 
}var overlay=$("overlay");
var headerBar=[];
if(!tabs){headerBar.push(Builder.node("h2",{className:"title dialog-handle"},header));
if(header.length==0){headerBar[0].innerHTML="&nbsp;"
}}if(exitCallback){var exitButton=Builder.node("a",{href:"#",className:"topdialog-exit"},[Builder.node("img",{src:habboStaticFilePath+"/v2/images/close_x.gif",width:15,height:15,alt:""})]);
Event.observe(exitButton,"click",function(e){Event.stop(e);
exitCallback()
},false);
headerBar.push(exitButton)
}var childNodes=[];
if(tabs){var tabContent=Builder.node("div",{className:"topdialog-tabs"});
tabContent.innerHTML=tabs;
childNodes.push(headerBar);
childNodes.push(tabContent);
var tabContainer=$(tabContent).getElementsBySelector("ul");
if(tabContainer.length>0){tabContainer[0].addClassName("box-tabs")
}}else{childNodes.push(headerBar)
}childNodes.push(Builder.node("div",{id:dialogId+"-body",className:"topdialog-body"}));
var dialogClassName="cbb topdialog"+(tabs?" black":"");
var dialog=overlay.parentNode.insertBefore(Builder.node("div",{id:dialogId,className:dialogClassName},childNodes),overlay.nextSibling);
Rounder.round(dialog);
dialog=dialog.parentNode.parentNode.parentNode;
dialog.style.zIndex=(dialogZIndex||9001);
dialog.style.left=(dialogLeft||-1000)+"px";
dialog.style.top=(dialogTop||0)+"px";
Dialog.makeDialogDraggable(dialog);
return dialog
},showInfoDialog:function(dialogId,message,buttonText,buttonOnClick){Overlay.show();
var dialog=Dialog.createDialog(dialogId,"","9003");
var link=Builder.node("a",{href:"#",className:"new-button"},[Builder.node("b",buttonText),Builder.node("i")]);
Dialog.appendDialogBody(dialog,Builder.node("p",{id:dialogId+"content"}));
$(dialogId+"content").innerHTML=message;
Dialog.appendDialogBody(dialog,Builder.node("p",[link]));
if(buttonOnClick==null){Event.observe(link,"click",function(e){Event.stop(e);
Element.hide($(dialogId));
Overlay.hide()
},false)
}else{Event.observe(link,"click",buttonOnClick,false)
}Overlay.move("9002");
Dialog.moveDialogToCenter(dialog)
},showConfirmDialog:function(message){var options=Object.extend({dialogId:"confirm-dialog",buttonText:"OK",cancelButtonText:"Cancel",headerText:"Are you sure?",okHandler:Prototype.emptyFunction,cancelHandler:Prototype.emptyFunction},arguments[1]||{});
Overlay.show();
var dialog=Dialog.createDialog(options.dialogId,options.headerText,"9003");
if(options.width){dialog.style.width=options.width
}Dialog.appendDialogBody(dialog,Builder.node("p",{id:options.dialogId+"content"}));
$(options.dialogId+"content").innerHTML=message;
var link=Builder.node("a",{href:"#",className:"new-button"},[Builder.node("b",options.buttonText),Builder.node("i")]);
var cancelLink=Builder.node("a",{href:"#",className:"new-button"},[Builder.node("b",options.cancelButtonText),Builder.node("i")]);
Dialog.appendDialogBody(dialog,Builder.node("div",[cancelLink,link]));
Event.observe(link,"click",function(e){Event.stop(e);
options.okHandler()
},false);
Event.observe(cancelLink,"click",function(e){Event.stop(e);
Element.remove($(options.dialogId));
Overlay.hide();
options.cancelHandler()
},false);
Overlay.move("9002");
Dialog.moveDialogToCenter(dialog);
return dialog
},appendDialogBody:function(dialog,bodyEl,useInnerHTML){var el=$(dialog);
if(el){var el2=$(el.id+"-body");
(useInnerHTML)?el2.innerHTML+=bodyEl:el2.insertBefore(bodyEl,el2.lastChild);
if(bodyEl.innerHTML){bodyEl.innerHTML.evalScripts()
}}},setDialogBody:function(dialog,bodyEl){var el=$(dialog);
if(el){var el2=$(el.id+"-body");
el2.innerHTML=bodyEl
}},setAsWaitDialog:function(dialog){var el=$(dialog);
if(el){Element.wait($(el.id+"-body"))
}},makeDialogDraggable:function(dialog){if(typeof Draggable!="undefined"){var handle="title";
if(!$(dialog).down("."+handle,0)){handle="box-tabs"
}new Draggable(dialog,{handle:handle,starteffect:Prototype.emptyFunction,endeffect:Prototype.emptyFunction,zindex:9100})
}}};
var Overlay={show:function(clickCallback,progressText){var pageSize=Utils._getPageSize();
var overlay=$("overlay");
overlay.style.display="block";
overlay.style.height=pageSize[1]+"px";
try{var topWidth=Element.getDimensions("top").width;
if(topWidth>pageSize[2]){overlay.style.minWidth=topWidth+"px"
}}catch(ex){}overlay.style.zIndex="9000";
if(progressText){var progress=overlay.parentNode.insertBefore(Builder.node("div",{id:"overlay_progress"},[Builder.node("p",[Builder.node("img",{src:"../images/progress_habbos.gif",alt:progressText})]),Builder.node("p",progressText)]),overlay.nextSibling);
Overlay.center(progress)
}if(clickCallback){Event.observe($("overlay"),"click",function(e){clickCallback()
},false);
if(progressText){Event.observe($("overlay_progress"),"click",function(e){clickCallback()
},false)
}}$$("object,embed").each(function(item){item.setStyle({visibility:"hidden"})
})
},center:function(element){var pageSize=Utils._getPageSize();
var dim=Element.getDimensions(element);
var x=0,y=0;
x=Math.round(pageSize[2]/2)-Math.round(dim.width/2);
if(x<0){x=0
}y=Utils._getViewportScrollY()+(Math.round(pageSize[3]/2)-Math.round(dim.height/2));
if(y<0){y=0
}element.style.left=x+"px";
element.style.top=y+"px"
},hide:function(){if($("overlay_progress")){Element.remove($("overlay_progress"))
}var overlay=$("overlay");
overlay.style.zIndex="9000";
overlay.style.display="none";
$$("object,embed").each(function(item){item.setStyle({visibility:"visible"})
})
},move:function(zIndex){$("overlay").style.zIndex=zIndex;
if($("overlay_progress")){$("overlay_progress").style.zIndex=zIndex
}},hideIfMacFirefox:function(){var c_os=navigator.platform;
var c_ua=navigator.appName;
if((c_os=="Mac"||c_os=="MacIntel"||c_os=="MacPPC")&&(c_ua=="Netscape"||c_ua=="Mozilla"||c_ua=="Firefox")){Overlay.hide()
}},lightbox:function(imgUrl,progressText){var img=Builder.node("img",{src:imgUrl,style:"display: none; position: absolute; z-index: 9001; top:0; left:0; border: 7px solid #fff"});
var clickHandler=function(e){if(e){Event.stop(e)
}img.hide();
Overlay.hide()
};
Event.observe(img,"click",clickHandler);
var preloader=new Image();
Overlay.show(clickHandler,progressText||"");
preloader.onload=function(){if($("overlay_progress")){Element.remove($("overlay_progress"))
}$("overlay").parentNode.insertBefore(img,$("overlay"));
Overlay.center(img);
img.show();
preloader.onload=function(){}
};
preloader.src=imgUrl
}};
var ScriptLoader={loaded:[],callbacks:[],load:function(scriptName,options){if(!options){options={}
}if(!ScriptLoader.loaded[scriptName]){var headEl=document.getElementsByTagName("head")[0];
var scriptEl=document.createElement("script");
scriptEl.type="text/javascript";
scriptEl.src="../js/"+scriptName+".js";
if(options.callback){ScriptLoader.callbacks[scriptName]=options.callback
}headEl.appendChild(scriptEl)
}else{if(options.callback){options.callback()
}}},notify:function(scriptName,e){ScriptLoader.loaded[scriptName]=true;
if(ScriptLoader.callbacks[scriptName]){ScriptLoader.callbacks[scriptName](e)
}}};
QuickMenu=Class.create();
QuickMenu.prototype={initialize:function(){},add:function(element,clickHandler){new QuickMenuItem(this,element,clickHandler)
},activate:function(quickMenuItem){var element=quickMenuItem.element;
if(this.active){Element.removeClassName(this.active,"selected")
}if(this.active===element){this.closeContainer()
}else{Element.addClassName(element,"selected");
if(this.openContainer(element)){if(quickMenuItem.clickHandler){quickMenuItem.clickHandler.apply(null,[this.qtabContainer])
}}}},openContainer:function(element){var el=$("the-qtab-"+element.id);
var firstTime=(el==null);
if(firstTime){var el=$(Builder.node("div",{"class":"the-qtab","id":"the-qtab-"+element.id}));
$("header").appendChild(el);
var filler="<div style=\"margin-left: 1px; width: "+(element.getWidth()-2)+"px; height: 1px; background-color: #fff\"></div>";
el.update("<div class=\"qtab-container-top\">"+filler+"</div><div class=\"qtab-container-bottom\"><div id=\"qtab-container-"+element.id+"\" class=\"qtab-container\"></div></div>");
this.qtabContainer=$("qtab-container-"+element.id);
Position.clone(element,el,{setWidth:false,setHeight:false,offsetTop:25})
}$("header").getElementsBySelector(".the-qtab").each(Element.hide);
el.show();
this.active=element;
return firstTime
},closeContainer:function(){$("header").getElementsBySelector(".the-qtab").each(Element.hide);
if(this.active){var qtab=$("the-qtab-"+this.active.id);
Element.removeClassName(this.active,"selected")
}this.active=null
}};
QuickMenuItem=Class.create();
QuickMenuItem.prototype={initialize:function(quickMenu,element,clickHandler){this.quickMenu=quickMenu;
this.element=$(element);
var clickListener=this.click.bind(this);
element.down("a").observe("click",clickListener);
if(clickHandler){this.clickHandler=clickHandler
}},click:function(event){Event.stop(event);
this.quickMenu.activate(this)
}};
HabboView.add(function(){if(document.habboLoggedIn&&$("subnavi-user")){var qm=new QuickMenu();
var items=$A([["myfriends","/quickmenu/friends_all.cfm"],["mygroups","/quickmenu/groups.cfm"],["myrooms","/quickmenu/rooms.cfm"]]);
items.each(function(item){qm.add($(item[0]),function(container){var targetUrl=item[1];
Element.wait(container);
new Ajax.Updater(container,targetUrl,{onComplete:function(){new QuickMenuListPaging(item[0],targetUrl)
}})
})
});
Event.observe(document.body,"click",function(e){qm.closeContainer()
})
}});
var Accordion=Class.create();
Accordion.prototype={initialize:function(accordionContainer,summaryContainerPrefix,toggleDetailsClassName,detailsContainerPrefix,openDetailsL10NKey,closeDetailsL10NKey){this.animating=false;
this.openedItem=null;
this.accordionContainer=accordionContainer;
this.summaryContainerPrefix=summaryContainerPrefix;
this.toggleDetailsClassName=toggleDetailsClassName;
this.detailsContainerPrefix=detailsContainerPrefix;
this.openDetailsL10NKey=openDetailsL10NKey;
this.closeDetailsL10NKey=closeDetailsL10NKey;
var self=this;
document.getElementsByClassName(this.toggleDetailsClassName,this.accordionContainer).each(function(link){var item=self.parseItem(link);
if(item.el.visible()){self.openedItem=item;
throw $break
}});
Event.observe(this.accordionContainer,"click",function(e){var link=Event.element(e);
if(link&&link.id&&link.hasClassName(self.toggleDetailsClassName)){Event.stop(e);
var item=self.parseItem(link);
if(item.el){self.toggleItems(item.link,item.el,item.id)
}}})
},parseItem:function(link){var id=link.id.split("-").last();
var el=$(this.detailsContainerPrefix+id);
return{link:link,el:el,id:id}
},toggleItems:function(link,el,id){if(this.animating){return false
}var oldOpenedItem=this.openedItem;
var effects=[];
if(!oldOpenedItem||(oldOpenedItem&&oldOpenedItem.id!=id)){$(this.summaryContainerPrefix+id).addClassName("selected");
if(this.closeDetailsL10NKey){link.innerHTML=L10N.get(this.closeDetailsL10NKey)
}effects.push(new Effect.BlindDown(el));
this.openedItem={link:link,el:el,id:id}
}if(oldOpenedItem&&oldOpenedItem.id==id){this.openedItem=null
}if(oldOpenedItem){$(this.summaryContainerPrefix+oldOpenedItem.id).removeClassName("selected");
if(this.openDetailsL10NKey){oldOpenedItem.link.innerHTML=L10N.get(this.openDetailsL10NKey)
}effects.push(new Effect.BlindUp(oldOpenedItem.el))
}var self=this;
new Effect.Parallel(effects,{queue:{position:"end",scope:"accordionAnimation"},beforeStart:function(effect){self.animating=true
},afterFinish:function(effect){self.animating=false
}})
}};
RememberMeUI={};
RememberMeUI.init=function(){var rememberMeCheckBox=$("login-remember-me");
if(rememberMeCheckBox){var offsets=Position.positionedOffset(rememberMeCheckBox);
$("remember-me-notification").setStyle({left:(offsets[0]-10)+"px",top:(offsets[1]+20)+"px"});
Event.observe(rememberMeCheckBox,"click",function(e){$("remember-me-notification").setStyle({"display":rememberMeCheckBox.checked?"block":"none"})
})
}};
var SearchBoxHelper=Class.create();
SearchBoxHelper.initialized=false;
SearchBoxHelper.originalValues=[];
SearchBoxHelper.init=function(){if(SearchBoxHelper.initialized){return 
}SearchBoxHelper.initialized=true;
SearchBoxHelper.bindEventListeners()
};
SearchBoxHelper.bindEventListeners=function(){var fn=function(e){SearchBoxHelper.onBoxFocus(e)
};
var fn2=function(e){SearchBoxHelper.onBoxBlur(e)
};
$$(".search-box-onfocus").each(function(element){Event.observe(element,"focus",fn);
Event.observe(element,"blur",fn2);
SearchBoxHelper.originalValues[element]=element.value;
Element.removeClassName(element,"search-box-onfocus")
})
};
SearchBoxHelper.onBoxFocus=function(e){var element=Event.element(e);
if(element.value==SearchBoxHelper.originalValues[element]){element.value="";
element.style.color="#333333"
}else{element.select()
}};
SearchBoxHelper.onBoxBlur=function(e){var element=Event.element(e);
if(element.value==""){element.value=SearchBoxHelper.originalValues[element];
element.style.color="#777777"
}};
var NewsPromo=function(){var divs_to_fade=[];
var i=0;
var pause=false;
var swapFade=function(){if(!pause){Effect.Fade(divs_to_fade[i],{duration:0.8,from:1,to:0});
i++;
if(i==divs_to_fade.length){i=0
}Effect.Appear(divs_to_fade[i],{duration:0.8,from:0,to:1})
}};
return{init:function(){divs_to_fade=$$("#topstories .topstory");
if(divs_to_fade.length<2){return 
}Event.observe("topstories","mouseover",function(e){pause=true
});
Event.observe("topstories","mouseout",function(e){pause=false
});
var wait=10000;
setInterval(swapFade,wait)
}}
}();
LoginFormUI={};
LoginFormUI.init=function(){if($("login-submit-button")){$("login-submit-button").setStyle({marginLeft:"-10000px"});
$("login-submit-new-button").show();
Event.observe($("login-submit-new-button"),"click",function(e){Event.stop(e);
$("login-submit-new-button").up("form").submit()
})
}};
var TimeTracker=function(opt_bucket){if(opt_bucket){this.bucket_=opt_bucket.sort(this.sortNumber)
}else{this.bucket_=TimeTracker.DEFAULT_BUCKET
}};
TimeTracker.prototype.startTime_;
TimeTracker.prototype.stopTime_;
TimeTracker.prototype.bucket_;
TimeTracker.DEFAULT_BUCKET=[100,500,1500,2500,5000];
TimeTracker.prototype._getTimeDiff=function(){return(this.stopTime_-this.startTime_)
};
TimeTracker.prototype.sortNumber=function(a,b){return(a-b)
};
TimeTracker.prototype._recordStartTime=function(opt_time){if(opt_time!=undefined){this.startTime_=opt_time
}else{this.startTime_=(new Date()).getTime()
}};
TimeTracker.prototype._recordEndTime=function(opt_time){if(opt_time!=undefined){this.stopTime_=opt_time
}else{this.stopTime_=(new Date()).getTime()
}};
TimeTracker.prototype._track=function(tracker,opt_event_obj_name,opt_event_label){var eventTracker;
if(opt_event_obj_name!=undefined&&opt_event_obj_name.length!=0){eventTracker=tracker._createEventTracker(opt_event_obj_name)
}else{eventTracker=tracker._createEventTracker("TimeTracker")
}var i;
var bucketString;
for(i=0;
i<this.bucket_.length;
i++){if((this._getTimeDiff())<this.bucket_[i]){if(i==0){bucketString="0-"+(this.bucket_[0]);
break
}else{bucketString=this.bucket_[i-1]+"-"+(this.bucket_[i]-1);
break
}}}if(!bucketString){bucketString=this.bucket_[i-1]+"+"
}eventTracker._trackEvent(bucketString,opt_event_label,this._getTimeDiff())
};
TimeTracker.prototype._setHistogramBuckets=function(buckets_array){this.bucket_=buckets_array.sort(this.sortNumber)
};
TimeTracker.prototype._registerMeasurement=function(){new Ajax.Request("/log/measure",{method:"post",parameters:{requestUrl:window.location.href,pageLoadTime:this._getTimeDiff(),userAgent:navigator.userAgent}})
};
PersonalInfo={};
PersonalInfo.init=function(originalMotto){var mottoContainer=$("motto-container");
var nameWidth=mottoContainer.down("strong").getWidth();
var containerWidth=329;
mottoContainer.down("div").setStyle({width:containerWidth-nameWidth-12+"px"});
var mottoField=mottoContainer.down("input");
mottoField.setStyle({width:containerWidth-nameWidth-15+"px"});
var motto=mottoContainer.down("span");
var mottoFieldContainer=mottoContainer.down("p");
var links=$("motto-links");
var startEditing=function(){motto.hide();
mottoFieldContainer.show();
mottoField.value=originalMotto;
mottoField.focus();
mottoField.select();
links.show()
};
var hideEditing=function(){mottoFieldContainer.hide();
motto.show();
links.hide()
};
var updateMotto=function(){hideEditing();
if(originalMotto==mottoField.value){return 
}var origInnerHTML=motto.innerHTML;
motto.update("<img src=\""+habboStaticFilePath+"/images/progress_bubbles.gif\" width=\"29\" height=\"6\" alt=\"\" class=\"progress\"/>");
new Ajax.Request("../habblet/ajax/updatemotto.cfm",{parameters:{"motto":mottoField.value},onSuccess:function(transport,data){if(data&&data.spamming===true){alert(L10N.get("personal_info.motto_editor.spamming"));
mottoField.value=originalMotto;
motto.update(origInnerHTML);
return 
}if(data){originalMotto=data.motto
}motto.update(transport.responseText)
}})
};
Event.observe(motto,"click",startEditing);
Event.observe(mottoField,"keypress",function(e){if(e.keyCode==Event.KEY_RETURN){updateMotto()
}else{if(e.keyCode==Event.KEY_ESC){hideEditing()
}}});
Event.observe($("motto-cancel"),"click",function(e){Event.stop(e);
hideEditing()
});
if($("show-all-friends")){Event.observe("show-all-friends","click",function(e){Event.stop(e);
el=Event.element(e);
el.replace("<img src=\""+habboStaticFilePath+"/images/progress_bubbles.gif\" width=\"29\" height=\"6\" alt=\"\"/>");
new Ajax.Request("/habblet/ajax/allfriends",{onSuccess:function(transport){$("feed-friends").down("span").update(transport.responseText)
}})
})
}};
var GroupUtils={validateGroupElements:function(fieldId,maxLength,message){var groupElement=$(fieldId);
if(groupElement.value.length>=maxLength){groupElement.value=groupElement.value.substring(0,maxLength);
$(fieldId+"_message_error").innerHTML=message;
$(fieldId+"_message_error").style.display="block"
}else{$(fieldId+"_message_error").innerHTML="";
$(fieldId+"_message_error").style.display="none"
}if($(fieldId+"-counter")){var charatersLeft=maxLength-groupElement.value.length;
$(fieldId+"-counter").value=charatersLeft
}}};
var GroupPurchase=function(){var dialog=null;
var params=null;
var callAction=function(name){Dialog.setAsWaitDialog(dialog);
new Ajax.Request("../groups/purchase/"+name+".cfm",{parameters:params,onComplete:function(req,json){Dialog.setDialogBody(dialog,req.responseText)
}})
};
return{open:function(){dialog=Dialog.createDialog("group_purchase_form",L10N.get("purchase.group.title"),9001,0,-1000,GroupPurchase.close);
Dialog.setAsWaitDialog(dialog);
Dialog.moveDialogToCenter(dialog);
Dialog.makeDialogDraggable(dialog);
Overlay.show();
new Ajax.Request("../groups/purchase/group_create_form.cfm",{onComplete:function(req,json){Dialog.setDialogBody(dialog,req.responseText)
}})
},close:function(e){if(!!e){Event.stop(e)
}$("group_purchase_form").remove();
Overlay.hide();
dialog=null;
params=null
},confirm:function(){params={name:$F("group_name"),description:$F("group_description")};
callAction("purchase_confirmation")
},purchase:function(){callAction("purchase_ajax")
}}
}()
