var ventanaEmergente = null;
var ventanaPDF;
Ancho = 650;
Alto = 390;

function abrirVentana(url) {
    if (ventanaEmergente == null) {
        //ventanaEmergente = window.open(url, "_blank", "status=no, scrollbars=no, resizable=no, menubar=no, height=500, width=500");
        ventanaEmergente = window.open(url, "_blank", "status=no, scrollbars=yes, resizable=no, menubar=no, height="+Alto+", width="+Ancho);
    }
    else {
        respuesta = confirm("Actualmente ya tiene abierta una ventana emergente, si continúa se cerrará la ventana actual y se abrira el nuevo destino.\n¿Es lo que desea?");
        if (respuesta == 1) {
            ventanaEmergente.close();
            ventanaEmergente = window.open(url, "_blank", "status=no, scrollbars=yes, resizable=no, menubar=no, height="+Alto+", width="+Ancho);
        }
    }
}

function abrirVentanaPoniendoEsto(codigo) {
    if (ventanaEmergente == null) {
        //ventanaEmergente = window.open(url, "_blank", "status=no, scrollbars=no, resizable=no, menubar=no, height=500, width=500");
        ventanaEmergente = window.open("/blanco", "_blank", "status=no, scrollbars=yes, resizable=no, menubar=no, height=" + Alto + ", width=" + Ancho);
        alert(codigo);
        ventanaEmergente.innerHTML = codigo;
        
    }
    else {
        respuesta = confirm("Actualmente ya tiene abierta una ventana emergente, si continúa se cerrará la ventana actual y se abrira el nuevo destino.\n¿Es lo que desea?");
        if (respuesta == 1) {
            ventanaEmergente.close();
            ventanaEmergente = window.open("/blanco", "_blank", "status=no, scrollbars=yes, resizable=no, menubar=no, height=" + Alto + ", width=" + Ancho);
            alert(codigo);
            ventanaEmergente.innerHTML = codigo;
        }
    }
}

function ventanaEmergenteCerrada() {
    if (ventanaEmergente != null) {
        ventanaEmergente.close();
        ventanaEmergente = null;
    }
}

function abrirInforme(url) {
    if (ventanaPDF == null) {
        ventanaPDF = window.open(url, "_blank", "status=no, scrollbars=yes, resizable=no, menubar=no, height=600, width=800");
    }
    else {
        try {
            ventanaPDF.close();
        }
        catch (e) {
            alert("catch!!");
        }
        ventanaPDF = window.open(url, "_blank", "status=no, scrollbars=yes, resizable=no, menubar=no, height=600, width=800");
    }
}

function MuestraAyuda() {
    if (document.getElementById("capaAyuda").style.display == "none") {
        window.resizeTo(Ancho + 640, Alto);
        document.getElementById("capaAyuda").style.display = "block";
    }
    else {
        window.resizeTo(Ancho , Alto);
        document.getElementById("capaAyuda").style.display = "none";
    }

}

function ImprimeAyuda(url) {
    abrirVentana("index.php?dest=imprimeAyuda&archivo="+url, 600, 600);
}


