rules_recargar_fotoAmpliada = {
ampliacion: function() {
	$("a.ampliarFoto").bind("click",rules_ampliar_foto.ejecutar);
	}
}
rules_ampliar_foto = {
    evento: function() {
        $("a.ampliarFoto").bind("click", rules_ampliar_foto.ejecutar);
    },
    before: function() {
        ctn = p.split("ctn=")[1];
        ctn = ctn.split("&")[0];
        if (ctn == "")
            $("#modal").popUp();
        $().pre_loading("#modal", img_cargando, 0.1, "modal");
    },
    ejecutar: function() {
        var p = this.href;
        var foto = p.split("foto=")[1];
        $('#modal').html("<div class='popup4'><div style='height:30px'><h2><img class='titulares' src='/txt/ampliacion_de_foto.gif'/></h2><a class='cerrar' href='?modulo=COMEncuentrosEntrevistaPreguntarOU&encuentro=5000'>cerrar</a></div><div  class='popup3 estirar'><img src='" + foto + "'></div></div>");
        $("div#modal").popUp();
        $(".cerrar,.boton").bind("click", function() {
            $("div#modal").popDown();
        });

        p = parametros(this.href);
        var params = p;
        var foto = params;
        foto = foto.split("foto=")[1];
        fin_foto = function(html) {
            if (validarErr(html)) {
                foto = $.fn.foto;
                alto = $.fn.alto;
                ancho = $.fn.ancho;
                var anchoConf = 600;
                var altoConf = 500;
                if (ancho >= alto) {
                    ratio = (ancho / anchoConf);
                    nuevaanchura = anchoConf;
                    nuevaaltura = Math.round(alto / ratio);
                }
                else {
                    ratio = (alto / altoConf);
                    nuevaanchura = Math.round(ancho / ratio);
                    nuevaaltura = altoConf;
                }
                $("#modal").animate({ opacity: "toggle" }, "fast", function() {
                    $("div#modal").html(html).popUp();
                    $("#img_cargando").attr("src", foto);
                    $("#img_cargando").attr("width", nuevaanchura);
                    $("#img_cargando").attr("height", nuevaaltura);
                    $().post_loading("#modal", 1);
                    $("div#modal").popUp();
                    $("div#modal").each(rules_recargar_fotoAmpliada.ampliacion);
                });
            }
        }
        fin = function(html) {
            if (validarErr(html)) {
                $("#modal").animate({ opacity: "toggle" }, "fast", function() {
                    $("div#modal").html(html).popUp();
                    $().post_loading("#modal", 1);
                    $("div#modal").popUp();
                    $("div#modal").each(rules_recargar_fotoAmpliada.ampliacion);
                });
            }
        }
        if (foto != undefined && foto != "") {
            var preloader = new Image();
            preloader.onload = function() {

                var ancho = preloader.width;
                var alto = preloader.height;
                $.fn.ancho = ancho;
                $.fn.alto = alto;
                $.fn.foto = foto;
                preloader.onload = function() { };
                $.ajax({ url: "/modulo/index.html", dataType: "html", data: p, beforeSend: rules_ampliar_foto.before, success: fin_foto });
            }
            preloader.src = foto;
        }
        else
            $.ajax({ url: "/modulo/index.html", dataType: "html", data: p, beforeSend: rules_ampliar_foto.before, success: fin });
        return false;
    }
}
$(document).ready(rules_ampliar_foto.evento);

