// JavaScript Document
function alterarimg()
{
 	   caminho = document.getElementById("pontodeatendimento").value;
	   document.getElementById("endereco").src = caminho;
}	

function selecionacidade(origem,destino)
	{
	for(a=document.getElementById(destino).length; a>=1; a--) {document.getElementById(destino).options[a]=null; }
	i=0;
	while (i < cidades.length) 
		{
		if(document.getElementById(origem).value==cidades[i][1]) 
			{				
			document.getElementById(destino).options[document.getElementById(destino).length] = new Option(cidades[i][3],cidades[i][2]);	
			}
		i++;
		}
	}	
function selecionabairro(origem,destino)
	{
	for(a=document.getElementById(destino).length; a>=1; a--) {document.getElementById(destino).options[a]=null; }
	i=0;
	while (i < bairros.length) 
		{
		if(document.getElementById(origem).value==bairros[i][1]) 
			{				
			document.getElementById(destino).options[document.getElementById(destino).length] = new Option(bairros[i][3],bairros[i][2]);	
			}
		i++;
		}
	}	

function selecionaestados(destino)
	{
	for(a=document.getElementById(destino).length; a>=1; a--) {document.getElementById(destino).options[a]=null; }
	i=0;
	while (i < estados.length) 
		{
		document.getElementById(destino).options[document.getElementById(destino).length] = new Option(estados[i][2],estados[i][1]);	
		i++;
		}	
	}

function selecionatipos()
	{
	for(a=document.getElementById("cod_tipo_imovel").length; a>=1; a--) {document.getElementById("cod_tipo_imovel").options[a]=null; }
	i=0;
	while (i < tipos.length) 
		{
		document.getElementById("cod_tipo_imovel").options[document.getElementById("cod_tipo_imovel").length] = new Option(tipos[i][2],tipos[i][1]);	
		i++;
		}	
	}
function selecionaquartos()
	{
	for(a=document.getElementById("quartos").length; a>=1; a--) {document.getElementById("quartos").options[a]=null; }
	i=0;
	while (i < quartos.length) 
		{
		document.getElementById("quartos").options[document.getElementById("quartos").length] = new Option(quartos[i][2],quartos[i][1]);	
		i++;
		}	
	}
	

function iniciar(iddestino,codigo)
	{
		for(a=0; a<document.getElementById(iddestino).length; a++) 
		{			
			if (iddestino == 'Disponibilidade')
			{
			 	alert("Disponibilidade");
			}
			if (document.getElementById(iddestino).options[a].value==codigo)
			{
				document.getElementById(iddestino).options[a].selected = true;				
			} else { 
				document.getElementById(iddestino).options[a].selected = false;
			}
		
		}

	}
	
function mostra(qualmostra,qualesconde) {
	j = 0;
	esconde = qualesconde.split("/");
	// mostra
	document.getElementById(qualmostra).style.display= "";
	// esconde
	while (j < esconde.length) 
		{ 
			document.getElementById(esconde[j]).style.display = "none";
			j++;
		}	
}
			
			
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

function validaavaliacao()
{
 	erros = "" ;	
	// VERIFICAÇÀO DE CAMPOS
    if(document.getElementById("nome").value=="")
    {
      erros = erros + "   - Insira seu Nome.\n";
    }
    
    if(document.getElementById("e-mail").value=="")
    {
      erros = erros + "   - Insira seu E-Mail.\n";
    }
    
    if(document.getElementById("telefone").value=="")
    {
      erros = erros + "   - Insira seu Telefone .\n";
    }
   
    if(document.getElementById("rua").value=="")
    {
      erros = erros + "   - Preencha a Rua.\n";
    }
    
    if(document.getElementById("numero").value=="")
    {
      erros = erros + "   - Preencha o Número.\n";
    }
    
    if(document.getElementById("av_estados").value=="")
    {
      erros = erros + "   - Selecione o Estado.\n";
    }		
    if(document.getElementById("av_cidades").value=="")
    {
      erros = erros + "   - Selecione a Cidade.\n";
    }
    if(document.getElementById("av_bairros").value=="")
    {
      erros = erros + "   - Selecione o  Bairro.\n";
    }	

	// SE HOUVER ERROS ELE FAZ O ALERTA, SE NÃO HOUVER ENVIA O FORMULÁRIO
	
	if (erros == "") 
	{
		 document.getElementById("Avaliacao").submit();
	} 
	else
	{
	alert("Prezado cliente, confirme os dados do formulário, segue abaixo o(s) erro(s) encontrado(s) :\n\n" + erros);
	}

}
function validacontato()
{
 	erros = "" ;	
	// VERIFICAÇÀO DE CAMPOS
    if(document.getElementById("nome").value=="")
    {
      erros = erros + "   - Insira seu Nome.\n";
    }
    
    if(document.getElementById("e-mail").value=="")
    {
      erros = erros + "   - Insira seu E-Mail.\n";
    }
    
    if(document.getElementById("telefone").value=="")
    {
      erros = erros + "   - Insira seu Telefone .\n";
    }
   
	// SE HOUVER ERROS ELE FAZ O ALERTA, SE NÃO HOUVER ENVIA O FORMULÁRIO
	
	if (erros == "") 
	{
		 document.getElementById("Contato").submit();
	} 
	else
	{
	alert("Prezado cliente, confirme os dados do formulário, segue abaixo o(s) erro(s) encontrado(s) :\n\n" + erros);
	}

}
function validatrabalheconosco()
{
 	erros = "" ;	
	// VERIFICAÇÀO DE CAMPOS
    if(document.getElementById("nome").value=="")
    {
      erros = erros + "   - Insira seu Nome.\n";
    }
    
    if(document.getElementById("e-mail").value=="")
    {
      erros = erros + "   - Insira seu E-Mail.\n";
    }
    
    if(document.getElementById("telefone").value=="")
    {
      erros = erros + "   - Insira seu Telefone .\n";
    }
   
    if(document.getElementById("av_estados").value=="")
    {
      erros = erros + "   - Selecione o Estado.\n";
    }		

	if(document.getElementById("av_cidades").value=="")
    {
      erros = erros + "   - Selecione a Cidade.\n";
    }
    if(document.getElementById("av_bairros").value=="")
    {
      erros = erros + "   - Selecione o  Bairro.\n";
    }	

   
	// SE HOUVER ERROS ELE FAZ O ALERTA, SE NÃO HOUVER ENVIA O FORMULÁRIO
	
	if (erros == "") 
	{
		 document.getElementById("trabalheconosco").submit();
	} 
	else
	{
	alert("Prezado cliente, confirme os dados do formulário, segue abaixo o(s) erro(s) encontrado(s) :\n\n" + erros);
	}

}