$('.owl-carousel1').owlCarousel({
    loop: true,
    margin: 10,
    nav: true,
    autoplay: true,
    responsive: {
        0: {
            items: 1
        },
        600: {
            items: 1
        },
        1000: {
            items: 1
        }
    }
})


$('.owl-theme2').owlCarousel({
    loop: true,
    margin: 10,
    nav: true,
    responsive: {
        0: {
            items: 1
        },
        600: {
            items: 1
        },
        1000: {
            items: 1
        }
    }
})


$('.client-carousel').owlCarousel({
    loop: true,
    nav: false,
    pagination: false,
    margin: 10,
    autoplay: true,
    responsive: {
        0: {
            items: 1
        },
        600: {
            items: 3
        },
        1000: {
            items: 6
        }
    }
})

$('.portfolio-menu ul li').click(function() {
    $('.portfolio-menu ul li').removeClass('active');
    $(this).addClass('active');

    var selector = $(this).attr('data-filter');
    $('.portfolio-item').isotope({
        filter: selector
    });
    return false;
});
$(document).ready(function() {
    var popup_btn = $('.popup-btn');
    popup_btn.magnificPopup({
        type: 'image',
        gallery: {
            enabled: true
        }
    });
});



$('.portfolio-menu ul li').click(function() {
    $('.portfolio-menu ul li').removeClass('active');
    $(this).addClass('active');

    var selector = $(this).attr('data-filter');
    $('.portfolio-item').isotope({
        filter: selector
    });
    return false;
});
$(document).ready(function() {
    var popup_btn = $('.popup-btn');
    popup_btn.magnificPopup({
        type: 'image',
        gallery: {
            enabled: true
        }
    });
});



$('.nxt').click(function() {
    $('.step1').hide();
    $('.step2').show();
});
$('.pre').click(function() {
    $('.step1').show();
    $('.step2').hide();
});



function nextSection() {
    if (document.getElementById('previous_btn').disabled)
        document.getElementById('previous_btn').disabled = false;
    var header_titles = document.getElementsByClassName('header_title');
    var active_position = -1;
    for (var i = 0; i < header_titles.length; i++) {
        if (header_titles[i].className.indexOf('active') != -1) {
            active_position = i;
        }
    }
    for (var i = 0; i <= active_position + 1 && active_position + 1 < header_titles.length; i++) {
        addClass(header_titles[i], 'active');
        if (i == 0) {
            addClass(header_titles[i].children[1].children[2], 'active-line');
            addClass(header_titles[i + 1].children[1].children[0], 'active-line')
        } else {
            addClass(header_titles[i - 1].children[1].children[2], 'active-line')
            addClass(header_titles[i].children[1].children[0], 'active-line')
        }
    }
    // Content items.
    var content_divs = document.getElementsByClassName('progress_item');
    var active_div = -1;
    for (var i = 0; i < content_divs.length; i++) {
        if (content_divs[i].className.indexOf('hide') == -1) {
            active_div = i;
        }
    }
    if (active_div + 1 < content_divs.length) {
        addClass(content_divs[active_div], 'hide');
        removeClass(content_divs[active_div + 1], 'hide');
        removeClass(content_divs[active_div], 'fade-in');
        addClass(content_divs[active_div + 1], 'fade-in');
    }
    active_div++;
    if (active_div == content_divs.length - 1) {
        var btn = document.getElementById('next_finish_btn');
        btn.innerHTML = 'Finish';
        btn.setAttribute('onclick', 'finishSections()');
    }
}

function previousSection() {
    var btn = document.getElementById('next_finish_btn');
    if (btn.innerHTML == 'Finish') {
        btn.innerHTML = 'Next';
        btn.setAttribute('onclick', 'nextSection()');
    }
    var header_titles = document.getElementsByClassName('header_title');
    var active_position = -1;
    for (var i = 0; i < header_titles.length; i++) {
        if (header_titles[i].className.indexOf('active') != -1) {
            active_position = i;
        }
    }
    if (active_position > 0) {
        removeClass(header_titles[active_position], 'active');
        removeClass(header_titles[active_position].children[1].children[0], 'active-line');
        removeClass(header_titles[active_position - 1].children[1].children[2], 'active-line');
    }
    // Content items.
    var content_divs = document.getElementsByClassName('progress_item');
    var active_div = -1;
    for (var i = 0; i < content_divs.length; i++) {
        if (content_divs[i].className.indexOf('hide') == -1) {
            active_div = i;
        }
    }
    if (active_div > 0) {
        addClass(content_divs[active_div], 'hide');
        removeClass(content_divs[active_div - 1], 'hide');
        removeClass(content_divs[active_div], 'fade-in');
        addClass(content_divs[active_div - 1], 'fade-in');
    }
    active_div--;
    if (active_div == 0) {
        document.getElementById('previous_btn').disabled = true;
    }
}

function addClass(element, value) {
    if (element.className.indexOf(value) == -1) {
        element.className += ' ' + value;
    }
}

function removeClass(element, value) {
    if (element.className.indexOf(value) != -1) element.className = element.className.replace(new RegExp(value,
        'g'), '');
}

function finishSections() {
    alert('Do finish action');
}




$(document).ready(function() {
    $('.image-popup-vertical-fit').magnificPopup({
        type: 'image',
        mainClass: 'mfp-with-zoom',
        gallery: {
            enabled: true
        },

        zoom: {
            enabled: true,

            duration: 300, // duration of the effect, in milliseconds
            easing: 'ease-in-out', // CSS transition easing function

            opener: function(openerElement) {

                return openerElement.is('img') ? openerElement : openerElement.find('img');
            }
        }

    });

});