// Hello.
//
// This is The Scripts used for ___________ Theme
//
//

function main() {

(function () {
   'use strict';

   /* ==============================================
  	Testimonial Slider
  	=============================================== */ 

  	$('a.page-scroll').click(function() {
        if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
          var target = $(this.hash);
          target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
          if (target.length) {
            $('html,body').animate({
              scrollTop: target.offset().top - 40
            }, 900);
            return false;
          }
        }
      });

    /*====================================
    Show Menu on Book
    ======================================*/

  	var subPageImageHeight = $("#tf-home2").height();
  	//alert(subPageImageHeight);
  	if (subPageImageHeight) {
  		$(".navbar-brand").css("display", "block");
  	}
  	$(window).bind('scroll', function () {
  		var navHeight = 0;
  		if (subPageImageHeight) {
  			navHeight = $(window).height() - 1200;
  			
  			if ($(window).scrollTop() > navHeight) {
  				//alert($(window).scrollTop());
  				$('.navbar-default').addClass('on');
  				
  			} else {
  				$('.navbar-default').removeClass('on');
  				
  			}

  		} else {
  			navHeight = $(window).height() - 600;
  			if ($(window).scrollTop() > navHeight) {
  				//alert($(window).scrollTop());
  				$('.navbar-default').addClass('on');
  				$(".navbar-brand").css("display", "block");
  				//$("#content").fadeOut("slow");
  				
  			} else {
  				$('.navbar-default').removeClass('on');
  				$(".navbar-brand").css("display", "none");
  				//$("#content").fadeIn("slow");
  			}
  		}

        
    });

    $('body').scrollspy({ 
        target: '.navbar-default',
        offset: 80
    })

    $(document).ready(function () {

    	var updateFeed = function () {
    		var initialQuery = $('#query').val();
    		initialQuery = initialQuery.replace(" ", "");
    		var queryTags = initialQuery.split(",");
    		$('.social-feed-container').socialfeed({
    			// FACEBOOK
    			facebook: {
    				accounts: queryTags,
    				limit: 3,
    				access_token: '150849908413827|a20e87978f1ac491a0c4a721c961b68c'
    			},
    			// GOOGLEPLUS
    			/* google: {
					 accounts: queryTags,
					 limit: 2,
					 access_token: 'AIzaSyDpNQcIwQf5TcKmI8B0rh3e4OodIywJP14'
				 },*/
    			// Twitter
    			/*twitter: {
					accounts: queryTags,
					limit: 2,
					consumer_key: 'qzRXgkI7enflNJH1lWFvujT2P', // make sure to have your app read-only
					consumer_secret: '8e7E7gHuTwyDHw9lGQFO73FcUwz9YozT37lEvZulMq8FXaPl8O', // make sure to have your app read-only
				},*/
    			// VKONTAKTE
    			/* vk: {
					 accounts: queryTags,
					 limit: 2,
					 source: 'all'
				 },*/
    			// INSTAGRAM
    			/* instagram: {
					 accounts: queryTags,
					 limit: 10,
					 client_id: '88b4730e0e2c4b2f8a09a6184af2e218'
				 },*/

    			// GENERAL SETTINGS
    			length: 200,
    			show_media: true,
    			// Moderation function - if returns false, template will have class hidden
    			moderation: function (content) {
    				return (content.text) ? content.text.indexOf('fuck') == -1 : true;
    			},
    			//update_period: 5000,
    			// When all the posts are collected and displayed - this function is evoked
    			callback: function () {
    				console.log('all posts are collected');
    			}
    		});
    	};

    	/* $(".media-body .muted").each(function () {
    		$this = $(this);
    		$this.html($this.html().replace('days', 'dagar'));
    	});*/

    	updateFeed();

    	$('#button-update').click(function () {
    		updateFeed();
    	});


    	$("#team").owlCarousel({
  	 
  	      navigation : false, // Show next and prev buttons
  	      slideSpeed : 300,
  	      paginationSpeed : 400,
  	      autoHeight : true,
  	      itemsCustom : [
				        [0, 1],
				        [450, 2],
				        [600, 2],
				        [700, 2],
				        [1000, 4],
				        [1200, 4],
				        [1400, 4],
				        [1600, 4]
				      ],
  	  });

  	  $("#clients").owlCarousel({
  	 
  	      navigation : false, // Show next and prev buttons
  	      slideSpeed : 300,
  	      paginationSpeed : 400,
  	      autoHeight : true,
  	      itemsCustom : [
				        [0, 1],
				        [450, 2],
				        [600, 2],
				        [700, 2],
				        [1000, 4],
				        [1200, 5],
				        [1400, 5],
				        [1600, 5]
				      ],
  	  });

      $("#testimonial").owlCarousel({
        navigation : false, // Show next and prev buttons
        slideSpeed : 300,
        paginationSpeed : 400,
        singleItem:true
        });

  	});

  	/*====================================
    Portfolio Isotope Filter
    ======================================*/
    $(window).load(function() {
        var $container = $('#lightbox');
        $container.isotope({
            filter: '*',
            animationOptions: {
                duration: 750,
                easing: 'linear',
                queue: false
            }
        });
        $('.cat a').click(function() {
            $('.cat .active').removeClass('active');
            $(this).addClass('active');
            var selector = $(this).attr('data-filter');
            $container.isotope({
                filter: selector,
                animationOptions: {
                    duration: 750,
                    easing: 'linear',
                    queue: false
                }
            });
            return false;
        });

    });



}());


}
main();