var Prototype={Version:"1.6.0.3",Browser:{IE:!!(window.attachEvent&&navigator.userAgent.indexOf("Opera")===-1),Opera:navigator.userAgent.indexOf("Opera")>-1,WebKit:navigator.userAgent.indexOf("AppleWebKit/")>-1,Gecko:navigator.userAgent.indexOf("Gecko")>-1&&navigator.userAgent.indexOf("KHTML")===-1,MobileSafari:!!navigator.userAgent.match(/Apple.*Mobile.*Safari/)},BrowserFeatures:{XPath:!!document.evaluate,SelectorsAPI:!!document.querySelector,ElementExtensions:!!window.HTMLElement,SpecificElementExtensions:document.createElement("div")["__proto__"]&&document.createElement("div")["__proto__"]!==document.createElement("form")["__proto__"]},ScriptFragment:"<script[^>]*>([\\S\\s]*?)<\/script>",JSONFilter:/^\/\*-secure-([\s\S]*)\*\/\s*$/,emptyFunction:function(){},K:function(A){return A}};if(Prototype.Browser.MobileSafari){Prototype.BrowserFeatures.SpecificElementExtensions=false}var Class={create:function(){var B=null,C=$A(arguments);if(Object.isFunction(C[0])){B=C.shift()}function A(){this.initialize.apply(this,arguments)}Object.extend(A,Class.Methods);A.superclass=B;A.subclasses=[];if(B){var E=function(){};E.prototype=B.prototype;A.prototype=new E;B.subclasses.push(A)}for(var D=0;D<C.length;D++){A.addMethods(C[D])}if(!A.prototype.initialize){A.prototype.initialize=Prototype.emptyFunction}A.prototype.constructor=A;return A}};Class.Methods={addMethods:function(B){var E=this.superclass&&this.superclass.prototype;var D=Object.keys(B);if(!Object.keys({toString:true}).length){D.push("toString","valueOf")}for(var F=0,C=D.length;F<C;F++){var A=D[F],G=B[A];if(E&&Object.isFunction(G)&&G.argumentNames().first()=="$super"){var H=G;G=(function(I){return function(){return E[I].apply(this,arguments)}})(A).wrap(H);G.valueOf=H.valueOf.bind(H);G.toString=H.toString.bind(H)}this.prototype[A]=G}return this}};var Abstract={};Object.extend=function(C,B){for(var A in B){C[A]=B[A]}return C};Object.extend(Object,{inspect:function(A){try{if(Object.isUndefined(A)){return"undefined"}if(A===null){return"null"}return A.inspect?A.inspect():String(A)}catch(B){if(B instanceof RangeError){return"..."}throw B}},toJSON:function(C){var D=typeof C;switch(D){case"undefined":case"function":case"unknown":return ;case"boolean":return C.toString()}if(C===null){return"null"}if(C.toJSON){return C.toJSON()}if(Object.isElement(C)){return }var B=[];for(var A in C){var E=Object.toJSON(C[A]);if(!Object.isUndefined(E)){B.push(A.toJSON()+": "+E)}}return"{"+B.join(", ")+"}"},toQueryString:function(A){return $H(A).toQueryString()},toHTML:function(A){return A&&A.toHTML?A.toHTML():String.interpret(A)},keys:function(B){var C=[];for(var A in B){C.push(A)}return C},values:function(B){var C=[];for(var A in B){C.push(B[A])}return C},clone:function(A){return Object.extend({},A)},isElement:function(A){return !!(A&&A.nodeType==1)},isArray:function(A){return A!=null&&typeof A=="object"&&"splice" in A&&"join" in A},isHash:function(A){return A instanceof Hash},isFunction:function(A){return typeof A=="function"},isString:function(A){return typeof A=="string"},isNumber:function(A){return typeof A=="number"},isUndefined:function(A){return typeof A=="undefined"}});Object.extend(Function.prototype,{argumentNames:function(){var A=this.toString().match(/^[\s\(]*function[^(]*\(([^\)]*)\)/)[1].replace(/\s+/g,"").split(",");return A.length==1&&!A[0]?[]:A},bind:function(){if(arguments.length<2&&Object.isUndefined(arguments[0])){return this}var C=this,A=$A(arguments),B=A.shift();return function(){if(typeof $A==="function"){return C.apply(B,A.concat($A(arguments)))}}},bindAsEventListener:function(){var C=this,A=$A(arguments),B=A.shift();return function(D){if(typeof $A==="function"){return C.apply(B,[D||window.event].concat(A))}}},curry:function(){if(!arguments.length){return this}var B=this,A=$A(arguments);return function(){return B.apply(this,A.concat($A(arguments)))}},delay:function(){var C=this,B=$A(arguments),A=B.shift()*1000;return window.setTimeout(function(){return C.apply(C,B)},A)},defer:function(){var A=[0.01].concat($A(arguments));return this.delay.apply(this,A)},wrap:function(B){var A=this;return function(){return B.apply(this,[A.bind(this)].concat($A(arguments)))}},methodize:function(){if(this._methodized){return this._methodized}var A=this;return this._methodized=function(){return A.apply(null,[this].concat($A(arguments)))}}});Date.prototype.toJSON=function(){return'"'+this.getUTCFullYear()+"-"+(this.getUTCMonth()+1).toPaddedString(2)+"-"+this.getUTCDate().toPaddedString(2)+"T"+this.getUTCHours().toPaddedString(2)+":"+this.getUTCMinutes().toPaddedString(2)+":"+this.getUTCSeconds().toPaddedString(2)+'Z"'};var Try={these:function(){var B;for(var C=0,A=arguments.length;C<A;C++){var D=arguments[C];try{B=D();break}catch(E){}}return B}};RegExp.prototype.match=RegExp.prototype.test;RegExp.escape=function(A){return String(A).replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")};var PeriodicalExecuter=Class.create({initialize:function(A,B){this.callback=A;this.frequency=B;this.currentlyExecuting=false;this.registerCallback()},registerCallback:function(){this.timer=setInterval(this.onTimerEvent.bind(this),this.frequency*1000)},execute:function(){this.callback(this)},stop:function(){if(!this.timer){return }clearInterval(this.timer);this.timer=null},onTimerEvent:function(){if(!this.currentlyExecuting){try{this.currentlyExecuting=true;this.execute()}finally{this.currentlyExecuting=false}}}});Object.extend(String,{interpret:function(A){return A==null?"":String(A)},specialChar:{"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r","\\":"\\\\"}});Object.extend(String.prototype,{gsub:function(B,D){var E="",A=this,C;D=arguments.callee.prepareReplacement(D);while(A.length>0){if(C=A.match(B)){E+=A.slice(0,C.index);E+=String.interpret(D(C));A=A.slice(C.index+C[0].length)}else{E+=A,A=""}}return E},sub:function(A,B,C){B=this.gsub.prepareReplacement(B);C=Object.isUndefined(C)?1:C;return this.gsub(A,function(D){if(--C<0){return D[0]}return B(D)})},scan:function(A,B){this.gsub(A,B);return String(this)},truncate:function(A,B){A=A||30;B=Object.isUndefined(B)?"...":B;return this.length>A?this.slice(0,A-B.length)+B:String(this)},strip:function(){return this.replace(/^\s+/,"").replace(/\s+$/,"")},stripTags:function(){return this.replace(/<\/?[^>]+>/gi,"")},stripScripts:function(){return this.replace(new RegExp(Prototype.ScriptFragment,"img"),"")},extractScripts:function(){var B=new RegExp(Prototype.ScriptFragment,"img");var A=new RegExp(Prototype.ScriptFragment,"im");return(this.match(B)||[]).map(function(C){return(C.match(A)||["",""])[1]})},evalScripts:function(){return this.extractScripts().map(function(script){return eval(script)})},escapeHTML:function(){var A=arguments.callee;A.text.data=this;return A.div.innerHTML},unescapeHTML:function(){var A=new Element("div");A.innerHTML=this.stripTags();return A.childNodes[0]?(A.childNodes.length>1?$A(A.childNodes).inject("",function(B,C){return B+C.nodeValue}):A.childNodes[0].nodeValue):""},toQueryParams:function(B){var A=this.strip().match(/([^?#]*)(#.*)?$/);if(!A){return{}}return A[1].split(B||"&").inject({},function(E,F){if((F=F.split("="))[0]){var C=decodeURIComponent(F.shift());var D=F.length>1?F.join("="):F[0];if(D!=undefined){D=decodeURIComponent(D)}if(C in E){if(!Object.isArray(E[C])){E[C]=[E[C]]}E[C].push(D)}else{E[C]=D}}return E})},toArray:function(){return this.split("")},succ:function(){return this.slice(0,this.length-1)+String.fromCharCode(this.charCodeAt(this.length-1)+1)},times:function(A){return A<1?"":new Array(A+1).join(this)},camelize:function(){var D=this.split("-"),A=D.length;if(A==1){return D[0]}var B=this.charAt(0)=="-"?D[0].charAt(0).toUpperCase()+D[0].substring(1):D[0];for(var C=1;C<A;C++){B+=D[C].charAt(0).toUpperCase()+D[C].substring(1)}return B},capitalize:function(){return this.charAt(0).toUpperCase()+this.substring(1).toLowerCase()},underscore:function(){return this.gsub(/::/,"/").gsub(/([A-Z]+)([A-Z][a-z])/,"#{1}_#{2}").gsub(/([a-z\d])([A-Z])/,"#{1}_#{2}").gsub(/-/,"_").toLowerCase()},dasherize:function(){return this.gsub(/_/,"-")},inspect:function(B){var A=this.gsub(/[\x00-\x1f\\]/,function(C){var D=String.specialChar[C[0]];return D?D:"\\u00"+C[0].charCodeAt().toPaddedString(2,16)});if(B){return'"'+A.replace(/"/g,'\\"')+'"'}return"'"+A.replace(/'/g,"\\'")+"'"},toJSON:function(){return this.inspect(true)},unfilterJSON:function(A){return this.sub(A||Prototype.JSONFilter,"#{1}")},isJSON:function(){var A=this;if(A.blank()){return false}A=this.replace(/\\./g,"@").replace(/"[^"\\\n\r]*"/g,"");return(/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(A)},evalJSON:function(sanitize){var json=this.unfilterJSON();try{if(!sanitize||json.isJSON()){return eval("("+json+")")}}catch(e){}throw new SyntaxError("Badly formed JSON string: "+this.inspect())},include:function(A){return this.indexOf(A)>-1},startsWith:function(A){return this.indexOf(A)===0},endsWith:function(A){var B=this.length-A.length;return B>=0&&this.lastIndexOf(A)===B},empty:function(){return this==""},blank:function(){return/^\s*$/.test(this)},interpolate:function(B,A){return new Template(this,A).evaluate(B)}});if(Prototype.Browser.WebKit||Prototype.Browser.IE){Object.extend(String.prototype,{escapeHTML:function(){return this.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")},unescapeHTML:function(){return this.stripTags().replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">")}})}String.prototype.gsub.prepareReplacement=function(B){if(Object.isFunction(B)){return B}var A=new Template(B);return function(C){return A.evaluate(C)}};String.prototype.parseQuery=String.prototype.toQueryParams;Object.extend(String.prototype.escapeHTML,{div:document.createElement("div"),text:document.createTextNode("")});String.prototype.escapeHTML.div.appendChild(String.prototype.escapeHTML.text);var Template=Class.create({initialize:function(B,A){this.template=B.toString();this.pattern=A||Template.Pattern},evaluate:function(A){if(Object.isFunction(A.toTemplateReplacements)){A=A.toTemplateReplacements()}return this.template.gsub(this.pattern,function(F){if(A==null){return""}var C=F[1]||"";if(C=="\\"){return F[2]}var D=A,G=F[3];var B=/^([^.[]+|\[((?:.*?[^\\])?)\])(\.|\[|$)/;F=B.exec(G);if(F==null){return C}while(F!=null){var E=F[1].startsWith("[")?F[2].gsub("\\\\]","]"):F[1];D=D[E];if(null==D||""==F[3]){break}G=G.substring("["==F[3]?F[1].length:F[0].length);F=B.exec(G)}return C+String.interpret(D)})}});Template.Pattern=/(^|.|\r|\n)(#\{(.*?)\})/;var $break={};var Enumerable={each:function(C,B){var A=0;try{this._each(function(E){C.call(B,E,A++)})}catch(D){if(D!=$break){throw D}}return this},eachSlice:function(A,D,C){var B=-A,E=[],F=this.toArray();if(A<1){return F}while((B+=A)<F.length){E.push(F.slice(B,B+A))}return E.collect(D,C)},all:function(B,A){B=B||Prototype.K;var C=true;this.each(function(E,D){C=C&&!!B.call(A,E,D);if(!C){throw $break}});return C},any:function(B,A){B=B||Prototype.K;var C=false;this.each(function(E,D){if(C=!!B.call(A,E,D)){throw $break}});return C},collect:function(C,B){C=C||Prototype.K;var A=[];this.each(function(E,D){A.push(C.call(B,E,D))});return A},detect:function(B,A){var C;this.each(function(E,D){if(B.call(A,E,D)){C=E;throw $break}});return C},findAll:function(C,B){var A=[];this.each(function(E,D){if(C.call(B,E,D)){A.push(E)}});return A},grep:function(A,D,C){D=D||Prototype.K;var B=[];if(Object.isString(A)){A=new RegExp(A)}this.each(function(F,E){if(A.match(F)){B.push(D.call(C,F,E))}});return B},include:function(A){if(Object.isFunction(this.indexOf)){if(this.indexOf(A)!=-1){return true}}var B=false;this.each(function(C){if(C==A){B=true;throw $break}});return B},inGroupsOf:function(A,B){B=Object.isUndefined(B)?null:B;return this.eachSlice(A,function(C){while(C.length<A){C.push(B)}return C})},inject:function(A,C,B){this.each(function(E,D){A=C.call(B,A,E,D)});return A},invoke:function(B){var A=$A(arguments).slice(1);return this.map(function(C){return C[B].apply(C,A)})},max:function(B,A){B=B||Prototype.K;var C;this.each(function(E,D){E=B.call(A,E,D);if(C==null||E>=C){C=E}});return C},min:function(B,A){B=B||Prototype.K;var C;this.each(function(E,D){E=B.call(A,E,D);if(C==null||E<C){C=E}});return C},partition:function(D,B){D=D||Prototype.K;var C=[],A=[];this.each(function(F,E){(D.call(B,F,E)?C:A).push(F)});return[C,A]},pluck:function(A){var B=[];this.each(function(C){B.push(C[A])});return B},reject:function(C,B){var A=[];this.each(function(E,D){if(!C.call(B,E,D)){A.push(E)}});return A},sortBy:function(B,A){return this.map(function(D,C){return{value:D,criteria:B.call(A,D,C)}}).sort(function(F,E){var D=F.criteria,C=E.criteria;return D<C?-1:D>C?1:0}).pluck("value")},toArray:function(){return this.map()},zip:function(){var B=Prototype.K,A=$A(arguments);if(Object.isFunction(A.last())){B=A.pop()}var C=[this].concat(A).map($A);return this.map(function(E,D){return B(C.pluck(D))})},size:function(){return this.toArray().length},inspect:function(){return"#<Enumerable:"+this.toArray().inspect()+">"}};Object.extend(Enumerable,{map:Enumerable.collect,find:Enumerable.detect,select:Enumerable.findAll,filter:Enumerable.findAll,member:Enumerable.include,entries:Enumerable.toArray,every:Enumerable.all,some:Enumerable.any});function $A(C){if(!C){return[]}if(C.toArray){return C.toArray()}var A=C.length||0,B=new Array(A);while(A--){B[A]=C[A]}return B}if(Prototype.Browser.WebKit){$A=function(C){if(!C){return[]}if(!(typeof C==="function"&&typeof C.length==="number"&&typeof C.item==="function")&&C.toArray){return C.toArray()}var A=C.length||0,B=new Array(A);while(A--){B[A]=C[A]}return B}}Array.from=$A;Object.extend(Array.prototype,Enumerable);if(!Array.prototype._reverse){Array.prototype._reverse=Array.prototype.reverse}Object.extend(Array.prototype,{_each:function(C){for(var B=0,A=this.length;B<A;B++){C(this[B])}},clear:function(){this.length=0;return this},first:function(){return this[0]},last:function(){return this[this.length-1]},compact:function(){return this.select(function(A){return A!=null})},flatten:function(){return this.inject([],function(B,A){return B.concat(Object.isArray(A)?A.flatten():[A])})},without:function(){var A=$A(arguments);return this.select(function(B){return !A.include(B)})},reverse:function(A){return(A!==false?this:this.toArray())._reverse()},reduce:function(){return this.length>1?this:this[0]},uniq:function(A){return this.inject([],function(D,C,B){if(0==B||(A?D.last()!=C:!D.include(C))){D.push(C)}return D})},intersect:function(A){return this.uniq().findAll(function(B){return A.detect(function(C){return B===C})})},clone:function(){return[].concat(this)},size:function(){return this.length},inspect:function(){return"["+this.map(Object.inspect).join(", ")+"]"},toJSON:function(){var A=[];this.each(function(B){var C=Object.toJSON(B);if(!Object.isUndefined(C)){A.push(C)}});return"["+A.join(", ")+"]"}});if(Object.isFunction(Array.prototype.forEach)){Array.prototype._each=Array.prototype.forEach}if(!Array.prototype.indexOf){Array.prototype.indexOf=function(C,B){B||(B=0);var A=this.length;if(B<0){B=A+B}for(;B<A;B++){if(this[B]===C){return B}}return -1}}if(!Array.prototype.lastIndexOf){Array.prototype.lastIndexOf=function(B,A){A=isNaN(A)?this.length:(A<0?this.length+A:A)+1;var C=this.slice(0,A).reverse().indexOf(B);return(C<0)?C:A-C-1}}Array.prototype.toArray=Array.prototype.clone;function $w(A){if(!Object.isString(A)){return[]}A=A.strip();return A?A.split(/\s+/):[]}if(Prototype.Browser.Opera){Array.prototype.concat=function(){var E=[];for(var C=0,A=this.length;C<A;C++){E.push(this[C])}for(var C=0,A=arguments.length;C<A;C++){if(Object.isArray(arguments[C])){for(var B=0,D=arguments[C].length;B<D;B++){E.push(arguments[C][B])}}else{E.push(arguments[C])}}return E}}Object.extend(Number.prototype,{toColorPart:function(){return this.toPaddedString(2,16)},succ:function(){return this+1},times:function(B,A){$R(0,this,true).each(B,A);return this},toPaddedString:function(A,C){var B=this.toString(C||10);return"0".times(A-B.length)+B},toJSON:function(){return isFinite(this)?this.toString():"null"}});$w("abs round ceil floor").each(function(A){Number.prototype[A]=Math[A].methodize()});function $H(A){return new Hash(A)}var Hash=Class.create(Enumerable,(function(){function A(B,C){if(Object.isUndefined(C)){return B}return B+"="+encodeURIComponent(String.interpret(C))}return{initialize:function(B){this._object=Object.isHash(B)?B.toObject():Object.clone(B)},_each:function(C){for(var B in this._object){var D=this._object[B],E=[B,D];E.key=B;E.value=D;C(E)}},set:function(B,C){return this._object[B]=C},get:function(B){if(this._object[B]!==Object.prototype[B]){return this._object[B]}},unset:function(B){var C=this._object[B];delete this._object[B];return C},toObject:function(){return Object.clone(this._object)},keys:function(){return this.pluck("key")},values:function(){return this.pluck("value")},index:function(C){var B=this.detect(function(D){return D.value===C});return B&&B.key},merge:function(B){return this.clone().update(B)},update:function(B){return new Hash(B).inject(this,function(C,D){C.set(D.key,D.value);return C})},toQueryString:function(){return this.inject([],function(C,E){var B=encodeURIComponent(E.key),D=E.value;if(D&&typeof D=="object"){if(Object.isArray(D)){return C.concat(D.map(A.curry(B)))}}else{C.push(A(B,D))}return C}).join("&")},inspect:function(){return"#<Hash:{"+this.map(function(B){return B.map(Object.inspect).join(": ")}).join(", ")+"}>"},toJSON:function(){return Object.toJSON(this.toObject())},clone:function(){return new Hash(this)}}})());Hash.prototype.toTemplateReplacements=Hash.prototype.toObject;Hash.from=$H;var ObjectRange=Class.create(Enumerable,{initialize:function(C,A,B){this.start=C;this.end=A;this.exclusive=B},_each:function(A){var B=this.start;while(this.include(B)){A(B);B=B.succ()}},include:function(A){if(A<this.start){return false}if(this.exclusive){return A<this.end}return A<=this.end}});var $R=function(C,A,B){return new ObjectRange(C,A,B)};var Ajax={getTransport:function(){return Try.these(function(){return new XMLHttpRequest()},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")})||false},activeRequestCount:0};Ajax.Responders={responders:[],_each:function(A){this.responders._each(A)},register:function(A){if(!this.include(A)){this.responders.push(A)}},unregister:function(A){this.responders=this.responders.without(A)},dispatch:function(C,B,D,A){this.each(function(E){if(Object.isFunction(E[C])){try{E[C].apply(E,[B,D,A])}catch(F){}}})}};Object.extend(Ajax.Responders,Enumerable);Ajax.Responders.register({onCreate:function(){Ajax.activeRequestCount++},onComplete:function(){Ajax.activeRequestCount--}});Ajax.Base=Class.create({initialize:function(A){this.options={method:"post",asynchronous:true,contentType:"application/x-www-form-urlencoded",encoding:"UTF-8",parameters:"",evalJSON:true,evalJS:true};Object.extend(this.options,A||{});this.options.method=this.options.method.toLowerCase();if(Object.isString(this.options.parameters)){this.options.parameters=this.options.parameters.toQueryParams()}else{if(Object.isHash(this.options.parameters)){this.options.parameters=this.options.parameters.toObject()}}}});Ajax.Request=Class.create(Ajax.Base,{_complete:false,initialize:function($super,A,B){$super(B);this.transport=Ajax.getTransport();this.request(A)},request:function(A){this.url=A;this.method=this.options.method;var D=Object.clone(this.options.parameters);if(!["get","post"].include(this.method)){D._method=this.method;this.method="post"}this.parameters=D;if(D=Object.toQueryString(D)){if(this.method=="get"){this.url+=(this.url.include("?")?"&":"?")+D}else{if(/Konqueror|Safari|KHTML/.test(navigator.userAgent)){D+="&_="}}}try{var B=new Ajax.Response(this);if(this.options.onCreate){this.options.onCreate(B)}Ajax.Responders.dispatch("onCreate",this,B);this.transport.open(this.method.toUpperCase(),this.url,this.options.asynchronous);if(this.options.asynchronous){this.respondToReadyState.bind(this).defer(1)}this.transport.onreadystatechange=this.onStateChange.bind(this);this.setRequestHeaders();this.body=this.method=="post"?(this.options.postBody||D):null;this.transport.send(this.body);if(!this.options.asynchronous&&this.transport.overrideMimeType){this.onStateChange()}}catch(C){this.dispatchException(C)}},onStateChange:function(){var A=this.transport.readyState;if(A>1&&!((A==4)&&this._complete)){this.respondToReadyState(this.transport.readyState)}},setRequestHeaders:function(){var E={"X-Requested-With":"XMLHttpRequest","X-Prototype-Version":Prototype.Version,Accept:"text/javascript, text/html, application/xml, text/xml, */*"};if(this.method=="post"){E["Content-type"]=this.options.contentType+(this.options.encoding?"; charset="+this.options.encoding:"");if(this.transport.overrideMimeType&&(navigator.userAgent.match(/Gecko\/(\d{4})/)||[0,2005])[1]<2005){E.Connection="close"}}if(typeof this.options.requestHeaders=="object"){var B=this.options.requestHeaders;if(Object.isFunction(B.push)){for(var D=0,A=B.length;D<A;D+=2){E[B[D]]=B[D+1]}}else{$H(B).each(function(F){E[F.key]=F.value})}}for(var C in E){this.transport.setRequestHeader(C,E[C])}},success:function(){var A=this.getStatus();return !A||(A>=200&&A<300)},getStatus:function(){try{return this.transport.status||0}catch(A){return 0}},respondToReadyState:function(A){var C=Ajax.Request.Events[A],B=new Ajax.Response(this);if(C=="Complete"){try{this._complete=true;(this.options["on"+B.status]||this.options["on"+(this.success()?"Success":"Failure")]||Prototype.emptyFunction)(B,B.headerJSON)}catch(E){this.dispatchException(E)}var D=B.getHeader("Content-type");if(this.options.evalJS=="force"||(this.options.evalJS&&this.isSameOrigin()&&D&&D.match(/^\s*(text|application)\/(x-)?(java|ecma)script(;.*)?\s*$/i))){this.evalResponse()}}try{(this.options["on"+C]||Prototype.emptyFunction)(B,B.headerJSON);Ajax.Responders.dispatch("on"+C,this,B,B.headerJSON)}catch(E){this.dispatchException(E)}if(C=="Complete"){this.transport.onreadystatechange=Prototype.emptyFunction}},isSameOrigin:function(){var A=this.url.match(/^\s*https?:\/\/[^\/]*/);return !A||(A[0]=="#{protocol}//#{domain}#{port}".interpolate({protocol:location.protocol,domain:document.domain,port:location.port?":"+location.port:""}))},getHeader:function(A){try{return this.transport.getResponseHeader(A)||null}catch(B){return null}},evalResponse:function(){try{return eval((this.transport.responseText||"").unfilterJSON())}catch(e){this.dispatchException(e)}},dispatchException:function(A){(this.options.onException||Prototype.emptyFunction)(this,A);Ajax.Responders.dispatch("onException",this,A)}});Ajax.Request.Events=["Uninitialized","Loading","Loaded","Interactive","Complete"];Ajax.Response=Class.create({initialize:function(C){this.request=C;var D=this.transport=C.transport,A=this.readyState=D.readyState;if((A>2&&!Prototype.Browser.IE)||A==4){this.status=this.getStatus();this.statusText=this.getStatusText();this.responseText=String.interpret(D.responseText);this.headerJSON=this._getHeaderJSON()}if(A==4){var B=D.responseXML;this.responseXML=Object.isUndefined(B)?null:B;this.responseJSON=this._getResponseJSON()}},status:0,statusText:"",getStatus:Ajax.Request.prototype.getStatus,getStatusText:function(){try{return this.transport.statusText||""}catch(A){return""}},getHeader:Ajax.Request.prototype.getHeader,getAllHeaders:function(){try{return this.getAllResponseHeaders()}catch(A){return null}},getResponseHeader:function(A){return this.transport.getResponseHeader(A)},getAllResponseHeaders:function(){return this.transport.getAllResponseHeaders()},_getHeaderJSON:function(){var A=this.getHeader("X-JSON");if(!A){return null}A=decodeURIComponent(escape(A));try{return A.evalJSON(this.request.options.sanitizeJSON||!this.request.isSameOrigin())}catch(B){this.request.dispatchException(B)}},_getResponseJSON:function(){var A=this.request.options;if(!A.evalJSON||(A.evalJSON!="force"&&!(this.getHeader("Content-type")||"").include("application/json"))||this.responseText.blank()){return null}try{return this.responseText.evalJSON(A.sanitizeJSON||!this.request.isSameOrigin())}catch(B){this.request.dispatchException(B)}}});Ajax.Updater=Class.create(Ajax.Request,{initialize:function($super,C,A,B){this.container={success:(C.success||C),failure:(C.failure||(C.success?null:C))};B=Object.clone(B);var D=B.onComplete;B.onComplete=(function(F,E){this.updateContent(F.responseText);if(Object.isFunction(D)){D(F,E)}}).bind(this);$super(A,B)},updateContent:function(D){var B=this.container[this.success()?"success":"failure"],C=this.options;if(!C.evalScripts){D=D.stripScripts()}if(B=$(B)){if(C.insertion){if(Object.isString(C.insertion)){var A={};A[C.insertion]=D;B.insert(A)}else{C.insertion(B,D)}}else{B.update(D)}}}});Ajax.PeriodicalUpdater=Class.create(Ajax.Base,{initialize:function($super,C,A,B){$super(B);this.onComplete=this.options.onComplete;this.frequency=(this.options.frequency||2);this.decay=(this.options.decay||1);this.updater={};this.container=C;this.url=A;this.start()},start:function(){this.options.onComplete=this.updateComplete.bind(this);this.onTimerEvent()},stop:function(){this.updater.options.onComplete=undefined;clearTimeout(this.timer);(this.onComplete||Prototype.emptyFunction).apply(this,arguments)},updateComplete:function(A){if(this.options.decay){this.decay=(A.responseText==this.lastText?this.decay*this.options.decay:1);this.lastText=A.responseText}this.timer=this.onTimerEvent.bind(this).delay(this.decay*this.frequency)},onTimerEvent:function(){this.updater=new Ajax.Updater(this.container,this.url,this.options)}});function $(C){if(arguments.length>1){for(var D=0,A=[],B=arguments.length;D<B;D++){A.push($(arguments[D]))}return A}if(Object.isString(C)){C=document.getElementById(C)}return Element.extend(C)}if(Prototype.BrowserFeatures.XPath){document._getElementsByXPath=function(F,D){var C=[];var E=document.evaluate(F,$(D)||document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);for(var B=0,A=E.snapshotLength;B<A;B++){C.push(Element.extend(E.snapshotItem(B)))}return C}}if(!window.Node){var Node={}}if(!Node.ELEMENT_NODE){Object.extend(Node,{ELEMENT_NODE:1,ATTRIBUTE_NODE:2,TEXT_NODE:3,CDATA_SECTION_NODE:4,ENTITY_REFERENCE_NODE:5,ENTITY_NODE:6,PROCESSING_INSTRUCTION_NODE:7,COMMENT_NODE:8,DOCUMENT_NODE:9,DOCUMENT_TYPE_NODE:10,DOCUMENT_FRAGMENT_NODE:11,NOTATION_NODE:12})}(function(){var A=this.Element;this.Element=function(D,C){C=C||{};D=D.toLowerCase();var B=Element.cache;if(Prototype.Browser.IE&&C.name){D="<"+D+' name="'+C.name+'">';delete C.name;return Element.writeAttribute(document.createElement(D),C)}if(!B[D]){B[D]=Element.extend(document.createElement(D))}return Element.writeAttribute(B[D].cloneNode(false),C)};Object.extend(this.Element,A||{});if(A){this.Element.prototype=A.prototype}}).call(window);Element.cache={};Element.Methods={visible:function(A){return $(A).style.display!="none"},toggle:function(A){A=$(A);Element[Element.visible(A)?"hide":"show"](A);return A},hide:function(A){A=$(A);A.style.display="none";return A},show:function(A){A=$(A);A.style.display="";return A},remove:function(A){A=$(A);A.parentNode.removeChild(A);return A},update:function(A,B){A=$(A);if(B&&B.toElement){B=B.toElement()}if(Object.isElement(B)){return A.update().insert(B)}B=Object.toHTML(B);A.innerHTML=B.stripScripts();B.evalScripts.bind(B).defer();return A},replace:function(B,C){B=$(B);if(C&&C.toElement){C=C.toElement()}else{if(!Object.isElement(C)){C=Object.toHTML(C);var A=B.ownerDocument.createRange();A.selectNode(B);C.evalScripts.bind(C).defer();C=A.createContextualFragment(C.stripScripts())}}B.parentNode.replaceChild(C,B);return B},insert:function(D,F){D=$(D);if(Object.isString(F)||Object.isNumber(F)||Object.isElement(F)||(F&&(F.toElement||F.toHTML))){F={bottom:F}}var E,B,C,G;for(var A in F){E=F[A];A=A.toLowerCase();B=Element._insertionTranslations[A];if(E&&E.toElement){E=E.toElement()}if(Object.isElement(E)){B(D,E);continue}E=Object.toHTML(E);C=((A=="before"||A=="after")?D.parentNode:D).tagName.toUpperCase();G=Element._getContentFromAnonymousElement(C,E.stripScripts());if(A=="top"||A=="after"){G.reverse()}G.each(B.curry(D));E.evalScripts.bind(E).defer()}return D},wrap:function(B,C,A){B=$(B);if(Object.isElement(C)){$(C).writeAttribute(A||{})}else{if(Object.isString(C)){C=new Element(C,A)}else{C=new Element("div",C)}}if(B.parentNode){B.parentNode.replaceChild(C,B)}C.appendChild(B);return C},inspect:function(A){A=$(A);var B="<"+A.tagName.toLowerCase();$H({id:"id",className:"class"}).each(function(F){var C=F.first(),D=F.last();var E=(A[C]||"").toString();if(E){B+=" "+D+"="+E.inspect(true)}});return B+">"},recursivelyCollect:function(C,B){C=$(C);var A=[];while(C=C[B]){if(C.nodeType==1){A.push(Element.extend(C))}}return A},ancestors:function(A){return $(A).recursivelyCollect("parentNode")},descendants:function(A){return $(A).select("*")},firstDescendant:function(A){A=$(A).firstChild;while(A&&A.nodeType!=1){A=A.nextSibling}return $(A)},immediateDescendants:function(A){if(!(A=$(A).firstChild)){return[]}while(A&&A.nodeType!=1){A=A.nextSibling}if(A){return[A].concat($(A).nextSiblings())}return[]},previousSiblings:function(A){return $(A).recursivelyCollect("previousSibling")},nextSiblings:function(A){return $(A).recursivelyCollect("nextSibling")},siblings:function(A){A=$(A);return A.previousSiblings().reverse().concat(A.nextSiblings())},match:function(B,A){if(Object.isString(A)){A=new Selector(A)}return A.match($(B))},up:function(C,D,B){C=$(C);if(arguments.length==1){return $(C.parentNode)}var A=C.ancestors();return Object.isNumber(D)?A[D]:Selector.findElement(A,D,B)},down:function(B,C,A){B=$(B);if(arguments.length==1){return B.firstDescendant()}return Object.isNumber(C)?B.descendants()[C]:Element.select(B,C)[A||0]},previous:function(B,D,A){B=$(B);if(arguments.length==1){return $(Selector.handlers.previousElementSibling(B))}var C=B.previousSiblings();return Object.isNumber(D)?C[D]:Selector.findElement(C,D,A)},next:function(B,D,A){B=$(B);if(arguments.length==1){return $(Selector.handlers.nextElementSibling(B))}var C=B.nextSiblings();return Object.isNumber(D)?C[D]:Selector.findElement(C,D,A)},select:function(){var B=$A(arguments),A=$(B.shift());return Selector.findChildElements(A,B)},adjacent:function(){var B=$A(arguments),A=$(B.shift());return Selector.findChildElements(A.parentNode,B).without(A)},identify:function(B){B=$(B);var C=B.readAttribute("id"),A=arguments.callee;if(C){return C}do{C="anonymous_element_"+A.counter++}while($(C));B.writeAttribute("id",C);return C},readAttribute:function(B,A){B=$(B);if(Prototype.Browser.IE){var C=Element._attributeTranslations.read;if(C.values[A]){return C.values[A](B,A)}if(C.names[A]){A=C.names[A]}if(A.include(":")){return(!B.attributes||!B.attributes[A])?null:B.attributes[A].value}}return B.getAttribute(A)},writeAttribute:function(D,C,F){D=$(D);var B={},E=Element._attributeTranslations.write;if(typeof C=="object"){B=C}else{B[C]=Object.isUndefined(F)?true:F}for(var A in B){C=E.names[A]||A;F=B[A];if(E.values[A]){C=E.values[A](D,F)}if(F===false||F===null){D.removeAttribute(C)}else{if(F===true){D.setAttribute(C,C)}else{D.setAttribute(C,F)}}}return D},getHeight:function(A){return $(A).getDimensions().height},getWidth:function(A){return $(A).getDimensions().width},classNames:function(A){return new Element.ClassNames(A)},hasClassName:function(B,A){if(!(B=$(B))){return }var C=B.className;return(C.length>0&&(C==A||new RegExp("(^|\\s)"+A+"(\\s|$)").test(C)))},addClassName:function(B,A){if(!(B=$(B))){return }if(!B.hasClassName(A)){B.className+=(B.className?" ":"")+A}return B},removeClassName:function(B,A){if(!(B=$(B))){return }B.className=B.className.replace(new RegExp("(^|\\s+)"+A+"(\\s+|$)")," ").strip();return B},toggleClassName:function(B,A){if(!(B=$(B))){return }return B[B.hasClassName(A)?"removeClassName":"addClassName"](A)},cleanWhitespace:function(B){B=$(B);var C=B.firstChild;while(C){var A=C.nextSibling;if(C.nodeType==3&&!/\S/.test(C.nodeValue)){B.removeChild(C)}C=A}return B},empty:function(A){return $(A).innerHTML.blank()},descendantOf:function(B,A){B=$(B),A=$(A);if(B.compareDocumentPosition){return(B.compareDocumentPosition(A)&8)===8}if(A.contains){return A.contains(B)&&A!==B}while(B=B.parentNode){if(B==A){return true}}return false},scrollTo:function(A){A=$(A);var B=A.cumulativeOffset();window.scrollTo(B[0],B[1]);return A},getStyle:function(A,C){A=$(A);C=C=="float"?"cssFloat":C.camelize();var D=A.style[C];if(!D||D=="auto"){var B=document.defaultView.getComputedStyle(A,null);D=B?B[C]:null}if(C=="opacity"){return D?parseFloat(D):1}return D=="auto"?null:D},getOpacity:function(A){return $(A).getStyle("opacity")},setStyle:function(E,C){E=$(E);var B=E.style,D;if(Object.isString(C)){E.style.cssText+=";"+C;return C.include("opacity")?E.setOpacity(C.match(/opacity:\s*(\d?\.?\d*)/)[1]):E}for(var A in C){if(A=="opacity"){E.setOpacity(C[A])}else{B[(A=="float"||A=="cssFloat")?(Object.isUndefined(B.styleFloat)?"cssFloat":"styleFloat"):A]=C[A]}}return E},setOpacity:function(A,B){A=$(A);A.style.opacity=(B==1||B==="")?"":(B<0.00001)?0:B;return A},getDimensions:function(C){C=$(C);var G=C.getStyle("display");if(G!="none"&&G!=null){return{width:C.offsetWidth,height:C.offsetHeight}}var E=C.style;var A=E.visibility;var B=E.position;var D=E.display;E.visibility="hidden";E.position="absolute";E.display="block";var H=C.clientWidth;var F=C.clientHeight;E.display=D;E.position=B;E.visibility=A;return{width:H,height:F}},makePositioned:function(A){A=$(A);var B=Element.getStyle(A,"position");if(B=="static"||!B){A._madePositioned=true;A.style.position="relative";if(Prototype.Browser.Opera){A.style.top=0;A.style.left=0}}return A},undoPositioned:function(A){A=$(A);if(A._madePositioned){A._madePositioned=undefined;A.style.position=A.style.top=A.style.left=A.style.bottom=A.style.right=""}return A},makeClipping:function(A){A=$(A);if(A._overflow){return A}A._overflow=Element.getStyle(A,"overflow")||"auto";if(A._overflow!=="hidden"){A.style.overflow="hidden"}return A},undoClipping:function(A){A=$(A);if(!A._overflow){return A}A.style.overflow=A._overflow=="auto"?"":A._overflow;A._overflow=null;return A},cumulativeOffset:function(A){var B=0,C=0;do{B+=A.offsetTop||0;C+=A.offsetLeft||0;A=A.offsetParent}while(A);return Element._returnOffset(C,B)},positionedOffset:function(A){var B=0,D=0;do{B+=A.offsetTop||0;D+=A.offsetLeft||0;A=A.offsetParent;if(A){if(A.tagName.toUpperCase()=="BODY"){break}var C=Element.getStyle(A,"position");if(C!=="static"){break}}}while(A);return Element._returnOffset(D,B)},absolutize:function(B){B=$(B);if(B.getStyle("position")=="absolute"){return B}var A=B.positionedOffset();var F=A[1];var E=A[0];var C=B.clientWidth;var D=B.clientHeight;B._originalLeft=E-parseFloat(B.style.left||0);B._originalTop=F-parseFloat(B.style.top||0);B._originalWidth=B.style.width;B._originalHeight=B.style.height;B.style.position="absolute";B.style.top=F+"px";B.style.left=E+"px";B.style.width=C+"px";B.style.height=D+"px";return B},relativize:function(A){A=$(A);if(A.getStyle("position")=="relative"){return A}A.style.position="relative";var C=parseFloat(A.style.top||0)-(A._originalTop||0);var B=parseFloat(A.style.left||0)-(A._originalLeft||0);A.style.top=C+"px";A.style.left=B+"px";A.style.height=A._originalHeight;A.style.width=A._originalWidth;return A},cumulativeScrollOffset:function(A){var B=0,C=0;do{B+=A.scrollTop||0;C+=A.scrollLeft||0;A=A.parentNode}while(A);return Element._returnOffset(C,B)},getOffsetParent:function(A){if(A.offsetParent){return $(A.offsetParent)}if(A==document.body){return $(A)}while((A=A.parentNode)&&A!=document.body){if(Element.getStyle(A,"position")!="static"){return $(A)}}return $(document.body)},viewportOffset:function(C){var B=0,D=0;var A=C;do{B+=A.offsetTop||0;D+=A.offsetLeft||0;if(A.offsetParent==document.body&&Element.getStyle(A,"position")=="absolute"){break}}while(A=A.offsetParent);A=C;do{if(!Prototype.Browser.Opera||(A.tagName&&(A.tagName.toUpperCase()=="BODY"))){B-=A.scrollTop||0;D-=A.scrollLeft||0}}while(A=A.parentNode);return Element._returnOffset(D,B)},clonePosition:function(C,A){var D=Object.extend({setLeft:true,setTop:true,setWidth:true,setHeight:true,offsetTop:0,offsetLeft:0},arguments[2]||{});A=$(A);var E=A.viewportOffset();C=$(C);var F=[0,0];var B=null;if(Element.getStyle(C,"position")=="absolute"){B=C.getOffsetParent();F=B.viewportOffset()}if(B==document.body){F[0]-=document.body.offsetLeft;F[1]-=document.body.offsetTop}if(D.setLeft){C.style.left=(E[0]-F[0]+D.offsetLeft)+"px"}if(D.setTop){C.style.top=(E[1]-F[1]+D.offsetTop)+"px"}if(D.setWidth){C.style.width=A.offsetWidth+"px"}if(D.setHeight){C.style.height=A.offsetHeight+"px"}return C}};Element.Methods.identify.counter=1;Object.extend(Element.Methods,{getElementsBySelector:Element.Methods.select,childElements:Element.Methods.immediateDescendants});Element._attributeTranslations={write:{names:{className:"class",htmlFor:"for"},values:{}}};if(Prototype.Browser.Opera){Element.Methods.getStyle=Element.Methods.getStyle.wrap(function(A,C,D){switch(D){case"left":case"top":case"right":case"bottom":if(A(C,"position")==="static"){return null}case"height":case"width":if(!Element.visible(C)){return null}var E=parseInt(A(C,D),10);if(E!==C["offset"+D.capitalize()]){return E+"px"}var B;if(D==="height"){B=["border-top-width","padding-top","padding-bottom","border-bottom-width"]}else{B=["border-left-width","padding-left","padding-right","border-right-width"]}return B.inject(E,function(G,F){var H=A(C,F);return H===null?G:G-parseInt(H,10)})+"px";default:return A(C,D)}});Element.Methods.readAttribute=Element.Methods.readAttribute.wrap(function(A,B,C){if(C==="title"){return B.title}return A(B,C)})}else{if(Prototype.Browser.IE){Element.Methods.getOffsetParent=Element.Methods.getOffsetParent.wrap(function(B,C){C=$(C);try{C.offsetParent}catch(E){return $(document.body)}var A=C.getStyle("position");if(A!=="static"){return B(C)}C.setStyle({position:"relative"});var D=B(C);C.setStyle({position:A});return D});$w("positionedOffset viewportOffset").each(function(A){Element.Methods[A]=Element.Methods[A].wrap(function(C,D){D=$(D);try{D.offsetParent}catch(G){return Element._returnOffset(0,0)}var B=D.getStyle("position");if(B!=="static"){return C(D)}var E=D.getOffsetParent();if(E&&E.getStyle("position")==="fixed"){E.setStyle({zoom:1})}D.setStyle({position:"relative"});var F=C(D);D.setStyle({position:B});return F})});Element.Methods.cumulativeOffset=Element.Methods.cumulativeOffset.wrap(function(A,B){try{B.offsetParent}catch(C){return Element._returnOffset(0,0)}return A(B)});Element.Methods.getStyle=function(A,B){A=$(A);B=(B=="float"||B=="cssFloat")?"styleFloat":B.camelize();var C=A.style[B];if(!C&&A.currentStyle){C=A.currentStyle[B]}if(B=="opacity"){if(C=(A.getStyle("filter")||"").match(/alpha\(opacity=(.*)\)/)){if(C[1]){return parseFloat(C[1])/100}}return 1}if(C=="auto"){if((B=="width"||B=="height")&&(A.getStyle("display")!="none")){return A["offset"+B.capitalize()]+"px"}return null}return C};Element.Methods.setOpacity=function(C,E){function F(G){return G.replace(/alpha\([^\)]*\)/gi,"")}C=$(C);var B=C.currentStyle;if((B&&!B.hasLayout)||(!B&&C.style.zoom=="normal")){C.style.zoom=1}var A=C.getStyle("filter"),D=C.style;if(E==1||E===""){(A=F(A))?D.filter=A:D.removeAttribute("filter");return C}else{if(E<0.00001){E=0}}D.filter=F(A)+"alpha(opacity="+(E*100)+")";return C};Element._attributeTranslations={read:{names:{"class":"className","for":"htmlFor"},values:{_getAttr:function(A,B){return A.getAttribute(B,2)},_getAttrNode:function(A,C){var B=A.getAttributeNode(C);return B?B.value:""},_getEv:function(A,B){B=A.getAttribute(B);return B?B.toString().slice(23,-2):null},_flag:function(A,B){return $(A).hasAttribute(B)?B:null},style:function(A){return A.style.cssText.toLowerCase()},title:function(A){return A.title}}}};Element._attributeTranslations.write={names:Object.extend({cellpadding:"cellPadding",cellspacing:"cellSpacing"},Element._attributeTranslations.read.names),values:{checked:function(A,B){A.checked=!!B},style:function(A,B){A.style.cssText=B?B:""}}};Element._attributeTranslations.has={};$w("colSpan rowSpan vAlign dateTime accessKey tabIndex encType maxLength readOnly longDesc frameBorder").each(function(A){Element._attributeTranslations.write.names[A.toLowerCase()]=A;Element._attributeTranslations.has[A.toLowerCase()]=A});(function(A){Object.extend(A,{href:A._getAttr,src:A._getAttr,type:A._getAttr,action:A._getAttrNode,disabled:A._flag,checked:A._flag,readonly:A._flag,multiple:A._flag,onload:A._getEv,onunload:A._getEv,onclick:A._getEv,ondblclick:A._getEv,onmousedown:A._getEv,onmouseup:A._getEv,onmouseover:A._getEv,onmousemove:A._getEv,onmouseout:A._getEv,onfocus:A._getEv,onblur:A._getEv,onkeypress:A._getEv,onkeydown:A._getEv,onkeyup:A._getEv,onsubmit:A._getEv,onreset:A._getEv,onselect:A._getEv,onchange:A._getEv})})(Element._attributeTranslations.read.values)}else{if(Prototype.Browser.Gecko&&/rv:1\.8\.0/.test(navigator.userAgent)){Element.Methods.setOpacity=function(A,B){A=$(A);A.style.opacity=(B==1)?0.999999:(B==="")?"":(B<0.00001)?0:B;return A}}else{if(Prototype.Browser.WebKit){Element.Methods.setOpacity=function(A,B){A=$(A);A.style.opacity=(B==1||B==="")?"":(B<0.00001)?0:B;if(B==1){if(A.tagName.toUpperCase()=="IMG"&&A.width){A.width++;A.width--}else{try{var D=document.createTextNode(" ");A.appendChild(D);A.removeChild(D)}catch(C){}}}return A};Element.Methods.cumulativeOffset=function(A){var B=0,C=0;do{B+=A.offsetTop||0;C+=A.offsetLeft||0;if(A.offsetParent==document.body){if(Element.getStyle(A,"position")=="absolute"){break}}A=A.offsetParent}while(A);return Element._returnOffset(C,B)}}}}}if(Prototype.Browser.IE||Prototype.Browser.Opera){Element.Methods.update=function(B,C){B=$(B);if(C&&C.toElement){C=C.toElement()}if(Object.isElement(C)){return B.update().insert(C)}C=Object.toHTML(C);var A=B.tagName.toUpperCase();if(A in Element._insertionTranslations.tags){$A(B.childNodes).each(function(D){B.removeChild(D)});Element._getContentFromAnonymousElement(A,C.stripScripts()).each(function(D){B.appendChild(D)})}else{B.innerHTML=C.stripScripts()}C.evalScripts.bind(C).defer();return B}}if("outerHTML" in document.createElement("div")){Element.Methods.replace=function(E,F){E=$(E);if(F&&F.toElement){F=F.toElement()}if(Object.isElement(F)){E.parentNode.replaceChild(F,E);return E}F=Object.toHTML(F);var C=E.parentNode,D=C.tagName.toUpperCase();if(Element._insertionTranslations.tags[D]){var B=E.next();var A=Element._getContentFromAnonymousElement(D,F.stripScripts());C.removeChild(E);if(B){A.each(function(G){C.insertBefore(G,B)})}else{A.each(function(G){C.appendChild(G)})}}else{E.outerHTML=F.stripScripts()}F.evalScripts.bind(F).defer();return E}}Element._returnOffset=function(A,B){var C=[A,B];C.left=A;C.top=B;return C};Element._getContentFromAnonymousElement=function(A,C){var D=new Element("div"),B=Element._insertionTranslations.tags[A];if(B){D.innerHTML=B[0]+C+B[1];B[2].times(function(){D=D.firstChild})}else{D.innerHTML=C}return $A(D.childNodes)};Element._insertionTranslations={before:function(A,B){A.parentNode.insertBefore(B,A)},top:function(A,B){A.insertBefore(B,A.firstChild)},bottom:function(A,B){A.appendChild(B)},after:function(A,B){A.parentNode.insertBefore(B,A.nextSibling)},tags:{TABLE:["<table>","</table>",1],TBODY:["<table><tbody>","</tbody></table>",2],TR:["<table><tbody><tr>","</tr></tbody></table>",3],TD:["<table><tbody><tr><td>","</td></tr></tbody></table>",4],SELECT:["<select>","</select>",1]}};(function(){Object.extend(this.tags,{THEAD:this.tags.TBODY,TFOOT:this.tags.TBODY,TH:this.tags.TD})}).call(Element._insertionTranslations);Element.Methods.Simulated={hasAttribute:function(A,C){C=Element._attributeTranslations.has[C]||C;var B=$(A).getAttributeNode(C);return !!(B&&B.specified)}};Element.Methods.ByTag={};Object.extend(Element,Element.Methods);if(!Prototype.BrowserFeatures.ElementExtensions&&document.createElement("div")["__proto__"]){window.HTMLElement={};window.HTMLElement.prototype=document.createElement("div")["__proto__"];Prototype.BrowserFeatures.ElementExtensions=true}Element.extend=(function(){if(Prototype.BrowserFeatures.SpecificElementExtensions){return Prototype.K}var B={},A=Element.Methods.ByTag;var C=Object.extend(function(G){if(!G||G._extendedByPrototype||G.nodeType!=1||G==window){return G}var E=Object.clone(B),F=G.tagName.toUpperCase(),D,H;if(A[F]){Object.extend(E,A[F])}for(D in E){H=E[D];if(Object.isFunction(H)&&!(D in G)){G[D]=H.methodize()}}G._extendedByPrototype=Prototype.emptyFunction;return G},{refresh:function(){if(!Prototype.BrowserFeatures.ElementExtensions){Object.extend(B,Element.Methods);Object.extend(B,Element.Methods.Simulated)}}});C.refresh();return C})();Element.hasAttribute=function(A,B){if(A.hasAttribute){return A.hasAttribute(B)}return Element.Methods.Simulated.hasAttribute(A,B)};Element.addMethods=function(C){var I=Prototype.BrowserFeatures,D=Element.Methods.ByTag;if(!C){Object.extend(Form,Form.Methods);Object.extend(Form.Element,Form.Element.Methods);Object.extend(Element.Methods.ByTag,{FORM:Object.clone(Form.Methods),INPUT:Object.clone(Form.Element.Methods),SELECT:Object.clone(Form.Element.Methods),TEXTAREA:Object.clone(Form.Element.Methods)})}if(arguments.length==2){var G=C;C=arguments[1]}if(!G){Object.extend(Element.Methods,C||{})}else{if(Object.isArray(G)){G.each(A)}else{A(G)}}function A(F){F=F.toUpperCase();if(!Element.Methods.ByTag[F]){Element.Methods.ByTag[F]={}}Object.extend(Element.Methods.ByTag[F],C)}function B(K,N,M){M=M||false;for(var F in K){var L=K[F];if(!Object.isFunction(L)){continue}if(!M||!(F in N)){N[F]=L.methodize()}}}function E(K){var F;var L={OPTGROUP:"OptGroup",TEXTAREA:"TextArea",P:"Paragraph",FIELDSET:"FieldSet",UL:"UList",OL:"OList",DL:"DList",DIR:"Directory",H1:"Heading",H2:"Heading",H3:"Heading",H4:"Heading",H5:"Heading",H6:"Heading",Q:"Quote",INS:"Mod",DEL:"Mod",A:"Anchor",IMG:"Image",CAPTION:"TableCaption",COL:"TableCol",COLGROUP:"TableCol",THEAD:"TableSection",TFOOT:"TableSection",TBODY:"TableSection",TR:"TableRow",TH:"TableCell",TD:"TableCell",FRAMESET:"FrameSet",IFRAME:"IFrame"};if(L[K]){F="HTML"+L[K]+"Element"}if(window[F]){return window[F]}F="HTML"+K+"Element";if(window[F]){return window[F]}F="HTML"+K.capitalize()+"Element";if(window[F]){return window[F]}window[F]={};window[F].prototype=document.createElement(K)["__proto__"];return window[F]}if(I.ElementExtensions){B(Element.Methods,HTMLElement.prototype);B(Element.Methods.Simulated,HTMLElement.prototype,true)}if(I.SpecificElementExtensions){for(var J in Element.Methods.ByTag){var H=E(J);if(Object.isUndefined(H)){continue}B(D[J],H.prototype)}}Object.extend(Element,Element.Methods);delete Element.ByTag;if(Element.extend.refresh){Element.extend.refresh()}Element.cache={}};document.viewport={getDimensions:function(){var A={},C=Prototype.Browser;$w("width height").each(function(E){var B=E.capitalize();if(C.WebKit&&!document.evaluate){A[E]=self["inner"+B]}else{if(C.Opera&&parseFloat(window.opera.version())<9.5){A[E]=document.body["client"+B]}else{A[E]=document.documentElement["client"+B]}}});return A},getWidth:function(){return this.getDimensions().width},getHeight:function(){return this.getDimensions().height},getScrollOffsets:function(){return Element._returnOffset(window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft,window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop)}};var Selector=Class.create({initialize:function(A){this.expression=A.strip();if(this.shouldUseSelectorsAPI()){this.mode="selectorsAPI"}else{if(this.shouldUseXPath()){this.mode="xpath";this.compileXPathMatcher()}else{this.mode="normal";this.compileMatcher()}}},shouldUseXPath:function(){if(!Prototype.BrowserFeatures.XPath){return false}var A=this.expression;if(Prototype.Browser.WebKit&&(A.include("-of-type")||A.include(":empty"))){return false}if((/(\[[\w-]*?:|:checked)/).test(A)){return false}return true},shouldUseSelectorsAPI:function(){if(!Prototype.BrowserFeatures.SelectorsAPI){return false}if(!Selector._div){Selector._div=new Element("div")}try{Selector._div.querySelector(this.expression)}catch(A){return false}return true},compileMatcher:function(){var e=this.expression,ps=Selector.patterns,h=Selector.handlers,c=Selector.criteria,le,p,m;if(Selector._cache[e]){this.matcher=Selector._cache[e];return }this.matcher=["this.matcher = function(root) {","var r = root, h = Selector.handlers, c = false, n;"];while(e&&le!=e&&(/\S/).test(e)){le=e;for(var i in ps){p=ps[i];if(m=e.match(p)){this.matcher.push(Object.isFunction(c[i])?c[i](m):new Template(c[i]).evaluate(m));e=e.replace(m[0],"");break}}}this.matcher.push("return h.unique(n);\n}");eval(this.matcher.join("\n"));Selector._cache[this.expression]=this.matcher},compileXPathMatcher:function(){var E=this.expression,F=Selector.patterns,B=Selector.xpath,D,A;if(Selector._cache[E]){this.xpath=Selector._cache[E];return }this.matcher=[".//*"];while(E&&D!=E&&(/\S/).test(E)){D=E;for(var C in F){if(A=E.match(F[C])){this.matcher.push(Object.isFunction(B[C])?B[C](A):new Template(B[C]).evaluate(A));E=E.replace(A[0],"");break}}}this.xpath=this.matcher.join("");Selector._cache[this.expression]=this.xpath},findElements:function(A){A=A||document;var C=this.expression,B;switch(this.mode){case"selectorsAPI":if(A!==document){var D=A.id,E=$(A).identify();C="#"+E+" "+C}B=$A(A.querySelectorAll(C)).map(Element.extend);A.id=D;return B;case"xpath":return document._getElementsByXPath(this.xpath,A);default:return this.matcher(A)}},match:function(H){this.tokens=[];var L=this.expression,B=Selector.patterns,F=Selector.assertions;var A,D,E;while(L&&A!==L&&(/\S/).test(L)){A=L;for(var I in B){D=B[I];if(E=L.match(D)){if(F[I]){this.tokens.push([I,Object.clone(E)]);L=L.replace(E[0],"")}else{return this.findElements(document).include(H)}}}}var K=true,C,J;for(var I=0,G;G=this.tokens[I];I++){C=G[0],J=G[1];if(!Selector.assertions[C](H,J)){K=false;break}}return K},toString:function(){return this.expression},inspect:function(){return"#<Selector:"+this.expression.inspect()+">"}});Object.extend(Selector,{_cache:{},xpath:{descendant:"//*",child:"/*",adjacent:"/following-sibling::*[1]",laterSibling:"/following-sibling::*",tagName:function(A){if(A[1]=="*"){return""}return"[local-name()='"+A[1].toLowerCase()+"' or local-name()='"+A[1].toUpperCase()+"']"},className:"[contains(concat(' ', @class, ' '), ' #{1} ')]",id:"[@id='#{1}']",attrPresence:function(A){A[1]=A[1].toLowerCase();return new Template("[@#{1}]").evaluate(A)},attr:function(A){A[1]=A[1].toLowerCase();A[3]=A[5]||A[6];return new Template(Selector.xpath.operators[A[2]]).evaluate(A)},pseudo:function(A){var B=Selector.xpath.pseudos[A[1]];if(!B){return""}if(Object.isFunction(B)){return B(A)}return new Template(Selector.xpath.pseudos[A[1]]).evaluate(A)},operators:{"=":"[@#{1}='#{3}']","!=":"[@#{1}!='#{3}']","^=":"[starts-with(@#{1}, '#{3}')]","$=":"[substring(@#{1}, (string-length(@#{1}) - string-length('#{3}') + 1))='#{3}']","*=":"[contains(@#{1}, '#{3}')]","~=":"[contains(concat(' ', @#{1}, ' '), ' #{3} ')]","|=":"[contains(concat('-', @#{1}, '-'), '-#{3}-')]"},pseudos:{"first-child":"[not(preceding-sibling::*)]","last-child":"[not(following-sibling::*)]","only-child":"[not(preceding-sibling::* or following-sibling::*)]",empty:"[count(*) = 0 and (count(text()) = 0)]",checked:"[@checked]",disabled:"[(@disabled) and (@type!='hidden')]",enabled:"[not(@disabled) and (@type!='hidden')]",not:function(B){var H=B[6],G=Selector.patterns,A=Selector.xpath,E,C;var F=[];while(H&&E!=H&&(/\S/).test(H)){E=H;for(var D in G){if(B=H.match(G[D])){C=Object.isFunction(A[D])?A[D](B):new Template(A[D]).evaluate(B);F.push("("+C.substring(1,C.length-1)+")");H=H.replace(B[0],"");break}}}return"[not("+F.join(" and ")+")]"},"nth-child":function(A){return Selector.xpath.pseudos.nth("(count(./preceding-sibling::*) + 1) ",A)},"nth-last-child":function(A){return Selector.xpath.pseudos.nth("(count(./following-sibling::*) + 1) ",A)},"nth-of-type":function(A){return Selector.xpath.pseudos.nth("position() ",A)},"nth-last-of-type":function(A){return Selector.xpath.pseudos.nth("(last() + 1 - position()) ",A)},"first-of-type":function(A){A[6]="1";return Selector.xpath.pseudos["nth-of-type"](A)},"last-of-type":function(A){A[6]="1";return Selector.xpath.pseudos["nth-last-of-type"](A)},"only-of-type":function(A){var B=Selector.xpath.pseudos;return B["first-of-type"](A)+B["last-of-type"](A)},nth:function(D,B){var G,F=B[6],E;if(F=="even"){F="2n+0"}if(F=="odd"){F="2n+1"}if(G=F.match(/^(\d+)$/)){return"["+D+"= "+G[1]+"]"}if(G=F.match(/^(-?\d*)?n(([+-])(\d+))?/)){if(G[1]=="-"){G[1]=-1}var C=G[1]?Number(G[1]):1;var A=G[2]?Number(G[2]):0;E="[((#{fragment} - #{b}) mod #{a} = 0) and ((#{fragment} - #{b}) div #{a} >= 0)]";return new Template(E).evaluate({fragment:D,a:C,b:A})}}}},criteria:{tagName:'n = h.tagName(n, r, "#{1}", c);      c = false;',className:'n = h.className(n, r, "#{1}", c);    c = false;',id:'n = h.id(n, r, "#{1}", c);           c = false;',attrPresence:'n = h.attrPresence(n, r, "#{1}", c); c = false;',attr:function(A){A[3]=(A[5]||A[6]);return new Template('n = h.attr(n, r, "#{1}", "#{3}", "#{2}", c); c = false;').evaluate(A)},pseudo:function(A){if(A[6]){A[6]=A[6].replace(/"/g,'\\"')}return new Template('n = h.pseudo(n, "#{1}", "#{6}", r, c); c = false;').evaluate(A)},descendant:'c = "descendant";',child:'c = "child";',adjacent:'c = "adjacent";',laterSibling:'c = "laterSibling";'},patterns:{laterSibling:/^\s*~\s*/,child:/^\s*>\s*/,adjacent:/^\s*\+\s*/,descendant:/^\s/,tagName:/^\s*(\*|[\w\-]+)(\b|$)?/,id:/^#([\w\-\*]+)(\b|$)/,className:/^\.([\w\-\*]+)(\b|$)/,pseudo:/^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|(?=\s|[:+~>]))/,attrPresence:/^\[((?:[\w]+:)?[\w]+)\]/,attr:/\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\4]*?)\4|([^'"][^\]]*?)))?\]/},assertions:{tagName:function(A,B){return B[1].toUpperCase()==A.tagName.toUpperCase()},className:function(A,B){return Element.hasClassName(A,B[1])},id:function(A,B){return A.id===B[1]},attrPresence:function(A,B){return Element.hasAttribute(A,B[1])},attr:function(B,C){var A=Element.readAttribute(B,C[1]);return A&&Selector.operators[C[2]](A,C[5]||C[6])}},handlers:{concat:function(B,A){for(var C=0,D;D=A[C];C++){B.push(D)}return B},mark:function(A){var D=Prototype.emptyFunction;for(var B=0,C;C=A[B];B++){C._countedByPrototype=D}return A},unmark:function(A){for(var B=0,C;C=A[B];B++){C._countedByPrototype=undefined}return A},index:function(F,C,G){F._countedByPrototype=Prototype.emptyFunction;if(C){for(var A=F.childNodes,D=A.length-1,B=1;D>=0;D--){var E=A[D];if(E.nodeType==1&&(!G||E._countedByPrototype)){E.nodeIndex=B++}}}else{for(var D=0,B=1,A=F.childNodes;E=A[D];D++){if(E.nodeType==1&&(!G||E._countedByPrototype)){E.nodeIndex=B++}}}},unique:function(B){if(B.length==0){return B}var D=[],E;for(var C=0,A=B.length;C<A;C++){if(!(E=B[C])._countedByPrototype){E._countedByPrototype=Prototype.emptyFunction;D.push(Element.extend(E))}}return Selector.handlers.unmark(D)},descendant:function(A){var D=Selector.handlers;for(var C=0,B=[],E;E=A[C];C++){D.concat(B,E.getElementsByTagName("*"))}return B},child:function(A){var E=Selector.handlers;for(var D=0,C=[],F;F=A[D];D++){for(var B=0,G;G=F.childNodes[B];B++){if(G.nodeType==1&&G.tagName!="!"){C.push(G)}}}return C},adjacent:function(A){for(var C=0,B=[],E;E=A[C];C++){var D=this.nextElementSibling(E);if(D){B.push(D)}}return B},laterSibling:function(A){var D=Selector.handlers;for(var C=0,B=[],E;E=A[C];C++){D.concat(B,Element.nextSiblings(E))}return B},nextElementSibling:function(A){while(A=A.nextSibling){if(A.nodeType==1){return A}}return null},previousElementSibling:function(A){while(A=A.previousSibling){if(A.nodeType==1){return A}}return null},tagName:function(A,H,F,G){var I=F.toUpperCase();var D=[],E=Selector.handlers;if(A){if(G){if(G=="descendant"){for(var C=0,B;B=A[C];C++){E.concat(D,B.getElementsByTagName(F))}return D}else{A=this[G](A)}if(F=="*"){return A}}for(var C=0,B;B=A[C];C++){if(B.tagName.toUpperCase()===I){D.push(B)}}return D}else{return H.getElementsByTagName(F)}},id:function(C,B,H,A){var G=$(H),E=Selector.handlers;if(!G){return[]}if(!C&&B==document){return[G]}if(C){if(A){if(A=="child"){for(var D=0,F;F=C[D];D++){if(G.parentNode==F){return[G]}}}else{if(A=="descendant"){for(var D=0,F;F=C[D];D++){if(Element.descendantOf(G,F)){return[G]}}}else{if(A=="adjacent"){for(var D=0,F;F=C[D];D++){if(Selector.handlers.previousElementSibling(G)==F){return[G]}}}else{C=E[A](C)}}}}for(var D=0,F;F=C[D];D++){if(F==G){return[G]}}return[]}return(G&&Element.descendantOf(G,B))?[G]:[]},className:function(D,B,C,A){if(D&&A){D=this[A](D)}return Selector.handlers.byClassName(D,B,C)},byClassName:function(C,A,B){if(!C){C=Selector.handlers.descendant([A])}var H=" "+B+" ";for(var E=0,D=[],G,F;G=C[E];E++){F=G.className;if(F.length==0){continue}if(F==B||(" "+F+" ").include(H)){D.push(G)}}return D},attrPresence:function(D,C,A,B){if(!D){D=C.getElementsByTagName("*")}if(D&&B){D=this[B](D)}var F=[];for(var E=0,G;G=D[E];E++){if(Element.hasAttribute(G,A)){F.push(G)}}return F},attr:function(A,I,H,J,G,F){if(!A){A=I.getElementsByTagName("*")}if(A&&F){A=this[F](A)}var K=Selector.operators[G],D=[];for(var C=0,B;B=A[C];C++){var E=Element.readAttribute(B,H);if(E===null){continue}if(K(E,J)){D.push(B)}}return D},pseudo:function(C,D,E,B,A){if(C&&A){C=this[A](C)}if(!C){C=B.getElementsByTagName("*")}return Selector.pseudos[D](C,E,B)}},pseudos:{"first-child":function(B,F,A){for(var D=0,C=[],E;E=B[D];D++){if(Selector.handlers.previousElementSibling(E)){continue}C.push(E)}return C},"last-child":function(B,F,A){for(var D=0,C=[],E;E=B[D];D++){if(Selector.handlers.nextElementSibling(E)){continue}C.push(E)}return C},"only-child":function(B,G,A){var E=Selector.handlers;for(var D=0,C=[],F;F=B[D];D++){if(!E.previousElementSibling(F)&&!E.nextElementSibling(F)){C.push(F)}}return C},"nth-child":function(B,C,A){return Selector.pseudos.nth(B,C,A)},"nth-last-child":function(B,C,A){return Selector.pseudos.nth(B,C,A,true)},"nth-of-type":function(B,C,A){return Selector.pseudos.nth(B,C,A,false,true)},"nth-last-of-type":function(B,C,A){return Selector.pseudos.nth(B,C,A,true,true)},"first-of-type":function(B,C,A){return Selector.pseudos.nth(B,"1",A,false,true)},"last-of-type":function(B,C,A){return Selector.pseudos.nth(B,"1",A,true,true)},"only-of-type":function(B,D,A){var C=Selector.pseudos;return C["last-of-type"](C["first-of-type"](B,D,A),D,A)},getIndices:function(B,A,C){if(B==0){return A>0?[A]:[]}return $R(1,C).inject([],function(D,E){if(0==(E-A)%B&&(E-A)/B>=0){D.push(E)}return D})},nth:function(A,B,N,L,K){if(A.length==0){return[]}if(B=="even"){B="2n+0"}if(B=="odd"){B="2n+1"}var J=Selector.handlers,I=[],C=[],E;J.mark(A);for(var H=0,D;D=A[H];H++){if(!D.parentNode._countedByPrototype){J.index(D.parentNode,L,K);C.push(D.parentNode)}}if(B.match(/^\d+$/)){B=Number(B);for(var H=0,D;D=A[H];H++){if(D.nodeIndex==B){I.push(D)}}}else{if(E=B.match(/^(-?\d*)?n(([+-])(\d+))?/)){if(E[1]=="-"){E[1]=-1}var O=E[1]?Number(E[1]):1;var M=E[2]?Number(E[2]):0;var P=Selector.pseudos.getIndices(O,M,A.length);for(var H=0,D,F=P.length;D=A[H];H++){for(var G=0;G<F;G++){if(D.nodeIndex==P[G]){I.push(D)}}}}}J.unmark(A);J.unmark(C);return I},empty:function(B,F,A){for(var D=0,C=[],E;E=B[D];D++){if(E.tagName=="!"||E.firstChild){continue}C.push(E)}return C},not:function(A,D,I){var G=Selector.handlers,J,C;var H=new Selector(D).findElements(I);G.mark(H);for(var F=0,E=[],B;B=A[F];F++){if(!B._countedByPrototype){E.push(B)}}G.unmark(H);return E},enabled:function(B,F,A){for(var D=0,C=[],E;E=B[D];D++){if(!E.disabled&&(!E.type||E.type!=="hidden")){C.push(E)}}return C},disabled:function(B,F,A){for(var D=0,C=[],E;E=B[D];D++){if(E.disabled){C.push(E)}}return C},checked:function(B,F,A){for(var D=0,C=[],E;E=B[D];D++){if(E.checked){C.push(E)}}return C}},operators:{"=":function(B,A){return B==A},"!=":function(B,A){return B!=A},"^=":function(B,A){return B==A||B&&B.startsWith(A)},"$=":function(B,A){return B==A||B&&B.endsWith(A)},"*=":function(B,A){return B==A||B&&B.include(A)},"$=":function(B,A){return B.endsWith(A)},"*=":function(B,A){return B.include(A)},"~=":function(B,A){return(" "+B+" ").include(" "+A+" ")},"|=":function(B,A){return("-"+(B||"").toUpperCase()+"-").include("-"+(A||"").toUpperCase()+"-")}},split:function(B){var A=[];B.scan(/(([\w#:.~>+()\s-]+|\*|\[.*?\])+)\s*(,|$)/,function(C){A.push(C[1].strip())});return A},matchElements:function(A,G){var F=$$(G),E=Selector.handlers;E.mark(F);for(var D=0,C=[],B;B=A[D];D++){if(B._countedByPrototype){C.push(B)}}E.unmark(F);return C},findElement:function(A,C,B){if(Object.isNumber(C)){B=C;C=false}return Selector.matchElements(A,C||"*")[B||0]},findChildElements:function(C,G){G=Selector.split(G.join(","));var E=[],F=Selector.handlers;for(var D=0,B=G.length,A;D<B;D++){A=new Selector(G[D].strip());F.concat(E,A.findElements(C))}return(B>1)?F.unique(E):E}});if(Prototype.Browser.IE){Object.extend(Selector.handlers,{concat:function(B,A){for(var C=0,D;D=A[C];C++){if(D.tagName!=="!"){B.push(D)}}return B},unmark:function(A){for(var B=0,C;C=A[B];B++){C.removeAttribute("_countedByPrototype")}return A}})}function $$(){return Selector.findChildElements(document,$A(arguments))}var Form={reset:function(A){$(A).reset();return A},serializeElements:function(C,E){if(typeof E!="object"){E={hash:!!E}}else{if(Object.isUndefined(E.hash)){E.hash=true}}var D,G,B=false,A=E.submit;var F=C.inject({},function(I,H){if(!H.disabled&&H.name){D=H.name;G=$(H).getValue();if(G!=null&&H.type!="file"&&(H.type!="submit"||(!B&&A!==false&&(!A||D==A)&&(B=true)))){if(D in I){if(!Object.isArray(I[D])){I[D]=[I[D]]}I[D].push(G)}else{I[D]=G}}}return I});return E.hash?F:Object.toQueryString(F)}};Form.Methods={serialize:function(B,A){return Form.serializeElements(Form.getElements(B),A)},getElements:function(A){return $A($(A).getElementsByTagName("*")).inject([],function(B,C){if(Form.Element.Serializers[C.tagName.toLowerCase()]){B.push(Element.extend(C))}return B})},getInputs:function(G,E,C){G=$(G);var F=G.getElementsByTagName("input");if(!E&&!C){return $A(F).map(Element.extend)}for(var D=0,H=[],A=F.length;D<A;D++){var B=F[D];if((E&&B.type!=E)||(C&&B.name!=C)){continue}H.push(Element.extend(B))}return H},disable:function(A){A=$(A);Form.getElements(A).invoke("disable");return A},enable:function(A){A=$(A);Form.getElements(A).invoke("enable");return A},findFirstElement:function(C){var A=$(C).getElements().findAll(function(D){return"hidden"!=D.type&&!D.disabled});var B=A.findAll(function(D){return D.hasAttribute("tabIndex")&&D.tabIndex>=0}).sortBy(function(D){return D.tabIndex}).first();return B?B:A.find(function(D){return["input","select","textarea"].include(D.tagName.toLowerCase())})},focusFirstElement:function(A){A=$(A);A.findFirstElement().activate();return A},request:function(C,B){C=$(C),B=Object.clone(B||{});var D=B.parameters,A=C.readAttribute("action")||"";if(A.blank()){A=window.location.href}B.parameters=C.serialize(true);if(D){if(Object.isString(D)){D=D.toQueryParams()}Object.extend(B.parameters,D)}if(C.hasAttribute("method")&&!B.method){B.method=C.method}return new Ajax.Request(A,B)}};Form.Element={focus:function(A){$(A).focus();return A},select:function(A){$(A).select();return A}};Form.Element.Methods={serialize:function(A){A=$(A);if(!A.disabled&&A.name){var B=A.getValue();if(B!=undefined){var C={};C[A.name]=B;return Object.toQueryString(C)}}return""},getValue:function(A){A=$(A);var B=A.tagName.toLowerCase();return Form.Element.Serializers[B](A)},setValue:function(A,B){A=$(A);var C=A.tagName.toLowerCase();Form.Element.Serializers[C](A,B);return A},clear:function(A){$(A).value="";return A},present:function(A){return $(A).value!=""},activate:function(A){A=$(A);try{A.focus();if(A.select&&(A.tagName.toLowerCase()!="input"||!["button","reset","submit"].include(A.type))){A.select()}}catch(B){}return A},disable:function(A){A=$(A);A.disabled=true;return A},enable:function(A){A=$(A);A.disabled=false;return A}};var Field=Form.Element;var $F=Form.Element.Methods.getValue;Form.Element.Serializers={input:function(A,B){switch(A.type.toLowerCase()){case"checkbox":case"radio":return Form.Element.Serializers.inputSelector(A,B);default:return Form.Element.Serializers.textarea(A,B)}},inputSelector:function(A,B){if(Object.isUndefined(B)){return A.checked?A.value:null}else{A.checked=!!B}},textarea:function(A,B){if(Object.isUndefined(B)){return A.value}else{A.value=B}},select:function(B,F){if(Object.isUndefined(F)){return this[B.type=="select-one"?"selectOne":"selectMany"](B)}else{var D,E,G=!Object.isArray(F);for(var C=0,A=B.length;C<A;C++){D=B.options[C];E=this.optionValue(D);if(G){if(E==F){D.selected=true;return }}else{D.selected=F.include(E)}}}},selectOne:function(B){var A=B.selectedIndex;return A>=0?this.optionValue(B.options[A]):null},selectMany:function(B){var E,A=B.length;if(!A){return null}for(var D=0,E=[];D<A;D++){var C=B.options[D];if(C.selected){E.push(this.optionValue(C))}}return E},optionValue:function(A){return Element.extend(A).hasAttribute("value")?A.value:A.text}};Abstract.TimedObserver=Class.create(PeriodicalExecuter,{initialize:function($super,A,C,B){$super(B,C);this.element=$(A);this.lastValue=this.getValue()},execute:function(){var A=this.getValue();if(Object.isString(this.lastValue)&&Object.isString(A)?this.lastValue!=A:String(this.lastValue)!=String(A)){this.callback(this.element,A);this.lastValue=A}}});Form.Element.Observer=Class.create(Abstract.TimedObserver,{getValue:function(){return Form.Element.getValue(this.element)}});Form.Observer=Class.create(Abstract.TimedObserver,{getValue:function(){return Form.serialize(this.element)}});Abstract.EventObserver=Class.create({initialize:function(A,B){this.element=$(A);this.callback=B;this.lastValue=this.getValue();if(this.element.tagName.toLowerCase()=="form"){this.registerFormCallbacks()}else{this.registerCallback(this.element)}},onElementEvent:function(){var A=this.getValue();if(this.lastValue!=A){this.callback(this.element,A);this.lastValue=A}},registerFormCallbacks:function(){Form.getElements(this.element).each(this.registerCallback,this)},registerCallback:function(A){if(A.type){switch(A.type.toLowerCase()){case"checkbox":case"radio":Event.observe(A,"click",this.onElementEvent.bind(this));break;default:Event.observe(A,"change",this.onElementEvent.bind(this));break}}}});Form.Element.EventObserver=Class.create(Abstract.EventObserver,{getValue:function(){return Form.Element.getValue(this.element)}});Form.EventObserver=Class.create(Abstract.EventObserver,{getValue:function(){return Form.serialize(this.element)}});if(!window.Event){var Event={}}Object.extend(Event,{KEY_BACKSPACE:8,KEY_TAB:9,KEY_RETURN:13,KEY_ESC:27,KEY_LEFT:37,KEY_UP:38,KEY_RIGHT:39,KEY_DOWN:40,KEY_DELETE:46,KEY_HOME:36,KEY_END:35,KEY_PAGEUP:33,KEY_PAGEDOWN:34,KEY_INSERT:45,cache:{},relatedTarget:function(B){var A;switch(B.type){case"mouseover":A=B.fromElement;break;case"mouseout":A=B.toElement;break;default:return null}return Element.extend(A)}});Event.Methods=(function(){var B;if(Prototype.Browser.IE){var A={0:1,1:4,2:2};B=function(D,C){return D.button==A[C]}}else{if(Prototype.Browser.WebKit){B=function(D,C){switch(C){case 0:return D.which==1&&!D.metaKey;case 1:return D.which==1&&D.metaKey;default:return false}}}else{B=function(D,C){return D.which?(D.which===C+1):(D.button===C)}}}return{isLeftClick:function(C){return B(C,0)},isMiddleClick:function(C){return B(C,1)},isRightClick:function(C){return B(C,2)},element:function(E){E=Event.extend(E);var D=E.target,C=E.type,F=E.currentTarget;if(F&&F.tagName){if(C==="load"||C==="error"||(C==="click"&&F.tagName.toLowerCase()==="input"&&F.type==="radio")){D=F}}if(D.nodeType==Node.TEXT_NODE){D=D.parentNode}return Element.extend(D)},findElement:function(E,F){var D=Event.element(E);if(!F){return D}var C=[D].concat(D.ancestors());return Selector.findElement(C,F,0)},pointer:function(E){var D=document.documentElement,C=document.body||{scrollLeft:0,scrollTop:0};return{x:E.pageX||(E.clientX+(D.scrollLeft||C.scrollLeft)-(D.clientLeft||0)),y:E.pageY||(E.clientY+(D.scrollTop||C.scrollTop)-(D.clientTop||0))}},pointerX:function(C){return Event.pointer(C).x},pointerY:function(C){return Event.pointer(C).y},stop:function(C){Event.extend(C);C.preventDefault();C.stopPropagation();C.stopped=true}}})();Event.extend=(function(){var A=Object.keys(Event.Methods).inject({},function(B,C){B[C]=Event.Methods[C].methodize();return B});if(Prototype.Browser.IE){Object.extend(A,{stopPropagation:function(){this.cancelBubble=true},preventDefault:function(){this.returnValue=false},inspect:function(){return"[object Event]"}});return function(B){if(!B){return false}if(B._extendedByPrototype){return B}B._extendedByPrototype=Prototype.emptyFunction;var C=Event.pointer(B);Object.extend(B,{target:B.srcElement,relatedTarget:Event.relatedTarget(B),pageX:C.x,pageY:C.y});return Object.extend(B,A)}}else{Event.prototype=Event.prototype||document.createEvent("HTMLEvents")["__proto__"];Object.extend(Event.prototype,A);return Prototype.K}})();Object.extend(Event,(function(){var A=Event.cache;function D(J){if(J._prototypeEventID){return J._prototypeEventID[0]}arguments.callee.id=arguments.callee.id||1;return J._prototypeEventID=[++arguments.callee.id]}function E(J){if(J&&J.include(":")){return"dataavailable"}return J}function G(J){return A[J]=A[J]||{}}function F(L,J){var K=G(L);return K[J]=K[J]||[]}function I(K,J,L){var O=D(K);var N=F(O,J);if(N.pluck("handler").include(L)){return false}var M=function(P){if(!Event||!Event.extend||(P.eventName&&P.eventName!=J)){return false}Event.extend(P);L.call(K,P)};M.handler=L;N.push(M);return M}function H(M,J,K){var L=F(M,J);return L.find(function(N){return N.handler==K})}function B(M,J,K){var L=G(M);if(!L[J]){return false}L[J]=L[J].without(H(M,J,K))}function C(){for(var K in A){for(var J in A[K]){A[K][J]=null}}}if(window.attachEvent){window.attachEvent("onunload",C)}if(Prototype.Browser.WebKit){window.addEventListener("unload",Prototype.emptyFunction,false)}return{observe:function(L,J,M){L=$(L);var K=E(J);var N=I(L,J,M);if(!N){return L}if(L.addEventListener){L.addEventListener(K,N,false)}else{L.attachEvent("on"+K,N)}return L},stopObserving:function(L,J,M){L=$(L);var O=D(L),K=E(J);if(!M&&J){F(O,J).each(function(P){L.stopObserving(J,P.handler)});return L}else{if(!J){Object.keys(G(O)).each(function(P){L.stopObserving(P)});return L}}var N=H(O,J,M);if(!N){return L}if(L.removeEventListener){L.removeEventListener(K,N,false)}else{L.detachEvent("on"+K,N)}B(O,J,M);return L},fire:function(L,K,J){L=$(L);if(L==document&&document.createEvent&&!L.dispatchEvent){L=document.documentElement}var M;if(document.createEvent){M=document.createEvent("HTMLEvents");M.initEvent("dataavailable",true,true)}else{M=document.createEventObject();M.eventType="ondataavailable"}M.eventName=K;M.memo=J||{};if(document.createEvent){L.dispatchEvent(M)}else{L.fireEvent(M.eventType,M)}return Event.extend(M)}}})());Object.extend(Event,Event.Methods);Element.addMethods({fire:Event.fire,observe:Event.observe,stopObserving:Event.stopObserving});Object.extend(document,{fire:Element.Methods.fire.methodize(),observe:Element.Methods.observe.methodize(),stopObserving:Element.Methods.stopObserving.methodize(),loaded:false});(function(){var B;function A(){if(document.loaded){return }if(B){window.clearInterval(B)}document.fire("dom:loaded");document.loaded=true}if(document.addEventListener){if(Prototype.Browser.WebKit){B=window.setInterval(function(){if(/loaded|complete/.test(document.readyState)){A()}},0);Event.observe(window,"load",A)}else{document.addEventListener("DOMContentLoaded",A,false)}}else{document.write("<script id=__onDOMContentLoaded defer src=//:><\/script>");$("__onDOMContentLoaded").onreadystatechange=function(){if(this.readyState=="complete"){this.onreadystatechange=null;A()}}}})();Hash.toQueryString=Object.toQueryString;var Toggle={display:Element.toggle};Element.Methods.childOf=Element.Methods.descendantOf;var Insertion={Before:function(A,B){return Element.insert(A,{before:B})},Top:function(A,B){return Element.insert(A,{top:B})},Bottom:function(A,B){return Element.insert(A,{bottom:B})},After:function(A,B){return Element.insert(A,{after:B})}};var $continue=new Error('"throw $continue" is deprecated, use "return" instead');var Position={includeScrollOffsets:false,prepare:function(){this.deltaX=window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0;this.deltaY=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0},within:function(B,A,C){if(this.includeScrollOffsets){return this.withinIncludingScrolloffsets(B,A,C)}this.xcomp=A;this.ycomp=C;this.offset=Element.cumulativeOffset(B);return(C>=this.offset[1]&&C<this.offset[1]+B.offsetHeight&&A>=this.offset[0]&&A<this.offset[0]+B.offsetWidth)},withinIncludingScrolloffsets:function(B,A,D){var C=Element.cumulativeScrollOffset(B);this.xcomp=A+C[0]-this.deltaX;this.ycomp=D+C[1]-this.deltaY;this.offset=Element.cumulativeOffset(B);return(this.ycomp>=this.offset[1]&&this.ycomp<this.offset[1]+B.offsetHeight&&this.xcomp>=this.offset[0]&&this.xcomp<this.offset[0]+B.offsetWidth)},overlap:function(B,A){if(!B){return 0}if(B=="vertical"){return((this.offset[1]+A.offsetHeight)-this.ycomp)/A.offsetHeight}if(B=="horizontal"){return((this.offset[0]+A.offsetWidth)-this.xcomp)/A.offsetWidth}},cumulativeOffset:Element.Methods.cumulativeOffset,positionedOffset:Element.Methods.positionedOffset,absolutize:function(A){Position.prepare();return Element.absolutize(A)},relativize:function(A){Position.prepare();return Element.relativize(A)},realOffset:Element.Methods.cumulativeScrollOffset,offsetParent:Element.Methods.getOffsetParent,page:Element.Methods.viewportOffset,clone:function(A,C,B){B=B||{};return Element.clonePosition(C,A,B)}};if(!document.getElementsByClassName){document.getElementsByClassName=function(B){function A(C){return C.blank()?null:"[contains(concat(' ', @class, ' '), ' "+C+" ')]"}B.getElementsByClassName=Prototype.BrowserFeatures.XPath?function(D,C){C=C.toString().strip();var E=/\s/.test(C)?$w(C).map(A).join(""):A(C);return E?document._getElementsByXPath(".//*"+E,D):[]}:function(F,E){E=E.toString().strip();var C=[],H=(/\s/.test(E)?$w(E):null);if(!H&&!E){return C}var D=$(F).getElementsByTagName("*");E=" "+E+" ";for(var G=0,J,I;J=D[G];G++){if(J.className&&(I=" "+J.className+" ")&&(I.include(E)||(H&&H.all(function(K){return !K.toString().blank()&&I.include(" "+K+" ")})))){C.push(Element.extend(J))}}return C};return function(C,D){return $(D||document.body).getElementsByClassName(C)}}(Element.Methods)}Element.ClassNames=Class.create();Element.ClassNames.prototype={initialize:function(A){this.element=$(A)},_each:function(A){this.element.className.split(/\s+/).select(function(B){return B.length>0})._each(A)},set:function(A){this.element.className=A},add:function(A){if(this.include(A)){return }this.set($A(this).concat(A).join(" "))},remove:function(A){if(!this.include(A)){return }this.set($A(this).without(A).join(" "))},toString:function(){return $A(this).join(" ")}};Object.extend(Element.ClassNames.prototype,Enumerable);Element.addMethods();Object.extend(Ajax.Request.prototype,{isSameOrigin:function(){var A=this.url.match(/^\s*https?:\/\/[^\/]*/);return !A||(A[0]=="#{protocol}//#{domain}#{port}".interpolate({protocol:location.protocol,domain:window.location.host,port:location.port?":"+location.port:""}))}});ComCore.Configuration={get:function(A,B){if(B&&(B.length>0)){if(ComCore.configValues[A]&&ComCore.configValues[A][B]){return ComCore.configValues[A][B]}return false}else{if(ComCore.configValues[A]){return ComCore.configValues[A]}}return false}};ComCore.Debug={debugData:[],startDate:new Date(),log:function(A,D){if(ComCore.Configuration.get("debug")){try{if(!D){D="log"}var B=new Date();ComCore.Debug.debugData[ComCore.Debug.debugData.length]={t:B.getTime(),m:A,type:D};if(window.console){if(typeof (A)=="string"){B=new Date();A="["+B.getHours()+":"+B.getMinutes()+":"+B.getSeconds()+"."+B.getMilliseconds()+"] "+A}if(D=="info"){window.console.info(A)}else{if(D=="warning"){window.console.warn(A)}else{if(D=="error"){window.console.error(A)}else{window.console.log(A)}}}}}catch(C){}}}};function debug(A){ComCore.Debug.log(A)}ComCore.Page={defaults:[],get:function(A){return ComCore.Page.defaults[A]},getContextURL:function(){var A="";if(ComCore.Page.get("contextUrl")){A+=ComCore.Page.get("contextUrl")}else{A+="/go"}return A},getOwnerContextURL:function(){return"/go"},_eoo:true,splashBanner:false};ComCore.Profile={};ComCore.Message={_hide:function(){var A=$A(arguments);if(A.size()>0){A.each(function(B){$("content").select("div."+B).invoke("hide")})}},hideAll:function(){ComCore.Message._hide("success","warning","error")},hideSuccess:function(){ComCore.Message._hide("success")},hideWarning:function(){ComCore.Message._hide("warning")},hideError:function(){ComCore.Message._hide("error")},_eoo:true};ComCore.Events={extend:function(A){A._objectEventSetup=function(B){this._observers=this._observers||{};this._observers[B]=this._observers[B]||[]};A.observe=function(D,B){if(typeof (D)=="string"&&typeof (B)!="undefined"){this._objectEventSetup(D);if(!this._observers[D].include(B)){this._observers[D].push(B)}}else{for(var C in D){if(D){this.observe(C,D[C])}}}};A.stopObserving=function(C,B){this._objectEventSetup(C);if(C&&B){this._observers[C]=this._observers[C].without(B)}else{if(C){this._observers[C]=[]}else{this._observers={}}}};A.observeOnce=function(D,C){var B=function(){C.apply(this,arguments);this.stopObserving(D,B)}.bind(this);this._objectEventSetup(D);this._observers[D].push(B)};A.notify=function(F){this._objectEventSetup(F);var D=[];var B=$A(arguments).slice(1);try{for(var C=0;C<this._observers[F].length;++C){D.push(this._observers[F][C].apply(this._observers[F][C],B)||null)}}catch(E){if(E==$break){return false}else{throw E}}return D};if(A.prototype){A.prototype._objectEventSetup=A._objectEventSetup;A.prototype.observe=A.observe;A.prototype.stopObserving=A.stopObserving;A.prototype.observeOnce=A.observeOnce;A.prototype.notify=function(F){var B=null;if(A.notify){B=$A(arguments).slice(1);B.unshift(this);B.unshift(F);A.notify.apply(A,B)}this._objectEventSetup(F);B=$A(arguments).slice(1);var D=[];try{if(this.options&&this.options[F]&&typeof (this.options[F])=="function"){D.push(this.options[F].apply(this,B)||null)}for(var C=0;C<this._observers[F].length;++C){D.push(this._observers[F][C].apply(this._observers[F][C],B)||null)}}catch(E){if(E==$break){return false}else{throw E}}return D}}}};ComCore.Queuer={functions:[],add:function(A,B){ComCore.Queuer.functions[ComCore.Queuer.functions.length]={name:A,onwindowload:B}}};ComCore.CSRF={showStandardMessage:true,setToken:function(A,B){try{$$('input.csrftoken[name="csrftoken_'+A.toLowerCase()+'"]').first().value=B;return true}catch(C){debug(C);return false}},getToken:function(A){try{return $$('input.csrftoken[name="csrftoken_'+A.toLowerCase()+'"]').first().value}catch(B){debug(B);return""}},getParam:function(A,B){return"csrftoken_"+A.toLowerCase()+"="+this.getToken(A,B)+(B?"&getNewToken=1":"")},onInvalidToken:function(B,A){if(this.showStandardMessage){ComCore.MessageBox.error(A.responseText+(A.getHeader("X-Debug-Csrf")?A.getHeader("X-Debug-Csrf"):""))}else{this.enableStandardMessage()}},disableStandardMessage:function(){this.showStandardMessage=false},enableStandardMessage:function(){this.showStandardMessage=true}};function comcoreSetHomepageTakeover(E,B,F,A,D){var C="adWallpaper";if(typeof D!="undefined"&&D=="true"){C="adWallpaperBlack"}if(F!==null){C=C+" adWallpaperDummyBackground"}if(A===null){A="no-repeat"}document.getElementById("adLeaderboardPlaceholder").className="adSuperLeaderboard";document.getElementById("adLeaderboardPlaceholder").style.backgroundColor=B;document.getElementById("adLeaderboard").style.width=""+E+"px";document.getElementById("wallpaper").className=C;document.getElementById("wallpaper").style.backgroundColor=B;if(F!==null){document.getElementById("wallpaper").style.backgroundImage="url("+F+")";document.getElementById("wallpaper").style.backgroundPosition="center 34px";document.getElementById("wallpaper").style.backgroundRepeat=A;document.getElementById("adLeaderboardPlaceholder").style.backgroundImage="url("+F+")";document.getElementById("adLeaderboardPlaceholder").style.backgroundPosition="center 0px";document.getElementById("adLeaderboardPlaceholder").style.backgroundRepeat=A}}comcoreSplashPage=function(A){var B=this;B.overlayNode=A.overlayNode||document.getElementById("splashOverlay");B.counterNode=A.counterNode||document.getElementById("splashCounter");B.contentNode=A.contentNode||document.getElementById("splashContent");B.closer=A.closer||[document.getElementById("splashLogo"),document.getElementById("splashCloser")];B.timer=A.runtime||15;B.size=A.size||{width:0,height:0};B.timeout=false;B.stylesheet=document.styleSheets[document.styleSheets.length-1];B.openSplash=function(){document.body.parentNode.style.overflow=document.body.style.overflow="hidden";document.body.parentNode.style.height=document.body.style.height="100%";if(B.stylesheet.addRule){B.stylesheet.addRule("select","display:none !important")}B.overlayNode.style.display="block"};B.closeSplash=function(){B.stopTimeout();if(B.stylesheet.removeRule){B.stylesheet.removeRule(B.stylesheet.rules.length-1)}B.overlayNode.style.display="none";document.body.parentNode.style.height=document.body.style.height="auto";document.body.parentNode.style.overflow=document.body.style.overflow="auto"};B.runTimeout=function(){B.timeout=setInterval(B.updateTimer,1000)};B.stopTimeout=function(){clearInterval(B.timeout)};B.updateTimer=function(){B.counterNode.innerHTML=B.timer;B.timer-=1;if(B.timer<=0){B.closeSplash()}};B.init=function(){B.contentNode.style.width=B.size.width+"px";B.contentNode.style.height=B.size.height+"px";B.openSplash();B.contentNode.onmouseover=function(){B.stopTimeout()};B.contentNode.onmouseout=function(){B.runTimeout()};for(var C=0;C<B.closer.length;C++){B.closer[C].onclick=function(){B.closeSplash();return false}}B.updateTimer()}};ComCore.OpenSocialList={};ComCore.pageLoaded=false;var isPageLoaded=function(){return ComCore.pageLoaded};jx={getHTTPObject:function(){var A=false;if(typeof ActiveXObject!="undefined"){try{A=new ActiveXObject("Msxml2.XMLHTTP")}catch(D){try{A=new ActiveXObject("Microsoft.XMLHTTP")}catch(C){A=false}}}else{if(window.XMLHttpRequest){try{A=new XMLHttpRequest()}catch(B){A=false}}}return A},load:function(B,C,E,D){var A=this.init();if(!A||!B){return }if(A.overrideMimeType){A.overrideMimeType("text/xml")}C+="&t="+new Date().getTime();if(E=="post"){A.open("POST",B,true);A.setRequestHeader("Content-type","application/x-www-form-urlencoded");A.setRequestHeader("Content-length",C.length);A.setRequestHeader("Connection","close")}else{A.open("GET",B+"&"+C,true);C=null}A.onreadystatechange=function(){if(A.readyState==4){if(A.status==200){var F="";if(A.responseText){F=A.responseText}if(D){D(F)}}else{if(error){error(A.status)}}}};A.send(C)},init:function(){return this.getHTTPObject()}};window.onerror=function(F,C,E){if(ComCore.configValues.jsPostErrors===true){var D="";if(ComCore.Debug.errorCount){D+="count="+ComCore.Debug.errorCount}else{D+="count=1"}if(F){D+="&message="+encodeURIComponent(F)}if(C){D+="&script_url="+encodeURIComponent(C)}if(E){D+="&lno="+E}var B=printStackTrace();D+="&trace="+encodeURIComponent(B);if(ComCore.Page.pageSection){D+="&pageSection="+ComCore.Page.pageSection}if(ComCore.Server&&ComCore.Server.Number){D+="&server="+ComCore.Server.Number}D+="&url="+encodeURIComponent(window.location);var A=location.hostname;jx.load(ComCore.Page.getContextURL()+"/ajax/debug/action=postJavaScriptError",D,"post")}};function printStackTrace(){var I=[];var C=false;try{B.dont.exist+=0}catch(F){if(F.stack){return F.stack}else{if(window.opera&&F.message){var J=F.message.split("\n");for(var B=0,E=J.length;B<E;B++){if(J[B].match(/^\s*[A-Za-z0-9\-_\$]+\(/)){var H=J[B];if(J[B+1]){H+=" at "+J[B+1];B++}I.push(H)}}I.shift();C=true}}}if(!C){var D=arguments.callee.caller;while(D){var G=D.toString();var A=G.substring(G.indexOf("function")+8,G.indexOf("("))||"anonymous";I.push(A);D=D.caller}}return I.join(" ")}var comcoreSetProfileBackground=function(A,B,D,C){if(ComCore.Page.pageSection.substring(0,7)!=="profile"){return false}if(A){document.getElementById("content").style.backgroundImage="url('"+A+"')"}if(B){document.getElementById("content").style.backgroundColor=B}if(D){document.getElementById("content").style.backgroundImage=D}if(C){document.getElementById("content").style.backgroundImage=C}};var comcoreGetPageIdentifier=function(){return ComCore.Page.pageIdentifier};var comcoreGetProfileBackground=function(A){if(ComCore.Page.pageSection.substring(0,7)!=="profile"){return false}var B="";var C="content";switch(A){case"backgroundImage":B=document.getElementById(C).style.backgroundImage;break;case"backgroundColor":B=document.getElementById(C).style.backgroundColor;break;case"backgroundRepeat":B=document.getElementById(C).style.backgroundRepeat;break;case"backgroundPosition":B=document.getElementById(C).style.backgroundPosition;break}return B};var comcoreSetSkin=function(A,C){var B="";if(C){B=C+"/"}if(ComCore.pageLoaded&&ComCore.Login.isLoggedIn()){B+=ComCore.Configuration.get("rootURL")+"/"+ComCore.TopLogin.getNickname()}else{if(document.getElementById("userNickname")==null){return false}else{B+=ComCore.Configuration.get("rootURL")+"/"+document.getElementById("userNickname").innerHTML}}B+="/?preview=1&skin="+A;window.location=B};ComCore.Ads={};ComCore.Ads.showLeaderboard=function(A){};ComCore.Ads.hideLeaderboard=function(){};ComCore.bubbleManager=null;ComCore.BubbleManager=Class.create();ComCore.BubbleManager.prototype={initialize:function(){this.doCheckCounter=0;this.doCheckForNewCountersDelay=20000;this.showBubbleTime=30000;this.maxBubbles=4;this.effectIntervalMilliseconds=2000;this.effectIntervalSeconds=2;this.version=0.5;this.bubbleCounter=0;var A=$("chatList");this.bubble=$("bubble");if(A&&A.visible()){this.bubble.setStyle({width:"160px"})}this.showBubbles=true;try{this.showBubbleGuestbook=showBubbleGuestbook;this.showBubbleBlog=showBubbleBlog;this.showBubblePhoto=showBubblePhoto;this.showBubbleBirthday=showBubbleBirthday;this.showBubbleFriendship=showBubbleFriendship;this.showBubblePm=showBubblePm;this.showBubbleClan=showBubbleClan;this.showBubbleVideo=showBubbleVideo;this.showBubbleQuote=showBubbleQuote;this.showBubbleEvent=showBubbleEvent;this.showBubblePartner=showBubblePartner;this.showBubbleLink=showBubbleLink;this.showBubbleFriendsOnline=showBubbleFriendsOnline;this.showBubbleNewVisitor=showBubbleNewVisitor;this.showBubblePhotoFriend=showBubblePhotoFriend}catch(B){}this.doCheckForNewCounters=ComCore.configValues.bubblesPoller.enabled&&(this.showBubbleGuestbook||this.showBubbleBlog||this.showBubblePhoto||this.showBubbleBirthday||this.showBubbleFriendship||this.showBubblePm||this.showBubbleClan||this.showBubbleVideo||this.showBubbleQuote||this.showBubbleEvent||this.showBubbleFriendsOnline||this.showBubbleNewVisitor||this.showBubbleLink);if(this.doCheckForNewCounters===true){window.setTimeout((function(){this.checkForNewCounters()}).bind(this),this.doCheckForNewCountersDelay)}},checkForNewCounters:function(){if(this.doCheckForNewCounters){var A=ComCore.Page.buildAjaxURL("bubbles","getCounters",true)+"&hip="+Math.floor(Math.random()*1000000)+"&version="+this.version;var B=this;var C=new Ajax.Request(A,{method:"get",onSuccess:function(E,D){B.onCheckedForNewCounters(E,D)},onFailure:this.onCheckedForNewCountersFailure.bindAsEventListener(B)})}},onCheckedForNewCounters:function(B,A){try{if(!A||!A.ni){A=B.responseText.evalJSON(true)}if(A.s&&(A.ni===ComCore.Login.getNickname())){if(!A.m){A.m=0}if(!A.n){A.n=0}if(!A.f){A.f=0}if(!A.c){A.c=0}this.updateCounters(A.m,A.n,A.f,A.c);if(A.b){this.renderBubbles(A.b)}}else{debug("Not updating counters. You're now logged in as "+ComCore.Login.getNickname())}this.doCheckCounter++;if(this.doCheckCounter>3){this.doCheckForNewCountersDelay=60000;debug("Updated doCheckForNewCountersDelay to "+this.doCheckForNewCountersDelay+"ms")}if(this.doCheckCounter>10){this.doCheckForNewCountersDelay=300000;debug("Updated doCheckForNewCountersDelay to "+this.doCheckForNewCountersDelay+"ms")}if(this.doCheckCounter>15){this.doCheckForNewCountersDelay=600000;debug("Updated doCheckForNewCountersDelay to "+this.doCheckForNewCountersDelay+"ms")}if(this.doCheckCounter>20){this.doCheckForNewCounters=false;debug("disabling counter checks")}window.setTimeout((function(){this.checkForNewCounters()}).bind(this),this.doCheckForNewCountersDelay)}catch(C){ComCore.Debug.error("Error in onCheckedForNewCounters");ComCore.Debug.error(C)}},onCheckedForNewCountersFailure:function(A){window.setTimeout((function(){this.checkForNewCounters()}).bind(this),this.doCheckForNewCountersDelay)},updateCounters:function(G,I,A,E){var D=$("messageCount");if(D&&(parseInt(D.innerHTML,10)!==parseInt(G,10))){if(parseInt(G,10)<=0){D.hide()}else{D.innerHTML=G;D.show();if(typeof (Effect)!=="undefined"){var J=new Effect.Highlight(D,{startcolor:"#ffffff",endcolor:"#cc0000",duration:this.effectIntervalSeconds})}}}var B=$("notificationCount");if(B&&(parseInt(B.innerHTML,10)!==parseInt(I,10))){if(parseInt(I,10)<=0){B.hide()}else{B.innerHTML=I;B.show();if(typeof (Effect)!=="undefined"){var F=new Effect.Highlight(B,{startcolor:"#ffffff",endcolor:"#cc0000",duration:this.effectIntervalSeconds})}}}var H=$("friendCount");if(H&&(parseInt(H.innerHTML,10)!==parseInt(A,10))){if(parseInt(A,10)<=0){H.hide()}else{H.innerHTML=A;H.show();if(typeof (Effect)!=="undefined"){var C=new Effect.Highlight(H,{startcolor:"#ffffff",endcolor:"#cc0000",duration:this.effectIntervalSeconds})}}}},renderBubbles:function(D){var B={NEWFRIENDSTARTED:{f:this.showBubbleFriendship},FRIENDSTOPPED:{f:this.showBubbleFriendship},NEWFRIENDACCEPTED:{f:this.showBubbleFriendship},NEWFRIENDREGISTERED:{f:this.showBubbleFriendship},NEWEMAILCONTACTREGISTERED:{f:this.showBubbleFriendship},NEWFRIENDFROMINVITATION:{f:this.showBubbleFriendship},NEWFRIENDDENIED:{f:this.showBubbleFriendship},FRIENDRESTARTED:{f:this.showBubbleFriendship},LOVESTATERELATIONWITHYOU:{f:this.showBubbleFriendship},NEWGUESTBOOK:{f:this.showBubbleGuestbook},NEWQUEUEDGUESTBOOK:{f:this.showBubbleGuestbook},NEWCOMMENTONBLOG:{f:this.showBubbleBlog},NEWQUEUEDCOMMENTONBLOG:{f:this.showBubbleBlog},NEWCOMMENTONPHOTO:{f:this.showBubblePhoto},NEWQUEUEDCOMMENTONPHOTO:{f:this.showBubblePhoto},PHOTONOTEUSERMARKED:{f:this.showBubblePhoto},PHOTOCONFIRMED:{f:this.showBubblePhoto},NEWCOMMENTONVIDEO:{f:this.showBubbleVideo},NEWQUEUEDCOMMENTONVIDEO:{f:this.showBubbleVideo},VIDEOACTIVATED:{f:this.showBubbleVideo,picture:0},VIDEOERROR:{f:this.showBubbleVideo,picture:0},VIDEODUPLICATE:{f:this.showBubbleVideo,picture:0},VIDEODENIED:{f:this.showBubbleVideo,picture:0},NEWGUESTBOOKCOMMENTQUOTE:{f:this.showBubbleQuote},NEWBLOGCOMMENTQUOTE:{f:this.showBubbleQuote},NEWPHOTOCOMMENTQUOTE:{f:this.showBubbleQuote},NEWVIDEOCOMMENTQUOTE:{f:this.showBubbleQuote},EVENTACTIVATED:{f:this.showBubbleEvent,picture:0},EVENTDENIED:{f:this.showBubbleEvent,picture:0},EVENTATTENDINGTOMORROW:{f:this.showBubbleEvent,picture:0},BIRTHDAYTOMORROW:{f:this.showBubbleBirthday},BIRTHDAYTODAY:{f:this.showBubbleBirthday},PARTNERDELETED:{f:this.showBubblePartner,picture:0},APPLICATION:{f:this.showBubblePartner,picture:0},NEWPRIVATEMESSAGE:{f:this.showBubblePm},SHOUTMENTION:{f:this.showBubblePm},WHITELISTADD:{f:this.showBubblePm},NEWHELPDESKTICKET:{f:this.showBubblePm},ONLINEFRIEND:{f:this.showBubbleFriendsOnline},NEWVISITOR:{f:this.showBubbleNewVisitor},NEWCOMMENTONLINK:{f:this.showBubbleLink},NEWQUEUEDCOMMENTONLINK:{f:this.showBubbleLink},NEWLINKCOMMENTQUOTE:{f:this.showBubbleLink},CREDITSBOUGHT:{f:this.showBubblePm},PREMIUMEXPIRES7:{f:this.showBubblePm},PREMIUMEXPIRES3:{f:this.showBubblePm},PREMIUMEXPIRES1:{f:this.showBubblePm},PREMIUMSTOPPED:{f:this.showBubblePm},NOTIFICATION_BUBBLE_FRIEND_PHOTO_VIDEO_UPLOAD:{f:this.showBubbleLink}};for(var E=0,H=D.length;E<H;E++){var A=D[E];var I=A.type;var F=A.nickname;var C=A.pictureURL?'<img class="avatar" src="'+A.pictureURL+'" alt="'+F+'" />':"";var G=A.body;var K=A.id;var J="/logs/notifications/notificationID="+K;if((B[I]!==undefined)&&(B[I].f===true)){this.showBubble(J,(B[I].picture===undefined)?C:0,G,this.showBubbleTime)}else{ComCore.Debug.error("Unknown type or user doesn't want this (type: "+I+")")}}},showBubble:function(I,C,D,H,G){this.bubbleCounter++;var A=this.bubbleCounter;var F=$("bubble");if(F===null){return }if(ComCore.Configuration.get("bubblesPoller","enabled")===false){var E=($$("#chatConversationWindows .window").findAll(function(K){return K.visible()}).length>0);var B=E?150:180;html='<div class="clearfix" id="bubble'+A+'" style="display:none; width: '+B+'px">'}else{html='<div class="clearfix" id="bubble'+A+'" style="display:none;">'}html+='<div class="closeBubble" id="closeBubble'+A+'"><img class="icon iconCloseAlt" src="'+ComCore.Configuration.get("staticURL")+'//s/i/common/blank.gif" alt="" /></div>';if(C!=="0"){html+=C}html+='<p class="smiley">'+D+"</p></div>";$(F).insert({top:html});this.newBubble=$("bubble"+A);this.newBubble.observe("click",(function(K){if(G){debug("executing onClickFunction()");G(K);Element.remove("bubble"+A)}else{this.bubbleAction(I,A)}}).bind(this));this.closeBubble=$("closeBubble"+A);this.closeBubble.observe("click",function(K){Element.remove("bubble"+A);Event.stop(K)});this.newBubble.observe("mouseover",function(){$("closeBubble"+A).show()});this.newBubble.observe("mouseout",function(){$("closeBubble"+A).hide()});$(this.closeBubble).hide();if(this.bubbleCounter>this.maxBubbles){var J=(this.bubbleCounter-this.maxBubbles);Element.remove("bubble"+J)}if(typeof (Effect)!=="undefined"){Effect.Appear(this.newBubble,{duration:this.effectIntervalSeconds})}else{this.newBubble.show()}if(H!==0){window.setTimeout("ComCore.bubbleManager.hideBubble('bubble"+A+"')",H)}},bubbleAction:function(B,A){Element.remove("bubble"+A);var C="#utm_source=bubbles#utm_medium=bubbles#utm_campaign=bubbles";B=B+C;window.location=B},hideBubble:function(A){if($(A)){if(typeof (Effect)!=="undefined"){Effect.Fade(A,{duration:this.effectIntervalSeconds})}else{$(A).hide()}}},removeBubble:function(B){var A=$(B);if(A){A.remove()}}};ComCore.bubbleManager=new ComCore.BubbleManager();function XmlDocument(){}XmlDocument.create=function(C,E){C=C||"foo";E=E||"";try{var H;if(document.implementation&&document.implementation.createDocument){H=document.implementation.createDocument(E,C,null);var F=navigator.userAgent.toLowerCase();if(/mozilla/.test(F)&&!/(compatible|webkit)/.test(F)){var G=new DOMParser();var B="";if(E!=""){xmlns=' "'+E+'"'}H=G.parseFromString("<"+C+B+"></"+C+">","text/xml")}else{H=document.implementation.createDocument(E,C,null)}if(H.readyState==null){H.readyState=1;H.addEventListener("load",function(){H.readyState=4;if(typeof H.onreadystatechange=="function"){H.onreadystatechange()}},false)}}else{if(window.ActiveXObject){H=new ActiveXObject(XmlDocument.getPrefix()+".DomDocument")}}if(!H.documentElement||H.documentElement.tagName!=C||(H.documentElement.namespaceURI&&H.documentElement.namespaceURI!=E)){try{if(E!=""){H.appendChild(H.createElement(C)).setAttribute("xmlns",E)}else{H.appendChild(H.createElement(C))}}catch(A){H=document.implementation.createDocument(E,C,null);if(H.documentElement==null){H.appendChild(H.createElement(C))}if(E!=""&&H.documentElement.getAttribute("xmlns")!=E){H.documentElement.setAttribute("xmlns",E)}}}return H}catch(D){}throw new Error("Your browser does not support XmlDocument objects"+D)};XmlDocument.getPrefix=function(){if(XmlDocument.prefix){return XmlDocument.prefix}var A=["MSXML2","Microsoft","MSXML","MSXML3"];var D;for(var C=0;C<A.length;C++){try{D=new ActiveXObject(A[C]+".DomDocument");return XmlDocument.prefix=A[C]}catch(B){}}throw new Error("Could not find an installed XML parser")};if(typeof (Document)!="undefined"&&window.DOMParser){if(typeof (Document.prototype)=="undefined"){Document.prototype=0}Document.prototype.loadXML=function(B){var C=(new DOMParser()).parseFromString(B,"text/xml");while(this.hasChildNodes()){this.removeChild(this.lastChild)}for(var A=0;A<C.childNodes.length;A++){this.appendChild(this.importNode(C.childNodes[A],true))}}}if(window.XMLSerializer&&window.Node&&Node.prototype&&Node.prototype.__defineGetter__){XMLDocument.prototype.__defineGetter__("xml",function(){return(new XMLSerializer()).serializeToString(this)});Document.prototype.__defineGetter__("xml",function(){return(new XMLSerializer()).serializeToString(this)});Node.prototype.__defineGetter__("xml",function(){return(new XMLSerializer()).serializeToString(this)})}function getXmlDoc(A){var B=navigator.userAgent.toLowerCase();if(/mozilla/.test(B)&&!/(compatible|webkit)/.test(B)){var C=new DOMParser();return C.parseFromString(A.responseText,"text/xml")}else{return A.responseXML}}var JSJACJID_FORBIDDEN=[];function JSJaCJID(A){this._node="";this._domain="";this._resource="";if(typeof (A)=="string"){if(A.indexOf("@")!=-1){this.setNode(A.substring(0,A.indexOf("@")));A=A.substring(A.indexOf("@")+1)}if(A.indexOf("/")!=-1){this.setResource(A.substring(A.indexOf("/")+1));A=A.substring(0,A.indexOf("/"))}this.setDomain(A)}else{this.setNode(A.node);this.setDomain(A.domain);this.setResource(A.resource)}}JSJaCJID.prototype.getNode=function(){return this._node};JSJaCJID.prototype.getDomain=function(){return this._domain};JSJaCJID.prototype.getResource=function(){return this._resource};JSJaCJID.prototype.setNode=function(A){JSJaCJID._checkNodeName(A);this._node=A||"";return this};JSJaCJID.prototype.setDomain=function(A){if(!A||A==""){throw new JSJaCJIDInvalidException("domain name missing")}JSJaCJID._checkNodeName(A);this._domain=A;return this};JSJaCJID.prototype.setResource=function(A){this._resource=A||"";return this};JSJaCJID.prototype.toString=function(){var A="";if(this.getNode()&&this.getNode()!=""){A=this.getNode()+"@"}A+=this.getDomain();if(this.getResource()&&this.getResource()!=""){A+="/"+this.getResource()}return A};JSJaCJID.prototype.clone=function(){return new JSJaCJID(this.toString())};JSJaCJID._checkNodeName=function(A){if(!A||A==""){return }for(var B=0;B<JSJACJID_FORBIDDEN.length;B++){if(A.indexOf(JSJACJID_FORBIDDEN[B])!=-1){throw new JSJaCJIDInvalidException("forbidden char in nodename: "+JSJACJID_FORBIDDEN[B])}}};function JSJaCJIDInvalidException(A){this.message=A;this.name="JSJaCJIDInvalidException"}var JSJaCBuilder={buildNode:function(D,A){var B,C=arguments[4];if(arguments[2]){if(JSJaCBuilder._isStringOrNumber(arguments[2])||(arguments[2] instanceof Array)){B=this._createElement(D,A,C);JSJaCBuilder._children(D,B,arguments[2])}else{C=arguments[2]["xmlns"]||C;B=this._createElement(D,A,C);for(attr in arguments[2]){if(arguments[2].hasOwnProperty(attr)&&attr!="xmlns"){B.setAttribute(attr,arguments[2][attr])}}}}else{B=this._createElement(D,A,C)}if(arguments[3]){JSJaCBuilder._children(D,B,arguments[3],C)}return B},_createElement:function(E,A,D){try{if(D){return E.createElementNS(D,A)}}catch(B){}var C=E.createElement(A);if(D){C.setAttribute("xmlns",D)}return C},_text:function(A,B){return A.createTextNode(B)},_children:function(G,A,C,D){if(typeof C=="object"){for(var B in C){if(C.hasOwnProperty(B)){var F=C[B];if(typeof F=="object"){if(F instanceof Array){var E=JSJaCBuilder.buildNode(G,F[0],F[1],F[2],D);A.appendChild(E)}else{A.appendChild(F)}}else{if(JSJaCBuilder._isStringOrNumber(F)){A.appendChild(JSJaCBuilder._text(G,F))}}}}}else{if(JSJaCBuilder._isStringOrNumber(C)){A.appendChild(JSJaCBuilder._text(G,C))}}},_attributes:function(A){var B=[];for(attribute in A){if(A.hasOwnProperty(attribute)){B.push(attribute+'="'+A[attribute].toString().htmlEnc()+'"')}}return B.join(" ")},_isStringOrNumber:function(A){return(typeof A=="string"||typeof A=="number")}};var JSJACPACKET_USE_XMLNS=true;function JSJaCPacket(A){this.name=A;if(typeof (JSJACPACKET_USE_XMLNS)!="undefined"&&JSJACPACKET_USE_XMLNS){this.doc=XmlDocument.create(A,"jabber:client")}else{this.doc=XmlDocument.create(A,"")}}JSJaCPacket.prototype.getDoc=function(){return this.doc};JSJaCPacket.prototype.getNode=function(){if(this.getDoc()&&this.getDoc().documentElement){return this.getDoc().documentElement}else{return null}};JSJaCPacket.prototype.setTo=function(A){if(!A||A==""){this.getNode().removeAttribute("to")}else{if(typeof (A)=="string"){this.getNode().setAttribute("to",A)}else{this.getNode().setAttribute("to",A.toString())}}return this};JSJaCPacket.prototype.setFrom=function(A){if(!A||A==""){this.getNode().removeAttribute("from")}else{if(typeof (A)=="string"){this.getNode().setAttribute("from",A)}else{this.getNode().setAttribute("from",A.toString())}}return this};JSJaCPacket.prototype.setID=function(A){if(!A||A==""){this.getNode().removeAttribute("id")}else{this.getNode().setAttribute("id",A)}return this};JSJaCPacket.prototype.setType=function(A){if(!A||A==""){this.getNode().removeAttribute("type")}else{this.getNode().setAttribute("type",A)}return this};JSJaCPacket.prototype.getTo=function(){return this.getNode().getAttribute("to")};JSJaCPacket.prototype.getFrom=function(){return this.getNode().getAttribute("from")};JSJaCPacket.prototype.getToJID=function(){return new JSJaCJID(this.getTo())};JSJaCPacket.prototype.getFromJID=function(){return new JSJaCJID(this.getFrom())};JSJaCPacket.prototype.getID=function(){return this.getNode().getAttribute("id")};JSJaCPacket.prototype.getType=function(){return this.getNode().getAttribute("type")};JSJaCPacket.prototype.getChild=function(B,D){if(!this.getNode()){return null}B=B||"*";D=D||"*";if(this.getNode().getElementsByTagNameNS){return this.getNode().getElementsByTagNameNS(D,B).item(0)}var A=this.getNode().getElementsByTagName(B);if(D!="*"){for(var C=0;C<A.length;C++){if(A.item(C).namespaceURI==D){return A.item(C)}}}else{return A.item(0)}return null};JSJaCPacket.prototype.getChildVal=function(B,D){var E=this.getChild(B,D);var A="";if(E&&E.hasChildNodes()){for(var C=0;C<E.childNodes.length;C++){if(E.childNodes.item(C).nodeValue){A+=E.childNodes.item(C).nodeValue}}}return A};JSJaCPacket.prototype.clone=function(){return JSJaCPacket.wrapNode(this.getNode())};JSJaCPacket.prototype.isError=function(){return(this.getType()=="error")};JSJaCPacket.prototype.errorReply=function(A){var B=this.clone();B.setTo(this.getFrom());B.setFrom();B.setType("error");B.appendNode("error",{code:A.code,type:A.type},[[A.cond]]);return B};JSJaCPacket.prototype.xml=typeof XMLSerializer!="undefined"?function(){var A=(new XMLSerializer()).serializeToString(this.getNode());if(typeof (A)=="undefined"){A=(new XMLSerializer()).serializeToString(this.doc)}return A}:function(){return this.getDoc().xml};JSJaCPacket.prototype._getAttribute=function(A){return this.getNode().getAttribute(A)};JSJaCPacket.prototype._replaceNode=function(A){for(var B=0;B<A.attributes.length;B++){if(A.attributes.item(B).nodeName!="xmlns"){this.getNode().setAttribute(A.attributes.item(B).nodeName,A.attributes.item(B).nodeValue)}}for(var B=0;B<A.childNodes.length;B++){if(this.getDoc().importNode){this.getNode().appendChild(this.getDoc().importNode(A.childNodes.item(B),true))}else{this.getNode().appendChild(A.childNodes.item(B).cloneNode(true))}}};JSJaCPacket.prototype._setChildNode=function(F,B){var A=this.getChild(F);var D=this.getDoc().createTextNode(B);if(A){try{A.replaceChild(D,A.firstChild)}catch(E){}}else{try{A=this.getDoc().createElementNS(this.getNode().namespaceURI,F)}catch(C){A=this.getDoc().createElement(F)}this.getNode().appendChild(A);A.appendChild(D)}return A};JSJaCPacket.prototype.buildNode=function(A){return JSJaCBuilder.buildNode(this.getDoc(),A,arguments[1],arguments[2])};JSJaCPacket.prototype.appendNode=function(A){if(typeof A=="object"){return this.getNode().appendChild(A)}else{return this.getNode().appendChild(this.buildNode(A,arguments[1],arguments[2],null,this.getNode().namespaceURI))}};function JSJaCPresence(){this.base=JSJaCPacket;this.base("presence")}JSJaCPresence.prototype=new JSJaCPacket;JSJaCPresence.prototype.setStatus=function(A){this._setChildNode("status",A);return this};JSJaCPresence.prototype.setShow=function(A){if(A=="chat"||A=="away"||A=="xa"||A=="dnd"||A=="idle"){this._setChildNode("show",A)}return this};JSJaCPresence.prototype.getStatus=function(){return this.getChildVal("status")};JSJaCPresence.prototype.getShow=function(){return this.getChildVal("show")};function JSJaCIQ(){this.base=JSJaCPacket;this.base("iq")}JSJaCIQ.prototype=new JSJaCPacket;JSJaCIQ.prototype.setIQ=function(C,A,B){if(C){this.setTo(C)}if(A){this.setType(A)}if(B){this.setID(B)}return this};JSJaCIQ.prototype.setQuery=function(C){var A;try{A=this.getDoc().createElementNS(C,"query")}catch(B){A=this.getDoc().createElement("query")}if(A&&A.getAttribute("xmlns")!=C){A.setAttribute("xmlns",C)}this.getNode().appendChild(A);return A};JSJaCIQ.prototype.getQuery=function(){return this.getNode().getElementsByTagName("query").item(0)};function JSJaCMessage(){this.base=JSJaCPacket;this.base("message")}JSJaCMessage.prototype=new JSJaCPacket;JSJaCMessage.prototype.getBody=function(){return this.getChildVal("body")};JSJaCPacket.wrapNode=function(B){var A;switch(B.nodeName.toLowerCase()){case"presence":A=new JSJaCPresence();break;case"message":A=new JSJaCMessage();break;case"iq":A=new JSJaCIQ();break;default:return null}A._replaceNode(B);return A};ComCore.JabberCookieStore=Class.create({initialize:function(){},getSessionsObject:function(){return this._getCookie("jabber")},_getCookie:function(D){var E=document.cookie.split(";");var B="";for(var C=0,A=E.length;C<A;C++){var F=E[C];while(F.charAt(0)===" "){F=F.substring(1,F.length)}if(F.indexOf(D)===0){B=unescape(F)}}if(B.length===0){return{}}return B.evalJSON()},writeSessionsObject:function(E){var D=$H(E).collect(function(F){return{key:F.key,value:F.value}});D=D.sortBy(function(F){return F.value.timestamp}).reverse();var B={};var A=0;D.each(function(F){if(A++<=3){B[F.key]=F.value}});if(B){debug("write cookie");var C=Object.toJSON(B);this._writeCookie("jabber",C)}},writeJabberStatus:function(A){this._writeCookie("chatStatus",Object.toJSON({s:A}))},updatePeopleCount:function(B){var A=new Date();A.setTime(A.getTime()+(10*24*60*60*1000));this._writeCookie("chatPeopleCount",B,A)},getPeopleCount:function(){return parseInt(this._getCookie("chatPeopleCount"),10)},getJabberStatus:function(){var A=this._getCookie("chatStatus");return A.s},writeCurrentState:function(C){var A=Object.toJSON(C);var B=new Date();B.setTime(B.getTime()+(6*60*60*1000));this._writeCookie("state",A,B)},writeRoster:function(C){var A=Object.toJSON(C);var B=new Date();B.setTime(B.getTime()+(6*60*60*1000));this._writeCookie("roster",A,B)},getRoster:function(){return this._getCookie("roster")},getCurrentState:function(){return this._getCookie("state")},_writeCookie:function(A,C,B){if(B===undefined){B=new Date();B.setTime(B.getTime()+(60*10*1000))}document.cookie=A+"="+escape(C)+"; expires="+B.toGMTString()+"; path=/"},_eoo:true});if(!ComCore.Jabber){ComCore.Jabber={}}function stanza_error(C,B,A){this.code=C;this.type=B;this.cond=A;return{code:C,type:B,cond:A}}function ERR_FEATURE_NOT_IMPLEMENTED(){var A=new JSJaCIQ();return A.errorReply(stanza_error("501","cancel","feature-not-implemented"))}ComCore.Jabber.Connection=function(B,A){this.initialize=function(D,C){this.connectionParams=D;this.setupConnection(D,C);this.cookieExpire=1000*60;this.archiveCallbacks={}};this.setupConnection=function(E,C){this.roster={};this.controller=C;this.resources={};this.isRosterLoaded=false;this.connection=null;this.username=E.username.toLowerCase();this.firstName=E.firstName;this.isQuitting=false;try{this.connection=document.getElementById("remoteFrame").contentWindow.boot();this.connection.userDetails=this.controller.getUserDetails();this.connection.username=E.username.toLowerCase();this.connection.signature=E.signature;this.connection.hash=E.hash;this.connection.userID=E.userID;this.connection.distro=E.distro;this.connection.registerHandler("onConnect",this._onConnect.bind(this));this.connection.registerHandler("onInvalidSID",this._onInvalidSID.bind(this));window.onbeforeunload=this._quit.bind(this)}catch(D){debug(D);window.setTimeout((function(){this.setupConnection(E,C)}).bind(this),1000)}};this.getSession=function(H){var E=new ComCore.JabberCookieStore();var I=E.getSessionsObject();try{for(var D in I){if(I[D]){var G=I[D];var C=(new Date().getTime()-G.timestamp)>this.cookieExpire;if((G.in_use===false)&&G.sid&&G.resource&&(G.sid!=="null")&&!C){G.in_use=true;G.timestamp=new Date().getTime();I[D]=G;E.writeSessionsObject(I);this.connection.username=G.username.toLowerCase();this.connection.resource=G.resource;this.connection.hash=G.hash;this.connection.signature=G.signature;this.connection.userID=G.uid;this.connection.sid=G.sid;this.connection.revive();return }}}}catch(F){debug("Error in getSession: "+F)}this.connection.username=H.username.toLowerCase();this.connection.signature=H.signature;this.connection.hash=H.hash;this.connection.userID=H.userID;this.connection.resource="netlog_webclient_"+(new Date()).getTime()+"-"+Math.floor(Math.random()*10000)+"-"+this.connection.userID;this.connection.connect()};this.sendTypingNotification=function(E,C){var D=this.connection.username+"@chat.netlog.com";var F=C+"@chat.netlog.com";var G={xml:function(){return"<message from='"+D+"' to='"+F+"' type='chat'><"+E+" xmlns='http://jabber.org/protocol/chatstates' /></message>"}};this.connection.addPacketToQueue(G)};this.sendMessage=function(D,C,I){try{var E=this.connection.username+"@chat.netlog.com";var F=D+"@chat.netlog.com";var H=this.createMessage({recipient:F,body:C},false,I);this.connection.addPacketToQueue(H);if(!I){H=this.createMessage({recipient:E,body:C,receiver:D},true,I);this.connection.addPacketToQueue(H);C=C.replace(/&amp;/ig,"&");this.notify("onMessageReceived",{username:E,message:C,chat:D})}}catch(G){debug("Error in sendMessage(): "+G.message)}};this.createMessage=function(D,C,F){var E={xml:function(){var G='<message to="'+D.recipient+'"><body>'+D.body+"</body>";if(C===true){G+="<chat>"+D.receiver+"</chat>"}if(F!==undefined){G+="<payload>"+F+"</payload>"}G+="</message>";return G}};return E};this.setStatus=function(C,D){var E=new JSJaCPresence();E.setShow(C);if(D){E.setStatus(D)}this.connection.addPacketToQueue(E)};this.requestArchive=function(D,E){this.archiveCallbacks[D.to]=(function(F){this.parseArchiveXML(F,E)}).bind(this);var C={xml:function(){return'<iq from="'+D.from+'@chat.netlog.com" to="'+D.to+'@chat.netlog.com" type="get"><chat xmlns="netlog-messageArchive"/></iq>'}};this.connection.addPacketToQueue(C)};this.parseArchiveXML=function(G,I){var C=G.getChild();if(C.childNodes.length===0){I([]);return }var D=[];for(var F=0,H=C.childNodes.length;F<H;F++){var E=C.childNodes[F];D.push(this._createMessage(E))}I(D)};this._createMessage=function(D){var C=D.getElementsByTagName("body")[0];if(C.childNodes.length===0){return{}}var F=C.firstChild.nodeValue;if(!F){return{}}var G=D.getElementsByTagName("delay")[0].getAttribute("stamp");function E(I){var J=I.split("T");var L=J[0].split("-");var H=J[1].split(":");var K=L[1]-1;if(K<0){K=11}return new Date(L[0],K,L[2],H[0],H[1],H[2])}return{body:F,date:E(G),username:D.getAttribute("from").replace("@chat.netlog.com","").split("/")[0]}};this._onMessage=function(J){debug("_onMessage");debug(J);if(J.isError()){return }var K=this.connection.username+"@chat.netlog.com/"+this.connection.resource;var G=J.getFromJID().getNode()+"@"+J.getFromJID().getDomain()+"/"+J.getFromJID().getResource();if(K===G){debug("skipping a message I've sent");return }var F=J.getFromJID().getNode();var I=J.getBody();var M=J.getChild("x");var N=J.getChild("payload");if((N!==null)&&N.childNodes&&N.childNodes[0]){this.controller.games.challengeReceived(N.childNodes[0].nodeValue.toString(),F);return }if((J.getChild().tagName==="composing")||(J.getChild().tagName==="active")||(J.getChild().getAttribute("xmlns")==="jabber:x:event")){var H=J.getChild().tagName;if((H!=="composing")&&(H!=="active")){H=J.getChild().getChild().tagName}this.notify("onChatStateNotification",F,H)}if(!I.blank()){if(F==="netlog"){var C=J.getNode();var L=C.getAttribute("link");var E=C.getAttribute("image");var D='<img src="'+E+'" alt="image" style="width: 40px; height: 30px;" />';ComCore.bubbleManager.showBubble(L,D,I,ComCore.bubbleManager.showBubbleTime);this.notify("onBubbleReceived",L,E,D,I);return }var O=J.getChildVal("chat")||"";if((O!==F)&&(O.length>0)){this.notify("onMessageReceived",{username:F,message:I,chat:O})}else{this.notify("onMessageReceived",{username:F,message:I})}}};this.sendSecondPresence=function(){var C=new JSJaCPresence();C.getNode().setAttribute("getAll","true");this.connection.addPacketToQueue(C,null)};this._onPresence=function(D){var C=this.getPresenceStatus(D);if(C&&C.username&&C.userstatus){this.notify("onUserStatusChanged",C)}};this.sendIdle=function(C){var D=new JSJaCPresence();D.setShow("idle");this.connection.addPacketToQueue(D)};this.sendActive=function(C){C=C||"online";var D=new JSJaCPresence();D.setShow("chat");D.setStatus(C);D.getNode().setAttribute("restoreFromIdle","true");this.connection.addPacketToQueue(D)};this.getPresenceStatus=function(K){var C;var O=K.getFromJID();var F=O.getNode();var J=O.getResource();var L=this.connection.username+"@chat.netlog.com/"+this.connection.resource;var G=O.getNode()+"@"+O.getDomain()+"/"+O.getResource();var D=K.getChild();if(L===G){debug("skipping a presence I've sent");return }if(!K.getType()&&!K.getShow()&&(F===this.connection.username)&&(K.getNode().getAttribute("getAll")==="false")){return undefined}if(!C){var N=K.getShow();var H=K.getStatus();var E={online:{show:"chat"},busy:{show:"dnd"},away:{show:"away"},idle:{show:"idle"},invisible:{show:"xa"}};var M;for(var P in E){if(E.hasOwnProperty(P)){M=E[P];if(N===M.show){if(M.status){if(H===M.status){C=(M.status===H?P:false)}}else{C=P}}}}}if(!C){C="online"}if(C==="idle"){C="away"}var I={userstatus:C,username:F};if(K&&K.getNode().getAttribute("onlineFriends")){I.onlineFriendCounter=parseInt(K.getNode().getAttribute("onlineFriends"),10)}if(K&&K.getNode().getAttribute("type")&&(K.getNode().getAttribute("type")==="unavailable")){I.userstatus="invisible"}if(D&&(D.tagName.toLowerCase()==="user")){I.user={};["username","avatarUrl","firstname","shout","distro"].each(function(Q){I.user[Q]=unescape(D.getAttribute(Q))});I.user.status=I.userstatus;I.user.name=I.user.username}return I};this._onInvalidSID=function(D){var C={hash:this.connection.hash,signature:this.connection.signature,username:this.connection.username,userID:this.connection.userID};this.getSession(C)};this._onIQ=function(K){var E=K.getType();var M=K.getID();var I=K.getChild();var C=K.getFrom();var J;if(E==="get"){this.connection.addPacketToQueue(ERR_FEATURE_NOT_IMPLEMENTED())}else{if(E==="error"){debug("An iq error occured");this.connection.connected=false;this.connection.connectErrors++;this.connection.lastError=new Date().getTime();return false}else{if(E==="set"){var G;if(M==="game_challenge"){G=I.getAttribute("json");J=I.getAttribute("from").match(/(.*)\@(.*)/);this.controller.games.challengeReceived(G,J[1]);return }if(M==="nudge"){G=I.childNodes[0].nodeValue;J=I.getAttribute("from").match(/(.*)\@(.*)/);if(G){this.controller.nudgeReceived(G,J[1])}}if(C){J=C.match(/([a-z]+)\@(.*)/);if(J&&J[1]&&(J[1]==="netlog")){var N=I;var F=parseInt(N.getAttribute("messages"),10);var H=parseInt(N.getAttribute("friendships"),10);var L=parseInt(N.getAttribute("notifications"),10);this.notify("onNewCounters",{messages:F,friendships:H,notifications:L})}}}else{if(E==="result"){if(M==="get_roster"){this._onRosterLoaded(K)}if(I&&(I.getAttribute("xmlns")==="netlog-messageArchive")){var D=C.replace("@chat.netlog.com","");if(D&&this.archiveCallbacks[D]){this.archiveCallbacks[D](K)}}}else{debug("An unknow IQ occured: "+E)}}}}return false};this._onConnect=function(){this.notify("onConnect");window.chatStatus="onConnect";this.connection.registerHandler("message",this._onMessage.bind(this));this.connection.registerHandler("presence",this._onPresence.bind(this));this.connection.registerHandler("iq",this._onIQ.bind(this));this.connection.registerHandler("onDisconnect",this._onDisconnect.bind(this));this.connection.registerHandler("onError",this._onError.bind(this));this.connection.registerHandler("onReconnect",this._onReconnect.bind(this));this.connection.registerHandler("onReceiveOnlinePeopleCount",this.onReceiveOnlinePeopleCount.bind(this))};this.onReceiveOnlinePeopleCount=function(C){this.notify("onReceiveOnlinePeopleCount",C)};this._onReconnect=function(){this.notify("onReconnect")};this._onDisconnect=function(){this.notify("onDisconnect")};this._onError=function(C){debug("_onError()");if(this.connection.connected){this.connection.disconnect()}};this.getRoster=function(){return this.roster};this.isRosterLoaded=function(){return this.isRosterLoaded};this._onRosterLoaded=function(D){if(this.rosterTimeout){window.clearTimeout(this.rosterTimeout)}var I={"":"online",chat:"online",dnd:"busy",away:"away",xa:"invisible",idle:"away"};var K=D.getQuery().childNodes;for(var N=0,O=K.length;N<O;N++){var R=K[N];var Q="invisible";var L="";var E=ComCore.Configuration.get("photoStaticURL")+"/p/tt/000/000/0.jpg";var G=R.getAttribute("jid").substr(0,R.getAttribute("jid").indexOf("@"));var T=R.getAttribute("name");var C=R.getAttribute("presence");var F=R.getElementsByTagName("presence");var M=parseInt(R.getAttribute("userID"),10);var P=R.getAttribute("distro")||ComCore.Configuration.get("language");var S=R.getElementsByTagName("lastShout");var H=R.getElementsByTagName("avatarUrl");if((S.length>0)&&(S[0].childNodes.length>0)){L=S[0].childNodes[0].nodeValue}if((H.length>0)&&(H[0].childNodes.length>0)){E=H[0].childNodes[0].nodeValue}if(C!==null){if(I[C]){Q=I[C]}else{Q="busy"}}else{if(F&&F.length>0){var J=this.getPresenceStatus(JSJaCPacket.wrapNode(F[0]));Q=J.userstatus}}this.roster[G]={username:G,name:T,userID:M,shout:L,avatarUrl:E,status:Q,distro:P}}this.isRosterLoaded=true;this.notify("onRosterLoaded")};this.loadRoster=function(E){E=(E===undefined)?false:E;this.rosterTimeout=window.setTimeout((function(){if(this.controller&&this.controller.logging&&(this.controller.logging.state==="START")){this.controller.logging.addCustom("QUEUE "+this.connection._outQueue.join(",")+" | AJAX REQ COUNT: "+this.connection.getAjaxCount()+" | AJAX DATA: "+this.connection.currentPostData)}this.controller.onlineFriends.displayRosterError()}).bind(this),10000);var D=E===false?' small="true"':"";var C={xml:function(){return'<iq type="get" id="get_roster"'+D+'><query xmlns="jabber:iq:roster"/></iq>'}};this.connection.addPacketToQueue(C)};this.sendCustomMessage=function(D,C,E){this.sendMessage(D,C,E)};this.sendNudge=function(C,D){this.sendCustomIQ("nudge",D,C)};this.sendCustomIQ=function(D,F,H){var E=F+"@chat.netlog.com";var G=this.connection.username+"@chat.netlog.com";var C={xml:function(){return'<iq to="'+E+'" type="set" id="'+D+'"><payload xmlns="http://chat.netlog.com/xmlns/customiq" from="'+G+'">'+H+"</payload></iq>"}};this.connection.addPacketToQueue(C)};this._quit=function(){if(this.isQuitting===true){return }if(this.controller.logging&&(this.controller.logging.state==="START")){this.controller.logging.sendInvalid()}var D=this.connection.connected;window.clearInterval(this.connection.poller);this.notify("onQuit");this.connection.terminated=true;this.isQuitting=true;try{var C=new ComCore.JabberCookieStore();var F=C.getSessionsObject();if(F[this.connection.resource]){F[this.connection.resource].in_use=false;F[this.connection.resource].timestamp=new Date().getTime()}else{if(this.connection.sid&&this.connection.resource){F[this.connection.resource]={in_use:false,sid:this.connection.sid,resource:this.connection.resource,hash:this.connection.hash,timestamp:new Date().getTime(),signature:this.connection.signature,username:this.connection.username.toLowerCase(),uid:this.connection.userID}}}if((D===true)&&this.connection.sid){C.writeSessionsObject(F)}}catch(E){debug("Could not write cookie: "+E)}};this.initialize(B,A)};ComCore.Events.extend(ComCore.Jabber.Connection);if(!ComCore.Chat){ComCore.Chat={}}ComCore.Chat.Constants={TAB_WIDTH:142,WINDOW_WIDTH:254,CHAT_STATE_NOTIFICATION_RECEIVED_TIMEOUT:30000,CHAT_STATE_TYPING_TIMEOUT:7000,COOKIE_OBSERVE_INTERVAL:2000,SCROLL_DURATION:0.2,CHAT_STATUSSES:["Everyone","Friends","Busy","Away","Invisible"],MAX_COOKIE_ELEMENTS:20,REFRESH_EVERYONE_INTERVAL:30000,SHOW_BUBBLE_TIME:5000,IDLE_TIMEOUT:300000,ACTIVE_BLINK_TIMEOUT:3000};function log(A,B,E){var C=$("logContainer");if(C&&(ComCore.Chat.Settings.debug!==undefined)){var F=new Element("div",{"class":"txt"});var D=new Element("li");if(B!==undefined){F.insert(new Element("span",{"class":"type"+B}).update(B+": "))}D.insert(new Element("span",{"class":"timestamp"}).update(new Date().toString()));D.insert(F.insert(ComCore.Chat.FormatText.stripHTML(A)));C.insert(D)}if(E===undefined){debug(A)}}String.prototype.ucFirst=function(){return this.substr(0,1).toUpperCase()+this.substr(1,this.length)};String.prototype.trim=function(){var A=this.toString();A=A.replace(/^\s+/,"");A=A.replace(/\s+$/,"");return A};ComCore.Chat.Helper={array_merge:function(){var D=[];for(var C=0,A=arguments.length;C<A;C++){for(var B=0,E=arguments[C].length;B<E;B++){D=D.concat(arguments[C][B])}}return D},parseDate:function(A){var E=A.split(" ");var C=E[0].split("-");var B=E[1].split(":");var D=C[1]-1;if(D<0){D=11}return new Date(C[0],D,C[2],B[0],B[1],B[2])},getImagePathId:function(B){var A=B.split("/");return parseInt(A[A.length-1].replace(".jpg",""),10)},getWindowPosition:function(){var A=parseInt($("chatTabsList").getStyle("right").replace("px",""),10);var B=Math.abs(Math.round(A/ComCore.Chat.Constants.TAB_WIDTH));var D=Math.floor($("chatTabsContainer").clientWidth/141);var C=(B+(D-1));return{left:C,right:B}},str_pad:function(B,G,F,C){var E="",D;var A=function(I,H){var J="";while(J.length<H){J+=I}J=J.substr(0,H);return J};B+="";if(C!=="STR_PAD_LEFT"&&C!=="STR_PAD_RIGHT"&&C!=="STR_PAD_BOTH"){C="STR_PAD_RIGHT"}if((D=G-B.length)>0){if(C==="STR_PAD_LEFT"){B=A(F,D)+B}else{if(C==="STR_PAD_RIGHT"){B=B+A(F,D)}else{if(C==="STR_PAD_BOTH"){E=A(F,Math.ceil(D/2));B=E+B+E;B=B.substr(0,G)}}}}return B},buildImagePath:function(D,B){var C=ComCore.Chat.Helper.str_pad(D,9,0,"STR_PAD_LEFT");var A=ComCore.Configuration.get("photoStaticURL");if(B!==undefined){A="http://"+B+".netlogstatic.com"}return A+"/p/tt/"+C.substr(0,3)+"/"+C.substr(3,3)+"/"+D+".jpg"},getMsgFormatted:function(C,B){for(var A in B){if(B.hasOwnProperty(A)){C=C.replace(new RegExp("\\%"+A+"%","gi"),B[A])}}return C},getTranslation:function(A,B){return ComCore.Chat.Helper.getMsgFormatted(ComCore.Chat.Messages[A],B)},sortByName:function(A){return A.firstname.toLowerCase().replace(/[\xC0-\xC6]/g,"A").replace(/[\xE0-\xE6]/g,"a").replace(/[\xC8-\xCB]/g,"E").replace(/[\xE8-\xEB]/g,"e").replace(/[\xCC-\xCF]/g,"I").replace(/[\xEC-\xEF]/g,"i").replace(/[\xD2-\xD6]/g,"O").replace(/[\xF2-\xF6]/g,"o").replace(/[\xD9-\xDC]/g,"U").replace(/[\xF9-\xFC]/g,"u").replace(/[\xD1]/g,"N").replace(/[\xF1]/g,"n")},sortList:function(G){var D;var B={online:[],invisible:[],away:[],busy:[]};var F=ComCore.Chat.WelcomeMessage.name;if(G.length===0){return }G=G.sortBy(ComCore.Chat.Helper.sortByName);for(var E=0,A=G.length;E<A;E++){D=G[E];if(D.status&&(D.username!==F)){if(B[D.status]){B[D.status].push(D)}else{log("something went wrong"+D.status)}}}var C=ComCore.Chat.Helper.array_merge(B.online||[],B.busy||[],B.away||[],B.invisible||[]);return C}};ComCore.Chat.Button=Class.create({initialize:function(B,A){this.button=$(B);this.isBlinking=false;if((A===undefined)||(A===true)){this.button.observe("click",this._onClick.bind(this));this.observe("onChange",this._render.bind(this))}this.active=false},_onClick:function(A){A.stop();this.setActive(!this.isActive());this.notify("onClick")},_render:function(){this.button[this.isActive()?"addClassName":"removeClassName"]("active")},setLabel:function(A){this.button.down(".chatTabLabel").update(ComCore.Chat.FormatText.shorten(A,8));return this},getLabel:function(){return this.button.down(".chatTabLabel").innerHTML},setActive:function(A){if(A!==this.active){this.active=A;this.notify("onChange")}return this},isActive:function(){return this.active},show:function(){this.button.show();return this},hide:function(){this.button.hide();return this},visible:function(){return this.button.visible()},getType:function(){return"BUTTON"},getID:function(){return this.button.id},blink:function(){this.button.toggleClassName("blink")},setBlinking:function(B,A){if((A!==false)&&(B===true)){this.notify("onBlink")}if(B===true){if(this.isBlinking===false){this.blinkIntervalID=window.setInterval((function(){this.blink()}).bind(this),250);if(this.isActive()){window.setTimeout((function(){this.setBlinking(false)}).bind(this),ComCore.Chat.Constants.ACTIVE_BLINK_TIMEOUT)}this.isBlinking=true}}else{window.clearInterval(this.blinkIntervalID);this.button.removeClassName("blink");this.isBlinking=false}return this},_eoo:true});ComCore.Events.extend(ComCore.Chat.Button);ComCore.Chat.ChatStatusButton=Class.create({initialize:function(A,B){this.button=B;this.button.observe("click",this._togglechatStatusWindow.bind(this));this.controller=A;this.controller.userStatus.observe("onUserStatusChanged",this._onUserStatusChanged.bind(this))},_togglechatStatusWindow:function(A){A.stop();this.notify("onToggleUserWindow")},setLoading:function(A){this.button[A?"addClassName":"removeClassName"]("loading");return this},setStatus:function(){var D=this.controller.userStatus.jabberStatus;var E=ComCore.Chat.Constants.CHAT_STATUSSES;var B=5;var C;var A=this.button.down("img");while(B--){C=E[B];A[D.toLowerCase()===C.toLowerCase()?"addClassName":"removeClassName"]("iconStatus"+C)}return this},_onUserStatusChanged:function(){this.setStatus()},_eoo:true});ComCore.Events.extend(ComCore.Chat.ChatStatusButton);ComCore.Chat.ConversationButton=Class.create(ComCore.Chat.Button,{initialize:function($super,B,A,C){this.user=B;this.controller=A;this.isFriend=(this.user.nofriend===undefined);if(C!==undefined){$super(C)}else{$super(this._create(this.user.username))}this.unreadCount=this.button.down(".chatTabUnreadCount");this.setLabel((this.isFriend===true)?this.user.firstname:this.user.username);this.setStatus(this.user.status)},onChatStateNotification:function(D){var B=this.controller.onlineFriends.get(this.user.username);if(B&&B.element&&B.element.getElement()){var C=B.element.getElement().down("img.iconStatus");var A=this.button.down("img.chatTabStatus");if(D==="composing"){if(C){C.className="icon iconStatus "+D}A.className="icon chatTabStatus "+D;window.setTimeout(this.onChatStateNotification.bind(this,"active"),ComCore.Chat.Constants.CHAT_STATE_NOTIFICATION_RECEIVED_TIMEOUT)}else{if(C){C.className="icon iconStatus iconStatus"+(B.nofriend===undefined?this.user.status.ucFirst():"Everyone")}A.removeClassName("composing");this.user=this.controller.onlineFriends.users.get(this.user.username);this.setStatus(this.user.status)}}},showButton:function(A){this.controller.scrollController.requestAction((function(){this.show().setActive(true)}).bind(this))},_create:function(B){var A=$("chatTab").cloneNode(true);A.addClassName("conversation");if(this.isFriend!==true){A.addClassName("nofriend")}A.id="chatTab_"+B;var C=ComCore.Chat.Helper.getTranslation("conversationButtonTitle",{username:this.user.name});A.title=C.trim();$("chatTabsList").insert(A);return A.id},_onClick:function($super,A){A.stop();if(A.element().hasClassName("chatTabClose")){this.notify("onClose",this.user.username)}else{$super(A)}},resetUnreadCount:function(){this.unreadCount.update(0).hide();return this},updateUnreadCount:function(){log("updateUnreadCount");this.unreadCount.update(this.getUnreadCount()+1).show();return this},getUnreadCount:function(){return parseInt(this.unreadCount.innerHTML,10)},setStatus:function(D){if(this.isFriend===false){this.button.down("img.chatTabStatus").className="icon chatTabStatus iconStatusEveryone";return this}var E=["Online","Busy","Away","Invisible"];if(this.user.nofriend!==undefined){D="Everyone";E.push("Everyone")}var B=E.length;var C;var A=this.button.down("img.chatTabStatus");while(B--){C=E[B];A[(D.toLowerCase()===C.toLowerCase())?"addClassName":"removeClassName"]("iconStatus"+C)}return this},getID:function(){return this.user.username},_eoo:true});ComCore.Chat.Window=Class.create({initialize:function(C,B,A){this.window=$(C);this.button=B;this.close=this.window.down(".chatTabClose");this.minimize=this.window.down(".minimize");if((A===undefined)||(A===true)){this.window.observe("click",this._onClick.bindAsEventListener(this))}},_onClick:function(C){C.stop();var B=C.findElement("a");if(!B){return }if(B===this.close){this._onClose()}else{if(B===this.minimize){this._onMinimize()}else{var A=B.getAttribute("href").replace(/\u200b|<wbr(.*)>/g,"").replace("%E2%80%8B","");if(B.getAttribute("target")==="_blank"){window.open(A)}else{window.location=A}}}},_onClose:function(){},_onMinimize:function(){this.button.setActive(false)},setTitle:function(A){this.window.down(".title").update(A);return this},getTitle:function(){return this.window.down(".title").innerHTML},closeWindow:function(){this.button.setActive(false);this.window.hide()},setActive:function(A){this.window[A===true?"addClassName":"removeClassName"]("open")},isVisible:function(){var B=this.button.button.previousSiblings().length-1;var D=ComCore.Chat.Helper.getWindowPosition();var C=D.left;var A=D.right;if((B<=C)&&(B>=A)){return true}return false},openWindow:function(){this.setActive(true);this.button.setActive(true);this.window.show()},calculatePosition:function(){return((this.button.button.cumulativeOffset()[0]-this.window.getWidth())+this.button.button.getWidth()-4)},setPosition:function(){this.window.setStyle({left:this.calculatePosition()+"px"})},show:function(){this.setActive(true);this.setPosition();this.window.show();return this},hide:function(){this.window.hide();return this},toggle:function(){if(this.positionSet===undefined){this.setPosition();this.positionSet=true}this.window.toggle();return this},_eoo:true});ComCore.Events.extend(ComCore.Chat.Window);ComCore.Chat.chatStatusWindow=Class.create({initialize:function(A,B){this.controller=A;this.chatStatusButton=B;this.window=$("chatStatusWindow");this.chatStatusButton.observe("onToggleUserWindow",this._toggleWindow.bind(this));ComCore.Chat.UserStatus.observe("onUserStatusChanged",this._statusChange.bind(this));this.window.observe("click",this._onContentClick.bind(this))},_statusChange:function(){this.setStatus(this.controller.userStatus.jabberStatus)},_toggleWindow:function(A){this.window.toggle()},_onContentClick:function(A){var B=A.findElement("li");A.stop();var D=B.getAttribute("id").replace("chatStatus_","");var C=this.controller.userStatus.statusMapping[D];$$("#chatStatusWindow li").invoke("removeClassName","chatStatusCurrent");B.addClassName("chatStatusCurrent");this.controller.userStatus.set(C,true,D);this.hide()},setStatus:function(B){var A=this.window.down("#chatStatus_"+B);if(A){this.window.select("li").invoke("removeClassName","chatStatusCurrent");A.addClassName("chatStatusCurrent")}},hide:function(){this.window.hide()},show:function(){this.window.show()},_eoo:true});ComCore.Chat.State=Class.create({cookieStore:new ComCore.JabberCookieStore(),initialize:function(A){this.controller=A},getState:function(){var A=this.cookieStore.getCurrentState();return(A!==undefined)?A.w:undefined},writeState:function(A){this.cookieStore.writeCurrentState(A)},writeRoster:function(B,A){this.cookieStore.writeRoster({roster:B,time:new Date().getTime()})},getLastUpdateRoster:function(){var A=this.cookieStore.getRoster();if(A&&A.time){return A.time}},getRoster:function(){var A=this.cookieStore.getRoster();if(A){return A}return false},updateRoster:function(F){function C(G){var H={u:escape(G.username),s:G.status,f:escape(G.firstname),a:ComCore.Chat.Helper.getImagePathId(G.avatarUrl),id:G.userID};if(G.shout){H.t=escape(ComCore.Chat.FormatText.shortenShout(G.shout))}return H}if((F===undefined)||((F.constructor===Array)&&(F.length===0))){return }F=ComCore.Chat.Helper.sortList(F);var E=F.findAll(function(G){return((G.status!==undefined)&&(G.status!=="invisible")&&(G.nofriend===undefined)&&(G.username!==ComCore.Chat.WelcomeMessage.name))});var B=0;E=E.collect(function(G){if(B++<7){return C(G)}});if(!E){E=[]}if(E.length<7){var D=7-E.length;var A=F.findAll(function(G){return((G.status==="invisible")&&(G.nofriend===undefined))});A=A.collect(function(G){return C(G)});if(A.length>0){A=A.eachSlice(D).first();E=ComCore.Chat.Helper.array_merge(E,A)}}this.writeRoster(E,F)},updateJabberStatus:function(A){this.cookieStore.writeJabberStatus(A)},getJabberStatus:function(){return this.cookieStore.getJabberStatus()},updateState:function(){var K=this.controller.onlineFriends.users.values();if(!K){this.writeState([]);return }var R=[];var Q=$$("#chatConversationWindows div.open");var G=0;if(Q&&Q.length>0){var E=Q.first().getAttribute("id").replace("conversationWindow_","");var H=this.controller.conversationWindow(E);if(H){G=((H.button.button.cumulativeOffset()[0]-H.window.getWidth())+H.button.button.getWidth()-4);if(H.window.visible()){G+=4}}}var A=this.controller.conversations.values();var S,I,C,O,T,J;for(var L=0,M=A.length;L<M;L++){S=A[L];I=S.b;C=S.w;if(I&&(C.window.hasClassName("open"))){O=S.c.user.status;T=this.controller.onlineFriends.get(S.c.user.username);J=I.getUnreadCount();if(C){R.push({username:T.username,friend:(T.nofriend===undefined),firstname:T.firstname,state:C.window.visible(),position:L,status:O,m:J,id:T.userID,a:ComCore.Chat.Helper.getImagePathId(T.avatarUrl)})}}if(L>ComCore.Chat.Constants.MAX_COOKIE_ELEMENTS){break}}var F=parseInt($("chatTabsList").getStyle("right").replace("px",""),10);var N=(F!==0)?F:0;var D=K.findAll(function(U){return((U.status!=="invisible")&&(U.status!=="offline")&&(U.nofriend===undefined))});var P=(D!==undefined)?D.length:0;var B={w:R,p:G,o:Math.round($("chatTabsContainer").clientWidth/ComCore.Chat.Constants.TAB_WIDTH),f:N};this.updateOnlinePeopleCountCookie();this.writeState(B)},updateOnlinePeopleCountCookie:function(){var A=$("hudButtonChatCount").innerHTML.match(/\((\d*)\)/);var B=(A.length===2)?~~A[1]:0;this.cookieStore.updatePeopleCount(B)}});ComCore.Chat.ConversationWindow=Class.create(ComCore.Chat.Window,{initialize:function($super,D,C,B,E){this.conversation=D;this.smileysLoaded=false;this.isFriend=(this.conversation.user.nofriend===undefined);if(E!==undefined){$super(E,C)}else{$super(this._create(this.conversation.user),C)}this.objectStash=$H();this.user=this.conversation.user;this.controller=B;this.status=this.controller.userStatus.status;this.form=this.window.down("form");this.form.observe("submit",this.onSendMessage.bindAsEventListener(this));this.input=this.form.down("input");this.input.observe("keyup",this.onKeyUp.bind(this));this.input.observe("keydown",this.onKeyDown.bind(this));this.hasFocus=false;this.input.observe("click",this.onInputFocus.bind(this));this.input.observe("focus",this.onInputFocus.bind(this));this.input.observe("blur",this.onInputBlur.bind(this));var A=this.window.select("dt.newDay").last();if(A){this.dayFromLastMessage=this.getDayFormat(ComCore.Chat.Helper.parseDate(A.getAttribute("rel")))}else{this.dayFromLastMessage=new Date().getDay()}this.usernameFromLastMessage=this.user.username;if(this.isFriend===false){this.abuseButton=this.getObject(".chatAbuse");this.abuseButton.observe("click",this._sendAbuse.bind(this))}this.smileyButton=this.window.down(".chatSmilies");this.smileyButton.observe("click",this._handleSmilies.bind(this));this.offlineWarning=this.window.down(".conversationOfflineWarning");ComCore.Chat.UserStatus.observe("onUserStatusChanged",this._statusChange.bind(this));this.changeStatusLink=this.offlineWarning.down("a");this.changeStatusLink.observe("click",this.onChangeStatus.bind(this));this.addAsFriendLink=this.window.down(".chatAddAsFriend");this.addAsFriendLink.setAttribute("href","/friends/add/userid="+this.conversation.user.userID);this.addAsFriendLink.setAttribute("rel",this.conversation.user.userID);this.addAsFriendLink[(this.isFriend===false)?"show":"hide"]();this.addAsFriendLink.observe("click",this.onAddFriend.bind(this));this.messageHistory=[];this.messageHistoryPosition=0;this.clearArchiveLink=this.window.down(".clearArchive");this.clearArchiveLink.observe("click",this.onClearArchive.bind(this));this.getObject(".conversationContent").observe("click",this.focusConversationWindow.bind(this));this.controller.onlineFriends.observe("onUserStatusChanged",this.onUserStatusChanged.bind(this));this.conversation.observe("onMessageAdded",this.onMessageAdded.bind(this));if(this.user.status&&(this.user.status==="invisible")){this.showOfflineNotice()}if(this.controller.userStatus.status==="invisible"){this.showofflineWarning()}window.setTimeout((function(){this.hideLoading()}).bind(this),10000);this.typingState="ACTIVE"},focusConversationWindow:function(A){if($(this.form).visible()){this.input.focus()}},clearArchive:function(){this.usernameFromLastMessage="";this.dayFromLastMessage=new Date().getDay();this.getObject(".conversation").innerHTML="";[this.clearArchiveLink,this.window.down("img.iconTrash")].invoke("addClassName","disabled")},onClearArchive:function(A){if(this.clearArchiveLink.hasClassName("disabled")){return }A.stop();if(confirm(ComCore.Chat.Messages.clearArchiveConfirm)===true){this.clearArchive();var B=new Ajax.Request(ComCore.Page.buildAjaxURL("chatbar","clearArchive"),{method:"post",parameters:{userid:this.user.userID,csrftoken_cleararchive:ComCore.CSRF.getToken("clearArchive")}})}},onInputFocus:function(A){this.hasFocus=true;this.button.resetUnreadCount();this.button.setBlinking(false);this.controller.windowTitle.onWindowFocus()},onInputBlur:function(A){this.hasFocus=false},onAddFriend:function(A){A.stop();ComCore.Dialog.initialize();ComCore.Dialog.options.width=750;if((this.conversation.user.userID===undefined)||isNaN(this.conversation.user.userID)){ComCore.Dialog.postContent(ComCore.Page.buildAjaxURL("friends","addFriend"),"nick="+escape(this.conversation.user.username))}else{ComCore.Dialog.postContent(ComCore.Page.buildAjaxURL("friends","addFriend"),"userid="+this.conversation.user.userID)}},onChatStateNotification:function(A){this.button.onChatStateNotification(A)},onKeyDown:function(A){var B=A.keyCode||A.which;var C=false;switch(B){case Event.KEY_UP:this.messageHistoryPosition--;C=true;break;case Event.KEY_DOWN:this.messageHistoryPosition++;C=true;break}if(C===true){A.stop();if(this.messageHistoryPosition<0){this.messageHistoryPosition=0}if(this.messageHistoryPosition>this.messageHistory.length){this.messageHistoryPosition=this.messageHistory.length}this.input.value=this.messageHistory[this.messageHistoryPosition]||""}},onKeyUp:function(A){A.stop();this.onInputFocus();var C=false;var B=A.keyCode||A.which;switch(B){case Event.KEY_DOWN:case Event.KEY_UP:C=true;break}if(C===true){this.typingState="ACTIVE";return }var D=this.input.value;if(D.length>0){this.startTyping();if(this.typingTimeout!==undefined){window.clearTimeout(this.typingTimeout)}this.typingTimeout=window.setTimeout(this.stopTyping.bind(this),ComCore.Chat.Constants.CHAT_STATE_TYPING_TIMEOUT)}else{this.stopTyping()}},startTyping:function(){if(this.typingState==="ACTIVE"){this.typingState="COMPOSING";this.controller.connection.sendTypingNotification("composing",this.user.username)}},stopTyping:function(){if(this.typingState==="COMPOSING"){this.typingState="ACTIVE";this.controller.connection.sendTypingNotification("active",this.user.username)}},getObject:function(B){var A=this.objectStash.get(B);if(!A){A=this.window.down(B);this.objectStash.set(A)}return A},onChangeStatus:function(A){A.stop();this.closeWindow();this.controller.onlineFriendsButton.setActive(true);this.controller.chatStatusWindow.show()},onReceiveArchive:function(){var A=this.conversation.user;var B=this.controller.onlineFriends.get(A.username);B.isArchiveLoaded=A.isArchiveLoaded=true;this.conversation.messages.each(function(C){if((C.body.gameName===undefined)&&(C.username.toLowerCase()===this.controller.connection.username.toLowerCase())){this.messageHistory.push(C.body);this.messageHistoryPosition=this.messageHistory.length;log("add msg "+C.body)}},this);if(A.pendingMessages){A.pendingMessages.each(function(C){this.controller.onMessageReceived(C)},this);A.pendingMessages=[]}if(this.archiveCallback){this.archiveCallback()}if(this.conversation.messages.length>0){[this.clearArchiveLink,this.window.down("img.iconTrash")].invoke("removeClassName","disabled")}this.hideLoading()},showofflineWarning:function(){if(this.controller.userStatus.status!=="online"){this.controller.userStatus.set("online",true,ComCore.Chat.Settings.chatPrivacy.toLowerCase());this.controller.showBubble("STATUS_CHANGED",this.user)}},hideofflineWarning:function(){if(!((this.controller.userStatus.jabberStatus==="friends")&&(this.isFriend===false))){this.form.show()}this.offlineWarning.hide();this.getObject(".conversationContent").scrollTop=this.getObject(".conversationContent").scrollHeight},_checkinvisible:function(){if(this.status==="invisible"){this.showofflineWarning()}else{this.hideofflineWarning()}},_statusChange:function(A){this.status=this.controller.userStatus.status},prepareSmilies:function(){this.getObject(".chatSmiliesList").observe("click",this._smileyClick.bind(this))},_smileyClick:function(B){B.stop();var C=Event.findElement(B,"a");if(!C){return }var A=C.parentNode;this.hideSmilies();if((ComCore.Login.isPremium()===false)&&(A.hasClassName("chatSmileypremium"))){ComCore.Chat.Smilies.premiumTeaser();return false}this.input.value+=C.title;if($(this.form).visible()){this.input.focus()}},_sendAbuse:function(B){if(this.abuseButton.hasClassName("disabled")){return }B.stop();if(confirm(ComCore.Chat.Helper.getTranslation("chatReportAbuse",{user:this.conversation.user.firstname}))){var A=new Element("input",{type:"hidden",name:"chatConversation"});var C=Object.toJSON(this.conversation.messages);A.value=C;this.form.insert(A);this.form.action="/"+escape(this.conversation.user.username)+"/abuse";this.form.submit()}},_handleSmilies:function(A){A.stop();var B=this.getObject(".chatSmiliesBox");this[B.visible()?"hideSmilies":"showSmilies"]()},hideSmilies:function(){this.animateSmilies(false)},showSmilies:function(){if(this.smileysLoaded===false){this.attachSmilies();this.prepareSmilies();this.smileysLoaded=true}this.animateSmilies(true)},animateSmilies:function(B){var E=B?0:100;var A=B?100:0;var C=this.getObject(".chatSmiliesBox");if(typeof (Effect)!=="undefined"){var D=new Effect.Tween(C,E,A,{duration:0.3,afterFinish:function(){if(A===0){C.hide()}}},function(F){C.show();C.setStyle({height:F+"px"})})}else{C[B===true?"show":"hide"]()}},hide:function($super){this.window.hide();this.button.setActive(false);$super();this.controller.state.updateState()},onUserStatusChanged:function(B,A){if(B===this.conversation.user.username){if(A==="invisible"){this.showOfflineNotice()}else{this.hideOfflineNotice()}}},showDisconnectedNotification:function(){this.getObject(".conversationDisconnected").show()},hideDisconnectedNotification:function(){this.getObject(".conversationDisconnected").hide()},addNotification:function(B){var A=this.getDateString(new Date());this.getObject(".conversation").insert('<dd><span class="chatTimestamp">'+A+'</span><br /><div class="info">'+B+"</div></dd>");this.getObject(".conversationContent").scrollTop=this.getObject(".conversationContent").scrollHeight},showLoading:function(){this.window.down(".conversationLoading").show();window.setTimeout((function(){this.hideLoading()}).bind(this),10000)},hideLoading:function(){var A=this.window.down(".conversationLoading");if(A){A.hide()}},attachSmilies:function(A){var B=ComCore.Chat.Settings.smilies;var C=[];$H(B).each(function(D){if(D.value.d===true){C.push("<li class='chatSmiley"+((D.value.t==="f")?"free":"premium")+"'><a href='#' title='"+D.key+"'><img src='"+ComCore.Configuration.get("staticURL")+"/s/i/smilies/"+D.value.i+"' alt='"+D.key+"'>")}});this.getObject(".chatSmiliesList").innerHTML=C.join("")},_create:function(B){var A=$("conversationWindow").cloneNode(true);A.addClassName("conversation");A.setAttribute("id","conversationWindow_"+B.username);if(B.shout&&B.shout.length>0){A.down(".chatShout").update(B.shout)}if(B.avatarUrl){A.down(".titleBar .avatar").setAttribute("src",B.avatarUrl)}if((B.shout===undefined)||(B.shout.length===0)){A.down(".chatShout").hide()}if((this.isFriend!==true)&&(A.down(".titleBar .chatAbuse"))){A.down(".titleBar .chatAbuse").show()}A.down(".titleBar a.chatUserLink").setAttribute("href","/"+escape(B.username));A.down(".titleBar .title").update(ComCore.Chat.FormatText.wordWrap((B.nofriend===undefined)?B.firstname:B.username,10));$("chatConversationWindows").insert(A);return A.getAttribute("id")},getDayFormat:function(B){var A=B.getDate();var C=B.getMonth()+1;if(A<10){A="0"+A}if(C<10){C="0"+C}return A+"/"+C},getDateString:function(B){var A=B.getHours();if(A<10){A="0"+A}var C=B.getMinutes();if(C<10){C="0"+C}return A+":"+C},onMessageAdded:function(H){if(this.abuseButton){this.abuseButton.removeClassName("disabled")}[this.clearArchiveLink,this.window.down("img.iconTrash")].invoke("removeClassName","disabled");this.button.onChatStateNotification("active");var L=H.message;var D=H.fromArchive;var G=H.type;var K=H.chat;if(G==="game"){L.body=this.controller.games.createBody(L)}else{if(G==="challengeSent"){L.body=this.controller.games.createChallengeSentBody(L,K)}else{if(L.username.toLowerCase()!==this.controller.connection.username.toLowerCase()){L.body=ComCore.Chat.FormatText.process(L.body,this)}else{L.body=ComCore.Chat.FormatText.processOwner(L.body,this)}}}var E=this.controller.onlineFriends.users.get(L.username);var C=L.username;var F=(E&&(E.firstname!==undefined))?E.firstname:L.username;if(L.username.toLowerCase()===this.controller.connection.username.toLowerCase()){F=this.controller.connection.firstName}if(L.date===undefined){L.date=new Date()}var A=this.getDayFormat(L.date);if(this.dayFromLastMessage!==A){this.getObject(".conversation").insert('<dt class="newDay">'+A+"</dt>");this.dayFromLastMessage=A;this.getObject(".conversation").insert("<dt>"+F+"</dt>");this.usernameFromLastMessage=C}if(this.usernameFromLastMessage.toLowerCase()!==C.toLowerCase()){this.getObject(".conversation").insert("<dt>"+F+"</dt>");this.usernameFromLastMessage=C}var B=this.getDateString(L.date);var I=(G!==undefined)?'<dd class="gameChallengeBody">':"<dd>";this.getObject(".conversation").insert(I+'<span class="chatTimestamp">'+B+'</span><span class="chatMessage">'+L.body+"</span></dd>");this.doScroll();if(G==="game"){var J=this.window.select("div.gameImage img").last();if(J){J.observe("load",this.doScroll.bind(this))}}if(((!this.button.isActive())||(this.controller.windowTitle.hasFocus===false))&&(this.controller.connection.username!==L.username)&&(D!==true)){log("new update");this.button.updateUnreadCount()}},doScroll:function(){this.getObject(".conversationContent").scrollTop=this.getObject(".conversationContent").scrollHeight},onSendMessage:function(C){C.stop();var B=this.input.value;this.input.value="";if(B.length===0){return }if(B.length>ComCore.Chat.Settings.maximumCharsAllowedPerMessage){this.addError(ComCore.Chat.Messages.messageTooLong);return }this.messageHistory.push(B);this.messageHistoryPosition=this.messageHistory.length;this.notify("onSendMessage",this.conversation.user.username,B);try{$(document).fire("comcore:chat_conversations_sendmessage",{from_userid:ComCore.Login.getUserID(),to_userid:this.conversation.user.userID})}catch(A){log(A)}},addError:function(A){this.getObject(".conversation").insert('<dd class="chatError">'+A+"</dd>");this.doScroll()},showOfflineNotice:function(){var B=ComCore.Chat.Helper.getTranslation("contactOffline",{contact:this.conversation.user.firstname});var A=this.getObject(".conversationOfflineNotice");A.update(B);A.show();this.button.onChatStateNotification("active")},hideOfflineNotice:function(){this.getObject(".conversationOfflineNotice").hide()},show:function($super){this.button.setBlinking(false);this.button.resetUnreadCount();$super();this.doScroll();if($(this.form).visible()){this.input.focus()}this._checkinvisible();this.controller.state.updateState()},_onClose:function(){this.notify("onClose",this.conversation.user.username)},_eoo:true});ComCore.Chat.Conversation=Class.create({initialize:function(A){this.user=A;this.messages=[]},addMessage:function(D){var G=D.username;var F=D.message;var H=D.fromArchive;var E=D.type;var B=D.chat;var C=D.date||new Date();var A={username:G,body:F,date:C};this.messages.push(A);if(H!==true){this.notify("onMessageAdded",{message:A,fromArchive:false,type:E,chat:B})}},_eoo:true});ComCore.Events.extend(ComCore.Chat.Conversation);ComCore.Chat.OnlineFriendsElement=Class.create({parentUL:false,title:false,friendElement:null,initialize:function(A){this.user=A;this.html=this._createElement(A)},_setFriendElement:function(){this.friendElement=$("onlineFriend_"+this.user.username)},getHTML:function(){return this.html},_createElement:function(A){var B="";if(A.shout){B=ComCore.Chat.FormatText.removeHTML(A.shout)}var C=ComCore.Chat.Helper.getTranslation("conversationButtonTitle",{username:A.name});return'<li onclick="ComCore.Chat.controller.onlineFriendsWindow.onClick(this); return false;" class="'+A.status+'" id="onlineFriend_'+A.username+'"><a href="javascript://" class="clearfix"><img class="avatar" src="'+A.avatarUrl+'" alt="" /><img class="icon iconStatus iconStatus'+A.status.ucFirst()+'" src="'+ComCore.Configuration.get("staticURL")+'/s/i/common/blank.gif" alt="" /><strong class="name">'+ComCore.Chat.FormatText.wordWrap(A.firstname,20)+'</strong><br /><span class="unreadMessages" style="display: none">0</span><small class="shout">'+B+"</small></a></li>"},getElement:function(){if(this.friendElement===null){this._setFriendElement()}return this.friendElement},_eoo:true});ComCore.Chat.OnlineEveryoneElement=Class.create(ComCore.Chat.OnlineFriendsElement,{initialize:function(A){this.user=A;this.html=this._createElement(A)},_createElement:function(B){var D="";if(B.shout){D=ComCore.Chat.FormatText.removeHTML(B.shout)}var G=ComCore.Chat.Helper.getTranslation("conversationButtonTitle",{username:B.name});var E="";if(B.gender&&B.age&&B.region){var A=B.gender;var F='<img class="icon icon'+A.toLowerCase().ucFirst()+'" src="'+ComCore.Configuration.get("staticURL")+'/s/i/common/blank.gif" alt="" />';var C=$A([F,B.age,B.region]);E=C.compact().join("-")}return'<li onclick="ComCore.Chat.controller.onlineFriendsWindow.onClick(this); return false;" class="iconStatusEveryone" id="onlineFriend_'+B.username+'"><a href="javascript://" class="clearfix"><img class="avatar" src="'+B.avatarUrl+'" alt="" /><img class="icon iconStatus iconStatusEveryone" src="'+ComCore.Configuration.get("staticURL")+'/s/i/common/blank.gif" alt="" /><strong class="name">'+ComCore.Chat.FormatText.wordWrap(B.username,20)+'</strong><br /><span class="asl">'+E+'</span><span class="unreadMessages" style="display: none">0</span><small class="shout">'+D+"</small></a></li>"},_eoo:true});ComCore.Chat.SearchController=Class.create({initialize:function(A){this.friendsWindow=A;this.searchInput=this.friendsWindow.searchInput;this.searchResetIcon=this.friendsWindow.searchResetIcon;this.resetVars();this.searchInput.observe("keyup",this.onSearch.bind(this));this.searchInput.observe("click",this.onInputClick.bind(this));this.searchResetIcon.observe("click",this.onResetSearch.bind(this))},onInputClick:function(A){A.stop()},resetVars:function(){this.searchResults=[];this.currentResult=null;this.currentPosition=0},onSearch:function(H){var C=this.friendsWindow.controller.onlineFriends;if(!!C.fullRosterLoaded===false){C.load(this.onSearch.bind(this,H),true)}var I=H.keyCode||H.which;if(I===Event.KEY_ESC){this.onResetSearch(H);return }if(I===Event.KEY_DOWN||I===Event.KEY_UP){this.handleArrows(I===Event.KEY_UP);H.stop();return }if(I===Event.KEY_RETURN){this.selectElement();return }var A=this.searchInput.getValue().trim();if(A.length>0){this.currentPosition=0;var F=this.friendsWindow.onlineFriends.search(A);var B=[];for(var D=0,G=F.length;D<G;D++){B.push(this.friendsWindow.onlineFriends.get(F[D]))}var E=$$("#chatListRoster li");E.invoke("hide");if(B.length>0){B=B.sortBy(ComCore.Chat.Helper.sortByName);this.searchResults=B.collect(function(J){return J.element.getElement()});this.searchResults.invoke("show");this.searchResults=E.reject(function(J){return !J.visible()});this.currentResult=this.searchResults.first();if(this.currentResult){this.clearHighlights();this.currentResult.down("a").addClassName("highlight")}}this.friendsWindow.window.down(".search").addClassName("active")}else{this.onResetSearch(H)}},selectElement:function(){this.currentResult=this.searchResults[this.currentPosition];if(this.currentResult){var A=this.currentResult.id.replace(/onlineFriend_/,"").toLowerCase();this.resetSearch();this.friendsWindow.closeWindow();this.friendsWindow.notify("onStartChat",A,true)}},handleArrows:function(A){this.currentResult=this.searchResults[this.currentPosition];if(this.currentResult){this.currentPosition+=A?-1:1;if(this.currentPosition>=this.searchResults.length){this.currentPosition=0}if(this.currentPosition<0){this.currentPosition=this.searchResults.length-1}this.currentResult=this.searchResults[this.currentPosition];if(this.currentResult){this.clearHighlights();this.currentResult.down("a").addClassName("highlight")}}},clearHighlights:function(){$$("#chatListRoster li a.highlight").invoke("removeClassName","highlight")},onResetSearch:function(A){A.stop();this.resetSearch()},resetSearch:function(){this.clearHighlights();this.resetVars();this.friendsWindow.window.down(".search").removeClassName("active");$$("#chatListRoster li").invoke("show");this.searchInput.value="";this.searchInput.focus()},_eoo:true});ComCore.Chat.OnlineFriendsWindowHeader=Class.create({initialize:function(A){this.controller=A;this.windowHeader=$("chatListHeader");this.shoutInputField=$("chatShoutFormInput");this.chatShoutChange=$("chatShoutChange");this.chatShoutSave=$("chatShoutSave");this.chatShoutForm=$("chatShoutForm");this.chatShout=$("chatShout");this.myShout=this.chatShout.down("span");this.shout=this.myShout.innerHTML.trim();this.shoutError=$("chatShoutError");this.shoutErrorMsg=this.shoutError.down(".chatShoutErrorMsg");this.closeShout=$("chatShoutCancel");this.closeShout.observe("click",this._closeShout.bind(this));this.shoutInputField.observe("click",function(B){B.stop()});this.shoutInputField.observe("keypress",this._handleKeypress.bind(this));this._attachEvents()},_closeShout:function(A){A.stop();this.closeShoutF()},closeShoutF:function(){this.chatShoutForm.hide();this.chatShout.show()},_handleKeypress:function(A){if(this.shoutInputField.value.length>140){this.shoutInputField.value=this.shoutInputField.value.substring(0,140)}},_attachEvents:function(){this.chatShoutChange.observe("click",this._toggleShout.bind(this));this.chatShoutSave.observe("click",this._toggleShout.bind(this))},_toggleShout:function(G){var A=Event.element(G);G.stop();if(A===this.chatShoutSave){try{var D=this.shoutInputField.value;if(D.indexOf(ComCore.Language.get("eastereggs","santa"))!==-1||D.indexOf(ComCore.Language.get("eastereggs","christmas"))!==-1||D.indexOf(ComCore.Language.get("eastereggs","snow"))!==-1||D.indexOf("santa")!==-1||D.indexOf("christmas")!==-1||D.indexOf("snow")!==-1||D.indexOf("xmas")!==-1||D.indexOf("kerst")!==-1){var F=Element.extend(document.createElement("script"));F.setAttribute("language","javascript");F.setAttribute("type","text/javascript");F.setAttribute("src",ComCore.Configuration.get("staticURL")+"/s/j/snowstorm.js");var E=function(){ComCore.Queuer.add(function(){ComCore.EasterEggs.SnowStorm.snowColor="#ddd";ComCore.EasterEggs.SnowStorm.usePositionFixed=true;ComCore.EasterEggs.SnowStorm.followMouse=false;if(!$("hud").hasClassName("minimized")){ComCore.EasterEggs.SnowStorm.flakeBottom=document.viewport.getHeight()-40}var H=250;if(Prototype.Browser.IE){H=100}ComCore.EasterEggs.SnowStorm.flakesMax=H;ComCore.EasterEggs.SnowStorm.flakesMaxActive=H/2;ComCore.EasterEggs.SnowStorm.start()});ComCore.Queuer.execute()};if(!Prototype.Browser.IE){F.observe("load",function(){if(Object.isFunction(E)){E()}})}else{F.onreadystatechange=function(){if((F.readyState=="complete"||F.readyState=="loaded")&&Object.isFunction(E)){E()}}}var C=$(document.getElementsByTagName("head")[0]);C.appendChild(F)}}catch(B){log(B)}this._saveShout()}else{this.toggleView();this.shoutInputField.focus()}},toggleView:function(){this.chatShout.toggle();this.chatShoutForm.toggle()},_saveShout:function(){var A=this.shoutInputField.value.trim();A=ComCore.Chat.FormatText.stripHTML(A);this.sendNewShout(A)},sendNewShout:function(B){this.newShout=B;var C=$("chatShoutLoading");this.shoutTimeout=window.setTimeout((function(){C.hide();this.closeShoutF();this.myShout.update(ComCore.Chat.FormatText.wordWrap(this.shout));this.shoutInputField.value=""}).bind(this),8000);C.show();var A=new Ajax.Request(ComCore.Page.buildAjaxURL(null,"addShout"),{method:"post",parameters:{shout:B,logs:1,type:"BOTH","short":1,csrftoken_addShout:ComCore.CSRF.getToken("addShout")},onSuccess:this._onShoutSuccess.bind(this)})},_onShoutSuccess:function(B,A){this.closeShoutF();window.clearTimeout(this.shoutTimeout);$("chatShoutLoading").hide();if(A.actionState!=="shoutSuccess"){this._handleError(A.actionState)}else{this.shout=ComCore.Chat.FormatText.stripHTML(this.newShout)}this.myShout.update(ComCore.Chat.FormatText.wordWrap(this.shout));this.shoutInputField.value=""},_handleError:function(C){var A=$(C);if(!A){A=$("shoutFailure")}var B=A.innerHTML.trim();this.chatShoutForm.hide();this.chatShout.hide();this.shoutError.show();this.shoutErrorMsg.update(B);window.setTimeout((function(){this.chatShoutForm.show();this.shoutError.hide()}).bind(this),5000)},_eoo:true});ComCore.Chat.OnlineFriendsWindow=Class.create(ComCore.Chat.Window,{initialize:function($super,B,C,A){$super("chatList",C,false);this.controller=A;this.onlineFriends=B;this.button=C;this.hasTracked=false;this.chatTab=$("chatTabFriends");this.chatList=$("chatListRoster");this.onlineFriends.observe("onUserStatusChanged",this.onUserStatusChanged.bind(this));this.onlineFriends.observe("onLoaded",this.onLoaded.bind(this));this.searchInput=this.window.down(".search input");this.searchResetIcon=this.window.down(".search .reset");this.searchController=new ComCore.Chat.SearchController(this);this.minimize=this.window.down(".minimize");this.minimize.observe("click",this.onMinimize.bind(this));this.chatTab.observe("scroll",this.onScrollEvent.bind(this))},onScrollEvent:function(C){var A=(this.chatTab.scrollTop+this.chatTab.getHeight());var B=this.chatList.getHeight();if((Math.abs(A-B)<60)&&(!!this.onlineFriends.fullRosterLoaded===false)&&(this.onlineFriends.isLoadingRoster===false)){log("req roster");this.onlineFriends.load(undefined,true)}},onMinimize:function(A){this.button.setActive(false)},onClick:function(A){A=$(A);var B=ComCore.Chat.controller.onlineFriendsWindow;if(A){if(!A.hasClassName("chatStatus")){var C=A.id.replace(/onlineFriend_/,"").toLowerCase();B.closeWindow();B.notify("onStartChat",C,true)}else{B.notify("onStatusChange",A)}}},onLoaded:function(){var I=[];var B=this.onlineFriends.users.values().reject(function(K){return(K.nofriend&&(K.nofriend===true))});var G=ComCore.Chat.Helper.sortList(B);var C,D;for(var E=0,F=G.length;E<F;E++){D=G[E];if((D.username===ComCore.Chat.WelcomeMessage.name)||(D.nofriend!==undefined)){continue}C=this.addNewOnlineFriend(D);I.push(C.getHTML())}var A=$("chatListRoster");A.innerHTML=I.join("");if(!this.hasTracked&&this.controller.logging){this.controller.logging.endLog();this.hasTracked=true}if(this.onlineFriends.rosterCallback!==null){try{this.onlineFriends.rosterCallback(this.onlineFriends.getRosterDetails())}catch(H){log("Error callback");log(H)}}try{$(document).fire("comcore:chat_contactlist_updatelist",{tab:"friends",contacts_count:G.length})}catch(J){log(J)}},addNewOnlineFriend:function(A){var B=new ComCore.Chat.OnlineFriendsElement(A);A.element=B;A.friendElement=null;return B},search:function(F,C,D){var E=F.length,B=-1,A;while(E-B>1){if(F[A=E+B>>1]<C){B=A}else{E=A}}return F[E]!==C?D?E:-1:E},addFirstContactInStatusList:function(J,F,E){var C=null;var B=["online","busy","away","invisible"];var H=B.indexOf(E);H=(H<0)?0:H;var A=function(L){return(L.down("strong.name").innerHTML.toLowerCase()===F.firstname.toLowerCase())};for(var G=H;G>=0;G--){var K=$$("#"+J+" li."+B[G]).reject(A);if(K.length>0){C=K.last();break}}var D=F.element.getElement();if(C===null){var I=$(J);I.insert({top:D})}else{C.insert({after:D})}},highlightNewUserStatus:function(A,F){function E(I){I.style.cssText=""}var H={online:["#96CB00","#ACD733"],away:["#DC0D0D","#C60000"],busy:["#F69825","#FFDC81"],invisible:["#3B3B3B","#616161"]};var G=H[F][0];var D=H[F][1];var B=A.element.getElement();if(typeof (Effect)!=="undefined"){var C=new Effect.Highlight(B,{startcolor:G,endcolor:D,afterFinish:E.bind(this,B)})}},updateContactList:function(E,D,B){if(D.element.getElement()===null){return }var F=$$("#"+E+" li."+B).reject(function(J){return(J.down("strong.name").innerHTML.toLowerCase()===D.firstname.toLowerCase())});if(F.length===0){this.addFirstContactInStatusList(E,D,B);this.updateOnlineStatus(D,B);return }var C=F.collect(function(J){return J.down("strong.name").innerHTML.toLowerCase()});var G=this.search(C,D.firstname.toLowerCase(),true);var A=D.element.getElement();if(!A){return }if(G===0){var I=F.first();I.insert({before:A});this.updateOnlineStatus(D,B);return }var H=F[G-1];if(H){H.insert({after:A})}this.updateOnlineStatus(D,B)},updateOnlineStatus:function(A,F){if((A.nofriend!==undefined)&&(A.nofriend===true)){return }var B=A.element.getElement();if(B===null){return }var G=["online","busy","away","invisible"];var C=4;var E;var D=B.down("img.icon");while(C--){E=G[C];D[F===E?"addClassName":"removeClassName"]("iconStatus"+E.ucFirst())}this.highlightNewUserStatus(A,F)},onUserStatusChanged:function(D,B){var A=this.onlineFriends.get(D);if(A.element&&(A.nofriend===undefined)){this.updateContactList("chatListRoster",A,B);var C=A.element.getElement();if(C){$A(["online","busy","away","invisible"]).each(function(E){C[B===E?"addClassName":"removeClassName"](E)})}}},show:function($super){$super();this.button.setActive(true);this.searchInput.focus()},toggle:function($super){$super();if(this.window.visible()){this.searchInput.focus()}},hide:function($super){this.button.setActive(false);$super()},_eoo:true});ComCore.Events.extend(ComCore.Chat.OnlineFriendsWindow);ComCore.Chat.FormatText={process:function(B,A){B=this.stripHTML(B);B=this.parseEmails(B);B=this.parseURLs(B);B=this.wordWrap(B,34);B=this.addSmilies(B,A);return B},processOwner:function(B,A){B=this.parseEmails(B);B=this.parseURLs(B);B=this.wordWrap(B,34);B=this.addSmilies(B,A);return B},removeHTML:function(A){return A.replace(/(<([^>]+)>)/ig,"")},shorten:function(B,A){A=(A===undefined)?10:A;return(B.length>A)?(B.substr(0,A)+"..."):B},parseEmails:function(B){var A=/([a-zA-Z0-9_.\-]*)@([a-zA-Z0-9_.\-]*)\.(.*)/;return B.gsub(A,function(C){if(C.length===4){return'<a href="/go/messages/send/receiver='+escape(C[0])+'">'+C[0]+"</a>"}})},parseURLs:function(A){var B=/(http:\/\/)+([\w\-]+\.)?[\w\-]+(\/[\w\- .\/?%&=]*)?(\.[a-zA-Z]{2,})+(\S*)?/;return A.gsub(B,function(D){var C=D[0];var F=D[0];var E=/([a-z]{2,3})+\.netlog.com\/(.*)$/gi;if(F.indexOf("http")===-1){F="http://"+F}if(E.test(F)===true){return'<a href="'+F+'">'+C+"</a>"}else{return'<a href="/go/out/url='+F+'" target="_blank">'+C+"</a>"}})},stripHTML:function(A){return A.replace(/&/ig,"&amp;").replace(/</ig,"&lt;").replace(/>/ig,"&gt;")},wordWrap:function(K,J){if(/a href/.test(K)===true){return K}if(!J){J=30}var N=new RegExp("\\S{"+J+"}","g");var A=0;var I=K;var E=[];var G=K.match(N);var B=false;if(/MSIE (\d+\.\d+);/.test(navigator.userAgent)){var C=parseInt(RegExp.$1,10);if(C<=6){B=true}}if(G){for(var D=0,H=G.length;D<H;D++){var F=G[D];var L=A+I.indexOf(F);var M=K.substring(A,L);if(M){E.push(M)}if(B===false){E.push(F+"&#8203;")}else{E.push(F+"<wbr/>")}A=L+F.length;I=K.substring(A)}}if(I){E.push(I)}return E.join("")},addSmilies:function(D,A){function C(F){var E=new Image();E.src=F;E.onload=function(){A.getObject(".conversationContent").scrollTop=A.getObject(".conversationContent").scrollHeight};return E}var B=function(F){var E=C(ComCore.Configuration.get("staticURL")+"/s/i/smilies/"+ComCore.Chat.Settings.smilies[F].i);return'<img class="smiley" src="'+E.src+'" />'};D=D.replace(ComCore.Chat.Settings.freeSmiliesRegex,B);D=D.replace(ComCore.Chat.Settings.premiumSmiliesRegex,B);return D},shortenShout:function(C,F){var G="";var B=false;var I=false;var A=0;if(F===undefined){F=50}for(var D=0,E=C.length;D<E;D++){if(C.substr(D,1)==="<"){B=true}if(C.substr(D,1)===">"){var H=I;if(I===true){B=false;H=false}if(I===false){H=true}I=H}if(A>=F){G+="...";break}G+=C.substr(D,1);if(B===false){A++}}return G}};ComCore.Chat.Smilies={smilies:{},premiumTeaser:function(){ComCore.Dialog.initialize();ComCore.Dialog.options.width=630;ComCore.Dialog.getContent("/go/settings/account/view=super&type=FUN")}};ComCore.Chat.OnlineFriends=Class.create({initialize:function(A){this.users=$H();this.controller=A;this.connection=A.connection;this.rosterLoaded=false;this.fullRosterLoaded=false;this.connectionLoaded=false;this.rosterCallback=null;this.isLoadingRoster=false;this.rosterNumberLoadingAttemptsAllowed=1;this.rosterAttempts=0;this.onlineFriendsCounter=0;this.connection.observe("onUserStatusChanged",this.onUserStatusChanged.bind(this));this.connection.observe("onRosterLoaded",this.onLoaded.bind(this))},addUserToRoster:function(C,A){this.add(C,A);var B=this.controller.onlineFriendsWindow.addNewOnlineFriend(A);$("chatListRoster").insert(B.getHTML());this.controller.onlineFriendsWindow.updateContactList("chatListRoster",A,A.status)},onUserStatusChanged:function(D){var C=D.username;var B=D.userstatus;var E=D.onlineFriendCounter;var A;if(E&&!isNaN(E)&&(this.isLoaded()===false)){this.controller.updateOnlinePeopleCount(E)}else{A=this.users.get(C);if(!A&&(D.user)){A=D.user;this.addUserToRoster(C,A)}}if((C===this.connection.username)&&(this.controller.userStatus.status!==B)){if(B==="idle"){return }this.controller.userStatus.set(B,false,(B.toLowerCase()==="online")?ComCore.Chat.Settings.chatPrivacy.toLowerCase():B);return }A=this.users.get(C);if(A&&(A.nofriend===undefined)){if(A.status!==B){A.status=B;this.notify("onUserStatusChanged",C,B)}}},load:function(C,B){if(C){this.rosterCallback=C}this.isLoadingRoster=true;var A=(B===undefined)?false:B;if(ComCore.Chat.Settings.smallRoster===false){A=true}this.fullRosterLoaded|=A;log("loadRoster("+A+")");this.connection.loadRoster(A)},getRosterDetails:function(){return this.users.values().reject(function(A){return(A.distro!==ComCore.Configuration.get("language"))}).collect(function(A){return{thumbnailUrl:A.avatarUrl,firstname:A.firstname,name:A.name,userID:A.userID,presence:A.status,nickname:A.username}})},displayRosterError:function(A){if(this.controller.logging){this.controller.logging.sendRosterError(A)}if(this.rosterAttempts<this.rosterNumberLoadingAttemptsAllowed){this.rosterAttempts++;this.load()}else{$$("#chatListRoster li").invoke("remove");$("loadingFriends").hide();$("loadingError").show();this.rosterAttempts=0}},cleanUser:function(A){function B(C){if(C&&(C.length>15)){return C.substr(0,15)+"..."}else{return C}}A.name=B(A.name);A.firstname=B(A.firstname);if(!A.avatarUrl){A.avatarUrl=ComCore.Configuration.get("photoStaticURL")+"/p/tt/000/000/0.jpg"}},displayNoFriends:function(){$$("#chatListRoster li").invoke("remove");$("loadingFriends").hide();$("noChatFriends").show();try{$(document).fire("comcore:chat_contactlist_updatelist",{tab:"friends",contacts_count:0})}catch(A){log(A)}},onLoaded:function(){var A=this.connection.getRoster();this.isLoadingRoster=false;this.controller.connection.isRosterLoaded=true;this.rosterLoaded=true;if($H(A).values().length===0){this.displayNoFriends();return }$("loadingError").hide();$H(A).each(function(B){this.add(B.key,B.value)},this);$("loadingFriends").hide();if(this.controller.messageQueue.length>0){this.controller.messageQueue.each(function(C){this.controller.onStartChat(C.username);var B=this.controller.conversationWindow(C.username);B.openWindow();if(B.hasFocus!==true){ComCore.Chat.SoundManager.beep()}this.controller.onMessageReceived({username:C.username,message:C.body,type:C.type,chat:C.chat,playSound:C.playSound})},this)}this.notify("onLoaded");this.controller.updateOnlinePeopleCountFromRoster()},updateUserStatus:function(D,C){var A=this.users.get(D);if(A.status===C){return }A.status=C;var B=this.controller.conversationButton(D);if(B!==false){B.setStatus(C)}},isLoaded:function(){return this.rosterLoaded},search:function(B){var A=$A();this.users.values().each(function(C){if(C&&(C.nofriend===undefined)&&C.username&&C.name&&(C.name.toLowerCase().indexOf(B.toLowerCase())>-1||C.username.toLowerCase().indexOf(B.toLowerCase())>-1)){A.push(C.username)}});return A},add:function(D,C){D=D.toLowerCase();var B=C.name.split(" ");C.firstname=B[0].substr(0,1).toUpperCase()+B[0].substr(1).toLowerCase();this.cleanUser(C);var A=this.get(D);if(A){C=$H(A).merge(C).toObject()}this.users.set(D,C)},get:function(A){return this.users.get(A.toLowerCase())},getAll:function(){return this.users},_eoo:true});ComCore.Events.extend(ComCore.Chat.OnlineFriends);ComCore.Chat.UserStatus=Class.create({statusMapping:{everyone:"online",friends:"online",busy:"busy",away:"away",invisible:"invisible"},jabberStatusMapping:{online:{show:"chat"},busy:{show:"dnd"},away:{show:"away"},invisible:{show:"xa"}},initialize:function(A,B){this.previousStatus=B;this.controller=A;this.connection=A.connection;if(B){this.status=B;this.jabberStatus=this.controller.connectionParams.jabberStatus}},getPrivacyStatus:function(){if(this.privacyStatus===undefined){this.privacyStatus=$H(this.statusMapping).find((function(A){return(A.value===this.status)}).bind(this)).key}return this.privacyStatus},setStatus:function(C){var A=this.jabberStatusMapping[C].show;var B=this.jabberStatusMapping[C].status?this.jabberStatusMapping[C].status:false;this.connection.setStatus(A,B)},set:function(D,A,E){this.jabberStatus=E;var C;$A($H(this.statusMapping).keys()).each(function(G){this.controller.onlineFriendsButton.img[this.jabberStatus===G?"addClassName":"removeClassName"]("iconChat"+G.ucFirst())},this);if(A===undefined){A=true}if(A!==false){C=function(){this.setStatus(this.status);if((E!=="invisible")&&(this.controller.pendingMessages.length>0)){this.controller.emptyPendingMessages(E)}this.notify("onUserStatusChanged",this.status)}.bind(this)}this.status=D;var F={status:E.toUpperCase()};var B=new Ajax.Request(ComCore.Page.buildAjaxURL("contactlist","setChatbarStatus"),{method:"post",parameters:F,onSuccess:function(H,G){if(A!==false){C()}if(G.success===false){log("Error setting user status!")}}})},get:function(){return this.status},_eoo:true});ComCore.Events.extend(ComCore.Chat.UserStatus);ComCore.Chat.Archive=Class.create({initialize:function(B,C,A){this.connection=B.connection;this.controller=B;this.user=C;this.window=A;this.displayArchive()},displayArchive:function(){var B={from:this.connection.connection.username,to:this.user.username};var C={userid:this.user.userID};var A=new Ajax.Request("/go/ajax/chatbar/view=getArchive",{method:"post",parameters:C,onSuccess:this._receiveArchive.bind(this)})},_receiveArchive:function(D){var B=D.responseJSON.messages;if(D.responseJSON.success===false){return }if($A(B).length>0){this.window.dayFromLastMessage=new Date().getDay();this.window.getObject(".conversation").childElements().invoke("remove")}var C,A;$A(B).each(function(J){C=ComCore.Chat.Helper.parseDate(J.datetime);var H={body:J.message,username:J.sender_nickname,date:C};A={message:H,fromArchive:true};if(J.isGame!==undefined){var I={gameName:J.gameName,gameThumbnail:ComCore.Configuration.get("staticURL")+J.gameAvatar,gameUrl:J.gameURL};log("parse game archive");this.controller.conversation(this.user.username).addMessage({username:H.username,message:I,playSound:false,type:"game",fromArchive:true});this.window.onMessageAdded({message:{body:I,username:J.sender_nickname,date:C},fromArchive:true,type:"game"})}else{this.controller.conversation(this.user.username).addMessage({username:H.username,message:H.body,fromArchive:true,date:C});this.window.onMessageAdded(A)}},this);if(this.user.status==="invisible"){this.window.showOfflineNotice()}var E=this.controller.state.getState();if((E!==undefined)&&(E.constructor===Array)){var G=this.user.username;var F=E.find(function(H){return(H.username===G)});if(F&&F.m&&(F.m>0)){this.window.button.setBlinking(true)}}this.window.onReceiveArchive()},_eoo:true});ComCore.Chat.OnlineFriendsButton=Class.create(ComCore.Chat.Button,{initialize:function($super,A){this.img=$(A).down("img");$super(A)},_eoo:true});ComCore.Chat.SoundManager={beep:function(){if(ComCore.Chat.Settings.soundEnabled===true){var A=parseInt(ComCore.Chat.Settings.soundType,10);if(A===0){return }Sound.play(ComCore.Configuration.get("staticURL")+"/s/i/chat/sounds/"+A+".swf")}}};ComCore.Chat.ScrollController=Class.create({initialize:function(A){this.controller=A;this.conversationButtons=$("chatTabsList");this.chatTabsContainer=$("chatTabsContainer");this.busyScrolling=false;this.attachScrollers();this.controller.observe("onCloseConversation",this.onDelete.bind(this));this.controller.observe("onOpenHiddenWindow",this.onOpenHiddenWindow.bind(this));ComCore.Chat.Button.observe("onBlink",this.handleBlink.bind(this))},handleBlink:function(E){var A=ComCore.Chat.Helper.getWindowPosition();var C=E.button.previousSiblings().length-1;var D=A.left;var B=A.right;if(C>D){this.scrollLeftButton.addNewMessage()}if(C<B){this.scrollRightButton.addNewMessage()}},onOpenHiddenWindow:function(F){var C=this.controller.conversationButton(F.username);var E=C.button.previousSiblings().length-1;var G=this.calculateScrollAmounts();var I=G.right;var A=Math.floor(this.chatTabsContainer.clientWidth/140);var D=G.right+A-1;var B;var H=(function(){C.show().setActive(true)}).bind(this);if(E>D){B=(E-D);this.doScroll((-ComCore.Chat.Constants.TAB_WIDTH*B),[H])}if(E<I){B=I-E;this.doScroll((ComCore.Chat.Constants.TAB_WIDTH*B),[H])}},attachScrollers:function(){this.updateScrollWidth();this.scrollLeftButton=new ComCore.Chat.ScrollButton(this,"LEFT");this.scrollRightButton=new ComCore.Chat.ScrollButton(this,"RIGHT")},updateScrollWidth:function(){this.conversationButtonsRoom=Math.round(this.chatTabsContainer.clientWidth/ComCore.Chat.Constants.TAB_WIDTH);this.chatTabsContainer.setStyle({width:((this.conversationButtonsRoom*ComCore.Chat.Constants.TAB_WIDTH)-1)+"px"})},getConversations:function(){return $$("#chatTabsList li.conversation")},showScrollButtonsIfNecessary:function(){if(this.getConversations().length>this.conversationButtonsRoom){this.scrollLeftButton.show();this.scrollRightButton.show()}else{this.scrollLeftButton.hide();this.scrollRightButton.hide()}},scrollRight:function(A){this.doScroll(ComCore.Chat.Constants.TAB_WIDTH,A)},scrollLeft:function(A){this.doScroll(-ComCore.Chat.Constants.TAB_WIDTH,A)},requestAction:function(B){var C=this.getConversations().length;if(C>this.conversationButtonsRoom){var A=this.calculateScrollAmounts();this.doScroll(-(A.left*ComCore.Chat.Constants.TAB_WIDTH),[B])}else{B()}},doScroll:function(A,B){this.controller.hideConversations();this.currentPosition=parseInt(this.conversationButtons.getStyle("right").replace("px",""),10);ComCore.Chat.ScrollEffect.create(this.conversationButtons,this.currentPosition,(this.currentPosition+A),(function(){this.updateScrollers();B.each(function(C){C()});this.busyScrolling=false}).bind(this))},calculateScrollAmounts:function(){var A;if(this.conversationButtons.getStyle("right")){A=parseInt(this.conversationButtons.getStyle("right").replace("px",""),10)}else{A=0}var B=Math.abs(Math.round(A/140));var D=Math.floor(this.chatTabsContainer.clientWidth/140);var C=(this.getConversations().length-(B+D));return{left:C,right:B}},onDelete:function(B){var A=this.calculateScrollAmounts();var C=[];B.remove();if(A.right>0){this.scrollRight(C)}else{if((A.left-1)>0){this.scrollLeft(C)}}this.updateScrollers()},updateScrollers:function(){var A=this.calculateScrollAmounts();if(A.left>=0){this.scrollLeftButton.updatePageNumber(A.left)}if(A.right>=0){this.scrollRightButton.updatePageNumber(A.right)}this.showScrollButtonsIfNecessary()},_eoo:true});ComCore.Chat.ScrollButton=Class.create(ComCore.Chat.Button,{initialize:function($super,D,C){var A=(C==="LEFT")?"chatScrollLeft":"chatScrollRight";$super(A,false);var B=$(A);this.scrollController=D;this.enabled=false;this.pageNumber=0;this.element=B;this.pageElement=B.down("span");this.conversationButtons=$("chatTabsList");this.type=C;this.element.observe("click",this._buttonClick.bind(this))},addNewMessage:function(){this.setBlinking(true,false)},checkCanStopBlinking:function(){var J=true;var H,A;var G=$("chatTabsList");function I(K){return K.down("small.chatTabUnreadCount").visible()}var C=ComCore.Chat.Helper.getWindowPosition();if(this.type==="LEFT"){var E=($$("#hud li.conversation").length-(C.left+C.right));H=G.childElements();for(var D=E;D>0;D--){A=G.childElements()[H.length-D];if(A&&I(A)){J=false;break}}}else{H=G.select("li.conversation");for(var B=0,F=C.right;B<F;B++){A=H[B];if(A&&I(A)){J=false;break}}}if(J===true){this.setBlinking(false,false)}},_buttonClick:function(C){var B=[];if(this.isBlinking===true){B.push(this.checkCanStopBlinking.bind(this))}if(this.enabled&&(this.scrollController.busyScrolling===false)){this.scrollController.busyScrolling=true;var A=$H(this.scrollController.controller.conversations).values().find(function(D){return(D.b.isActive()===true)});if(A){B.push((function(){if(A.w.isVisible()){A.w.openWindow()}}).bind(this))}if(this.type==="RIGHT"){this.scrollController.scrollRight(B)}else{this.scrollController.scrollLeft(B)}}},updatePageNumber:function(A){this.pageNumber=A;this.pageElement.update(A);if((this.pageNumber===0)&&(this.enabled)){this.disable()}if((this.pageNumber>0)&&(!this.enabled)){this.enable()}},getType:function(){return this.type},enable:function(){this.enabled=true;this.element.removeClassName("disabled")},disable:function(){this.enabled=false;this.element.addClassName("disabled")},_eoo:true});ComCore.Chat.ScrollEffect={create:function(B,E,C,D){if(typeof (Effect)!=="undefined"){var A=new Effect.Tween(B,E,C,{afterFinish:function(){D()},duration:ComCore.Chat.Constants.SCROLL_DURATION},function(F){B.setStyle({right:F+"px"})})}else{if(D){D()}}}};ComCore.Chat.WelcomeConversationWindow=Class.create(ComCore.Chat.ConversationWindow,{initialize:function($super,C,B,A){$super(C,B,A);this.form.hide()},onSendMessage:function(){return },_eoo:true});ComCore.Chat.WelcomeMessage={name:"Netlog",sentWelcome:false,openWindow:true,start:function(A,E){if(E!==undefined){ComCore.Chat.WelcomeMessage.openWindow=E}if(this.sentWelcome===false){this.controller=A;var B={username:this.name,firstname:this.name,name:this.name,status:"online",avatarUrl:ComCore.Configuration.get("staticURL")+"/s/i/chat/netlog-icon.png"};this.controller.onlineFriends.add(this.name,B);var D=new ComCore.Chat.Conversation(B);var C=new ComCore.Chat.ConversationButton(B,this.controller);this.window=new ComCore.Chat.WelcomeConversationWindow(D,C,this.controller);this.controller.conversations.set(this.name,{c:D,b:C,w:this.window});this.controller.onStartChat(this.name);if(!ComCore.Chat.WelcomeMessage.openWindow){this.window.closeWindow()}this.addMessage();this.sentWelcome=true}},addMessage:function(){var A=ComCore.Chat.Messages.chatWelcomeMessage;var B={body:A,username:this.name,date:new Date()};this.window.onMessageAdded({message:B,fromArchive:false})}};ComCore.Chat.PrivacyCheck=Class.create({initialize:function(A){this.controller=A},canSendMessage:function(C){var B=this.controller.userStatus.getPrivacyStatus();if(B==="everyone"){return true}if((B==="friends")||(B==="busy")){var A=this.controller.onlineFriends.get(C);return((A!==undefined)&&(A!==null))}return false},_eoo:true});ComCore.Chat.ChatbarOptions=Class.create({initialize:function(){this.shoutButton=$("hudButtonShouts").down("a");if(this.shoutButton){this.shoutButton.observe("click",this.showShoutDialog.bind(this))}this.minimizeButton=$("hudButtonMinimize").down("a.hudMinimizeButton");this.maximizeButton=$("hudButtonMaximize").down("a.hudMaximizeButton");if(this.minimizeButton&&this.maximizeButton){[this.minimizeButton,this.maximizeButton].each(function(A){A.observe("click",this.onMinimize.bind(this))},this)}},onMinimize:function(A){A.stop();var B=$("hud");if(!B.hasClassName("minimized")){var C=ComCore.Chat.controller.connection.connection;C.stopPoller();C.abortRequest()}B[B.hasClassName("minimized")?"removeClassName":"addClassName"]("minimized");B.setStyle({bottom:""});B.removeClassName("dock");var D=new Ajax.Request(ComCore.Page.buildAjaxURL("chatbar","saveMinimize"),{method:"post",parameters:{keepMinimized:B.hasClassName("minimized")?"YES":"NO"}})},onMaximize:function(A){A.stop();var B=$("hud");B.removeClassName("dock");this.onMinimize(A)},onDocumentClick:function(A){if(!A.findElement("#hudShortcuts")){this.hideShortcuts()}},showShoutDialog:function(A){A.stop();ComCore.Dialog.initialize();ComCore.Dialog.getContent(ComCore.Page.buildAjaxURL(null,"showShoutsDialog&reply="))},_eoo:true});ComCore.Chat.Logging=Class.create({initialize:function(A){this.state=null;this.controller=A;this.logInfo=$A();this.isLogging=false;this.userID=ComCore.Login.getUserID();this.trackingID=parseInt(new Date().getMilliseconds()+parseInt(this.userID,10)+Math.round(Math.random()*1000000),10)},startLog:function(){if(this.state!==null){return false}this.state="START";this.isLogging=true;this.sendStart()},sendRosterError:function(B){if(B!==undefined){this.logInfo.push("EMPTY ROSTER")}else{this.logInfo.push("ROSTER TIMEOUT")}this.isLogging=false;var A=this.logInfo.toJSON();this.sendReport("INVALID",A)},endLog:function(){if(this.state!=="START"){return }this.state="STOP";this.logInfo.push("END: "+new Date().getTime().toString());this.isLogging=false;var A=this.logInfo.toJSON();this.sendReport("STOP",A)},addResponse:function(A,B){if(B&&B.xml()){this.logInfo.push("RESPONSE: ("+A+")"+B.xml().toString())}else{this.logInfo.push("RESPONSE: ("+A+")")}},addRequest:function(A){this.logInfo.push("REQUEST: "+A.toString())},getMetaInfo:function(){var A=window.location.href.split("/");var B=A[4];var C=A[5];return{module:B,submodule:C}},sendStart:function(){this.sendReport("START","")},sendInvalid:function(){this.sendReport("INVALID","")},addCustom:function(A){this.logInfo.push(A)},sendReport:function(D,B){var A=new Image();var F=this.getMetaInfo();var C=$H({module:F.module,submodule:F.submodule,type:D,userID:this.userID,trackID:this.trackingID});if(B&&B.length>0){C.set("information",escape(B))}var G=C.toQueryString();var E=new Ajax.Request("/go/ajax/chatbar/view=saveLogging",{method:"post",parameters:G})},_eoo:true});ComCore.Chat.Controller=Class.create({initialize:function(A){this.connectionParams=A;this.connection=new ComCore.Jabber.Connection(A,this);this.connection.controller=this;this.connection.observe("onMessageReceived",this.onMessageReceived.bind(this));this.connection.observe("onDisconnect",this.onDisconnect.bind(this));this.connection.observe("onReconnect",this.onReconnect.bind(this));this.connection.observe("onConnect",this.onConnect.bind(this));this.connection.observe("onQuit",this.onQuit.bind(this));this.connection.observe("onNewCounters",this.onNewCounters.bind(this));this.connection.observe("onChatStateNotification",this.onChatStateNotification.bind(this));this.connection.observe("onReceiveOnlinePeopleCount",this.updateOnlinePeopleCount.bind(this));if(window.chatStatus&&(window.chatStatus==="onConnect")){this.onConnect()}this.chatBar=$("hud");this.messageQueue=[];this.windowTitle=new ComCore.Chat.WindowTitle();this.loggedClick=false;this.idle=false;ComCore.Chat.Button.observe("onChange",this.onButtonChanged.bind(this));ComCore.Chat.Button.observe("onClose",this.onCloseConversation.bind(this));ComCore.Chat.Window.observe("onClose",this.onCloseConversation.bind(this));ComCore.Chat.Window.observe("onSendMessage",this.onSendMessage.bind(this));this.onlineFriends=new ComCore.Chat.OnlineFriends(this);this.onlineFriendsButton=new ComCore.Chat.OnlineFriendsButton("hudButtonChatLink");this.onlineFriendsWindow=new ComCore.Chat.OnlineFriendsWindow(this.onlineFriends,this.onlineFriendsButton,this);this.onlineFriendsWindow.observe("onStartChat",this.onStartChat.bind(this));this.onlineFriends.observe("onLoaded",this.onLoaded.bind(this));this.onlineFriends.observe("onUserStatusChanged",this.onUserStatusChanged.bind(this));this.idleNotifier=new ComCore.Chat.IdleNotifier();this.chatBarOptions=new ComCore.Chat.ChatbarOptions(this);this.userStatus=new ComCore.Chat.UserStatus(this,this.connection.connectionParams.userStatus);this.state=new ComCore.Chat.State(this);this.conversations=$H();this.chatStatusButton=new ComCore.Chat.ChatStatusButton(this,$("chatStatusButton"));this.chatStatusWindow=new ComCore.Chat.chatStatusWindow(this,this.chatStatusButton);this.scrollController=new ComCore.Chat.ScrollController(this);this.onlineFriendsHeader=new ComCore.Chat.OnlineFriendsWindowHeader(this);this.privacyCheck=new ComCore.Chat.PrivacyCheck(this);this.menuController=new ComCore.Chat.MenuController(this);this.settingsController=new ComCore.Chat.SettingsController(this);this.bubbleFloodContainer={};if(ComCore.Chat.Settings.nudgesEnabled===true){this.nudgeController=new ComCore.Chat.NudgeController(this)}this.restorePreviousSession();ComCore.Chat.UserStatus.observe("onUserStatusChanged",this._statusChange.bind(this));this.debugButton=$("hudDebugButton");if(this.debugButton){this.debugButton.observe("click",this.onToggleDebug.bind(this))}this.games=new ComCore.Chat.Games(this);this.pendingMessages=[];this.observeMainWindow();try{if(ComCore.Chat.trackingEnabled&&(ComCore.Chat.trackingEnabled===true)){this.logging=new ComCore.Chat.Logging(this)}}catch(B){}if($("gameContent")&&(navigator.appVersion.indexOf("Win")!==-1)){}},onToggleDebug:function(A){A.stop();$("logContainer").toggle()},getUserDetails:function(){return{username:this.connectionParams.username.toLowerCase(),avatar:$$("#chatListHeaderLeft img.myAvatar")[0].getAttribute("src"),distro:ComCore.Configuration.get("language"),firstname:this.connectionParams.firstName,shout:escape($$("#chatShout span")[0].innerHTML)}},nudgeReceived:function(A,B){if(this.nudgeController){this.nudgeController.nudgeReceived(A,B)}},updateOnlinePeopleCount:function(A){if(A<=0){$("hudButtonChatCount").hide();return false}$("hudButtonChatCount").update("("+A+")").show()},updateOnlinePeopleCountFromRoster:function(){var A=this.onlineFriends.users.values().findAll(function(B){return((B.status!=="invisible")&&(B.nofriend===undefined))}).length;this.updateOnlinePeopleCount(A)},onChatStateNotification:function(C,B){var A=this.conversationWindow(C);if(A&&(A.button.visible()===true)){A.onChatStateNotification(B)}},onNewCounters:function(B){var A=$H();A.set("messages",$("hudButtonInbox").down("span.hudCounter"));A.set("notifications",$("hudButtonNotifications").down("span.hudCounter"));A.each(function(D){if(B[D.key]){var E=$(D.value);if(E&&(parseInt(B[D.key],10)!==parseInt($(D.value).innerHTML,10))){if(parseInt(B[D.key],10)<=0){E.hide()}else{if(parseInt(B[D.key],10)>99){E.down(".count").update("99+")}else{E.down(".count").update(B[D.key])}E.show();if(typeof (Effect)!=="undefined"){var C=new Effect.Highlight(E,{startcolor:"#ffffff",endcolor:"#cc0000",duration:2})}}}}})},onLoaded:function(){var A=$$("#chatTabsList li.conversation");A.each(function(E){var F=E.getAttribute("id").replace("chatTab_","");var D=this.conversationButton(F);var C=this.onlineFriends.get(F);if(D&&C){D.setStatus(C.status);var B=this.conversationWindow(F);if(B){B.onUserStatusChanged(F,C.status)}}},this)},onQuit:function(A){this.state.updateRoster(this.onlineFriends.users.values());this.state.updateState();this.state.updateJabberStatus(this.userStatus.status)},emptyPendingMessages:function(B){var A;if(B==="everyone"){A=this.pendingMessages;this.pendingMessages=[]}else{A=this.pendingMessages.find(function(C){return(C.isFriend===true)});this.pendingMessages=this.pendingMessages.reject(function(C){return(C.isFriend===true)})}A.each(function(C){this.onMessageReceived({username:C.username,message:C.message})},this)},hideConversations:function(){this.conversations.values().each(function(A){A.w.closeWindow()})},disableChat:function(){$$("#hud div.conversation").invoke("hide");$$("#hud li.conversation").invoke("hide");this.controller.chatStatusButton.setStatus("invisible");this.controller.userStatus.set("invisible",false,"invisible")},observeMainWindow:function(){var A=document;Event.observe(A.onresize?A:window,"resize",this.fixOpenWindows.bind(this));A.observe("click",this.onDocumentClick.bind(this));A.observe("state:idle",this.onStateIdle.bind(this)).observe("state:active",this.onStateActive.bind(this))},onStateIdle:function(){if(this.idle===false){this.userStatus.previousStatus=this.userStatus.status;this.userStatus.status="idle";this.connection.sendIdle(ComCore.Chat.Constants.IDLE_TIMEOUT);this.idle=true;log("you are now idle")}},onStateActive:function(){if(this.idle===true){log("active again");var A=(this.userStatus.previousStatus!=="idle")?this.userStatus.previousStatus:"online";this.connection.sendActive(A);this.userStatus.status=A;this.idle=false}},_statusChange:function(B){var A=B.jabberStatus;this.chatStatusWindow.setStatus(A)},onDocumentClick:function(A){if(!A.findElement("#hud")){this.onlineFriendsWindow.hide()}},fixOpenWindows:function(){if(this.gamesFix){this.gamesFix.poll()}this.onlineFriendsWindow.setPosition();$H(this.conversations).values().each(function(C){if(C.w){C.w.setPosition();C.w.window.style.left=(parseInt(C.w.window.style.left.replace("px",""),10)+4)+"px"}});var A=(this.chatBar.clientWidth/100)*65;var B=Math.floor(A/141);$("chatTabsContainer").setStyle({width:((B*ComCore.Chat.Constants.TAB_WIDTH)-1)+"px"});this.scrollController.updateScrollers()},onReconnect:function(){$("disconnectedWarning").hide();this.userStatus.set("online",true,"everyone");this.showReconnectToAllWindows()},onDisconnect:function(){$("disconnectedWarning").show();$("loadingFriends").hide();this.showDisconnectToAllWindows();log("controller received disconnect")},showReconnectToAllWindows:function(){this.conversations.values().each(function(B){var A=B.w;if(A){A.hideDisconnectedNotification()}})},showDisconnectToAllWindows:function(){this.conversations.values().each(function(B){var A=B.w;if(A){A.showDisconnectedNotification()}})},restorePreviousSession:function(){this.restoreRoster();this.restoreWindows()},restoreRoster:function(){var A=this.state.getRoster();if(A){var F=A.roster;if(F&&(F.constructor===Array)&&(F.length>0)){$("loadingFriends").hide();var D=ComCore.Configuration.get("photoStaticURL")+"/p/tt/000/000/0.jpg";F.each(function(K){var J=unescape(K.u);var I=(K.f!==undefined)?unescape(K.f):unescape(K.u);var H=(K.t!==undefined)?unescape(unescape(K.t)):"";var G=(K.a!==undefined)?ComCore.Chat.Helper.buildImagePath(K.a):D;this.onlineFriends.users.set(unescape(K.u),{username:J,status:K.s,firstname:I,name:I,shout:H,avatarUrl:G,userID:K.id})},this);var E=this.onlineFriends.users.values().reject(function(G){return(G.nofriend&&(G.nofriend===true))});E=ComCore.Chat.Helper.sortList(E);var B=[];E.each(function(G){var H=this.onlineFriendsWindow.addNewOnlineFriend(G);B.push(H.getHTML())},this);var C=$("chatListRoster");C.innerHTML=B.join("")}}},restoreWindows:function(){var A=$$("#chatTabsList li.conversation");if(A.length>0){A.each(function(C){var K=C.down("a");var F=K.className.toLowerCase()||"invisible";var L=parseInt(K.getAttribute("id").replace("chatuser_",""),10);var E=C.getAttribute("id").replace("chatTab_","");var B=$("conversationWindow_"+E);var H=C.down("span.chatTabLabel").innerHTML;if(!B){return }var D=B.down("div.chatShout").innerHTML;var M=B.down("img.avatar").getAttribute("src");var G=this.onlineFriends.get(E);if(G===undefined){G={nofriend:B.hasClassName("nofriend")?true:undefined,name:E,status:F,isArchiveLoaded:true,avatarUrl:M,username:E,shout:D,firstname:H,userID:L};this.onlineFriends.add(E,G)}G.isArchiveLoaded=true;var I={button:C,window:B};this.createConversation(E,I,true);var J=this.conversationButton(E);if(J){J.setStatus(F)}B=this.conversationWindow(E);J.show();if(C.hasClassName("active")){J.active=true}},this)}},onConnect:function(){$("hudButtonChatList").onclick=null;var A=$("hudButtonChatLoading");if(A.visible()){A.hide();this.onlineFriendsWindow.show();this.loggedClick=true;if(this.onlineFriends.isLoaded()===false){this.onlineFriends.load()}}if(ComCore.Chat.Settings.sendWelcomeMessage===true){ComCore.Chat.Settings.sendWelcomeMessage=false;ComCore.Chat.WelcomeMessage.start(this)}},onUserStatusChanged:function(D,C){if(C==="online"){if(this.onlineFriends.isLoaded()===false){this.onlineFriends.load((function(){this.onUserStatusChanged(D,C)}).bind(this));return }var A=this.onlineFriends.get(D);this.showBubble("ONLINEFRIEND",A)}var B=this.conversationButton(D);if(B!==false){B.setStatus(C)}},showBubble:function(D,C){if(ComCore.bubbleManager&&C){var B;var F=this.bubbleFloodContainer[C];if((F!==undefined)&&(F[D]!==undefined)){if((new Date().getTime()-F[D])<20000){return }}if(F===undefined){this.bubbleFloodContainer[C]={}}this.bubbleFloodContainer[C][D]=new Date().getTime();if(D==="ONLINEFRIEND"){var E=(function(H,G){G.stop();if(H){this.onStartChat(H.username)}}).bind(this,C);if(this.onlineFriendsWindow.window.visible()===false){B=ComCore.Chat.Helper.getTranslation("onlineFriend",{name:C.firstname});var A=(C.avatarUrl!==undefined)?'<img class="avatar" src="'+C.avatarUrl+'" />':"0";ComCore.bubbleManager.showBubble("/"+escape(C.username),A,B,ComCore.Chat.Constants.SHOW_BUBBLE_TIME,E)}}else{if(D==="STATUS_CHANGED"){B=ComCore.Chat.Helper.getTranslation("statusChanged");ComCore.bubbleManager.showBubble("#","0",B,ComCore.Chat.Constants.SHOW_BUBBLE_TIME)}else{if(D==="STATUS_CHANGED_TO_EVERYONE"){B=ComCore.Chat.Helper.getTranslation("statusChangedToEveryone");ComCore.bubbleManager.showBubble("#","0",B,ComCore.Chat.Constants.SHOW_BUBBLE_TIME)}}}}},onCloseConversation:function(C,D){this.hideConversations();var B=this.conversationButton(D).button;var A=this.conversationWindow(D);if(A){A.setActive(false);A.hide()}this.notify("onCloseConversation",B)},onButtonChanged:function(B){if(B===this.chatStatusButton){this.chatStatusWindow.toggle();var D=this.conversations.keys().first();if(D){this.conversationWindow(D).hide()}if(B.isActive()){this.onlineFriendsButton.setActive(false)}}else{if(B===this.onlineFriendsButton){if(!this.loggedClick&&this.logging&&(this.onlineFriendsWindow.hasTracked!==true)){this.logging.startLog();this.loggedClick=true}this.onlineFriendsWindow.toggle();if(B.isActive()){this.hideConversations();if(this.onlineFriends.isLoaded()===false){this.onlineFriends.load()}try{$(document).fire("comcore:chat_open")}catch(C){log(C)}}}else{if(B.getType()!=="BUTTON"){}else{var A=this.conversationWindow(B.getID());if(A&&B.isActive()){this.onlineFriendsWindow.hide();this.conversations.values().each(function(E){E.b.setActive(E.b===B)});A.show()}else{if(A){A.hide()}}}}}},conversation:function(A){return this.conversations.get(A).c},conversationWindow:function(A){if(this.conversations.get(A)!==undefined){return this.conversations.get(A).w}return false},conversationButton:function(A){if(this.conversations.get(A)!==undefined){return this.conversations.get(A).b}return false},createConversation:function(D,E,K){if(K===undefined){K=false}var F=this.onlineFriends.get(D);if(F.element===undefined){var B;if(F.nofriend===undefined){B=new ComCore.Chat.OnlineFriendsElement(F)}else{B=new ComCore.Chat.OnlineEveryoneElement(F)}F.element=B}var C,J;if(!this.conversations.get(D)){J=new ComCore.Chat.Conversation(F);C=new ComCore.Chat.ConversationButton(F,this,(E!==undefined)?E.button:undefined);var A=new ComCore.Chat.ConversationWindow(J,C,this,(E!==undefined)?E.window:undefined);if((F.archiveLoading!==true)&&(K===false)){var H=new ComCore.Chat.Archive(this,F,A);F.archiveLoading=true}this.conversations.set(D,{c:J,b:C,w:A})}else{C=this.conversationButton(D)}var I=$("chatTabsList");var G=(parseInt(I.getStyle("width").replace("px",""),10)+150)+"px";I.setStyle({width:G});this.scrollController.updateScrollers();return J},onSendMessage:function(A,F,D){if(D==="/dragon"){ComCore.EasterEggs.showDragon();return }if(ComCore.Chat.Settings.nudgesEnabled===true){var E=D.match(/^\/nudge(.*)/i);if(E&&(E.length>0)){var C=E[1].trim();if(C.length===0){A.addNotification("nudges: "+$H(ComCore.Chat.NudgeController.nudges).keys().invoke("toLowerCase").join(", "))}else{this.nudgeController.sendNudge(C,F)}return }}var B=this.onlineFriends.get(F);if(B&&(this.userStatus.jabberStatus!=="everyone")&&(B.nofriend&&(B.nofriend===true))){this.userStatus.set("online",true,"everyone");this.showBubble("STATUS_CHANGED_TO_EVERYONE",B)}D=ComCore.Chat.FormatText.stripHTML(D);this.connection.sendMessage(F,D)},logStartConversation:function(A){if(A.username){var D={to:A.username};var C=new Ajax.Request(ComCore.Page.buildAjaxURL("chatbar","logConversation"),{parameters:D})}try{$(document).fire("comcore:chat_conversations_startnew",{from_userid:ComCore.Login.getUserID(),to_userid:A.userID})}catch(B){log(B)}},onStartChat:function(D){var B=this.onlineFriends.get(D);if(!B){B={nofriend:true,name:D,status:"online",username:D,avatarUrl:ComCore.Configuration.get("photoStaticURL")+"/p/tt/000/000/0.jpg"};this.onlineFriends.add(D,B)}if(B){if(this.onlineFriends.isLoaded()===false){this.onlineFriends.load()}if(!this.conversations.get(D)){this.logStartConversation(B);this.createConversation(D)}var C=this.conversationButton(D);if(!$(C.button).descendantOf("chatTabsList")){this.regenerateChatEnvironment(B);this.conversationButton(D).showButton(D);return }var A=this.conversationWindow(D);if(A.isVisible()){if(C.button===$("chatTabsList").lastChild){C.showButton(D)}else{C.show().setActive(true)}}else{this.notify("onOpenHiddenWindow",B)}}},isFriend:function(B){var A=this.onlineFriends.users.keys().find(function(C){return(C===B)});return(A!==undefined)},onMessageReceived:function(I){if(this.chatBar.hasClassName("minimized")){this.chatBar.removeClassName("minimized")}var D=I.username;var K=I.message;var J=I.chat;var B=I.playSound;var H=I.type;var F,C,A;F=this.onlineFriends.get(D);if(this.onlineFriends.isLoaded()===false){if(J===undefined){F=(J!==undefined)?J:D;this.onlineFriends.load(this.onMessageReceived.bind(this,I));return }else{if(this.conversations.get(J)){this.onlineFriends.load()}else{this.onlineFriends.load(this.onMessageReceived.bind(this,I));return }}}if(H!==undefined){F=this.onlineFriends.get((J!==undefined)?J:D);if(F&&(F.isArchiveLoaded!==true)){this.createConversation(F.username);A=this.conversationWindow(F.username);A.archiveCallback=this.onMessageReceived.bind(this,I);return false}}var E=true;if(J!==undefined){if(this.conversations.get(J)===undefined){if(this.onlineFriends.get(J)!==undefined){this.createConversation(J)}else{E=false}}if(E){C=this.conversationButton(J);if(C){C.show().setActive(true)}this.conversation(J).addMessage({username:ComCore.TopLogin.getNickname(),message:K,fromArchive:false,type:H,chat:J})}}else{log("onMessageReceived("+D+", "+K+")");if(!F){F={nofriend:true,name:D,firstname:D,status:"online",username:D,avatarUrl:ComCore.Configuration.get("photoStaticURL")+"/p/tt/000/000/0.jpg"};if(I.userid&&(I.userid>0)){F.userID=I.userid}this.onlineFriends.add(D,F);this.createConversation(D)}if(F){if((F.nofriend!==undefined)&&(this.userStatus.jabberStatus==="friends")){return }this.windowTitle.poll(F);if(!this.conversations.get(D)){this.createConversation(D)}C=this.conversationButton(D).button;if(!$(C).descendantOf("chatTabsList")){this.regenerateChatEnvironment(F)}this.conversation(D).addMessage({username:D,message:K,fromArchive:false,type:H});A=this.conversationWindow(D);A.hideOfflineNotice();if((A&&!$(A.window).visible())||(B===true)||(this.windowTitle.hasFocus===false)){ComCore.Chat.SoundManager.beep()}C=this.conversationButton(D);C.setStatus(F.status).show();C.setBlinking(true);try{$(document).fire("comcore:chat_conversations_receivemessage",{from_userid:F.userID,to_userid:ComCore.Login.getUserID()})}catch(G){log(G)}}}this.state.updateState()},regenerateChatEnvironment:function(A){var C=this.conversations.get(A.username);var B=new ComCore.Chat.ConversationButton(A,this);C.b=B;this.conversationWindow(A.username).button=B},startNew:function(E,D){if(this.onlineFriends.isLoaded()===false){ComCore.LoadingIndicator.show();this.onlineFriends.load((function(){this.startNew(E,D)}).bind(this));return }ComCore.LoadingIndicator.hide();var A=$H({nofriend:true,gender:"",age:"",region:"",status:"online",avatarUrl:ComCore.Configuration.get("photoStaticURL")+"/p/tt/000/000/0.jpg",name:E});D=$H(A).merge(D).toObject();if(D.mainphotoid&&!isNaN(D.mainphotoid)){D.avatarUrl=ComCore.Chat.Helper.buildImagePath(D.mainphotoid,D.distro)}var B=this.onlineFriends.get(E.toLowerCase());if(B===undefined){B={name:D.firstname,status:D.status,username:E.toLowerCase(),avatarUrl:D.avatarUrl,userID:D.userID};if(D.nofriend&&(D.nofriend===true)){B.nofriend=true}this.onlineFriends.add(E,B);var C=new ComCore.Chat.OnlineEveryoneElement(B);B.element=C;$("chatListEveryone").insert(B.element.html);this.onlineFriendsWindow.updateContactList("chatListEveryone",B,B.status)}this.onStartChat(B.username)},_eoo:true});ComCore.Chat.MenuController=Class.create({initialize:function(A){this.controller=A;this.menu=$("chatMenuTabs");this.tabs=this.menu.select("a");this.views=[$("chatTabFriends"),$("chatTabEveryone"),$("chatTabSettings")];this.menu.observe("click",this.onMenuClick.bind(this));this.searchFunctions=[$("chatSearchFriends"),$("chatSearchEveryone")];this.everyoneController=new ComCore.Chat.EveryoneController(this)},onMenuClick:function(A){A.stop();var C=(A.element().tagName.toLowerCase()==="a")?A.element():A.element().down("a.menuTab")||A.element().up("a.menuTab");var B=C.getAttribute("id").replace("chatMenuItem","");this.tabs.invoke("removeClassName","selected");C.addClassName("selected");this.controller.chatStatusWindow.hide();this.views.each(function(E){E[(E.getAttribute("id")===("chatTab"+B))?"show":"hide"]()});this.searchFunctions.each(function(E){E[(E.getAttribute("id")===("chatSearch"+B))?"show":"hide"]()});if(B==="Everyone"){this.notify("onEveryoneClick")}else{$("chatRefreshEveryone").hide()}try{$(document).fire("comcore:chat_contactlist_switchtab",{tab:B.toLowerCase()})}catch(D){log(D)}},_eoo:true});ComCore.Events.extend(ComCore.Chat.MenuController);ComCore.Chat.SettingsController=Class.create({initialize:function(A){$("chatSound").observe("change",this.onChatSoundChange.bind(this));$("privacySettings").observe("change",this.saveChatSettings.bind(this));$("disableChatBar").observe("click",this.saveChatSettings.bind(this));$("chatDeleteAllHistory").observe("click",this.onDeleteAllHistory.bind(this));this.controller=A;this.controller.userStatus.observe("onUserStatusChanged",this.changeStatus.bind(this))},onDeleteAllHistory:function(A){A.stop();var D=ComCore.Chat.Helper.getTranslation("clearAllArchives");if(confirm(D)===true){$("savingLoading").show();var C={csrftoken_clearallarchives:ComCore.CSRF.getToken("clearAllArchives")};var B=new Ajax.Request(ComCore.Page.buildAjaxURL("chatbar","clearAllArchives"),{method:"post",parameters:C,onSuccess:this.onDeleteAllHistoryDone.bind(this)})}},onDeleteAllHistoryDone:function(B){if(B.responseJSON.success===true){this.onSaveChatSettingsDone();var A;this.controller.conversations.each(function(C){A=C.value.w;if(A){A.clearArchive()}})}},changeStatus:function(A){if(A!=="invisible"){$("disableChatBar").checked=true}else{$("disableChatBar").checked=false}if((this.controller.userStatus.jabberStatus==="everyone")||(this.controller.userStatus.jabberStatus==="friends")){$("privacySettings").select("option").each(function(B){B.selected=(B.value===this.controller.userStatus.jabberStatus)},this)}},saveChatSettings:function(){var C=$("disableChatBar");$("savingLoading").show();if(C.checked===false){this.controller.userStatus.set("invisible",true,"invisible")}else{if(this.controller.userStatus.status!=="online"){this.controller.userStatus.set("online",true,ComCore.Chat.Settings.chatPrivacy.toLowerCase())}}var G=C.checked?"ACTIVE":"DISABLED";var B=($("privacySettings").selectedIndex===1)?"EVERYONE":"FRIENDS";var A=$("chatSound");var E=A.options[A.selectedIndex].value;if(this.controller.userStatus.status==="online"){this.controller.userStatus.set("online",true,B.toLowerCase())}var F="chatActive="+G+"&privacy="+B+"&sound="+E+"&"+ComCore.CSRF.getParam("saveSettings");var D=new Ajax.Request(ComCore.Page.buildAjaxURL("chatbar","saveSettings"),{method:"post",parameters:F,onSuccess:this.onSaveChatSettingsDone.bind(this)})},onSaveChatSettingsDone:function(A){$("savingLoading").hide();var B=$("savingSuccess");B.show();window.setTimeout(function(){B.hide()},3000)},onChatSoundChange:function(A){A.stop();var C=$("chatSound");var B=parseInt(C.options[C.selectedIndex].value,10);if(B!==0){Sound.play(ComCore.Configuration.get("staticURL")+"/s/i/chat/sounds/"+B+".swf")}ComCore.Chat.Settings.soundType=B;this.saveChatSettings()},_eoo:true});ComCore.Chat.EveryoneController=Class.create({initialize:function(A){this.ajaxLoaded=this.ajaxLoading=false;this.menuController=A;this.menuController.observe("onEveryoneClick",this.onShowView.bind(this));$("chatRefreshEveryone").observe("click",this.onRefreshEveryoneView.bind(this))},onRefreshEveryoneView:function(A){A.stop();this.ajaxLoaded=false;this.loadEveryoneContent()},onShowView:function(A){this.lastFetch=new Date().getTime();$("chatRefreshEveryone").show();if(((this.ajaxLoaded===false)&&(this.ajaxLoading===false))||((new Date().getTime()-this.lastFetch)>ComCore.Chat.Constants.REFRESH_EVERYONE_INTERVAL)){this.loadEveryoneContent()}},loadEveryoneContent:function(){$("chatTabEveryone").down(".hudLoading").show();var A=new Ajax.Request("/go/ajax/chatbar/view=getEveryone",{method:"GET",onCreate:(function(){this.ajaxLoading=true}).bind(this),onSuccess:this.onReceiveEveryoneList.bind(this)})},onReceiveEveryoneList:function(E){$("chatTabEveryone").down(".hudLoading").hide();this.ajaxLoading=true;var B=E.responseJSON;var G=[];var J=[];for(var F=0,H=B.length;F<H;F++){var A=B[F];if(A){A.nickname=A.nickname.toLowerCase();var D={nofriend:true,age:A.age,region:A.region,gender:A.gender,name:A.firstname,status:"online",username:A.nickname,avatarUrl:A.picture,userID:(parseInt(A.userid,10)||0)};var I=this.menuController.controller.onlineFriends.get(D.username);if(I===undefined){this.menuController.controller.onlineFriends.add(D.username,D);D=this.menuController.controller.onlineFriends.get(D.username)}else{D=I}var C=new ComCore.Chat.OnlineEveryoneElement(D);D.element=C;J.push(D)}}var L=this.menuController.controller.onlineFriends.users.values().findAll(function(M){return(M.nofriend&&(M.nofriend===true)&&M.element)});J.each(function(M){G.push(M.element.html)});$("chatListEveryone").innerHTML="";$("chatListEveryone").innerHTML=G.join("");try{$(document).fire("comcore:chat_contactlist_updatelist",{tab:"everyone",contacts_count:B.length})}catch(K){log(K)}},_eoo:true});ComCore.Events.extend(ComCore.Chat.EveryoneController);ComCore.Chat.Games=Class.create({initialize:function(A){this.controller=A},getRoster:function(A){if(this.controller.onlineFriends.rosterLoaded===false){this.controller.onlineFriends.load(this.getRoster.bind(this,A))}else{var B=this.controller.onlineFriends.getRosterDetails();A(B)}},createChallenge:function(C){if(this.controller.onlineFriends.isLoaded()===false){var D=(function(F){this.createChallenge(C)}).bind(this);this.controller.onlineFriends.load(D);return }var B=this.controller.onlineFriends.users.values().find(function(F){return(F.userID===C.netlogid)});var E=escape(Object.toJSON(C));if(B){var A=ComCore.Chat.Helper.getTranslation("gameChallengeArchive",{sender:this.controller.connection.username,game:C.gameName,url:C.gameUrl});this.controller.connection.sendCustomMessage(B.username,A,E)}else{log("Could not find user!")}},challengeReceived:function(C,E){var A=unescape(C);var D=null;try{D=A.evalJSON()}catch(B){log(B)}if((D!==null)&&(D.gameName!==undefined)){this.displayChallenge(D,E)}},createBody:function(E){var A=E.body;var G=ComCore.Chat.Helper.getTranslation("gameChallengeString",{sender:E.username,game:A.gameName});var J=ComCore.Chat.Helper.getTranslation("gameChallengeLink");var D=new Element("img",{src:A.gameThumbnail});var H=$("gameChallengeClone").cloneNode(true);var C=H.down(".gameImage");var F=H.down(".gameDescription");var B=((/go\/explore\/games\/((.*)+)/i).test(window.location.href)===true)?"_blank":"_self";var I=new Element("a",{href:A.gameUrl,target:B}).update(J);C.insert(D);F.insert(G);F.insert(new Element("br"));F.insert(I);return H.innerHTML},createChallengeSentBody:function(G,C){var A=unescape(G.body).evalJSON();var D=ComCore.Chat.Helper.getTranslation("gameChallengeSent",{receiver:C,game:A.gameName});var B=new Element("img",{src:A.gameThumbnail});var H=$("gameChallengeClone").cloneNode(true);var F=H.down(".gameImage");var E=H.down(".gameDescription");F.insert(B);E.insert(D);return H.innerHTML},displayChallenge:function(A,B){this.controller.onMessageReceived({username:B,message:A,playSound:false,type:"game"})},_eoo:true});ComCore.Chat.GamesFix=Class.create({initialize:function(A){this.controller=A;ComCore.Chat.GamesFix.originalHeight=$$("#gameContent iframe").first().getHeight();Event.observe(window,"scroll",this.poll.bind(this))},getPositions:function(){var B=((this.getInnerHeight()+this.getScrollTop())-$("hud").clientHeight);var A=$("gameContent").cumulativeOffset()[1];return{b:B,g:A}},getScrollTop:function(){var A=document;if(A.documentElement&&A.documentElement.scrollTop){return A.documentElement.scrollTop}return A.body.scrollTop},getInnerHeight:function(){var A;if(self.innerHeight){A=self.innerHeight}else{if(document.documentElement&&document.documentElement.clientWidth){A=document.documentElement.clientHeight}else{if(document.body){A=document.body.clientHeight}}}return A},isOverlapping:function(){var A=this.getPositions();var D=A.b;var C=A.g;var B=((D>=C)&&(D<=(C+$("gameContent").getHeight())));return B},poll:function(){var B=$$("#gameContent iframe").first();if(this.isOverlapping()===true){var A=this.getPositions();var C=(A.b-A.g)-22;B.setStyle({height:C+"px"})}else{if(B.getHeight()!==ComCore.Chat.GamesFix.originalHeight){B.setStyle({height:ComCore.Chat.GamesFix.originalHeight+"px"})}}},_eoo:true});ComCore.Chat.GamesFix.setOriginalHeight=function(A){ComCore.Chat.GamesFix.originalHeight=A};ComCore.Chat.WindowTitle=Class.create({initialize:function(){this.setFocusEvents();this.originalTitle=document.title;this.hasFocus=true;this.newMessages=0;this.isScrolling=false},poll:function(A){if(!this.hasFocus){if(this.isScrolling===false){var B=ComCore.Chat.Helper.getTranslation("newChatMessageReceived",{username:A.name});this.scrollTitle(B)}}},scrollTitle:function(A){if(this.scrollTimeout){window.clearTimeout(this.scrollTimeout)}A=A.substring(1,A.length)+A.substring(0,1);document.title=A;this.isScrolling=true;this.scrollTimeout=window.setTimeout((function(){this.scrollTitle(A)}).bind(this),600)},setFocusEvents:function(){this.active_element=document.activeElement;var A=document;if(Prototype.Browser.IE){A.observe("onfocusout",this.onWindowBlur.bind(this));A.observe("onfocusin",this.onWindowFocus.bind(this))}else{window.onblur=this.onWindowBlur.bind(this);window.onfocus=this.onWindowFocus.bind(this);A.onblur=window.onblur.bind(this);A.focus=window.onfocus.bind(this)}},onWindowFocus:function(B){var A=document;if(this.scrollTimeout){window.clearTimeout(this.scrollTimeout);this.isScrolling=false}if(A.title!==this.originalTitle){A.title=this.originalTitle}this.hasFocus=true;this.notify("onWindowFocus")},onWindowBlur:function(A){this.hasFocus=false;if(this.active_element!==document.activeElement){this.active_element=document.activeElement}},_eoo:true});ComCore.Events.extend(ComCore.Chat.WindowTitle);ComCore.Events.extend(ComCore.Chat.Controller);ComCore.Chat.IdleNotifier=Class.create({_events:[[window,"scroll"],[window,"resize"],[document,"mousemove"],[document,"keydown"]],_timer:null,_idleTime:null,initialize:function(){this.initObservers();this.setTimer()},initObservers:function(){this._events.each((function(A){Event.observe(A[0],A[1],this.onInterrupt.bind(this))}).bind(this))},onInterrupt:function(){document.fire("state:active",{idleTime:(new Date()-this._idleTime)});this.setTimer()},setTimer:function(){window.clearTimeout(this._timer);this._idleTime=new Date();this._timer=window.setTimeout(function(){document.fire("state:idle")},ComCore.Chat.Constants.IDLE_TIMEOUT)},_eoo:true});ComCore.Chat.NudgeController=Class.create({initialize:function(A){this.nudges=ComCore.Chat.NudgeController.nudges;this.floodCheck=[];this.controller=A;this.pendingNudges=[];this.isNudgeVisible=false;this.controller.windowTitle.observe("onWindowFocus",this.emptyQueue.bind(this))},emptyQueue:function(){if(this.pendingNudges.length>3){this.pendingNudges=this.pendingNudges.slice(0,3)}if(this.pendingNudges.length>0){var A=this.pendingNudges.shift();this.nudgeReceived(A[0],A[1])}},sendNudge:function(A,B){if(this.nudges[A.toUpperCase()]){log("sending nudge");this.controller.connection.sendNudge(this.nudges[A.toUpperCase()].cmd,B)}},nudgeReceived:function(D,G){if(this.nudges[D.toUpperCase()]===undefined){log("Received unknown nudge");return }if(this.isNudgeVisible===true){this.pendingNudges.push([D,G]);return }if(this.controller.windowTitle.hasFocus===false){this.controller.windowTitle.scrollTitle("You received a nudge from "+G+" ");this.pendingNudges.push([D,G]);return false}var F=this.floodCheck.any(function(H){return(((new Date().getTime()-H.timestamp)<30000)&&(H.username===G))});if(F===true){return }this.floodCheck.push({timestamp:new Date().getTime(),username:G});if(!this.controller.conversations.get(G)){this.controller.createConversation(G)}var C=this.controller.conversationWindow(G);this.controller.onStartChat(G);if(C){C.addNotification("You received a nudge!")}var B=this.nudges[D.toUpperCase()].ttl;log("received a nudge!!");var E=new Element("embed",{id:"currentNudge",src:ComCore.Configuration.get("staticURL")+"/s/f/chat/"+D+".swf",wmode:"transparent",loop:"false",style:"width: 100%; height: 90%; position:absolute; top:0px; left:0px; z-index: 99999"});var A=$("currentNudge");if(A){A.remove()}window.setTimeout((function(){$("currentNudge").remove();this.isNudgeVisible=false;this.emptyQueue()}).bind(this),(B*1000));document.body.insert(E)},_eoo:true});ComCore.Chat.NudgeController.nudges={FART:{cmd:"fart",ttl:10},BUNNY:{cmd:"bunny",ttl:10},CRY:{cmd:"cry",ttl:5},CUPID:{cmd:"cupid",ttl:7},KISS:{cmd:"kiss",ttl:7},PANIC:{cmd:"panic",ttl:12},PENGUIN:{cmd:"penguin",ttl:14},SEXY:{cmd:"sexy",ttl:10},AMADEUS:{cmd:"amadeus",ttl:5}};