function slickSlider(element, options, arrowHide) {
     
    var $mainControl = $('<div class="-slick-controls"></div>');
    var $arrowControl = $('<div class="-slick-arrows"></div>');

    var settings = {
        slidesToShow: 1,
        slidesToScroll: 1,
        dots: true,
        arrows: true,
        accessibility: false,
        infinite: true,
        nextArrow: '<button type="button" class="slick-next"></button>',
        prevArrow: '<button type="button" class="slick-prev"></button>',
        focusOnSelect: true,
        speed: 300,
        autoplaySpeed: 5000,
        appendArrows: $arrowControl,
        appendDots: $mainControl
    }
    var object = $.extend(settings, options);

    element.slick(object);

    $mainControl.append($arrowControl);

    if (object.arrows) {
        element.parent().append($mainControl);
    }

}

function slickEvent(element, onEvent, triggerEvent) {
    element.on(onEvent, function (event, slick, currentSlide, nextSlide) {
        if (triggerEvent == "remove") {
            slick.$slider.removeClass('-animating');
        }
        if (triggerEvent == "add") {
            slick.$slider.addClass('-animating');
        }
    });
}

function isNavVisible(nav) {
    return (nav.classList.contains('show') ? true : false);
}

function headerStick() {
    var header = document.querySelector('.-header');
    var nav = document.querySelector('.-navigation');
    var options = {
        onUnpin: function () {

            if (isNavVisible(nav)) {
                this.elem.classList.remove(this.classes.unpinned);
                this.elem.classList.add(this.classes.pinned);
            }
            else {
                this.elem.classList.add(this.classes.unpinned);
                this.elem.classList.remove(this.classes.pinned);
            }
        }
    };

    var headroom = new Headroom(header, options);
    headroom.init();
}

function scrollAnimation(trigger, event) {
    var hash = trigger.attr('href');
    if (hash !== "") {
        event.preventDefault();

        $('html, body').stop(false, true).animate({
            scrollTop: $(hash).offset().top
        }, 800, function () {
            window.location.hash = hash;
        });
    }
}

function scroller(direction) {
    var parent = $('.-page-scrollspy .-mid .navbar');
    var current = $('a.active', parent).length
        ? $('a.active', parent)
        : $('li:first a', parent);

    var next = $('a.active', parent).length ? $('a', current.parent().next()) : $('li:first a', parent);
    var prev = $('a', current.parent().prev());

    if (direction == "down") {
        next.trigger('click');
    } else {
        prev.trigger('click');
    }
}

function scrollFunction() {
    var gotop = $('.-go-top');
    var timer;
    gotop.click(function (e) {
        e.preventDefault();
        $('html,body').stop(true, true).animate({
            scrollTop: 0
        }, 1000);
    });
    window.onscroll = function (e) {
        clearTimeout(timer);
        timer = setTimeout(function () {
            if ($(window).scrollTop() > 100) {
                gotop.stop(true, false).fadeIn();
            } else {
                gotop.stop(true, false).fadeOut();
            }
        }, 300);
    };
    /*
    $(window).scroll(function (e) {
        clearTimeout(timer);
        timer = setTimeout(function () {
            if ($('html,body').scrollTop() > 100) {
                gotop.stop(true, false).fadeIn();
            } else {
                gotop.stop(true, false).fadeOut();
            }
        }, 300);
    });
    */
}

function inpLabel($this) {
    $this.focus(function (e) {
        $this.parent('.-input').addClass('-active -focused');
        if ($this.attr("placeholder") != "") $this.attr("placeholder", "");
        if ($this.is(".-passenger")) $this.parent('.-input').addClass('-selecting');
    });
    $('.done-select').click(function (e) {
        $this.parent('.-input').removeClass('-focused -selecting');
        e.preventDefault();
    });
    $(document).mouseup(function (e) {
        var container = $this.parent('.-input');
        // if the target of the click isn't the container nor a descendant of the container
        if (!container.is(e.target) && container.has(e.target).length === 0) {
            $this.parent('.-input').removeClass('-focused -selecting');
        }
    });
    $this.on('blur', function () {
        if ($this.val().length == 0 && !$this.parent().is('.-fixed')) {
            $this.parent('.-input').removeClass('-active -focused');
        } else {
            $this.parent('.-input').removeClass('-focused');
        }
    });
    if ($this.val() != "") $this.parent('.-input').addClass('-active');
}

function landingShow() {
    if ($(".-landing").length > 0) {
        $(".-landing").each(function () {
            $(this).modal('show');
        });
    }
}