{************************
	display the usage of the page.
	actually this measures the number of calls to eventScheduler.schedule() functions
*************************}

<span style="text-align: right;">
	<div
		id="pageStatus2_details"
		style="color: #844; font-size: 8px;"
		>&nbsp;</div>
	<div
		id="pageStatus2"
		style="background-color: #c88; width: 0px; height: 1px; overflow: hidden;"
		>&nbsp;</div>
</span>

{strip2}
	{literal}
	<script type="text/javascript">
		/*
		 * this can display a load-like bar
		 * not really necesarry for now
		 * */
		_eventScheduler.prototype.throbberFunction = function(add , eventStr , id ,timeout){
			if(isNaN(this.heap['eventCount']))this.heap['eventCount']=0;
			if(isNaN(this.heap['lastUpdate']))this.heap['lastUpdate']=0;

			this.heap['totalEvents']=0;

			var now=new Date().getTime();

			if(isNaN(this.heap['events_per_sec']))this.heap['events_per_sec']=now;

			this.heap['eventCount']++;

			var s=(now-this.heap['lastUpdate'])/1000;
			if(s > 1){
				if(isNaN(Controls.getGlobal('expensiveCalls')))Controls.setGlobal('expensiveCalls',0);

				this.heap['events_per_sec']=((2*this.heap['eventCount'] + Controls.getGlobal('expensiveCalls')) + this.heap['events_per_sec'])/(3*s);

				Controls.setGlobal('expensiveCalls',0);
				this.heap['eventCount']=0;
				this.heap['lastUpdate']=now;

				this.heap['usage']=this.heap['events_per_sec']/10;
			}

			for(var i in this.events){
				if(!Object.isFunction(this.events[i]) && this.events[i]){
					this.heap['totalEvents']++;
				}
			}

			var newWidth=Math.round(Number(this.heap['events_per_sec']).toFixed(3)*5);

			if(newWidth!=this.effect_value){
				this.effect_value=newWidth;

				$('pageStatus2_details').update(Math.round(this.effect_value)+'['+this.heap['totalEvents']+']');

				if(this.effect_value<=1)this.effect_value=2;
				this.effect_value=Math.log(this.effect_value);
				this.effect_value=this.effect_value*this.effect_value*5;

				if(this.effect_value>65)this.effect_value=65;

				if(!this.timeout){
					if(this.effect_morph && this.effect_morph.state!='finished')this.effect_morph.cancel();
					this.effect_morph=new Effect.Morph($('pageStatus2'),{
											style:{	'width':this.effect_value+'px'},
											queue:{position: 'end', scope: 'loadAvg'},
											duration:1
									}
								);

					this.timeout=setTimeout("eventScheduler.schedule('_eventScheduler.throbberFunction',function(){eventScheduler.timeout=false;},1.0);",0);
				}
			}
		}
	</script>
	{/literal}
{/strip2}