function Formatar_Cep(objeto,tammax,teclapres)

{

	var tecla = teclapres.keyCode;

	vr = objeto.value;

	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 > 3) {

	 		objeto.value = vr.substr(0,tam-3) + '-' + vr.substr( tam - 3, tam ) ;

		}

	}		

}