
function enviapropiedad(inform)
{
var cade;
var nohacer=0;
var mxa;
mxa=inform.txtemail.value;

if ((mxa.indexOf('@')<1) && (nohacer==0))      nohacer=1;
if ((mxa.indexOf('.')<1) && (nohacer==0))      nohacer=1;
if ((mxa.indexOf(' ')>0) && (nohacer==0))       nohacer=1;
if ((mxa.length<5) && (nohacer==0))      nohacer=1;

if (nohacer==1)
    alert ("<?php echo $erroremail; ?>");
else
{
if (inform.txtnombre.value == "")
        {
        alert ("<?php echo $errornombre; ?>");
          nohacer=1;
        }else if(inform.textolegal.checked==false){
              alert ("Debes aceptar el aviso legal");
              nohacer=1;
            
        }
}


if (nohacer==0)  document.form1.submit();

}


//deja solo introducir numeros 
function solonumeros(e){
tecla_codigo = (document.all) ? e.keyCode : e.which;
if(tecla_codigo==8)return true;
patron =/[0-9]/;
if (tecla_codigo!=0) {
    tecla_valor = String.fromCharCode(tecla_codigo);
    return patron.test(tecla_valor);
}


}


/* FUNCIONES AJAX */


// Ejecuta una peticion ajax.
/*
  Si le pasas la capa, te carga los resultados en la capa id
  La funcion tambien devuelve la respuesta html
  parametros="id=5&a=6"
 */
function lanzaajax(tipo,url,parametros,capa){
    if (capa==null) capa="";
    var respuesta='';
     
     $.ajax({
      url: url,
      type: tipo,
      data: parametros,
      dataType:"html",
      async:false,
      errror:muestraError,
      success: function(html){
                       if(capa!="")
                         document.getElementById(capa).innerHTML=html;
                         respuesta=html;
              }
    });
    return respuesta;
        
}

function muestraError(html){
    alert(html);
}



 
 //Actualiza la zona segun la localidad
 function actualizarZona(id_loca,id_zona){
     
    var indice = document.getElementById(id_loca).selectedIndex;
    var localidad = document.getElementById(id_loca).options[indice].value;
	
    //alert(localidad);
 
    var parametros = "localidad="+localidad;
    
    lanzaajax("POST","lib/cargaZona.php",parametros,id_zona);
 
    
     
 }
    
    
function Cambiaridioma(idio)
{
    window.location="index.php?idio=" + idio;
}
