// Modal Message handler
function modalMessageHandler(state, messageType, message) {

    const messageBox = document.querySelector('.modal-message-container');
    const messageElem = document.getElementById('modal-message');
    const modalTitle = document.querySelector('.modal-sche-title')

    if (state == 'show') {
        messageBox.style.display = 'block'
        modalTitle.style.display = 'none'
        messageElem.innerText = message;

        document.querySelector('.modal-content').scrollTop = 0;

        if (messageType == 'danger') {
            messageElem.style.backgroundColor = '#ff2222'
        } else if (messageType == 'success') {
            messageElem.style.backgroundColor = '#8bc34a'
        }
    } else if ('hide') {
        modalMessageHidder()
    }

    
    document.querySelector('.modal-message-container span').addEventListener('click', function(){
        messageBox.style.display = 'none'
        modalTitle.style.display = 'block'
    });
 
   function modalMessageHidder() {

        messageBox.style.display = 'none'
        modalTitle.style.display = 'block'

    }

}


//Show and Hide Error box 
function errorHandler(toggler, message) {
    var errorSection = document.querySelector('.error-back')
    var errorMessage = document.getElementById('error-message')
    if (toggler == 'show') {
        errorSection.classList.replace('hide', 'show');
        errorMessage.innerText = message

    } else if (toggler == 'hide') {
        errorSection.classList.replace('show', 'hide');
    }

}


//accordion 
var acc = document.getElementsByClassName("accordion");
var i;

for (i = 0; i < acc.length; i++) {
    acc[i].addEventListener("click", function () {
        this.classList.toggle("active");
        var panel = this.nextElementSibling;
        if (panel.style.display === "block") {
            panel.style.display = "none";
        } else {
            panel.style.display = "block";
        }
    });
}



//Show and Hide Loader
function loaderHandler(toggler) {
    var loadSection = document.querySelector('#loader-wrap')
    if (toggler == 'show') {
        loadSection.classList.replace('hide', 'show');

    } else if (toggler == 'hide') {
        loadSection.classList.replace('show', 'hide');
    }
}



//Gallery Photo Slider #Start
var slideIndex = 1;
showDivs(slideIndex);

function plusDivs(n) {
    showDivs(slideIndex += n);
}

function currentDiv(n) {
    showDivs(slideIndex = n);
}

function showDivs(n) {
    var i;

    var x = document.getElementsByClassName('sliderImages');
    var dots = document.getElementsByClassName('demo');
    if (n > x.length) {
        slideIndex = 1
    }
    if (n < 1) {
        slideIndex = x.length
    }
    for (i = 0; i < x.length; i++) {
        x[i].style.display = "none";
    }
    for (i = 0; i < dots.length; i++) {
        dots[i].className = dots[i].className.replace(" slider-white", "");
    }
    x[slideIndex - 1].style.display = "block";
    dots[slideIndex - 1].className += " slider-white";
}
//Gallery Photo Slider #End