// JavaScript Document

 function somente_numero(campo){  
 var digits="0123456789/:"
 var campo_temp   
     for (var i=0;i<campo.value.length;i++){  
         campo_temp=campo.value.substring(i,i+1)   
         if (digits.indexOf(campo_temp)==-1){  
             campo.value = campo.value.substring(0,i);  
         }  
     }  
 }  

function formatar_mascara(src, mascara) {
	var campo = src.value.length;
	var saida = mascara.substring(0,1);
	var texto = mascara.substring(campo);
	if(texto.substring(0,1) != saida) {
		src.value += texto.substring(0,1);
	}
}


String.prototype.trim = function() {
		var x = this;
		x = x.replace(/^\s*(.*)/, "$1");
		x = x.replace(/(.*?)\s*$/, "$1");
		return x;
		}
		
function valida_cadastro(){
		

		if(document.form_cadastro.nome.value.trim()==''){
			//alert('Por favor informe a UNIDADE.');
                        document.getElementById("alert_erro").innerHTML = "Por favor, informe o campo nome!";
			document.form_cadastro.nome.focus();
			return false;
		}
		
	
		if (document.form_cadastro.email.value.trim()==''){
				//alert('Por favor informe o E-MAIL.');
                                document.getElementById("alert_erro").innerHTML = "Por favor, informe o campo e-mail!";
				document.form_cadastro.email.focus();
				return false;
			}else{
				aux = 0;
				if (aux==0) {
					if (document.form_cadastro.email.value.indexOf("@") < 0){
						aux=1;
						//alert("Preencha o e-mail no formato SEU@EMAIL.COM.BR")
                                                document.getElementById("alert_erro").innerHTML = "Preencha o e-mail no formato SEU@EMAIL.COM.BR!";
						document.form_cadastro.email.focus();
						return false;
					}
				}
				if (aux==0) {
					if (document.form_cadastro.email.value.indexOf(".") < 0){
						aux=1;
						//alert("Preencha o e-mail no formato SEU@EMAIL.COM.BR");
                                                document.getElementById("alert_erro").innerHTML = "Preencha o e-mail no formato SEU@EMAIL.COM.BR!";
						document.form_cadastro.email.focus();
						return false;
                        }
                        }
                        }
					
					
			if(document.form_cadastro.ddd.value.trim()==''){
				//alert('Por favor informe o DDD.');
                                document.getElementById("alert_erro").innerHTML = "Por favor informe o DDD!";

				document.form_cadastro.ddd.focus();
				return false;
			}

			if(document.form_cadastro.telefone.value.trim()==''){
				//alert('Por favor informe o TELEFONE.');
                                document.getElementById("alert_erro").innerHTML = "Por favor informe o TELEFONE!";
				document.form_cadastro.telefone.focus();
				return false;
			}

                                if(document.form_cadastro.inscrito[0].checked==false && document.form_cadastro.inscrito[1].checked==false){
				//alert('Por favor informe o TELEFONE.');
                                document.getElementById("alert_erro").innerHTML = "Está inscrito na Secretaria de Habitação de Joinville?";
				return false;
			}
                            
                            if(document.form_cadastro.termos.checked==false){
                                
				//alert('Por favor informe o TELEFONE.');
                                document.getElementById("alert_erro").innerHTML = "Por favor, selecione a autorização de ENVIO de INFORMAÇÕES!";
				return false;
			}
				
	
	}   

