$(document).ready(function(){

    $("#dezentral_domain").keyup(function(){
        $(".dezentral_domain").html($(this).val());
    });

    $("#update_list").change(function(){
        var selected_val = $(this).find("option:selected").val();
        if(selected_val == "true"){
            $("#dezentral_mis").prop("disabled", true);

        }else{
            $("#dezentral_mis").prop("disabled", false);
        }
    });

    $("#pool_join").change(function(){
        var selected_val = $(this).find("option:selected").val();
        if(selected_val == "true"){
            $("#pool_subdomain").prop("disabled", false);

        }else{
            $("#pool_subdomain").prop("disabled", true);
        }
    });

    $("#pool_subdomain").bind("keyup", function(){
        $("#pool_subdomain_state").show();
        $("#pool_subdomain_state").attr("class", "glyphicon glyphicon-refresh");
        $("#pool_subdomain_state").css({"color":"black","font-size":"20px"});
        if($(this).val() == ""){
            $("#pool_subdomain_state").attr("class", "glyphicon glyphicon-remove-circle");
            $("#pool_subdomain_state").css({"color":"red","font-size":"20px"});
        }else{
            $.get("http://api.mc-caching.org/check_domain/"+$(this).val(), function(data){
                if(data != "true"){
                    $("#pool_subdomain_state").attr("class", "glyphicon glyphicon-remove-circle");
                    $("#pool_subdomain_state").css({"color":"red","font-size":"20px"});
                }else{
                    $("#pool_subdomain_state").attr("class", "glyphicon glyphicon-ok-circle");
                    $("#pool_subdomain_state").css({"color":"green","font-size":"20px"});
                }
            });
        }
    });
});