var strTxtSearch='Cidade & Estado, ou CEP';
var strTxtSearch2='Cidade & Estado, ou CEP';
var strTxtMin='min';
var strTxtMax='max';

//Tratamento de conteúdo dentro da TextBox
function trim(s)
{
  if (!s)
    return '';
  return s.replace(/^\s*|\s*$/g,"");
}

//Limpa se não existir digitação na TextBox
function ResetIf(id, resetval, ifval)
{ 
  var e = xb_get_element(id);
  if (e && (e.value == ifval || trim(e.value) == ''))
    e.value = resetval;
}

//Limpa se não existir digitação na TextBox
function ClearIf(id,val)
{

  var e = xb_get_element(id);
  if (e && e.value == val)
    e.value = '';
}

//Retorna o HTML Element associado ao ID
function xb_get_element(id)
{
  var el = document.all ? document.all[id] : document.getElementById(id);
  if (el)
    return el;
  else
    return null;
}


function ValidaSearchBox(obj)
{

  var blnRetorno;

  var stext = document.frm.SearchBox.value.replace(/^\s+/g, '').replace(/\s+$/g, '');

  if (!stext || stext == strTxtSearch)
  {
    alert("Por favor, entre com uma cidade, estado, bairro ou cep.");
    document.frm.SearchBox.focus();
    blnRetorno=false;
  }
  else
   blnRetorno=true;
  
  return blnRetorno;
}

function ValidaSearchBox2(obj)
{

  var blnRetorno;

  var stext = document.frm2.SearchBox2.value.replace(/^\s+/g, '').replace(/\s+$/g, '');

  if (!stext || stext == strTxtSearch2)
  {
    alert("Por favor, entre com uma cidade, estado, bairro ou cep.");
    document.frm2.SearchBox2.focus();
    blnRetorno=false;
  }
  else
   blnRetorno=true;
  
  return blnRetorno;
}
