(function($) {
    "use strict";

    /*----------------------------
    START - Method for assign the_ok_house controls
    ------------------------------ */
    function the_ok_house() {
        var windws = $(window),
            windwH = windws.height(),
            menus = $('.navbar-collapse'),
            menuH = menus.height(),
            welcoemTexts = $('.welcome-text-content'),
            welcoemTextH = welcoemTexts.height(),
            bannerH = (windwH - menuH),
            socialIs = $('.ok-social-icon'),
            socialI = (socialIs.height() / 2),
            verticalText = ((bannerH - welcoemTextH) / 2);
        $('.ok-welcome-text').css('height', windwH);
        socialIs.css('margin-top', - socialI);
        welcoemTexts.css({
            paddingTop: verticalText + 'px',
            paddingBottom: verticalText + 'px'
        });
    }
    // ScrollTop activation
    $(window).on('scroll', function() {

        if ($(this).scrollTop() > 1) {
            $('.ok-navbar-area').addClass("sticky");
        } else {
            $('.ok-navbar-area').removeClass("sticky");
        }
    });
    // call the_ok_house method & init preloader when window load
    $(window).on('load', function() {
        the_ok_house();
        $('#preloader').fadeOut('slow', function() {
            $(this).remove();
        });

    });

	/*----------------------------
	START - menubar
	------------------------------ */
    $('.nav li a').on('click', function () {
		$(".collapse").removeClass("show");
    });

    // OnePageNav control
    $('.navbar-nav').onePageNav({
        currentClass: 'active',
        changeHash: false,
        scrollSpeed: 750,
        scrollThreshold: 0.5,
        filter: '',
        easing: 'swing',
        begin: function() {
            //I get fired when the animation is starting
        },
        end: function() {
            //I get fired when the animation is ending
        },
        scrollChange: function($currentListItem) {
            //I get fired when you enter a section and I pass the list item of the section
        }
    });

	/*----------------------------
	START - jQuery window load function
	------------------------------ */
    $(window).on('load', function() {
        the_ok_house();
    });

	/*----------------------------
	START - jQuery window resize function
	------------------------------ */
    $(window).on('resize', function() {
        the_ok_house();

    });

	/*----------------------------
	START - isotop active
	------------------------------ */
    if ($.fn.isotope) {
        $(".ok-project-active").isotope({
            filter: '*',
        });

        $('.ok-project-nav ul li').on('click', function() {

            $(".ok-project-nav ul li").removeClass("active");
            $(this).addClass("active");

            var selector = $(this).attr('data-filter');
            $(".ok-project-active").isotope({
                filter: selector,
                animationOptions: {
                    duration: 750,
                    easing: 'linear',
                    queue: false,
                }
            });
            return false;
        });
    }

	/*----------------------------
	START - Scroll to Top
	------------------------------ */
    $(window).on('scroll', function() {
		if ($(this).scrollTop() > 400) {
			$('.scrollToTop').fadeIn();
		} else {
			$('.scrollToTop').fadeOut();
		}
	});
    $(document).on('click', '.scrollToTop', function() { // When arrow is clicked
		$('html, body').animate({scrollTop : 0},200);
		return false;
	});



    $('.bxslider').bxSlider({
      auto: true,
      autoControls: false,
      stopAutoOnClick: true,
      pager: false,
      minSlides: 2,
      maxSlides: 6,
      slideWidth: 150,
      slideMargin: 30,
    });

})(jQuery);
