//*****************************************************************************
//	FUNÇÃO PARA VALIDAR SE VARIAVEL ESTA EM BRANCO
//*****************************************************************************
function isEmpty(varData){
	for ( var i = 0 ; i < varData.length ; i++ ){
		if ( varData.substring( i, i+1 ) != " " )
			return false;
	}
	return true;
}


//*****************************************************************************
//	FUNÇÃO PARA VALIDAR CAMPO E-MAIL SE TEM @ . ETC...
//*****************************************************************************
function chkMail(varMail){
	
	if (varMail == "") return false;	
	var t = varMail;
	
	var Alpha = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
	var Digit = '1234567890';
	var Symbol='_-';
	var check = '@.' + Alpha + Digit + Symbol;

	for (i=0; i < t.length; i++)
	   if(check.indexOf(t.substring(i,i+1)) < 0) 	{
		return false;
		}

	var check = '@';
	var a = 0;
	for (i=0; i < t.length; i++)
	  if(check.indexOf(t.substring(i,i+1)) >= 0) 	a = i;
	
	var check = '.';
	var b = 0;	
	for (i=a+1; i < t.length; i++)
		if(check.indexOf(t.substring(i,i+1)) >= 0) 	b = i;

	if (a != 0 && b != 0 && b != t.length-1 ) {
		return true;
	} else {
		return false;
	}

}



//*****************************************************************************
//	VALIDACAO DO CADASTRE-SE CAMPOS EM BRANCOS
//*****************************************************************************
function chkFormCadastrese(form){
	
		if(isEmpty(form.n_titulo.value)){
			alert("Coloque o Número do Título");
			form.n_titulo.focus();
			return false;
		}			
	
		if(isEmpty(form.nome.value)){
			alert("Digite seu Nome");
			form.nome.focus();
			return false;
		}
		
		if(!chkMail(form.email.value)){
			alert("E-mail incorreto");
			form.email.focus();
			return false; 
		}
		
		if(isEmpty(form.obs.value)){
			alert("Digite sua Observação");
			form.obs.focus();
			return false;
		}		
}




//*****************************************************************************
//	VALIDACAO DO CONTATO CAMPOS EM BRANCOS
//*****************************************************************************
function chkFormFaleConosco(form){
	
		if(isEmpty(form.nome.value)){
			alert("Digite seu Nome");
			form.nome.focus();
			return false;
		}
		
		if(isEmpty(form.ddd.value)){
			alert("Digite o DDD");
			form.ddd.focus();
			return false;
		}
		
		if(isEmpty(form.telefone.value)){
			alert("Digite seu Telefone");
			form.telefone.focus();
			return false;
		}		


		if(!chkMail(form.email.value)){
			alert("E-mail incorreto");
			form.email.focus();
			return false; 
		}
		
		if(isEmpty(form.mensagem.value)){
			alert("Digite sua mensagem");
			form.mensagem.focus();
			return false;
		}		
}


//*****************************************************************************
//	ABRE POP-UP DAS FOTOS
//*****************************************************************************
function imagem(conteudo,campo){
	window.open('verfoto.asp?CDFoto=' + conteudo + '&area=' + campo,'url','width=300, height=400, toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no')
}


//*****************************************************************************
//	ABRE POP-UP DAS FOTOS LOCACAO DEPENDENCIAS
//*****************************************************************************
function imagemDependencias(conteudo,campo){
	window.open('verfoto2.asp?Foto=' + conteudo + '&area=' + campo,'url','width=300, height=400, toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no')
}

//*****************************************************************************
//	ABRE POP-UP PARA DOWNLOAD DOS PLANOS
//*****************************************************************************
function planos(){ 
	window.open('download_planos.asp','planos','width=346,height=166'); 
} 
