var EventSelectorsClass=Class.create();EventSelectorsClass.prototype={version:"1.1_pre_ss",rules:[],timers:[],windowLoaded:false,initialize:function(){Event.observe(window,"load",function(){this.windowLoaded=true;this._fireEventPhase("BINLoad",true)}.bind(this),false);Event.observe(document,"dom:loaded",this._fireEventPhase.bind(this,"DOMLoad",true),false)},register:function(rules,phase){if(phase===true){phase="BINLoad"}else{if(typeof(phase)=="undefined"||phase===false||phase!="BINLoad"){phase="DOMLoad"}}for(var selector in rules){switch(selector.toLowerCase()){case"window:binload":phase="BINLoad";break;case"window:domload":phase="DOMLoad";break}this.rules.push({selector:selector,func:rules[selector],phase:phase,applications:[]})}},apply:function(){this._fireEventPhase("DOMLoad",true);this._fireEventPhase("BINLoad",true)},_executeRule:function(rule,unredundantly){var selectors=$A(rule.selector.split(","));for(var x=0;x<selectors.length;x++){var selector=selectors[x];var pair=selector.split(":");var eventName=(pair.length>1)?pair[1]:"";var elements=(pair[0]=="window")?[window]:$$(pair[0]);for(var y=0;y<elements.length;y++){var element=elements[y];var event=false;var isRedundant=false;if(unredundantly===true){for(var z=0;z<rule.applications.length;z++){if(rule.applications[z].node.parentNode==null&&rule.applications[z].node!=window){rule.applications.splice(z,1)}else{if(rule.applications[z].node==element){isRedundant=true}}}}if((unredundantly===true&&isRedundant==false)||unredundantly!==true){switch(eventName.toLowerCase()){case"":case"load":case"binload":case"domload":case"loaded":if(pair[0]=="window"||eventName==""){rule.func(element)}else{this.timers[pair[0]]=setInterval(function(element,timer,rule){var node=$(element);if(element.tagName!="undefined"){clearInterval(this.timers[timer]);rule.func(node)}}.bind(this,element,pair[0],rule),15)}break;default:var event=Event.observe(element,eventName,rule.func.bind(this,element));break}rule.applications.push({node:element,event:event})}}}},_fireEventPhase:function(phase,unredundantly){if((phase=="BINLoad"&&this.windowLoaded)||phase!="BINLoad"){for(var x=0;x<this.rules.length;x++){if(this.rules[x].phase==phase){this._executeRule(this.rules[x],unredundantly)}}}},_unloadEventCache:function(){for(var i=0;i<this.rules.length;i++){for(var x=0;x<this.rules[i].applications.length;x++){Event.unObserve(this.rules[i].applications[x].event)}this.rules[i].applications=[]}}};EventSelectors=new EventSelectorsClass();EventSelectors.onDOMLoad=function(func){EventSelectors.register({"window:domload":func})};EventSelectors.onBINLoad=function(func){EventSelectors.register({"window:binload":func})};EventSelectors.addLoadEvent=EventSelectors.onBINLoad;Behaviour=EventSelectors;Ajax.Responders.register({onComplete:function(){EventSelectors.apply()}});