//////////////////////////////////////////////////////////////////////////////
// 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;
}

//////////////////////////////////////////////////////////////////////////////
// select
//////////////////////////////////////////////////////////////////////////////
function select(id){
alert(document.getElementById('idBody').scrollY);  
//  var left = document.getElementById(id).getBoundingClientRect().left + document.body.scrollLeft;
//  var right = document.getElementById(id).getBoundingClientRect().right + document.body.scrollLeft;
//  var bottom = document.getElementById(id).getBoundingClientRect().bottom + document.body.scrollTop;
//  var top = document.getElementById(id).getBoundingClientRect().top + document.body.scrollTop;
//  var width = right - left;
//  var height = bottom - top;
//  
//	var div_select_box = document.getElementById('divSelectBox');
//	div_select_box.style.display = 'none';	
//	div_select_box.style.left = left;
//	div_select_box.style.top = top;
//	div_select_box.style.width = width;
//	div_select_box.style.height = height;
//	div_select_box.style.display = 'inline';
}

//////////////////////////////////////////////////////////////////////////////
// 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;	
	}
}

//////////////////////////////////////////////////////////////////////////////
// abreImagePopUp
//////////////////////////////////////////////////////////////////////////////
function abreImagePopUp(url,janela,W,H){
  
  var scroll = 'no';
	var T = Math.round((eval(screen.height)-H)/2);	
	var L = Math.round((eval(screen.width)-W)/2);
  
  if (W > (eval(screen.width)-30)) {
    W = eval(screen.width)-30;
    scroll = 'yes';
  }
  if (H > (eval(screen.height)-90)) {
    H = eval(screen.height)-90;
    scroll = 'yes';
  }
	
	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';
    }        
  }
  
}

//////////////////////////////////////////////////////////////////////////////
// indicaImovel - exibir/ocultar o form "indica imovel" da tela de detalhes de imóvel
//////////////////////////////////////////////////////////////////////////////
function searchByDay(day) {
  $('formBuscaEventosDay').value = day;
  document.formBuscaEventos.submit();
}
