function Timer() {

	this.decimais = 3;
	this.startTime = parseFloat(0.0);
	this.stopTime = parseFloat(0.0);
	this.pauseStartTime = parseFloat(0.0);
	this.pauseStopTime = parseFloat(0.0);
	this.totalTime = parseFloat(0.0);
	this.serverTime = parseFloat(0.0);
	this.isStoped = true;
	this.isPaused = false;

	this.start = function() {
		this.startTime = parseFloat(new Date().getTime() / 1000, 0.0);
		this.serverTime = 0.0;
		this.isStoped = false;
	};

	this.stop = function() {
		this.stopTime = parseFloat( new Date().getTime() / 1000, 0.0 );;
		this.totalTime = this.stopTime - this.startTime;
		this.isStoped = true;
		return this.totalTime.toFixed(4);

	};

	this.addServerTime = function(seconds) {
		this.serverTime += (parseFloat(seconds) || 0.0);
	};

	this.getMsg = function(stop) {
		if (stop || stop == undefined) this.isStoped = true;
		var s = new String();
		
		s = this.serverTime.toFixed(this.decimais).replace('.', ',')
			+ "s. no servidor. "
			+ (this.totalTime - this.serverTime).toFixed(this.decimais).replace('.', ',') 
			+ "s. no navegador. " + "Total de "
			+ this.totalTime.toFixed(this.decimais).replace('.', ',') + 's';
		return s;
	};

	this.pause = function() {
		this.pauseStartTime = parseFloat( new Date().getTime() / 1000, 0.0 );
		this.isPaused = true;
	};

	this.reStart = function() {
		this.pauseStopTime = parseFloat( new Date().getTime() / 1000, 0.0 );
		this.startTime = this.startTime + this.pauseStopTime - this.pauseStartTime;
		this.isPaused = false;
	};

};

var cronometro = new Timer();
