event-min.js revision d98d5e2bbc3fcf2015c549dd94c4c0371b3fdbe7
(function(){var E=YUI.Env,G=YUI.config,F=G.doc,B=G.pollInterval||20;if(!E._ready){E.windowLoaded=false;var A=function(C){E._ready();};E._ready=function(){if(!E.DOMReady){E.DOMReady=true;if(F.removeEventListener){F.removeEventListener("DOMContentLoaded",A,false);}}};if(navigator.userAgent.match(/MSIE/)){E._dri=setInterval(function(){try{document.documentElement.doScroll("left");clearInterval(E._dri);E._dri=null;A();}catch(C){}},B);}else{F.addEventListener("DOMContentLoaded",A,false);}}})();YUI.add("event",function(A){var h=A.UA.ie?"focusin":"focus",S=A.UA.ie?"focusout":"blur",l="capture_",m=A.Lang;A.Env.eventAdaptors={focus:{on:function(){arguments[0]=l+h;return A.Event.attach.apply(A.Event,arguments);},detach:function(){arguments[0]=l+h;return A.Event.detach.apply(A.Event,arguments);}},blur:{on:function(){arguments[0]=l+S;return A.Event.attach.apply(A.Event,arguments);},detach:function(){arguments[0]=l+S;return A.Event.detach.apply(A.Event,arguments);}},available:{on:function(n,Y,q,p){var L=arguments.length>4?A.Array(arguments,4,true):[];return A.Event.onAvailable.call(A.Event,q,Y,p,L);}},contentready:{on:function(n,Y,q,p){var L=arguments.length>4?A.Array(arguments,4,true):[];return A.Event.onContentReady.call(A.Event,q,Y,p,L);}},key:{on:function(p,r,L,v,Y){if(!v||v.indexOf(":")==-1){arguments[0]="keypress";return A.on.apply(A,arguments);}var q=v.split(":"),u=q[0],t=(q[1])?q[1].split(/,|\+/):null,n=(m.isString(L)?L:A.stamp(L))+v,s=A.Array(arguments,0,true);A.on(p+u,function(z){var AA=false,w=false;for(var x=0;x<t.length;x=x+1){var o=t[x],y=parseInt(o,10);if(m.isNumber(y)){if(z.charCode===y){AA=true;}else{w=true;}}else{if(AA||!w){AA=(z[o+"Key"]);w=!AA;}}}if(AA){A.fire(n,z);}},L);s.splice(2,2);s[0]=n;return A.on.apply(A,s);}}};A.on=function(Y,n,p){var L=A.Env.eventAdaptors[Y];if(L&&L.on){return L.on.apply(A,arguments);}else{if(L||Y.indexOf(":")>-1){return A.subscribe.apply(A,arguments);}else{return A.Event.attach.apply(A.Event,arguments);}}};A.detach=function(Y,n,p){var L=A.Env.eventAdaptors[Y];if(m.isObject(Y)&&Y.detach){return Y.detach();}else{if(L&&L.detach){return L.detach.apply(A,arguments);}else{if(L||Y.indexOf(":")>-1){return A.unsubscribe.apply(A,arguments);}else{return A.Event.detach.apply(A.Event,arguments);}}}};A.before=function(L,Y,n){if(m.isFunction(L)){return A.Do.before.apply(A.Do,arguments);}else{return A.on.apply(A,arguments);}};var X=A.after;A.after=function(L,Y,n){if(m.isFunction(L)){return A.Do.after.apply(A.Do,arguments);}else{return X.apply(A,arguments);}};var G=0,f=1;A.Do={objs:{},before:function(Y,o,p,q){var n=Y;if(q){var L=[Y,q].concat(A.Array(arguments,4,true));n=A.bind.apply(A,L);}return this._inject(G,n,o,p);},after:function(Y,o,p,q){var n=Y;if(q){var L=[Y,q].concat(A.Array(arguments,4,true));n=A.bind.apply(A,L);}return this._inject(f,n,o,p);},_inject:function(L,n,p,r){var s=A.stamp(p);if(!this.objs[s]){this.objs[s]={};}var q=this.objs[s];if(!q[r]){q[r]=new A.Do.Method(p,r);p[r]=function(){return q[r].exec.apply(q[r],arguments);};}var Y=s+A.stamp(n)+r;q[r].register(Y,n,L);return new A.EventHandle(q[r],Y);},detach:function(L){if(L.detach){L.detach();}},_unload:function(Y,L){}};A.Do.Method=function(L,Y){this.obj=L;this.methodName=Y;this.method=L[Y];this.before={};this.after={};};A.Do.Method.prototype.register=function(Y,n,L){if(L){this.after[Y]=n;}else{this.before[Y]=n;}};A.Do.Method.prototype._delete=function(L){delete this.before[L];delete this.after[L];};A.Do.Method.prototype.exec=function(){var n=A.Array(arguments,0,true),o,Y,r,p=this.before,L=this.after,q=false;for(o in p){if(p.hasOwnProperty(o)){Y=p[o].apply(this.obj,n);if(Y){switch(Y.constructor){case A.Do.Halt:return Y.retVal;case A.Do.AlterArgs:n=Y.newArgs;break;case A.Do.Prevent:q=true;break;default:}}}}if(!q){Y=this.method.apply(this.obj,n);}for(o in L){if(L.hasOwnProperty(o)){r=L[o].apply(this.obj,n);if(r&&r.constructor==A.Do.Halt){return r.retVal;}else{if(r&&r.constructor==A.Do.AlterReturn){Y=r.newRetVal;}}}}return Y;};A.Do.AlterArgs=function(Y,L){this.msg=Y;this.newArgs=L;};A.Do.AlterReturn=function(Y,L){this.msg=Y;this.newRetVal=L;};A.Do.Halt=function(Y,L){this.msg=Y;this.retVal=L;};A.Do.Prevent=function(L){this.msg=L;};A.Do.Error=A.Do.Halt;var Q="_event:onsub",f="after",e=["broadcast","bubbles","context","configured","currentTarget","defaultFn","details","emitFacade","fireOnce","host","preventable","preventedFn","queuable","silent","stoppedFn","target","type"],T=9;A.EventHandle=function(L,Y){this.evt=L;this.sub=Y;};A.EventHandle.prototype={detach:function(){if(this.evt){this.evt._delete(this.sub);}}};A.CustomEvent=function(L,Y){Y=Y||{};this.id=A.stamp(this);this.type=L;this.context=A;this.logSystem=(L=="yui:log");this.broadcast=0;this.silent=this.logSystem;this.queuable=false;this.subscribers={};this.afters={};this.fired=false;this.fireOnce=false;this.stopped=0;this.prevented=0;this.host=null;this.defaultFn=null;this.stoppedFn=null;this.preventedFn=null;this.preventable=true;this.bubbles=true;this.signature=T;this.emitFacade=false;this.applyConfig(Y,true);this.log("Creating "+this.type);if(L!==Q){this.subscribeEvent=new A.CustomEvent(Q,{context:this,silent:true});}};A.CustomEvent.prototype={_YUI_EVENT:true,applyConfig:function(Y,L){if(Y){A.mix(this,Y,L,e);}},_subscribe:function(o,q,Y,L){if(!o){A.fail("Invalid callback for CE: "+this.type);}var p=this.subscribeEvent;if(p){p.fire.apply(p,Y);}var n=new A.Subscriber(o,q,Y,L);if(this.fireOnce&&this.fired){A.later(0,this,this._notify,n);}if(L==f){this.afters[n.id]=n;}else{this.subscribers[n.id]=n;}return new A.EventHandle(this,n);},subscribe:function(L,Y){return this._subscribe(L,Y,arguments,true);},after:function(L,Y){return this._subscribe(L,Y,arguments,f);},unsubscribe:function(o,q){if(o&&o.detach){return o.detach();}if(!o){return this.unsubscribeAll();}var p=false,Y=this.subscribers;for(var L in Y){if(Y.hasOwnProperty(L)){var n=Y[L];if(n&&n.contains(o,q)){this._delete(n);p=true;}}}return p;},_getFacade:function(Y){var L=this._facade;if(!L){L=new A.Event.Facade(this,this.currentTarget);
}var n=Y&&Y[0];if(A.Lang.isObject(n,true)&&!n._yuifacade){A.mix(L,n,true);}L.details=this.details;L.target=this.target;L.currentTarget=this.currentTarget;L.stopped=0;L.prevented=0;this._facade=L;return this._facade;},_notify:function(p,n,L){this.log(this.type+"->"+": "+p);var Y,q,o;if(this.emitFacade){if(!L){L=this._getFacade(n);n[0]=L;}}o=(n&&A.Lang.isObject(n[0])&&n[0].currentTarget);Y=p.notify(o||this.context,n,this);if(false===Y||this.stopped>1){this.log(this.type+" cancelled by subscriber");return false;}return true;},log:function(o,L){var n=A.Env._eventstack,Y=n&&n.logging;if(!this.silent){}},fire:function(){var w=A.Env._eventstack;if(w){if(this.queuable&&this.type!=w.next.type){this.log("queue "+this.type);w.queue.push([this,arguments]);return true;}}else{A.Env._eventstack={id:this.id,next:this,silent:this.silent,logging:(this.type==="yui:log"),stopped:0,prevented:0,queue:[]};w=A.Env._eventstack;}var u=true;if(this.fireOnce&&this.fired){this.log("fireOnce event: "+this.type+" already fired");}else{var n=A.merge(this.subscribers),x,v=A.Array(arguments,0,true),o;this.stopped=0;this.prevented=0;this.target=this.target||this.host;this.currentTarget=this.host||this.currentTarget;this.fired=true;this.details=v.slice();this.log("Firing "+this.type);var t=false;w.lastLogState=w.logging;var p=null;if(this.emitFacade){this._facade=null;p=this._getFacade(v);v[0]=p;}for(o in n){if(n.hasOwnProperty(o)){if(!t){w.logging=(w.logging||(this.type==="yui:log"));t=true;}if(this.stopped==2){break;}x=n[o];if(x&&x.fn){u=this._notify(x,v,p);if(false===u){this.stopped=2;}}}}w.logging=(w.lastLogState);if(this.bubbles&&this.host&&!this.stopped){w.stopped=0;w.prevented=0;u=this.host.bubble(this);this.stopped=Math.max(this.stopped,w.stopped);this.prevented=Math.max(this.prevented,w.prevented);}if(this.defaultFn&&!this.prevented){this.defaultFn.apply(this.host||this,v);}if(!this.prevented&&this.stopped<2){n=A.merge(this.afters);for(o in n){if(n.hasOwnProperty(o)){if(!t){w.logging=(w.logging||(this.type==="yui:log"));t=true;}if(this.stopped==2){break;}x=n[o];if(x&&x.fn){u=this._notify(x,v,p);if(false===u){this.stopped=2;}}}}}}if(w.id===this.id){var r=w.queue;while(r.length){var L=r.pop(),Y=L[0];w.stopped=0;w.prevented=0;w.next=Y;u=Y.fire.apply(Y,L[1]);}A.Env._eventstack=null;}return(u!==false);},unsubscribeAll:function(){var n=this.subscribers,Y,L=0;for(Y in n){if(n.hasOwnProperty(Y)){this._delete(n[Y]);L++;}}this.subscribers={};return L;},_delete:function(L){if(L){delete L.fn;delete L.obj;delete this.subscribers[L.id];delete this.afters[L.id];}},toString:function(){return this.type;},stopPropagation:function(){this.stopped=1;A.Env._eventstack.stopped=1;if(this.stoppedFn){this.stoppedFn.call(this.host||this,this);}},stopImmediatePropagation:function(){this.stopped=2;A.Env._eventstack.stopped=2;if(this.stoppedFn){this.stoppedFn.call(this.host||this,this);}},preventDefault:function(){if(this.preventable){this.prevented=1;A.Env._eventstack.prevented=1;}if(this.preventedFn){this.preventedFn.call(this.host||this,this);}}};A.Subscriber=function(Y,n,L){this.fn=Y;this.obj=n;this.id=A.stamp(this);this.wrappedFn=Y;if(n){this.wrappedFn=A.bind.apply(A,L);}};A.Subscriber.prototype={notify:function(L,n,q){var r=this.obj||L,Y=true,o=function(){switch(q.signature){case 0:Y=this.fn.call(r,q.type,n,this.obj);break;case 1:Y=this.fn.call(r,n[0]||null,this.obj);break;default:Y=this.wrappedFn.apply(r,n||[]);}};if(A.config.throwFail){o.call(this);}else{try{o.call(this);}catch(p){A.fail(this+" failed: "+p.message,p);}}return Y;},contains:function(L,Y){if(Y){return((this.fn==L)&&this.obj==Y);}else{return(this.fn==L);}},toString:function(){return"Subscriber "+this.id;}};var W={"yui:log":true},D=A.Lang;A.EventTarget=function(L){var Y=(D.isObject(L))?L:{};this._yuievt={events:{},targets:{},config:Y,defaults:{context:this,host:this,emitFacade:Y.emitFacade||false,bubbles:("bubbles" in Y)?Y.bubbles:true}};};var P=A.EventTarget;P.prototype={subscribe:function(r,s,L){if(D.isObject(r)){var n=s,q=L,p=A.Array(arguments,0,true),o={};A.each(r,function(w,u){if(w){n=w.fn||n;q=w.context||q;}p[0]=u;p[1]=n;p[2]=q;o[u]=this.subscribe.apply(this,p);},this);return o;}var Y=this._yuievt.events[r]||this.publish(r),t=A.Array(arguments,1,true);return Y.subscribe.apply(Y,t);},unsubscribe:function(q,p,o){if(D.isObject(q)&&q.detach){return q.detach();}var L=this._yuievt.events;if(q){var r=L[q];if(r){return r.unsubscribe(p,o);}}else{var Y=true;for(var n in L){if(L.hasOwnProperty(n)){Y=Y&&L[n].unsubscribe(p,o);}}return Y;}return false;},unsubscribeAll:function(L){return this.unsubscribe(L);},publish:function(n,p){if(D.isObject(n)){var L={};A.each(n,function(s,o){L[o]=this.publish(o,s||p);},this);return L;}var Y=this._yuievt.events,q=Y[n];if(q){q.applyConfig(p,true);}else{var r=p||{};A.mix(r,this._yuievt.defaults);q=new A.CustomEvent(n,r);Y[n]=q;if(r.onSubscribeCallback){q.subscribeEvent.subscribe(r.onSubscribeCallback);}}return Y[n];},addTarget:function(L){this._yuievt.targets[A.stamp(L)]=L;this._yuievt.hasTargets=true;},removeTarget:function(L){delete this._yuievt.targets[A.stamp(L)];},fire:function(o){var q=D.isString(o),n=(q)?o:(o&&o.type);var p=this.getEvent(n);if(!p){if(this._yuievt.hasTargets){p=this.publish(n);p.details=A.Array(arguments,(q)?1:0,true);return this.bubble(p);}return true;}var L=A.Array(arguments,(q)?1:0,true);var Y=p.fire.apply(p,L);p.target=null;return Y;},getEvent:function(L){var Y=this._yuievt.events;return(Y&&L in Y)?Y[L]:null;},bubble:function(Y){var r=this._yuievt.targets,n=true;if(!Y.stopped&&r){for(var p in r){if(r.hasOwnProperty(p)){var o=r[p],q=Y.type,s=o.getEvent(q),L=Y.target||this;if(!s){s=o.publish(q,Y);s.context=(Y.host===Y.context)?o:Y.context;s.host=o;s.defaultFn=null;s.preventedFn=null;s.stoppedFn=null;}s.target=L;s.currentTarget=o;n=n&&s.fire.apply(s,Y.details);if(s.stopped){break;}}}}return n;},after:function(n,Y){if(D.isFunction(n)){return A.Do.after.apply(A.Do,arguments);}else{var o=this._yuievt.events[n]||this.publish(n),L=A.Array(arguments,1,true);
return o.after.apply(o,L);}},before:function(Y,L){if(D.isFunction(Y)){return A.Do.after.apply(A.Do,arguments);}else{return this.subscribe.apply(this,arguments);}}};A.mix(A,P.prototype,false,false,{bubbles:false});P.call(A);var g=YUI.Env;A.mix(A.Env.eventAdaptors,{domready:{},"event:ready":{on:function(){arguments[0]="domready";return A.subscribe.apply(A,arguments);},detach:function(){arguments[0]="domready";return A.unsubscribe.apply(A,arguments);}}});A.publish("domready",{fireOnce:true});var O=function(){A.fire("domready");};if(g.DOMReady){O();}else{A.before(O,g,"_ready");}var B=function(o,n,Y,L){if(o.addEventListener){o.addEventListener(n,Y,!!L);}else{if(o.attachEvent){o.attachEvent("on"+n,Y);}}},N=function(o,n,Y,L){if(o.removeEventListener){o.removeEventListener(n,Y,!!L);}else{if(o.detachEvent){o.detachEvent("on"+n,Y);}}},d=function(){YUI.Env.windowLoaded=true;A.Event._load();N(window,"load",d);},M=function(){A.Event._unload();N(window,"unload",M);},j="domready",H="~yui|2|compat~",l="capture_";A.Event=function(){var n=false;var o=0;var Y=[];var p={};var L=null;var q={};return{POLL_RETRYS:2000,POLL_INTERVAL:20,lastError:null,_interval:null,_dri:null,DOMReady:false,startInterval:function(){var r=A.Event;if(!r._interval){r._interval=setInterval(A.bind(r._tryPreloadAttach,r),r.POLL_INTERVAL);}},onAvailable:function(y,u,x,w,v,s){var r=A.Array(y);for(var t=0;t<r.length;t=t+1){Y.push({id:r[t],fn:u,obj:x,override:w,checkReady:v,compat:s});}o=this.POLL_RETRYS;setTimeout(A.bind(A.Event._tryPreloadAttach,A.Event),0);return new A.EventHandle();},onContentReady:function(v,s,u,t,r){return this.onAvailable(v,s,u,t,true,r);},attach:function(x,z,s,AA){var w=A.Array(arguments,0,true),v=w.slice(1),y,AB=A.Event,AE=false;if(x.indexOf(l)>-1){x=x.substr(l.length);AE=true;}if(v[v.length-1]===H){y=true;v.pop();}if(!z||!z.call){return false;}if(this._isValidCollection(s)){var r=[],AG,AF;A.each(s,function(AK,AJ){w[2]=AK;r.push(AB.attach.apply(AB,w));});return(r.length===1)?r[0]:r;}else{if(A.Lang.isString(s)){var AD=(y)?A.DOM.byId(s):A.all(s);if(AD&&(AD instanceof A.Node)){var AC=AD.size();if(AC>1){w[2]=AD;return AB.attach.apply(AB,w);}else{s=AD.item(0);}}else{if(AD){s=AD;}else{return this.onAvailable(s,function(){AB.attach.apply(AB,w);},AB,true,false,y);}}}}if(!s){return false;}var t=A.stamp(s),AI="event:"+t+x,AH=p[AI];if(!AH){AH=A.publish(AI,{silent:true,bubbles:false});AH.el=s;AH.type=x;AH.fn=function(AJ){AH.fire(AB.getEvent(AJ,s,y));};if(s==A.config.win&&x=="load"){AH.fireOnce=true;L=AI;if(YUI.Env.windowLoaded){AH.fire();}}p[AI]=AH;q[t]=q[t]||{};q[t][AI]=AH;B(s,x,AH.fn,AE);}var u=v[2]||((y)?s:A.get(s));v[1]=u;v.splice(2,1);return AH.subscribe.apply(AH,v);},detach:function(y,AA,t,u){var x=A.Array(arguments,0,true),AC;if(x[x.length-1]===H){AC=true;}if(y&&y.detach){return y.detach();}var v,w,AB;if(typeof t=="string"){t=(AC)?A.DOM.byId(t):A.all(t);}else{if(this._isValidCollection(t)){var z=true;for(v=0,w=t.length;v<w;++v){x[2]=t[v];z=(A.Event.detach.apply(A.Event,x)&&z);}return z;}}if(!AA||!AA.call){return this.purgeElement(t,false,y);}var r="event:"+A.stamp(t)+y,s=p[r];if(s){return s.unsubscribe(AA);}else{return false;}},getEvent:function(u,s,r){var t=u||window.event;return(r)?t:new A.Event.Facade(t,s,p["event:"+A.stamp(s)+u.type]);},generateId:function(r){var s=r.id;if(!s){s=A.stamp(r);r.id=s;}return s;},_isValidCollection:function(s){try{return(s&&typeof s!=="string"&&(s.length&&((!s.size)||(s.size()>1)))&&!s.tagName&&!s.alert&&(s.item||typeof s[0]!=="undefined"));}catch(r){return false;}},_load:function(r){if(!n){n=true;if(A.fire){A.fire(j);}A.Event._tryPreloadAttach();}},_tryPreloadAttach:function(){if(this.locked){return;}if(A.UA.ie&&!YUI.Env.DOMReady){this.startInterval();return;}this.locked=true;var w=!n;if(!w){w=(o>0);}var v=[];var x=function(AA,AB){var z,y=AB.override;if(AB.compat){if(AB.override){if(y===true){z=AB.obj;}else{z=y;}}else{z=AA;}AB.fn.call(z,AB.obj);}else{z=AB.obj||A.get(AA);AB.fn.apply(z,(A.Lang.isArray(y))?y:[]);}};var s,r,u,t;for(s=0,r=Y.length;s<r;++s){u=Y[s];if(u&&!u.checkReady){t=(u.compat)?A.DOM.byId(u.id):A.get(u.id);if(t){x(t,u);Y[s]=null;}else{v.push(u);}}}for(s=0,r=Y.length;s<r;++s){u=Y[s];if(u&&u.checkReady){t=(u.compat)?A.DOM.byId(u.id):A.get(u.id);if(t){if(n||(t.get&&t.get("nextSibling"))||t.nextSibling){x(t,u);Y[s]=null;}}else{v.push(u);}}}o=(v.length===0)?0:o-1;if(w){this.startInterval();}else{clearInterval(this._interval);this._interval=null;}this.locked=false;return;},purgeElement:function(w,x,v){var t=(A.Lang.isString(w))?A.get(w):w,y=A.stamp(t);var s=this.getListeners(t,v),u,r;if(s){for(u=0,r=s.length;u<r;++u){s[u].unsubscribeAll();}}if(x&&t&&t.childNodes){for(u=0,r=t.childNodes.length;u<r;++u){this.purgeElement(t.childNodes[u],x,v);}}},getListeners:function(v,u){var w=A.stamp(v),r=q[w];if(!r){return null;}var t=[],s=(u)?"event:"+u:null;if(s){if(r[s]){t.push(r[s]);}}else{A.each(r,function(y,x){t.push(y);});}return(t.length)?t:null;},_unload:function(s){var r=A.Event;A.each(p,function(u,t){u.unsubscribeAll();N(u.el,u.type,u.fn);delete p[t];});N(window,"load",r._load);N(window,"unload",r._unload);},nativeAdd:B,nativeRemove:N};}();B(window,"load",d);B(window,"unload",M);var Z=A.Event;if(A.UA.ie&&A.on){A.on(j,Z._tryPreloadAttach,Z,true);}Z.Custom=A.CustomEvent;Z.Subscriber=A.Subscriber;Z.Target=A.EventTarget;Z._tryPreloadAttach();var b={"altKey":1,"cancelBubble":1,"ctrlKey":1,"clientX":1,"clientY":1,"detail":1,"keyCode":1,"metaKey":1,"shiftKey":1,"type":1,"x":1,"y":1};var c=A.UA,i={63232:38,63233:40,63234:37,63235:39,63276:33,63277:34,25:9},K=function(Y){if(!Y){return null;}try{if(c.webkit&&3==Y.nodeType){Y=Y.parentNode;}}catch(L){}return A.Node.get(Y);};A.Event.Facade=function(w,n,Y,L){var r=w,p=n,s=A.config.doc,z=s.body,AA=r.pageX,v=r.pageY,o=(w._YUI_EVENT);for(var q in b){if(b.hasOwnProperty(q)){this[q]=r[q];}}if(!AA&&0!==AA){AA=r.clientX||0;v=r.clientY||0;if(c.ie){AA+=Math.max(s.documentElement.scrollLeft,z.scrollLeft);v+=Math.max(s.documentElement.scrollTop,z.scrollTop);
}}this._yuifacade=true;this.pageX=AA;this.pageY=v;var u=r.keyCode||r.charCode||0;if(c.webkit&&(u in i)){u=i[u];}this.keyCode=u;this.charCode=u;this.button=r.which||r.button;this.which=this.button;this.details=L;this.time=r.time||new Date().getTime();this.target=(o)?r.target:K(r.target||r.srcElement);this.currentTarget=(o)?p:K(p);var AB=r.relatedTarget;if(!AB){if(r.type=="mouseout"){AB=r.toElement;}else{if(r.type=="mouseover"){AB=r.fromElement;}}}this.relatedTarget=(o)?AB:K(AB);this.stopPropagation=function(){if(r.stopPropagation){r.stopPropagation();}else{r.cancelBubble=true;}if(Y){Y.stopPropagation();}};this.stopImmediatePropagation=function(){if(r.stopImmediatePropagation){r.stopImmediatePropagation();}else{this.stopPropagation();}if(Y){Y.stopImmediatePropagation();}};this.preventDefault=function(){if(r.preventDefault){r.preventDefault();}else{r.returnValue=false;}if(Y){Y.preventDefault();}};this.halt=function(t){if(t){this.stopImmediatePropagation();}else{this.stopPropagation();}this.preventDefault();};};var D=A.Lang,C=A.Array,I=D.isFunction,F=D.isString,R=D.isBoolean,V=D.isObject,k=D.isNumber,U=["click","dblclick","mouseover","mouseout","mousedown","mouseup","mousemove"],a=["keydown","keyup","keypress"];function E(q,u,p,n,w,Y,L,v,s,y,x){if(!q){A.fail("simulateKeyEvent(): Invalid target.");}if(F(u)){u=u.toLowerCase();switch(u){case"textevent":u="keypress";case"keyup":case"keydown":case"keypress":break;default:A.fail("simulateKeyEvent(): Event type '"+u+"' not supported.");}}else{A.fail("simulateKeyEvent(): Event type must be a string.");}if(!R(p)){p=true;}if(!R(n)){n=true;}if(!V(w)){w=window;}if(!R(Y)){Y=false;}if(!R(L)){L=false;}if(!R(v)){v=false;}if(!R(s)){s=false;}if(!k(y)){y=0;}if(!k(x)){x=0;}var t=null;if(I(document.createEvent)){try{t=document.createEvent("KeyEvents");t.initKeyEvent(u,p,n,w,Y,L,v,s,y,x);}catch(r){try{t=document.createEvent("Events");}catch(o){t=document.createEvent("UIEvents");}finally{t.initEvent(u,p,n);t.view=w;t.altKey=L;t.ctrlKey=Y;t.shiftKey=v;t.metaKey=s;t.keyCode=y;t.charCode=x;}}q.dispatchEvent(t);}else{if(V(document.createEventObject)){t=document.createEventObject();t.bubbles=p;t.cancelable=n;t.view=w;t.ctrlKey=Y;t.altKey=L;t.shiftKey=v;t.metaKey=s;t.keyCode=(x>0)?x:y;q.fireEvent("on"+u,t);}else{A.fail("simulateKeyEvent(): No event simulation framework present.");}}}function J(v,AA,s,p,AB,u,r,q,o,Y,n,L,z,x,t,w){if(!v){A.fail("simulateMouseEvent(): Invalid target.");}if(F(AA)){AA=AA.toLowerCase();if(C.indexOf(U,AA)==-1){A.fail("simulateMouseEvent(): Event type '"+AA+"' not supported.");}}else{A.fail("simulateMouseEvent(): Event type must be a string.");}if(!R(s)){s=true;}if(!R(p)){p=(AA!="mousemove");}if(!V(AB)){AB=window;}if(!k(u)){u=1;}if(!k(r)){r=0;}if(!k(q)){q=0;}if(!k(o)){o=0;}if(!k(Y)){Y=0;}if(!R(n)){n=false;}if(!R(L)){L=false;}if(!R(z)){z=false;}if(!R(x)){x=false;}if(!k(t)){t=0;}var y=null;if(I(document.createEvent)){y=document.createEvent("MouseEvents");if(y.initMouseEvent){y.initMouseEvent(AA,s,p,AB,u,r,q,o,Y,n,L,z,x,t,w);}else{y=document.createEvent("UIEvents");y.initEvent(AA,s,p);y.view=AB;y.detail=u;y.screenX=r;y.screenY=q;y.clientX=o;y.clientY=Y;y.ctrlKey=n;y.altKey=L;y.metaKey=x;y.shiftKey=z;y.button=t;y.relatedTarget=w;}if(w&&!y.relatedTarget){if(AA=="mouseout"){y.toElement=w;}else{if(AA=="mouseover"){y.fromElement=w;}}}v.dispatchEvent(y);}else{if(V(document.createEventObject)){y=document.createEventObject();y.bubbles=s;y.cancelable=p;y.view=AB;y.detail=u;y.screenX=r;y.screenY=q;y.clientX=o;y.clientY=Y;y.ctrlKey=n;y.altKey=L;y.metaKey=x;y.shiftKey=z;switch(t){case 0:y.button=1;break;case 1:y.button=4;break;case 2:break;default:y.button=0;}y.relatedTarget=w;v.fireEvent("on"+AA,y);}else{A.fail("simulateMouseEvent(): No event simulation framework present.");}}}C.each(U,function(L){A.Event[L]=function(n,Y){Y=Y||{};J(n,L,Y.bubbles,Y.cancelable,Y.view,Y.detail,Y.screenX,Y.screenY,Y.clientX,Y.clientY,Y.ctrlKey,Y.altKey,Y.shiftKey,Y.metaKey,Y.button,Y.relatedTarget);};});C.each(a,function(L){A.Event[L]=function(n,Y){Y=Y||{};E(n,L,Y.bubbles,Y.cancelable,Y.view,Y.ctrlKey,Y.altKey,Y.shiftKey,Y.metaKey,Y.keyCode,Y.charCode);};});A.Event.simulate=function(n,Y,L){if(I(A.Event[Y])){A.Event[Y](n,L);}};},"@VERSION@");