﻿var visor = null;

var zoomOptions = {
    zoomType: 'innerZoom',
    lens: true,
    preloadImages: true,
    alwaysOn: false,
    zoomWidth: 300,
    zoomHeight: 250,
    xOffset: 90,
    yOffset: 30,
    position: 'center'
};

function isNumber(e) { //Para que el cuadro de texto solo acepte serials
    var tecla = (document.all) ? e.keyCode : e.which;
    if (tecla == 8) return true;
    var patron = /\d/;
    var te = String.fromCharCode(tecla);
    return patron.test(te);
}

function showModalWindow(target, tWidth, tHeight, tOpenCallback, tCloseCallback) {
    //alert('Entre en el showModalWindow');
    $(target).dialog({
        modal: true,
        rezisable: true,
        width: tWidth,
        height: tHeight,
        open: function () {
            if (tOpenCallback != null || undefined != tOpenCallback)
                tOpenCallback();
        },
        close: function () {
            if (tCloseCallback != null || undefined != tCloseCallback)
                tCloseCallback();
        }
    });
}
function ShowValidationError(msg, elem) {
    $(elem).addClass('inputError');
    $(elem).focus();
    alert('Error: ' + msg);
    //    var errDiv = '<div class="error"><p>' + msg + '</p></div>';
    //    $('#resultado').html('');
    //    $('#resultado').html(errDiv);
    //    $('#resultado').toggle(200);
}

function ValidarTextYLongitud(elem) {
    var parametro = $(elem).val();
    var min = parseInt($(elem).attr('minLength'));
    var max = parseInt($(elem).attr('maxLength'));
    if (parametro == '') {
        ShowValidationError($(elem).attr('title'), elem);
        return false;
    }
    if (min == max)
        if (parametro.length != min) {
            ShowValidationError($(elem).attr('title') + ', la longitud debe ser de "' + min + '" dígitos.', elem);
            return false;
        }
    if (parametro.length < min || parametro.length > max) {
        ShowValidationError($(elem).attr('title') + ', la longitud debe ser de "' + min + '" a "' + max + '" dígitos.', elem);
        return false;
    }
    ;

    return true;
}

function showDialog(form, modal, opensuccess) {
    $(form).dialog({ modal: modal, width: '500px', resizable: modal, open: opensuccess });
}

function consultaInmueble() {
    var form = "divInmueble";
    var uri = '/webji/consultas/Inmueble.htm';
    $('div#' + form).load(uri, function () {
        $('div#' + form).dialog({
            modal: true,
            width: 500,
            rezisable: true,
            open: function () {
                $('#tipoBusqueda').focus();
            }
        });
    });
}

function loadURI(uri) {
    var windowOptions = "resizable=1;toolbar=0;status=1;personalbar=0;menubar=0;location=0;fullscreen=1;";
    windowOptions += 'scrollbars=0;'; //''width=' + $(window).width() + ';height=' + $(window).height() + ';';
    window.open('/webji/consultas/VisorDocumento.aspx?file=' + ('/webji/' + uri), 'VisorDocumentos', windowOptions);
}
