var MooTools={'version':'1.2.0','build':''};var Native=function(options){options=options||{};var afterImplement=options.afterImplement||function(){};var generics=options.generics;generics=(generics!==false);var legacy=options.legacy;var initialize=options.initialize;var protect=options.protect;var name=options.name;var object=initialize||legacy;object.constructor=Native;object.$family={name:'native'};if(legacy&&initialize)object.prototype=legacy.prototype;object.prototype.constructor=object;if(name){var family=name.toLowerCase();object.prototype.$family={name:family};Native.typize(object,family);}
var add=function(obj,name,method,force){if(!protect||force||!obj.prototype[name])obj.prototype[name]=method;if(generics)Native.genericize(obj,name,protect);afterImplement.call(obj,name,method);return obj;};object.implement=function(a1,a2,a3){if(typeof a1=='string')return add(this,a1,a2,a3);for(var p in a1)add(this,p,a1[p],a2);return this;};object.alias=function(a1,a2,a3){if(typeof a1=='string'){a1=this.prototype[a1];if(a1)add(this,a2,a1,a3);}else{for(var a in a1)this.alias(a,a1[a],a2);}
return this;};return object;};Native.implement=function(objects,properties){for(var i=0,l=objects.length;i<l;i++)objects[i].implement(properties);};Native.genericize=function(object,property,check){if((!check||!object[property])&&typeof object.prototype[property]=='function')object[property]=function(){var args=Array.prototype.slice.call(arguments);return object.prototype[property].apply(args.shift(),args);};};Native.typize=function(object,family){if(!object.type)object.type=function(item){return($type(item)===family);};};Native.alias=function(objects,a1,a2,a3){for(var i=0,j=objects.length;i<j;i++)objects[i].alias(a1,a2,a3);};(function(objects){for(var name in objects)Native.typize(objects[name],name);})({'boolean':Boolean,'native':Native,'object':Object});(function(objects){for(var name in objects)new Native({name:name,initialize:objects[name],protect:true});})({'String':String,'Function':Function,'Number':Number,'Array':Array,'RegExp':RegExp,'Date':Date});(function(object,methods){for(var i=methods.length;i--;i)Native.genericize(object,methods[i],true);return arguments.callee;})
(Array,['pop','push','reverse','shift','sort','splice','unshift','concat','join','slice','toString','valueOf','indexOf','lastIndexOf'])
(String,['charAt','charCodeAt','concat','indexOf','lastIndexOf','match','replace','search','slice','split','substr','substring','toLowerCase','toUpperCase','valueOf']);function $chk(obj){return!!(obj||obj===0);};function $clear(timer){clearTimeout(timer);clearInterval(timer);return null;};function $defined(obj){return(obj!=undefined);};function $empty(){};function $arguments(i){return function(){return arguments[i];};};function $lambda(value){return(typeof value=='function')?value:function(){return value;};};function $extend(original,extended){for(var key in(extended||{}))original[key]=extended[key];return original;};function $unlink(object){var unlinked;switch($type(object)){case'object':unlinked={};for(var p in object)unlinked[p]=$unlink(object[p]);break;case'hash':unlinked=$unlink(object.getClean());break;case'array':unlinked=[];for(var i=0,l=object.length;i<l;i++)unlinked[i]=$unlink(object[i]);break;default:return object;}
return unlinked;};function $merge(){var mix={};for(var i=0,l=arguments.length;i<l;i++){var object=arguments[i];if($type(object)!='object')continue;for(var key in object){var op=object[key],mp=mix[key];mix[key]=(mp&&$type(op)=='object'&&$type(mp)=='object')?$merge(mp,op):$unlink(op);}}
return mix;};function $pick(){for(var i=0,l=arguments.length;i<l;i++){if(arguments[i]!=undefined)return arguments[i];}
return null;};function $random(min,max){return Math.floor(Math.random()*(max-min+1)+min);};function $splat(obj){var type=$type(obj);return(type)?((type!='array'&&type!='arguments')?[obj]:obj):[];};var $time=Date.now||function(){return new Date().getTime();};function $try(){for(var i=0,l=arguments.length;i<l;i++){try{return arguments[i]();}catch(e){}}
return null;};function $type(obj){if(obj==undefined)return false;if(obj.$family)return(obj.$family.name=='number'&&!isFinite(obj))?false:obj.$family.name;if(obj.nodeName){switch(obj.nodeType){case 1:return'element';case 3:return(/\S/).test(obj.nodeValue)?'textnode':'whitespace';}}else if(typeof obj.length=='number'){if(obj.callee)return'arguments';else if(obj.item)return'collection';}
return typeof obj;};var Hash=new Native({name:'Hash',initialize:function(object){if($type(object)=='hash')object=$unlink(object.getClean());for(var key in object)this[key]=object[key];return this;}});Hash.implement({getLength:function(){var length=0;for(var key in this){if(this.hasOwnProperty(key))length++;}
return length;},forEach:function(fn,bind){for(var key in this){if(this.hasOwnProperty(key))fn.call(bind,this[key],key,this);}},getClean:function(){var clean={};for(var key in this){if(this.hasOwnProperty(key))clean[key]=this[key];}
return clean;}});Hash.alias('forEach','each');function $H(object){return new Hash(object);};Array.implement({forEach:function(fn,bind){for(var i=0,l=this.length;i<l;i++)fn.call(bind,this[i],i,this);}});Array.alias('forEach','each');function $A(iterable){if(iterable.item){var array=[];for(var i=0,l=iterable.length;i<l;i++)array[i]=iterable[i];return array;}
return Array.prototype.slice.call(iterable);};function $each(iterable,fn,bind){var type=$type(iterable);((type=='arguments'||type=='collection'||type=='array')?Array:Hash).each(iterable,fn,bind);};var Browser=new Hash({Engine:{name:'unknown',version:''},Platform:{name:(navigator.platform.match(/mac|win|linux/i)||['other'])[0].toLowerCase()},Features:{xpath:!!(document.evaluate),air:!!(window.runtime)},Plugins:{}});if(window.opera)Browser.Engine={name:'presto',version:(document.getElementsByClassName)?950:925};else if(window.ActiveXObject)Browser.Engine={name:'trident',version:(window.XMLHttpRequest)?5:4};else if(!navigator.taintEnabled)Browser.Engine={name:'webkit',version:(Browser.Features.xpath)?420:419};else if(document.getBoxObjectFor!=null)Browser.Engine={name:'gecko',version:(document.getElementsByClassName)?19:18};Browser.Engine[Browser.Engine.name]=Browser.Engine[Browser.Engine.name+Browser.Engine.version]=true;if(window.orientation!=undefined)Browser.Platform.name='ipod';Browser.Platform[Browser.Platform.name]=true;Browser.Request=function(){return $try(function(){return new XMLHttpRequest();},function(){return new ActiveXObject('MSXML2.XMLHTTP');});};Browser.Features.xhr=!!(Browser.Request());Browser.Plugins.Flash=(function(){var version=($try(function(){return navigator.plugins['Shockwave Flash'].description;},function(){return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version');})||'0 r0').match(/\d+/g);return{version:parseInt(version[0]||0+'.'+version[1]||0),build:parseInt(version[2]||0)};})();function $exec(text){if(!text)return text;if(window.execScript){window.execScript(text);}else{var script=document.createElement('script');script.setAttribute('type','text/javascript');script.text=text;document.head.appendChild(script);document.head.removeChild(script);}
return text;};Native.UID=1;var $uid=(Browser.Engine.trident)?function(item){return(item.uid||(item.uid=[Native.UID++]))[0];}:function(item){return item.uid||(item.uid=Native.UID++);};var Window=new Native({name:'Window',legacy:(Browser.Engine.trident)?null:window.Window,initialize:function(win){$uid(win);if(!win.Element){win.Element=$empty;if(Browser.Engine.webkit)win.document.createElement("iframe");win.Element.prototype=(Browser.Engine.webkit)?window["[[DOMElement.prototype]]"]:{};}
return $extend(win,Window.Prototype);},afterImplement:function(property,value){window[property]=Window.Prototype[property]=value;}});Window.Prototype={$family:{name:'window'}};new Window(window);var Document=new Native({name:'Document',legacy:(Browser.Engine.trident)?null:window.Document,initialize:function(doc){$uid(doc);doc.head=doc.getElementsByTagName('head')[0];doc.html=doc.getElementsByTagName('html')[0];doc.window=doc.defaultView||doc.parentWindow;if(Browser.Engine.trident4)$try(function(){doc.execCommand("BackgroundImageCache",false,true);});return $extend(doc,Document.Prototype);},afterImplement:function(property,value){document[property]=Document.Prototype[property]=value;}});Document.Prototype={$family:{name:'document'}};new Document(document);Array.implement({every:function(fn,bind){for(var i=0,l=this.length;i<l;i++){if(!fn.call(bind,this[i],i,this))return false;}
return true;},filter:function(fn,bind){var results=[];for(var i=0,l=this.length;i<l;i++){if(fn.call(bind,this[i],i,this))results.push(this[i]);}
return results;},clean:function(){return this.filter($defined);},indexOf:function(item,from){var len=this.length;for(var i=(from<0)?Math.max(0,len+from):from||0;i<len;i++){if(this[i]===item)return i;}
return-1;},map:function(fn,bind){var results=[];for(var i=0,l=this.length;i<l;i++)results[i]=fn.call(bind,this[i],i,this);return results;},some:function(fn,bind){for(var i=0,l=this.length;i<l;i++){if(fn.call(bind,this[i],i,this))return true;}
return false;},associate:function(keys){var obj={},length=Math.min(this.length,keys.length);for(var i=0;i<length;i++)obj[keys[i]]=this[i];return obj;},link:function(object){var result={};for(var i=0,l=this.length;i<l;i++){for(var key in object){if(object[key](this[i])){result[key]=this[i];delete object[key];break;}}}
return result;},contains:function(item,from){return this.indexOf(item,from)!=-1;},extend:function(array){for(var i=0,j=array.length;i<j;i++)this.push(array[i]);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(item){if(!this.contains(item))this.push(item);return this;},combine:function(array){for(var i=0,l=array.length;i<l;i++)this.include(array[i]);return this;},erase:function(item){for(var i=this.length;i--;i){if(this[i]===item)this.splice(i,1);}
return this;},empty:function(){this.length=0;return this;},flatten:function(){var array=[];for(var i=0,l=this.length;i<l;i++){var type=$type(this[i]);if(!type)continue;array=array.concat((type=='array'||type=='collection'||type=='arguments')?Array.flatten(this[i]):this[i]);}
return array;},hexToRgb:function(array){if(this.length!=3)return null;var rgb=this.map(function(value){if(value.length==1)value+=value;return value.toInt(16);});return(array)?rgb:'rgb('+rgb+')';},rgbToHex:function(array){if(this.length<3)return null;if(this.length==4&&this[3]==0&&!array)return'transparent';var hex=[];for(var i=0;i<3;i++){var bit=(this[i]-0).toString(16);hex.push((bit.length==1)?'0'+bit:bit);}
return(array)?hex:'#'+hex.join('');}});Function.implement({extend:function(properties){for(var property in properties)this[property]=properties[property];return this;},create:function(options){var self=this;options=options||{};return function(event){var args=options.arguments;args=(args!=undefined)?$splat(args):Array.slice(arguments,(options.event)?1:0);if(options.event)args=[event||window.event].extend(args);var returns=function(){return self.apply(options.bind||null,args);};if(options.delay)return setTimeout(returns,options.delay);if(options.periodical)return setInterval(returns,options.periodical);if(options.attempt)return $try(returns);return returns();};},pass:function(args,bind){return this.create({arguments:args,bind:bind});},attempt:function(args,bind){return this.create({arguments:args,bind:bind,attempt:true})();},bind:function(bind,args){return this.create({bind:bind,arguments:args});},bindWithEvent:function(bind,args){return this.create({bind:bind,event:true,arguments:args});},delay:function(delay,bind,args){return this.create({delay:delay,bind:bind,arguments:args})();},periodical:function(interval,bind,args){return this.create({periodical:interval,bind:bind,arguments:args})();},run:function(args,bind){return this.apply(bind,$splat(args));}});Number.implement({limit:function(min,max){return Math.min(max,Math.max(min,this));},round:function(precision){precision=Math.pow(10,precision||0);return Math.round(this*precision)/precision;},times:function(fn,bind){for(var i=0;i<this;i++)fn.call(bind,i,this);},toFloat:function(){return parseFloat(this);},toInt:function(base){return parseInt(this,base||10);}});Number.alias('times','each');(function(math){var methods={};math.each(function(name){if(!Number[name])methods[name]=function(){return Math[name].apply(null,[this].concat($A(arguments)));};});Number.implement(methods);})(['abs','acos','asin','atan','atan2','ceil','cos','exp','floor','log','max','min','pow','sin','sqrt','tan']);String.implement({test:function(regex,params){return((typeof regex=='string')?new RegExp(regex,params):regex).test(this);},contains:function(string,separator){return(separator)?(separator+this+separator).indexOf(separator+string+separator)>-1:this.indexOf(string)>-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(match){return match.charAt(1).toUpperCase();});},hyphenate:function(){return this.replace(/[A-Z]/g,function(match){return('-'+match.charAt(0).toLowerCase());});},capitalize:function(){return this.replace(/\b[a-z]/g,function(match){return match.toUpperCase();});},escapeRegExp:function(){return this.replace(/([-.*+?^${}()|[\]\/\\])/g,'\\$1');},toInt:function(base){return parseInt(this,base||10);},toFloat:function(){return parseFloat(this);},hexToRgb:function(array){var hex=this.match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/);return(hex)?hex.slice(1).hexToRgb(array):null;},rgbToHex:function(array){var rgb=this.match(/\d{1,3}/g);return(rgb)?rgb.rgbToHex(array):null;},stripScripts:function(option){var scripts='';var text=this.replace(/<script[^>]*>([\s\S]*?)<\/script>/gi,function(){scripts+=arguments[1]+'\n';return'';});if(option===true)$exec(scripts);else if($type(option)=='function')option(scripts,text);return text;},substitute:function(object,regexp){return this.replace(regexp||(/\\?\{([^}]+)\}/g),function(match,name){if(match.charAt(0)=='\\')return match.slice(1);return(object[name]!=undefined)?object[name]:'';});}});Hash.implement({has:Object.prototype.hasOwnProperty,keyOf:function(value){for(var key in this){if(this.hasOwnProperty(key)&&this[key]===value)return key;}
return null;},hasValue:function(value){return(Hash.keyOf(this,value)!==null);},extend:function(properties){Hash.each(properties,function(value,key){Hash.set(this,key,value);},this);return this;},combine:function(properties){Hash.each(properties,function(value,key){Hash.include(this,key,value);},this);return this;},erase:function(key){if(this.hasOwnProperty(key))delete this[key];return this;},get:function(key){return(this.hasOwnProperty(key))?this[key]:null;},set:function(key,value){if(!this[key]||this.hasOwnProperty(key))this[key]=value;return this;},empty:function(){Hash.each(this,function(value,key){delete this[key];},this);return this;},include:function(key,value){var k=this[key];if(k==undefined)this[key]=value;return this;},map:function(fn,bind){var results=new Hash;Hash.each(this,function(value,key){results.set(key,fn.call(bind,value,key,this));},this);return results;},filter:function(fn,bind){var results=new Hash;Hash.each(this,function(value,key){if(fn.call(bind,value,key,this))results.set(key,value);},this);return results;},every:function(fn,bind){for(var key in this){if(this.hasOwnProperty(key)&&!fn.call(bind,this[key],key))return false;}
return true;},some:function(fn,bind){for(var key in this){if(this.hasOwnProperty(key)&&fn.call(bind,this[key],key))return true;}
return false;},getKeys:function(){var keys=[];Hash.each(this,function(value,key){keys.push(key);});return keys;},getValues:function(){var values=[];Hash.each(this,function(value){values.push(value);});return values;},toQueryString:function(base){var queryString=[];Hash.each(this,function(value,key){if(base)key=base+'['+key+']';var result;switch($type(value)){case'object':result=Hash.toQueryString(value,key);break;case'array':var qs={};value.each(function(val,i){qs[i]=val;});result=Hash.toQueryString(qs,key);break;default:result=key+'='+encodeURIComponent(value);}
if(value!=undefined)queryString.push(result);});return queryString.join('&');}});Hash.alias({keyOf:'indexOf',hasValue:'contains'});var Event=new Native({name:'Event',initialize:function(event,win){win=win||window;var doc=win.document;event=event||win.event;if(event.$extended)return event;this.$extended=true;var type=event.type;var target=event.target||event.srcElement;while(target&&target.nodeType==3)target=target.parentNode;if(type.test(/key/)){var code=event.which||event.keyCode;var key=Event.Keys.keyOf(code);if(type=='keydown'){var fKey=code-111;if(fKey>0&&fKey<13)key='f'+fKey;}
key=key||String.fromCharCode(code).toLowerCase();}else if(type.match(/(click|mouse|menu)/i)){doc=(!doc.compatMode||doc.compatMode=='CSS1Compat')?doc.html:doc.body;var page={x:event.pageX||event.clientX+doc.scrollLeft,y:event.pageY||event.clientY+doc.scrollTop};var client={x:(event.pageX)?event.pageX-win.pageXOffset:event.clientX,y:(event.pageY)?event.pageY-win.pageYOffset:event.clientY};if(type.match(/DOMMouseScroll|mousewheel/)){var wheel=(event.wheelDelta)?event.wheelDelta/120:-(event.detail||0)/3;}
var rightClick=(event.which==3)||(event.button==2);var related=null;if(type.match(/over|out/)){switch(type){case'mouseover':related=event.relatedTarget||event.fromElement;break;case'mouseout':related=event.relatedTarget||event.toElement;}
if(!(function(){while(related&&related.nodeType==3)related=related.parentNode;return true;}).create({attempt:Browser.Engine.gecko})())related=false;}}
return $extend(this,{event:event,type:type,page:page,client:client,rightClick:rightClick,wheel:wheel,relatedTarget:related,target:target,code:code,key:key,shift:event.shiftKey,control:event.ctrlKey,alt:event.altKey,meta:event.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;}});var Class=new Native({name:'Class',initialize:function(properties){properties=properties||{};var klass=function(empty){for(var key in this)this[key]=$unlink(this[key]);for(var mutator in Class.Mutators){if(!this[mutator])continue;Class.Mutators[mutator](this,this[mutator]);delete this[mutator];}
this.constructor=klass;if(empty===$empty)return this;var self=(this.initialize)?this.initialize.apply(this,arguments):this;if(this.options&&this.options.initialize)this.options.initialize.call(this);return self;};$extend(klass,this);klass.constructor=Class;klass.prototype=properties;return klass;}});Class.implement({implement:function(){Class.Mutators.Implements(this.prototype,Array.slice(arguments));return this;}});Class.Mutators={Implements:function(self,klasses){$splat(klasses).each(function(klass){$extend(self,($type(klass)=='class')?new klass($empty):klass);});},Extends:function(self,klass){var instance=new klass($empty);delete instance.parent;delete instance.parentOf;for(var key in instance){var current=self[key],previous=instance[key];if(current==undefined){self[key]=previous;continue;}
var ctype=$type(current),ptype=$type(previous);if(ctype!=ptype)continue;switch(ctype){case'function':if(!arguments.callee.caller)self[key]=eval('('+String(current).replace(/\bthis\.parent\(\s*(\))?/g,function(full,close){return'arguments.callee._parent_.call(this'+(close||', ');})+')');self[key]._parent_=previous;break;case'object':self[key]=$merge(previous,current);}}
self.parent=function(){return arguments.callee.caller._parent_.apply(this,arguments);};self.parentOf=function(descendant){return descendant._parent_.apply(this,Array.slice(arguments,1));};}};var Chain=new Class({chain:function(){this.$chain=(this.$chain||[]).extend(arguments);return this;},callChain:function(){return(this.$chain&&this.$chain.length)?this.$chain.shift().apply(this,arguments):false;},clearChain:function(){if(this.$chain)this.$chain.empty();return this;}});var Events=new Class({addEvent:function(type,fn,internal){type=Events.removeOn(type);if(fn!=$empty){this.$events=this.$events||{};this.$events[type]=this.$events[type]||[];this.$events[type].include(fn);if(internal)fn.internal=true;}
return this;},addEvents:function(events){for(var type in events)this.addEvent(type,events[type]);return this;},fireEvent:function(type,args,delay){type=Events.removeOn(type);if(!this.$events||!this.$events[type])return this;this.$events[type].each(function(fn){fn.create({'bind':this,'delay':delay,'arguments':args})();},this);return this;},removeEvent:function(type,fn){type=Events.removeOn(type);if(!this.$events||!this.$events[type])return this;if(!fn.internal)this.$events[type].erase(fn);return this;},removeEvents:function(type){for(var e in this.$events){if(type&&type!=e)continue;var fns=this.$events[e];for(var i=fns.length;i--;i)this.removeEvent(e,fns[i]);}
return this;}});Events.removeOn=function(string){return string.replace(/^on([A-Z])/,function(full,first){return first.toLowerCase();});};var Options=new Class({setOptions:function(){this.options=$merge.run([this.options].extend(arguments));if(!this.addEvent)return this;for(var option in this.options){if($type(this.options[option])!='function'||!(/^on[A-Z]/).test(option))continue;this.addEvent(option,this.options[option]);delete this.options[option];}
return this;}});Document.implement({newElement:function(tag,props){if(Browser.Engine.trident&&props){['name','type','checked'].each(function(attribute){if(!props[attribute])return;tag+=' '+attribute+'="'+props[attribute]+'"';if(attribute!='checked')delete props[attribute];});tag='<'+tag+'>';}
return $.element(this.createElement(tag)).set(props);},newTextNode:function(text){return this.createTextNode(text);},getDocument:function(){return this;},getWindow:function(){return this.defaultView||this.parentWindow;},purge:function(){var elements=this.getElementsByTagName('*');for(var i=0,l=elements.length;i<l;i++)Browser.freeMem(elements[i]);}});var Element=new Native({name:'Element',legacy:window.Element,initialize:function(tag,props){var konstructor=Element.Constructors.get(tag);if(konstructor)return konstructor(props);if(typeof tag=='string')return document.newElement(tag,props);return $(tag).set(props);},afterImplement:function(key,value){if(!Array[key])Elements.implement(key,Elements.multi(key));Element.Prototype[key]=value;}});Element.Prototype={$family:{name:'element'}};Element.Constructors=new Hash;var IFrame=new Native({name:'IFrame',generics:false,initialize:function(){var params=Array.link(arguments,{properties:Object.type,iframe:$defined});var props=params.properties||{};var iframe=$(params.iframe)||false;var onload=props.onload||$empty;delete props.onload;props.id=props.name=$pick(props.id,props.name,iframe.id,iframe.name,'IFrame_'+$time());iframe=new Element(iframe||'iframe',props);var onFrameLoad=function(){var host=$try(function(){return iframe.contentWindow.location.host;});if(host&&host==window.location.host){var win=new Window(iframe.contentWindow);var doc=new Document(iframe.contentWindow.document);$extend(win.Element.prototype,Element.Prototype);}
onload.call(iframe.contentWindow,iframe.contentWindow.document);};(!window.frames[props.id])?iframe.addListener('load',onFrameLoad):onFrameLoad();return iframe;}});var Elements=new Native({initialize:function(elements,options){options=$extend({ddup:true,cash:true},options);elements=elements||[];if(options.ddup||options.cash){var uniques={},returned=[];for(var i=0,l=elements.length;i<l;i++){var el=$.element(elements[i],!options.cash);if(options.ddup){if(uniques[el.uid])continue;uniques[el.uid]=true;}
returned.push(el);}
elements=returned;}
return(options.cash)?$extend(elements,this):elements;}});Elements.implement({filter:function(filter,bind){if(!filter)return this;return new Elements(Array.filter(this,(typeof filter=='string')?function(item){return item.match(filter);}:filter,bind));}});Elements.multi=function(property){return function(){var items=[];var elements=true;for(var i=0,j=this.length;i<j;i++){var returns=this[i][property].apply(this[i],arguments);items.push(returns);if(elements)elements=($type(returns)=='element');}
return(elements)?new Elements(items):items;};};Window.implement({$:function(el,nocash){if(el&&el.$family&&el.uid)return el;var type=$type(el);return($[type])?$[type](el,nocash,this.document):null;},$$:function(selector){if(arguments.length==1&&typeof selector=='string')return this.document.getElements(selector);var elements=[];var args=Array.flatten(arguments);for(var i=0,l=args.length;i<l;i++){var item=args[i];switch($type(item)){case'element':item=[item];break;case'string':item=this.document.getElements(item,true);break;default:item=false;}
if(item)elements.extend(item);}
return new Elements(elements);},getDocument:function(){return this.document;},getWindow:function(){return this;}});$.string=function(id,nocash,doc){id=doc.getElementById(id);return(id)?$.element(id,nocash):null;};$.element=function(el,nocash){$uid(el);if(!nocash&&!el.$family&&!(/^object|embed$/i).test(el.tagName)){var proto=Element.Prototype;for(var p in proto)el[p]=proto[p];};return el;};$.object=function(obj,nocash,doc){if(obj.toElement)return $.element(obj.toElement(doc),nocash);return null;};$.textnode=$.whitespace=$.window=$.document=$arguments(0);Native.implement([Element,Document],{getElement:function(selector,nocash){return $(this.getElements(selector,true)[0]||null,nocash);},getElements:function(tags,nocash){tags=tags.split(',');var elements=[];var ddup=(tags.length>1);tags.each(function(tag){var partial=this.getElementsByTagName(tag.trim());(ddup)?elements.extend(partial):elements=partial;},this);return new Elements(elements,{ddup:ddup,cash:!nocash});}});Element.Storage={get:function(uid){return(this[uid]||(this[uid]={}));}};Element.Inserters=new Hash({before:function(context,element){if(element.parentNode)element.parentNode.insertBefore(context,element);},after:function(context,element){if(!element.parentNode)return;var next=element.nextSibling;(next)?element.parentNode.insertBefore(context,next):element.parentNode.appendChild(context);},bottom:function(context,element){element.appendChild(context);},top:function(context,element){var first=element.firstChild;(first)?element.insertBefore(context,first):element.appendChild(context);}});Element.Inserters.inside=Element.Inserters.bottom;Element.Inserters.each(function(value,key){var Key=key.capitalize();Element.implement('inject'+Key,function(el){value(this,$(el,true));return this;});Element.implement('grab'+Key,function(el){value($(el,true),this);return this;});});Element.implement({getDocument:function(){return this.ownerDocument;},getWindow:function(){return this.ownerDocument.getWindow();},getElementById:function(id,nocash){var el=this.ownerDocument.getElementById(id);if(!el)return null;for(var parent=el.parentNode;parent!=this;parent=parent.parentNode){if(!parent)return null;}
return $.element(el,nocash);},set:function(prop,value){switch($type(prop)){case'object':for(var p in prop)this.set(p,prop[p]);break;case'string':var property=Element.Properties.get(prop);(property&&property.set)?property.set.apply(this,Array.slice(arguments,1)):this.setProperty(prop,value);}
return this;},get:function(prop){var property=Element.Properties.get(prop);return(property&&property.get)?property.get.apply(this,Array.slice(arguments,1)):this.getProperty(prop);},erase:function(prop){var property=Element.Properties.get(prop);(property&&property.erase)?property.erase.apply(this,Array.slice(arguments,1)):this.removeProperty(prop);return this;},match:function(tag){return(!tag||Element.get(this,'tag')==tag);},inject:function(el,where){Element.Inserters.get(where||'bottom')(this,$(el,true));return this;},wraps:function(el,where){el=$(el,true);return this.replaces(el).grab(el,where);},grab:function(el,where){Element.Inserters.get(where||'bottom')($(el,true),this);return this;},appendText:function(text,where){return this.grab(this.getDocument().newTextNode(text),where);},adopt:function(){Array.flatten(arguments).each(function(element){element=$(element,true);if(element)this.appendChild(element);},this);return this;},dispose:function(){return(this.parentNode)?this.parentNode.removeChild(this):this;},clone:function(contents,keepid){switch($type(this)){case'element':var attributes={};for(var j=0,l=this.attributes.length;j<l;j++){var attribute=this.attributes[j],key=attribute.nodeName.toLowerCase();if(Browser.Engine.trident&&(/input/i).test(this.tagName)&&(/width|height/).test(key))continue;var value=(key=='style'&&this.style)?this.style.cssText:attribute.nodeValue;if(!$chk(value)||key=='uid'||(key=='id'&&!keepid))continue;if(value!='inherit'&&['string','number'].contains($type(value)))attributes[key]=value;}
var element=new Element(this.nodeName.toLowerCase(),attributes);if(contents!==false){for(var i=0,k=this.childNodes.length;i<k;i++){var child=Element.clone(this.childNodes[i],true,keepid);if(child)element.grab(child);}}
return element;case'textnode':return document.newTextNode(this.nodeValue);}
return null;},replaces:function(el){el=$(el,true);el.parentNode.replaceChild(this,el);return this;},hasClass:function(className){return this.className.contains(className,' ');},addClass:function(className){if(!this.hasClass(className))this.className=(this.className+' '+className).clean();return this;},removeClass:function(className){this.className=this.className.replace(new RegExp('(^|\\s)'+className+'(?:\\s|$)'),'$1').clean();return this;},toggleClass:function(className){return this.hasClass(className)?this.removeClass(className):this.addClass(className);},getComputedStyle:function(property){if(this.currentStyle)return this.currentStyle[property.camelCase()];var computed=this.getWindow().getComputedStyle(this,null);return(computed)?computed.getPropertyValue([property.hyphenate()]):null;},empty:function(){$A(this.childNodes).each(function(node){Browser.freeMem(node);Element.empty(node);Element.dispose(node);},this);return this;},destroy:function(){Browser.freeMem(this.empty().dispose());return null;},getSelected:function(){return new Elements($A(this.options).filter(function(option){return option.selected;}));},toQueryString:function(){var queryString=[];this.getElements('input, select, textarea').each(function(el){if(!el.name||el.disabled)return;var value=(el.tagName.toLowerCase()=='select')?Element.getSelected(el).map(function(opt){return opt.value;}):((el.type=='radio'||el.type=='checkbox')&&!el.checked)?null:el.value;$splat(value).each(function(val){if(val)queryString.push(el.name+'='+encodeURIComponent(val));});});return queryString.join('&');},getProperty:function(attribute){var EA=Element.Attributes,key=EA.Props[attribute];var value=(key)?this[key]:this.getAttribute(attribute,2);return(EA.Bools[attribute])?!!value:(key)?value:value||null;},getProperties:function(){var args=$A(arguments);return args.map(function(attr){return this.getProperty(attr);},this).associate(args);},setProperty:function(attribute,value){var EA=Element.Attributes,key=EA.Props[attribute],hasValue=$defined(value);if(key&&EA.Bools[attribute])value=(value||!hasValue)?true:false;else if(!hasValue)return this.removeProperty(attribute);(key)?this[key]=value:this.setAttribute(attribute,value);return this;},setProperties:function(attributes){for(var attribute in attributes)this.setProperty(attribute,attributes[attribute]);return this;},removeProperty:function(attribute){var EA=Element.Attributes,key=EA.Props[attribute],isBool=(key&&EA.Bools[attribute]);(key)?this[key]=(isBool)?false:'':this.removeAttribute(attribute);return this;},removeProperties:function(){Array.each(arguments,this.removeProperty,this);return this;}});(function(){var walk=function(element,walk,start,match,all,nocash){var el=element[start||walk];var elements=[];while(el){if(el.nodeType==1&&(!match||Element.match(el,match))){elements.push(el);if(!all)break;}
el=el[walk];}
return(all)?new Elements(elements,{ddup:false,cash:!nocash}):$(elements[0],nocash);};Element.implement({getPrevious:function(match,nocash){return walk(this,'previousSibling',null,match,false,nocash);},getAllPrevious:function(match,nocash){return walk(this,'previousSibling',null,match,true,nocash);},getNext:function(match,nocash){return walk(this,'nextSibling',null,match,false,nocash);},getAllNext:function(match,nocash){return walk(this,'nextSibling',null,match,true,nocash);},getFirst:function(match,nocash){return walk(this,'nextSibling','firstChild',match,false,nocash);},getLast:function(match,nocash){return walk(this,'previousSibling','lastChild',match,false,nocash);},getParent:function(match,nocash){return walk(this,'parentNode',null,match,false,nocash);},getParents:function(match,nocash){return walk(this,'parentNode',null,match,true,nocash);},getChildren:function(match,nocash){return walk(this,'nextSibling','firstChild',match,true,nocash);},hasChild:function(el){el=$(el,true);return(!!el&&$A(this.getElementsByTagName(el.tagName)).contains(el));}});})();Element.Properties=new Hash;Element.Properties.style={set:function(style){this.style.cssText=style;},get:function(){return this.style.cssText;},erase:function(){this.style.cssText='';}};Element.Properties.tag={get:function(){return this.tagName.toLowerCase();}};Element.Properties.href={get:function(){return(!this.href)?null:this.href.replace(new RegExp('^'+document.location.protocol+'\/\/'+document.location.host),'');}};Element.Properties.html={set:function(){return this.innerHTML=Array.flatten(arguments).join('');}};Native.implement([Element,Window,Document],{addListener:function(type,fn){if(this.addEventListener)this.addEventListener(type,fn,false);else this.attachEvent('on'+type,fn);return this;},removeListener:function(type,fn){if(this.removeEventListener)this.removeEventListener(type,fn,false);else this.detachEvent('on'+type,fn);return this;},retrieve:function(property,dflt){var storage=Element.Storage.get(this.uid);var prop=storage[property];if($defined(dflt)&&!$defined(prop))prop=storage[property]=dflt;return $pick(prop);},store:function(property,value){var storage=Element.Storage.get(this.uid);storage[property]=value;return this;},eliminate:function(property){var storage=Element.Storage.get(this.uid);delete storage[property];return this;}});Element.Attributes=new Hash({Props:{'html':'innerHTML','class':'className','for':'htmlFor','text':(Browser.Engine.trident)?'innerText':'textContent'},Bools:['compact','nowrap','ismap','declare','noshade','checked','disabled','readonly','multiple','selected','noresize','defer'],Camels:['value','accessKey','cellPadding','cellSpacing','colSpan','frameBorder','maxLength','readOnly','rowSpan','tabIndex','useMap']});Browser.freeMem=function(item){if(!item)return;if(Browser.Engine.trident&&(/object/i).test(item.tagName)){for(var p in item){if(typeof item[p]=='function')item[p]=$empty;}
Element.dispose(item);}
if(item.uid&&item.removeEvents)item.removeEvents();};(function(EA){var EAB=EA.Bools,EAC=EA.Camels;EA.Bools=EAB=EAB.associate(EAB);Hash.extend(Hash.combine(EA.Props,EAB),EAC.associate(EAC.map(function(v){return v.toLowerCase();})));EA.erase('Camels');})(Element.Attributes);window.addListener('unload',function(){window.removeListener('unload',arguments.callee);document.purge();if(Browser.Engine.trident)CollectGarbage();});Element.Properties.events={set:function(events){this.addEvents(events);}};Native.implement([Element,Window,Document],{addEvent:function(type,fn){var events=this.retrieve('events',{});events[type]=events[type]||{'keys':[],'values':[]};if(events[type].keys.contains(fn))return this;events[type].keys.push(fn);var realType=type,custom=Element.Events.get(type),condition=fn,self=this;if(custom){if(custom.onAdd)custom.onAdd.call(this,fn);if(custom.condition){condition=function(event){if(custom.condition.call(this,event))return fn.call(this,event);return false;};}
realType=custom.base||realType;}
var defn=function(){return fn.call(self);};var nativeEvent=Element.NativeEvents[realType]||0;if(nativeEvent){if(nativeEvent==2){defn=function(event){event=new Event(event,self.getWindow());if(condition.call(self,event)===false)event.stop();};}
this.addListener(realType,defn);}
events[type].values.push(defn);return this;},removeEvent:function(type,fn){var events=this.retrieve('events');if(!events||!events[type])return this;var pos=events[type].keys.indexOf(fn);if(pos==-1)return this;var key=events[type].keys.splice(pos,1)[0];var value=events[type].values.splice(pos,1)[0];var custom=Element.Events.get(type);if(custom){if(custom.onRemove)custom.onRemove.call(this,fn);type=custom.base||type;}
return(Element.NativeEvents[type])?this.removeListener(type,value):this;},addEvents:function(events){for(var event in events)this.addEvent(event,events[event]);return this;},removeEvents:function(type){var events=this.retrieve('events');if(!events)return this;if(!type){for(var evType in events)this.removeEvents(evType);events=null;}else if(events[type]){while(events[type].keys[0])this.removeEvent(type,events[type].keys[0]);events[type]=null;}
return this;},fireEvent:function(type,args,delay){var events=this.retrieve('events');if(!events||!events[type])return this;events[type].keys.each(function(fn){fn.create({'bind':this,'delay':delay,'arguments':args})();},this);return this;},cloneEvents:function(from,type){from=$(from);var fevents=from.retrieve('events');if(!fevents)return this;if(!type){for(var evType in fevents)this.cloneEvents(from,evType);}else if(fevents[type]){fevents[type].keys.each(function(fn){this.addEvent(type,fn);},this);}
return this;}});Element.NativeEvents={click:2,dblclick:2,mouseup:2,mousedown:2,contextmenu:2,mousewheel:2,DOMMouseScroll:2,mouseover:2,mouseout:2,mousemove:2,selectstart:2,selectend:2,keydown:2,keypress:2,keyup:2,focus:2,blur:2,change:2,reset:2,select:2,submit:2,load:1,unload:1,beforeunload:2,resize:1,move:1,DOMContentLoaded:1,readystatechange:1,error:1,abort:1,scroll:1};(function(){var $check=function(event){var related=event.relatedTarget;if(related==undefined)return true;if(related===false)return false;return($type(this)!='document'&&related!=this&&related.prefix!='xul'&&!this.hasChild(related));};Element.Events=new Hash({mouseenter:{base:'mouseover',condition:$check},mouseleave:{base:'mouseout',condition:$check},mousewheel:{base:(Browser.Engine.gecko)?'DOMMouseScroll':'mousewheel'}});})();Element.Properties.styles={set:function(styles){this.setStyles(styles);}};Element.Properties.opacity={set:function(opacity,novisibility){if(!novisibility){if(opacity==0){if(this.style.visibility!='hidden')this.style.visibility='hidden';}else{if(this.style.visibility!='visible')this.style.visibility='visible';}}
if(!this.currentStyle||!this.currentStyle.hasLayout)this.style.zoom=1;if(Browser.Engine.trident)this.style.filter=(opacity==1)?'':'alpha(opacity='+opacity*100+')';this.style.opacity=opacity;this.store('opacity',opacity);},get:function(){return this.retrieve('opacity',1);}};Element.implement({setOpacity:function(value){return this.set('opacity',value,true);},getOpacity:function(){return this.get('opacity');},setStyle:function(property,value){switch(property){case'opacity':return this.set('opacity',parseFloat(value));case'float':property=(Browser.Engine.trident)?'styleFloat':'cssFloat';}
property=property.camelCase();if($type(value)!='string'){var map=(Element.Styles.get(property)||'@').split(' ');value=$splat(value).map(function(val,i){if(!map[i])return'';return($type(val)=='number')?map[i].replace('@',Math.round(val)):val;}).join(' ');}else if(value==String(Number(value))){value=Math.round(value);}
this.style[property]=value;return this;},getStyle:function(property){switch(property){case'opacity':return this.get('opacity');case'float':property=(Browser.Engine.trident)?'styleFloat':'cssFloat';}
property=property.camelCase();var result=this.style[property];if(!$chk(result)){result=[];for(var style in Element.ShortStyles){if(property!=style)continue;for(var s in Element.ShortStyles[style])result.push(this.getStyle(s));return result.join(' ');}
result=this.getComputedStyle(property);}
if(result){result=String(result);var color=result.match(/rgba?\([\d\s,]+\)/);if(color)result=result.replace(color[0],color[0].rgbToHex());}
if(Browser.Engine.presto||(Browser.Engine.trident&&!$chk(parseInt(result)))){if(property.test(/^(height|width)$/)){var values=(property=='width')?['left','right']:['top','bottom'],size=0;values.each(function(value){size+=this.getStyle('border-'+value+'-width').toInt()+this.getStyle('padding-'+value).toInt();},this);return this['offset'+property.capitalize()]-size+'px';}
if(Browser.Engine.presto&&String(result).test('px'))return result;if(property.test(/(border(.+)Width|margin|padding)/))return'0px';}
return result;},setStyles:function(styles){for(var style in styles)this.setStyle(style,styles[style]);return this;},getStyles:function(){var result={};Array.each(arguments,function(key){result[key]=this.getStyle(key);},this);return result;}});Element.Styles=new Hash({left:'@px',top:'@px',bottom:'@px',right:'@px',width:'@px',height:'@px',maxWidth:'@px',maxHeight:'@px',minWidth:'@px',minHeight:'@px',backgroundColor:'rgb(@, @, @)',backgroundPosition:'@px @px',color:'rgb(@, @, @)',fontSize:'@px',letterSpacing:'@px',lineHeight:'@px',clip:'rect(@px @px @px @px)',margin:'@px @px @px @px',padding:'@px @px @px @px',border:'@px @ rgb(@, @, @) @px @ rgb(@, @, @) @px @ rgb(@, @, @)',borderWidth:'@px @px @px @px',borderStyle:'@ @ @ @',borderColor:'rgb(@, @, @) rgb(@, @, @) rgb(@, @, @) rgb(@, @, @)',zIndex:'@','zoom':'@',fontWeight:'@',textIndent:'@px',opacity:'@'});Element.ShortStyles={margin:{},padding:{},border:{},borderWidth:{},borderStyle:{},borderColor:{}};['Top','Right','Bottom','Left'].each(function(direction){var Short=Element.ShortStyles;var All=Element.Styles;['margin','padding'].each(function(style){var sd=style+direction;Short[style][sd]=All[sd]='@px';});var bd='border'+direction;Short.border[bd]=All[bd]='@px @ rgb(@, @, @)';var bdw=bd+'Width',bds=bd+'Style',bdc=bd+'Color';Short[bd]={};Short.borderWidth[bdw]=Short[bd][bdw]=All[bdw]='@px';Short.borderStyle[bds]=Short[bd][bds]=All[bds]='@';Short.borderColor[bdc]=Short[bd][bdc]=All[bdc]='rgb(@, @, @)';});(function(){Element.implement({scrollTo:function(x,y){if(isBody(this)){this.getWindow().scrollTo(x,y);}else{this.scrollLeft=x;this.scrollTop=y;}
return this;},getSize:function(){if(isBody(this))return this.getWindow().getSize();return{x:this.offsetWidth,y:this.offsetHeight};},getScrollSize:function(){if(isBody(this))return this.getWindow().getScrollSize();return{x:this.scrollWidth,y:this.scrollHeight};},getScroll:function(){if(isBody(this))return this.getWindow().getScroll();return{x:this.scrollLeft,y:this.scrollTop};},getScrolls:function(){var element=this,position={x:0,y:0};while(element&&!isBody(element)){position.x+=element.scrollLeft;position.y+=element.scrollTop;element=element.parentNode;}
return position;},getOffsetParent:function(){var element=this;if(isBody(element))return null;if(!Browser.Engine.trident)return element.offsetParent;while((element=element.parentNode)&&!isBody(element)){if(styleString(element,'position')!='static')return element;}
return null;},getOffsets:function(){var element=this,position={x:0,y:0};if(isBody(this))return position;while(element&&!isBody(element)){position.x+=element.offsetLeft;position.y+=element.offsetTop;if(Browser.Engine.gecko){if(!borderBox(element)){position.x+=leftBorder(element);position.y+=topBorder(element);}
var parent=element.parentNode;if(parent&&styleString(parent,'overflow')!='visible'){position.x+=leftBorder(parent);position.y+=topBorder(parent);}}else if(element!=this&&(Browser.Engine.trident||Browser.Engine.webkit)){position.x+=leftBorder(element);position.y+=topBorder(element);}
element=element.offsetParent;if(Browser.Engine.trident){while(element&&!element.currentStyle.hasLayout)element=element.offsetParent;}}
if(Browser.Engine.gecko&&!borderBox(this)){position.x-=leftBorder(this);position.y-=topBorder(this);}
return position;},getPosition:function(relative){if(isBody(this))return{x:0,y:0};var offset=this.getOffsets(),scroll=this.getScrolls();var position={x:offset.x-scroll.x,y:offset.y-scroll.y};var relativePosition=(relative&&(relative=$(relative)))?relative.getPosition():{x:0,y:0};return{x:position.x-relativePosition.x,y:position.y-relativePosition.y};},getCoordinates:function(element){if(isBody(this))return this.getWindow().getCoordinates();var position=this.getPosition(element),size=this.getSize();var obj={left:position.x,top:position.y,width:size.x,height:size.y};obj.right=obj.left+obj.width;obj.bottom=obj.top+obj.height;return obj;},computePosition:function(obj){return{left:obj.x-styleNumber(this,'margin-left'),top:obj.y-styleNumber(this,'margin-top')};},position:function(obj){return this.setStyles(this.computePosition(obj));}});Native.implement([Document,Window],{getSize:function(){var win=this.getWindow();if(Browser.Engine.presto||Browser.Engine.webkit)return{x:win.innerWidth,y:win.innerHeight};var doc=getCompatElement(this);return{x:doc.clientWidth,y:doc.clientHeight};},getScroll:function(){var win=this.getWindow();var doc=getCompatElement(this);return{x:win.pageXOffset||doc.scrollLeft,y:win.pageYOffset||doc.scrollTop};},getScrollSize:function(){var doc=getCompatElement(this);var min=this.getSize();return{x:Math.max(doc.scrollWidth,min.x),y:Math.max(doc.scrollHeight,min.y)};},getPosition:function(){return{x:0,y:0};},getCoordinates:function(){var size=this.getSize();return{top:0,left:0,bottom:size.y,right:size.x,height:size.y,width:size.x};}});var styleString=Element.getComputedStyle;function styleNumber(element,style){return styleString(element,style).toInt()||0;};function borderBox(element){return styleString(element,'-moz-box-sizing')=='border-box';};function topBorder(element){return styleNumber(element,'border-top-width');};function leftBorder(element){return styleNumber(element,'border-left-width');};function isBody(element){return(/^(?:body|html)$/i).test(element.tagName);};function getCompatElement(element){var doc=element.getDocument();return(!doc.compatMode||doc.compatMode=='CSS1Compat')?doc.html:doc.body;};})();Native.implement([Window,Document,Element],{getHeight:function(){return this.getSize().y;},getWidth:function(){return this.getSize().x;},getScrollTop:function(){return this.getScroll().y;},getScrollLeft:function(){return this.getScroll().x;},getScrollHeight:function(){return this.getScrollSize().y;},getScrollWidth:function(){return this.getScrollSize().x;},getTop:function(){return this.getPosition().y;},getLeft:function(){return this.getPosition().x;}});Native.implement([Document,Element],{getElements:function(expression,nocash){expression=expression.split(',');var items,local={};for(var i=0,l=expression.length;i<l;i++){var selector=expression[i],elements=Selectors.Utils.search(this,selector,local);if(i!=0&&elements.item)elements=$A(elements);items=(i==0)?elements:(items.item)?$A(items).concat(elements):items.concat(elements);}
return new Elements(items,{ddup:(expression.length>1),cash:!nocash});}});Element.implement({match:function(selector){if(!selector)return true;var tagid=Selectors.Utils.parseTagAndID(selector);var tag=tagid[0],id=tagid[1];if(!Selectors.Filters.byID(this,id)||!Selectors.Filters.byTag(this,tag))return false;var parsed=Selectors.Utils.parseSelector(selector);return(parsed)?Selectors.Utils.filter(this,parsed,{}):true;}});var Selectors={Cache:{nth:{},parsed:{}}};Selectors.RegExps={id:(/#([\w-]+)/),tag:(/^(\w+|\*)/),quick:(/^(\w+|\*)$/),splitter:(/\s*([+>~\s])\s*([a-zA-Z#.*:\[])/g),combined:(/\.([\w-]+)|\[(\w+)(?:([!*^$~|]?=)["']?(.*?)["']?)?\]|:([\w-]+)(?:\(["']?(.*?)?["']?\)|$)/g)};Selectors.Utils={chk:function(item,uniques){if(!uniques)return true;var uid=$uid(item);if(!uniques[uid])return uniques[uid]=true;return false;},parseNthArgument:function(argument){if(Selectors.Cache.nth[argument])return Selectors.Cache.nth[argument];var parsed=argument.match(/^([+-]?\d*)?([a-z]+)?([+-]?\d*)?$/);if(!parsed)return false;var inta=parseInt(parsed[1]);var a=(inta||inta===0)?inta:1;var special=parsed[2]||false;var b=parseInt(parsed[3])||0;if(a!=0){b--;while(b<1)b+=a;while(b>=a)b-=a;}else{a=b;special='index';}
switch(special){case'n':parsed={a:a,b:b,special:'n'};break;case'odd':parsed={a:2,b:0,special:'n'};break;case'even':parsed={a:2,b:1,special:'n'};break;case'first':parsed={a:0,special:'index'};break;case'last':parsed={special:'last-child'};break;case'only':parsed={special:'only-child'};break;default:parsed={a:(a-1),special:'index'};}
return Selectors.Cache.nth[argument]=parsed;},parseSelector:function(selector){if(Selectors.Cache.parsed[selector])return Selectors.Cache.parsed[selector];var m,parsed={classes:[],pseudos:[],attributes:[]};while((m=Selectors.RegExps.combined.exec(selector))){var cn=m[1],an=m[2],ao=m[3],av=m[4],pn=m[5],pa=m[6];if(cn){parsed.classes.push(cn);}else if(pn){var parser=Selectors.Pseudo.get(pn);if(parser)parsed.pseudos.push({parser:parser,argument:pa});else parsed.attributes.push({name:pn,operator:'=',value:pa});}else if(an){parsed.attributes.push({name:an,operator:ao,value:av});}}
if(!parsed.classes.length)delete parsed.classes;if(!parsed.attributes.length)delete parsed.attributes;if(!parsed.pseudos.length)delete parsed.pseudos;if(!parsed.classes&&!parsed.attributes&&!parsed.pseudos)parsed=null;return Selectors.Cache.parsed[selector]=parsed;},parseTagAndID:function(selector){var tag=selector.match(Selectors.RegExps.tag);var id=selector.match(Selectors.RegExps.id);return[(tag)?tag[1]:'*',(id)?id[1]:false];},filter:function(item,parsed,local){var i;if(parsed.classes){for(i=parsed.classes.length;i--;i){var cn=parsed.classes[i];if(!Selectors.Filters.byClass(item,cn))return false;}}
if(parsed.attributes){for(i=parsed.attributes.length;i--;i){var att=parsed.attributes[i];if(!Selectors.Filters.byAttribute(item,att.name,att.operator,att.value))return false;}}
if(parsed.pseudos){for(i=parsed.pseudos.length;i--;i){var psd=parsed.pseudos[i];if(!Selectors.Filters.byPseudo(item,psd.parser,psd.argument,local))return false;}}
return true;},getByTagAndID:function(ctx,tag,id){if(id){var item=(ctx.getElementById)?ctx.getElementById(id,true):Element.getElementById(ctx,id,true);return(item&&Selectors.Filters.byTag(item,tag))?[item]:[];}else{return ctx.getElementsByTagName(tag);}},search:function(self,expression,local){var splitters=[];var selectors=expression.trim().replace(Selectors.RegExps.splitter,function(m0,m1,m2){splitters.push(m1);return':)'+m2;}).split(':)');var items,match,filtered,item;for(var i=0,l=selectors.length;i<l;i++){var selector=selectors[i];if(i==0&&Selectors.RegExps.quick.test(selector)){items=self.getElementsByTagName(selector);continue;}
var splitter=splitters[i-1];var tagid=Selectors.Utils.parseTagAndID(selector);var tag=tagid[0],id=tagid[1];if(i==0){items=Selectors.Utils.getByTagAndID(self,tag,id);}else{var uniques={},found=[];for(var j=0,k=items.length;j<k;j++)found=Selectors.Getters[splitter](found,items[j],tag,id,uniques);items=found;}
var parsed=Selectors.Utils.parseSelector(selector);if(parsed){filtered=[];for(var m=0,n=items.length;m<n;m++){item=items[m];if(Selectors.Utils.filter(item,parsed,local))filtered.push(item);}
items=filtered;}}
return items;}};Selectors.Getters={' ':function(found,self,tag,id,uniques){var items=Selectors.Utils.getByTagAndID(self,tag,id);for(var i=0,l=items.length;i<l;i++){var item=items[i];if(Selectors.Utils.chk(item,uniques))found.push(item);}
return found;},'>':function(found,self,tag,id,uniques){var children=Selectors.Utils.getByTagAndID(self,tag,id);for(var i=0,l=children.length;i<l;i++){var child=children[i];if(child.parentNode==self&&Selectors.Utils.chk(child,uniques))found.push(child);}
return found;},'+':function(found,self,tag,id,uniques){while((self=self.nextSibling)){if(self.nodeType==1){if(Selectors.Utils.chk(self,uniques)&&Selectors.Filters.byTag(self,tag)&&Selectors.Filters.byID(self,id))found.push(self);break;}}
return found;},'~':function(found,self,tag,id,uniques){while((self=self.nextSibling)){if(self.nodeType==1){if(!Selectors.Utils.chk(self,uniques))break;if(Selectors.Filters.byTag(self,tag)&&Selectors.Filters.byID(self,id))found.push(self);}}
return found;}};Selectors.Filters={byTag:function(self,tag){return(tag=='*'||(self.tagName&&self.tagName.toLowerCase()==tag));},byID:function(self,id){return(!id||(self.id&&self.id==id));},byClass:function(self,klass){return(self.className&&self.className.contains(klass,' '));},byPseudo:function(self,parser,argument,local){return parser.call(self,argument,local);},byAttribute:function(self,name,operator,value){var result=Element.prototype.getProperty.call(self,name);if(!result)return false;if(!operator||value==undefined)return true;switch(operator){case'=':return(result==value);case'*=':return(result.contains(value));case'^=':return(result.substr(0,value.length)==value);case'$=':return(result.substr(result.length-value.length)==value);case'!=':return(result!=value);case'~=':return result.contains(value,' ');case'|=':return result.contains(value,'-');}
return false;}};Selectors.Pseudo=new Hash({empty:function(){return!(this.innerText||this.textContent||'').length;},not:function(selector){return!Element.match(this,selector);},contains:function(text){return(this.innerText||this.textContent||'').contains(text);},'first-child':function(){return Selectors.Pseudo.index.call(this,0);},'last-child':function(){var element=this;while((element=element.nextSibling)){if(element.nodeType==1)return false;}
return true;},'only-child':function(){var prev=this;while((prev=prev.previousSibling)){if(prev.nodeType==1)return false;}
var next=this;while((next=next.nextSibling)){if(next.nodeType==1)return false;}
return true;},'nth-child':function(argument,local){argument=(argument==undefined)?'n':argument;var parsed=Selectors.Utils.parseNthArgument(argument);if(parsed.special!='n')return Selectors.Pseudo[parsed.special].call(this,parsed.a,local);var count=0;local.positions=local.positions||{};var uid=$uid(this);if(!local.positions[uid]){var self=this;while((self=self.previousSibling)){if(self.nodeType!=1)continue;count++;var position=local.positions[$uid(self)];if(position!=undefined){count=position+count;break;}}
local.positions[uid]=count;}
return(local.positions[uid]%parsed.a==parsed.b);},index:function(index){var element=this,count=0;while((element=element.previousSibling)){if(element.nodeType==1&&++count>index)return false;}
return(count==index);},even:function(argument,local){return Selectors.Pseudo['nth-child'].call(this,'2n+1',local);},odd:function(argument,local){return Selectors.Pseudo['nth-child'].call(this,'2n',local);}});Element.Events.domready={onAdd:function(fn){if(Browser.loaded)fn.call(this);}};(function(){var domready=function(){if(Browser.loaded)return;Browser.loaded=true;window.fireEvent('domready');document.fireEvent('domready');};switch(Browser.Engine.name){case'webkit':(function(){(['loaded','complete'].contains(document.readyState))?domready():arguments.callee.delay(50);})();break;case'trident':var temp=document.createElement('div');(function(){($try(function(){temp.doScroll('left');return $(temp).inject(document.body).set('html','temp').dispose();}))?domready():arguments.callee.delay(50);})();break;default:window.addEvent('load',domready);document.addEvent('DOMContentLoaded',domready);}})();var JSON=new Hash({encode:function(obj){switch($type(obj)){case'string':return'"'+obj.replace(/[\x00-\x1f\\"]/g,JSON.$replaceChars)+'"';case'array':return'['+String(obj.map(JSON.encode).filter($defined))+']';case'object':case'hash':var string=[];Hash.each(obj,function(value,key){var json=JSON.encode(value);if(json)string.push(JSON.encode(key)+':'+json);});return'{'+string+'}';case'number':case'boolean':return String(obj);case false:return'null';}
return null;},$specialChars:{'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},$replaceChars:function(chr){return JSON.$specialChars[chr]||'\\u00'+Math.floor(chr.charCodeAt()/16).toString(16)+(chr.charCodeAt()%16).toString(16);},decode:function(string,secure){if($type(string)!='string'||!string.length)return null;if(secure&&!(/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(string.replace(/\\./g,'@').replace(/"[^"\\\n\r]*"/g,'')))return null;return eval('('+string+')');}});Native.implement([Hash,Array,String,Number],{toJSON:function(){return JSON.encode(this);}});var Cookie=new Class({Implements:Options,options:{path:false,domain:false,duration:false,secure:false,document:document},initialize:function(key,options){this.key=key;this.setOptions(options);},write:function(value){value=encodeURIComponent(value);if(this.options.domain)value+='; domain='+this.options.domain;if(this.options.path)value+='; path='+this.options.path;if(this.options.duration){var date=new Date();date.setTime(date.getTime()+this.options.duration*24*60*60*1000);value+='; expires='+date.toGMTString();}
if(this.options.secure)value+='; secure';this.options.document.cookie=this.key+'='+value;return this;},read:function(){var value=this.options.document.cookie.match('(?:^|;)\\s*'+this.key.escapeRegExp()+'=([^;]*)');return(value)?decodeURIComponent(value[1]):null;},dispose:function(){new Cookie(this.key,$merge(this.options,{duration:-1})).write('');return this;}});Cookie.write=function(key,value,options){return new Cookie(key,options).write(value);};Cookie.read=function(key){return new Cookie(key).read();};Cookie.dispose=function(key,options){return new Cookie(key,options).dispose();};var Swiff=new Class({Implements:[Options],options:{id:null,height:1,width:1,container:null,properties:{},params:{quality:'high',allowScriptAccess:'always',wMode:'transparent',swLiveConnect:true},callBacks:{},vars:{}},toElement:function(){return this.object;},initialize:function(path,options){this.instance='Swiff_'+$time();this.setOptions(options);options=this.options;var id=this.id=options.id||this.instance;var container=$(options.container);Swiff.CallBacks[this.instance]={};var params=options.params,vars=options.vars,callBacks=options.callBacks;var properties=$extend({height:options.height,width:options.width},options.properties);var self=this;for(var callBack in callBacks){Swiff.CallBacks[this.instance][callBack]=(function(option){return function(){return option.apply(self.object,arguments);};})(callBacks[callBack]);vars[callBack]='Swiff.CallBacks.'+this.instance+'.'+callBack;}
params.flashVars=Hash.toQueryString(vars);if(Browser.Engine.trident){properties.classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000';params.movie=path;}else{properties.type='application/x-shockwave-flash';properties.data=path;}
var build='<object id="'+id+'"';for(var property in properties)build+=' '+property+'="'+properties[property]+'"';build+='>';for(var param in params){if(params[param])build+='<param name="'+param+'" value="'+params[param]+'" />';}
build+='</object>';this.object=((container)?container.empty():new Element('div')).set('html',build).firstChild;},replaces:function(element){element=$(element,true);element.parentNode.replaceChild(this.toElement(),element);return this;},inject:function(element){$(element,true).appendChild(this.toElement());return this;},remote:function(){return Swiff.remote.apply(Swiff,[this.toElement()].extend(arguments));}});Swiff.CallBacks={};Swiff.remote=function(obj,fn){var rs=obj.CallFunction('<invoke name="'+fn+'" returntype="javascript">'+__flash__argumentsToXML(arguments,2)+'</invoke>');return eval(rs);};var Fx=new Class({Implements:[Chain,Events,Options],options:{fps:50,unit:false,duration:500,link:'ignore',transition:function(p){return-(Math.cos(Math.PI*p)-1)/2;}},initialize:function(options){this.subject=this.subject||this;this.setOptions(options);this.options.duration=Fx.Durations[this.options.duration]||this.options.duration.toInt();var wait=this.options.wait;if(wait===false)this.options.link='cancel';},step:function(){var time=$time();if(time<this.time+this.options.duration){var delta=this.options.transition((time-this.time)/this.options.duration);this.set(this.compute(this.from,this.to,delta));}else{this.set(this.compute(this.from,this.to,1));this.complete();}},set:function(now){return now;},compute:function(from,to,delta){return Fx.compute(from,to,delta);},check:function(caller){if(!this.timer)return true;switch(this.options.link){case'cancel':this.cancel();return true;case'chain':this.chain(caller.bind(this,Array.slice(arguments,1)));return false;}
return false;},start:function(from,to){if(!this.check(arguments.callee,from,to))return this;this.from=from;this.to=to;this.time=0;this.startTimer();this.onStart();return this;},complete:function(){if(this.stopTimer())this.onComplete();return this;},cancel:function(){if(this.stopTimer())this.onCancel();return this;},onStart:function(){this.fireEvent('start',this.subject);},onComplete:function(){this.fireEvent('complete',this.subject);if(!this.callChain())this.fireEvent('chainComplete',this.subject);},onCancel:function(){this.fireEvent('cancel',this.subject).clearChain();},pause:function(){this.stopTimer();return this;},resume:function(){this.startTimer();return this;},stopTimer:function(){if(!this.timer)return false;this.time=$time()-this.time;this.timer=$clear(this.timer);return true;},startTimer:function(){if(this.timer)return false;this.time=$time()-this.time;this.timer=this.step.periodical(Math.round(1000/this.options.fps),this);return true;}});Fx.compute=function(from,to,delta){return(to-from)*delta+from;};Fx.Durations={'short':250,'normal':500,'long':1000};Fx.CSS=new Class({Extends:Fx,prepare:function(element,property,values){values=$splat(values);var values1=values[1];if(!$chk(values1)){values[1]=values[0];values[0]=element.getStyle(property);}
var parsed=values.map(this.parse);return{from:parsed[0],to:parsed[1]};},parse:function(value){value=$lambda(value)();value=(typeof value=='string')?value.split(' '):$splat(value);return value.map(function(val){val=String(val);var found=false;Fx.CSS.Parsers.each(function(parser,key){if(found)return;var parsed=parser.parse(val);if($chk(parsed))found={value:parsed,parser:parser};});found=found||{value:val,parser:Fx.CSS.Parsers.String};return found;});},compute:function(from,to,delta){var computed=[];(Math.min(from.length,to.length)).times(function(i){computed.push({value:from[i].parser.compute(from[i].value,to[i].value,delta),parser:from[i].parser});});computed.$family={name:'fx:css:value'};return computed;},serve:function(value,unit){if($type(value)!='fx:css:value')value=this.parse(value);var returned=[];value.each(function(bit){returned=returned.concat(bit.parser.serve(bit.value,unit));});return returned;},render:function(element,property,value,unit){element.setStyle(property,this.serve(value,unit));},search:function(selector){if(Fx.CSS.Cache[selector])return Fx.CSS.Cache[selector];var to={};Array.each(document.styleSheets,function(sheet,j){var href=sheet.href;if(href&&href.contains('://')&&!href.contains(document.domain))return;var rules=sheet.rules||sheet.cssRules;Array.each(rules,function(rule,i){if(!rule.style)return;var selectorText=(rule.selectorText)?rule.selectorText.replace(/^\w+/,function(m){return m.toLowerCase();}):null;if(!selectorText||!selectorText.test('^'+selector+'$'))return;Element.Styles.each(function(value,style){if(!rule.style[style]||Element.ShortStyles[style])return;value=String(rule.style[style]);to[style]=(value.test(/^rgb/))?value.rgbToHex():value;});});});return Fx.CSS.Cache[selector]=to;}});Fx.CSS.Cache={};Fx.CSS.Parsers=new Hash({Color:{parse:function(value){if(value.match(/^#[0-9a-f]{3,6}$/i))return value.hexToRgb(true);return((value=value.match(/(\d+),\s*(\d+),\s*(\d+)/)))?[value[1],value[2],value[3]]:false;},compute:function(from,to,delta){return from.map(function(value,i){return Math.round(Fx.compute(from[i],to[i],delta));});},serve:function(value){return value.map(Number);}},Number:{parse:parseFloat,compute:Fx.compute,serve:function(value,unit){return(unit)?value+unit:value;}},String:{parse:$lambda(false),compute:$arguments(1),serve:$arguments(0)}});Fx.Tween=new Class({Extends:Fx.CSS,initialize:function(element,options){this.element=this.subject=$(element);this.parent(options);},set:function(property,now){if(arguments.length==1){now=property;property=this.property||this.options.property;}
this.render(this.element,property,now,this.options.unit);return this;},start:function(property,from,to){if(!this.check(arguments.callee,property,from,to))return this;var args=Array.flatten(arguments);this.property=this.options.property||args.shift();var parsed=this.prepare(this.element,this.property,args);return this.parent(parsed.from,parsed.to);}});Element.Properties.tween={set:function(options){var tween=this.retrieve('tween');if(tween)tween.cancel();return this.eliminate('tween').store('tween:options',$extend({link:'cancel'},options));},get:function(options){if(options||!this.retrieve('tween')){if(options||!this.retrieve('tween:options'))this.set('tween',options);this.store('tween',new Fx.Tween(this,this.retrieve('tween:options')));}
return this.retrieve('tween');}};Element.implement({tween:function(property,from,to){this.get('tween').start(arguments);return this;},fade:function(how){var fade=this.get('tween'),o='opacity',toggle;how=$pick(how,'toggle');switch(how){case'in':fade.start(o,1);break;case'out':fade.start(o,0);break;case'show':fade.set(o,1);break;case'hide':fade.set(o,0);break;case'toggle':var flag=this.retrieve('fade:flag',this.get('opacity')==1);fade.start(o,(flag)?0:1);this.store('fade:flag',!flag);toggle=true;break;default:fade.start(o,arguments);}
if(!toggle)this.eliminate('fade:flag');return this;},highlight:function(start,end){if(!end){end=this.retrieve('highlight:original',this.getStyle('background-color'));end=(end=='transparent')?'#fff':end;}
var tween=this.get('tween');tween.start('background-color',start||'#ffff88',end).chain(function(){this.setStyle('background-color',this.retrieve('highlight:original'));tween.callChain();}.bind(this));return this;}});Fx.Morph=new Class({Extends:Fx.CSS,initialize:function(element,options){this.element=this.subject=$(element);this.parent(options);},set:function(now){if(typeof now=='string')now=this.search(now);for(var p in now)this.render(this.element,p,now[p],this.options.unit);return this;},compute:function(from,to,delta){var now={};for(var p in from)now[p]=this.parent(from[p],to[p],delta);return now;},start:function(properties){if(!this.check(arguments.callee,properties))return this;if(typeof properties=='string')properties=this.search(properties);var from={},to={};for(var p in properties){var parsed=this.prepare(this.element,p,properties[p]);from[p]=parsed.from;to[p]=parsed.to;}
return this.parent(from,to);}});Element.Properties.morph={set:function(options){var morph=this.retrieve('morph');if(morph)morph.cancel();return this.eliminate('morph').store('morph:options',$extend({link:'cancel'},options));},get:function(options){if(options||!this.retrieve('morph')){if(options||!this.retrieve('morph:options'))this.set('morph',options);this.store('morph',new Fx.Morph(this,this.retrieve('morph:options')));}
return this.retrieve('morph');}};Element.implement({morph:function(props){this.get('morph').start(props);return this;}});(function(){var old=Fx.prototype.initialize;Fx.prototype.initialize=function(options){old.call(this,options);var trans=this.options.transition;if(typeof trans=='string'&&(trans=trans.split(':'))){var base=Fx.Transitions;base=base[trans[0]]||base[trans[0].capitalize()];if(trans[1])base=base['ease'+trans[1].capitalize()+(trans[2]?trans[2].capitalize():'')];this.options.transition=base;}};})();Fx.Transition=function(transition,params){params=$splat(params);return $extend(transition,{easeIn:function(pos){return transition(pos,params);},easeOut:function(pos){return 1-transition(1-pos,params);},easeInOut:function(pos){return(pos<=0.5)?transition(2*pos,params)/2:(2-transition(2*(1-pos),params))/2;}});};Fx.Transitions=new Hash({linear:$arguments(0)});Fx.Transitions.extend=function(transitions){for(var transition in transitions)Fx.Transitions[transition]=new Fx.Transition(transitions[transition]);};Fx.Transitions.extend({Pow:function(p,x){return Math.pow(p,x[0]||6);},Expo:function(p){return Math.pow(2,8*(p-1));},Circ:function(p){return 1-Math.sin(Math.acos(p));},Sine:function(p){return 1-Math.sin((1-p)*Math.PI/2);},Back:function(p,x){x=x[0]||1.618;return Math.pow(p,2)*((x+1)*p-x);},Bounce:function(p){var value;for(var a=0,b=1;1;a+=b,b/=2){if(p>=(7-4*a)/11){value=-Math.pow((11-6*a-11*p)/4,2)+b*b;break;}}
return value;},Elastic:function(p,x){return Math.pow(2,10*--p)*Math.cos(20*p*Math.PI*(x[0]||1)/3);}});['Quad','Cubic','Quart','Quint'].each(function(transition,i){Fx.Transitions[transition]=new Fx.Transition(function(p){return Math.pow(p,[i+2]);});});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},initialize:function(options){this.xhr=new Browser.Request();this.setOptions(options);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));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();}
this.xhr.onreadystatechange=$empty;},isSuccess:function(){return((this.status>=200)&&(this.status<300));},processScripts:function(text){if(this.options.evalResponse||(/(ecma|java)script/).test(this.getHeader('Content-type')))return $exec(text);return text.stripScripts(this.options.evalScripts);},success:function(text,xml){this.onSuccess(this.processScripts(text),xml);},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(name,value){this.headers.set(name,value);return this;},getHeader:function(name){return $try(function(){return this.xhr.getResponseHeader(name);}.bind(this));},check:function(caller){if(!this.running)return true;switch(this.options.link){case'cancel':this.cancel();return true;case'chain':this.chain(caller.bind(this,Array.slice(arguments,1)));return false;}
return false;},send:function(options){if(!this.check(arguments.callee,options))return this;this.running=true;var type=$type(options);if(type=='string'||type=='element')options={data:options};var old=this.options;options=$extend({data:old.data,url:old.url,method:old.method},options);var data=options.data,url=options.url,method=options.method;switch($type(data)){case'element':data=$(data).toQueryString();break;case'object':case'hash':data=Hash.toQueryString(data);}
if(this.options.format){var format='format='+this.options.format;data=(data)?format+'&'+data:format;}
if(this.options.emulation&&['put','delete'].contains(method)){var _method='_method='+method;data=(data)?_method+'&'+data:_method;method='post';}
if(this.options.urlEncoded&&method=='post'){var encoding=(this.options.encoding)?'; charset='+this.options.encoding:'';this.headers.set('Content-type','application/x-www-form-urlencoded'+encoding);}
if(data&&method=='get'){url=url+(url.contains('?')?'&':'?')+data;data=null;}
this.xhr.open(method.toUpperCase(),url,this.options.async);this.xhr.onreadystatechange=this.onStateChange.bind(this);this.headers.each(function(value,key){if(!$try(function(){this.xhr.setRequestHeader(key,value);return true;}.bind(this)))this.fireEvent('exception',[key,value]);},this);this.fireEvent('request');this.xhr.send(data);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 methods={};['get','post','put','delete','GET','POST','PUT','DELETE'].each(function(method){methods[method]=function(){var params=Array.link(arguments,{url:String.type,data:$defined});return this.send($extend(params,{method:method.toLowerCase()}));};});Request.implement(methods);})();Element.Properties.send={set:function(options){var send=this.retrieve('send');if(send)send.cancel();return this.eliminate('send').store('send:options',$extend({data:this,link:'cancel',method:this.get('method')||'post',url:this.get('action')},options));},get:function(options){if(options||!this.retrieve('send')){if(options||!this.retrieve('send:options'))this.set('send',options);this.store('send',new Request(this.retrieve('send:options')));}
return this.retrieve('send');}};Element.implement({send:function(url){var sender=this.get('send');sender.send({data:this,url:url||sender.options.url});return this;}});Request.HTML=new Class({Extends:Request,options:{update:false,evalScripts:true,filter:false},processHTML:function(text){var match=text.match(/<body[^>]*>([\s\S]*?)<\/body>/i);text=(match)?match[1]:text;var container=new Element('div');return $try(function(){var root='<root>'+text+'</root>',doc;if(Browser.Engine.trident){doc=new ActiveXObject('Microsoft.XMLDOM');doc.async=false;doc.loadXML(root);}else{doc=new DOMParser().parseFromString(root,'text/xml');}
root=doc.getElementsByTagName('root')[0];for(var i=0,k=root.childNodes.length;i<k;i++){var child=Element.clone(root.childNodes[i],true,true);if(child)container.grab(child);}
return container;})||container.set('html',text);},success:function(text){var options=this.options,response=this.response;response.html=text.stripScripts(function(script){response.javascript=script;});var temp=this.processHTML(response.html);response.tree=temp.childNodes;response.elements=temp.getElements('*');if(options.filter)response.tree=response.elements.filter(options.filter);if(options.update)$(options.update).empty().adopt(response.tree);if(options.evalScripts)$exec(response.javascript);this.onSuccess(response.tree,response.elements,response.html,response.javascript);}});Element.Properties.load={set:function(options){var load=this.retrieve('load');if(load)send.cancel();return this.eliminate('load').store('load:options',$extend({data:this,link:'cancel',update:this,method:'get'},options));},get:function(options){if(options||!this.retrieve('load')){if(options||!this.retrieve('load:options'))this.set('load',options);this.store('load',new Request.HTML(this.retrieve('load:options')));}
return this.retrieve('load');}};Element.implement({load:function(){this.get('load').send(Array.link(arguments,{data:Object.type,url:String.type}));return this;}});Request.JSON=new Class({Extends:Request,options:{secure:true},initialize:function(options){this.parent(options);this.headers.extend({'Accept':'application/json','X-Request':'JSON'});},success:function(text){this.response.json=JSON.decode(text,this.options.secure);this.onSuccess(this.response.json,text);}});Hash.Cookie=new Class({Extends:Cookie,options:{autoSave:true},initialize:function(name,options){this.parent(name,options);this.load();},save:function(){var value=JSON.encode(this.hash);if(!value||value.length>4096)return false;if(value=='{}')this.dispose();else this.write(value);return true;},load:function(){this.hash=new Hash(JSON.decode(this.read(),true));return this;}});Hash.Cookie.implement((function(){var methods={};Hash.each(Hash.prototype,function(method,name){methods[name]=function(){var value=method.apply(this.hash,arguments);if(this.options.autoSave)this.save();return value;};});return methods;})());var Color=new Native({initialize:function(color,type){if(arguments.length>=3){type="rgb";color=Array.slice(arguments,0,3);}else if(typeof color=='string'){if(color.match(/rgb/))color=color.rgbToHex().hexToRgb(true);else if(color.match(/hsb/))color=color.hsbToRgb();else color=color.hexToRgb(true);}
type=type||'rgb';switch(type){case'hsb':var old=color;color=color.hsbToRgb();color.hsb=old;break;case'hex':color=color.hexToRgb(true);break;}
color.rgb=color.slice(0,3);color.hsb=color.hsb||color.rgbToHsb();color.hex=color.rgbToHex();return $extend(color,this);}});Color.implement({mix:function(){var colors=Array.slice(arguments);var alpha=($type(colors.getLast())=='number')?colors.pop():50;var rgb=this.slice();colors.each(function(color){color=new Color(color);for(var i=0;i<3;i++)rgb[i]=Math.round((rgb[i]/100*(100-alpha))+(color[i]/100*alpha));});return new Color(rgb,'rgb');},invert:function(){return new Color(this.map(function(value){return 255-value;}));},setHue:function(value){return new Color([value,this.hsb[1],this.hsb[2]],'hsb');},setSaturation:function(percent){return new Color([this.hsb[0],percent,this.hsb[2]],'hsb');},setBrightness:function(percent){return new Color([this.hsb[0],this.hsb[1],percent],'hsb');}});function $RGB(r,g,b){return new Color([r,g,b],'rgb');};function $HSB(h,s,b){return new Color([h,s,b],'hsb');};function $HEX(hex){return new Color(hex,'hex');};Array.implement({rgbToHsb:function(){var red=this[0],green=this[1],blue=this[2];var hue,saturation,brightness;var max=Math.max(red,green,blue),min=Math.min(red,green,blue);var delta=max-min;brightness=max/255;saturation=(max!=0)?delta/max:0;if(saturation==0){hue=0;}else{var rr=(max-red)/delta;var gr=(max-green)/delta;var br=(max-blue)/delta;if(red==max)hue=br-gr;else if(green==max)hue=2+rr-br;else hue=4+gr-rr;hue/=6;if(hue<0)hue++;}
return[Math.round(hue*360),Math.round(saturation*100),Math.round(brightness*100)];},hsbToRgb:function(){var br=Math.round(this[2]/100*255);if(this[1]==0){return[br,br,br];}else{var hue=this[0]%360;var f=hue%60;var p=Math.round((this[2]*(100-this[1]))/10000*255);var q=Math.round((this[2]*(6000-this[1]*f))/600000*255);var t=Math.round((this[2]*(6000-this[1]*(60-f)))/600000*255);switch(Math.floor(hue/60)){case 0:return[br,t,p];case 1:return[q,br,p];case 2:return[p,br,t];case 3:return[p,q,br];case 4:return[t,p,br];case 5:return[br,p,q];}}
return false;}});String.implement({rgbToHsb:function(){var rgb=this.match(/\d{1,3}/g);return(rgb)?hsb.rgbToHsb():null;},hsbToRgb:function(){var hsb=this.match(/\d{1,3}/g);return(hsb)?hsb.hsbToRgb():null;}});var Group=new Class({initialize:function(){this.instances=Array.flatten(arguments);this.events={};this.checker={};},addEvent:function(type,fn){this.checker[type]=this.checker[type]||{};this.events[type]=this.events[type]||[];if(this.events[type].contains(fn))return false;else this.events[type].push(fn);this.instances.each(function(instance,i){instance.addEvent(type,this.check.bind(this,[type,instance,i]));},this);return this;},check:function(type,instance,i){this.checker[type][i]=true;var every=this.instances.every(function(current,j){return this.checker[type][j]||false;},this);if(!every)return;this.checker[type]={};this.events[type].each(function(event){event.call(this,this.instances,instance);},this);}});var Asset=new Hash({javascript:function(source,properties){properties=$extend({onload:$empty,document:document,check:$lambda(true)},properties);var script=new Element('script',{'src':source,'type':'text/javascript'});var load=properties.onload.bind(script),check=properties.check,doc=properties.document;delete properties.onload;delete properties.check;delete properties.document;script.addEvents({load:load,readystatechange:function(){if(['loaded','complete'].contains(this.readyState))load();}}).setProperties(properties);if(Browser.Engine.webkit419)var checker=(function(){if(!$try(check))return;$clear(checker);load();}).periodical(50);return script.inject(doc.head);},css:function(source,properties){return new Element('link',$merge({'rel':'stylesheet','media':'screen','type':'text/css','href':source},properties)).inject(document.head);},image:function(source,properties){properties=$merge({'onload':$empty,'onabort':$empty,'onerror':$empty},properties);var image=new Image();var element=$(image)||new Element('img');['load','abort','error'].each(function(name){var type='on'+name;var event=properties[type];delete properties[type];image[type]=function(){if(!image)return;if(!element.parentNode){element.width=image.width;element.height=image.height;}
image=image.onload=image.onabort=image.onerror=null;event.delay(1,element,element);element.fireEvent(name,element,1);};});image.src=element.src=source;if(image&&image.complete)image.onload.delay(1);return element.setProperties(properties);},images:function(sources,options){options=$merge({onComplete:$empty,onProgress:$empty},options);if(!sources.push)sources=[sources];var images=[];var counter=0;sources.each(function(source){var img=new Asset.image(source,{'onload':function(){options.onProgress.call(this,counter,sources.indexOf(source));counter++;if(counter==sources.length)options.onComplete();}});images.push(img);});return new Elements(images);}});Gixaw.namespace('Gixaw.Hooks');Gixaw._Hooks=new Class({Implements:[Options,Events]});Gixaw.Hooks=new Gixaw._Hooks();Gixaw.namespace('Gixaw.UI.Widget');Gixaw.UI.Widget=new Class({Implements:[Options,Events],options:{className:'gixaw-ui-widget',parentEl:null,visible:true,fill:false,autoFill:false,position:{x:0,y:0},size:{x:'auto',y:'auto'},minSize:{x:null,y:null},maxSize:{x:null,y:null}},templates:{'surface':''},initialize:function(options){this.setOptions(options);this.prepare(options);this.suspendLayout();this.setSize(this.options.size);this.setPosition(this.options.position);this.setParentEl(this.options.parentEl);},onPrepare:function(){this._buffer={};this._ready={queue:[],done:false};this._state={canLayout:true};this._templates={};if(this.options.autoFill)this.setAutoFill();else if(this.options.fill)this.fill();},afterPrepare:function(){},prepare:function(options){this._options=options||{};this.onPrepare();this.fireEvent('onPrepare');this.afterPrepare();},onRender:function(){this._surfaceEl=new Element('div',{'class':'gixaw-ui-widget','html':this.templates['surface'],'styles':{'position':'absolute'}});this._surfaceEl.addClass(this.options.className);this._surfaceEl.inject(this._parentEl);},afterRender:function(){this._ready.queue.each(function(item){item.fn.apply(this,item.args);},this);},render:function(){this._ready.done=true;this.onRender();this.fireEvent('onRender');this.afterRender();this.setSize(this.size);this.setPosition(this.position);this.resumeLayout();},onLayout:function(){},afterLayout:function(){},layout:function(){if(!this.isVisible()||!this._state.canLayout)return;this.onLayout();this.fireEvent('onLayout');this.afterLayout();},onFill:function(){var position=this._surfaceEl.parentNode.getInnerPosition();var size=this._surfaceEl.parentNode.getInnerSize();if(Browser.Engine.webkit)size.y-=3;else if(!Browser.Engine.trident)size.y-=2;this.setPosition(position);this.setSize(size);},afterFill:function(){},fill:function(){if(!this.isReady()){return this.runWhenReady(arguments.callee,$A(arguments));}
this.onFill();this.fireEvent('onFill');this.afterFill();},setAutoFill:function(autoFill){if(!this.isReady()){return this.runWhenReady(arguments.callee,$A(arguments));}
if(!$defined(autoFill)){autoFill=$defined(this.options.autoFill)?this.options.autoFill:true;}
if(!autoFill){if(this._autoFillFn)$(window).removeEvent('resize',this._autoFillFn);return;}
if(autoFill&&this._autoFillFn){return;}
this._autoFillFn=function(event){$clear(this._fillViewportTimerA);$clear(this._fillViewportTimerB);this._fillViewportTimerA=setTimeout(function(){this.fill();}.bind(this),250);this._fillViewportTimerB=setTimeout(function(){this.fill();}.bind(this),500);}.bindWithEvent(this);$(window).addEvent('resize',this._autoFillFn);this.fill();},runWhenReady:function(fn,args,scope){this._ready.queue.push({scope:scope,fn:fn,args:args});},setParentEl:function(parentEl,visible){if(this.isAdopted()){return;}
this._parentEl=$(parentEl);if(!this._parentEl){return;}
if(!$defined(visible)){visible=$defined(this.options.visible)?this.options.visible:true;}
if(visible)this.render();},setPosition:function(position){this.position=$merge(this.position||{},position||{});this.position.x=this.position.x||0;this.position.y=this.position.y||0;if(!this.isReady()){return;}
if(this.position.x=='center'){this.position.x=(this.getParentEl().getWidth()/2)-(this.getSurfaceEl().getWidth()/2);}
if(this.position.y=='center'){this.position.y=(this.getParentEl().getHeight()/2)-(this.getSurfaceEl().getHeight()/2);}
this._surfaceEl.setStyles({'left':this.position.x,'top':this.position.y});},setSize:function(size){this.size=$merge(this.size||{},size||{});this.size.x=this.size.x||'auto';this.size.y=this.size.y||'auto';if(this.options.minSize.x&&this.size.x!='auto')this.size.x=Math.max(this.size.x,this.options.minSize.x);if(this.options.minSize.y&&this.size.y!='auto')this.size.y=Math.max(this.size.y,this.options.minSize.y);if(this.options.maxSize.x&&this.size.x!='auto')this.size.x=Math.min(this.size.x,this.options.maxSize.x);if(this.options.maxSize.y&&this.size.y!='auto')this.size.y=Math.min(this.size.y,this.options.maxSize.y);if(!this.isReady()){return;}
this._oldSize=this._oldSize||{x:0,y:0};if(this.size.x!=this._oldSize.x||this.size.y!=this._oldSize.y){this._oldSize.x=this.size.x;this._oldSize.y=this.size.y;this._surfaceEl.setSize(this.size);this.layout();}},suspendLayout:function(){this._state.canLayout=false;},resumeLayout:function(){this._state.canLayout=true;this.layout();},getParentEl:function(){return this._parentEl;},getSurfaceEl:function(){return this._surfaceEl;},isAdopted:function(){return $defined(this._parentEl);},isReady:function(){return this._ready.done;},isVisible:function(){if(!this.isReady())return false;return(this._surfaceEl.getComputedStyle('display')!='none');},show:function(){if(!this.isAdopted())return;if(this.isReady()){this._surfaceEl.setStyle('display','block');this.layout();}
else{this.render();}},hide:function(){if(!this.isReady())return;this._surfaceEl.setStyle('display','none');},dispose:function(){if(!this.isReady())return;this._surfaceEl.dispose();}});Native.implement([Element,IFrame],{getComputedStyle:function(property){var result=null;if(this.getWindow().getComputedStyle){var computed=this.getWindow().getComputedStyle(this,null);if(computed)result=computed.getPropertyValue([property.hyphenate()]);}
else{result=this.currentStyle[property.camelCase()];}
return result;},prependHTML:function(html){this.set('html',html+this.get('html'));},appendHTML:function(html){this.set('html',this.get('html')+html);},getPadding:function(side){return parseInt(this.getComputedStyle('padding'+side.toLowerCase().capitalize()))||0;},getPaddingWidth:function(){return this.getPadding('left')+this.getPadding('right');},getPaddingHeight:function(){return this.getPadding('top')+this.getPadding('bottom');},getBorder:function(side){return parseInt(this.getComputedStyle('border'+side.toLowerCase().capitalize()+'Width'))||0;},getBorderWidth:function(){return this.getBorder('left')+this.getBorder('right');},getBorderHeight:function(){return this.getBorder('top')+this.getBorder('bottom');},getMargin:function(side){return parseInt(this.getComputedStyle('margin'+side.toLowerCase().capitalize()))||0;},getMarginWidth:function(){return this.getMargin('left')+this.getMargin('right');},getMarginHeight:function(){return this.getMargin('top')+this.getMargin('bottom');},getOuterWidth:function(){return this.getMarginWidth()+this.getBorderWidth()+this.getPaddingWidth();},getOuterHeight:function(){return this.getMarginHeight()+this.getBorderHeight()+this.getPaddingHeight();},getInnerWidth:function(){return this.getWidth()-this.getOuterWidth();},getInnerHeight:function(){return this.getHeight()-this.getOuterHeight();},getOuterSize:function(){return{x:this.getOuterWidth(),y:this.getOuterHeight()};},getInnerSize:function(){return{x:this.getInnerWidth(),y:this.getInnerHeight()};},getSide:function(side){return this.getMargin(side)+this.getBorder(side)+this.getPadding(side);},getInnerPosition:function(){var position=this.getPosition(this.getParent());position.x+=this.getSide('left');position.y+=this.getSide('top');return position;},hasOuter:function(){return['div','li'].contains(this.get('tag'));},setWidth:function(width){if(this.hasOuter()){width-=this.getOuterWidth();}
this.setStyle('width',Math.max(0,width));},setHeight:function(height){if(this.hasOuter()){height-=this.getOuterHeight();}
this.setStyle('height',Math.max(0,height));},setSize:function(size){size=size||{x:null,y:null};if(size.x)this.setWidth(size.x);if(size.y)this.setHeight(size.y);}});Gixaw.namespace('Gixaw.UI.Layout.Generic');Gixaw.namespace('Gixaw.UI.Layout.Stretch');Gixaw.namespace('Gixaw.UI.Layout.Grid');Gixaw.namespace('Gixaw.UI.Layout.Card');Gixaw.namespace('Gixaw.UI.Layout.Border');Gixaw.UI.Layout.Generic=new Class({Implements:[Options,Events],options:{container:null},initialize:function(options){this.setOptions(options);this._options=options;this.onPrepare();},onPrepare:function(){this._activeId=null;this.getContainer().addEvents({'onLayout':this.onLayout.bind(this),'onAdd':this.onAdd.bind(this),'onRemove':this.onRemove.bind(this),'onActivate':this.onActivate.bind(this),'onDeactivate':this.onDeactivate.bind(this)});},onLayout:function(){},onAdd:function(item){item.widget.suspendLayout();item.widget.setParentEl(this.getClientAreaEl());},onRemove:function(item,index){item.widget.dispose();},onActivate:function(item,options){this._activeId=item.id;},onDeactivate:function(item,options){this._activeId=null;},getContainer:function(){return this._options.container();},getClientAreaEl:function(){return this.getContainer().getClientAreaEl();},getItems:function(){return this.getContainer().getItems();}});Gixaw.UI.Layout.Stretch=new Class({Extends:Gixaw.UI.Layout.Generic,options:{},onPrepare:function(){this.parent();},onLayout:function(){this.parent();var clientAreaEl=this.getClientAreaEl();var items=this.getItems();var clientAreaSize=clientAreaEl.getInnerSize();items.each(function(item){var position=$unlink(item.position||{});var size=$unlink(item.size||{});if(String(position.x).test(/\d+\%/))position.x=Math.floor(clientAreaSize.x*(position.x.toInt()/100));if(String(position.y).test(/\d+\%/))position.y=Math.floor(clientAreaSize.y*(position.y.toInt()/100));if(String(size.x).test(/\d+\%/))size.x=Math.floor(clientAreaSize.x*(size.x.toInt()/100));if(String(size.y).test(/\d+\%/))size.y=Math.floor(clientAreaSize.y*(size.y.toInt()/100));position.x=parseInt(position.x||0).limit(0,clientAreaSize.x-1);position.y=parseInt(position.y||0).limit(0,clientAreaSize.y-1);size.x=parseInt(size.x||0).limit(0,clientAreaSize.x);size.y=parseInt(size.y||0).limit(0,clientAreaSize.y);item.widget.resumeLayout();item.widget.setPosition(position);item.widget.setSize(size);});},onAdd:function(item){this.parent(item);},onRemove:function(item,index){this.parent(item,index);},onActivate:function(item,options){this.parent(item,options);},onDeactivate:function(item,options){this.parent(item,options);}});Gixaw.UI.Layout.Grid=new Class({Extends:Gixaw.UI.Layout.Generic,options:{gridSize:{x:20,y:20}},onPrepare:function(){this.parent();},onLayout:function(){this.parent();var clientAreaEl=this.getClientAreaEl();var items=this.getItems();var clientAreaPosition=clientAreaEl.getInnerPosition();var clientAreaSize=clientAreaEl.getInnerSize();var gridSize={x:this.options.gridSize.x,y:this.options.gridSize.y};var cellSize={x:(Math.floor(clientAreaSize.x/gridSize.x)),y:(Math.floor(clientAreaSize.y/gridSize.y))}
items.each(function(item){var position=$unlink(item.position||{});position.x=parseInt(position.x||0).limit(0,gridSize.x-1);position.y=parseInt(position.y||0).limit(0,gridSize.y-1);var size=$unlink(item.size||{});size.x=parseInt(size.x||0).limit(0,gridSize.x);size.y=parseInt(size.y||0).limit(0,gridSize.y);item.widget.resumeLayout();item.widget.setPosition({x:((position.x*cellSize.x)+clientAreaPosition.x),y:((position.y*cellSize.y)+clientAreaPosition.y)});item.widget.setSize({x:size.x*cellSize.x,y:size.y*cellSize.y});});},onAdd:function(item){this.parent(item);},onRemove:function(item,index){this.parent(item,index);},onActivate:function(item,options){this.parent(item,options);},onDeactivate:function(item,options){this.parent(item,options);}});Gixaw.UI.Layout.Card=new Class({Extends:Gixaw.UI.Layout.Generic,options:{},onPrepare:function(){this.parent();},onLayout:function(){this.parent();var clientAreaEl=this.getClientAreaEl();var clientAreaPosition=clientAreaEl.getInnerPosition();var clientAreaSize=clientAreaEl.getInnerSize();var items=this.getItems();items.each(function(item){item.widget.suspendLayout();item.widget.hide();},this);if(this._activeId){var activeItem=this.getContainer().getItemById(this._activeId);if(activeItem){activeItem.widget.resumeLayout();activeItem.widget.setPosition(clientAreaPosition);activeItem.widget.setSize(clientAreaSize);activeItem.widget.show();}}},onAdd:function(item){this.parent(item);},onRemove:function(item,index){this.parent(item,index);},onActivate:function(item,options){this.parent(item,options);this._activeId=item.id;item.widget.resumeLayout();item.widget.show();this.getContainer().layout();},onDeactivate:function(item,options){this.parent(item,options);item.widget.suspendLayout();item.widget.hide();this._activeId=null;this.getContainer().layout();}});Gixaw.UI.Layout.Border=new Class({Extends:Gixaw.UI.Layout.Generic,options:{initialSize:100,splitterSize:5},onPrepare:function(){this.parent();this._regions={};this._splitters={};},onLayout:function(){this.parent();var center=this._regions.center;var north=this._regions.north;var east=this._regions.east;var west=this._regions.west;var south=this._regions.south;if(!center){return;}
var clientAreaEl=this.getClientAreaEl();var clientAreaSize=clientAreaEl.getInnerSize();var items=this.getItems();center.position={x:0,y:0};center.size.x=clientAreaSize.x;center.size.y=clientAreaSize.y;if(north){north.position={x:0,y:0};north.size.x=center.size.x;north.size.y=north.size.y||north.initialSize;this.adjustCenter('north',north.size.y);north.widget.setPosition(north.position);north.widget.setSize(north.size);north.widget.resumeLayout();this.adjustSplitter('north');}
if(south){south.position={x:0,y:0};south.size.x=center.size.x;south.size.y=south.size.y||south.initialSize;this.adjustCenter('south',south.size.y);south.position.y=center.position.y+center.size.y;south.widget.setPosition(south.position);south.widget.setSize(south.size);south.widget.resumeLayout();this.adjustSplitter('south');}
if(west){west.position={x:0,y:0};west.size.x=west.size.x||west.initialSize;west.size.y=center.size.y;this.adjustCenter('west',west.size.x);west.position.y=center.position.y;west.widget.setPosition(west.position);west.widget.setSize(west.size);west.widget.resumeLayout();this.adjustSplitter('west');}
if(east){east.position={x:0,y:0};east.size.x=east.size.x||east.initialSize;east.size.y=center.size.y;this.adjustCenter('east',east.size.x);east.position.x=center.position.x+center.size.x;east.position.y=center.position.y;east.widget.setPosition(east.position);east.widget.setSize(east.size);east.widget.resumeLayout();this.adjustSplitter('east');}
center.widget.setPosition(center.position);center.widget.setSize(center.size);center.widget.resumeLayout();},onAdd:function(item){this.parent(item);item.direction=item.direction||'center';item.initialSize=item.initialSize||this.options.initialSize||100;item.position={x:0,y:0};item.size={x:0,y:0};this._regions[item.direction]=item;this._regions[item.direction].widget.suspendLayout();this._regions[item.direction].widget.setParentEl(this.getClientAreaEl());if(item.direction!='center'&&item.splitter){this.createSplitter(item.direction);}},onRemove:function(item,index){this.parent(item,index);this._regions[item.direction].widget.dispose();this._splitters[item.direction].dispose();delete this._regions[item.direction];delete this._splitters[item.direction];},onActivate:function(item,options){this.parent(item,options);},onDeactivate:function(item,options){this.parent(item,options);},createSplitter:function(direction){if($type(direction)!='string'||direction=='center'||!this._regions[direction]||!this._regions[direction].splitter){return;}
this._splitters[direction]=new Element('div',{'class':('border-'+direction+'-splitter')});this.getClientAreaEl().adopt(this._splitters[direction]);if(!this._regions[direction].resizable){return;}
var mouseOver=function(event){this._splitters[direction].addClass('border-splitter-hover');}.bindWithEvent(this);var mouseOut=function(event){this._splitters[direction].removeClass('border-splitter-hover');}.bindWithEvent(this);this._splitters[direction].addEvent('mouseover',mouseOver);this._splitters[direction].addEvent('mouseout',mouseOut);this._splitters[direction].addEvent('mousedown',function(event){var splitterDoc=this._splitters[direction].getDocument();var isMoving=true;position={x:event.page.x,y:event.page.y};var eventStop=$lambda(false);var mouseMove=function(event){if(!isMoving||!position)return;var diff={x:(event.page.x-position.x),y:(event.page.y-position.y)};if(direction=='north'||direction=='south'){if(diff.y!=0){var yDefaultMaxSize=this.getClientAreaEl().getInnerSize().y-
(this._regions.center.yMinSize||this._regions.center.minSize||50);if(direction=='north'&&this._regions.south){yDefaultMaxSize-=this._regions.south.size.y;}
else if(direction=='south'&&this._regions.north){yDefaultMaxSize-=this._regions.north.size.y;}
var ySize=this._regions[direction].size.y+((direction=='north')?diff.y:-diff.y);var yMinSize=this._regions[direction].minSize||50;var yMaxSize=this._regions[direction].maxSize||yDefaultMaxSize;if((ySize>=yMinSize)&&(ySize<=yMaxSize)){this._regions[direction].size.y=ySize;}}
this.getContainer().layout();}
else if(direction=='east'||direction=='west'){if(diff.x!=0){var xDefaultMaxSize=this.getClientAreaEl().getInnerSize().x-
(this._regions.center.xMinSize||this._regions.center.minSize||50);if(direction=='east'&&this._regions.west){xDefaultMaxSize-=this._regions.west.size.x;}
else if(direction=='west'&&this._regions.east){xDefaultMaxSize-=this._regions.east.size.x;}
var xSize=this._regions[direction].size.x+((direction=='west')?diff.x:-diff.x);var xMinSize=this._regions[direction].minSize||50;var xMaxSize=this._regions[direction].maxSize||xDefaultMaxSize;if((xSize>=xMinSize)&&(xSize<=xMaxSize)){this._regions[direction].size.x=xSize;}}
this.getContainer().layout();}
position={x:event.page.x,y:event.page.y};event.stop();}.bindWithEvent(this);var mouseUp=function(event){isMoving=false;splitterDoc.removeEvent('mousemove',mouseMove);splitterDoc.removeEvent('mouseup',mouseUp);splitterDoc.removeEvent((Browser.Engine.trident)?'selectstart':'mousedown',eventStop);this._splitters[direction].removeClass('splitter-hover');this._splitters[direction].addEvent('mouseout',mouseOut);event.stop();}.bindWithEvent(this);this._splitters[direction].removeEvent('mouseout',mouseOut);splitterDoc.addEvent('mousemove',mouseMove);splitterDoc.addEvent('mouseup',mouseUp);splitterDoc.addEvent((Browser.Engine.trident)?'selectstart':'mousedown',eventStop);event.stop();}.bindWithEvent(this));},adjustCenter:function(direction,size){var center=this._regions.center;if(!center){return;}
switch(direction){case'north':center.position.y+=size;center.size.y-=size;break;case'south':center.size.y-=size;break;case'west':center.size.x-=size;center.position.x+=size;break;case'east':center.size.x-=size;break;}},adjustSplitter:function(direction){if(!this._regions[direction]||!this._regions[direction].splitter){return;}
var splitter={position:{x:0,y:0},size:{x:0,y:0}};var region=this._regions[direction];switch(direction){case'north':this.adjustCenter(direction,this.options.splitterSize);splitter.size.x=region.size.x;splitter.size.y=this.options.splitterSize;splitter.position.x=region.position.x;splitter.position.y=region.size.y;break;case'south':this.adjustCenter(direction,this.options.splitterSize);splitter.size.x=region.size.x;splitter.size.y=this.options.splitterSize;splitter.position.x=region.position.x;splitter.position.y=region.position.y-splitter.size.y;break;case'west':this.adjustCenter(direction,this.options.splitterSize);splitter.size.x=this.options.splitterSize;splitter.size.y=region.size.y;splitter.position.x=region.size.x;splitter.position.y=region.position.y;break;case'east':this.adjustCenter(direction,this.options.splitterSize);splitter.size.x=this.options.splitterSize;splitter.size.y=region.size.y;splitter.position.x=region.position.x-splitter.size.x;splitter.position.y=region.position.y;break;}
this._splitters[direction].setStyles({'position':'absolute','left':splitter.position.x,'top':splitter.position.y,'width':splitter.size.x,'height':splitter.size.y,'overflow':'hidden'});}});Gixaw.namespace('Gixaw.UI.Container');Gixaw.UI.Container=new Class({Extends:Gixaw.UI.Widget,options:{className:'gixaw-ui-container',layout:null,layoutOptions:{},items:[],activeId:null,activeIndex:-1},onPrepare:function(){this.parent();this._state.lastId=0;this._state.items=[];if(this.options.layout){this._layout=new Gixaw.UI.Layout[this.options.layout.capitalize()]($merge(this.options.layoutOptions,{container:$lambda(this)}));}
(this._options.items||[]).each(function(item){this.add(item);},this);},afterPrepare:function(){this.parent();},onRender:function(){this.parent();},afterRender:function(){this.parent();if(this.getCount()>0){if(this.options.activeId){this.activate(this.options.activeId);}
else if(this.options.activeIndex>=0){var item=this.getItemByIndex(this.options.activeIndex);if(item){this.activate(item.id);}}}},onLayout:function(){this.parent();},afterLayout:function(){this.parent();},onAdd:function(item){},afterAdd:function(item){this.layout();},add:function(item){if(!this.isReady()){return this.runWhenReady(arguments.callee,$A(arguments));}
item.id=item.id||this.generateId();this.onAdd(item);this.fireEvent('onAdd',item);this._state.items.push(item);this.afterAdd(item);return item;},onRemove:function(item,index){},afterRemove:function(item,index){this.layout();},remove:function(id){if(!this.isReady()){return this.runWhenReady(arguments.callee,$A(arguments));}
var index=this.getIndexById(id);if(index<0)return null;var item=this.getItemByIndex(index);this.onRemove(item,index);this.fireEvent('onRemove',item,index);this._state.items.splice(index,1);this.afterRemove(item,index);return item;},empty:function(){if(!this.isReady()){return this.runWhenReady(arguments.callee,$A(arguments));}
this._state.items=[];this.onEmpty();this.fireEvent('onEmpty');},onEmpty:function(){},onActivate:function(item,options){},afterActivate:function(item,options){},activate:function(id,options){var item=this.getItemById(id);if(!item)return false;this.onActivate(item,options);this.fireEvent('onActivate',item,options);this.afterActivate(item,options);return true;},onDeactivate:function(item,options){},afterDeactivate:function(item,options){},deactivate:function(id,options){var index=this.getIndexById(id);if(index<0)return false;this.onDeactivate(item,options);this.fireEvent('onDeactivate',item,options);this.afterDeactivate(item,options);return true;},getClientAreaEl:function(){return this.getSurfaceEl();},getItems:function(){return this._state.items;},getCount:function(){return this._state.items.length;},generateId:function(){return'item-'+(++this._state.lastId);},getIndexById:function(id){for(var i=0;i<this._state.items.length;i++){if(this._state.items[i].id==id){return i;}}
return-1;},getItemById:function(id){var index=this.getIndexById(id);return(index>=0)?this._state.items[index]:null;},getItemByIndex:function(index){return(index>=0&&index<this._state.items.length)?this._state.items[index]:null;}});Gixaw.namespace('Gixaw.UI.Dialog');Gixaw.UI.Dialog=new Class({Extends:Gixaw.UI.Widget,options:{className:'gixaw-ui-dialog',title:'',mode:'popup',url:null,autoSubmit:true,buttons:[{'id':'OK','title':Gixaw.Language.getString('site.button.OK')},{'id':'Cancel','title':Gixaw.Language.getString('site.button.cancel')}],position:{x:'center',y:'center'},closeImg:'core/img/gixaw/ui/dialog/close.png',loadImg:'core/img/gixaw/ui/dialog/loader.gif',iconImg:null},templates:{'surface':'<div class="title-bar"></div><div class="client-area"></div><div class="button-bar"></div>','title-bar':'<span class="icon"></span><span class="title"></span><span class="close"></span>'},onPrepare:function(){this.parent();if(this.options.title){this.setTitle(this.options.title);this.setIcon(this.options.loadImg);}
this._state.buttons=[];},onRender:function(){this.parent();this._titleBarEl=this._surfaceEl.getElement('.title-bar');this._titleBarEl.set('html',Gixaw.format(this.templates['title-bar']));this._clientAreaEl=this._surfaceEl.getElement('.client-area');this._buttonBarEl=this._surfaceEl.getElement('.button-bar');var closeImgEl=Asset.image(Gixaw.Router.getAssetUrl(this.options.closeImg));closeImgEl.addEvents({'click':function(event){this.close();}.bindWithEvent(this),'load':function(event){this.layout();}.bindWithEvent(this)});closeImgEl.inject(this._titleBarEl.getElement('.close'));if(this.options.url){this._iframeEl=new IFrame({'class':'dialog-iframe','src':this.options.url,'frameborder':'0','marginWidth':'0px','marginHeight':'0px','allowTransparency':'true','events':{'load':function(event){if(this._iframeEl.contentWindow.document.body.innerHTML==''){this.close();}
else{this.showIframe();if((this._iframeEl.contentWindow.document.getElementsByTagName('title')[0])&&(this._iframeEl.contentWindow.document.getElementsByTagName('title')[0].innerHTML.length>0)){this.options.title=this._iframeEl.contentWindow.document.getElementsByTagName('title')[0].innerHTML;this.setTitle(this.options.title);}}
this.fireEvent('onLoad',this);}.bindWithEvent(this)}});this._clientAreaEl.adopt(this._iframeEl);this.hideIframe();}
if(this.options.buttons){this.options.buttons.each(function(button){var buttonEl=new Element('button',{'text':button.title,'events':{'click':function(event){if(this['on'+button.id])this['on'+button.id]();this.fireEvent('on'+button.id,this);if(this['after'+button.id])this['after'+button.id]();}.bindWithEvent(this)}}).inject(this._buttonBarEl);this._state.buttons.push($unlink(button));},this);}
if(this._state.buttons.length==0){this._buttonBarEl.dispose();}
this._titleBarEl.addEvent('mousedown',function(event){var doc=this._titleBarEl.getDocument();var isMoving=true;position={x:event.page.x,y:event.page.y};var eventStop=$lambda(false);var mouseMove=function(event){if(!isMoving||!position)return;var diff={x:(event.page.x-position.x),y:(event.page.y-position.y)};this.setPosition({x:(this.position.x+diff.x),y:(this.position.y+diff.y)});position={x:event.page.x,y:event.page.y};event.stop();}.bindWithEvent(this);var mouseUp=function(event){isMoving=false;doc.removeEvent('mousemove',mouseMove);doc.removeEvent('mouseup',mouseUp);doc.removeEvent((Browser.Engine.trident)?'selectstart':'mousedown',eventStop);event.stop();}.bindWithEvent(this);doc.addEvent('mousemove',mouseMove);doc.addEvent('mouseup',mouseUp);doc.addEvent((Browser.Engine.trident)?'selectstart':'mousedown',eventStop);event.stop();}.bindWithEvent(this));},onLayout:function(){this.parent();this._titleBarEl.setWidth(this._surfaceEl.getInnerWidth());this._titleBarEl.getElement('.title').setWidth(this._titleBarEl.getInnerWidth()
-this._titleBarEl.getElement('.close').getWidth()-this._titleBarEl.getElement('.icon').getWidth());if(this._state.buttons.length==0){this._clientAreaEl.setHeight(this._surfaceEl.getInnerHeight()-this._titleBarEl.getHeight());}
else{this._clientAreaEl.setHeight(this._surfaceEl.getInnerHeight()-this._titleBarEl.getHeight()
-this._buttonBarEl.getHeight());}
if(this._iframeEl){this._iframeEl.setSize(this._clientAreaEl.getInnerSize());}},setTitle:function(title){if(!this.isReady()){return this.runWhenReady(arguments.callee,$A(arguments));}
if(title){this._titleBarEl.getElement('.title').empty();this._titleBarEl.getElement('.title').set('html',title);}},setIcon:function(iconImg){if(!this.isReady()){return this.runWhenReady(arguments.callee,$A(arguments));}
if(iconImg){this._titleBarEl.getElement('.icon').empty();var iconImgEl=Asset.image(Gixaw.Router.getAssetUrl(iconImg));iconImgEl.addEvent('load',function(event){this.layout()}.bindWithEvent(this));iconImgEl.inject(this._titleBarEl.getElement('.icon'));}},hideIframe:function(message){this._loadingDiv=new Element('div',{'class':'dialog-loading'});this._loadingDiv.innerHTML="<br />"+Gixaw.Language.getString('core.text.loading_wait');this._clientAreaEl.adopt(this._loadingDiv);if(message)this._loadingDiv.innerHTML="<br />"+message;this.setTitle(this.options.title);this.setIcon(this.options.loadImg);this._iframeEl.setStyles({display:'none'});},showIframe:function(){this._loadingDiv.dispose();this.setTitle(this.options.title);this.setIcon(this.options.iconImg);this._iframeEl.setStyles({display:'block'});},getField:function(field_name){if(this._iframeEl&&this._iframeEl.name){var iframe=this.getSurfaceEl().getWindow().frames[this._iframeEl.name];if(iframe.document.forms[0]){if(iframe.document.forms[0][field_name].type=="checkbox"){return iframe.document.forms[0][field_name].checked;}else{return iframe.document.forms[0][field_name].value;}}}},setField:function(field_name,val){if(this._iframeEl&&this._iframeEl.name){var iframe=this.getSurfaceEl().getWindow().frames[this._iframeEl.name];if(iframe.document.forms[0]){if(iframe.document.forms[0][field_name].type=="checkbox"){iframe.document.forms[0][field_name].checked=val;}else{iframe.document.forms[0][field_name].value=val;}}}},callLoadScript:function(){if(this._iframeEl&&this._iframeEl.name){var iframe=this.getSurfaceEl().getWindow().frames[this._iframeEl.name];if(iframe){iframe.loadScript();}}},onOK:function(){},afterOK:function(){if(this._iframeEl&&this._iframeEl.name){var iframe=this.getSurfaceEl().getWindow().frames[this._iframeEl.name];if(iframe.document.forms[0]&&this.options.autoSubmit){iframe.document.forms[0].submit();this.hideIframe(Gixaw.Language.getString('core.text.submitting'));}
else{this.close();}}
else{this.close();}},onCancel:function(){},afterCancel:function(){this.close();},onClose:function(){},afterClose:function(){},close:function(){if(!this.isReady()){return this.runWhenReady(arguments.callee,$A(arguments));}
this.onClose();this.fireEvent('onClose',this);this.afterClose();this.dispose.delay(100,this);}});Gixaw.namespace('Gixaw.UI.Form');Gixaw.namespace('Gixaw.UI.Form.Button');Gixaw.namespace('Gixaw.UI.Form.TextBox');Gixaw.namespace('Gixaw.UI.Form.ListBox');Gixaw.UI.Form=new Class({Extends:Gixaw.UI.Container,options:{className:'gixaw-ui-form',layout:'grid',position:{x:'center',y:'center'},autoActivate:false,title:'',closeImg:'core/img/gixaw/ui/tabview/close.png'},templates:{'surface':'<div class="title-bar"></div><div class="client-area"></div>','title-bar':'<span class="title"></span><span class="close"></span>'},onPrepare:function(){this.parent();if(this.options.title)this.setTitle(this.options.title);},onRender:function(){this.parent();this._titleBarEl=this._surfaceEl.getElement('.title-bar');this._titleBarEl.set('html',Gixaw.format(this.templates['title-bar']));this._clientAreaEl=this._surfaceEl.getElement('.client-area');var closeImgEl=Asset.image(Gixaw.Router.getAssetUrl(this.options.closeImg));closeImgEl.addEvents({'click':function(event){this.close();}.bindWithEvent(this),'load':function(event){this.layout();}.bindWithEvent(this)});closeImgEl.inject(this._titleBarEl.getElement('.close'));this._titleBarEl.addEvent('mousedown',function(event){var doc=this._titleBarEl.getDocument();var isMoving=true;position={x:event.page.x,y:event.page.y};var eventStop=$lambda(false);var mouseMove=function(event){if(!isMoving||!position)return;var diff={x:(event.page.x-position.x),y:(event.page.y-position.y)};this.setPosition({x:(this.position.x+diff.x),y:(this.position.y+diff.y)});position={x:event.page.x,y:event.page.y};event.stop();}.bindWithEvent(this);var mouseUp=function(event){isMoving=false;doc.removeEvent('mousemove',mouseMove);doc.removeEvent('mouseup',mouseUp);doc.removeEvent((Browser.Engine.trident)?'selectstart':'mousedown',eventStop);event.stop();}.bindWithEvent(this);doc.addEvent('mousemove',mouseMove);doc.addEvent('mouseup',mouseUp);doc.addEvent((Browser.Engine.trident)?'selectstart':'mousedown',eventStop);event.stop();}.bindWithEvent(this));},onLayout:function(){this.parent();this._titleBarEl.setWidth(this._surfaceEl.getInnerWidth());this._titleBarEl.getElement('.title').setWidth(this._titleBarEl.getInnerWidth()
-this._titleBarEl.getElement('.close').getWidth());this._clientAreaEl.setHeight(this._surfaceEl.getInnerHeight()-this._titleBarEl.getHeight());},getClientAreaEl:function(){return this._clientAreaEl;},setTitle:function(title){if(!this.isReady()){return this.runWhenReady(arguments.callee,$A(arguments));}
this._titleBarEl.getElement('.title').set('html',title);},onClose:function(){},afterClose:function(){},close:function(){if(!this.isReady()){return this.runWhenReady(arguments.callee,$A(arguments));}
this.onClose();this.fireEvent('onClose');this.afterClose();this.dispose();}});Gixaw.UI.Form.Button=new Class({Extends:Gixaw.UI.Widget,options:{className:'gixaw-ui-form-button',text:''},templates:{'surface':'<input type="button" />'},onPrepare:function(){this.parent();if(this.options.text)this.setText(this.options.text);},onRender:function(){this.parent();this._buttonEl=this._surfaceEl.getElement('input');this._buttonEl.addEvents({'click':function(event){this.onClick();this.fireEvent('onClick');}.bindWithEvent(this)});},afterRender:function(){this.parent();},onLayout:function(){this.parent();this._buttonEl.setSize(this._surfaceEl.getInnerSize());},onClick:function(){},setText:function(text){if(!this.isReady()){return this.runWhenReady(arguments.callee,$A(arguments));}
this._buttonEl.set('value',text);}});Gixaw.UI.Form.TextBox=new Class({Extends:Gixaw.UI.Widget,options:{className:'gixaw-ui-form-textbox',text:''},templates:{'surface':'<input type="text" />'},onPrepare:function(){this.parent();if(this.options.text)this.setText(this.options.text);},onRender:function(){this.parent();this._textBoxEl=this._surfaceEl.getElement('input');this._textBoxEl.addEvents({'change':function(event){this.onChange();this.fireEvent('onChange');}.bindWithEvent(this)});},onLayout:function(){this.parent();this._textBoxEl.setSize(this._surfaceEl.getInnerSize());},onChange:function(){},setText:function(text){if(!this.isReady()){return this.runWhenReady(arguments.callee,$A(arguments));}
this._textBoxEl.set('value',text);}});Gixaw.UI.Form.ListBox=new Class({Extends:Gixaw.UI.Container,options:{className:'gixaw-ui-form-listbox'},templates:{'surface':'<select />'},onPrepare:function(){this.parent();},onRender:function(){this.parent();this._listBoxEl=this._surfaceEl.getElement('select');this._listBoxEl.addEvents({'change':function(event){this.onChange();this.fireEvent('onChange');}.bindWithEvent(this)});},onLayout:function(){this.parent();this._listBoxEl.setSize(this._surfaceEl.getInnerSize());},onAdd:function(item){},onRemove:function(item){},onChange:function(){}});Gixaw.namespace('Gixaw.UI.Editor');Gixaw.UI.Editor=new Class({Extends:Gixaw.UI.Widget,options:{className:'gixaw-ui-editor',html:null},onPrepare:function(){this.parent();this._buffer.html=this.options.html;this._font=[];this._font['bold']=false;this._font['italic']=false;this._font['underline']=false;this._font['size']="small";this._font['color']="#000000";this._font['name']="Verdana";},onRender:function(){this.parent();this._editorEl=new Element('textarea',{'class':'editor'});this._editorEl.setStyle('resize','none');if(this._editorEl.addEventListener){this._editorEl.addEventListener("keypress",function(event){this.fireEvent('onKeyPress',new Event(event));}.bind(this),true);}else{this._editorEl.onkeypress=function(){this.fireEvent('onKeyPress',new Event(event));}.bind(this);}
if(this._buffer.text)this.setText(this._buffer.text);this.layout();this._editorEl.inject(this._surfaceEl);},onLayout:function(){this.parent();this._editorEl.setSize(this._surfaceEl.getInnerSize());this._editorEl.setStyle('font-size',this._font['size']);this._editorEl.setStyle('font-family',this._font['name']);this._editorEl.setStyle('color',this._font['color']);},appendText:function(text){if(!this.isReady()){this._buffer.text=text;return;}
if(!text){text="";}
this._editorEl.value+=text;},setText:function(text){if(!this.isReady()){this._buffer.text=text;return;}
if(!text){text="";}
this._editorEl.value=text;},getText:function(){return this._editorEl.value;},focus:function(){if(!this._editorEl.disabled)this._editorEl.focus();},richState:function(){this._editorEl.setStyle('text-align','left');if(this._font['bold']==true){this._editorEl.setStyle('font-weight','bold');}else{this._editorEl.setStyle('font-weight','normal');}
if(this._font['italic']==true){this._editorEl.setStyle('font-style','italic');}else{this._editorEl.setStyle('font-style','normal');}
if(this._font['underline']==true){this._editorEl.setStyle('text-decoration','underline');}else{this._editorEl.setStyle('text-decoration','none');}
if(this._font['size']){this._editorEl.setStyle('font-size',this._font['size']);}
if(this._font['name']){this._editorEl.setStyle('font-family',this._font['name']);}
if(this._font['color']){this._editorEl.setStyle('color',this._font['color']);}},noticeState:function(){this._editorEl.setStyle('text-align','center');this._editorEl.setStyle('color','#666666');this._editorEl.setStyle('font-size','small');this._editorEl.setStyle('font-family','Verdana');this._editorEl.setStyle('font-style','normal');this._editorEl.setStyle('font-weight','normal');this._editorEl.setStyle('text-decoration','none');}});Gixaw.namespace('Gixaw.UI.ListView');Gixaw.UI.ListView=new Class({Extends:Gixaw.UI.Container,options:{className:'gixaw-ui-listview',caption:null,showLoader:false,showCount:false,showSearch:false},templates:{'surface':'<div class="caption"></div><div class="status"></div><div class="inputbox"><input type="text" class="inputsearch" value="'+Gixaw.Language.getString('core.text.search')+'"></div><ul class="list" unselectable="on" onmousedown="return false;"></ul>','item':'<span class="icon"></span><span class="title">${title}</span><span class="subtitle">${subtitle}</span>','bar':'<span class="icon"><img src="${icon}" /></span><span class="title">${status}</span>'},onPrepare:function(){this.parent();this._buffer.caption=this.options.caption;this._buffer.status=null;if(this.options.showLoader){this.setStatus({status:Gixaw.Language.getString('core.text.loading'),icon:"site/img/icons/loader.gif"});}},onRender:function(){this.parent();this._captionEl=this._surfaceEl.getElement('.caption');this._statusEl=this._surfaceEl.getElement('.status');this._listEl=this._surfaceEl.getElement('.list');if(this.options.showSearch){this._inputEl=this._surfaceEl.getElement('.inputbox');this._inputFieldEl=this._inputEl.getElement('.inputsearch');this._inputFieldEl.addEvent('focus',function(){if(this._inputFieldEl.value==Gixaw.Language.getString('core.text.search')){this._inputFieldEl.value='';}}.bindWithEvent(this));this._inputFieldEl.addEvent('blur',function(){if(this._inputFieldEl.value==''){this._inputFieldEl.value=Gixaw.Language.getString('core.text.search');}}.bindWithEvent(this));this._inputFieldEl.addEvent('keyup',function(){this.searchList(this._inputFieldEl.value);}.bindWithEvent(this));}
if(!this.options.caption){this._captionEl.setStyles({display:'none'});}},searchList:function(phrase){this._listEl.empty();var filteredArray=this.getItems().filter(function(item,index){var re=new RegExp(phrase,"gi");return re.test(item.title);});filteredArray.each(function(item){this.onAdd(item);this.afterAdd(item,filteredArray);}.bindWithEvent(this));if(filteredArray.length==0){new Element('li',{'html':Gixaw.Language.getString('core.text.no_items')}).injectInside(this._listEl);}},afterRender:function(){this.parent();if(this._buffer.caption)this.setCaption(this._buffer.caption);if(this._buffer.status)this.setStatus(this._buffer.status);},onLayout:function(){this.parent();var listHeight=this._surfaceEl.getInnerHeight();if(this.options.caption){listHeight-=this._captionEl.getHeight();}
if(this.options.showSearch){listHeight-=this._inputEl.getHeight();}
if(this._statusEl.getStyle('display')!="none"){listHeight-=this._statusEl.getHeight();}
this._listEl.setHeight(listHeight);},onAdd:function(item){if(item.itemEl)item.itemEl.dispose();item.itemEl=new Element('li',{'html':Gixaw.format(this.templates['item'],{title:item.title,subtitle:item.subtitle}),'events':{'click':function(event){this.activate(item.id,{x:$unlink(event.page.x),y:$unlink(event.page.y),itemEl:$unlink(item.itemEl)});event.stop();}.bindWithEvent(this),'mouseenter':function(event){item.itemEl.addClass('hover');if(item.color_hover){item.itemEl.style.backgroundColor=item.color_hover;};}.bindWithEvent(this),'mouseleave':function(event){item.itemEl.removeClass('hover');if(item.color_hover){item.itemEl.style.backgroundColor=item.color_background;};}.bindWithEvent(this)}});if(item.color_background)item.itemEl.style.backgroundColor=item.color_background;if(item.color_foreground){item.itemEl.getElement('.title').style.color=item.color_foreground;}
if(item.color_foreground_subtitle){item.itemEl.getElement('.subtitle').style.color=item.color_foreground_subtitle;}
if(item.subtitle)item.itemEl.getElement('.subtitle').setStyles({display:'block'});if(item.disabled){item.itemEl.removeEvents();item.itemEl.addClass('disabled');}},afterAdd:function(item,search_items){this.sortList(search_items);if(item.iconImg)this.setIcon(item.id,item.iconImg);if(this.options.showCount&&this.caption)this.setCaption(this.caption);this.loaded();this.layout();},sortList:function(items){var items=(items)?items:this.getItems();items.sort(function(x,y){if(x.sort_order&&y.sort_order){if(x.sort_order>y.sort_order){return 1;}else if(x.sort_order<y.sort_order){return-1;}}
var a=String(x.title).toUpperCase();var b=String(y.title).toUpperCase();if(a>b)
return 1
if(a<b)
return-1
return 0;});items.each(function(item){item.itemEl.injectInside(this._listEl);}.bind(this));},onEmpty:function(){this._listEl.empty();if(this.options.showSearch)this._inputEl.dispose();this.setCaption(this.options.caption);this.setStatus({status:Gixaw.Language.getString('core.text.no_items'),icon:"site/img/icons/info.png"});},onRemove:function(item,index){item.itemEl.dispose();},afterRemove:function(item,index){if(this.options.showCount&&this.caption){this.setCaption(this.caption);}
this.layout();},loaded:function(){if(this.getCount()>0){if(this.options.showSearch){this._inputEl.setStyles({display:'block'});}
this.setStatus();}
else{this.setStatus({status:Gixaw.Language.getString('core.text.no_items'),icon:"site/img/icons/info.png"});}},onActivate:function(item,options){if(item.fn){item.fn(options);}},setStatus:function(status){if(!this.isReady()){this._buffer.status=status;return;}
if(status){this._statusEl.setStyle('display','block');this._statusEl.set('html',Gixaw.format(this.templates['bar'],{status:status.status,icon:Gixaw.Router.getAssetUrl(status.icon)}));}
else{this._statusEl.setStyle('display','none');}},setCaption:function(caption){if(!this.isReady()){this._buffer.caption=caption;return;}
this._captionEl.empty();this.caption=caption;if(this.options.showCount){caption=Gixaw.format(this.caption,{count:String(this.getCount())});}
this._captionEl.set('html',caption);},setIcon:function(id,iconImg){var item=this.getItemById(id);if(!item)return;if(iconImg){item.itemEl.getElement('.title').set('html',item.title);item.itemEl.getElement('.icon').empty();var iconImgEl=Asset.image(Gixaw.Router.getAssetUrl(iconImg));iconImgEl.addEvent('load',function(event){this.layout()}.bindWithEvent(this));iconImgEl.inject(item.itemEl.getElement('.icon'));}
item.iconImg=iconImg;},getTitle:function(id){var item=this.getItemById(id);if(!item)return;return item.title;},setTitle:function(id,title){var item=this.getItemById(id);if(!item)return;if(title){item.title=title;var _titleEl=item.itemEl.getElement('.title').empty();_titleEl.set('html',title);}},getSubTitle:function(id){var item=this.getItemById(id);if(!item)return;return item.subtitle;},setSubTitle:function(id,subtitle){var item=this.getItemById(id);if(!item)return;if(subtitle){item.subtitle=subtitle;var _subtitleEl=item.itemEl.getElement('.subtitle').empty();_subtitleEl.set('text',subtitle);_subtitleEl.setStyle('display','block');}}});Gixaw.namespace('Gixaw.UI.TabView');Gixaw.UI.TabView=new Class({Extends:Gixaw.UI.Container,options:{className:'gixaw-ui-tabview',layout:'card',activeId:null,maxTabWidth:150,closeImg:'core/img/gixaw/ui/tabview/close.png'},templates:{'surface':'<ul class="tab-group"></ul><div class="client-area"></div>','tab':'<span class="icon"></span><span class="title">${title}</span><span class="close"></span>'},getClientAreaEl:function(){return this._clientAreaEl;},onPrepare:function(){this.parent();this._state.activeId=this.options.activeId;this._state.flashTimers=[];},onRender:function(){this.parent();this._tabGroupEl=this._surfaceEl.getElement('.tab-group');this._clientAreaEl=this._surfaceEl.getElement('.client-area');},afterRender:function(){this.parent();if(this.getCount()>0){var item=this.getItemByIndex(0);if(item){this.activate(item.id);}}},onLayout:function(){this.parent();var tabGroupElHeight=(this.getCount()==0)?0:this._tabGroupEl.getHeight();this._clientAreaEl.setHeight(this._surfaceEl.getHeight()-tabGroupElHeight);this._tabGroupEl.getElements('li').removeClass('first').removeClass('last');this._tabGroupEl.getElements('li:first-child').addClass('first');this._tabGroupEl.getElements('li:last-child').addClass('last');var availableWidth=this._surfaceEl.getInnerWidth()-this._tabGroupEl.getOuterWidth();var tabWidth=Math.min(this.options.maxTabWidth,Math.floor(availableWidth/this.getCount()));this._state.items.each(function(item){if(item.tabEl.hasClass('first-tab')||item.tabEl.hasClass('last-tab')){item.tabEl.setWidth(30);}else{item.tabEl.setWidth(tabWidth);item.tabEl.getElement('.title').setWidth(item.tabEl.getInnerWidth()-item.tabEl.getElement('.icon').getWidth()
-item.tabEl.getElement('.close').getWidth());}},this);},onAdd:function(item){item.tabEl=new Element('li',{'html':Gixaw.format(this.templates['tab'],{title:item.title}),'events':{'click':function(event){if(item.fn){item.fn({x:$unlink(event.page.x),y:$unlink(event.page.y)});}else{this.activate(item.id,event);}event.stop();}.bindWithEvent(this),'mouseenter':function(event){if(!item.tabEl.hasClass('active'))item.tabEl.addClass('hover');}.bindWithEvent(this),'mouseleave':function(event){if(!item.tabEl.hasClass('active'))item.tabEl.removeClass('hover');}.bindWithEvent(this)}});if(item.className)item.tabEl.addClass(item.className);if(this._tabGroupEl.getElement('li.last-tab')){item.tabEl.inject(this._tabGroupEl.getElement('li.last-tab'),'before');}else{item.tabEl.inject(this._tabGroupEl);}
if(item.widget){item.widget.suspendLayout();item.widget.setParentEl(this._clientAreaEl,false);}},afterAdd:function(item){if(item.iconImg)this.setIcon(item.id,item.iconImg);if(item.closable)this.setClosable(item.id,item.closable);this.parent(item);},onRemove:function(item,index){item.tabEl.dispose();},afterRemove:function(item,index){this.parent(item,index);if(this._state.activeId==item.id){if(index>0){if(this._state.items[index-1].fn){this.activate(this._state.items[0].id);}else{this.activate(this._state.items[index-1].id);}}}},onActivate:function(item,options){if(item.fn)return;if(this._state.activeId){var lastItem=this.getItemById(this._state.activeId);if(lastItem){lastItem.tabEl.removeClass('active');lastItem.widget.suspendLayout();lastItem.widget.hide();}}
item.tabEl.removeClass('new');if(this._state.flashTimers[item.id]){$clear(this._state.flashTimers[item.id]);delete this._state.flashTimers[item.id];}
item.tabEl.removeClass('hover');item.tabEl.addClass('active');item.widget.show();this._state.activeId=item.id;this.layout();},setClosable:function(id,flag){var item=this.getItemById(id);if(!item)return;if(!$defined(flag))flag=true;item.tabEl.getElement('.close').empty();if(flag){var closeImgEl=Asset.image(Gixaw.Router.getAssetUrl(this.options.closeImg));closeImgEl.addEvents({'load':function(event){this.layout();}.bindWithEvent(this),'click':function(event){this.remove(id);event.stop();}.bindWithEvent(this)});closeImgEl.inject(item.tabEl.getElement('.close'));}
item.closable=flag;},isClosable:function(id){var item=this.getItemById(id);if(!item)return false;return item.closable;},setIcon:function(id,iconImg){var item=this.getItemById(id);if(!item)return;if(iconImg){item.tabEl.getElement('.icon').empty();var iconImgEl=Asset.image(Gixaw.Router.getAssetUrl(iconImg));iconImgEl.addEvent('load',function(event){this.layout()}.bindWithEvent(this));iconImgEl.inject(item.tabEl.getElement('.icon'));}
item.iconImg=iconImg;},setTitle:function(id,title){var item=this.getItemById(id);if(!item)return;if(title){item.tabEl.getElement('.title').empty();item.tabEl.getElement('.title').set('html',title);}},flashTab:function(id){var item=this.getItemById(id);if(!item)return;if(!this._state.flashTimers[id]){this._state.flashTimers[id]=setInterval(function(){item.tabEl.toggleClass('new');}.bind(this),750);}}});Gixaw.namespace('Gixaw.UI.ToolBar');Gixaw.UI.ToolBar=new Class({Extends:Gixaw.UI.Container,options:{className:'gixaw-ui-toolbar'},templates:{'surface':'<ul class="band"></ul>','button':'<span class="button"></span><span class="title">${title}</span>'},onPrepare:function(){this.parent();},onRender:function(){this.parent();this._bandEl=this._surfaceEl.getElement('.band');},onLayout:function(){this.parent();},onAdd:function(item){item.title=item.title||'';item.desc=item.desc||'';item.itemEl=new Element('li',{'html':Gixaw.format(this.templates['button'],{title:item.title}),'title':item.desc,'events':{'click':function(event){this.activate(item.id,{x:$unlink(event.page.x),y:$unlink(event.page.y),itemEl:$unlink(item.itemEl)});if(item.keepSelected){if(item.itemEl.hasClass('selected')){item.itemEl.removeClass('selected');}else{item.itemEl.addClass('selected');}}
event.stop();}.bindWithEvent(this),'mouseenter':function(event){item.itemEl.addClass('hover');}.bindWithEvent(this),'mouseleave':function(event){item.itemEl.removeClass('hover');}.bindWithEvent(this)}});if(item.disabled){item.itemEl.removeEvents();item.itemEl.addClass('disabled');}
item.itemEl.inject(this._bandEl);if(item.title.length==0)item.itemEl.getElement('.title').remove();},afterAdd:function(item){if(item.buttonImg)this.setButton(item.id,item.buttonImg);this.layout();},onRemove:function(item,index){item.itemEl.dipose();},onActivate:function(item,options){if(item.fn){item.fn(options||{});}},setButton:function(id,buttonImg){var item=this.getItemById(id);if(!item)return;if(buttonImg){item.itemEl.getElement('.button').empty();var buttonImgEl=Asset.image(Gixaw.Router.getAssetUrl(buttonImg));buttonImgEl.addEvent('load',function(event){this.layout()}.bindWithEvent(this));buttonImgEl.inject(item.itemEl.getElement('.button'));}
item.buttonImg=buttonImg;}});Gixaw.namespace('Gixaw.UI.Panel');Gixaw.UI.Panel=new Class({Extends:Gixaw.UI.Widget,options:{className:'gixaw-ui-panel',html:null,url:null},onPrepare:function(){this.parent();if(this.options.html)this.setHTML(this.options.html);if(this.options.url)this.setURL(this.options.url);},onRender:function(){this.parent();},onLayout:function(){this.parent();if(this._iframeEl){this._iframeEl.setSize(this.getSurfaceEl().getInnerSize());}},setHTML:function(html){if(!this.isReady()){return this.runWhenReady(arguments.callee,$A(arguments));}
this._surfaceEl.set('html',html);},appendHTML:function(html){if(!this.isReady()){return this.runWhenReady(arguments.callee,$A(arguments));}
this.getSurfaceEl().appendHTML(html);},setURL:function(url){if(!this.isReady()){return this.runWhenReady(arguments.callee,$A(arguments));}
this._iframeEl=new IFrame({'src':url,'frameborder':'0','marginWidth':'0px','marginHeight':'0px','scrolling':'no','events':{'load':function(event){}.bindWithEvent(this)}});this.getSurfaceEl().adopt(this._iframeEl);this.layout();}});Gixaw.namespace('Gixaw.UI.Popup');Gixaw.UI.Popup=new Class({Extends:Gixaw.UI.Container,options:{className:'gixaw-ui-popup',wait:1500,caption:null},templates:{'surface':'<ul class="menu"></ul>','item':'<span class="icon"></span><span class="title">${title}</span>'},onPrepare:function(){this.parent();},onRender:function(){this.parent();this._menuEl=this._surfaceEl.getElement('.menu');this._docClick=function(){this.dispose();}.bindWithEvent(this);document.addEvent('click',this._docClick);if(this.options.caption){var caption=new Element('li',{'class':'caption','html':this.options.caption});caption.inject(this._menuEl);}},afterRender:function(){this.parent();this.appear();},onLayout:function(){this.parent();var maxPos=$unlink(Document.getSize());var bottomRightPos=this.getSurfaceEl().getPosition();bottomRightPos.x+=this.getSurfaceEl().getWidth();bottomRightPos.y+=this.getSurfaceEl().getHeight();var position=$unlink(this.getSurfaceEl().getPosition());if(bottomRightPos.x>maxPos.x){position.x-=this.getSurfaceEl().getWidth();}
if(bottomRightPos.y>maxPos.y){position.y-=this.getSurfaceEl().getHeight();}
this.setPosition(position);},onAdd:function(item){item.title=item.title||'';item.itemEl=new Element('li',{'html':Gixaw.format(this.templates['item'],{title:item.title}),'events':{'click':function(event){this.dispose();this.activate(item.id);event.stop();}.bindWithEvent(this),'mouseenter':function(event){if(!item.itemEl.hasClass('hover'))item.itemEl.addClass('hover');}.bindWithEvent(this),'mouseleave':function(e){if(item.itemEl.hasClass('hover'))item.itemEl.removeClass('hover');}.bindWithEvent(this)}});if(item.seperator==true)item.itemEl.addClass('seperator');if(item.className)item.itemEl.addClass(item.className);if(item.disabled){item.itemEl.removeEvents();item.itemEl.addClass('disabled');}
item.itemEl.inject(this._menuEl);},afterAdd:function(item){item.iconSize=item.iconSize||null;if(item.iconImg)this.setIcon(item.id,item.iconImg,item.iconSize);this.layout();},onRemove:function(item,index){item.itemEl.dipose();},afterRemove:function(item,index){this.layout();},onActivate:function(item,options){if(item.fn){item.fn(options);}},setIcon:function(id,iconImg,iconSize){var item=this.getItemById(id);if(!item)return;if(iconImg){item.itemEl.getElement('.icon').empty();var iconImgEl=Asset.image(Gixaw.Router.getAssetUrl(iconImg));if(iconSize){iconImgEl.setStyle('width',iconSize+'px');iconImgEl.setStyle('height',iconSize+'px');}
iconImgEl.addEvent('load',function(event){this.layout()}.bindWithEvent(this));iconImgEl.inject(item.itemEl.getElement('.icon'));}
item.iconImg=iconImg;},appear:function(){if(Gixaw.UI.Popup.current)Gixaw.UI.Popup.current.dispose();Gixaw.UI.Popup.current=this;this._appearTimer=setTimeout(this.dispose.bind(this),this.options.wait*2);this._surfaceEl.addEvent('mouseenter',function(event){$clear(this._appearTimer);}.bindWithEvent(this));this._surfaceEl.addEvent('mouseleave',function(event){this._appearTimer=setTimeout(this.dispose.bind(this),this.options.wait);}.bindWithEvent(this));},dispose:function(){this.parent();document.removeEvent('click',this._docClick);$clear(this._appearTimer);Gixaw.UI.Popup.current=null;}});Gixaw.UI.Popup.current=null;Gixaw.namespace('Gixaw.UI.Notice');Gixaw.UI.Notice=new Class({Extends:Gixaw.UI.Widget,options:{className:'gixaw-ui-notice',text:'',iconImg:null,position:{x:0,y:0}},templates:{'surface':'<table class="client-area"><tr><td class="text"></td></tr></table>'},onPrepare:function(){this.parent();if(this.options.text)this.setText(this.options.text);},onRender:function(){this.parent();this._clientAreaEl=this._surfaceEl.getElement('.client-area');this._textEl=this._clientAreaEl.getElement('.text');},onLayout:function(){this.parent();this._surfaceEl.setSize(this._parentEl.getInnerSize());this._clientAreaEl.setSize(this._surfaceEl.getInnerSize());},setText:function(text){if(!this.isReady()){return this.runWhenReady(arguments.callee,$A(arguments));}
if(this.options.iconImg){this._textEl.set('html','<img src="'+Gixaw.Router.getAssetUrl(this.options.iconImg)+'"><br />'+text);}else{this._textEl.set('html',text);}
this.layout();}});Gixaw.namespace('Gixaw.UI.Balloon');Gixaw.UI.Balloon=new Class({Extends:Gixaw.UI.Container,options:{className:'gixaw-ui-balloon',text:Gixaw.Language.getString('core.text.no_text'),closeImg:'core/img/gixaw/ui/balloon/close.png',arrowLeft:'core/img/gixaw/ui/balloon/arrowleft.png',closeFn:null},templates:{'surface':'<div class="left"></div><div class="menu"></div>'},onPrepare:function(){this.parent();},onRender:function(){this.parent();this._menuEl=this._surfaceEl.getElement('.menu');this._leftEl=this._surfaceEl.getElement('.left');var leftImg=Asset.image(Gixaw.Router.getAssetUrl(this.options.arrowLeft));leftImg.inject(this._leftEl);this._menuEl.set('text',this.options.text);var closeImg=Asset.image(Gixaw.Router.getAssetUrl(this.options.closeImg));closeImg.addEvents({'click':function(event){if(this.options.closeFn){this.options.closeFn();}this.dispose();}.bindWithEvent(this)});closeImg.inject(this._menuEl);},afterRender:function(){this.parent();},onLayout:function(){this.parent();var maxPos=$unlink(Document.getSize());var bottomRightPos=this.getSurfaceEl().getPosition();bottomRightPos.x+=this.getSurfaceEl().getWidth();bottomRightPos.y+=this.getSurfaceEl().getHeight();var position=$unlink(this.getSurfaceEl().getPosition());if(bottomRightPos.x>maxPos.x){position.x-=this.getSurfaceEl().getWidth();}
if(bottomRightPos.y>maxPos.y){position.y-=this.getSurfaceEl().getHeight();}
this.setPosition(position);},onActivate:function(item,options){if(item.fn){item.fn(options);}}});function SoundManager(smURL,smID){var self=this;this.version='V2.2.20080420';this.url=(smURL||'soundmanager2.swf');this.debugMode=true;this.useConsole=true;this.consoleOnly=false;this.nullURL='data/null.mp3';this.defaultOptions={'autoLoad':false,'stream':true,'autoPlay':false,'onid3':null,'onload':null,'whileloading':null,'onplay':null,'whileplaying':null,'onstop':null,'onfinish':null,'onbeforefinish':null,'onbeforefinishtime':5000,'onbeforefinishcomplete':null,'onjustbeforefinish':null,'onjustbeforefinishtime':200,'multiShot':true,'position':null,'pan':0,'volume':100}
this.allowPolling=true;this.enabled=false;this.o=null;this.id=(smID||'sm2movie');this.oMC=null;this.sounds=[];this.soundIDs=[];this.isIE=(navigator.userAgent.match(/MSIE/));this.isSafari=(navigator.userAgent.match(/safari/i));this.debugID='soundmanager-debug';this._debugOpen=true;this._didAppend=false;this._appendSuccess=false;this._didInit=false;this._disabled=false;this._hasConsole=(typeof console!='undefined'&&typeof console.log!='undefined');this._debugLevels=!self.isSafari?['debug','info','warn','error']:['log','log','log','log'];this.supported=function(){return(self._didInit&&!self._disabled);}
this.getMovie=function(smID){return self.isIE?window[smID]:(self.isSafari?document[smID+'-embed']:document.getElementById(smID+'-embed'));}
this.loadFromXML=function(sXmlUrl){try{self.o._loadFromXML(sXmlUrl);}catch(e){self._failSafely();return true;}}
this.createSound=function(oOptions){if(!self._didInit)throw new Error('soundManager.createSound(): Not loaded yet - wait for soundManager.onload() before calling sound-related methods');if(arguments.length==2){oOptions={'id':arguments[0],'url':arguments[1]}}
var thisOptions=self._mergeObjects(oOptions);self._writeDebug('soundManager.createSound(): "<a href="#" onclick="soundManager.play(\''+thisOptions.id+'\');return false" title="play this sound">'+thisOptions.id+'</a>" ('+thisOptions.url+')',1);if(self._idCheck(thisOptions.id,true)){self._writeDebug('sound '+thisOptions.id+' already defined - exiting',2);return self.sounds[thisOptions.id];}
self.sounds[thisOptions.id]=new SMSound(self,thisOptions);self.soundIDs[self.soundIDs.length]=thisOptions.id;try{self.o._createSound(thisOptions.id,thisOptions.onjustbeforefinishtime);}catch(e){self._failSafely();return true;}
if(thisOptions.autoLoad||thisOptions.autoPlay)self.sounds[thisOptions.id].load(thisOptions);if(thisOptions.autoPlay)self.sounds[thisOptions.id].playState=1;return self.sounds[thisOptions.id];}
this.destroySound=function(sID){if(!self._idCheck(sID))return false;for(var i=0;i<self.soundIDs.length;i++){if(self.soundIDs[i]==sID){self.soundIDs.splice(i,1);continue;}}
self.sounds[sID].unload();delete self.sounds[sID];}
this.load=function(sID,oOptions){if(!self._idCheck(sID))return false;self.sounds[sID].load(oOptions);}
this.unload=function(sID){if(!self._idCheck(sID))return false;self.sounds[sID].unload();}
this.play=function(sID,oOptions){if(!self._idCheck(sID)){if(typeof oOptions!='Object')oOptions={url:oOptions};if(oOptions&&oOptions.url){self._writeDebug('soundController.play(): attempting to create "'+sID+'"',1);oOptions.id=sID;self.createSound(oOptions);}else{return false;}}
self.sounds[sID].play(oOptions);}
this.start=this.play;this.setPosition=function(sID,nMsecOffset){if(!self._idCheck(sID))return false;self.sounds[sID].setPosition(nMsecOffset);}
this.stop=function(sID){if(!self._idCheck(sID))return false;self._writeDebug('soundManager.stop('+sID+')',1);self.sounds[sID].stop();}
this.stopAll=function(){self._writeDebug('soundManager.stopAll()',1);for(var oSound in self.sounds){if(self.sounds[oSound]instanceof SMSound)self.sounds[oSound].stop();}}
this.pause=function(sID){if(!self._idCheck(sID))return false;self.sounds[sID].pause();}
this.resume=function(sID){if(!self._idCheck(sID))return false;self.sounds[sID].resume();}
this.togglePause=function(sID){if(!self._idCheck(sID))return false;self.sounds[sID].togglePause();}
this.setPan=function(sID,nPan){if(!self._idCheck(sID))return false;self.sounds[sID].setPan(nPan);}
this.setVolume=function(sID,nVol){if(!self._idCheck(sID))return false;self.sounds[sID].setVolume(nVol);}
this.setPolling=function(bPolling){if(!self.o||!self.allowPolling)return false;self._writeDebug('soundManager.setPolling('+bPolling+')');self.o._setPolling(bPolling);}
this.disable=function(){if(self._disabled)return false;self._disabled=true;self._writeDebug('soundManager.disable(): Disabling all functions - future calls will return false.',1);for(var i=self.soundIDs.length;i--;){self._disableObject(self.sounds[self.soundIDs[i]]);}
self.initComplete();self._disableObject(self);}
this.getSoundById=function(sID,suppressDebug){if(!sID)throw new Error('SoundManager.getSoundById(): sID is null/undefined');var result=self.sounds[sID];if(!result&&!suppressDebug){self._writeDebug('"'+sID+'" is an invalid sound ID.',2);}
return result;}
this.onload=function(){soundManager._writeDebug('<em>Warning</em>: soundManager.onload() is undefined.',2);}
this.onerror=function(){}
this._idCheck=this.getSoundById;this._disableObject=function(o){for(var oProp in o){if(typeof o[oProp]=='function'&&typeof o[oProp]._protected=='undefined')o[oProp]=function(){return false;}}
oProp=null;}
this._failSafely=function(){var flashCPLink='http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html';var fpgssTitle='You may need to whitelist this location/domain eg. file:///C:/ or C:/ or mysite.com, or set ALWAYS ALLOW under the Flash Player Global Security Settings page. Note that this seems to apply only to file system viewing.';var flashCPL='<a href="'+flashCPLink+'" title="'+fpgssTitle+'">view/edit</a>';var FPGSS='<a href="'+flashCPLink+'" title="Flash Player Global Security Settings">FPGSS</a>';if(!self._disabled){self._writeDebug('soundManager: JS-&gt;Flash communication failed. Possible causes: flash/browser security restrictions ('+flashCPL+'), insufficient browser/plugin support, or .swf not found',2);self._writeDebug('Verify that the movie path of <em>'+self.url+'</em> is correct (<a href="'+self.url+'" title="If you get a 404/not found, fix it!">test link</a>)',1);if(self._didAppend){if(!document.domain){self._writeDebug('Loading from local file system? (document.domain appears to be null, this URL path may need to be added to \'trusted locations\' in '+FPGSS+')',1);self._writeDebug('Possible security/domain restrictions ('+flashCPL+'), should work when served by http on same domain',1);}}
self.disable();}}
this._createMovie=function(smID,smURL){if(self._didAppend&&self._appendSuccess)return false;if(window.location.href.indexOf('debug=1')+1)self.debugMode=true;self._didAppend=true;var html=['<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="16" height="16" id="'+smID+'"><param name="movie" value="'+smURL+'"><param name="quality" value="high"><param name="allowScriptAccess" value="always" /></object>','<embed name="'+smID+'-embed" id="'+smID+'-embed" src="'+smURL+'" width="1" height="1" quality="high" allowScriptAccess="always" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>'];var toggleElement='<div id="'+self.debugID+'-toggle" style="position:fixed;_position:absolute;right:0px;bottom:0px;_top:0px;width:1.2em;height:1.2em;line-height:1.2em;margin:2px;padding:0px;text-align:center;border:1px solid #999;cursor:pointer;background:#fff;color:#333;z-index:706" title="Toggle SM2 debug console" onclick="soundManager._toggleDebug()">-</div>';var debugHTML='<div id="'+self.debugID+'" style="display:'+(self.debugMode&&((!self._hasConsole||!self.useConsole)||(self.useConsole&&self._hasConsole&&!self.consoleOnly))?'block':'none')+';opacity:0.85"></div>';var appXHTML='soundManager._createMovie(): appendChild/innerHTML set failed. Serving application/xhtml+xml MIME type? Browser may be enforcing strict rules, not allowing write to innerHTML. (PS: If so, this means your commitment to XML validation is going to break stuff now, because this part isn\'t finished yet. ;))';var sHTML='<div style="position:absolute;left:-256px;top:-256px;width:1px;height:1px" class="movieContainer">'+html[self.isIE?0:1]+'</div>'+(self.debugMode&&((!self._hasConsole||!self.useConsole)||(self.useConsole&&self._hasConsole&&!self.consoleOnly))&&!document.getElementById(self.debugID)?'x'+debugHTML+toggleElement:'');var oTarget=(document.body?document.body:document.getElementsByTagName('div')[0]);if(oTarget){self.oMC=document.createElement('div');self.oMC.className='movieContainer';self.oMC.style.position='absolute';self.oMC.style.left='-256px';self.oMC.style.width='1px';self.oMC.style.height='1px';try{oTarget.appendChild(self.oMC);self.oMC.innerHTML=html[self.isIE?0:1];self._appendSuccess=true;}catch(e){throw new Error(appXHTML);}
if(!document.getElementById(self.debugID)&&((!self._hasConsole||!self.useConsole)||(self.useConsole&&self._hasConsole&&!self.consoleOnly))){var oDebug=document.createElement('div');oDebug.id=self.debugID;oDebug.style.display=(self.debugMode?'block':'none');if(self.debugMode){try{var oD=document.createElement('div');oTarget.appendChild(oD);oD.innerHTML=toggleElement;}catch(e){throw new Error(appXHTML);}}
oTarget.appendChild(oDebug);}
oTarget=null;}
self._writeDebug('-- SoundManager 2 Version '+self.version.substr(1)+' --',1);self._writeDebug('soundManager._createMovie(): trying to load <a href="'+smURL+'" title="Test this link (404=bad)">'+smURL+'</a>',1);}
this._writeDebug=function(sText,sType){if(!self.debugMode)return false;if(self._hasConsole&&self.useConsole){console[self._debugLevels[sType]||'log'](sText);if(self.useConsoleOnly)return true;}
var sDID='soundmanager-debug';try{var o=document.getElementById(sDID);if(!o)return false;var p=document.createElement('div');sText=sText.replace(/\n/g,'<br />');p.innerHTML=sText;o.insertBefore(p,o.firstChild);}catch(e){}
o=null;}
this._writeDebug._protected=true;this._writeDebugAlert=function(sText){alert(sText);}
if(window.location.href.indexOf('debug=alert')+1&&self.debugMode){self._writeDebug=self._writeDebugAlert;}
this._toggleDebug=function(){var o=document.getElementById(self.debugID);var oT=document.getElementById(self.debugID+'-toggle');if(!o)return false;if(self._debugOpen){oT.innerHTML='+';o.style.display='none';}else{oT.innerHTML='-';o.style.display='block';}
self._debugOpen=!self._debugOpen;}
this._toggleDebug._protected=true;this._debug=function(){self._writeDebug('soundManager._debug(): sounds by id/url:',0);for(var i=0,j=self.soundIDs.length;i<j;i++){self._writeDebug(self.sounds[self.soundIDs[i]].sID+' | '+self.sounds[self.soundIDs[i]].url,0);}}
this._mergeObjects=function(oMain,oAdd){var o1=oMain;var o2=(typeof oAdd=='undefined'?self.defaultOptions:oAdd);for(var o in o2){if(typeof o1[o]=='undefined')o1[o]=o2[o];}
return o1;}
this.createMovie=function(sURL){if(sURL)self.url=sURL;self._initMovie();}
this._initMovie=function(){if(self.o)return false;self.o=self.getMovie(self.id);if(!self.o){self._createMovie(self.id,self.url);self.o=self.getMovie(self.id);}
if(self.o){self._writeDebug('soundManager._initMovie(): Got '+self.o.nodeName+' element ('+(self._didAppend?'created via JS':'static HTML')+')',1);}}
this.initComplete=function(){if(self._didInit)return false;self._didInit=true;self._writeDebug('-- SoundManager 2 '+(self._disabled?'failed to load':'loaded')+' ('+(self._disabled?'security/load error':'OK')+') --',1);if(self._disabled){self._writeDebug('soundManager.initComplete(): calling soundManager.onerror()',1);self.onerror.apply(window);return false;}
self._writeDebug('soundManager.initComplete(): calling soundManager.onload()',1);try{self.onload.apply(window);}catch(e){self._writeDebug('soundManager.onload() threw an exception: '+e.message,2);throw e;}
self._writeDebug('soundManager.onload() complete',1);}
this.init=function(){if(window.removeEventListener){window.removeEventListener('load',self.beginInit,false);}else if(window.detachEvent){window.detachEvent('onload',self.beginInit);}
try{self.o._externalInterfaceTest();self._writeDebug('Flash ExternalInterface call (JS -&gt; Flash) succeeded.',1);if(!self.allowPolling)self._writeDebug('Polling (whileloading/whileplaying support) is disabled.',1);self.setPolling(true);self.enabled=true;}catch(e){self._failSafely();self.initComplete();return false;}
self.initComplete();}
this.beginDelayedInit=function(){setTimeout(self.beginInit,200);}
this.beginInit=function(){self.createMovie();self._initMovie();setTimeout(self.init,1000);}
this.destruct=function(){self._writeDebug('soundManager.destruct()');if(self.isSafari){for(var i=self.soundIDs.length;i--;){if(self.sounds[self.soundIDs[i]].readyState==1)self.sounds[self.soundIDs[i]].unload();}}
self.disable();}
function SMSound(oSM,oOptions){var self=this;var sm=oSM;this.sID=oOptions.id;this.url=oOptions.url;this.options=sm._mergeObjects(oOptions);if(sm.debugMode){var stuff=null;var msg=[];var sF=null;var sfBracket=null;var maxLength=64;for(stuff in this.options){if(this.options[stuff]!=null){if(this.options[stuff]instanceof Function){sF=this.options[stuff].toString();sF=sF.replace(/\s\s+/g,' ');sfBracket=sF.indexOf('{');msg[msg.length]=' '+stuff+': {'+sF.substr(sfBracket+1,(Math.min(Math.max(sF.indexOf('\n')-1,maxLength),maxLength))).replace(/\n/g,'')+'... }';}else{msg[msg.length]=' '+stuff+': '+this.options[stuff];}}}
sm._writeDebug('SMSound() merged options: {\n'+msg.join(', \n')+'\n}');}
this.id3={}
self.resetProperties=function(bLoaded){self.bytesLoaded=null;self.bytesTotal=null;self.position=null;self.duration=null;self.durationEstimate=null;self.loaded=false;self.loadSuccess=null;self.playState=0;self.paused=false;self.readyState=0;self.didBeforeFinish=false;self.didJustBeforeFinish=false;}
self.resetProperties();this.load=function(oOptions){self.loaded=false;self.loadSuccess=null;self.readyState=1;self.playState=(oOptions.autoPlay||false);var thisOptions=sm._mergeObjects(oOptions);if(typeof thisOptions.url=='undefined')thisOptions.url=self.url;try{sm._writeDebug('loading '+thisOptions.url,1);sm.o._load(self.sID,thisOptions.url,thisOptions.stream,thisOptions.autoPlay,thisOptions.whileloading?1:0);}catch(e){sm._writeDebug('SMSound().load(): JS-&gt;Flash communication failed.',2);}}
this.unload=function(){sm._writeDebug('SMSound().unload(): "'+self.sID+'"');self.setPosition(0);sm.o._unload(self.sID,sm.nullURL);self.resetProperties();}
this.play=function(oOptions){if(!oOptions)oOptions={};if(oOptions.onfinish)self.options.onfinish=oOptions.onfinish;if(oOptions.onbeforefinish)self.options.onbeforefinish=oOptions.onbeforefinish;if(oOptions.onjustbeforefinish)self.options.onjustbeforefinish=oOptions.onjustbeforefinish;var thisOptions=sm._mergeObjects(oOptions,self.options);thisOptions=sm._mergeObjects(thisOptions);if(self.playState==1){var allowMulti=thisOptions.multiShot;if(!allowMulti){sm._writeDebug('SMSound.play(): "'+self.sID+'" already playing? (one-shot)',1);return false;}else{sm._writeDebug('SMSound.play(): "'+self.sID+'" already playing (multi-shot)',1);}}
if(!self.loaded){if(self.readyState==0){sm._writeDebug('SMSound.play(): .play() before load request. Attempting to load "'+self.sID+'"',1);thisOptions.stream=true;thisOptions.autoPlay=true;self.load(thisOptions);}else if(self.readyState==2){sm._writeDebug('SMSound.play(): Could not load "'+self.sID+'" - exiting',2);return false;}else{sm._writeDebug('SMSound.play(): "'+self.sID+'" is loading - attempting to play..',1);}}else{sm._writeDebug('SMSound.play(): "'+self.sID+'"');}
if(self.paused){self.resume();}else{self.playState=1;self.position=(typeof thisOptions.position!='undefined'&&!isNaN(thisOptions.position)?thisOptions.position/1000:0);if(thisOptions.onplay)thisOptions.onplay.apply(self);self.setVolume(thisOptions.volume);self.setPan(thisOptions.pan);if(!thisOptions.autoPlay){sm.o._start(self.sID,thisOptions.loop||1,self.position);}}}
this.start=this.play;this.stop=function(bAll){if(self.playState==1){self.playState=0;self.paused=false;if(self.options.onstop)self.options.onstop.apply(self);sm.o._stop(self.sID);}}
this.setPosition=function(nMsecOffset){self.options.position=nMsecOffset;sm.o._setPosition(self.sID,nMsecOffset/1000,self.paused||!self.playState);}
this.pause=function(){if(self.paused)return false;sm._writeDebug('SMSound.pause()');self.paused=true;sm.o._pause(self.sID);}
this.resume=function(){if(!self.paused)return false;sm._writeDebug('SMSound.resume()');self.paused=false;sm.o._pause(self.sID);}
this.togglePause=function(){sm._writeDebug('SMSound.togglePause()');if(!self.playState){self.play({position:self.position/1000});return false;}
if(self.paused){sm._writeDebug('SMSound.togglePause(): resuming..');self.resume();}else{sm._writeDebug('SMSound.togglePause(): pausing..');self.pause();}}
this.setPan=function(nPan){if(typeof nPan=='undefined')nPan=0;sm.o._setPan(self.sID,nPan);self.options.pan=nPan;}
this.setVolume=function(nVol){if(typeof nVol=='undefined')nVol=100;sm.o._setVolume(self.sID,nVol);self.options.volume=nVol;}
this._whileloading=function(nBytesLoaded,nBytesTotal,nDuration){self.bytesLoaded=nBytesLoaded;self.bytesTotal=nBytesTotal;self.duration=nDuration;self.durationEstimate=parseInt((self.bytesTotal/self.bytesLoaded)*self.duration);if(self.readyState!=3&&self.options.whileloading)self.options.whileloading.apply(self);}
this._onid3=function(oID3PropNames,oID3Data){sm._writeDebug('SMSound()._onid3(): "'+this.sID+'" ID3 data received.');var oData=[];for(var i=0,j=oID3PropNames.length;i<j;i++){oData[oID3PropNames[i]]=oID3Data[i];}
self.id3=sm._mergeObjects(self.id3,oData);if(self.options.onid3)self.options.onid3.apply(self);}
this._whileplaying=function(nPosition){if(isNaN(nPosition)||nPosition==null)return false;self.position=nPosition;if(self.playState==1){if(self.options.whileplaying)self.options.whileplaying.apply(self);if(self.loaded&&self.options.onbeforefinish&&self.options.onbeforefinishtime&&!self.didBeforeFinish&&self.duration-self.position<=self.options.onbeforefinishtime){sm._writeDebug('duration-position &lt;= onbeforefinishtime: '+self.duration+' - '+self.position+' &lt= '+self.options.onbeforefinishtime+' ('+(self.duration-self.position)+')');self._onbeforefinish();}}}
this._onload=function(bSuccess){bSuccess=(bSuccess==1?true:false);sm._writeDebug('SMSound._onload(): "'+self.sID+'"'+(bSuccess?' loaded.':' failed to load (or loaded from cache - weird bug) - [<a href="'+self.url+'">test URL</a>]'));self.loaded=bSuccess;self.loadSuccess=bSuccess;self.readyState=bSuccess?3:2;if(self.options.onload)self.options.onload.apply(self);}
this._onbeforefinish=function(){if(!self.didBeforeFinish){self.didBeforeFinish=true;if(self.options.onbeforefinish)self.options.onbeforefinish.apply(self);}}
this._onjustbeforefinish=function(msOffset){if(!self.didJustBeforeFinish){self.didJustBeforeFinish=true;if(self.options.onjustbeforefinish)self.options.onjustbeforefinish.apply(self);;}}
this._onfinish=function(){sm._writeDebug('SMSound._onfinish(): "'+self.sID+'"');self.playState=0;self.paused=false;if(self.options.onfinish)self.options.onfinish.apply(self);if(self.options.onbeforefinishcomplete)self.options.onbeforefinishcomplete.apply(self);self.setPosition(0);self.didBeforeFinish=false;self.didJustBeforeFinish=false;}}}
var soundManager=new SoundManager();if(window.addEventListener){window.addEventListener('load',soundManager.beginDelayedInit,false);window.addEventListener('beforeunload',soundManager.destruct,false);}else if(window.attachEvent){window.attachEvent('onload',soundManager.beginInit);window.attachEvent('beforeunload',soundManager.destruct);}else{soundManager.onerror();soundManager.disable();}Gixaw.namespace('Gixaw.Media');soundManager.url=Gixaw.Router.getAssetUrl('core/js/gixaw/src/media/soundmanager2.swf');soundManager.debugMode=false;soundManager.consoleOnly=false;soundManager.onload=function(){}
Gixaw.Media=function(){return{playSound:function(name){try{soundManager.play(name,Gixaw.Router.getAssetUrl(name));}
catch(ex){}}}}();Gixaw.namespace('Gixaw.Messenger.Base');Gixaw.Messenger.Base=new Class({Implements:[Options,Events],options:{},initialize:function(options){this.setOptions(options);this.prepare(options);this._messages=[];},onPrepare:function(){},afterPrepare:function(){},prepare:function(options){this._options=options||{};this.onPrepare();this.fireEvent('onPrepare');this.afterPrepare();},onConnect:function(){},afterConnect:function(){},connect:function(token,userId){this._token=token;this._userId=userId;this.onConnect();this.fireEvent('onConnect');this.afterConnect();},onDisconnect:function(){},afterDisconnect:function(){},disconnect:function(){this.onDisconnect();this.fireEvent('onDisconnect');this.afterDisconnect();},onSend:function(type,args,force){},afterSend:function(type,args,force){},send:function(type,args,force){args=args||{};force=force||false;this._messages.push({type:type,args:args,force:force});this.onSend(type,args,force);this.fireEvent('onSend',[type,args,force]);this.afterSend(type,args,force);},post:function(type,args,force){this.send.apply(this,arguments);},isConnected:function(){return false;}});Gixaw.namespace('Gixaw.Messenger.Ajax');Gixaw.Messenger.Ajax=new Class({Extends:Gixaw.Messenger.Base,Implements:[Options,Events],options:{url:null,delay:{avg:Gixaw.Config.get('site.client_to_server_delay_avg'),min:Gixaw.Config.get('site.client_to_server_delay_min'),max:Gixaw.Config.get('site.client_to_server_delay_max')},timeout:Gixaw.Config.get('site.ajax_request_timeout')},onPrepare:function(){this._lastId=null;this._messages=[];this._sentMessages=[];this._countdown=0;this._force=false;this._timeout=false;this._timeoutTimer=this.options.timeout;this._request=null;this._loop=null;},onConnect:function(){this._loop=setInterval(this.loop.bind(this),1000);},onDisconnect:function(){this.cancel();if(this._loop)clearInterval(this._loop);this._loop=null;},onSend:function(type,args,force){if(force){if(!this.isConnected()&&(this._countdown>this.options.delay.min)){this._countdown=this.options.delay.min;}
else{this._force=true;}}},isConnected:function(){return!!this._request;},getCountDown:function(){return this._countdown;},callTimeout:function(){this._timeout=false;this._timeoutTimer=this.options.timeout;this._countdown=this.options.delay.max;this.cancel();this.onFailure();},onComplete:function(){if(this._force){this._countdown=this.options.delay.min;this._force=false;}else{this._countdown=this.options.delay.avg;}
if(this._timeout){this._timeout=false;this._timeoutTimer=this.options.timeout;}},onSuccess:function(response){this.fireEvent('onSuccess');this._lastId=response.last_id||null;this._sentMessages=[];var messages=response.messages||[];messages.each(function(message){this.fireEvent('onMessage',message);}.bind(this));this._request=null;},onFailure:function(xhr){this.fireEvent('onFailure');this._messages=this._sentMessages.filter(function(item,index){if(item.force){return item;}}).extend(this._messages);this._sentMessages.each(function(message){this.fireEvent('onFailedMessage',message);}.bind(this));this._sentMessages=[];this._request=null;},loop:function(){this._countdown--;if(this._timeout){this._timeoutTimer--;if(this._timeoutTimer<=0){this.callTimeout();}}
if(this._countdown<=0){this.poll();}},poll:function(){if(this.isConnected()){return;}
var messages=this._messages;this._sentMessages=this._messages;this._messages=[];this._request=new Request.JSON({url:this.options.url.replace('{version}',new Date().getTime()),onComplete:this.onComplete.bind(this),onSuccess:this.onSuccess.bind(this),onFailure:this.onFailure.bind(this)}).POST({'token':this._token,'last_id':$unlink(this._lastId),'messages':JSON.encode($unlink(messages))});this._timeout=true;},cancel:function(){if(this._request){this._request.cancel();this._request=null;}
if(this._timeout){this._timeout=false;this._timeoutTimer=this.options.timeout;}},unload:function(){this.disconnect();this.poll();}});Gixaw.namespace('Gixaw.Chat.Login');Gixaw.namespace('Gixaw.Chat.Desktop');Gixaw.namespace('Gixaw.Chat.Desktop.Home');Gixaw.namespace('Gixaw.Chat.Desktop.Controls');Gixaw.Chat.Desktop=new Class({Extends:Gixaw.UI.Widget,options:{className:'gixaw-chat-desktop',autoStart:false},templates:{'surface':'','header':'<div class="info"><div class="display_name"></div><span class="status">${status}</span></div><div class="display_picture"><img src="${display}" class="display_picture" title="'+Gixaw.Language.getString('site.text.change_your_display')+'" /></div>'},onPrepare:function(){this.parent();this._conversations=new Hash();this._users=new Hash();this.idToKeyMap=new Hash();this.status='site.status.default';this.title=document.title;this.connected=false;this.sounds=((this.preferences!=null)&&(this.preferences['sounds']!=null))?this.preferences['sounds']:true;this.rooms=Gixaw.Config.get("rooms")||null;this.integrated=Gixaw.Config.get("core.use_integration");this.messenger=null;Gixaw.Hooks.fireEvent('Gixaw.Chat.Desktop.messenger',[$lambda(this)]);if(!this.messenger){this.messenger=new Gixaw.Messenger.Ajax({'url':Gixaw.Config.get('site.server_url'),'onFailure':this.showConnectionProblem.bind(this),'onSuccess':this.hideConnectionProblem.bind(this)});}
this.messenger.addEvent('onMessage',this.onMessage.bind(this));this.messenger.addEvent('onFailedMessage',this.onFailedMessage.bind(this));this.messenger.addEvent('onConnect',this.onConnect.bind(this));if(this.options.autoStart)this.start();window.onbeforeunload=function(e){e=window.event?window.event:e;if(this.connected){return Gixaw.Language.getString('site.text.self_logout');}}.bind(this);window.onunload=function(){if(this.connected){this.connected=false;if(this._notice)this._notice.dispose();this._notice=new Gixaw.UI.Notice({parentEl:$(document.body),text:Gixaw.Language.getString('site.text.signing_out'),iconImg:"site/img/icons/stop.png"});this.messenger.disconnect();this.disconnectRequeest=new Request({method:'get',url:Gixaw.Router.generate('site/disconnect',{t:Gixaw.Config.get('site.t')})});this.disconnectRequeest.send();}}.bind(this);this.unreadMessages=0;$(document).addEvents({'focus':function(){this.onActivity();}.bind(this),'mousemove':function(){this.onActivity();}.bind(this),'keypress':function(){this.onActivity();}.bind(this)});},onRender:function(){this.parent();this.headerPanel=new Gixaw.UI.Panel({className:'gixaw-ui-panel-header',layout:'border',html:Gixaw.format(this.templates['header'],{display:Gixaw.Router.getAssetUrl("site/img/chat/unknown_small.png"),status:"("+this.getStatus()+")"})});this.controls=new Gixaw.Chat.Desktop.Controls({'desktop':$lambda(this)});this._headerLayout=new Gixaw.UI.Container({layout:'border',items:[{direction:'center',widget:this.headerPanel},{direction:'west',widget:this.controls,initialSize:300}]});this.home=new Gixaw.Chat.Desktop.Home({'desktop':$lambda(this)});this.tabs=new Gixaw.UI.TabView({'onRemove':function(item){var result=this._conversations.filter(function(value){return value.tabId==item.id;},this);var key=result.getKeys().shift();var value=result[key];delete this._conversations[key];delete this.idToKeyMap[value.conversationId];}.bind(this),items:[{id:"first-tab",className:"first-tab",title:"",widget:this.home,iconImg:'site/img/icons/home.png'},{id:"last-tab",className:"last-tab",title:"",widget:this.home,fn:this.roomMenu.bind(this),iconImg:'site/img/icons/plus.png'}]});this._layoutWg=new Gixaw.UI.Container({layout:'border',parentEl:this._surfaceEl,size:{x:800,y:600},items:[{direction:'north',widget:this._headerLayout,initialSize:45},{direction:'center',widget:this.tabs}]});this._infoEl=this.headerPanel._surfaceEl.getElement('.info');this._displayPictureEl=this.headerPanel._surfaceEl.getElement('img.display_picture');this._infoDisplayNameEl=this._infoEl.getElement('.display_name');this._infoStatusEl=this._infoEl.getElement('.status');this._infoDisplayNameEl.addEvent('mouseenter',function(){this._infoDisplayNameEl.addClass('display_name-hover');}.bind(this));this._infoDisplayNameEl.addEvent('mouseleave',function(){this._infoDisplayNameEl.removeClass('display_name-hover');}.bind(this));this._infoStatusEl.addEvent('mouseenter',function(){this._infoStatusEl.addClass('status-hover');}.bind(this));this._infoStatusEl.addEvent('mouseleave',function(){this._infoStatusEl.removeClass('status-hover');}.bind(this));this._infoDisplayNameEl.addEvent('click',function(event){if(!this.integrated&&!this.guest){this.editProfile();}}.bind(this));if(!this.integrated&&!this.guest){this._displayPictureEl.addEvents({'click':function(event){this.changeDisplay()}.bindWithEvent(this)});}
this._infoStatusEl.addEvent('click',function(event){var statusMenu=new Gixaw.UI.Popup({parentEl:$(document.body),position:{x:event.page.x,y:event.page.y}});statusMenu.add({title:Gixaw.Language.getString('site.status.online'),iconImg:"site/img/icons/user.png",fn:function(){this.sendMessage('change_status',{status:'site.status.online'});}.bind(this)});statusMenu.add({title:Gixaw.Language.getString('site.status.away'),iconImg:"site/img/icons/away.png",fn:function(){this.sendMessage('change_status',{status:'site.status.away'});}.bind(this)});statusMenu.add({title:Gixaw.Language.getString('site.status.busy'),iconImg:"site/img/icons/busy.png",fn:function(){this.sendMessage('change_status',{status:'site.status.busy'});}.bind(this)});statusMenu.add({title:Gixaw.Language.getString('site.status.brb'),iconImg:"site/img/icons/away.png",fn:function(){this.sendMessage('change_status',{status:'site.status.brb'});}.bind(this)});statusMenu.add({title:Gixaw.Language.getString('site.status.signout'),seperator:true,iconImg:"site/img/icons/offline.png",fn:function(){try{window.location=Gixaw.Router.generate('site/logout',{t:Gixaw.Config.get('site.t')});}catch(err){}}.bind(this)});event.stop();}.bindWithEvent(this));},afterRender:function(){this.parent();if(!Gixaw.Config.get('site.logged_in')){this._login=new Gixaw.Chat.Login({parentEl:$(document.body),'desktop':$lambda(this)});}else{this.start();}
this.rooms.each(function(room){if(room.auto_join){if(room.protected_flag==1){if(this._conversations[room.conversation_id]){this.tabs.activate(this._conversations[room.conversation_id].tabId);return false;}
if(this._roomPassword)this._roomPassword.dispose();this._roomPassword=new Gixaw.UI.Dialog({parentEl:$(document.body),title:Gixaw.Language.getString('site.text.password_verification'),url:Gixaw.Router.generate('site/room_password'),iconImg:'site/img/icons/lock.png',size:{x:300,y:170},autoSubmit:false,onOK:function(dialog){var password=dialog.getField('room_password')||null;this.newConversation({title:room.name,topic:room.topic,conversationId:room.conversation_id,mode:'room',emoticons:room.allow_emoticons,font_styles:room.allow_font_styles,word_filters:room.allow_word_filters,protected:true,password:password},true);}.bind(this),onClose:function(){this._roomPassword=null;}.bind(this)});}else{this.newConversation({title:room.name,topic:room.topic,conversationId:room.conversation_id,mode:'room',emoticons:room.allow_emoticons,font_styles:room.allow_font_styles,word_filters:room.allow_word_filters},true);}}}.bind(this));},onLayout:function(){this.parent();this.tabs.getItemById('last-tab').tabEl.addEvents({'mouseenter':function(event){if(this._controlTooltip)this._controlTooltip.dispose();this._controlTooltip=new Gixaw.UI.Popup({className:'gixaw-ui-tooltip',parentEl:$(document.body),position:{x:event.page.x+10,y:event.page.y+15},caption:Gixaw.Language.getString('site.text.rooms')});}.bindWithEvent(this),'mouseleave':function(event){if(this._controlTooltip)this._controlTooltip.dispose();}.bindWithEvent(this)});document.getElementById("load-wait").style.display="none";this._layoutWg.setSize(this._surfaceEl.getInnerSize());if(this._login){this._login.setSize(this._surfaceEl.getInnerSize());}
if(this._notice){this._notice.setSize(this._surfaceEl.getInnerSize());}},roomMenu:function(options){if(this._controlMenu)this._controlMenu.dispose();this._controlMenu=new Gixaw.UI.Popup({className:'gixaw-ui-popup gixaw-chat-roomlist',caption:Gixaw.Language.getString('site.text.rooms')+" ("+this.rooms.length+")",parentEl:$(document.body),position:{x:options.x,y:options.y}});this.rooms.each(function(item){this._controlMenu.add({title:item.name,iconImg:(item.protected_flag)?'site/img/icons/lock.png':'site/img/icons/people.png',fn:function(){if(item.protected_flag==1){if(this._conversations[item.conversation_id]){this.tabs.activate(this._conversations[item.conversation_id].tabId);return false;}
if(this._roomPassword)this._roomPassword.dispose();this._roomPassword=new Gixaw.UI.Dialog({parentEl:$(document.body),title:Gixaw.Language.getString('site.text.password_verification'),url:Gixaw.Router.generate('site/room_password'),iconImg:'site/img/icons/lock.png',size:{x:300,y:170},autoSubmit:false,onOK:function(dialog){var password=dialog.getField('room_password')||null;this.newConversation({title:item.name,topic:item.topic,conversationId:item.conversation_id,mode:'room',emoticons:item.allow_emoticons,font_styles:item.allow_font_styles,word_filters:item.allow_word_filters,protected:true,password:password},true);}.bind(this),onClose:function(){this._roomPassword=null;}.bind(this)});}else{this.newConversation({title:item.name,topic:item.topic,conversationId:item.conversation_id,mode:'room',emoticons:item.allow_emoticons,font_styles:item.allow_font_styles,word_filters:item.allow_word_filters},true);}}.bind(this)})}.bind(this));},accountMenu:function(options){if(this._controlMenu)this._controlMenu.dispose();this._controlMenu=new Gixaw.UI.Popup({caption:Gixaw.Language.getString('site.text.membership'),parentEl:$(document.body),position:{x:options.x,y:options.y}});if(!this.integrated){if(!this.guest){this._controlMenu.add({title:Gixaw.Language.getString('site.text.my_account'),iconImg:"site/img/icons/account_icon.png",fn:function(){this.userAccount();}.bind(this)});this._controlMenu.add({title:Gixaw.Language.getString('site.text.edit_profile'),iconImg:"site/img/icons/profile_icon.png",fn:function(){this.editProfile();}.bind(this)});this._controlMenu.add({title:Gixaw.Language.getString('site.text.change_display'),iconImg:"site/img/icons/photo.png",fn:function(){this.changeDisplay();}.bind(this)});this._controlMenu.add({title:Gixaw.Language.getString('site.icon.preferences'),iconImg:'site/img/icons/preferences.png',fn:function(){this.changePreferences();}.bind(this)});}else{if(Gixaw.Config.get('loginMember')){this._controlMenu.add({title:Gixaw.Language.getString('site.icon.signup'),iconImg:"site/img/icons/add.png",fn:function(){window.location=Gixaw.Router.generate('site/signup');}.bind(this)});}}}},adminMenu:function(options){if(this._controlMenu)this._controlMenu.dispose();this._controlMenu=new Gixaw.UI.Popup({caption:Gixaw.Language.getString('site.text.administration'),parentEl:$(document.body),position:{x:options.x,y:options.y}});this._controlMenu.add({title:Gixaw.Language.getString('site.text.control_panel'),iconImg:"site/img/icons/admin.png",fn:function(){window.open(Gixaw.Router.generate('admin/index'),'_blank');}.bind(this)});Gixaw.Hooks.fireEvent('Gixaw.Chat.Desktop.AdminMenu',[this._controlMenu]);},start:function(){if(!this.isReady()){return this.runWhenReady(arguments.callee,$A(arguments));}
this.userId=Gixaw.Config.get('site.user_id');this.groupId=Gixaw.Config.get('site.group_id');this.preferences=Gixaw.Config.get("core.user_preferences");this.displayName=Gixaw.Config.get('site.display_name');this.admin=Gixaw.Config.get('core.is_admin');this.guest=Gixaw.Config.get('site.is_guest');this._displayPictureEl.src=Gixaw.Config.get("site.user_display_picture")?Gixaw.Config.get("site.user_display_picture"):Gixaw.Router.getAssetUrl("site/img/chat/unknown_small.png");this._infoDisplayNameEl.innerHTML=this.displayName;if(!this.integrated&&Gixaw.Config.get('loginMember')){this.controls.add({caption:Gixaw.Language.getString('site.text.my_account'),iconImg:'site/img/icons/profile.png',fn:this.accountMenu.bind(this)});}
this.controls.add({caption:Gixaw.Language.getString('site.icon.sounds'),id:"sounds",iconImg:(this.sounds)?'site/img/icons/sound.png':'site/img/icons/disable-sound.png',fn:function(){if(this.sounds){this.sendMessage('save_preference',{'preference':'sounds',value:false});this.sounds=false;this.controls.getItemById("sounds").itemEl.getElement('img').src=Gixaw.Router.getAssetUrl('site/img/icons/disable-sound.png');}else{this.sendMessage('save_preference',{'preference':'sounds',value:true});this.sounds=true;this.controls.getItemById("sounds").itemEl.getElement('img').src=Gixaw.Router.getAssetUrl('site/img/icons/sound.png');Gixaw.Media.playSound('core/media/ding.mp3');}}.bind(this)});Gixaw.Hooks.fireEvent('Gixaw.Chat.Desktop.icons',[$lambda(this)]);if(this.admin){if(Gixaw.Config.get('site.subscription'))this.controls.add({caption:Gixaw.Language.getString('site.text.subscription'),iconImg:'site/img/icons/card.png',fn:function(){window.open(Gixaw.Router.generate('admin/subscription'),'_blank');}.bind(this)});this.controls.add({caption:Gixaw.Language.getString('site.text.administration'),iconImg:'site/img/icons/config.png',fn:this.adminMenu.bind(this)});}
this.controls.add({caption:Gixaw.Language.getString('site.status.signout'),iconImg:'site/img/icons/logout.png',fn:function(){try{window.location=Gixaw.Router.generate('site/logout',{t:Gixaw.Config.get('site.t')});}catch(err){}}.bind(this)});this.messenger.connect(Gixaw.Config.get('site.user_status_token'),Gixaw.Config.get('site.user_id'));this.connected=true;if(this.tabs.getItemById(this.tabs._state.activeId).widget.typingArea)this.tabs.getItemById(this.tabs._state.activeId).widget.typingArea.focus();},onConnect:function(){},getStatus:function(){return Gixaw.Language.getString(this.status);},getUserId:function(){return this.userId;},getGroupId:function(){return this.groupId;},getDisplayName:function(){return this.displayName;},onFailedMessage:function(message){this.fireEvent('onFailedMessage',message);},onMessage:function(message){if(!this.connected)return false;switch(message.type){case'room_list':this.rooms=[];var rooms=message.args.rooms||[];rooms.each(function(room){this.rooms.push(room);},this);break;case'replace_conversation_id':var conversation=this._conversations[message.args.conversation_key];conversation.conversationId=message.conversation_id;this.tabs.getItemById(conversation.tabId).widget.setConversationId(message.conversation_id);this.idToKeyMap[message.conversation_id]=this.idToKeyMap[message.args.conversation_key];delete this.idToKeyMap[message.args.conversation_key];break;case'user_offline':var conversation=this._conversations[message.args.conversation_key];this.tabs.getItemById(conversation.tabId).widget.userOffline();break;case'change_status':if(message.user_id==this.getUserId()){this.status=message.args.status;if(this.status==null){this._infoEl.getElement('.status').set('text',"("+Gixaw.Language.getString('site.status.default')+")");}
else{this._infoEl.getElement('.status').set('text',"("+this.getStatus()+")");}}
break;case'update_display_name':if(this._users[message.user_id])this._users[message.user_id].displayName=message.args.new_display_name;if(message.user_id==this.getUserId()){this.headerPanel.getSurfaceEl().getElement('.display_name').innerHTML=message.args.new_display_name;this.displayName=message.args.new_display_name;}
break;case'change_topic':this.fireEvent('onRoomTopic',[message.conversation_id,message.args.topic]);break;case'text':if(!message.args.display_only){this.unreadMessages++;document.title="("+this.unreadMessages+") "+this.title;if(this.sounds)Gixaw.Media.playSound('site/media/beep.mp3');}
if(message.args.mode=='pair'){if(!this._conversations.has(message.args.conversation_key)){this.newConversation({title:message.args.display_name,user_id:message.user_id,conversationId:message.conversation_id,mode:'pair',font_styles:Gixaw.Config.get('private_messaging')['font_styles'].allow_font_styles,emoticons:Gixaw.Config.get('private_messaging')['emoticons'].allow_emoticons,word_filters:Gixaw.Config.get('private_messaging')['word_filters'].allow_word_filters},false);}
else{this.tabs.getItemById(this._conversations[message.args.conversation_key].tabId).widget.setConversationId(message.conversation_id);}}
break;case'invite_user':if(!this._conversations.has(message.args.conversation_key)){this.newConversation({title:Gixaw.Language.getString("site.text.group"),conversationId:message.conversation_id,mode:'group',font_styles:Gixaw.Config.get('private_messaging')['font_styles'].allow_font_styles,emoticons:Gixaw.Config.get('private_messaging')['emoticons'].allow_emoticons,word_filters:Gixaw.Config.get('private_messaging')['word_filters'].allow_word_filters,initialMessages:[{type:'invited','user_id':message.user_id,'display_name':message.args.display_name,'icon':'site/img/icons/add.png','text':Gixaw.Language.getFormattedString('site.messages.has_invited')}]},false);}else{this.tabs.getItemById(this._conversations[message.args.conversation_key].tabId).widget.setConversationId(message.conversation_id);}
break;case'user_list':var users=message.args.users;users.each(function(user){if(this._users[user.id]){this._users[user.id].conv_count+=1;}else{this._users[user.id]={displayName:user.display_name,conv_count:1};}},this);break;case'join':if(!message.args.display_only){if(this._users[message.user_id]){this._users[message.user_id].conv_count+=1;}else{this._users[message.user_id]={displayName:message.args.display_name,conv_count:1};}
if(this.sounds){Gixaw.Media.playSound('site/media/notify.mp3');}}
break;case'leave':if(!message.args.display_only){if(this._users[message.user_id]){this._users[message.user_id].conv_count-=1;if(this._users[message.user_id].conv_count==0){delete this._users[message.user_id];}}}
break;case'update_display_picture':if(message.user_id==this.getUserId()){this.headerPanel.getSurfaceEl().getElement('img.display_picture').src=message.args.thumb_location;}
break;case'disconnect':if(!message.args.display_only){if(this._users[message.user_id]){delete this._users[message.user_id];}
if(message.args.target_user_id==this.getUserId()){this.connected=false;if(this._notice)this._notice.dispose();this._notice=new Gixaw.UI.Notice({parentEl:$(document.body),text:Gixaw.Language.getString('site.text.session_expired'),iconImg:"site/img/icons/stop.png"});this.messenger.disconnect();}else{if(this._conversations[this.createKey([message.user_id,this.getUserId()])]){var conversation=this._conversations[this.createKey([message.user_id,this.getUserId()])];this.tabs.getItemById(conversation.tabId).widget.userOffline();}}}
break;case'quit':this.connected=false;if(this._notice)this._notice.dispose();this._notice=new Gixaw.UI.Notice({parentEl:$(document.body),text:Gixaw.Language.getString('site.text.session_expired'),iconImg:"site/img/icons/stop.png"});this.messenger.disconnect();break;}
this.fireEvent('onMessage',message);},postMessage:function(type,args){args=args||{};this.messenger.post(type,args);},sendMessage:function(type,args,force){args=args||{};this.messenger.send(type,args,force);},flushMessages:function(messages){if(messages.length==0)return;messages.each(function(message){this.postMessage(message[0],message[1]);},this);this.messenger.poll();},setConversationTitle:function(conversationKey,title,iconImg){var tabId=this._conversations[conversationKey].tabId;this.tabs.setTitle(tabId,title);if(iconImg)this.tabs.setIcon(tabId,iconImg);},newConversation:function(conversation,activate){var title=conversation.title;var conversationId=conversation.conversationId
var conversationKey=conversation.conversationId;var conversationMode=conversation.mode;var conversationTopic=conversation.topic;var conversationProtected=conversation.protected||false;var conversationPassword=conversation.password||null;var conversationEmoticons=conversation.emoticons||false;var conversationFontStyles=conversation.font_styles||false;var conversationWordFilters=conversation.word_filters||false;var initialMessages=conversation.initialMessages||[];if(conversation.mode=='pair'){conversationKey=this.createKey([conversation.user_id,this.getUserId()]);conversationId=conversationId||conversationKey;}
if(!this._conversations.has(conversationKey)){var conversationView=new Gixaw.Chat.ConversationView({desktop:$lambda(this),conversationId:conversationId,conversationKey:conversationKey,mode:conversationMode,topic:conversationTopic,initialMessages:initialMessages,protected:conversationProtected,password:conversationPassword,emoticons:conversationEmoticons,font_styles:conversationFontStyles,word_filters:conversationWordFilters});if(conversationMode=='pair'){conversationView.addUser(this.getUserId(),this.getDisplayName(),this.getStatus(),this.getGroupId());conversationView.addUser(conversation.user_id,title,conversation.status);iconImg='site/img/icons/user.png';}else{iconImg='site/img/icons/people.png';}
var tabItem=this.tabs.add({title:title,widget:conversationView,iconImg:iconImg,closable:true});this._conversations[conversationKey]={conversationId:conversationId,mode:conversationMode,tabId:tabItem.id};this.idToKeyMap[conversationId]=conversationKey;}
if(activate){this.tabs.activate(this._conversations[conversationKey].tabId);}else{this.tabs.flashTab(this._conversations[conversationKey].tabId);}},switchMode:function(conversationId,conversationKey,conversationMode,conversationUsers){var tabId=this._conversations[this.idToKeyMap[conversationId]].tabId;delete this._conversations[this.idToKeyMap[conversationId]];this._conversations[conversationKey]={conversationId:conversationId,mode:conversationMode,tabId:tabId};this.idToKeyMap[conversationId]=conversationKey;if(conversationMode=='group'){this.setConversationTitle(conversationKey,Gixaw.Language.getString('site.text.group'),'site/img/icons/people.png');}},createKey:function(ids){if($type(ids)!='array'){if($type(ids)=='string'&&ids.test(/^\d+(\-\d+)+$/))return ids;else return parseInt(ids);}
ids.sort(function(a,b){return parseInt(a)-parseInt(b);});return ids.join('-');},getUsers:function(){return this._users;},changeDisplay:function(){if(this._changeDisplay)this._changeDisplay.dispose();this._changeDisplay=new Gixaw.UI.Dialog({parentEl:$(document.body),title:Gixaw.Language.getString('site.text.display_picture'),url:Gixaw.Router.generate('site/change_display_picture'),iconImg:'site/img/icons/photo.png',size:{x:300,y:250},buttons:[{'id':'OK','title':Gixaw.Language.getString('site.button.change')},{'id':'Cancel','title':Gixaw.Language.getString('site.button.close')}],onClose:function(){this._changeDisplay=null;}.bind(this)});},hideConnectionProblem:function(){if(this._connectionProblem)this._connectionProblem.dispose();},showConnectionProblem:function(){if(this._connectionProblem)this._connectionProblem.dispose();this._connectionProblem=new Gixaw.UI.Notice({parentEl:$(document.body),text:Gixaw.Language.getString('site.text.connection_problem'),iconImg:"site/img/icons/stop.png"});this._reconnectEl=this._connectionProblem.getSurfaceEl().getElement('.reconnect');this._countdownEl=this._connectionProblem.getSurfaceEl().getElement('.reconnect_countdown');this._countdownEl.set('text'," "+this.messenger.getCountDown()+" ");this._reconnectInterval=setInterval(function(){if(this.messenger.getCountDown()<=1){this._reconnectEl.set('text',Gixaw.Language.getString('site.text.reconnecting'));clearInterval(this._reconnectInterval);}else{this._countdownEl.set('text'," "+this.messenger.getCountDown()+" ")}}.bind(this),1000);},onActivity:function(){if(document.title.match(/^\((\d+)\) /)){document.title=this.title;this.unreadMessages=0;}},editProfile:function(){if(this._editProfile)this._editProfile.dispose();this._editProfile=new Gixaw.UI.Dialog({parentEl:$(document.body),title:'Profile',url:Gixaw.Router.generate(Gixaw.Config.get('site.edit_profile_action_name')),iconImg:'site/img/icons/profile_icon.png',size:{x:400,y:350},onClose:function(){this._editProfile=null;}.bind(this)});},changePreferences:function(){if(this._changePreferences)this._changePreferences.dispose();this._changePreferences=new Gixaw.UI.Dialog({parentEl:$(document.body),title:'Profile',url:Gixaw.Router.generate('site/preferences'),iconImg:'site/img/icons/preferences_icon.png',size:{x:530,y:150},onClose:function(){this._changePreferences=null;}.bind(this)});},userAccount:function(){if(this._userAccount)this._userAccount.dispose();this._userAccount=new Gixaw.UI.Dialog({parentEl:$(document.body),title:Gixaw.Language.getString('site.text.my_account'),url:Gixaw.Router.generate('site/user_account'),iconImg:'site/img/icons/account_icon.png',size:{x:400,y:280},onClose:function(){this._userAccount=null;}.bind(this)});}});Gixaw.Chat.Desktop.Home=new Class({Extends:Gixaw.UI.Widget,options:{className:'gixaw-chat-desktop-home'},onPrepare:function(){this.parent();this._iframeEl=new IFrame({'class':'dialog-iframe','src':Gixaw.Router.generate('site/getting_started'),'frameborder':'0','marginWidth':'0px','marginHeight':'0px','allowTransparency':'true'});},onRender:function(){this.parent();this._surfaceEl.adopt(this._iframeEl);},afterRender:function(){this.parent();},onLayout:function(){this.parent();this._iframeEl.setSize(this._surfaceEl.getInnerSize());},getDesktop:function(){return this._options.desktop();}});Gixaw.Chat.Desktop.Controls=new Class({Extends:Gixaw.UI.Container,options:{className:'gixaw-chat-desktop-controls'},templates:{'icon':'<div class="icon"><img src="${icon}" /></div>'},onPrepare:function(){this.parent();},onRender:function(){this.parent();},onLayout:function(){this.parent();},onAdd:function(item){if(item.href){item.itemEl=new Element('div',{'class':'icon-container','html':Gixaw.format(this.templates['icon'],{icon:Gixaw.Router.getAssetUrl(item.iconImg)}),'events':{'mouseover':item.mouseover,'mouseout':item.mouseout,'click':item.fn}});}else{item.itemEl=new Element('div',{'class':'icon-container','html':Gixaw.format(this.templates['icon'],{icon:Gixaw.Router.getAssetUrl(item.iconImg)}),'events':{'click':function(event){this.activate(item.id,{x:$unlink(event.page.x),y:$unlink(event.page.y)});event.stop();}.bindWithEvent(this),'mousedown':function(event){if(this._controlTooltip)this._controlTooltip.dispose();}.bindWithEvent(this)}});item.itemEl.getElement('img').addEvents({'mouseenter':function(event){item.itemEl.addClass('hover');if(this._controlTooltip)this._controlTooltip.dispose();if(item.caption){this._controlTooltip=new Gixaw.UI.Popup({className:'gixaw-ui-tooltip',parentEl:$(document.body),position:{x:event.page.x+10,y:event.page.y+15},caption:item.caption});}}.bindWithEvent(this),'mouseleave':function(event){if(this._controlTooltip)this._controlTooltip.dispose();item.itemEl.removeClass('hover');}.bindWithEvent(this)});}
item.itemEl.inject(this._surfaceEl);},afterAdd:function(item){this.layout();},onActivate:function(item,options){if(item.fn){item.fn(options||{});}}});Gixaw.Chat.Login=new Class({Extends:Gixaw.UI.Widget,options:{className:'gixaw-chat-login',position:{x:0,y:0}},templates:{'surface':'<div class="overlay">&nbsp;</div><table class="client-area"><tr><td class="text"></td></tr></table>'},onPrepare:function(){this.parent();},onRender:function(){this.parent();this._overlayEl=this._surfaceEl.getElement('.overlay');this._clientAreaEl=this._surfaceEl.getElement('.client-area');this._textEl=this._clientAreaEl.getElement('.text');if(Gixaw.Config.get('loginMember')&&!Gixaw.Config.get('loginGuest')){var passwordLabel=Gixaw.Language.getString('site.field.password');}else{var passwordLabel=Gixaw.Language.getString('site.field.password_optional');}
this._textEl.set('html','<div class="container"><div class="innerBox"><div class="logo"><img src="'+Gixaw.Config.get('site.logo_url')+'" /></div><div class="errorBox"></div><form id="login-form"><div class="username-box"><div class="field-label">'+Gixaw.Language.getString('site.field.username')+':</div><input type="text" class="username" name="username" /></div><div class="password-box"><div class="field-label">'+passwordLabel+':</div><input type="password" class="password" name="password" /><div class="forgot"><a href="'+Gixaw.Router.generate('site/forgot_password')+'">'+Gixaw.Language.getString('site.text.forgot_your_password')+'</a></div></div><input type="submit" class="button" value="Login" /><div class="signup"><a href="'+Gixaw.Router.generate('site/signup')+'">'+Gixaw.Language.getString('site.text.signup_member')+'</a></div></form></div></div>');this._errorEl=this._textEl.getElement('div.errorBox');this._usernameEl=this._textEl.getElement('input[name=username]');this._passwordEl=this._textEl.getElement('input[name=password]');this._passwordBox=this._textEl.getElement('div.password-box');this._signupEl=this._textEl.getElement('div.signup');Gixaw.Hooks.fireEvent('Gixaw.Chat.login',[this._textEl]);if(!Gixaw.Config.get('loginMember')||!Gixaw.Config.get('site.allow_new_registrations'))this._signupEl.setStyle('display','none');if(!Gixaw.Config.get("loginMember"))this._passwordBox.setStyle('display','none');var formEl=this._textEl.getElementById('login-form');formEl.addEvent('submit',function(){this.hideError();if(this._usernameEl.value.length==0){this.showError(Gixaw.Language.getString('site.error.username'));}else{this._loginRequest=new Request.JSON({url:Gixaw.Router.generate('site/login'),onComplete:this.onComplete.bind(this),onSuccess:this.onSuccess.bind(this),onFailure:this.onFailure.bind(this)}).POST({'username':this._usernameEl.value,'password':this._passwordEl.value,'inline':true,'t':Gixaw.Config.get('site.t')});}
return false;}.bind(this));if(Gixaw.Config.get('error')){this.showError(Gixaw.Language.getString(Gixaw.Config.get('error')));}},onLayout:function(){this.parent();this._clientAreaEl.setSize(this._surfaceEl.getInnerSize());this._usernameEl.focus();},hideError:function(){this._errorEl.setStyle('display','none');this._errorEl.set('html',"");},showError:function(text){this._errorEl.setStyle('display','block');this._errorEl.set('html',text);},onComplete:function(){},onSuccess:function(response){var error=response.error||false;if(error){switch(response.type){case"site.error.user_exists":this.showError(Gixaw.Language.getString(response.type));this._passwordEl.focus();break;case"site.error.login":this.showError(Gixaw.Language.getString(response.type));this._passwordEl.focus();break;case"site.error.max_users":this.showError(Gixaw.Language.getFormattedString(response.type,{limit:response.limit}));break;default:this.showError(Gixaw.Language.getString(response.type));}}else{var data=response.data;for(i in data){Gixaw.Config.set(i,data[i]);}
this.dispose();this.getDesktop().start();}},onFailure:function(){},getDesktop:function(){return this._options.desktop();}});Gixaw.namespace('Gixaw.Chat.ConversationView');Gixaw.namespace('Gixaw.Chat.ConversationView.MessageArea');Gixaw.namespace('Gixaw.Chat.ConversationView.TypingArea');Gixaw.namespace('Gixaw.Chat.ConversationView.TypingArea.SendButton');Gixaw.Chat.ConversationView=new Class({Extends:Gixaw.UI.Widget,options:{className:'gixaw-chat-conversationview',conversationId:null,conversationKey:null,mode:null,initialMessages:[],topic:null,protected:false,password:null,emoticons:null,font_styles:null,word_filters:null},onPrepare:function(){this.parent();this._buffer.messages=[];this.mode=this.options.mode;this.conversationId=this.options.conversationId;if(this.mode=='pair'&&$type(this.conversationId)=='string'&&this.conversationId.test(/^\d+(\-\d+)+$/)){this.conversationId=null;}
this.conversationKey=this.options.conversationKey||this.conversationId;this.users=new Hash();this.pendingMessages=[];this._conversationBufferSize=Gixaw.Config.get('site.buffer_size');this._shaded=false;this._lastMessageUserId=null;this._emoticons=null;this._word_filters=null;if(this.mode=='pair'){this._userStatus=1;}
this._onMessageBind=this.onMessage.bind(this)
this.getDesktop().addEvent('onMessage',this._onMessageBind);this._onFailedMessageBind=this.onFailedMessage.bind(this)
this.getDesktop().addEvent('onFailedMessage',this._onFailedMessageBind);this.sendJoin();Gixaw.Hooks.fireEvent('Gixaw.Chat.ConversationView.onPrepare',[$lambda(this)]);},onRender:function(){this.parent();this.messageArea=new Gixaw.Chat.ConversationView.MessageArea({});this.typingArea=new Gixaw.Chat.ConversationView.TypingArea({conversation:$lambda(this),emoticons:this.options.emoticons,font_styles:this.options.font_styles,'onSend':function(message){this.sendText(message);}.bind(this),'onClear':function(message){this.messageArea.clearMessages();if(this.mode=="room"){this.displayTopic();};}.bind(this)});this.centerPanel=new Gixaw.UI.Container({layout:'border',items:[{direction:'center',widget:this.messageArea,minSize:200},{direction:'south',widget:this.typingArea,initialSize:100,splitter:true,resizable:true,minSize:75}]});if(this.mode=='room'){this.userList=new Gixaw.UI.ListView({caption:Gixaw.Language.getString('site.text.users')+' (${count})',showCount:true,showLoader:true,showSearch:true});}else if(this.mode=='group'){this.userList=new Gixaw.UI.ListView({caption:Gixaw.Language.getString('site.text.users')+' (${count})',showCount:true,showLoader:true,showSearch:true});this.groupToolBar=new Gixaw.UI.ToolBar({});this.groupToolBar.add({buttonImg:'site/img/icons/add.png',title:Gixaw.Language.getString('site.button.invitesomeone'),disabled:!Gixaw.Config.get('site.group_chat'),fn:this.showInviteUserDialog.bind(this)});this.groupLayout=new Gixaw.UI.Container({layout:'border',items:[{direction:'north',widget:this.groupToolBar,initialSize:26},{direction:'center',widget:this.userList}]});}else if(this.mode=='pair'){this.users.each(function(el,id){if(el.displayName!=this.getDesktop().getDisplayName()){this.pair_display_name=el.displayName;this.pair_user_id=id;}}.bind(this));this.userInfo=new Gixaw.UI.Panel({className:'gixaw-chat-conversationview-userinfo',html:'<img class="display" src="'+Gixaw.Router.generate('site/view_display_picture',{'user_id':this.pair_user_id})+'">'});this.userPanelMenu=new Gixaw.UI.ListView({caption:this.pair_display_name});this.userPanelMenu.add({title:Gixaw.Language.getString('site.button.invitesomeone'),iconImg:'site/img/icons/add.png',disabled:!Gixaw.Config.get('site.group_chat'),fn:this.showInviteUserDialog.bind(this)});if(Gixaw.Config.get('site.can_view_profile')){this.userPanelMenu.add({title:Gixaw.Language.getString('site.button.viewprofile'),iconImg:'site/img/icons/profile_icon.png',fn:function(){this.viewProfile(this.pair_user_id,this.pair_display_name);}.bind(this)});}
this.userPanel=new Gixaw.UI.Container({layout:'border',className:'gixaw-ui-borderlayout-userpanel',items:[{direction:'north',widget:this.userInfo,initialSize:125},{direction:'center',widget:this.userPanelMenu}]});if(Gixaw.Config.get('private_messaging')['emoticons'].allow_emoticons&&Gixaw.Config.get('private_messaging')['emoticons'].list){var emoticons={};emoticons.args={};emoticons.user_id=this.getDesktop().getUserId();emoticons.type='emoticons';emoticons.conversation_id=this.getConversationId();emoticons.args.conversation_id=this.getConversationId();emoticons.args.emoticons=Gixaw.Config.get('private_messaging')['emoticons'].list;this.onConversationMessage(emoticons);}
if(Gixaw.Config.get('private_messaging')['word_filters'].allow_word_filters&&Gixaw.Config.get('private_messaging')['word_filters'].list){var word_filters={};word_filters.args={};word_filters.user_id=this.getDesktop().getUserId();word_filters.type='word_filters';word_filters.conversation_id=this.getConversationId();word_filters.args.conversation_id=this.getConversationId();word_filters.args.word_filters=Gixaw.Config.get('private_messaging')['word_filters'].list;this.onConversationMessage(word_filters);}}
this._userListLayout=new Gixaw.UI.Container({layout:'border',items:[{direction:'center',widget:this.userList?(this.mode=='group')?this.groupLayout:this.userList:this.userPanel}]});Gixaw.Hooks.fireEvent('Gixaw.Chat.Conversation.userListLayout',[this._userListLayout]);this._layoutWg=new Gixaw.UI.Container({parentEl:this._surfaceEl,layout:'border',items:[{direction:'center',widget:this.centerPanel,minSize:200},{direction:'east',widget:this._userListLayout,initialSize:200,splitter:true,resizable:true,minSize:150}]});this.options.initialMessages.each(function(message){this.displayMessage(message);}.bind(this));this._buffer.messages.each(function(message){this.onMessage(message);},this);if(this.options.topic&&(this.options.protected!=true))this.displayTopic();Gixaw.Hooks.fireEvent('Gixaw.Chat.ConversationView.onRender',[$lambda(this)]);},afterRender:function(){Gixaw.Hooks.fireEvent('Gixaw.Chat.ConversationView.afterRender',[$lambda(this)]);},onLayout:function(){this.parent();this.messageArea.layout();this._layoutWg.layout();this._layoutWg.setSize(this._surfaceEl.getInnerSize());if(this._notice){this._notice.setSize(this._surfaceEl.getInnerSize());}
Gixaw.Hooks.fireEvent('Gixaw.Chat.ConversationView.onLayout',[$lambda(this)]);},setConversationId:function(conversationId){this.conversationId=conversationId;if(this.isCreating){this.isCreating=false;this.flushMessages(this.pendingMessages);this.pendingMessages=[];}},getConversationId:function(){return this.conversationId;},setConversationKey:function(conversationKey){this.conversationKey=conversationKey;},getConversationKey:function(){return this.conversationKey;},setMode:function(mode){this.mode=mode;},getMode:function(){return this.mode;},onFailedMessage:function(message){if(!this.isReady()){return;}
if(message.args.conversation_id==this.getConversationId()){switch(message.type){case'text':message.args.text=message.args.text.replace(new RegExp(/\n/ig),'<br />');message.args.text=this.formatURLs(message.args.text);message.args.text=this.replaceWords(message.args.text);message.args.text=this.replaceEmoticons(message.args.text);this.displayMessage({'type':"failed",'user_id':this.getDesktop().getUserId(),'display_name':Gixaw.Language.getString('site.error.notice'),'icon':'site/img/icons/error.png','text':Gixaw.Language.getString('site.error.not_delivered')+"<br />"+message.args.text,'display_only':false},false,false);if(this.getDesktop().sounds)Gixaw.Media.playSound('site/media/error.mp3');break;}}},onMessage:function(message){if(!this.isReady()){this._buffer.messages.push(message);return;}
if(message=="user_offline"){this._userStatus=0;this.pendingMessages=[];this.messageArea.setBarMessage(Gixaw.Language.getString('site.text.user_offline'));this.displayMessage({'type':"user_offline",'user_id':this.pair_user_id,'display_name':this.pair_display_name,'icon':'site/img/icons/arrow_left_blue.png','text':Gixaw.Language.getFormattedString('site.messages.user_offline'),'display_only':false});this.isCreating=false;return;}
if(message.conversation_id==null){if(message.args.broadcast_conversation_ids){message.args.broadcast_conversation_ids.each(function(id){if(id==this.getConversationId()){this.onConversationMessage(message);}}.bind(this));}else if(this.mode=="pair"){if(message.user_id==this.pair_user_id){this.onGlobalMessage(message);}}}
else if(message.conversation_id==this.getConversationId()){this.onConversationMessage(message);}},onGlobalMessage:function(message){Gixaw.Hooks.fireEvent('Gixaw.Chat.ConversationView.beforeGlobalMessage',[$lambda(this),message]);switch(message.type){case'connect':if(this.mode=="pair"){if(message.user_id==this.pair_user_id){this.messageArea.setBarMessage("");this.displayMessage({'type':message.type,'user_id':message.user_id,'display_name':message.args.display_name,'icon':'site/img/icons/arrow_right_green.png','text':Gixaw.Language.getFormattedString('site.messages.back_online'),'display_only':(message.args.display_only)?message.args.display_only:false});this.options.conversationKey=this.conversationKey=this.getDesktop().createKey([message.user_id,this.getDesktop().getUserId()]);this.options.conversationId=this.conversationKey;this.conversationId=null;this._userStatus=1;}}
break;}
Gixaw.Hooks.fireEvent('Gixaw.Chat.ConversationView.afterGlobalMessage',[$lambda(this),message]);},onConversationMessage:function(message){Gixaw.Hooks.fireEvent('Gixaw.Chat.ConversationView.beforeConversationMessage',[$lambda(this),message]);switch(message.type){case'user_list':if(this.options.protected==true){this.displayTopic();}
var users=message.args.users;users.each(function(user){this.addUser(user.id,user.display_name,user.status,user.group_id,user.permissions);},this);this.userList.loaded();Gixaw.Hooks.fireEvent('Gixaw.Chat.ConversationView.TypingArea.userlist',[$lambda(this)]);if(this.mode=="room"){if(this.getDesktop().admin||Gixaw.Config.get('core.is_admin')||this.hasPermission('site.can_ban')||this.hasPermission('site.can_change_topic')){this.typingArea.toolbar.add({buttonImg:'site/img/icons/settings.png',title:Gixaw.Language.getString('site.button.settings'),desc:Gixaw.Language.getString('site.text.modify_room_settings'),fn:this.typingArea.showSettingsMenu.bind(this.typingArea)});}
if(this.hasPermission('site.can_talk')!=true){this.typingArea.disable();}}
break;case'update_permissions':if(message.args.target_user_id==this.getDesktop().getUserId()){for(var i in this.users[this.getDesktop().getUserId()].permissions)
{delete this.users[this.getDesktop().getUserId()].permissions[i];}
for(var i in message.args.permissions)
{this.users[this.getDesktop().getUserId()].permissions[i]=message.args.permissions[i];}
if(this.hasPermission('site.can_talk')){this.typingArea.enable();}else{this.typingArea.disable();}}
break;case'emoticons':if(this.options.emoticons){this._emoticons=message.args.emoticons;this.typingArea.addEmoticons(this._emoticons);}
break;case'word_filters':if(this.options.word_filters){this._word_filters=message.args.word_filters;}
break;case'join':this.displayMessage({'type':message.type,'user_id':message.user_id,'display_name':message.args.display_name,'icon':'site/img/icons/arrow_right_green.png','text':(this.mode=='room')?Gixaw.Language.getFormattedString('site.messages.join'):Gixaw.Language.getFormattedString('site.messages.join_conversation'),'display_only':(message.args.display_only)?message.args.display_only:false});if(message.args.display_only)return;this.addUser(message.user_id,message.args.display_name,message.args.status,message.args.group_id,message.args.permissions);if(this.mode=='pair'){this.mode='group';this.messageArea.setBarMessage("");this.conversationKey=this.conversationId;this.getDesktop().switchMode(this.conversationId,this.conversationKey,this.mode);this.userList=new Gixaw.UI.ListView({caption:Gixaw.Language.getString('site.text.users')+' (${count})',showCount:true});this.groupToolBar=new Gixaw.UI.ToolBar({});if(Gixaw.Config.get('site.group_chat')){this.groupToolBar.add({buttonImg:'site/img/icons/add.png',title:Gixaw.Language.getFormattedString('site.button.inviteuser'),fn:this.showInviteUserDialog.bind(this)});}
this.groupLayout=new Gixaw.UI.Container({layout:'border',items:[{direction:'north',widget:this.groupToolBar,initialSize:25},{direction:'center',widget:this.userList}]});this.users.each(function(el,id){this.addUser(id,el.displayName,el.status,el.group_id,el.permissions,true);}.bind(this));this._layoutWg.add({direction:'east',widget:this.groupLayout,initialSize:200,splitter:true,resizable:true});this.layout();}
break;case"join_permission":this._notice=new Gixaw.UI.Notice({parentEl:this.getSurfaceEl(),text:Gixaw.Language.getString('site.text.no_join_permission'),iconImg:"site/img/icons/firewall.png"});this.typingArea.disable();this.userList.loaded();break;case"join_password_failed":this._notice=new Gixaw.UI.Notice({parentEl:this.getSurfaceEl(),text:Gixaw.Language.getString('site.error.incorrect_password'),iconImg:"site/img/icons/big_lock.png"});this.typingArea.disable();this.userList.loaded();break;case"join_license_failed":this._notice=new Gixaw.UI.Notice({parentEl:this.getSurfaceEl(),text:message.args.text,iconImg:"site/img/icons/big_lock.png"});this.typingArea.disable();this.userList.loaded();break;case"join_ban":if(message.args.reason!=null){var notice=message.args.display_name?Gixaw.Language.getFormattedString('site.messages.self_banned_user',{display_name:message.args.display_name})+"<br />"+Gixaw.Language.getFormattedString('site.messages.reason',{reason:message.args.reason}):Gixaw.Language.getFormattedString('site.messages.self_banned')+"<br />"+Gixaw.Language.getFormattedString('site.messages.reason',{reason:message.args.reason});}else{var notice=message.args.display_name?Gixaw.Language.getFormattedString('site.messages.self_banned_user',{display_name:message.args.display_name}):Gixaw.Language.getFormattedString('site.messages.self_banned');}
this._notice=new Gixaw.UI.Notice({parentEl:this.getSurfaceEl(),text:notice,iconImg:"site/img/icons/firewall.png"});this.typingArea.disable();this.userList.loaded();break;case'leave':this.displayMessage({'type':message.type,'user_id':message.user_id,'display_name':message.args.display_name,'icon':'site/img/icons/arrow_left_blue.png','text':(this.mode=='room')?Gixaw.Language.getFormattedString('site.messages.leave'):Gixaw.Language.getFormattedString('site.messages.leave_conversation'),'display_only':(message.args.display_only)?message.args.display_only:false});if(message.args.display_only)return;this.removeUser(message.user_id);break;case'text':message.args.text=message.args.text.replace(new RegExp(/\n/ig),'<br />');message.args.text=this.formatURLs(message.args.text);message.args.text=this.replaceWords(message.args.text);message.args.text=this.replaceEmoticons(message.args.text);this.displayMessage({'type':message.type,'user_id':message.user_id,'display_name':message.args.display_name,'icon':'site/img/icons/chat.png','text':message.args.text,'display_only':(message.args.display_only)?message.args.display_only:false},true,false,{'fontBold':message.args.fontBold,'fontItalic':message.args.fontItalic,'fontUnderline':message.args.fontUnderline,'fontName':message.args.fontName,'fontColor':message.args.fontColor,'fontSize':message.args.fontSize});break;case'update_display_name':this.displayMessage({'type':message.type,'user_id':message.user_id,'display_name':message.args.old_display_name,'icon':'site/img/icons/user.png','text':Gixaw.Language.getFormattedString('site.messages.update_display_name',{new_display_name:"<span class='display_name'>"+message.args.new_display_name+"</span>"}),'display_only':(message.args.display_only)?message.args.display_only:false});if(message.args.display_only)return;if(this.mode!="pair"){this.userList.setTitle(message.user_id,message.args.new_display_name);}
else{if(message.user_id==this.pair_user_id){this.getDesktop().tabs.setTitle(this.getDesktop()._conversations[this.conversationKey].tabId,message.args.new_display_name);this.userPanelMenu.setCaption(message.args.new_display_name);}}
break;case'update_display_picture':if(this.mode!="pair")return;if(message.user_id==this.pair_user_id){this.userInfo._surfaceEl.getElement('.display').src=message.args.image_location;}
break;case'kick_user':if(message.args.target_user_id==this.getDesktop().getUserId()){if(message.args.display_only){this.displayMessage({'type':message.type,'user_id':message.user_id,'display_name':message.args.target_display_name,'icon':'site/img/icons/shield.png','text':(message.args.reason)?Gixaw.Language.getFormattedString('site.messages.kick_reason',{kicker:"<span class='display_name'>"+message.args.display_name+"</span>",reason:message.args.reason}):Gixaw.Language.getFormattedString('site.messages.kick',{kicker:"<span class='display_name'>"+message.args.display_name+"</span>"}),'display_only':(message.args.display_only)?message.args.display_only:false});return;}
if(message.args.reason!=null){var notice=Gixaw.Language.getFormattedString('site.messages.self_kicked',{display_name:message.args.display_name})+"<br />"+Gixaw.Language.getFormattedString('site.messages.reason',{reason:message.args.reason});}else{var notice=Gixaw.Language.getFormattedString('site.messages.self_kicked',{display_name:message.args.display_name});}
this._notice=new Gixaw.UI.Notice({parentEl:this.getSurfaceEl(),text:notice,iconImg:"site/img/icons/firewall.png"});this.typingArea.disable();this.userList.empty();}else{this.displayMessage({'type':message.type,'user_id':message.user_id,'display_name':message.args.target_display_name,'icon':'site/img/icons/shield.png','text':(message.args.reason)?Gixaw.Language.getFormattedString('site.messages.kick_reason',{kicker:"<span class='display_name'>"+message.args.display_name+"</span>",reason:message.args.reason}):Gixaw.Language.getFormattedString('site.messages.kick',{kicker:"<span class='display_name'>"+message.args.display_name+"</span>"}),'display_only':(message.args.display_only)?message.args.display_only:false});if(message.args.display_only)return;this.removeUser(message.args.target_user_id);}
break;case'flood_kick':if(message.args.target_user_id==this.getDesktop().getUserId()){if(message.args.display_only){this.displayMessage({'type':message.type,'user_id':message.user_id,'display_name':message.args.target_display_name,'icon':'site/img/icons/shield.png','text':Gixaw.Language.getFormattedString('site.messages.auto_kick',{reason:"<span class='display_name'>"+Gixaw.Language.getString('site.field.flood_protection')+"</span>"}),'display_only':(message.args.display_only)?message.args.display_only:false});return;}
var notice=Gixaw.Language.getFormattedString('site.messages.flood_kick');this._notice=new Gixaw.UI.Notice({parentEl:this.getSurfaceEl(),text:notice,iconImg:"site/img/icons/firewall.png"});this.typingArea.disable();this.userList.empty();}else{this.displayMessage({'type':message.type,'user_id':message.user_id,'display_name':message.args.target_display_name,'icon':'site/img/icons/shield.png','text':Gixaw.Language.getFormattedString('site.messages.auto_kick',{reason:"<span class='display_name'>"+Gixaw.Language.getString('site.field.flood_protection')+"</span>"}),'display_only':(message.args.display_only)?message.args.display_only:false});if(message.args.display_only)return;this.removeUser(message.args.target_user_id);}
break;case'ban_user':if(message.args.target_user_id==this.getDesktop().getUserId()){if(message.args.display_only){this.displayMessage({'type':message.type,'user_id':message.user_id,'display_name':message.args.target_display_name,'icon':'site/img/icons/firewall_icon.png','text':(message.args.reason)?Gixaw.Language.getFormattedString('site.messages.ban_reason',{kicker:"<span class='display_name'>"+message.args.display_name+"</span>",reason:message.args.reason}):Gixaw.Language.getFormattedString('site.messages.ban',{kicker:"<span class='display_name'>"+message.args.display_name+"</span>"}),'display_only':(message.args.display_only)?message.args.display_only:false});return;}
if(message.args.reason!=null){var notice=Gixaw.Language.getFormattedString('site.messages.self_banned',{display_name:message.args.display_name})+"<br />"+Gixaw.Language.getFormattedString('site.messages.reason',{reason:message.args.reason});}else{var notice=Gixaw.Language.getFormattedString('site.messages.self_banned',{display_name:message.args.display_name});}
this._notice=new Gixaw.UI.Notice({parentEl:this.getSurfaceEl(),text:notice,iconImg:"site/img/icons/firewall.png"});this.typingArea.disable();this.userList.empty();}else{this.displayMessage({'type':message.type,'user_id':message.user_id,'display_name':message.args.target_display_name,'icon':'site/img/icons/firewall_icon.png','text':(message.args.reason)?Gixaw.Language.getFormattedString('site.messages.ban_reason',{kicker:"<span class='display_name'>"+message.args.display_name+"</span>",reason:message.args.reason}):Gixaw.Language.getFormattedString('site.messages.ban',{kicker:"<span class='display_name'>"+message.args.display_name+"</span>"}),'display_only':(message.args.display_only)?message.args.display_only:false});if(message.args.display_only)return;this.removeUser(message.args.target_user_id);}
break;case'flood_ban':if(message.args.target_user_id==this.getDesktop().getUserId()){if(message.args.display_only){this.displayMessage({'type':message.type,'user_id':message.user_id,'display_name':message.args.target_display_name,'icon':'site/img/icons/firewall_icon.png','text':Gixaw.Language.getFormattedString('site.messages.auto_ban',{reason:"<span class='display_name'>"+Gixaw.Language.getString('site.field.flood_protection')+"</span>"}),'display_only':(message.args.display_only)?message.args.display_only:false});return;}
var notice=Gixaw.Language.getFormattedString('site.messages.flood_ban');this._notice=new Gixaw.UI.Notice({parentEl:this.getSurfaceEl(),text:notice,iconImg:"site/img/icons/firewall.png"});this.typingArea.disable();this.userList.empty();}else{this.displayMessage({'type':message.type,'user_id':message.user_id,'display_name':message.args.target_display_name,'icon':'site/img/icons/firewall_icon.png','text':Gixaw.Language.getFormattedString('site.messages.auto_ban',{reason:"<span class='display_name'>"+Gixaw.Language.getString('site.field.flood_protection')+"</span>"}),'display_only':(message.args.display_only)?message.args.display_only:false});if(message.args.display_only)return;this.removeUser(message.args.target_user_id);}
break;case'change_topic':this.options.topic=message.args.topic;this.displayMessage({'type':message.type,'user_id':message.user_id,'display_name':message.args.display_name,'icon':'site/img/icons/info.png','text':Gixaw.Language.getFormattedString('site.messages.topic_change'),'display_only':(message.args.display_only)?message.args.display_only:false});this.displayMessage({'type':'topic','user_id':'topic','icon':'site/img/icons/info.png','display_name':Gixaw.Language.getString('site.text.topic'),'text':this.options.topic});if(message.args.display_only)return;break;case'change_status':this.users[message.user_id].status=Gixaw.Language.getString(message.args.status);if(this.mode!='pair'){this.userList.setSubTitle(message.args.target_user_id,Gixaw.Language.getString(message.args.status));this.userList.setIcon(message.args.target_user_id,this.statusIcon(message.args.status));}else{if(message.user_id!=this.getDesktop().getUserId()){this.messageArea.setBarMessage(Gixaw.Language.getFormattedString('site.messages.change_status',{status:Gixaw.Language.getString(message.args.status)}));}}
break;case'user_offline_group':this.displayMessage({'type':message.type,'user_id':message.user_id,'display_name':message.args.target_display_name,'icon':'site/img/icons/arrow_left_blue.png','text':Gixaw.Language.getFormattedString('site.messages.user_offline'),'display_only':(message.args.display_only)?message.args.display_only:false});break;case'disconnect':if(this.mode!='pair'){if(message.args.reason){this.displayMessage({'type':message.type,'user_id':message.user_id,'display_name':message.args.display_name,'icon':'site/img/icons/arrow_left_blue.png','text':Gixaw.Language.getFormattedString('site.messages.disconnect_reason',{reason:message.args.reason}),'display_only':(message.args.display_only)?message.args.display_only:false});}else{this.displayMessage({'type':message.type,'user_id':message.user_id,'display_name':message.args.display_name,'icon':'site/img/icons/arrow_left_blue.png','text':Gixaw.Language.getFormattedString('site.messages.disconnect'),'display_only':(message.args.display_only)?message.args.display_only:false});}
if(message.args.display_only)return;this.removeUser(message.user_id);}else{if(message.user_id==this.pair_user_id){this._userStatus=0;}}
break;}
this.fireEvent('onMessage',message);Gixaw.Hooks.fireEvent('Gixaw.Chat.ConversationView.afterConversationMessage',[$lambda(this),message]);},getDesktop:function(){return this._options.desktop();},userOffline:function(){this.onMessage("user_offline");},statusIcon:function(status){switch(status){case'site.status.away':return'site/img/icons/away.png';break;case'site.status.busy':return'site/img/icons/busy.png';break;case'site.status.brb':return'site/img/icons/away.png';break;default:return'site/img/icons/user.png';}},replaceEmoticons:function(message){if(this.options.emoticons){if(this._emoticons!=null){this._emoticons.each(function(emoticon){regExp=new RegExp(emoticon['regex'],'gi');message=message.replace(regExp,"<img src=\""+Gixaw.Router.getAssetUrl(emoticon['path'])+"\" style=\"vertical-align: text-top;\">");});}}
return message;},replaceWords:function(message){if(this.options.word_filters){if(this._word_filters!=null){this._word_filters.each(function(word){regExp=new RegExp(word['input'],'gi');message=message.replace(regExp,word['output']);});}}
return message;},formatURLs:function(message){regexp=/([^\w\/]|^)(https?:\/\/|ftp?:\/\/|telnet?:\/\/|gopher?:\/\/|file?:\/\/)(\S+)(\/(?:\S+))?/ig;regexp2=/([^\w\/]|^)(www\.[a-z0-9\-]+\.[a-z0-9\-]+)/ig;result=message.replace(regexp,"$1<a href=\"$2$3\" target=\"_blank\" title=\"Open Link: $2$3\">$2$3</a>");result=result.replace(regexp2,"$1<a href=\"http://$2\" target=\"_blank\" title=\"Open Link: http://$2\">$2</a>");return result;},displayMessage:function(message,box,top,styles){if(!box){this._lastMessageUserId=null;}
if(!this.isVisible()){this.getDesktop().tabs.flashTab(this.getDesktop()._conversations[this.conversationKey].tabId);}
if(message.user_id!=this._lastMessageUserId){this.insertMessageBox(message,top,styles);}else{var tbl=this.messageArea.getMessageArea().getElement('.text_box:last-child').getElement('table');this.insertMessageInsideBox(message,tbl,true,styles);}
if(this.messageArea.getMessageArea().getElements('.text_box').length>this._conversationBufferSize){this.messageArea.getMessageArea().getElement('.text_box:first-child').dispose();}
this.messageArea.getMessageArea().getElement('.text_box:last-child').getElements('img').addEvent('load',function(){this.messageArea.scrollMessages();}.bind(this));this.messageArea.scrollMessages();if(box){this._lastMessageUserId=message.user_id}},insertMessageBox:function(message,top,styles){var box=new Element("div",{'class':'text_box','events':{'mouseenter':function(){this.addClass('hover');},'mouseleave':function(){this.removeClass('hover');}}});if(message.display_only){box.addClass('oldMessage');}
else if(message.type){box.addClass(message.type);}
if(this._shaded){box.addClass('shaded');if(!top){this._shaded=false;}}else{this._shaded=true;};var tbl=new Element("table");var tblBody=new Element("tbody");tblBody.injectInside(tbl);tbl.injectInside(box);if(top){box.injectTop(this.messageArea.getMessageArea());}else{box.injectInside(this.messageArea.getMessageArea());}
this.insertMessageInsideBox(message,tbl,false,styles);},insertMessageInsideBox:function(message,tblEl,repeat,styles){var tbl=tblEl;var tblBody=tbl.getElement('tbody');var colspan=1;var row=new Element("tr");if(message.icon){var icon=new Element("td",{'class':'icon'});icon.injectInside(row);(repeat)?icon.set('html',"&nbsp;"):Asset.image(Gixaw.Router.getAssetUrl(message.icon)).injectInside(icon);}else{colspan++;}
if(message.display_name){var display_name=new Element("td",{'class':'display_name'});display_name.injectInside(row);(repeat)?display_name.set('html',".."):display_name.set('html',message.display_name);}else{colspan++;}
var text=new Element("td",{'class':'text_message','colspan':colspan});if(styles&&this.options.font_styles){if(styles.fontBold)text.setStyle('font-weight','bold');if(styles.fontItalic)text.setStyle('font-style','italic');if(styles.fontUnderline)text.setStyle('text-decoration','underline');if(styles.fontName)text.setStyle('font-family',styles.fontName);if(styles.fontColor)text.setStyle('color',styles.fontColor);if(styles.fontSize)text.setStyle('font-size',styles.fontSize);}
text.set('html',message.text);var timestamp=new Element("td",{'class':'timestamp'});if(!message.display_only){var currentTime=new Date();var hours=currentTime.getHours();var minutes=currentTime.getMinutes();minutes=(!isNaN(minutes)&&minutes.toString().length==1)?"0"+minutes:minutes;(repeat)?timestamp.set('html',"&nbsp;"):timestamp.set('html',hours+":"+minutes);}else{timestamp.set('html',"&nbsp;");}
text.injectInside(row);timestamp.injectInside(row);row.injectInside(tblBody);},addUser:function(id,display_name,status,group_id,permissions,force){if((this.users[id])&&(force!=true))return;iconImg=this.statusIcon(status);if(status)status=Gixaw.Language.getString(status);this.users[id]={displayName:display_name,status:status,group_id:group_id,permissions:permissions};if(this.mode!='pair'){this.userList.add({id:id,title:display_name,subtitle:status,color_background:(this.mode!="group")?Gixaw.Config.get('site.groups')[group_id].color_background:null,color_foreground:(this.mode!="group")?Gixaw.Config.get('site.groups')[group_id].color_foreground:null,color_foreground_subtitle:(this.mode!="group")?Gixaw.Config.get('site.groups')[group_id].color_foreground_subtitle:null,color_hover:(this.mode!="group")?Gixaw.Config.get('site.groups')[group_id].color_hover:null,sort_order:(this.mode!="group")?Gixaw.Config.get('site.groups')[group_id].sort_order:null,iconImg:iconImg,fn:function(options){var userMenu=new Gixaw.UI.Popup({parentEl:$(document.body),position:{x:options.x,y:options.y},caption:this.userList.getTitle(id)});if(id!=this.getDesktop().getUserId()){if(Gixaw.Config.get('site.can_private_message')){userMenu.add({title:Gixaw.Language.getString('site.button.privatemessage'),iconImg:'site/img/icons/user_message.png',disabled:!Gixaw.Config.get('site.private_messaging'),fn:function(){this.getDesktop().newConversation({title:this.userList.getTitle(id),user_id:id,status:status,mode:'pair',font_styles:Gixaw.Config.get('private_messaging')['font_styles'].allow_font_styles,emoticons:Gixaw.Config.get('private_messaging')['emoticons'].allow_emoticons,word_filters:Gixaw.Config.get('private_messaging')['word_filters'].allow_word_filters},true);}.bind(this)});}}
userMenu.add({title:Gixaw.Language.getString('site.button.viewprofile'),iconImg:'site/img/icons/profile_icon.png',disabled:!Gixaw.Config.get('site.can_view_profile'),fn:function(){this.viewProfile(id,this.userList.getTitle(id));}.bind(this)});if(id!=this.getDesktop().getUserId()){if(this.hasPermission('site.can_kick')){userMenu.add({title:Gixaw.Language.getString('site.button.kickquick'),iconImg:'site/img/icons/shield.png',fn:function(){this.sendKick(id,display_name);}.bind(this)});userMenu.add({title:Gixaw.Language.getString('site.button.kickreason'),iconImg:'site/img/icons/shield.png',fn:function(){var reason=new Gixaw.UI.Dialog({parentEl:$(document.body),title:Gixaw.Language.getString('site.text.enter_reason'),url:Gixaw.Router.generate('site/reason'),iconImg:'site/img/icons/shield.png',size:{x:300,y:150},autoSubmit:false,onOK:function(dialog){var reason=dialog.getField('reason')||null;if(reason){this.sendKick(id,this.userList.getTitle(id),reason);}}.bind(this)});}.bind(this)});}
if(this.hasPermission('site.can_ban')){userMenu.add({title:Gixaw.Language.getString('site.button.banquick'),iconImg:'site/img/icons/firewall_icon.png',fn:function(){this.sendBan(id,display_name,"display_name","conversation");}.bind(this)});userMenu.add({title:Gixaw.Language.getString('site.button.banreason'),iconImg:'site/img/icons/firewall_icon.png',fn:function(){var reason=new Gixaw.UI.Dialog({parentEl:$(document.body),title:Gixaw.Language.getString('site.text.enter_reason'),url:Gixaw.Router.generate('site/ban_reason'),iconImg:'site/img/icons/firewall_icon.png',size:{x:300,y:150},autoSubmit:false,onOK:function(dialog){var reason=dialog.getField('reason')||null;var ipban=dialog.getField('ban_type')||null;this.sendBan(id,this.userList.getTitle(id),(ipban)?"ip":"display_name","conversation",reason);}.bind(this)});}.bind(this)});}
if(this.getDesktop().admin&&(this.getMode()!="group")){userMenu.add({title:Gixaw.Language.getString('site.button.user_permissions'),iconImg:'site/img/icons/permissions.png',fn:function(){if(this._userPermissions)this._userPermissions.dispose();this._userPermissions=new Gixaw.UI.Dialog({parentEl:$(document.body),title:Gixaw.Language.getString('site.button.user_permissions')+' ('+this.userList.getTitle(id)+')',url:Gixaw.Router.generate('user_permissions',{user_id:id,conversation_id:this.conversationId}),iconImg:'site/img/icons/permissions.png',size:{x:550,y:300},onClose:function(){this._userPermissions=null;}.bind(this)});}.bind(this)});userMenu.add({title:Gixaw.Language.getString('site.button.user_group'),iconImg:'site/img/icons/people.png',fn:function(){if(this._userGroupSettings)this._userGroupSettings.dispose();this._userGroupSettings=new Gixaw.UI.Dialog({parentEl:$(document.body),title:Gixaw.Language.getString('site.button.user_group')+' ('+this.userList.getTitle(id)+')',url:Gixaw.Router.generate('user_group',{user_id:id,conversation_id:this.conversationId}),iconImg:'site/img/icons/people.png',size:{x:300,y:250},onClose:function(){this._userGroupSettings=null;}.bind(this)});}.bind(this)});}}}.bind(this)});}},viewProfile:function(id,display_name){if(this._viewProfile)this._viewProfile.dispose();this._viewProfile=new Gixaw.UI.Dialog({parentEl:$(document.body),title:Gixaw.Language.getString('site.text.profile')+' ('+display_name+')',url:Gixaw.Router.generate(Gixaw.Config.get('site.view_profile_action_name'),{user_id:id}),iconImg:'site/img/icons/profile_icon.png',size:{x:480,y:280},buttons:[{'id':'Cancel','title':Gixaw.Language.getString('site.button.close')}],onClose:function(){this._viewProfile=null;}.bind(this)});},removeUser:function(id){this.userList.remove(id);delete this.users[id];},getUser:function(id){return this.users[id];},postMessage:function(type,args){args=args||{};if(this.conversationId==null){this.pendingMessages.push([type,args]);if(!this.isCreating){this.sendCreate();}
return;}
args.conversation_id=args.conversation_id||this.conversationId||this.options.conversationId;args.conversation_key=args.conversation_key||this.conversationKey||this.options.conversationKey;args.mode=args.mode||this.mode||this.options.mode;this.getDesktop().postMessage(type,args);},sendMessage:function(type,args,force){args=args||{};if(this.conversationId==null){this.pendingMessages.push([type,args]);if(!this.isCreating){this.sendCreate();}
return;}
args.conversation_id=args.conversation_id||this.conversationId||this.options.conversationId;args.conversation_key=args.conversation_key||this.conversationKey||this.options.conversationKey;args.mode=args.mode||this.mode||this.options.mode;this.getDesktop().sendMessage(type,args,force);},flushMessages:function(messages){if(messages.length==0)return;this.getDesktop().flushMessages(messages.map(function(message){var type=message[0];var args=message[1];args.conversation_id=args.conversation_id||this.conversationId||this.options.conversationId;args.conversation_key=args.conversation_key||this.conversationKey||this.options.conversationKey;args.mode=args.mode||this.mode||this.options.mode;return[type,args];},this));},displayTopic:function(){Gixaw.Hooks.fireEvent('Gixaw.Chat.ConversationView.onTopic',[$lambda(this)]);this.displayMessage({'type':'topic','user_id':'topic','icon':'site/img/icons/info.png','display_name':Gixaw.Language.getString('site.text.topic'),'text':this.options.topic});Gixaw.Hooks.fireEvent('Gixaw.Chat.ConversationView.afterTopic',[$lambda(this)]);},sendJoin:function(){if(this.mode!='pair')this.sendMessage('join',{password:this.options.password},true);},sendLeave:function(){if(this.mode!='pair')this.sendMessage('leave',{},true);},sendCreate:function(){if(this.mode=='pair'){this.isCreating=true;this.flushMessages([['create',{}]]);}},sendText:function(text){if(text.trim().length==0)return;if(this.mode=="pair"){if(this._userStatus==0){this.userOffline();return;}}
this.sendMessage('text',{'text':text,'fontBold':this.typingArea.editor._font['bold'],'fontItalic':this.typingArea.editor._font['italic'],'fontUnderline':this.typingArea.editor._font['underline'],'fontColor':this.typingArea.editor._font['color'],'fontName':this.typingArea.editor._font['name'],'fontSize':this.typingArea.editor._font['size']});text=text.replace(new RegExp(/\n/ig),'\\\\\\n');text=Gixaw.Util.htmlSpecialChars(text);text=text.replace(new RegExp(/\\\\\\n/ig),' <br /> ');text=this.formatURLs(text);text=this.replaceWords(text);text=this.replaceEmoticons(text);this.displayMessage({'type':'self_text','user_id':this.getDesktop().getUserId(),'display_name':this.getDesktop().getDisplayName(),'icon':'site/img/icons/chat.png','text':text},true,false,{'fontBold':this.typingArea.editor._font['bold'],'fontItalic':this.typingArea.editor._font['italic'],'fontUnderline':this.typingArea.editor._font['underline'],'fontColor':this.typingArea.editor._font['color'],'fontName':this.typingArea.editor._font['name'],'fontSize':this.typingArea.editor._font['size']});this._lastMessageUserId=this.getDesktop().getUserId();},sendInvite:function(user_id,display_name){this.sendMessage('invite_user',{user_id:user_id,target_display_name:display_name});},sendKick:function(target_user_id,target_display_name,reason){this.sendMessage('kick_user',{target_user_id:target_user_id,target_display_name:target_display_name,reason:(reason)?reason:null});},sendBan:function(target_user_id,target_display_name,ban_type,ban_scope,reason){this.sendMessage('ban_user',{target_user_id:target_user_id,target_display_name:target_display_name,ban_type:ban_type,ban_scope:ban_scope,reason:(reason)?reason:null});},showInviteUserDialog:function(){this.inviteList=new Gixaw.UI.ListView({});this.inviteList.loaded();this.inviteDialog=new Gixaw.UI.Form({parentEl:this._surfaceEl,size:{x:400,y:300},title:Gixaw.Language.getString('site.text.inviteconversation'),layoutOptions:{gridSize:{x:1,y:1}},items:[{position:{x:0,y:0},size:{x:1,y:1},widget:this.inviteList}]});var users=this.getDesktop().getUsers();users.each(function(value,key){this.addInviteUser(key,value.displayName);}.bind(this));},addInviteUser:function(user_id,display_name){if((user_id!=this.getDesktop().getUserId())&&(!this.users[user_id])){this.inviteList.add({id:user_id,title:display_name,iconImg:'site/img/icons/user.png',fn:function(){this.sendInvite(user_id,display_name);this.inviteDialog.dispose();}.bind(this)});}},hasPermission:function(permission_name){var permissions=(this.users[this.getDesktop().getUserId()].permissions)?this.users[this.getDesktop().getUserId()].permissions:null;if((permissions!=null)&&(permissions[permission_name])){return true;}
return false;},show:function(){this.parent();if(!this.getDesktop()._login)this.typingArea.focus();},dispose:function(){this.sendLeave();this.getDesktop().removeEvent('onMessage',this._onMessageBind);this.parent();}});Gixaw.Chat.ConversationView.MessageArea=new Class({Extends:Gixaw.UI.Widget,options:{className:'gixaw-chat-conversationview-messagearea',messageBar:null},onPrepare:function(){this.parent();this.messageBar=this.options.messageBar;this._manualScrolling=false;this._templates['surface']='<div class="message-bar"></div><div class="message-area"></div>';this._templates['topic']='<span class="icon"></span><span class="topic">${topic}</span>';},onRender:function(){this.parent();this._surfaceEl.set('html',Gixaw.format(this._templates['surface']));this.messageBarEl=this._surfaceEl.getElement('.message-bar');this.clientAreaEl=this._surfaceEl.getElement('.message-area');this.clientAreaEl.onscroll=function(){if(this.clientAreaEl.getScrollTop()+this.clientAreaEl.getHeight()>=this.clientAreaEl.getScrollHeight()){this._manualScrolling=false;}else{this._manualScrolling=true;}}.bind(this);},onLayout:function(){this.parent();this.messageBarEl.setWidth(this._surfaceEl.getWidth());if(this.messageBar==null){var messageBarElHeight=0;this.messageBarEl.setStyles({display:'none'});}else{this.messageBarEl.setStyles({display:''});var messageBarElHeight=this.messageBarEl.getHeight()+this.messageBarEl.getMarginHeight();}
this.clientAreaEl.setHeight(this._surfaceEl.getHeight()-this.clientAreaEl.getMarginHeight()-messageBarElHeight);this.scrollMessages(true);},setBarMessage:function(message){if(message){this.messageBarEl.empty();var iconImgEl=Asset.image(Gixaw.Router.getAssetUrl('site/img/icons/info.png'));iconImgEl.addEvent('load',function(event){this.layout()}.bindWithEvent(this));var messageSpan=new Element('span');messageSpan.set('text',message);this.messageBar=message;iconImgEl.inject(this.messageBarEl);messageSpan.inject(this.messageBarEl);}else{this.messageBar=null;}
this.layout();},scrollMessages:function(force){if(!this._manualScrolling||force){this._manualScrolling=false;this.clientAreaEl.scrollTo(0,this.clientAreaEl.getScrollHeight());}},getMessageArea:function(){return this.clientAreaEl;},clearMessages:function(){this.clientAreaEl.empty();},add:function(message){var html=message.html||'';var args=message.args||{};this.clientAreaEl.appendHTML(Gixaw.format(html,args));}});Gixaw.Chat.ConversationView.TypingArea=new Class({Extends:Gixaw.UI.Widget,options:{className:'gixaw-chat-conversationview-typingarea',emoticons:null,font_styles:null,disabled:null},onPrepare:function(){this.parent();this.conversationId=this.getConversation().getConversationId();this.mode=this.getConversation().getMode();this.emoticons=null;},getConversation:function(){return this._options.conversation();},onRender:function(){this.parent();this.editor=new Gixaw.UI.Editor({'onKeyPress':function(event){this.processKey(event);}.bindWithEvent(this)});this.toolbar=new Gixaw.UI.ToolBar({items:[{buttonImg:'site/img/icons/window.png',title:Gixaw.Language.getString("site.button.clear"),desc:Gixaw.Language.getString("site.text.clear_screen"),fn:this.clearMessageArea.bind(this)}]});this.toolbar.add({buttonImg:'site/img/icons/smile.png',title:Gixaw.Language.getString("site.button.smileys"),desc:Gixaw.Language.getString("site.text.select_smiley"),disabled:!this.options.emoticons,fn:this.showEmoticonsMenu.bind(this)});this.toolbar.add({buttonImg:'site/img/icons/font.png',title:Gixaw.Language.getString("site.button.text"),desc:Gixaw.Language.getString("site.text.change_font"),disabled:!this.options.font_styles,fn:this.showFontStyles.bind(this)});this.sendButton=new Gixaw.Chat.ConversationView.TypingArea.SendButton({'onClick':function(){this.send();}.bind(this)});this._layoutWg=new Gixaw.UI.Container({layout:'border',items:[{direction:'north',widget:this.toolbar,initialSize:26},{direction:'center',widget:this.editor},{direction:'east',widget:this.sendButton}]});this._layoutWg.setParentEl(this._surfaceEl);},onLayout:function(){this.parent();this._layoutWg.setSize(this._surfaceEl.getInnerSize());},enable:function(){this.options.disabled=false;this._surfaceEl.disabled=false;this.sendButton.sendButtonEl.disabled=false;this.editor._editorEl.disabled=false;this.editor.richState();this.editor.setText();this.focus();},disable:function(){this.options.disabled=true;this._surfaceEl.disabled=true;this.sendButton.sendButtonEl.disabled=true;this.editor._editorEl.disabled=true;this.editor.noticeState();this.editor.setText(Gixaw.Language.getString("site.text.no_talk_permission"));},focus:function(){if(!this.isReady()){return this.runWhenReady(arguments.callee,$A(arguments));}
this.editor.focus();},send:function(){if(this.options.disabled){this.editor.noticeState();this.editor.setText(Gixaw.Language.getString("site.text.no_talk_permission"));}else{var text=this.editor.getText();this.editor.setText();this.focus();this.fireEvent('onSend',text);}},clearMessageArea:function(){this.focus();this.fireEvent('onClear');},processKey:function(event){if(this.options.disabled){this.editor.noticeState();this.editor.setText(Gixaw.Language.getString("site.text.no_talk_permission"));event.stop();return false;}else{if(!event.shift&&event.key=='enter'){this.send();event.stop();}}},hasPermission:function(permission_name){return this.getConversation().hasPermission(permission_name);},showEmoticonsMenu:function(options){if(this.options.disabled!=true){if(this.emoticons==null){var emoticonsMenu=new Gixaw.UI.Popup({className:'gixaw-ui-tooltip',parentEl:$(document.body),position:{x:options.x,y:options.y},caption:Gixaw.Language.getString("site.text.no_smileys")});}else{var emoticonsMenu=new Gixaw.UI.Popup({className:'gixaw-ui-popup-horizontal gixaw-chat-emoticons',parentEl:$(document.body),position:{x:options.x,y:options.y},caption:Gixaw.Language.getString("site.button.smileys")});if(this.emoticons!=null){this.emoticons.each(function(emoticon){emoticonsMenu.add({title:"",iconImg:emoticon['path'],iconSize:20,fn:function(){this.editor.appendText(emoticon['trigger']);}.bind(this)});},this);}}}},addEmoticons:function(emoticons){this.emoticons=emoticons;},showSettingsMenu:function(options){var settingsMenu=new Gixaw.UI.Popup({parentEl:$(document.body),position:{x:options.x,y:options.y},caption:Gixaw.Language.getString('site.button.settings')});if(this.getConversation().getDesktop().admin||Gixaw.Config.get('core.is_admin')){settingsMenu.add({title:Gixaw.Language.getString('site.button.roomsettings'),iconImg:'site/img/icons/window.png',fn:this.showRoomSettings.bind(this)});settingsMenu.add({title:Gixaw.Language.getString('site.button.groupsettings'),iconImg:'site/img/icons/people.png',fn:this.showGroupSettings.bind(this)});}
if(this.hasPermission('site.can_change_topic')){settingsMenu.add({title:Gixaw.Language.getString('site.button.change_topic'),iconImg:'site/img/icons/info.png',fn:this.showTopicChange.bind(this)});}
if(this.hasPermission('site.can_ban')){settingsMenu.add({title:Gixaw.Language.getString('site.button.roombans'),iconImg:'site/img/icons/firewall_icon.png',fn:this.showRoomBans.bind(this)});}},showRoomSettings:function(){if(this._roomSettings)this._roomSettings.dispose();this._roomSettings=new Gixaw.UI.Dialog({parentEl:$(document.body),title:Gixaw.Language.getString('site.button.roomsettings'),url:Gixaw.Router.generate('room_settings',{conversation_id:this.conversationId}),iconImg:'site/img/icons/window.png',size:{x:400,y:350},onClose:function(){this._roomSettings=null;}.bind(this)});},showRoomBans:function(){if(this._roomBans)this._roomBans.dispose();this._roomBans=new Gixaw.UI.Dialog({parentEl:$(document.body),title:Gixaw.Language.getString('site.button.roombans'),url:Gixaw.Router.generate('room_bans',{conversation_id:this.conversationId}),iconImg:'site/img/icons/firewall_icon.png',size:{x:440,y:280},buttons:[{'id':'OK','title':Gixaw.Language.getString('site.button.unban')},{'id':'Cancel','title':Gixaw.Language.getString('site.button.close')}],onClose:function(){this._roomBans=null;}.bind(this)});},showTopicChange:function(){if(this._roomTopic)this._roomTopic.dispose();this._roomTopic=new Gixaw.UI.Dialog({parentEl:$(document.body),title:Gixaw.Language.getString('site.text.change_topic'),url:Gixaw.Router.generate('change_topic',{conversation_id:this.conversationId}),iconImg:'site/img/icons/info.png',size:{x:300,y:150},buttons:[{'id':'OK','title':Gixaw.Language.getString('site.button.OK')},{'id':'Cancel','title':Gixaw.Language.getString('site.button.close')}],onClose:function(){this._roomBans=null;}.bind(this)});},showGroupSettings:function(){if(this._groupSettings)this._groupSettings.dispose();this._groupSettings=new Gixaw.UI.Dialog({parentEl:$(document.body),title:Gixaw.Language.getString('site.button.groupsettings'),url:Gixaw.Router.generate('group_settings',{conversation_id:this.conversationId}),iconImg:'site/img/icons/people.png',size:{x:600,y:350},onClose:function(){this._groupSettings=null;}.bind(this)});},showFontStyles:function(){if(this.options.disabled!=true){this.editor.setText();if(this._fontStyles)this._fontStyles.dispose();this._fontStyles=new Gixaw.UI.Dialog({parentEl:$(document.body),title:Gixaw.Language.getString('site.text.font_styles'),url:Gixaw.Router.generate('site/font_styles'),iconImg:'site/img/icons/font.png',size:{x:450,y:300},onClose:function(){this._fontStyles=null;}.bind(this),autoSubmit:false,onLoad:function(dialog){dialog.setField('fontName',this.editor._font['name']);dialog.setField('fontSize',this.editor._font['size']);dialog.setField('fontColor',this.editor._font['color']);dialog.setField('fontBold',this.editor._font['bold']);dialog.setField('fontItalic',this.editor._font['italic']);dialog.setField('fontUnderline',this.editor._font['underline']);dialog.callLoadScript();}.bind(this),onOK:function(dialog){this.editor.focus();this.editor._font['name']=dialog.getField('fontName');this.editor._font['size']=dialog.getField('fontSize');this.editor._font['color']=dialog.getField('fontColor');this.editor._font['bold']=dialog.getField('fontBold');this.editor._font['italic']=dialog.getField('fontItalic');this.editor._font['underline']=dialog.getField('fontUnderline');this.editor.richState();}.bind(this)});}}});Gixaw.Chat.ConversationView.TypingArea.SendButton=new Class({Extends:Gixaw.UI.Widget,options:{className:'gixaw-chat-conversationview-typingarea-sendbutton',html:Gixaw.Language.getString('site.button.send')},onPrepare:function(){this.parent();this._buffer.html=this.options.html;},onRender:function(){this.parent();this.sendButtonEl=new Element('button',{'class':'button','styles':{'position':'absolute'},'events':{'click':function(event){this.fireEvent('onClick',event)}.bindWithEvent(this)}});this.sendButtonEl.inject(this._surfaceEl);if(this._buffer.html)this.setHTML(this._buffer.html);},onLayout:function(){this.parent();this.sendButtonEl.setSize(this._surfaceEl.getInnerSize());},setHTML:function(html){if(!this.isReady()){this._buffer.html=html;return;}
this.sendButtonEl.set('html',html);}});function file_sharing_add_button(conversation){conversation.typingArea.toolbar.add({buttonImg:'plugins/file_sharing/img/icon.png',title:Gixaw.Language.getString("plugins/file_sharing.button.send_file"),desc:Gixaw.Language.getString("plugins/file_sharing.text.send_file"),fn:function(){if(conversation.typingArea.options.disabled!=true){var fileSharing=new Gixaw.UI.Dialog({parentEl:$(document.body),title:Gixaw.Language.getString('plugins/file_sharing.title.send_file'),url:Gixaw.Router.generate('plugins/file_sharing/index',{conversation_id:conversation.getConversationId()}),iconImg:'plugins/file_sharing/img/icon.png',size:{x:400,y:220},autoSubmit:false,buttons:[{'id':'Send','title':Gixaw.Language.getString('plugins/file_sharing.button.send_file')},{'id':'Cancel','title':Gixaw.Language.getString('site.button.close')}],onSend:function(){fileSharing.callLoadScript();}});}}});}
Gixaw.Hooks.addEvent('Gixaw.Chat.ConversationView.afterRender',function(conversation){conversation=conversation();if((conversation.getMode()=="pair"||conversation.getMode()=="group")&&(Gixaw.Config.get('plugins/file_sharing.private_message.allowed'))){file_sharing_add_button(conversation);}});Gixaw.Hooks.addEvent('Gixaw.Chat.ConversationView.afterConversationMessage',function(conversation,message){conversation=conversation();if(message.type=='send_file'){if(!message.args.display_only){conversation.getDesktop().unreadMessages++;document.title="("+conversation.getDesktop().unreadMessages+") "+conversation.getDesktop().title;}
var url=Gixaw.Router.generate('plugins/file_sharing/download',{id:message.args.file_id,conversation_id:message.args.conversation_id});var previewUrl=Gixaw.Router.generate('plugins/file_sharing/preview',{id:message.args.file_id,conversation_id:message.args.conversation_id});var stringName='plugins/file_sharing.message.send_file_without_permission';if(conversation.getMode()=="room"){if(conversation.hasPermission("plugins/file_sharing.can_download")){var stringName='plugins/file_sharing.message.send_file';}}else if((conversation.getMode()=="pair"||conversation.getMode()=="group")&&(Gixaw.Config.get('plugins/file_sharing.private_message.allowed'))){var stringName='plugins/file_sharing.message.send_file';}
conversation.displayMessage({'type':message.type,'user_id':message.user_id,'display_name':message.args.display_name,'icon':'plugins/file_sharing/img/icon.png','text':Gixaw.Language.getFormattedString(stringName,{url:url,filename:message.args.filename,preview_url:previewUrl,file_size:message.args.file_size.toString()}),'display_only':(message.args.display_only)?message.args.display_only:false});}else if(message.type=='user_list'){if((conversation.getMode()=="room")&&(conversation.hasPermission("plugins/file_sharing.can_upload"))){file_sharing_add_button(conversation);}}});function transcripts_add_button(conversation){conversation.typingArea.toolbar.add({buttonImg:'plugins/transcripts/img/icon.png',title:Gixaw.Language.getString("plugins/transcripts.button.transcripts"),desc:Gixaw.Language.getString("plugins/transcripts.text.transcripts"),fn:function(){if(conversation.typingArea.options.disabled!=true){if(this._roomTranscripts)this._roomTranscripts.dispose();this._roomTranscripts=new Gixaw.UI.Dialog({parentEl:$(document.body),title:Gixaw.Language.getString('plugins/transcripts.title.transcripts'),url:Gixaw.Router.generate('plugins/transcripts/index',{conversation_id:conversation.getConversationId()}),iconImg:'plugins/transcripts/img/icon.png',size:{x:530,y:250},autoSubmit:false,buttons:[{'id':'Send','title':Gixaw.Language.getString('plugins/transcripts.button.view')},{'id':'Cancel','title':Gixaw.Language.getString('site.button.close')}],onSend:function(){this._roomTranscripts.callLoadScript();}.bind(this)});}}});}
Gixaw.Hooks.addEvent('Gixaw.Chat.ConversationView.afterConversationMessage',function(conversation,message){conversation=conversation();if(message.type=='user_list'){if((conversation.getMode()=="room")&&(conversation.hasPermission("plugins/transcripts.can_view"))){transcripts_add_button(conversation);}}});Gixaw.Hooks.addEvent('Gixaw.Chat.Desktop.AdminMenu',function(adminMenu){if(Gixaw.Config.get('core.is_admin')){adminMenu.add({title:Gixaw.Language.getString('plugins/transcripts.button.transcripts'),iconImg:'plugins/transcripts/img/transcripts.png',fn:function(){if(this._transcripts)this._transcripts.dispose();this._transcripts=new Gixaw.UI.Dialog({parentEl:$(document.body),title:Gixaw.Language.getString('plugins/transcripts.title.transcripts'),url:Gixaw.Router.generate('plugins/transcripts/conversation'),iconImg:'plugins/transcripts/img/icon.png',size:{x:650,y:350},autoSubmit:false,buttons:[{'id':'Send','title':Gixaw.Language.getString('plugins/transcripts.button.view')},{'id':'Cancel','title':Gixaw.Language.getString('site.button.close')}],onSend:function(){this._transcripts.callLoadScript();}.bind(this)});}.bind(this)});}});var addthis_pub="gixaw";Gixaw.Hooks.addEvent('Gixaw.Chat.Desktop.icons',function(desktop){desktop=desktop();if(typeof addthis_open=='function'){desktop.controls.add({caption:Gixaw.Language.getString('plugins/social_sharing.text.share_chat'),iconImg:'plugins/social_sharing/img/invite.png',href:"http://www.addthis.com/bookmark.php?v=20",mouseover:function(event){return addthis_open(this,'',Gixaw.Config.get('site.chat_url'),Gixaw.Config.get('site.chat_name'));},mouseout:function(event){addthis_close();},fn:function(event){return addthis_sendto();}});}});