document.addEventListener("DOMContentLoaded", function() {
    var commentTextarea = document.getElementById("comment");
    var authorField = document.getElementById("author");
    var emailField = document.getElementById("email");
    var urlField = document.getElementById("url");
    var submitButton = document.getElementById("submit");

    if (authorField && emailField && submitButton) {
        authorField.classList.add("d-none");
        emailField.classList.add("d-none");
        submitButton.classList.add("d-none");

        if (urlField) {
            urlField.classList.add("d-none");
        }

        commentTextarea.addEventListener("focus", function() {
            authorField.classList.remove("d-none");
            emailField.classList.remove("d-none");
            submitButton.classList.remove("d-none");

            if (urlField) {
                urlField.classList.remove("d-none");
            }
        });
        
		submitButton.addEventListener("click", function(event) {
			var commentValue = commentTextarea.value.trim();

			if (commentValue.length < 20) {
				event.preventDefault();
				alert(translation.lang);
				//console.log(translation.lang);
			}
		});
    }
});
/* document.addEventListener("DOMContentLoaded", function() {
    var commentTextarea = document.getElementById("comment");
    var authorField = document.getElementById("author");
    var emailField = document.getElementById("email");
    var urlField = document.getElementById("url");
    var submitButton = document.getElementById("submit");

    if (authorField && emailField && submitButton) {
        authorField.setAttribute("class", "d-none");
        emailField.setAttribute("class", "d-none");
        submitButton.setAttribute("class", "d-none");

        if (urlField) {
            urlField.setAttribute("class", "d-none");
        }

        commentTextarea.addEventListener("input", function() {
            var commentValue = commentTextarea.value.trim();

            if (commentValue.length >= 10) {
                authorField.removeAttribute("class");
                emailField.removeAttribute("class");
                submitButton.removeAttribute("class");

                if (urlField) {
                    urlField.removeAttribute("class");
                }
            } else {
                authorField.setAttribute("class", "d-none");
                emailField.setAttribute("class", "d-none");
                submitButton.setAttribute("class", "d-none");

                if (urlField) {
                    urlField.setAttribute("class", "d-none");
                }
            }
        });
    }
});

document.addEventListener("DOMContentLoaded", function() {
    var commentTextarea = document.getElementById("comment");
    var authorField = document.getElementById("author");
    var emailField = document.getElementById("email");
    var urlField = document.getElementById("url");
    var submitButton = document.getElementById("submit");
    
    if (authorField && emailField && urlField && submitButton) {
        authorField.setAttribute("class", "d-none");
        emailField.setAttribute("class", "d-none");
        urlField.setAttribute("class", "d-none");
        submitButton.setAttribute("class", "d-none");

        commentTextarea.addEventListener("input", function() {
            var commentValue = commentTextarea.value.trim();

            if (commentValue.length >= 10) {
                authorField.removeAttribute("class");
                emailField.removeAttribute("class");
                urlField.removeAttribute("class");
                submitButton.removeAttribute("class");
            } else {
                authorField.setAttribute("class", "d-none");
                emailField.setAttribute("class", "d-none");
                urlField.setAttribute("class", "d-none");
                submitButton.setAttribute("class", "d-none");
            }
        });
    }
});
 */