function labelData(campo) {
   if(campo.value.length == 2 || campo.value.length == 5) {
      campo.value += "-";
   }
}

function labelHora(campo) {
	if (campo.value.length == 2) {
		campo.value += ":";	
	}	
}

function labelCep(campo) {
	if(campo.value.length == 2) {
		campo.value += ".";	
	}
	if(campo.value.length == 6) {
		campo.value += "-";
	}	
}

function tamanhoText(obj,tamanho) {
	texto = String(obj.value);
	if (texto.length > tamanho) {
		obj.value = texto.substring(0,tamanho);
	}
}

function apenasNumeros(caracter,excessoes) {
	
	//EXEMPLO DE USO DA FUNÇÃO PARA ESCREVER APENAS NÚMEROS
	//onkeypress="return apenasNumeros(event,'');"
	//onkeypress="return apenasNumeros(event,'A;B;C');"
	
	if (navigator.appName == "Microsoft Internet Explorer") {
		tecla = event.keyCode;
	}
	else if (navigator.appName == "Netscape") {
		tecla = caracter.which;
	}
	excessao = excessoes.split(";");
	for (i=0;i<excessao.length;i++) {
		if (excessao[i] != "") {
			if (excessao[i] == tecla) {
				return true;
			}
		}
	}
	if (tecla > 47 && tecla < 58) {
		return true;
	}
	else {
		if (tecla != 8 && tecla != 0) {
			return false;
		}
		else {
			return true;
		}
	}
}

function labelTelefone(objeto,tammax,teclapres)
{
	var tecla = teclapres.keyCode;
	vr = objeto.value;
	vr = vr.replace( "(", "" );
	vr = vr.replace( ")", "" );
	vr = vr.replace( " ", "" );
	vr = vr.replace( "-", "" );
	tam = vr.length;
	if (tam < tammax && tecla != 8) {
		tam = vr.length + 1 ;
	}
	if (tecla == 8 ) {
		tam = tam - 1 ;
	}
	if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ) {
		if ( tam <= 4 ) { 
	 		objeto.value = vr ;
		}
	 	if ( (tam > 4) && (tam <= 8) ) {
	 		objeto.value = vr.substr(0,tam-4) + '-' + vr.substr( tam - 4, tam ) ;
		}
	 	if ( (tam >= 9) && (tam <= 10) ) {
			objeto.value = '(' + vr.substr(0,2) + ') ' + vr.substr(2,tam-6) + '-' + vr.substr(tam-4,tam) ;			
		}
	}		
}

function labelCGC(objeto) {
	campo = eval(objeto);
	if (campo.value.length == 2) {
		campo.value = campo.value;
		campo.value = campo.value + '.';
	}
	if (campo.value.length == 6) {
		campo.value = campo.value;
		campo.value = campo.value + '.';
	}
	if (campo.value.length == 10) {
		campo.value = campo.value;
		campo.value = campo.value + '/';
	}
	if (campo.value.length == 15) {
		campo.value = campo.value;
		campo.value = campo.value + '-';
	}
}

function labelIE(objeto) {
	campo = eval(objeto);
	if (campo.value.length == 2) {
		campo.value = campo.value;
		campo.value = campo.value + '.';
	}
	if (campo.value.length == 5) {
		campo.value = campo.value;
		campo.value = campo.value + '.';
	}
	if (campo.value.length == 10) {
		campo.value = campo.value;
		campo.value = campo.value + '-';
	}
}
