
$(window).load(function() {
  "use strict";
    /* ==============================================
    PRELOADER
    =============================================== */
    var preloaderDelay = 800;
    var preloaderFadeOutTime = 1000;

    function hidePreloader() {
        var loadingAnimation = $('#loading-animation');
        var preloader = $('.main');

        loadingAnimation.fadeOut();
        preloader.delay(preloaderDelay).fadeOut(preloaderFadeOutTime, function() {
          jQuery('.animate').waypoint(function() {
               var animation = jQuery(this).attr("data-animate");
               jQuery(this).addClass(animation);
               jQuery(this).addClass('animated');
          }, { offset: '80%' });
         });
    }

    hidePreloader();

});

/* DOCUMENT READY  ----------- */
jQuery(document).ready(function() {

"use strict";

/*Removed call to video for checkout pages*/


/* ==============================================
    BRI SCROLL PAGE WITH EASING EFFECT
    =============================================== */
  $('#getstarted, .arrow-down-liteBlue').bind('click', function(e) {
      e.preventDefault();
      var target = this.hash;
      $.scrollTo(target, 750, {
        easing: 'easeInSine',
        axis: 'y',
        offset: -100
      });
  });
  $('.arrow-down-medBlue, .arrow-down-orange, .arrow-down-blue').bind('click', function(e) {
      e.preventDefault();
      var target = this.hash;
      $.scrollTo(target, 750, {
        easing: 'easeInSine',
        axis: 'y',
        offset: -240
      });
  });
  $('.scrollit-pricing').bind('click', function(e) {
      e.preventDefault();
      var target = this.hash;
      $.scrollTo(target, 750, {
        easing: 'easeInSine',
        axis: 'y',
        offset: -220
      });
  });

  /* ==============================================
    ACTIVE LINKS ON NAVIGATION BAR
    =============================================== */
  jQuery('body').scrollspy({ offset: 300,target: 'nav' })

  /* ==============================================
    TESTIMONIALS SLIDER
    =============================================== */
	var owl = $("#testimonials-slides");
	owl.owlCarousel({
		loop:true,
		nav : true, // Show next and prev buttons
		smartSpeed : 600,
		//dotsSpeed : 800,
		//singleItem:true,
		slideBy:1,
		items : 1,
		navText : ["<span class='testimonial-icon' aria-hidden='true' data-icon='&#x3c;'></span>", "<span class='testimonial-icon' aria-hidden='true' data-icon='&#x3d;'></span>"],
		dots : false
	});
	/* ==============================================
    DASHBOARD SLIDER
    =============================================== */
	var owl = $("#dashboard-demo");
	owl.owlCarousel({
		loop:true,
		nav : true, // Show next and prev buttons
		smartSpeed : 600,
		//dotsSpeed : 800,
		//singleItem:true,
		slideBy:1,
		items : 1,
		navText : ["<span class='dashboard-icon' aria-hidden='true' data-icon='&#x3c;'></span>", "<span class='dashboard-icon' aria-hidden='true' data-icon='&#x3d;'></span>"],
		dots : false,
        margin:15,
        autoHeight:true,
        navContainer: "#navit",
		onInitialized : function(){
        var activeImg = $('.owl-carousel').find('.active').find('img');
        //var comment = activeImg.attr('alt');
        var title = activeImg.attr('title');
        $('#image-caption').html('<h3>'+title+'</h3>');
    }

	});

	owl = $('#dashboard-demo').owlCarousel();
		$(".prev").click(function () {
    	owl.trigger('prev.owl.carousel');
	});
	$(".next").click(function () {
    	owl.trigger('next.owl.carousel');
	});

	owl.on('translated.owl.carousel', function(event) {
    	var activeImg = $(this).find('.active').find('img');
    	//var comment = activeImg.attr('alt');
    	var title = activeImg.attr('title');
    	$('#image-caption').html('<h3>'+title+'</h3>');

	});


    $('.popup-link, .popup-link-inception').magnificPopup({
  		type: 'ajax',
    	fixedContentPos: false,
    	fixedBgPos: true,
 		overflowY: 'auto',
		closeBtnInside: true,
    	preloader: false,
    	midClick: true,
    	removalDelay: 500,
   		mainClass: 'my-mfp-slide-bottom'

  	});



 /*POPUP WITHIN A POPUP ON WEBCAM SOFTWARE PAGE: (GET STARTED button in popup webcam sample popups), the faux button in the video sample popup closes the popup and prompts a click on .popup-link-incenption#faux-popup to open second form popup*/

    $(document).on('click', '#myButton', function(e){
     	e.preventDefault();

		$.magnificPopup.close();

    	window.setTimeout(openNewAjaxPopup, 501);
	});

  	function openNewAjaxPopup() {
  		$( ".popup-link-inception#faux-popup" ).trigger( "click" );
	}

  /* ==============================================
    TOOLTIPS AND CHECKOUT PROGRESS, WATCHA WATCHIN, CART POPUP SLIDER
    =============================================== */

 	 $('[data-toggle="tooltip"]').tooltip({container: 'body'});

     $('#checkout-progress .nav-pills > li.checkit > a > span.stepit').html("<span data-icon='&#x4e;' aria-hidden='true'></span>");

  	 $('#whatcha-watchin').click(function(){
    $('#whatcha-watchin-block').slideDown('1500', "swing", function () {
        // Animation complete.
    });
	});

    $('#whatcha-watchin-block .close-this').click(function(){
    $('#whatcha-watchin-block').slideUp('1500', "swing", function () {
        // Animation complete.
    });
	});

        
    // Cart UI: Set the cart-drop down to drop down after 1 second and retract after 2 more seconds with animation duration of 1.5 seconds.
    
    setTimeout(function() {
    $('#cart-popup-block').slideDown('1500', "swing", function () {
        // Animation complete.
        	setTimeout(function() {
      		// Do something after 5 seconds
     	 		$('#cart-popup-block').slideUp('1500', "swing", function () {
        		// Animation complete.
    			});
            }, 2000);
    });
    }, 1000);
        
    
    $('#cart-popup').click(function(){
    $('#cart-popup-block').slideDown('1500', "swing", function () {
        // Animation complete.
    });
	});

    $('#cart-popup-block .close-this').click(function(){
    $('#cart-popup-block').slideUp('1500', "swing", function () {
        // Animation complete.
    });
	});



  /* ==============================================
    /* LOAD THE ANIMATIONS IF THE BROWSER IS NOT IE
  ================================================== */
  if( !device.tablet() && !device.mobile() ) { //Load the animations if the device is not a mobile or tablet
    $('head').append('<!--[if !IE]><!--><link rel="stylesheet" type="text/css" media="screen" href="/css/animate.css"><!--<![endif]-->');
  }


}); /* END DOCUMENT READY  ----------- */
