/*
 *  Whiteboard64 Pro Theme Custom Scripts
 *  Copyright (c) 2017 Whiteboard64 Theme
 *  http://www.sumanshresthaa.com.np/
 *  Licensed under MIT
 */

(function($) {  
  	//Bootstrap Carousel First Item Active
  	$('.carousel-inner .item:first-child').addClass('active');
    $('#myCarousel').carousel({
      interval: 6000,
      cycle: true
    });

    $('.meta-socials li').addClass('col-sm-12 col-md-6');
    $('.meta-socials li a').addClass('col-sm-12 col-md-12');

    $(document).ready(function()
    {
      $('#slider1').tinycarousel();
      $('#slider2').tinycarousel();
      $('#slider3').tinycarousel();
    });

  	//Pagination for Next & Previous Adding FontAwesome Icon
  	$('.nav-previous a').prepend('<i class="fa fa-angle-double-left"></i>');
  	$('.nav-next a').prepend('<i class="fa fa-angle-double-right"></i>');

  	$('.widget li a').prepend('<i class="fa fa-angle-double-right"></i>');
  	$('.footers li a').prepend('<i class="fa fa-angle-double-right"></i>');

})(jQuery);





(function($) {  
	// Activating Animations
	var wow = new WOW(
	  {
	    boxClass:     'wow',      // animated element css class (default is wow)
	    animateClass: 'animated', // animation css class (default is animated)
	    offset:       0,          // distance to the element when triggering the animation (default is 0)
	    mobile:       true,       // trigger animations on mobile devices (default is true)
	    live:         true,       // act on asynchronously loaded content (default is true)
	    callback:     function(box) {
	      // the callback is fired every time an animation is started
	      // the argument that is passed in is the DOM node being animated
	    },
	    scrollContainer: null // optional scroll container selector, otherwise use window
	  }
	);
	wow.init();
})(jQuery);



(function($) { 

  //Sticky Header
  $(window).scroll(function() {
      if ($(this).scrollTop() > 10){  
          $('.topmenu').addClass("sticky-menu");
      }
      else{
          $('.topmenu').removeClass("sticky-menu");
      }
  });

	//Tab to top
	$(window).scroll(function() {
  	if ($(this).scrollTop() > 1){  
    	$('.scroll-top-wrapper').addClass("show");
  	}
  	else{
    	$('.scroll-top-wrapper').removeClass("show");
  	}
	});

	$(".scroll-top-wrapper").on("click", function() {
  	$("html, body").animate({ scrollTop: 0 }, 600);
  	return false;
	});

})(jQuery);




// Smart Menu
(function($) {

  // init ondomready
  $(function() {

    // init all navbars that don't have the "data-sm-skip" attribute set
    var $navbars = $('ul.navbar-nav:not([data-sm-skip])');
    $navbars.each(function() {
      var $this = $(this);
      $this.addClass('sm').smartmenus({

          // these are some good default options that should work for all
          // you can, of course, tweak these as you like
          subMenusSubOffsetX: 2,
          subMenusSubOffsetY: -6,
          subIndicators: false,
          collapsibleShowFunction: null,
          collapsibleHideFunction: null,
          rightToLeftSubMenus: $this.hasClass('navbar-right'),
          bottomToTopSubMenus: $this.closest('.navbar').hasClass('navbar-fixed-bottom')
        })
        .bind({
          // set/unset proper Bootstrap classes for some menu elements
          'show.smapi': function(e, menu) {
            var $menu = $(menu),
              $scrollArrows = $menu.dataSM('scroll-arrows');
            if ($scrollArrows) {
              // they inherit border-color from body, so we can use its background-color too
              $scrollArrows.css('background-color', $(document.body).css('background-color'));
            }
            $menu.parent().addClass('open');
          },
          'hide.smapi': function(e, menu) {
            $(menu).parent().removeClass('open');
          }
        })
        // set Bootstrap's "active" class to SmartMenus "current" items (should someone decide to enable markCurrentItem: true)
        .find('a.current').parent().addClass('active');

      // keep Bootstrap's default behavior for parent items when the "data-sm-skip-collapsible-behavior" attribute is set to the ul.navbar-nav
      // i.e. use the whole item area just as a sub menu toggle and don't customize the carets
      var obj = $this.data('smartmenus');
      if ($this.is('[data-sm-skip-collapsible-behavior]')) {
        $this.bind({
          // click the parent item to toggle the sub menus (and reset deeper levels and other branches on click)
          'click.smapi': function(e, item) {
            if (obj.isCollapsible()) {
              var $item = $(item),
                $sub = $item.parent().dataSM('sub');
              if ($sub && $sub.dataSM('shown-before') && $sub.is(':visible')) {
                obj.itemActivate($item);
                obj.menuHide($sub);
                return false;
              }
            }
          }
        });
      }

      var $carets = $this.find('.caret');

      // onresize detect when the navbar becomes collapsible and add it the "sm-collapsible" class
      var winW;
      function winResize() {
        var newW = obj.getViewportWidth();
        if (newW != winW) {
          if (obj.isCollapsible()) {
            $this.addClass('sm-collapsible');
            // set "navbar-toggle" class to carets (so they look like a button) if the "data-sm-skip-collapsible-behavior" attribute is not set to the ul.navbar-nav
            if (!$this.is('[data-sm-skip-collapsible-behavior]')) {
              $carets.addClass('navbar-toggle sub-arrow');
            }
          } else {
            $this.removeClass('sm-collapsible');
            if (!$this.is('[data-sm-skip-collapsible-behavior]')) {
              $carets.removeClass('navbar-toggle sub-arrow');
            }
          }
          winW = newW;
        }
      };
      winResize();
      $(window).bind('resize.smartmenus' + obj.rootId, winResize);
    });

  });

  // fix collapsible menu detection for Bootstrap 3
  $.SmartMenus.prototype.isCollapsible = function() {
    return this.$firstLink.parent().css('float') != 'left';
  };

})(jQuery);