function MascaraHora(evento, objeto){
	var keypress=(window.event)?event.keyCode:evento.which;
	campo = eval (objeto);
	if (campo.value == '00:00')
	{
		campo.value=""
	}
	caracteres = '0123456789';
	separacao1 = ':';
	conjunto1 = 2;
	conjunto2 = 5;
	if ( (caracteres.search(String.fromCharCode (keypress))!=-1) && campo.value.length < (5))
	{
		if (campo.value.length == conjunto1 )
		{campo.value = campo.value + separacao1;
		}
	else
		event.returnValue = false;
	}
}

function validaHora(horario)
{
/*      horario = document.form_x.tx_hora.value; */
        var hora, min;
        horario = retiraCaracter(horario, ':');
        hora = parseInt(horario.substr(0,2)); 
        min = parseInt(horario.substr(2,2));           
        if ((hora < 0) || (hora >24)) 
        {
                alert ("Hora Inválida");
                document.form_x.tx_hora.focus() 
                return false;
        }
        if ((min < 0) || (min >59)) {
                alert ("Minuto Inválido");
                document.form_x.tx_hora.focus() 
                return false;
        }
}

function retiraCaracter(string, caracter) {
        var i = 0;
        var final = '';
        while (i < string.length) {
                if (string.charAt(i) == caracter) {
                        final += string.substr(0, i);
                        string = string.substr(i+1, string.length - (i+1));
                        i = 0;
                }
                else {
                        i++;
                }
        }
        return final + string;
}
