'use strict'

window.addEventListener("load",function(){

    var agregarVentana = document.getElementById("nueva_conexion");
    var ventanaAgregarConexion = document.querySelector(".ventana_agregar_conexion");
    var cerrarVentana = document.getElementById("cerrar_ventana_agregar");
    var btnCancelar = document.getElementById("cancelar_ventana_agregar");

    var selectTipoConexion = document.getElementById("tipo_conexion_nueva");
    var selectServidor = document.getElementById("servidor_nuevo");

    agregarVentana.onclick = function(){
        ventanaAgregarConexion.style.display ="inline-block";
    }
    cerrarVentana.onclick = function () {
        ventanaAgregarConexion.style.display ="none";
    }
    btnCancelar.onclick = function () {
        ventanaAgregarConexion.style.display ="none";
    }


  //mostrar o oculatar campos de servidor
    selectTipoConexion.onchange= function () { 
   
        if(selectTipoConexion.value === "local"){
            selectServidor.setAttribute("disabled","");
            selectServidor.removeAttribute("required","");
        }else{
            selectServidor.removeAttribute("disabled","");
            selectServidor.setAttribute("required","");
        }

    }

    if(selectTipoConexion.value === "local"){
        selectServidor.setAttribute("disabled","");
    }



});