// JavaScript Document
<!--

var cod_tecla;
var tip_tecla;
var ies_shift;
var ies_ctrl;
var ies_alt;

//document.onkeydown = checkKey;

function checkKey(e) {
	if (window.event) {
		cod_tecla	= window.event.keyCode;
		ies_shift	= window.event.shiftKey;
		ies_ctrl		= window.event.ctrlKey;
		ies_alt		= window.event.altKey;
	}else{
		if (e) {
			cod_tecla	= e.which;
			ies_shift	= e.shiftKey;
			ies_ctrl		= e.ctrlKey;
			ies_alt		= e.altKey;
		}
	}
	if (cod_tecla >= 48 && cod_tecla <= 57 && ies_shift == false) {
		tip_tecla = 'numero';
	}else{
		if ((cod_tecla >= 65 && cod_tecla <= 90) || cod_tecla == 32) {
			tip_tecla = 'letra';
		}else{
			if (cod_tecla >= 48 && cod_tecla <= 57 && ies_shift == true) {
				tip_tecla = 'simbolo';
			}else{
				if (cod_tecla == 8 || cod_tecla == 13 || cod_tecla == 9 ||
					 (cod_tecla >= 33 && cod_tecla <= 40) ||
					 cod_tecla == 45 || cod_tecla == 46 ) {
					tip_tecla = 'outro';
				}else{
					tip_tecla = 'indefinida';
				}
			}
		}
	}
}

function limpa_campos(tela) {
	for (i=0; i<tela.elements.length; i++) {
		if (tela.elements[i].type == 'checkbox') {
			tela.elements[i].checked = false;
		}else{
			if (tela.elements[i].type == 'text' || tela.elements[i].type == 'hidden') {
				tela.elements[i].value = "";
			}
		}
	}
}

function Mascara_Telefone(objeto,tammax,evento)
{
	checkKey(evento);
	if (tip_tecla != 'numero' && tip_tecla != 'outro') {
		return false;
	}
	vr = objeto.value;
	vr = vr.replace( "(", "" );
	vr = vr.replace( ")", "" );
	vr = vr.replace( " ", "" );
	vr = vr.replace( "-", "" );
	tam = vr.length;
	if (tam < tammax && cod_tecla != 8) {
		tam = vr.length + 1 ;
	}
	if (cod_tecla == 8 ) {
		tam = tam - 1 ;
	}
	if ( cod_tecla == 8 || cod_tecla >= 48 && cod_tecla <= 57 || cod_tecla >= 96 && cod_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 Validar_Email(email)
{
	if(email.length < 6) {
		return false;
	}
	var x = 0;
	for (var c=0;c<email.length;c++) {
		if (email.substring(c,c+1) == '@') {
			x = c;
		}
	}
	var y = 0;
	if (x > 0) {
		for (c=x;c<email.length;c++) {
			if (email.substring(c,c+1)=='.') {
				y = c;
				var valida = 1;
			}
		}
		if (y > 0) {
			var dominio = '';
			for (c=x;c<y;c++) {
				dominio = dominio + email.substring(1,c);
			}
		}
	}
	else {
		return false;
	}					
	if (y <= x+2){
		return false;
	}				
	if (valida == 1){
		return true;
	}
}

function extensao_do_arquivo(nome) {
	barras	= nome.split("\\");
	arq		= barras[barras.length-1];
	pontos	= arq.split(".");
	ext		= pontos[pontos.length-1];
	return ext.toLowerCase();
}
-->
