function buscar_propiedades_google(pagina){
    contenido_div_error_admin(true);
    var tipo = $('#ddlTipoPropiedad').val();
    if (!document.sending) {
        document.sending = true;
        $.ajax({
            data: {
                tipo : tipo,
                pagina : pagina
            },
            type: 'POST',
            url: WEB_PATH + '_admin/ajax/propiedades_google_maps_get.php',
            success: function(response) {
                contenido_div_error_admin(false);
                document.sending = false;
                $('#contenido').html(response);
            }
        });
    }
}

function guardar_google_maps(){

    contenido_div_error_admin(true);
    var array_mapas = new Array();
    
    var cant = $(".fondoFicha").length;
    var paquete = $(".fondoFicha");

    for(i = 0; i < cant; i++) {

        var div = paquete[i];

        var id_prop = div.children[1].children[0].value;
        var mapa_val = div.children[2].children[0].value;

        array_mapas[i] = {
            id : id_prop,
            mapa : mapa_val
        };
    }

    if (!document.sending) {
        document.sending = true;
        $.ajax({
            data: {
                tipo : $("#ddlTipoPropiedad").val(),
                mapas : array_mapas
            },
            type: 'POST',
            url: WEB_PATH + '_admin/ajax/guardar_google_maps.php',
            success: function(response) {
                document.sending = false;
                contenido_div_error_admin(false);
                if (response == "1") {
                    $('#txtError').html("Datos guardados correctamente");
                }else{
                    $('#txtError').html("Se produjo un error al guardar los mapas. Intente nuevamente");
                }
            }
        });
    }
}

function contenido_div_error_admin(cargando){
    if (cargando) {
        $('#imgCargando').attr("style", "display: ''");
        $('#txtError').attr("style", "display: none");
    }else{

        $('#imgCargando').attr("style", "display: none");
        $('#txtError').attr("style", "display: ''");
    }
}
