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