var Class={create:function(){return function(){if(this.destroy){Class.registerForDestruction(this)}if(this.initialize){this.initialize.apply(this,arguments)}}},extend:function(a){constructor=function(){var b;this[a]={};for(b in window[a].prototype){if(!this[b]){this[b]=window[a].prototype[b]}if(typeof window[a].prototype[b]=="function"){this[a][b]=window[a].prototype[b].bind(this)}}if(window[a].getInheritedStuff){window[a].getInheritedStuff.apply(this)}if(this.destroy){Class.registerForDestruction(this)}if(this.initialize){this.initialize.apply(this,arguments)}};constructor.getInheritedStuff=function(){var b;this[a]={};for(b in window[a].prototype){if(!this[b]){this[b]=window[a].prototype[b]}if(typeof window[a].prototype[b]=="function"){this[a][b]=window[a].prototype[b].bind(this)}}if(window[a].getInheritedStuff){window[a].getInheritedStuff.apply(this)}};return constructor},objectsToDestroy:[],registerForDestruction:function(a){if(!Class.addedDestructionLoader){Event.observe(window,"unload",Class.destroyAllObjects);Class.addedDestructionLoader=true}Class.objectsToDestroy.push(a)},destroyAllObjects:function(){var a,b;for(a=0;b=Class.objectsToDestroy[a];a++){if(b.destroy){b.destroy()}}Class.objectsToDestroy=null}};Function.prototype.extend=function(b){var a=this;var c=function(){this[b]={};for(var d in window[b].prototype){if(!this[d]){this[d]=window[b].prototype[d]}this[b][d]=window[b].prototype[d].bind(this)}if(window[b].getInheritedStuff){window[b].getInheritedStuff.apply(this)}if(a.getInheritedStuff){a.getInheritedStuff.apply(this)}a.apply(this,arguments)};c.getInheritedStuff=function(){this[b]={};var d;for(d in window[b].prototype){if(!this[d]){this[d]=window[b].prototype[d]}this[b][d]=window[b].prototype[d].bind(this)}if(window[b].getInheritedStuff){window[b].getInheritedStuff.apply(this)}if(a.getInheritedStuff){a.getInheritedStuff.apply(this)}};return c};Function.prototype.bindAsEventListener=function(b){var a=this;return function(c){return a.call(b,c||window.event)}};Function.prototype.applyTo=function(a,h,g,f,e,d,c){if(typeof a=="string"){var b={};var i=this;b[a]={initialise:function(){behaveAs(this,i,h,g,f,e,d,c)}};Behaviour.register(b)}else{behaveAs(a,this)}};var _APPLYTOCHILDREN_GENERATED_IDS=0;Function.prototype.applyToChildren=function(b,f,e,d,c,a,h,g){if(!b.id){_APPLYTOCHILDREN_GENERATED_IDS++;b.id="atc-gen-id-"+_APPLYTOCHILDREN_GENERATED_IDS}this.applyTo("#"+b.id+" "+f)};if(typeof Behaviour=="undefined"){var Behaviour={isEventHandler:{onclick:true,onfocus:true,onblur:true,onmousedown:true,onmouseup:true,onmouseover:true,onmouseout:true,onclick:true},list:new Array,namedList:{},isDebugging:false,register:function(a,b){if(typeof a=="object"){Behaviour.list.push(a);if(Behaviour.alreadyApplied){Behaviour.process(a)}}else{Behaviour.list.push(b);Behaviour.namedList[a]=b;if(Behaviour.alreadyApplied){Behaviour.process(b)}}},start:function(){Behaviour.addLoader(function(){Behaviour.apply()})},debug:function(){Behaviour.isDebugging=true},apply:function(a,c){if(typeof(jQuery)!="undefined"&&typeof(jQuery.livequery)!="undefined"){jQuery.livequery.run()}if(Behaviour.isDebugging){console.time("Behaviour: apply took")}if(typeof a=="string"){a=document.getElementById(a)}var b;for(b=0;sheet=Behaviour.list[b];b++){Behaviour.process(sheet,a,c)}if(Behaviour.isDebugging){console.timeEnd("Behaviour: apply took")}Behaviour.alreadyApplied=true},reapply:function(a){if(typeof(jQuery)!="undefined"&&typeof(jQuery.livequery)!="undefined"){jQuery.livequery.run()}if(Behaviour.namedList[a]){Behaviour.process(Behaviour.namedList[a])}},process:function(g,e,h){var c;var a;var f;var d;var b="";for(a in g){if(!g[a]){continue}if(Behaviour.isDebugging){console.time("Behaviour: "+a)}f=document.getElementsBySelector(a,e);if(f&&f.length>0){if(Behaviour.isDebugging){console.log("Behaviour: %s: %d items, %o",a,f.length,f)}for(c=0;d=f[c];c++){if(e==d&&h!=true){continue}if(d.lastSelectorApplied!=g[a]){d.lastSelectorApplied=g[a];if(g[a].prototype){behaveAs(d,g[a])}else{var j;for(j in g[a]){if(d[j]&&!d["old_"+j]){d["old_"+j]=d[j]}if(g[a][j]){if(Behaviour.isEventHandler[j]){d[j]=g[a][j].bindAsEventListener(d)}else{d[j]=g[a][j]}}}if(g[a].initialise){d.initialise()}else{if(g[a].initialize){d.initialize()}}if(typeof g[a]=="undefined"){break}if(g[a].destroy){Class.registerForDestruction(d)}}}}}if(Behaviour.isDebugging){console.timeEnd("Behaviour: "+a)}}},addLoader:function(a){Behaviour.addEvent(window,"load",a)},addEvent:function(e,d,b,a){if(e.addEventListener){e.addEventListener(d,b,a);return true}else{if(e.attachEvent){var c=e.attachEvent("on"+d,b);return c}else{alert("Handler could not be attached")}}}};Behaviour.start()}function behaveAs(d,h,g,f,e,c,b,a){if(!d){return}d.initialize=null;var i;for(i in h.prototype){d[i]=h.prototype[i];if(i=="onclick"&&d[i]){d[i]=d[i].bindAsEventListener(d)}}h.apply(d,[g,f,e,c,b,a]);return d}function getAllChildren(a){return a.all?a.all:a.getElementsByTagName("*")}document.getElementsBySelector=function(w,l){if(!document.getElementsByTagName){return new Array()}var q=w.split(" ");var f=new Array(document);for(var y=0;y<q.length;y++){token=q[y].replace(/^\s+/,"").replace(/\s+$/,"");if(token.indexOf("#")>-1){var t=token.split("#");var d=t[0];var s=t[1];var b=document.getElementById(s);if(!b||(d&&b.nodeName.toLowerCase()!=d)){return new Array()}if(l&&!hasAncestor(b,l)&&!hasAncestor(l,b)){return new Array()}f=new Array(b);continue}if(token.indexOf(".")>-1){var t=token.split(".");var d=t[0];var c=t[1];if(!d){d="*"}var n=new Array;var g=0;for(var z=0;z<f.length;z++){var o;if(f[z]){if(d=="*"){o=getAllChildren(f[z])}else{o=f[z].getElementsByTagName(d)}for(var v=0;v<o.length;v++){n[g++]=o[v]}}}f=new Array;var r=0;if(t.length==2){for(var u=0;u<n.length;u++){if(n[u].className&&n[u].className.match(new RegExp("\\b"+c+"\\b"))){if(!l||hasAncestor(n[u],l)||hasAncestor(l,n[u])){f[r++]=n[u]}}}}else{var A=function(j){var h;if(!j.className){return false}for(h=1;h<t.length;h++){if(!j.className.match(new RegExp("\\b"+t[h]+"\\b"))){return false}}return true};for(var u=0;u<n.length;u++){if(A(n[u])){if(!l||hasAncestor(n[u],l)||hasAncestor(l,n[u])){f[r++]=n[u]}}}}continue}if(token.match(/^(\w*)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/)){var d=RegExp.$1;var x=RegExp.$2;var a=RegExp.$3;var p=RegExp.$4;if(!d){d="*"}var n=new Array;var g=0;for(var z=0;z<f.length;z++){if(f[z]){var o;if(d=="*"){o=getAllChildren(f[z])}else{o=f[z].getElementsByTagName(d)}for(var v=0;v<o.length;v++){if(!l||hasAncestor(o[v],l)||hasAncestor(l,o[v])){n[g++]=o[v]}}}}f=new Array;var r=0;var e;switch(a){case"=":e=function(h){return(h==p)};break;case"~":e=function(h){return(h.match(new RegExp("\\b"+p+"\\b")))};break;case"|":e=function(h){return(h.match(new RegExp("^"+p+"-?")))};break;case"^":e=function(h){return(h.indexOf(p)==0)};break;case"$":e=function(h){return(h.lastIndexOf(p)==h.length-p.length)};break;case"*":e=function(h){return(h.indexOf(p)>-1)};break;default:e=function(h){return h}}f=new Array;var r=0;for(var u=0;u<n.length;u++){var m=x=="class"?n[u].className:n[u].getAttribute(x);if(e(m)){if(!l||hasAncestor(n[u],l)||hasAncestor(l,n[u])){f[r++]=n[u]}}}continue}if(!f[0]){return}d=token;var n=new Array;var g=0;for(var z=0;z<f.length;z++){var o=f[z].getElementsByTagName(d);for(var v=0;v<o.length;v++){if(!l||hasAncestor(o[v],l)||hasAncestor(l,o[v])){n[g++]=o[v]}}}f=n}if(l){var y;for(y=0;y<f.length;y++){if(!hasAncestor(f[y],l)){f.splice(y,1)}}}return f};function hasAncestor(c,a){if(a){if(a.contains){return a==c||a.contains(c)}var b=c;while(b){if(b==a){return true}b=b.parentNode}}return false}Observable=Class.create();Observable.prototype={observe:function(b,a){return this.observeMethod(b,a["on"+Event].bind(a))},observeMethod:function(a,c){if(!this.observers){this.observers={}}if(!this.observers[a]){this.observers[a]=[]}var b=this.observers[a].length;this.observers[a][b]=c;return a+"|"+b},stopObserving:function(a){var b=a.split("|");if(this.observers&&this.observers[b[0]]&&this.observers[b[0]][b[1]]){this.observers[b[0]][b[1]]=null}else{throw ("Observeable.stopObserving: couldn't find '"+a+"'")}},notify:function(d,a){var b,c=true;if(this.observers&&this.observers[d]){for(b=0;b<this.observers[d].length;b++){if(this.observers[d][b]){if(this.observers[d][b](a)==false){c=false}}}}return c}};if(window.location.href.indexOf("debug_behaviour=")>-1){Behaviour.debug()};