//from   Sphere RPG Engine(sphere)  - http://sourceforge.net/projects/sphere

function Clock() {
	this.started = 0;
	this.seconds = 0;
	this.minutes = 0;
	this.hours = 0;
}

Clock.prototype.start = function() {
	this.started = (new Date()).getTime();
}

Clock.prototype.getTime = function() {

	var current = (new Date()).getTime() - this.started;
	var secs = 0;
	var mins = 0;
	var hours = 0;

	secs = Math.floor((current)/1000 + this.seconds) % 60;

	mins = Math.floor((current)/1000/60 + this.minutes) % 60;

	hours = Math.floor((current)/1000/60/60 + this.hours) % 60;


	return [hours, mins, secs];

}

Clock.prototype.getStringTime = function() {
	
	var time = this.getTime();

	hours = (time[0] < 10) ? "0" + time[0] : time[0];
	mins = (time[1] < 10) ? "0" + time[1] : time[1];
	secs = (time[2] < 10) ? "0" + time[2] : time[2];
	
	return hours + ":" + mins + ":" + secs;

}