/* Funciones de ayuda para el sitio */

function BuscarHome()
{
  var zona = document.getElementById("zona").options[document.getElementById("zona").selectedIndex].value;
  var tipo = document.getElementById("tipo").options[document.getElementById("tipo").selectedIndex].value;
  var disponibilidad = document.getElementById("disponibilidad").options[document.getElementById("disponibilidad").selectedIndex].value;
  
  //document.location = "listado.php?z="+zona+"&t="+tipo+"&d="+disponibilidad;
   xajax.call("BuscaSeo",[zona,tipo,disponibilidad,0]);
}

function BuscarHomeV()
{
  var zona = document.getElementById("zona").options[document.getElementById("zona").selectedIndex].value;
  var tipo = document.getElementById("tipo").options[document.getElementById("tipo").selectedIndex].value;
  var disponibilidad = document.getElementById("disponibilidad").options[document.getElementById("disponibilidad").selectedIndex].value;
  
  //document.location = "listado.php?c=1&z="+zona+"&t="+tipo+"&d="+disponibilidad;
  xajax.call("BuscaSeo",[zona,tipo,disponibilidad,1]);
}

function ReloadPropAgendadas()
{
  xajax.call("ListadoPropAgendadas",[]);
}

function AgendarProp(id)
{
  xajax.call("AgendarPropiedad",[id]);
}

function RemoverProp(id)
{
  xajax.call("QuitarAgendada",[id]);
}

function QuitarTodas()
{
  if(confirm("Esta seguro de quitar todas las propiedades Agendadas?"))
    xajax.call("QuitarTodas",[]);
}

function GetControl(id)
{
  return document.getElementById(id);
}

function Preview(image)
{
	xajax.call("PreviewImage",[image]);
}

function ExpandirVenta()
{
  if(document.getElementById("lblDatosVenta").style.display=="") document.getElementById("lblDatosVenta").style.display="none";
  else document.getElementById("lblDatosVenta").style.display="";
}

function TyC()
{
  var a = window.open("terminos.php","_tyc_","width=550,height=400,scrollbars=yes, resizable=yes");
  a.focus();
}

function IsNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }

function BuscarProp()
{
	prop = document.getElementById("idprop").value.toLowerCase();
	
	prop_id = prop.replace("pr","");
	prop_id = prop_id.replace("p","");
	prop_id = prop_id.replace("r","");
	
	if(!IsNumeric(prop_id))
	{
		alert("Debe ingresar el código de la propiedad.");
		document.getElementById("idprop").focus();
		return;
	}
	
	document.location="/propiedad.php?id="+prop_id;
}
