var MooTools={version:"1.2.5",build:"008d8f0f2fcc2044e54fdd3635341aaab274e757"};var Native=function(l){l=l||{};var a=l.name;var j=l.legacy;var b=l.protect;var c=l.implement;var i=l.generics;var g=l.initialize;var h=l.afterImplement||function(){};var d=g||j;i=i!==false;d.constructor=Native;d.$family={name:"native"};if(j&&g){d.prototype=j.prototype}d.prototype.constructor=d;if(a){var f=a.toLowerCase();d.prototype.$family={name:f};Native.typize(d,f)}var k=function(o,m,p,n){if(!b||n||!o.prototype[m]){o.prototype[m]=p}if(i){Native.genericize(o,m,b)}h.call(o,m,p);return o};d.alias=function(o,m,q){if(typeof o=="string"){var p=this.prototype[o];if((o=p)){return k(this,m,o,q)}}for(var n in o){this.alias(n,o[n],m)}return this};d.implement=function(n,m,q){if(typeof n=="string"){return k(this,n,m,q)}for(var o in n){k(this,o,n[o],m)}return this};if(c){d.implement(c)}return d};Native.genericize=function(b,c,a){if((!a||!b[c])&&typeof b.prototype[c]=="function"){b[c]=function(){var d=Array.prototype.slice.call(arguments);return b.prototype[c].apply(d.shift(),d)}}};Native.implement=function(d,c){for(var b=0,a=d.length;b<a;b++){d[b].implement(c)}};Native.typize=function(a,b){if(!a.type){a.type=function(c){return($type(c)===b)}}};(function(){var a={Array:Array,Date:Date,Function:Function,Number:Number,RegExp:RegExp,String:String};for(var j in a){new Native({name:j,initialize:a[j],protect:true})}var d={"boolean":Boolean,"native":Native,object:Object};for(var c in d){Native.typize(d[c],c)}var h={Array:["concat","indexOf","join","lastIndexOf","pop","push","reverse","shift","slice","sort","splice","toString","unshift","valueOf"],String:["charAt","charCodeAt","concat","indexOf","lastIndexOf","match","replace","search","slice","split","substr","substring","toLowerCase","toUpperCase","valueOf"]};for(var f in h){for(var b=h[f].length;b--;){Native.genericize(a[f],h[f][b],true)}}})();var Hash=new Native({name:"Hash",initialize:function(a){if($type(a)=="hash"){a=$unlink(a.getClean())}for(var b in a){this[b]=a[b]}return this}});Hash.implement({forEach:function(b,c){for(var a in this){if(this.hasOwnProperty(a)){b.call(c,this[a],a,this)}}},getClean:function(){var b={};for(var a in this){if(this.hasOwnProperty(a)){b[a]=this[a]}}return b},getLength:function(){var b=0;for(var a in this){if(this.hasOwnProperty(a)){b++}}return b}});Hash.alias("forEach","each");Array.implement({forEach:function(c,d){for(var b=0,a=this.length;b<a;b++){c.call(d,this[b],b,this)}}});Array.alias("forEach","each");function $A(b){if(b.item){var a=b.length,c=new Array(a);while(a--){c[a]=b[a]}return c}return Array.prototype.slice.call(b)}function $arguments(a){return function(){return arguments[a]}}function $chk(a){return !!(a||a===0)}function $clear(a){clearTimeout(a);clearInterval(a);return null}function $defined(a){return(a!=undefined)}function $each(c,b,d){var a=$type(c);((a=="arguments"||a=="collection"||a=="array")?Array:Hash).each(c,b,d)}function $empty(){}function $extend(c,a){for(var b in (a||{})){c[b]=a[b]}return c}function $H(a){return new Hash(a)}function $lambda(a){return($type(a)=="function")?a:function(){return a}}function $merge(){var a=Array.slice(arguments);a.unshift({});return $mixin.apply(null,a)}function $mixin(f){for(var d=1,a=arguments.length;d<a;d++){var b=arguments[d];if($type(b)!="object"){continue}for(var c in b){var h=b[c],g=f[c];f[c]=(g&&$type(h)=="object"&&$type(g)=="object")?$mixin(g,h):$unlink(h)}}return f}function $pick(){for(var b=0,a=arguments.length;b<a;b++){if(arguments[b]!=undefined){return arguments[b]}}return null}function $random(b,a){return Math.floor(Math.random()*(a-b+1)+b)}function $splat(b){var a=$type(b);return(a)?((a!="array"&&a!="arguments")?[b]:b):[]}var $time=Date.now||function(){return +new Date};function $try(){for(var b=0,a=arguments.length;b<a;b++){try{return arguments[b]()}catch(c){}}return null}function $type(a){if(a==undefined){return false}if(a.$family){return(a.$family.name=="number"&&!isFinite(a))?false:a.$family.name}if(a.nodeName){switch(a.nodeType){case 1:return"element";case 3:return(/\S/).test(a.nodeValue)?"textnode":"whitespace"}}else{if(typeof a.length=="number"){if(a.callee){return"arguments"}else{if(a.item){return"collection"}}}}return typeof a}function $unlink(c){var b;switch($type(c)){case"object":b={};for(var f in c){b[f]=$unlink(c[f])}break;case"hash":b=new Hash(c);break;case"array":b=[];for(var d=0,a=c.length;d<a;d++){b[d]=$unlink(c[d])}break;default:return c}return b}var Browser=$merge({Engine:{name:"unknown",version:0},Platform:{name:(window.orientation!=undefined)?"ipod":(navigator.platform.match(/mac|win|linux/i)||["other"])[0].toLowerCase()},Features:{xpath:!!(document.evaluate),air:!!(window.runtime),query:!!(document.querySelector)},Plugins:{},Engines:{presto:function(){return(!window.opera)?false:((arguments.callee.caller)?960:((document.getElementsByClassName)?950:925))},trident:function(){return(!window.ActiveXObject)?false:((window.XMLHttpRequest)?((document.querySelectorAll)?6:5):4)},webkit:function(){return(navigator.taintEnabled)?false:((Browser.Features.xpath)?((Browser.Features.query)?525:420):419)},gecko:function(){return(!document.getBoxObjectFor&&window.mozInnerScreenX==null)?false:((document.getElementsByClassName)?19:18)}}},Browser||{});Browser.Platform[Browser.Platform.name]=true;Browser.detect=function(){for(var b in this.Engines){var a=this.Engines[b]();if(a){this.Engine={name:b,version:a};this.Engine[b]=this.Engine[b+a]=true;break}}return{name:b,version:a}};Browser.detect();Browser.Request=function(){return $try(function(){return new XMLHttpRequest()},function(){return new ActiveXObject("MSXML2.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")})};Browser.Features.xhr=!!(Browser.Request());Browser.Plugins.Flash=(function(){var a=($try(function(){return navigator.plugins["Shockwave Flash"].description},function(){return new ActiveXObject("ShockwaveFlash.ShockwaveFlash").GetVariable("$version")})||"0 r0").match(/\d+/g);return{version:parseInt(a[0]||0+"."+a[1],10)||0,build:parseInt(a[2],10)||0}})();function $exec(b){if(!b){return b}if(window.execScript){window.execScript(b)}else{var a=document.createElement("script");a.setAttribute("type","text/javascript");a[(Browser.Engine.webkit&&Browser.Engine.version<420)?"innerText":"text"]=b;document.head.appendChild(a);document.head.removeChild(a)}return b}Native.UID=1;var $uid=(Browser.Engine.trident)?function(a){return(a.uid||(a.uid=[Native.UID++]))[0]}:function(a){return a.uid||(a.uid=Native.UID++)};var Window=new Native({name:"Window",legacy:(Browser.Engine.trident)?null:window.Window,initialize:function(a){$uid(a);if(!a.Element){a.Element=$empty;if(Browser.Engine.webkit){a.document.createElement("iframe")}a.Element.prototype=(Browser.Engine.webkit)?window["[[DOMElement.prototype]]"]:{}}a.document.window=a;return $extend(a,Window.Prototype)},afterImplement:function(b,a){window[b]=Window.Prototype[b]=a}});Window.Prototype={$family:{name:"window"}};new Window(window);var Document=new Native({name:"Document",legacy:(Browser.Engine.trident)?null:window.Document,initialize:function(a){$uid(a);a.head=a.getElementsByTagName("head")[0];a.html=a.getElementsByTagName("html")[0];if(Browser.Engine.trident&&Browser.Engine.version<=4){$try(function(){a.execCommand("BackgroundImageCache",false,true)})}if(Browser.Engine.trident){a.window.attachEvent("onunload",function(){a.window.detachEvent("onunload",arguments.callee);a.head=a.html=a.window=null})}return $extend(a,Document.Prototype)},afterImplement:function(b,a){document[b]=Document.Prototype[b]=a}});Document.Prototype={$family:{name:"document"}};new Document(document);Array.implement({every:function(c,d){for(var b=0,a=this.length;b<a;b++){if(!c.call(d,this[b],b,this)){return false}}return true},filter:function(d,f){var c=[];for(var b=0,a=this.length;b<a;b++){if(d.call(f,this[b],b,this)){c.push(this[b])}}return c},clean:function(){return this.filter($defined)},indexOf:function(c,d){var a=this.length;for(var b=(d<0)?Math.max(0,a+d):d||0;b<a;b++){if(this[b]===c){return b}}return -1},map:function(d,f){var c=[];for(var b=0,a=this.length;b<a;b++){c[b]=d.call(f,this[b],b,this)}return c},some:function(c,d){for(var b=0,a=this.length;b<a;b++){if(c.call(d,this[b],b,this)){return true}}return false},associate:function(c){var d={},b=Math.min(this.length,c.length);for(var a=0;a<b;a++){d[c[a]]=this[a]}return d},link:function(c){var a={};for(var f=0,b=this.length;f<b;f++){for(var d in c){if(c[d](this[f])){a[d]=this[f];delete c[d];break}}}return a},contains:function(a,b){return this.indexOf(a,b)!=-1},extend:function(c){for(var b=0,a=c.length;b<a;b++){this.push(c[b])}return this},getLast:function(){return(this.length)?this[this.length-1]:null},getRandom:function(){return(this.length)?this[$random(0,this.length-1)]:null},include:function(a){if(!this.contains(a)){this.push(a)}return this},combine:function(c){for(var b=0,a=c.length;b<a;b++){this.include(c[b])}return this},erase:function(b){for(var a=this.length;a--;a){if(this[a]===b){this.splice(a,1)}}return this},empty:function(){this.length=0;return this},flatten:function(){var d=[];for(var b=0,a=this.length;b<a;b++){var c=$type(this[b]);if(!c){continue}d=d.concat((c=="array"||c=="collection"||c=="arguments")?Array.flatten(this[b]):this[b])}return d},hexToRgb:function(b){if(this.length!=3){return null}var a=this.map(function(c){if(c.length==1){c+=c}return c.toInt(16)});return(b)?a:"rgb("+a+")"},rgbToHex:function(d){if(this.length<3){return null}if(this.length==4&&this[3]==0&&!d){return"transparent"}var b=[];for(var a=0;a<3;a++){var c=(this[a]-0).toString(16);b.push((c.length==1)?"0"+c:c)}return(d)?b:"#"+b.join("")}});try{delete Function.prototype.bind}catch(e){}Function.implement({extend:function(a){for(var b in a){this[b]=a[b]}return this},create:function(b){var a=this;b=b||{};return function(d){var c=b.arguments;c=(c!=undefined)?$splat(c):Array.slice(arguments,(b.event)?1:0);if(b.event){c=[d||window.event].extend(c)}var f=function(){return a.apply(b.bind||null,c)};if(b.delay){return setTimeout(f,b.delay)}if(b.periodical){return setInterval(f,b.periodical)}if(b.attempt){return $try(f)}return f()}},run:function(a,b){return this.apply(b,$splat(a))},pass:function(a,b){return this.create({bind:b,arguments:a})},bind:function(b,a){return this.create({bind:b,arguments:a})},bindWithEvent:function(b,a){return this.create({bind:b,arguments:a,event:true})},attempt:function(a,b){return this.create({bind:b,arguments:a,attempt:true})()},delay:function(b,c,a){return this.create({bind:c,arguments:a,delay:b})()},periodical:function(c,b,a){return this.create({bind:b,arguments:a,periodical:c})()}});Number.implement({limit:function(b,a){return Math.min(a,Math.max(b,this))},round:function(a){a=Math.pow(10,a||0);return Math.round(this*a)/a},times:function(b,c){for(var a=0;a<this;a++){b.call(c,a,this)}},toFloat:function(){return parseFloat(this)},toInt:function(a){return parseInt(this,a||10)}});Number.alias("times","each");(function(b){var a={};b.each(function(c){if(!Number[c]){a[c]=function(){return Math[c].apply(null,[this].concat($A(arguments)))}}});Number.implement(a)})(["abs","acos","asin","atan","atan2","ceil","cos","exp","floor","log","max","min","pow","sin","sqrt","tan"]);String.implement({test:function(a,b){return((typeof a=="string")?new RegExp(a,b):a).test(this)},contains:function(a,b){return(b)?(b+this+b).indexOf(b+a+b)>-1:this.indexOf(a)>-1},trim:function(){return this.replace(/^\s+|\s+$/g,"")},clean:function(){return this.replace(/\s+/g," ").trim()},camelCase:function(){return this.replace(/-\D/g,function(a){return a.charAt(1).toUpperCase()})},hyphenate:function(){return this.replace(/[A-Z]/g,function(a){return("-"+a.charAt(0).toLowerCase())})},capitalize:function(){return this.replace(/\b[a-z]/g,function(a){return a.toUpperCase()})},escapeRegExp:function(){return this.replace(/([-.*+?^${}()|[\]\/\\])/g,"\\$1")},toInt:function(a){return parseInt(this,a||10)},toFloat:function(){return parseFloat(this)},hexToRgb:function(b){var a=this.match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/);return(a)?a.slice(1).hexToRgb(b):null},rgbToHex:function(b){var a=this.match(/\d{1,3}/g);return(a)?a.rgbToHex(b):null},stripScripts:function(b){var a="";var c=this.replace(/<script[^>]*>([\s\S]*?)<\/script>/gi,function(){a+=arguments[1]+"\n";return""});if(b===true){$exec(a)}else{if($type(b)=="function"){b(a,c)}}return c},substitute:function(a,b){return this.replace(b||(/\\?\{([^{}]+)\}/g),function(d,c){if(d.charAt(0)=="\\"){return d.slice(1)}return(a[c]!=undefined)?a[c]:""})}});Hash.implement({has:Object.prototype.hasOwnProperty,keyOf:function(b){for(var a in this){if(this.hasOwnProperty(a)&&this[a]===b){return a}}return null},hasValue:function(a){return(Hash.keyOf(this,a)!==null)},extend:function(a){Hash.each(a||{},function(c,b){Hash.set(this,b,c)},this);return this},combine:function(a){Hash.each(a||{},function(c,b){Hash.include(this,b,c)},this);return this},erase:function(a){if(this.hasOwnProperty(a)){delete this[a]}return this},get:function(a){return(this.hasOwnProperty(a))?this[a]:null},set:function(a,b){if(!this[a]||this.hasOwnProperty(a)){this[a]=b}return this},empty:function(){Hash.each(this,function(b,a){delete this[a]},this);return this},include:function(a,b){if(this[a]==undefined){this[a]=b}return this},map:function(b,c){var a=new Hash;Hash.each(this,function(f,d){a.set(d,b.call(c,f,d,this))},this);return a},filter:function(b,c){var a=new Hash;Hash.each(this,function(f,d){if(b.call(c,f,d,this)){a.set(d,f)}},this);return a},every:function(b,c){for(var a in this){if(this.hasOwnProperty(a)&&!b.call(c,this[a],a)){return false}}return true},some:function(b,c){for(var a in this){if(this.hasOwnProperty(a)&&b.call(c,this[a],a)){return true}}return false},getKeys:function(){var a=[];Hash.each(this,function(c,b){a.push(b)});return a},getValues:function(){var a=[];Hash.each(this,function(b){a.push(b)});return a},toQueryString:function(a){var b=[];Hash.each(this,function(g,f){if(a){f=a+"["+f+"]"}var d;switch($type(g)){case"object":d=Hash.toQueryString(g,f);break;case"array":var c={};g.each(function(j,h){c[h]=j});d=Hash.toQueryString(c,f);break;default:d=f+"="+encodeURIComponent(g)}if(g!=undefined){b.push(d)}});return b.join("&")}});Hash.alias({keyOf:"indexOf",hasValue:"contains"});var Event=new Native({name:"Event",initialize:function(a,g){g=g||window;var l=g.document;a=a||g.event;if(a.$extended){return a}this.$extended=true;var k=a.type;var h=a.target||a.srcElement;while(h&&h.nodeType==3){h=h.parentNode}if(k.test(/key/)){var b=a.which||a.keyCode;var n=Event.Keys.keyOf(b);if(k=="keydown"){var d=b-111;if(d>0&&d<13){n="f"+d}}n=n||String.fromCharCode(b).toLowerCase()}else{if(k.match(/(click|mouse|menu)/i)){l=(!l.compatMode||l.compatMode=="CSS1Compat")?l.html:l.body;var j={x:a.pageX||a.clientX+l.scrollLeft,y:a.pageY||a.clientY+l.scrollTop};var c={x:(a.pageX)?a.pageX-g.pageXOffset:a.clientX,y:(a.pageY)?a.pageY-g.pageYOffset:a.clientY};if(k.match(/DOMMouseScroll|mousewheel/)){var i=(a.wheelDelta)?a.wheelDelta/120:-(a.detail||0)/3}var f=(a.which==3)||(a.button==2);var m=null;if(k.match(/over|out/)){switch(k){case"mouseover":m=a.relatedTarget||a.fromElement;break;case"mouseout":m=a.relatedTarget||a.toElement}if(!(function(){while(m&&m.nodeType==3){m=m.parentNode}return true}).create({attempt:Browser.Engine.gecko})()){m=false}}}}return $extend(this,{event:a,type:k,page:j,client:c,rightClick:f,wheel:i,relatedTarget:m,target:h,code:b,key:n,shift:a.shiftKey,control:a.ctrlKey,alt:a.altKey,meta:a.metaKey})}});Event.Keys=new Hash({enter:13,up:38,down:40,left:37,right:39,esc:27,space:32,backspace:8,tab:9,"delete":46});Event.implement({stop:function(){return this.stopPropagation().preventDefault()},stopPropagation:function(){if(this.event.stopPropagation){this.event.stopPropagation()}else{this.event.cancelBubble=true}return this},preventDefault:function(){if(this.event.preventDefault){this.event.preventDefault()}else{this.event.returnValue=false}return this}});function Class(b){if(b instanceof Function){b={initialize:b}}var a=function(){Object.reset(this);if(a._prototyping){return this}this._current=$empty;var c=(this.initialize)?this.initialize.apply(this,arguments):this;delete this._current;delete this.caller;return c}.extend(this);a.implement(b);a.constructor=Class;a.prototype.constructor=a;return a}Function.prototype.protect=function(){this._protected=true;return this};Object.reset=function(a,c){if(c==null){for(var f in a){Object.reset(a,f)}return a}delete a[c];switch($type(a[c])){case"object":var d=function(){};d.prototype=a[c];var b=new d;a[c]=Object.reset(b);break;case"array":a[c]=$unlink(a[c]);break}return a};new Native({name:"Class",initialize:Class}).extend({instantiate:function(b){b._prototyping=true;var a=new b;delete b._prototyping;return a},wrap:function(a,b,c){if(c._origin){c=c._origin}return function(){if(c._protected&&this._current==null){throw new Error('The method "'+b+'" cannot be called.')}var f=this.caller,g=this._current;this.caller=g;this._current=arguments.callee;var d=c.apply(this,arguments);this._current=g;this.caller=f;return d}.extend({_owner:a,_origin:c,_name:b})}});Class.implement({implement:function(a,d){if($type(a)=="object"){for(var f in a){this.implement(f,a[f])}return this}var g=Class.Mutators[a];if(g){d=g.call(this,d);if(d==null){return this}}var c=this.prototype;switch($type(d)){case"function":if(d._hidden){return this}c[a]=Class.wrap(this,a,d);break;case"object":var b=c[a];if($type(b)=="object"){$mixin(b,d)}else{c[a]=$unlink(d)}break;case"array":c[a]=$unlink(d);break;default:c[a]=d}return this}});Class.Mutators={Extends:function(a){this.parent=a;this.prototype=Class.instantiate(a);this.implement("parent",function(){var b=this.caller._name,c=this.caller._owner.parent.prototype[b];if(!c){throw new Error('The method "'+b+'" has no parent.')}return c.apply(this,arguments)}.protect())},Implements:function(a){$splat(a).each(function(b){if(b instanceof Function){b=Class.instantiate(b)}this.implement(b)},this)}};var Chain=new Class({$chain:[],chain:function(){this.$chain.extend(Array.flatten(arguments));return this},callChain:function(){return(this.$chain.length)?this.$chain.shift().apply(this,arguments):false},clearChain:function(){this.$chain.empty();return this}});var Events=new Class({$events:{},addEvent:function(c,b,a){c=Events.removeOn(c);if(b!=$empty){this.$events[c]=this.$events[c]||[];this.$events[c].include(b);if(a){b.internal=true}}return this},addEvents:function(a){for(var b in a){this.addEvent(b,a[b])}return this},fireEvent:function(c,b,a){c=Events.removeOn(c);if(!this.$events||!this.$events[c]){return this}this.$events[c].each(function(d){d.create({bind:this,delay:a,"arguments":b})()},this);return this},removeEvent:function(b,a){b=Events.removeOn(b);if(!this.$events[b]){return this}if(!a.internal){this.$events[b].erase(a)}return this},removeEvents:function(c){var d;if($type(c)=="object"){for(d in c){this.removeEvent(d,c[d])}return this}if(c){c=Events.removeOn(c)}for(d in this.$events){if(c&&c!=d){continue}var b=this.$events[d];for(var a=b.length;a--;a){this.removeEvent(d,b[a])}}return this}});Events.removeOn=function(a){return a.replace(/^on([A-Z])/,function(b,c){return c.toLowerCase()})};var Options=new Class({setOptions:function(){this.options=$merge.run([this.options].extend(arguments));if(!this.addEvent){return this}for(var a in this.options){if($type(this.options[a])!="function"||!(/^on[A-Z]/).test(a)){continue}this.addEvent(a,this.options[a]);delete this.options[a]}return this}});var Cookie=new Class({Implements:Options,options:{path:false,domain:false,duration:false,secure:false,document:document},initialize:function(b,a){this.key=b;this.setOptions(a)},write:function(b){b=encodeURIComponent(b);if(this.options.domain){b+="; domain="+this.options.domain}if(this.options.path){b+="; path="+this.options.path}if(this.options.duration){var a=new Date();a.setTime(a.getTime()+this.options.duration*24*60*60*1000);b+="; expires="+a.toGMTString()}if(this.options.secure){b+="; secure"}this.options.document.cookie=this.key+"="+b;return this},read:function(){var a=this.options.document.cookie.match("(?:^|;)\\s*"+this.key.escapeRegExp()+"=([^;]*)");return(a)?decodeURIComponent(a[1]):null},dispose:function(){new Cookie(this.key,$merge(this.options,{duration:-1})).write("");return this}});Cookie.write=function(b,c,a){return new Cookie(b,a).write(c)};Cookie.read=function(a){return new Cookie(a).read()};Cookie.dispose=function(b,a){return new Cookie(b,a).dispose()};var Request=new Class({Implements:[Chain,Events,Options],options:{url:"",data:"",headers:{"X-Requested-With":"XMLHttpRequest",Accept:"text/javascript, text/html, application/xml, text/xml, */*"},async:true,format:false,method:"post",link:"ignore",isSuccess:null,emulation:true,urlEncoded:true,encoding:"utf-8",evalScripts:false,evalResponse:false,noCache:false},initialize:function(a){this.xhr=new Browser.Request();this.setOptions(a);this.options.isSuccess=this.options.isSuccess||this.isSuccess;this.headers=new Hash(this.options.headers)},onStateChange:function(){if(this.xhr.readyState!=4||!this.running){return}this.running=false;this.status=0;$try(function(){this.status=this.xhr.status}.bind(this));this.xhr.onreadystatechange=$empty;if(this.options.isSuccess.call(this,this.status)){this.response={text:this.xhr.responseText,xml:this.xhr.responseXML};this.success(this.response.text,this.response.xml)}else{this.response={text:null,xml:null};this.failure()}},isSuccess:function(){return((this.status>=200)&&(this.status<300))},processScripts:function(a){if(this.options.evalResponse||(/(ecma|java)script/).test(this.getHeader("Content-type"))){return $exec(a)}return a.stripScripts(this.options.evalScripts)},success:function(b,a){this.onSuccess(this.processScripts(b),a)},onSuccess:function(){this.fireEvent("complete",arguments).fireEvent("success",arguments).callChain()},failure:function(){this.onFailure()},onFailure:function(){this.fireEvent("complete").fireEvent("failure",this.xhr)},setHeader:function(a,b){this.headers.set(a,b);return this},getHeader:function(a){return $try(function(){return this.xhr.getResponseHeader(a)}.bind(this))},check:function(){if(!this.running){return true}switch(this.options.link){case"cancel":this.cancel();return true;case"chain":this.chain(this.caller.bind(this,arguments));return false}return false},send:function(l){if(!this.check(l)){return this}this.running=true;var j=$type(l);if(j=="string"||j=="element"){l={data:l}}var d=this.options;l=$extend({data:d.data,url:d.url,method:d.method},l);var h=l.data,b=String(l.url),a=l.method.toLowerCase();switch($type(h)){case"element":h=document.id(h).toQueryString();break;case"object":case"hash":h=Hash.toQueryString(h)}if(this.options.format){var k="format="+this.options.format;h=(h)?k+"&"+h:k}if(this.options.emulation&&!["get","post"].contains(a)){var i="_method="+a;h=(h)?i+"&"+h:i;a="post"}if(this.options.urlEncoded&&a=="post"){var c=(this.options.encoding)?"; charset="+this.options.encoding:"";this.headers.set("Content-type","application/x-www-form-urlencoded"+c)}if(this.options.noCache){var g="noCache="+new Date().getTime();h=(h)?g+"&"+h:g}var f=b.lastIndexOf("/");if(f>-1&&(f=b.indexOf("#"))>-1){b=b.substr(0,f)}if(h&&a=="get"){b=b+(b.contains("?")?"&":"?")+h;h=null}this.xhr.open(a.toUpperCase(),b,this.options.async);this.xhr.onreadystatechange=this.onStateChange.bind(this);this.headers.each(function(n,m){try{this.xhr.setRequestHeader(m,n)}catch(o){this.fireEvent("exception",[m,n])}},this);this.fireEvent("request");this.xhr.send(h);if(!this.options.async){this.onStateChange()}return this},cancel:function(){if(!this.running){return this}this.running=false;this.xhr.abort();this.xhr.onreadystatechange=$empty;this.xhr=new Browser.Request();this.fireEvent("cancel");return this}});(function(){var a={};["get","post","put","delete","GET","POST","PUT","DELETE"].each(function(b){a[b]=function(){var c=Array.link(arguments,{url:String.type,data:$defined});return this.send($extend(c,{method:b}))}});Request.implement(a)})();var APE={version:"1.1",Request:{},Transport:{}};APE.Events=new Class({Extends:Events,onRaw:function(c,b,a){return this.addEvent("raw_"+c.toLowerCase(),b,a)},onCmd:function(c,b,a){return this.addEvent("cmd_"+c.toLowerCase(),b,a)},onError:function(c,b,a){return this.addEvent("error_"+c,b,a)},removeEvent:function(b,a){return Events.prototype.removeEvent.run([b,this.$originalEvents[b][a]],this)}});APE.Core=new Class({Implements:[APE.Events,Options],$originalEvents:{},options:{server:"",pollTime:25000,identifier:"ape",transport:0,frequency:0,cycledStackTime:350,secure:false},initialize:function(a){window.Ape=this;this.setOptions(a);this.selectTransport();this.request=new APE.Request(this);this.pipes=new $H;this.users=new $H;this.sessid=null;this.pubid=null;this.serverUri=(this.options.secure?"https":"http")+"://"+this.options.frequency+"."+this.options.server+"/"+this.options.transport+"/?",this.timer=null;this.status=0;this.failCounter=0;this.pollerObserver=null;this.requestDisabled=false;this.onRaw("login",this.rawLogin);this.onRaw("err",this.rawErr);this.onRaw("ident",this.rawIdent);this.onRaw("quit",this.rawQuit);this.onError("003",this.clearSession);this.onError("004",this.clearSession);if(a.init){a.init.apply(null,[this])}if(a.complete){a.complete.apply(null,[this])}this.fireEvent("load",this);if(this.options.connectOptions){this.start(this.options.connectOptions)}},selectTransport:function(){var a=[APE.Transport.longPolling,APE.Transport.XHRStreaming,APE.Transport.JSONP,null,null,null,APE.Transport.WebSocket];var c=this.options.transport;var b;while(b!==true){b=a[c].browserSupport();if(b===true){this.options.transport=c;this.transport=new a[c](this)}else{c=b}}},poller:function(){if(this.pollerActive){this.check()}},startPoller:function(){this.pollerActive=true},stopPoller:function(){$clear(this.pollerObserver);this.pollerActive=false},stopRequest:function(){this.cancelRequest();if(this.transport.streamRequest){this.transport.streamRequest.cancel()}this.requestDisabled=true},parseParam:function(a){return($type(a)=="object")?Hash.getValues(a):$splat(a)},cancelRequest:function(){this.transport.cancel()},requestFail:function(d,c){var b=false;if(c.request&&!c.request.dataSent){b=true}if(this.status>0){this.status=d;this.cancelRequest();this.stopPoller();this.fireEvent("apeDisconnect")}if(this.failCounter<6){this.failCounter++}this.cancelRequest();var a=(this.failCounter*$random(300,1000));this.check.delay(a,this)},parseResponse:function(f,g){if(f){if(this.status<0){this.failCounter=0;this.status=1;this.startPoller();this.fireEvent("apeReconnect")}}var b=false;var a;if(f){f=JSON.parse(f);if(!f){this.check();return}for(var d=0;d<f.length;d++){var c=f[d];if(g&&$type(g)=="function"){g.run(c)}this.callRaw(c);if(!this.transport.running()){if(!c.data.code||(c.data.code!="006"&&c.data.code!="007"&&c.data.code!="005"&&c.data.code!="001"&&c.data.code!="004"&&c.data.code!="003")){b=true}}else{b=false}}}else{if(!this.transport.running()){b=true}}if(b){this.check()}},callRaw:function(d){var c;if(d.data.pipe){var b=d.data.pipe.pubid,f;if(!this.pipes.has(b)){f=this.newPipe(d.data.pipe.casttype,d.data)}else{f=this.pipes.get(b)}if(f){c=[d,f];f.fireEvent("raw_"+d.raw.toLowerCase(),c)}}else{c=d}this.fireEvent("onRaw",c);if(d.data.chl){var a=this.request.callbackChl.get(d.data.chl);if(a){this.request.callbackChl.erase(d.data.chl);a.run(d)}}this.fireEvent("raw_"+d.raw.toLowerCase(),c)},newPipe:function(c,a){if(a&&a.pipe.pubid){var b=this.pipes.get(a.pipe.pubid);if(b){return b}}if(c=="uni"){return new APE.PipeSingle(this,a)}if(c=="multi"){return new APE.PipeMulti(this,a)}if(c=="proxy"){return new APE.PipeProxy(this,a)}},getRequest:function(a){if(!a.request){return this.request.send.bind(this.request)}else{return this.request[a.request].add.bind(this.request[a.request])}},addPipe:function(b,a){return this.pipes.set(b,a)},getPipe:function(b){var a=this.pipes.get(b);if(!a){a=this.users.get(b);if(a){a=this.newPipe("uni",{pipe:a})}}return a},delPipe:function(b){var a=this.pipes.get(b);this.pipes.erase(b);this.fireEvent(a.type+"PipeDelete",[a]);return a},check:function(){this.request.send("CHECK")},start:function(b,a){this.connect(b,a)},connect:function(b,a){if(!a){a={}}a.sessid=false;this.request.stack.add("CONNECT",b,a);if(this.options.channel){this.request.stack.add("JOIN",{channels:this.options.channel},a)}if(!$defined(a.sendStack)&&a.sendStack!==false){this.request.stack.send()}},join:function(b,a){a=a||{};a.channels=b;this.request.send("JOIN",a)},left:function(a){this.request.send("LEFT",{channel:this.pipes.get(a).name})},quit:function(){this.request.send("QUIT");this.clearSession()},getPubid:function(){return this.pubid},getSessid:function(){return this.sessid},setSession:function(b,a){if(this.restoring){return}this.request.send("SESSION",{action:"set",values:b},a)},getSession:function(b,d,c){if(!c){c={}}var a={};if(d){a.callback=function(f){if(f.raw=="SESSIONS"){this.apply(null,arguments)}}.bind(d)}a.requestCallback=c.requestCallback||null;this.getRequest(c)("SESSION",{action:"get",values:(($type(b)=="array")?b:[b])},a);if(c.request&&c.sendStack!==false){this.request[c.request].send()}},rawIdent:function(a){this.user=a.data.user;this.pubid=a.data.user.pubid;this.user.pipes=new $H;this.users.set(this.pubid,this.user)},rawLogin:function(a){this.sessid=a.data.sessid;this.status=1;this.startPoller();this.fireEvent("ready");this.fireEvent("init")},rawErr:function(a){this.fireEvent("error_"+a.data.code,a)},rawQuit:function(){this.stopRequest()},clearSession:function(){this.sessid=null;this.pubid=null;this.$events={};this.request.chl=1;this.status=0;this.options.restore=false;this.fireEvent("clearSession");this.stopPoller();this.cancelRequest()}});var Ape;APE.init=function(a){(function(){new APE.Core(a)}).delay(1)};APE.Pipe=new Class({Implements:APE.Events,initialize:function(b,a){this.pipe=a.pipe;this.properties=a.pipe.properties;this.ape=b;this.initRequestMethod();this.ape.addPipe(this.pipe.pubid,this)},initRequestMethod:function(){this.request={};this.request={send:function(){var a=this.parsePipeCmd.apply(this,arguments);this.ape.request.send.apply(this.ape.request,a)}.bind(this),cycledStack:{add:function(){var a=this.parsePipeCmd.apply(this,arguments);this.ape.request.cycledStack.add.apply(this.ape.request.cycledStack,a)}.bind(this),send:this.ape.request.send,setTime:this.ape.request.cycledStack.setTime.bind(this.ape.request.cycledStack)},stack:{add:function(){var a=this.parsePipeCmd.apply(this,arguments);this.ape.request.stack.add.apply(this.ape.request.stack,a)}.bind(this),send:this.ape.request.stack.send.bind(this.ape.request.stack)}}},parsePipeCmd:function(){var a=Array.prototype.slice.call(arguments);if($type(arguments[0])=="array"){for(var b=0;b<a[0].length;b++){if(!a[0][b].params){a[0][b].params={}}if(this.pipe){a[0][b].pipe=this.pipe.pubid}}}else{if(!a[1]){a[1]={}}if(this.pipe){a[1].pipe=this.pipe.pubid}}return a},send:function(a){this.request.send("SEND",{msg:a})},getPubid:function(){return this.pipe.pubid},fireGlobalEvent:function(c,b,a){this.fireEvent(c,b,a);this.ape.fireEvent(c,b,a)},fireInTheHall:this.fireGlobalEvent});APE.PipeProxy=new Class({Extends:APE.Pipe,initialize:function(a,b){this.core=a||window.Ape;this.ape=this.core;this.initRequestMethod();this.type="proxy";if(b){this.init(b)}},init:function(a){this.pipe=a.pipe;this.core.addPipe(this.getPubid(),this);this.onRaw("proxy_event",this.rawProxyEvent);this.ape.fireEvent("proxyPipeCreate",[this,a])},reset:function(){},close:function(){},open:function(b,a){if(this.core.status==0){this.core.start(null,false)}this.request.stack.add("PROXY_CONNECT",{host:b,port:a},this.pipe?{}:{callback:this.callback.bind(this)});this.request.stack.send()},send:function(a){this.request.send("SEND",{msg:B64.encode(a)})},rawProxyEvent:function(b){switch(b.data.event){case"read":var a=B64.decode(b.data.data);this.fireGlobalEvent("proxyRead",a);if(this.onread){this.onread(a)}break;case"connect":this.fireGlobalEvent("proxyConnect");if(this.onopen){this.onopen()}break;case"close":this.fireGlobalEvent("proxyClose");if(this.onclose){this.onclose()}break}},callback:function(a){this.init(a.data);this.rawProxyEvent(a)}});APE.Core=new Class({Extends:APE.Core,TCPSocket:APE.PipeProxy});APE.PipeMulti=new Class({Extends:APE.Pipe,initialize:function(b,c){this.parent(b,c);this.type="multi";this.name=c.pipe.properties.name;if(c.users){this.users=new $H;var f=c.users}this.ape.fireEvent("multiPipeCreate",[this,c]);if(c.users){var a=f.length;for(var d=0;d<a;d++){this.addUser(f[d].pubid,f[d])}}this.onRaw("left",this.rawLeft);this.onRaw("join",this.rawJoin)},rawJoin:function(a,b){this.addUser(a.data.user.pubid,a.data.user)},rawLeft:function(a,b){if(b.name.charAt(0)!="*"){this.delUser(a.data.user.pubid)}if(a.data.user.pubid==this.ape.user.pubid){this.ape.delPipe(b.pipe.pubid)}},left:function(){this.ape.left(this.pipe.pubid)},addUser:function(d,c){var a;if(!this.ape.users.has(d)){a=c;a.pipes=new $H;this.ape.users.set(d,c)}else{a=this.ape.users.get(d)}a.pipes.set(this.pipe.pubid,this);var b={pipes:a.pipes,casttype:a.casttype,pubid:a.pubid,properties:c.properties};this.users.set(d,b);this.fireGlobalEvent("userJoin",[b,this]);return b},delUser:function(b){var a=this.users.get(b);this.users.erase(b);a.pipes.erase(this.pipe.pubid);if(a.pipes.getLength()==0){this.ape.users.erase(a.pubid)}this.fireGlobalEvent("userLeft",[a,this]);return a},getUser:function(a){return this.users.get(a)},getUserPipe:function(a){if(typeof a=="string"){a=this.users.get(users.pubid)}return this.ape.newPipe("uni",{pipe:a})}});APE.PipeSingle=new Class({Extends:APE.Pipe,initialize:function(a,b){this.parent(a,b);this.type="uni";this.ape.fireEvent("uniPipeCreate",[this,b])}});APE.Request=new Class({initialize:function(a){this.ape=a;this.stack=new APE.Request.Stack(a);this.cycledStack=new APE.Request.CycledStack(a);this.chl=1;this.callbackChl=new $H;if(Browser.Engine.presto){this.requestVar={updated:false,args:[]};this.requestObserver.periodical(10,this)}},send:function(f,g,b,d){if(this.ape.requestDisabled){return}if(Browser.Engine.presto&&!d){this.requestVar.updated=true;this.requestVar.args.push([f,g,b]);return}var c={};if(!b){b={}}c.event=b.event||true;c.requestCallback=b.requestCallback||null;c.callback=b.callback;var a=this.ape.transport.send(this.parseCmd(f,g,c),c);$clear(this.ape.pollerObserver);this.ape.pollerObserver=this.ape.poller.delay(this.ape.options.pollTime,this.ape);return a},parseCmd:function(f,j,p){var b="";var n=[];var c={};if($type(f)=="array"){var l,h;for(var k=0;k<f.length;k++){l=f[k];c={};c.cmd=l.cmd;c.chl=this.chl++;if(!l.options){l.options={}}l.params?c.params=l.params:null;h=$extend({},c.params);if(!$defined(l.options.sessid)||l.options.sessid!==false){c.sessid=this.ape.sessid}n.push(c);var m="cmd_"+l.cmd.toLowerCase();if(l.options.callback){this.callbackChl.set(c.chl,l.options.callback)}if(l.options.requestCallback){p.requestCallback=l.options.requestCallback}if(p.event){if(c.params&&c.params.pipe){var d=this.ape.getPipe(c.params.pipe);if(d){h=[h,d]}}this.ape.fireEvent("onCmd",[l.cmd,h]);if(d){d.fireEvent(m,h)}this.ape.fireEvent(m,h)}}}else{c.cmd=f;c.chl=this.chl++;j?c.params=j:null;var h=$extend({},j);if(!$defined(p.sessid)||p.sessid!==false){c.sessid=this.ape.sessid}n.push(c);var m="cmd_"+f.toLowerCase();if(p.callback){this.callbackChl.set(c.chl,p.callback)}if(p.event){if(j&&j.pipe){var d=this.ape.getPipe(j.pipe);if(d){h=[h,d]}}this.ape.fireEvent("onCmd",[f,h]);if(d){d.fireEvent(m,h)}this.ape.fireEvent(m,h)}}var g=this.ape.options.transport;return JSON.stringify(n,function(a,i){if(typeof(i)=="string"){i=encodeURIComponent(i);if(g==2){i=encodeURIComponent(i)}return i}else{return i}})},requestObserver:function(){if(this.requestVar.updated){var a=this.requestVar.args.shift();this.requestVar.updated=(this.requestVar.args.length>0)?true:false;a[3]=true;this.send.run(a,this)}}});APE.Request.Stack=new Class({initialize:function(a){this.ape=a;this.stack=[]},add:function(b,c,a){this.stack.push({cmd:b,params:c,options:a})},send:function(){this.ape.request.send(this.stack);this.stack=[]}});APE.Request.CycledStack=new Class({initialize:function(a){this.ape=a;this.stack=[];this.reajustTime=false;this.timer=this.send.periodical(this.ape.options.cycledStackTime,this)},add:function(b,c,a){this.stack.push({cmd:b,params:c,sessid:a})},setTime:function(b,a){if(a){this.send();$clear(this.timer);this.timer=this.send.periodical(b,this);this.reajustTime=false}else{this.reajustTime=b}},send:function(){if(this.stack.length>0){this.ape.request.send(this.stack);this.stack=[];if(this.reajustTime){this.setTime(this.reajustTime,true)}}}});Request=new Class({Extends:Request,send:function(a){if(Browser.Engine.webkit){this.xhr.onreadystatechange=this.onStateChange.bind(this)}return this.parent(a)},onStateChange:function(){if(this.xhr.readyState==1){this.dataSent=true}this.parent()}});APE.Transport.longPolling=new Class({initialize:function(a){this.ape=a;this.requestFailObserver=[]},send:function(c,a){var b=new Request({url:this.ape.serverUri,onFailure:this.ape.requestFail.bind(this.ape,[-2,this]),onComplete:function(d){$clear(this.requestFailObserver.shift());this.ape.parseResponse(d,a.requestCallback)}.bind(this)}).send(c);b.id=$time();this.request=b;this.requestFailObserver.push(this.ape.requestFail.delay(this.ape.options.pollTime+10000,this.ape,[-1,b]));return b},running:function(){return this.request?this.request.running:false},cancel:function(){if(this.request){this.request.cancel()}$clear(this.requestFailObserver.shift())}});APE.Transport.longPolling.browserSupport=function(){return Browser.Features.xhr?true:2};APE.Request.SSE=new Class({SSESupport:((typeof window.addEventStream)=="function"),initSSE:function(d,a,c){var b=document.createElement("div");document.body.appendChild(b);b.innerHTML='<event-source src="'+this.ape.serverUri+d+"&"+$time()+'" id="APE_SSE">';this.eventSource=document.getElementById("APE_SSE");this.eventSource.addEventListener("ape-data",function(f){c.run(f.data)},false)}});Request.XHRStreaming=new Class({Extends:Request,lastTextLength:0,read:0,send:function(a){if(Browser.Engine.webkit){this.xhr.onreadystatechange=this.onStateChange.bind(this)}return this.parent(a)},onStateChange:function(){if(this.xhr.readyState==1){this.dataSent=true}else{if(this.xhr.readyState==3){this.progress(this.xhr.responseText,this.xhr.responseXML)}}this.parent()},onProgress:function(){this.fireEvent("progress",arguments)},progress:function(c,a){var b=c.length;this.read+=b;c=c.substr(this.lastTextLength);this.lastTextLength=b;this.onProgress(this.processScripts(c),a)}});APE.Transport.XHRStreaming=new Class({maxRequestSize:100000,Implements:APE.Request.SSE,initialize:function(a){this.ape=a;this.requestFailObserver=[];if(this.SSESupport){this.ape.options.transport=4}this.streamInfo={timeoutObserver:null,cleanClose:false,forceClose:false,callback:null}},send:function(c,a){if(this.SSESupport&&!this.eventSource){this.initSSE(c,a,this.readSSE.bind(this));if(a.requestCallback){this.streamInfo.callback=a.requestCallback}}else{if((!this.streamRequest||!this.streamRequest.running)&&!this.eventSource){this.buffer="";this.request=this.doRequest(c,a);if(a.requestCallback){this.streamInfo.callback=a.requestCallback}}else{var b=new Request({url:this.ape.serverUri,onFailure:this.ape.requestFail.bind(this.ape,[-2,this]),onComplete:function(d){$clear(this.requestFailObserver.shift());this.request.dataSent=true;this.ape.parseResponse(d,a.callback)}.bind(this)}).send(c);this.request=b;this.requestFailObserver.push(this.ape.requestFail.delay(this.ape.options.pollTime+10000,this.ape,[1,b]))}return this.request}},doRequest:function(c,a){this.streamInfo.forceClose=false;var b=new Request.XHRStreaming({url:this.ape.serverUri,onProgress:this.readFragment.bindWithEvent(this),onFailure:this.ape.requestFail.bind(this.ape,[-2,this]),onComplete:function(d){$clear(this.streamInfo.timeoutObserver);if(this.ape.status>0){if(this.streamInfo.cleanClose){this.ape.check()}else{this.newStream()}this.streamInfo.cleanClose=false}}.bind(this)}).send(c);b.id=$time();this.streamRequest=b;return b},readSSE:function(a){this.ape.parseResponse(a,this.streamInfo.callback);this.streamInfo.callback=null},readFragment:function(d){this.streamInfo.canClose=false;if(d==""){this.streamInfo.canClose=true;this.streamInfo.cleanClose=true;this.ape.parseResponse(d,this.streamInfo.callback);this.streamInfo.callback=null}else{d=this.buffer+d;var c=d.split("\n\n");var b=c.length;if(c.length>1){this.buffer="";for(var a=0;a<b-1;a++){this.ape.parseResponse(c[a],this.streamInfo.callback)}if(c[b-1]!==""){this.buffer+=c[b-1]}else{this.streamInfo.canClose=true;if(this.checkStream()){this.newStream()}}this.streamInfo.callback=null}else{this.buffer=d}}},running:function(){return(this.streamRequest&&this.streamRequest.running)?true:this.eventSource?true:false},checkStream:function(){return(this.streamInfo.forceClose&&this.streamInfo.canClose)||(this.streamRequest&&this.streamRequest.read>=this.maxRequestSize&&this.streamInfo.canClose)},newStream:function(){$clear(this.streamInfo.timeoutObserver);this.streamRequest.cancel();this.ape.check()},cancel:function(){if(this.request){this.request.cancel()}$clear(this.streamInfo.timeoutObserver);$clear(this.requestFailObserver.shift())}});APE.Transport.XHRStreaming.browserSupport=function(){if(Browser.Features.xhr&&(Browser.Engine.webkit||Browser.Engine.gecko)){return true}else{if(Browser.Features.xhr){return 0}else{return 2}}};APE.Transport.JSONP=new Class({Implements:APE.Transport.SSE,initialize:function(a){this.ape=a;this.requestFailObserver=[];this.requests=[];window.parent.onkeyup=function(b){if(b.keyCode==27){this.cancel();if(this.ape.status>0){this.ape.check()}}}.bind(this)},send:function(c,a){this.callback=a.requestCallback;var b=document.createElement("script");b.src=this.ape.serverUri+c;document.head.appendChild(b);this.requests.push(b);this.requestFailObserver.push(this.ape.requestFail.delay(this.ape.options.pollTime+10000,this.ape,[-1,b]));if(Browser.Engine.gecko){(function(){var d=document.createElement("iframe");document.body.appendChild(d);document.body.removeChild(d)}).delay(200)}},clearRequest:function(a){a.parentNode.removeChild(a);if(a.clearAttributes){a.clearAttributes()}else{for(var b in a){delete a[b]}}$clear(this.requestFailObserver.shift())},readSSE:function(a){this.ape.parseResponse(a,this.callback);this.callback=null},read:function(a){$clear(this.requestFailObserver.shift());this.clearRequest(this.requests.shift());this.ape.parseResponse(a,this.callback);this.callback=null},cancel:function(){if(this.requests.length>0){this.clearRequest(this.requests.shift())}},running:function(){return this.requests.length>0?true:false}});APE.Transport.JSONP.browserSupport=function(){return true};APE.Transport.WebSocket=new Class({stack:[],connRunning:false,initialize:function(a){this.ape=a;this.initWs()},initWs:function(){var a=(this.ape.options.secure?"wss":"ws")+"://"+this.ape.options.frequency+"."+this.ape.options.server+"/"+this.ape.options.transport+"/";this.ws=("MozWebSocket" in window?new MozWebSocket(a):new WebSocket(a));this.connRunning=true;this.ws.onmessage=this.readWs.bind(this);this.ws.onopen=this.openWs.bind(this);this.ws.onclose=this.closeWs.bind(this);this.ws.onerror=this.errorWs.bind(this)},readWs:function(a){this.ape.parseResponse(a.data,this.callback);this.callback=null},openWs:function(){if(this.stack.length>0){for(var a=0;a<this.stack.length;a++){this.send(this.stack[a].q,this.stack[a].options)}this.stack.length=0}},closeWs:function(){this.connRunning=false},errorWs:function(){this.connRunning=false},send:function(b,a){if(this.ws.readyState==1){if(a.requestCallback){this.callback=a.requestCallback}this.ws.send(b)}else{this.stack.push({q:b,options:a})}},running:function(){return this.connRunning},cancel:function(){this.ws.close()}});APE.Transport.WebSocket.browserSupport=function(){if("WebSocket" in window||"MozWebSocket" in window){return true}else{return 1}};String.implement({addSlashes:function(){return this.replace(/("|'|\\|\0)/g,"\\$1")},stripSlashes:function(){return this.replace(/\\("|'|\\|\0)/g,"$1")}});var B64=new Hash({$p:"=",$tab:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",encode:function(h){var f=[],b=h.length;var g=b%3;var a=b-g;var d;for(var c=0;c<a;){d=h.charCodeAt(c++)<<16|h.charCodeAt(c++)<<8|h.charCodeAt(c++);f.push(B64.$tab.charAt((d>>>18)&63));f.push(B64.$tab.charAt((d>>>12)&63));f.push(B64.$tab.charAt((d>>>6)&63));f.push(B64.$tab.charAt(d&63))}switch(g){case 2:d=h.charCodeAt(c++)<<16|h.charCodeAt(c++)<<8;f.push(B64.$tab.charAt((d>>>18)&63));f.push(B64.$tab.charAt((d>>>12)&63));f.push(B64.$tab.charAt((d>>>6)&63));f.push(B64.$p);break;case 1:d=h.charCodeAt(c++)<<16;f.push(B64.$tab.charAt((d>>>18)&63));f.push(B64.$tab.charAt((d>>>12)&63));f.push(B64.$p);f.push(B64.$p);break}return f.join("")},decode:function(h){var g=h.split(""),c=[];var a=g.length;var b=0;while(g[--a]==B64.$p){++b}for(var f=0;f<a;){var d=B64.$tab.indexOf(g[f++])<<18;if(f<=a){d|=B64.$tab.indexOf(g[f++])<<12}if(f<=a){d|=B64.$tab.indexOf(g[f++])<<6}if(f<=a){d|=B64.$tab.indexOf(g[f++])}c.push(String.fromCharCode((d>>>16)&255));c.push(String.fromCharCode((d>>>8)&255));c.push(String.fromCharCode(d&255))}while(b--){c.pop()}return c.join("")}});try{window.parent.setInterval();if(!Browser.Engine.trident&&!Browser.Engine.presto&&!(Browser.Engine.gecko&&Browser.Engine.version<=18)){setInterval=function(a,b){return window.parent.setInterval(a,b)};setTimeout=function(a,b){return window.parent.setTimeout(a,b)};clearInterval=function(a){return window.parent.clearInterval(a)};clearTimeout=function(a){return window.parent.clearTimeout(a)}}}catch(e){}if(!this.JSON){this.JSON={}}(function(){var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,rep;function quote(string){return'"'+string+'"'}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(typeof rep==="function"){value=rep.call(holder,key,value)}switch(typeof value){case"string":return quote(value);case"number":return isFinite(value)?String(value):"null";case"boolean":case"null":return String(value);case"object":if(!value){return"null"}gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==="[object Array]"){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||"null"}v=partial.length===0?"[]":gap?"[\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"]":"["+partial.join(",")+"]";gap=mind;return v}for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?": ":":")+v)}}}v=partial.length===0?"{}":gap?"{\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"}":"{"+partial.join(",")+"}";gap=mind;return v}}if(typeof JSON.stringify!=="function"||(navigator.product=="Gecko"&&(function(){var tmp=JSON.stringify({x:1},function(k,v){return typeof v==="number"?3:v});return tmp.x==1?true:false}))){JSON.stringify=function(value,replacer,space){rep=replacer;return str("",{"":value})}}if(typeof JSON.parse!=="function"){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==="object"){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v}else{delete value[k]}}}}return reviver.call(holder,key,value)}cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})}if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){j=eval("("+text+")");return typeof reviver==="function"?walk({"":j},""):j}throw new SyntaxError("JSON.parse")}}}());APE.Core=new Class({Extends:APE.Core,initialize:function(a){if(this.getInstance(a.identifier).instance){a.restore=true}this.parent(a);if(a.restore){this.init()}this.addEvent("uniPipeCreate",this.saveSessionPipe);this.addEvent("uniPipeDelete",this.saveSessionPipe)},saveSessionPipe:function(){var a=[];this.pipes.each(function(b){if(b.type=="uni"){a.push({casttype:b.type,pubid:b.pipe.pubid,properties:b.properties})}});this.setSession({uniPipe:JSON.stringify(a)})},restoreUniPipe:function(c){var b=JSON.parse(decodeURIComponent(c.data.sessions.uniPipe));if(b){for(var a=0;a<b.length;a++){this.newPipe("uni",{pipe:b[a]})}}this.fireEvent("restoreEnd");this.restoring=false},init:function(){this.initCookie();this.createCookie();this.saveCookie()},restoreCallback:function(a){if(a.raw!="ERR"&&this.status==0){this.fireEvent("init");this.fireEvent("ready");this.status=1}else{if(this.status==0){this.stopPoller()}}},connect:function(b,a){var c=this.initCookie();if(!c){this.addEvent("init",this.init);this.parent(b,a)}else{if(!a){a={}}if(!a.request){a.request="stack"}a.requestCallback=this.restoreCallback.bind(this);this.restoring=true;this.fireEvent("restoreStart");this.startPoller();this.getSession("uniPipe",this.restoreUniPipe.bind(this),a)}},getInstance:function(a){var c=Cookie.read("APE_Cookie",{domain:document.domain});a=a||this.options.identifier;if(!c){return false}c=JSON.parse(c);if(!c||!c.instance){return false}for(var b=0;b<c.instance.length;b++){if(c.instance[b]&&c.instance[b].identifier==a){return{instance:c.instance[b],cookie:c}}}return{cookie:c}},removeInstance:function(a){if(!this.cookie){return}for(var b=0;b<this.cookie.instance.length;b++){if(this.cookie.instance[b].identifier==a){this.cookie.instance.splice(b,1);return}}},initCookie:function(){var a=this.getInstance();if(a&&a.instance){this.sessid=a.instance.sessid;this.pubid=a.instance.pubid;a.cookie.frequency=a.cookie.frequency.toInt()+1;this.cookie=a.cookie;return true}else{if(a.cookie){this.createInstance(a.cookie);a.cookie.frequency=a.cookie.frequency.toInt()+1;this.cookie=a.cookie;return false}else{this.cookie=null;return false}}},createInstance:function(a){a.instance.push({identifier:this.options.identifier,pubid:this.getPubid(),sessid:this.getSessid()})},createCookie:function(){if(!this.cookie){var a={frequency:1,instance:[]};this.createInstance(a);this.cookie=a}},saveCookie:function(){Cookie.write("APE_Cookie",JSON.stringify(this.cookie),{domain:document.domain})},clearSession:function(){this.parent();this.removeInstance(this.options.identifier);this.saveCookie()},removeCookie:function(){Cookie.dispose("APE_Cookie",{domain:this.options.domain})}});