var dt = new Array();
var clockID = 0;

var cl_tf = '0';

function updateClock()
{
	if(clockID)
  	clearTimeout(clockID);

	var tDate = new Date();
	dt[0] = pad(tDate.getHours());
	dt[1] = pad(tDate.getMinutes());
	dt[2] = pad(tDate.getSeconds());

	tm_obj = document.getElementById('clock_tm');  // Este é o identificador da chamada "HORA"
	
	tm_obj.innerHTML = formatTime();

	clockID = setTimeout("updateClock()", 1000);
}

function pad(val)
{
	if(val <= 9)
	{
		val.toString();
		val = "0" + val;
	}

	return val;
}


function formatTime()
{
  var t;

	t = cl_tf.replace(/H/,dt[0]);
  t = t.replace(/i/,dt[1]);
  t = t.replace(/s/,dt[2]);

	return t;
}


function startClock(tf)
{
	cl_tf = tf;

	clockID = setTimeout("updateClock()", 1);
}