document.addEventListener("DOMContentLoaded", function() {
    const textContainer = document.querySelector('.typing-text');
    const textArray = ["RESPETO", "HONESTIDAD", "CONFIANZA"];
    const typingSpeed = 100; // speed in milliseconds
    const delayBetweenTexts = 1000; // delay between texts in milliseconds
    let textIndex = 0;
    let charIndex = 0;

    function type() {
      if (charIndex < textArray[textIndex].length) {
        textContainer.textContent += textArray[textIndex].charAt(charIndex);
        charIndex++;
        setTimeout(type, typingSpeed);
      } else {
        setTimeout(erase, delayBetweenTexts);
      }
    }

    function erase() {
      if (charIndex > 0) {
        textContainer.textContent = textArray[textIndex].substring(0, charIndex - 1);
        charIndex--;
        setTimeout(erase, typingSpeed);
      } else {
        textIndex = (textIndex + 1) % textArray.length;
        setTimeout(type, typingSpeed);
      }
    }

    type();
  });
