
/*************
|       TITLE: Pulse.Player.ClosedCaptions Object
|     VERSION: 5.0 (alpha)
|    PERFORCE: $Id: //depot/main/src/Pulse.Player.JS/javascript/Pulse.Player.ClosedCaptions.js#35 $
|              $Change: 19552 $
|        TYPE: Object Definition
|      AUTHOR: Chris van Rensburg
|   COPYRIGHT: (c)2003-2004 Pulse Entertainment Inc. <http://www.pulse3d.com>
| DESCRIPTION: Implements a JavaScript object class that acts as an abstraction for the Pulse Player
|    REQUIRES: Pulse.Player.js
*************/

(function(){var _a=Pulse.Player,_b='undefined',_c=null;function _d(_e){return(typeof _e=='string')?((typeof document.getElementById!=_b)?document.getElementById(_e):_c):_e}var _f=_a.ClosedCaptions=function(_g){var _h=_a.getGIN(),_i=this;_i._h=_h;_i._j=(typeof _g!=_b&&typeof _g.targetPlayer!=_b)?_g.targetPlayer:_a.instances[_a.instances.length-1];_i._k=_i._l=_c;_i._m=false;_i.objectName=_h;_i.setupInstance(_g);_i.setText('',2000);_i._j.addEventHandler('Audio Stopped',_h+'.onAudioStopped ()');return _i;
},_n=_f.prototype;_a.inherit(_f,{_o:'element'});_f.set({_o:_c});_n._p=function(){var _i=this;if(_i._k!=_c){clearTimeout(_i._k);_i._k=_c;}};_n._q=function(_r){if(typeof _r=='string'){var _i=this,_s=_d(_i._o);if(_s!=_c){if(_i._l==_c)_i._l=_s.innerHTML;_s.innerHTML=_r;}}};_n._t=function(){var _s=_d(this._o);if(_s!=_c)_s.title=this._m?this._u:'';};_n.advance=function(){var _i=this,_v=_i._w,_s=_d(_i._o),_r,_x,_y,_z;_i._p();if(_s!=_c){if(_i._A<_i._u.length){_s.style.height='';_r=_x=_y=_z='';for(var _B=_i._A;_B<_i._u.length;_B++){var _C=_i._u.charAt(_B);_x+=_C;if(' .,;:-!?(){}[]'.indexOf(_C)!= -1||_B==_i._u.length-1){_i._w=' ,;:-({['.indexOf(_C)!= -1;_z='"'+(_v?'...':'')+_x+(_i._w?'...':'')+'"';_i._q(_z);if(_s.offsetWidth>_i._D||_s.offsetHeight>_i._E){break;}else{_r=_x;_y=_z;}}}_i._q(_y);_s.style.height=_i._E+'px';_i._A+=_r.length;var _F=Math.round(Math.round(_i._G/_i._u.length*_r.length));_i._k=setTimeout(_i._h+'.advance ()',(_i._A<_i._u.length)?_F:Math.max(1500,_F));}else{_i.stop();}}};
_n.onAudioStopped=function(){this._A=this._u.length;};_n.displayIfIdle=function(_r){if(!this._m){this._q(_r);this._t();}};_n.play=function(_u,_G){var _i=this;if(typeof _u!=_b||typeof _G!=_b)_i.setText(_u,_G);_i._A=0;if(_i._G>0){_i._m=true;_i._t();_i.fireEvent('Captions Started');if(_i._u!=''&&_d(_i._o)!=_c){_i.advance();}else{_i._k=setTimeout(_i._h+'.stop ()',_i._G);}}else{_i.stop();}};_n.restoreIfIdle=function(){this.displayIfIdle(this._l);};_n.setText=function(_u,_G){var _i=this,_s=_d(_i._o);_i.stop();_i._u=(typeof _u!=_b)?_u:'';_i._G=(typeof _G!=_b)?_G:0;_i._w=false;_i._D=_i._E=0;if(_s!=_c){_i._D=parseFloat(_s.style.width);_i._E=parseFloat(_s.style.height);}};_n.stop=function(){var _i=this;if(_i._m){_i._p();_i._m=false;_i.displayIfIdle(_i._l);_i.fireEvent('Captions Stopped');}};})();
