/* Funciones de ayuda para el sitio */

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

function $(id)
{
    return document.getElementById(id);
    
}

function GetControl(id)
{
    return $(id);
}

function Cancelar(iradonde)
{
  document.location = iradonde;
}

function BuscarHome()
{
  var zona = document.getElementById("ciudad").options[document.getElementById("ciudad").selectedIndex].value;
  var tipo = document.getElementById("tipo").options[document.getElementById("tipo").selectedIndex].value;
  var disponibilidad = document.getElementById("disponibilidad").options[document.getElementById("disponibilidad").selectedIndex].value;
   xajax.call("BuscaSeo",[zona,tipo,disponibilidad,0]);
  //document.location = "listado.php?cd="+zona+"&t="+tipo+"&d="+disponibilidad;
}

function BuscarHomeV()
{
  var zona = document.getElementById("ciudad").options[document.getElementById("ciudad").selectedIndex].value;
  var tipo = document.getElementById("tipo").options[document.getElementById("tipo").selectedIndex].value;
  var disponibilidad = document.getElementById("disponibilidad").options[document.getElementById("disponibilidad").selectedIndex].value;
  
   xajax.call("BuscaSeo",[zona,tipo,disponibilidad,0]);
  //document.location = "listado.php?cd="+zona+"&t="+tipo+"&d="+disponibilidad;
}

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;
}
