/*
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.com/yui/license.html
version: 3.2.0
build: nightly
*/
YUI.add("event-valuechange",function(C){var B=C.Array,A={POLL_INTERVAL:50,TIMEOUT:10000,_history:{},_intervals:{},_notifiers:{},_timeouts:{},_poll:function(G,E,H){var D=G._node.value,I=A._history[E],F;if(D!==I){A._history[E]=D;F={_event:H,newVal:D,prevVal:I};B.each(A._notifiers[E],function(J){J.fire(F);});A._refreshTimeout(G,E);}},_refreshTimeout:function(E,D){A._stopTimeout(E,D);A._timeouts[D]=setTimeout(function(){A._stopPolling(E,D);},A.TIMEOUT);},_startPolling:function(E,D,G,F){if(!D){D=C.stamp(E);}if(!F&&A._intervals[D]){return;}A._stopPolling(E,D);A._intervals[D]=setInterval(function(){A._poll(E,D,G);},A.POLL_INTERVAL);A._refreshTimeout(E,D,G);},_stopPolling:function(E,D){if(!D){D=C.stamp(E);}A._intervals[D]=clearInterval(A._intervals[D]);A._stopTimeout(E,D);},_stopTimeout:function(E,D){if(!D){D=C.stamp(E);}A._timeouts[D]=clearTimeout(A._timeouts[D]);},_onBlur:function(D){A._stopPolling(D.currentTarget);},_onKeyDown:function(D){A._startPolling(D.currentTarget,null,D);},_onKeyUp:function(D){if(D.charCode===229||D.charCode===197){A._startPolling(D.currentTarget,null,D,true);}},_onMouseDown:function(D){A._startPolling(D.currentTarget,null,D);},_onSubscribe:function(H,G,F){var E=C.stamp(H),D=A._notifiers[E];A._history[E]=H.get("value");F._handles=H.on({blur:A._onBlur,keydown:A._onKeyDown,keyup:A._onKeyUp,mousedown:A._onMouseDown});if(!D){D=A._notifiers[E]=[];}D.push(F);},_onUnsubscribe:function(I,H,G){var F=C.stamp(I),D=A._notifiers[F],E=B.indexOf(D,G);G._handles.detach();if(E!==-1){D.splice(E,1);if(!D.length){A._stopPolling(I,F);delete A._notifiers[F];delete A._history[F];}}}};C.Event.define("valueChange",{detach:A._onUnsubscribe,on:A._onSubscribe,publishConfig:{emitFacade:true}});C.ValueChange=A;},"3.2.0",{requires:["event-focus","event-synthetic"]});