VerifiqueTAB=true;

//<!-- Função utilizada no tratamento para hora com número e dois pontos -->
function valida_numerico(caixa_texto) {
	VerifiqueTAB=true; 
	if (! ( window.event.keyCode  >= 48 && window.event.keyCode <=57)  ){
		window.event.keyCode = 0;
	}
}// function valida_numerico

//<!-- Função utilizada no tratamento para hora com número e dois pontos -->
function formata_horas(caixa_texto) {
	// verifica se a caixa tem texto digitado
	if (caixa_texto.value.length == 0) { return true; }
	
	// verifica se a caixa tem texto digitado <> de ':'
	if (caixa_texto.value.length == 1 && caixa_texto.value == ':') {
	caixa_texto.value = '';
	return true;
	} 
	
	var x;
	var bln_find;
	var timepart = /^(\d{1,2}):(\d{1,2})$/;
	var horas_valida = true;
	bln_find = false;
    str_value = new String(caixa_texto.value);

		for (x=0; x<str_value.length; x++){
			if (str_value.charAt(x) == ':') { bln_find = true; }
		}  
		
		// coloca ':' apenas se nao achou o ':'
		if (!bln_find ){
			caixa_texto.value = caixa_texto.value  + ':00';
			str_value = str_value + ':00';
		}

		// pega minuto e segundo
		var matcharray = str_value.match(timepart);
		var hora   = matcharray[1];
		var minuto = matcharray[2];
				
		//verifica se hora e minuto sao validos
		if ( hora < 0 || hora > 23 || minuto < 0 || minuto > 59 ) {
			alert('Horário inválido. \nO horário tem que estar no intervalo de 00:00 às 23:59');
			horas_valida = false;
		}

		// converte para string e formata
		var hora_str = new String(hora);
		var minuto_str = new String(minuto);
		if (hora_str.length == 1) {hora_str = '0' + hora_str; } 
		if (minuto_str.length == 1) {minuto_str = '0' + minuto_str; } 
		caixa_texto.value = hora_str + ':' + minuto_str;

		if(!horas_valida) { 
			caixa_texto.value='';			
			caixa_texto.focus();
		}

}//function formata_horas

function valida_horas(caixa_texto) {
	var x;
	var bln_find;
	bln_find = false;
	VerifiqueTAB=true; 
    str_value = new String(caixa_texto.value);

	if( caixa_texto.value.length  == 2){
		//alert(window.event.keyCode)
		// procura dentro da string se jah nao tem o caracter ':'
		for (x=0; x<caixa_texto.value.length; x++){
			if (str_value.charAt(x) == ':') { bln_find = true; }
		}  
		
		// coloca ':' apenas se nao achou o ':'
		if (bln_find == false && window.event.keyCode != 58){
		 caixa_texto.value = caixa_texto.value  + ':'; 
		}
	}else{
		if (! ( window.event.keyCode  >= 48 && window.event.keyCode <=57)  ){
			window.event.keyCode = 0;
		}
	}
}// function valida_horas

//<!-- Funções utilizadas no tratamento do TAB -->
function Mostra(quem, tammax) {
	if ( (quem.value.length == tammax) && (VerifiqueTAB) ) {
		var i=0,j=0, indice=-1;
		for (i=0; i<document.forms.length; i++) {
			for (j=0; j<document.forms[i].elements.length; j++) {
				if (document.forms[i].elements[j].name == quem.name) {
					indice=i;
					break;
				}
			}
			if (indice != -1)
		         break;
		}
		for (i=0; i<=document.forms[indice].elements.length; i++) {
			if (document.forms[indice].elements[i].name == quem.name) {
				while ( (document.forms[indice].elements[(i+1)].type == "hidden") &&
						(i < document.forms[indice].elements.length) ) {
							i++;
				}
				document.forms[indice].elements[(i+1)].focus();
				VerifiqueTAB=false;
				break;
			}
		}
	}
}// function mostra

function PararTAB(quem) 
{ 
   VerifiqueTAB=false; 
}// function parartab