
/*
	"Hemi" JavaScript Framework
	Engine for Web Applications 3.1
	Composite file "hemi.comp.js" release: 3.1.1
	Copyright 2002 - 2010. All Rights Reserved.
	Author: Stephen W. Cote
	Email: sw.cote@gmail.com
	Project: http://www.whitefrost.com/Hemi/
	BSD License: http://www.whitefrost.com/Hemi.license.txt
*/
(function(){H.namespace("util.thread",H,{newInstance:
function(o){if(!H.registry.service.isRegistered(o)){H.message.service.S("Object must be registered to use a thread.","200.4",1);return 0;}var n=H.FN("base_object","thread","3.1.1");n.p={r:"handle_thread_run",s:"handle_thread_start",t:"handle_thread_stop",d:1000,u:0,i:0,m:0,z:o.i,y:0};n.o={o:o};n.restart=function(){if(!this.stop(1)||!this.run(this.p.u,1))return 0;return 1;};n.getLastInterval=function(){return this.p.u;};n.run=function(d,b){var t=this,_s;_s=t.p;if(!t.getIsRunnable()||_s.i)return 0;if(!D.TN(d)||d<0)d=_s.d;_s.u=d;_s.m=1;if(!b&&D.TF(t.o.o[_s.s]))t.o.o[_s.s](t);_s.i=window.setInterval("H.registry.service.getObject('"+t.i+"').R()",d);return 1;};n.R=function(){var t=this,_s,_p;_s=t.p;_p=t.o;if(!_s.i||_s.y)return 0;if(D.TO(_p.o)&&_p.o.r>4){if(!t.stop())_s.y=1;return 0;}try{_p.o[_s.r](t);if(_s.m==2){_s.i=0;_s.m=0}}catch(e){if(_s.m==1)window.clearInterval(_s.i);_s.i=0;}return 1;};n.allStop=function(){this.p.y=1;this.stop();};n.stop=function(b){var t=this,_s;_s=t.p;if(!_s.i)return 0;if(_s.m==2){window.clearTimeout(_s.i);}else if(_s.m==1){window.clearInterval(_s.i);}else{return 0;}if(!b&&D.TF(t.o.o[_s.t]))t.o.o[_s.t](t);_s.m=0;_s.i=0;return 1;};n.getIsRunning=function(){if(this.p.i)return 1;return 0;};n.getIsRunnable=function(){var o=this.o.o;if(D.TO(o)&&typeof D.TF(o[this.p.r]))return 1;return 0;};n.destroy=function(){var t=this;if(t.r<5){t.stop();t.r=5;H.message.service.unsubscribe(t,"onremoveobject","H");H.registry.service.removeObject(t);}};n.H=function(s,i){if(i==this.p.z){this.destroy();}};H.registry.service.addObject(n);H.message.service.subscribe(n,"onremoveobject","H");o=0;return n;}});}());
/* End Hemi Framework 3.1 */
