function mostrar (src) {

	if (document.getElementById(src).style.visibility != "visible") {
		document.getElementById(src).style.visibility = "visible";
	}
	
}

function ocultar (src) {

	if (document.getElementById(src).style.visibility != "hidden") {
		document.getElementById(src).style.visibility = "hidden";
	}
	
}

function verificarEspacos (txt) {

	var cont = 0;
	
	for (var i=0; i<txt.length; i++) {
		if (txt.substr(i, 1) != " ") {
			cont++;
		}
	}
	
	return cont;

}

function somenteNumeros (e) {

	var tecla = (window.event)?event.keyCode:e.which;
	
	if (tecla > 47 && tecla < 58) {
		return true;
    } else {
    	if (tecla != 8) {
			return false;
    	} else {
			return true;
		}
    }

}

function somenteNumerosBarraDoisPontosEspaco (e) {

	var tecla = (window.event)?event.keyCode:e.which;
	
	if ((tecla >= 47 && tecla <= 58) || tecla == 32) {
		return true;
    } else {
    	if (tecla != 8) {
			return false;
    	} else {
			return true;
		}
    }

}

function compararData (data1, data2) {

	dt1 = new Date(data1);
	dt2	= new Date(data2);
		
	if (dt1 > dt2) {
		return 0;
	} else {
		if (dt1 < dt2) {
			return 1;
		} else {
			return 2;
		}
	}

}

function preencherFone (campo) {
	
	with (campo) {
		
		if (value.length == 0) {
			value = "(";
		}
		
		if (value.length == 3) {
			value = value + ") ";
		}
		
		if (value.length == 9) {
			value = value + "-";
		}
		
	}
	
}

function confirmacao (msg, url) {
	if (confirm(msg)) {
		location.href = url;
	}
}

function enviarMensagem() {

	with (document.frm_email) {
		
		with (cxa_nome) {
			if (verificarEspacos(value) == "") {
			
				alert("ERRO: Por favor, preencha o campo Nome!");
				focus();
				return false;
				
			}
		}
		
		with (cxa_email) {
			if (verificarEspacos(value) == "") {
			
				alert("ERRO: Por favor, preencha o campo E-mail!");
				focus();
				return false;
				
			}
		}
		
		with (cxa_assunto) {
			if (verificarEspacos(value) == "") {
			
				alert("ERRO: Por favor, preencha o campo Assunto!");
				focus();
				return false;
				
			}
		}
		
		with (cxa_mensagem) {
			if (verificarEspacos(value) == "") {
			
				alert("ERRO: Por favor, preencha o campo Mensagem!");
				focus();
				return false;
				
			}
		}
		
		submit();
	
	}
	
}
