function clsTimeout(timeout, divId) {
	this.timeout = timeout;
	this.divId = divId;
}

clsTimeout.prototype.startTimer = function() {
	this.startTime = Math.round((new Date()).getTime() / 1000);
	this.setTimer();
}

clsTimeout.prototype.setTimer = function() {
	var myClass = this;

	function timerRelay() {
		myClass.handleTimer();
	}

	setTimeout(timerRelay, 1000);
}

clsTimeout.prototype.handleTimer = function() {
	if (! (el = document.getElementById(this.divId)) ) {
		alert('missing divId: '+ this.divId);
	}
	if (! this.startTime) {
		alert('missing startTime: '+ this.startTime);
	}
	now = Math.round((new Date()).getTime() / 1000);
	passedTime = now - this.startTime;
	remTime = this.timeout - passedTime;
	remTimeSeconds = remTime % 60;
	remTimeMinutes = Math.floor(remTime / 60);
	if (remTimeSeconds <= 9) {
		remTimeSeconds = '0'+ remTimeSeconds;
	}
	if (remTimeMinutes <= 9) {
		remTimeMinutes = '0'+ remTimeMinutes;
	}
	if (remTime < 0) {
		remTime = 0;
	}
	if (remTime == 0) {
		el.innerHTML = '00:00';
	} else {
		el.innerHTML = remTimeMinutes +':'+ remTimeSeconds;
	}
	this.setTimer();
} 

