//////////////////////////////////////////////////////////////////////////////
// seleciona
//////////////////////////////////////////////////////////////////////////////
function seleciona(id){
	var selected_id = 1 * document.getElementById('selected_id').value;
  if (document.getElementById(id).style.borderWidth == '2px'){
		selected_id = -1; 
	  document.getElementById(id).style.borderWidth = '0px';
	}else{
		if (selected_id > -1){
			document.getElementById(selected_id).style.borderWidth = '0px';
		}
		selected_id = id;
		document.getElementById(id).style.borderWidth = '2px';			
	}
	document.getElementById('selected_id').value = selected_id;
}
//////////////////////////////////////////////////////////////////////////////
// abrePopup
//////////////////////////////////////////////////////////////////////////////
function abrePopUp(url,janela,scroll,W,H,T,L){
	if (W==0){
		W = eval(screen.width)-30;
	}
	if (H==0){
		H = eval(screen.height)-90;
	}
	if (T==0){
		T = Math.round((eval(screen.height)-H)/2);
	}
	if (L==0){
		L = Math.round((eval(screen.width)-W)/2);
	}
	if (wnd=window.open(url,janela,"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars="+scroll+",resizable=yes,copyhistory=no,width="+W+",height="+H+",top="+T+",left="+L)){
		return wnd;	
	}else{
		return false;	
	}
}
	
//////////////////////////////////////////////////////////////////////////////
// searchImovel
//////////////////////////////////////////////////////////////////////////////
function searchImovelPage(pagina) {
  if (document.getElementById('searchForm')) {        
    if (document.getElementById('searchFormPagina')) {      
      document.getElementById('searchFormPagina').value = pagina;
      if (pagina == 0) {
        document.getElementById('searchForm').action = 'index.php?page=imovel_busca';
      }
      else {
        document.getElementById('searchForm').action = 'index.php?page=imovel_list';
      }      
      document.getElementById('searchForm').submit();
      return true;
    }
  }
}

//////////////////////////////////////////////////////////////////////////////
// solicitaInformacoes - exibir/ocultar o form "solicita informacoes" da tela de detalhes de imóvel
//////////////////////////////////////////////////////////////////////////////
function solicitaInformacoes(show) {
  if (show == true) {
    // hide detail_table
    if (document.getElementById('detail_table')) {
      document.getElementById('detail_table').style.display = 'none';
      document.getElementById('form_indica_imovel_table').style.display = 'none';
      document.getElementById('form_informacoes_table').style.display = 'inline';
    }    
  }
  else {
    if (document.getElementById('form_informacoes_table')) {
      document.getElementById('detail_table').style.display = 'inline';
      document.getElementById('form_indica_imovel_table').style.display = 'none';
      document.getElementById('form_informacoes_table').style.display = 'none';
    }        
  }
  
}

//////////////////////////////////////////////////////////////////////////////
// indicaImovel - exibir/ocultar o form "indica imovel" da tela de detalhes de imóvel
//////////////////////////////////////////////////////////////////////////////
function indicaImovel(show) {
  if (show == true) {
    // hide detail_table
    if (document.getElementById('detail_table')) {
      document.getElementById('detail_table').style.display = 'none';
      document.getElementById('form_informacoes_table').style.display = 'none';
      document.getElementById('form_indica_imovel_table').style.display = 'inline';
    }    
  }
  else {
    if (document.getElementById('form_indica_imovel_table')) {
      document.getElementById('detail_table').style.display = 'inline';
      document.getElementById('form_informacoes_table').style.display = 'none';
      document.getElementById('form_indica_imovel_table').style.display = 'none';
    }        
  }
  
}


//////////////////////////////////////////////////////////////////////////////
// image Preload
//////////////////////////////////////////////////////////////////////////////

  var i = 0;
  imageObj = new Image();
  images = new Array();
       images[0]="{URL_ROOT}/image/site/Fundo_3_colunas.gif";
       images[1]="{URL_ROOT}/image/site/Fundo_Top.jpg";  
       images[2]="{URL_ROOT}/image/site/Fundo_Menu.gif"; 
       images[3]="{URL_ROOT}/image/site/Menu_Superior.gif";
       images[4]="{URL_ROOT}/image/site/Menu_Inferior.gif";
       images[5]="{URL_ROOT}/image/site/Casa_Top.jpg";
       images[6]="{URL_ROOT}/image/site/Casa_Bottom.jpg";
       images[7]="{URL_ROOT}/image/site/Fundo_Menu_Bottom.gif";       
       
  for(i=0; i<=7; i++) {
    imageObj.src=images[i];  
  }