/* ---------------------------------------- Polling Object */
function oPoll(name, functionCall, initialFrequency, maximumFrequency, frequencyStep, stepCount) {
	this.name=name;
	this.functionCall=functionCall;

	this.initialFrequency=initialFrequency;
	this.maximumFrequency=maximumFrequency;
	this.frequencyStep=frequencyStep;
	this.stepCount=stepCount;
	
	this.resetFrequency();
	this.current=0;
	this.suspended=false;}

oPoll.prototype.resetFrequency=function() {
	this.frequency=this.initialFrequency;
	this.step=0;}
	
oPoll.prototype.go=function(current) {
	if (this.current!=current) return;
	if (!this.suspended) {
		this.step++;
		if (this.frequency<this.maximumFrequency && this.step==this.stepCount) {
			this.frequency+=this.frequencyStep;
			this.step=0;}
		eval(this.functionCall);}}

oPoll.prototype.suspend=function() {
	if (this.suspended) return false;
	this.suspended=true;
	return true;}

oPoll.prototype.resume=function(immediate) {
	this.suspended=false;
	this.current++;
	setTimeout(this.name + '.go(' + this.current + ')',immediate?1:this.frequency);}
