  //browser detection
  var strUserAgent = navigator.userAgent.toLowerCase(); 
  var isIE = strUserAgent.indexOf("msie") > -1; 
	var isNS6 = strUserAgent.indexOf("netscape6") > -1; 
	var isNS4 = !isIE && !isNS6  && parseFloat(navigator.appVersion) < 5; 
		
	//regular expressions
	var reValidChars = /\d/;
		
  //Função para mascarar campo Hora
	function maskHora(objEvent, CampoH) {
	var iKeyCode, strKey;  

	if (isIE) {
	  iKeyCode = objEvent.keyCode;
	} else {
    iKeyCode = objEvent.which;
	}
				
	strKey = String.fromCharCode(iKeyCode);

	if (!reValidChars.test(strKey)) {
		return false;
	}
	else {

	  if ((CampoH.value.length == 0) && (strKey > 2)) {
		  return false;
		}
	  if ((CampoH.value.length == 1) && (CampoH.value.charAt(0) == 2) && (strKey > 3)) {
		  return false;
		}
	  if (CampoH.value.length == 2) {
		  CampoH.value += ":";
		}
	  if ((CampoH.value.length == 3) && (strKey > 5)) {
		  return false;
		}
	}
}

  //Função para mascarar campo Data
	function maskData(objEvent,Campo) {
	var iKeyCode, strKey;  
				
	if (isIE) {
	  iKeyCode = objEvent.keyCode;
	} else {
    iKeyCode = objEvent.which;
	}
				
	strKey = String.fromCharCode(iKeyCode);

	if (!reValidChars.test(strKey)) {
		return false;
	}
	else {
	  if ((Campo.value.length == 2) || (Campo.value.length == 5)) {
		  Campo.value += "/";
		}
	}
}

//Função para validar data (dd/mm/yyyy)
function validaData(campo) {

	if(campo.value == '' || campo.value.length < 10) {
	  campo.value='';
		return;
	}
	var dia = parseInt(campo.value.substr(0,2));
	var mes = parseFloat(campo.value.substr(3,2));
	var ano = parseInt(campo.value.substr(6,4));
	var bisexto = ano % 4;
	var monthMax = new Array(31,31,29,31,30,31,30,31,31,30,31,30,31);

  if(bisexto==0) {
	  monthMax[2] = 29;
	}
	else {
	  monthMax[2] = 28;
	}
	if (dia > parseInt(monthMax[mes]) || mes > 12 || mes < 1) {
	  alert("Data inválida.");
		campo.value='';
		campo.focus();
		return;
	}
	return;
}