/*

Author: soniJS
Author URI: http://www.sonijs.com
Version: 1.0.0
Description: A Beautiful, Professional and Multipurpose Yetishare Theme Made by soniJS

*/
var sivt=jQuery;
sivt.noConflict();


/* ---------------------------------------------------
	Initialize Boostrap
-------------------------------------------------- */

!function (sivt) {

  sivt(function(){
    // Bootstrap Tooltip
    sivt("[data-toggle=tooltip-boot]").tooltip()

    // Bootstrap Popover
    sivt("[data-toggle=popover]")
      .popover()
		}
	)
}(window.jQuery)

/* ---------------------------------------------------
	Main Menu
-------------------------------------------------- */


sivt('.navbar .dropdown').hover(function() {
sivt(this).addClass('open').find('.dropdown-menu').first().stop(true, true).slideDown(300);
    }, function() {
sivt(this).removeClass('open').find('.dropdown-menu').first().stop(true, true).hide(300);
    });

sivt('.navbar .dropdown > a').click(function(){
location.href = this.href;
});


sivt(document).on('click', '.sivt-nav .dropdown-menu', function(e) {
  e.stopPropagation()
})


/* ---------------------------------------------------
	Smooth Scroll to Section
-------------------------------------------------- */

    sivt(function() {
        sivt('a.smooth-scroll[href*=#]:not([href=#])').click(function() {
            if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') || location.hostname == this.hostname) {

                var target = sivt(this.hash);
                target = target.length ? target : sivt('[name=' + this.hash.slice(1) + ']');
                if (target.length) {
                    sivt('html,body').animate({
                        scrollTop: target.offset().top
                    }, 2000, 'easeInOutExpo');
                    return false;
                }
            }
        });
    });


/* ---------------------------------------------------
	Sticky Bar
-------------------------------------------------- */

            sivt(function() {

                sivt(".header-main").stickOnScroll({
                    topOffset: 0,
                    setParentOnStick:   true
                });
				
				 var shrinkHeader = 600;
  					sivt(window).scroll(function() {
    				var scroll = getCurrentScroll();
      					if ( scroll >= shrinkHeader ) {
           					sivt('.header-main').addClass('shrink');
        					}
       					else {
            				sivt('.header-main').removeClass('shrink');
        					 }
						});
				function getCurrentScroll() {
				return window.pageYOffset || document.documentElement.scrollTop;
				}
                
            });


/* ---------------------------------------------------
	Panel Slide
-------------------------------------------------- */


sivt(document).ready(function(){

	sivt(".slide-panel-btn").click(function(){
		sivt("#slide-panel").slideToggle(250);
		sivt(this).toggleClass("active"); return false;
	});
	
	 
});



/* ---------------------------------------------------
	Revolution Slider
-------------------------------------------------- */
				jQuery(document).ready(function() {
				
					
								
					jQuery('.tp-banner').show().revolution(
					{
						dottedOverlay:"threexthree",
						delay:16000,
						startwidth:1170,
						startheight:700,
						hideThumbs:200,
						
						thumbWidth:100,
						thumbHeight:50,
						thumbAmount:3,
						
						navigationType:"none",
						navigationArrows:"solo",
						navigationStyle:"preview4",
						
						touchenabled:"on",
						onHoverStop:"on",
						
						swipe_velocity: 0.7,
						swipe_min_touches: 1,
						swipe_max_touches: 1,
						drag_block_vertical: false,
												
						parallax:"scroll",
						parallaxBgFreeze:"on",
						parallaxLevels:[10,20,30,40,50,60,70,80,90,100],
												
						keyboardNavigation:"off",
						
						navigationHAlign:"center",
						navigationVAlign:"bottom",
						navigationHOffset:0,
						navigationVOffset:20,

						soloArrowLeftHalign:"left",
						soloArrowLeftValign:"center",
						soloArrowLeftHOffset:20,
						soloArrowLeftVOffset:0,

						soloArrowRightHalign:"right",
						soloArrowRightValign:"center",
						soloArrowRightHOffset:20,
						soloArrowRightVOffset:0,
								
						shadow:0,
						fullWidth:"off",
						fullScreen:"on",

						spinner:"spinner4",
						
						stopLoop:"off",
						stopAfterLoops:-1,
						stopAtSlide:-1,

						shuffle:"off",
						
						autoHeight:"off",						
						forceFullWidth:"off",												
												
						hideThumbsOnMobile:"off",
						hideNavDelayOnMobile:1500,						
						hideBulletsOnMobile:"off",
						hideArrowsOnMobile:"off",
						hideThumbsUnderResolution:0,
						
						hideSliderAtLimit:0,
						hideCaptionAtLimit:0,
						hideAllCaptionAtLilmit:0,
						startWithSlide:0,
						fullScreenOffsetContainer: ".header-wrapper"	
					});
					
					
					
									
				});	//ready

/* ---------------------------------------------------
	Revolution Shop Slider
-------------------------------------------------- */
				jQuery(document).ready(function() {
				
					
								
					jQuery('.shop-slider').show().revolution(
					{
						dottedOverlay:"none",
						delay:16000,
						startwidth:1170,
						startheight:600,
						hideThumbs:200,
						
						thumbWidth:100,
						thumbHeight:50,
						thumbAmount:3,
						
						navigationType:"none",
						navigationArrows:"solo",
						navigationStyle:"preview4",
						
						touchenabled:"on",
						onHoverStop:"on",
						
						swipe_velocity: 0.7,
						swipe_min_touches: 1,
						swipe_max_touches: 1,
						drag_block_vertical: false,
												
						parallax:"scroll",
						parallaxBgFreeze:"on",
						parallaxLevels:[10,20,30,40,50,60,70,80,90,100],
												
						keyboardNavigation:"off",
						
						navigationHAlign:"center",
						navigationVAlign:"bottom",
						navigationHOffset:0,
						navigationVOffset:20,

						soloArrowLeftHalign:"left",
						soloArrowLeftValign:"center",
						soloArrowLeftHOffset:20,
						soloArrowLeftVOffset:0,

						soloArrowRightHalign:"right",
						soloArrowRightValign:"center",
						soloArrowRightHOffset:20,
						soloArrowRightVOffset:0,
								
						shadow:0,
						fullWidth:"off",
						fullScreen:"off",

						spinner:"spinner4",
						
						stopLoop:"off",
						stopAfterLoops:-1,
						stopAtSlide:-1,

						shuffle:"off",
						
						autoHeight:"off",						
						forceFullWidth:"off",												
												
						hideThumbsOnMobile:"off",
						hideNavDelayOnMobile:1500,						
						hideBulletsOnMobile:"off",
						hideArrowsOnMobile:"off",
						hideThumbsUnderResolution:0,
						
						hideSliderAtLimit:0,
						hideCaptionAtLimit:0,
						hideAllCaptionAtLilmit:0,
						startWithSlide:0,
						fullScreenOffsetContainer: ".header-wrapper"	
					});
					
					
					
									
				});	//ready

/* ---------------------------------------------------
	Portfolio
-------------------------------------------------- */

		sivt(document).ready(function(){
			
		
			
			// "colio" plugin
			sivt('.portfolio .portfolio-grid').colio({
				theme: 'sivt',
				placement: 'after',
				scrollOffset: 60,
				expandLink: '.portfolio-expand',          // selector for element to expand colio viewport  
    			expandDuration: 900,                // duration of expand animation, ms  
    			expandEasing: 'swing',              // easing for expand animation  
    			collapseDuration: 500,              // duration of collapse animation, ms  
    			collapseEasing: 'swing',            // easing for collapse animation  
    			scrollDuration: 1300,                // page scroll duration, ms  
    			scrollEasing: 'swing',              // page scroll easing  
    			syncScroll: true,                  // sync page scroll with expand/collapse of colio viewport 
    			contentFadeIn: 900,                 // content fade-in duration, ms  
    			contentFadeOut: 300,                // content fade-out duration, ms  
    			contentDelay: 600,                  // content fade-in delay on expand, ms 
				closeText: '<span>X</span>',    // text/html for close button  
				nextText: '<span></span>',      // text/html for next button  
    			prevText: '<span></span>',      // text/html for previous button  
				hiddenItems: '.isotope-hidden',
				onExpand: 	function(content){sivt(".colio").resize() },

				onContent: function(content){
	
						sivt('.carousel-box-portfolio .carousel',content).each(function(index, element) {
							
							var carousel = sivt(this).closest('.carousel-box-portfolio');
							
							sivt(this).owlCarousel({
								//direction:'rtl', //use if your site is RTL
								autoPlay	 	 : sivt(this).data('carousel-autoplay'),
								items		 	 : sivt(this).data('carousel-items'),
								navigation		 : sivt(this).data('carousel-nav'),
								pagination		 : sivt(this).data('carousel-pagination'),
								singleItem		 : sivt(this).data('carousel-single'),
								transitionStyle	 : sivt(this).data('carousel-transition'),
								slideSpeed	     : sivt(this).data('carousel-speed'),
								navigationText : ["<i class='fa fa-angle-left'></i>","<i class='fa fa-angle-right'></i>"],
							}) 
							
						});

						
						if (sivt().magnificPopup) {
												  sivt('[data-lightbox=image], .lightbox').each(function(index, element) {sivt(this).magnificPopup({type:'image',	mainClass: 'mfp-fade',removalDelay: 300, fixedContentPos: false,  fixedBgPos: true,  overflowY: 'auto',	closeOnContentClick: true}); });
												  sivt('[data-lightbox=video], [data-lightbox=map], [data-lightbox=iframe], .lightbox-video, .lightbox-map, .lightbox-iframe').each(function(index, element) {sivt(this).magnificPopup({mainClass: 'mfp-fade', removalDelay: 300, fixedContentPos: false, fixedBgPos: true, overflowY: 'auto',  type: 'iframe',  fixedContentPos: false});});
												  sivt('[data-lightbox=gallery], .lightbox-gallery').each(function(index, element) {sivt(this).magnificPopup({mainClass: 'mfp-fade',
removalDelay: 300, fixedContentPos: false, fixedBgPos: true, overflowY: 'auto',  type: 'image', delegate: 'a', gallery: { enabled: true}});});
												};
					}

			});


			
			// "isotope" plugin
			var $container = sivt('.portfolio-grid');
			$container.imagesLoaded( function(){
				$container.isotope({
					
				});
			});	

			var filter = '*', isotope_run = function(f) {
				$container.isotope({filter: f}).
				trigger('colio','excludeHidden');
			};						
			sivt('#filters a').click(function(){
				var selector = sivt(this).attr('data-filter');
				$container.isotope({ filter: selector });
				return false;
			});
			
			// set selected menu items
			var $optionSets = sivt('.option-set'),
			$optionLinks = $optionSets.find('a'); 
			$optionLinks.click(function(){
				var $this = sivt(this);
				// don't proceed if already selected
				if ( $this.hasClass('selected') ) {
				return false;
				}
			var $optionSet = $this.parents('.option-set');
			$optionSet.find('.selected').removeClass('selected');
			$this.addClass('selected'); 
			});
			
			isotope_run(filter);
			
		});

				
/* ---------------------------------------------------
	OWL Carousel
-------------------------------------------------- */

  sivt('.carousel-box .carousel').each(function () {
	var carousel = sivt(this).closest('.carousel-box');

		sivt(this).owlCarousel({
			//direction		 :'rtl', //use if your site is RTL
	  		autoPlay	 	 : sivt(this).data('carousel-autoplay'),
	  		items		 	 : sivt(this).data('carousel-items'),
			navigation		 : sivt(this).data('carousel-nav'),
			pagination		 : sivt(this).data('carousel-pagination'),
			singleItem		 : sivt(this).data('carousel-single'),
			transitionStyle	 : sivt(this).data('carousel-transition'),
			slideSpeed	     : sivt(this).data('carousel-speed'),
			navigationText : ["<i class='fa fa-angle-left'></i>","<i class='fa fa-angle-right'></i>"],
			lazyLoad : true,
	  		autoHeight : true,
		})
  });


/* Sync Carousel */

    sivt(document).ready(function() {
     
    var sync1 = sivt("#full-sync");
    var sync2 = sivt("#thumb-sync");
     
    sync1.owlCarousel({
    singleItem : true,
    slideSpeed : 1000,
    navigation: false,
    pagination:false,
	transitionStyle : "fade",
    afterAction : syncPosition,
    responsiveRefreshRate : 200,
    });
     
    sync2.owlCarousel({
    items : 3,
	itemsDesktop : [1199,3],
	itemsDesktopSmall : [979,3],
	itemsTablet : [768,3],
	itemsMobile : [479,2],
    pagination:false,
    responsiveRefreshRate : 100,
    afterInit : function(el){
    el.find(".owl-item").eq(0).addClass("synced");
    }
    });
     
    function syncPosition(el){
    var current = this.currentItem;
    sivt("#thumb-sync")
    .find(".owl-item")
    .removeClass("synced")
    .eq(current)
    .addClass("synced")
    if(sivt("#thumb-sync").data("owlCarousel") !== undefined){
    center(current)
    }
    }
     
    sivt("#thumb-sync").on("click", ".owl-item", function(e){
    e.preventDefault();
    var number = sivt(this).data("owlItem");
    sync1.trigger("owl.goTo",number);
    });
     
    function center(number){
    var sync2visible = sync2.data("owlCarousel").owl.visibleItems;
    var num = number;
    var found = false;
    for(var i in sync2visible){
    if(num === sync2visible[i]){
    var found = true;
    }
    }
     
    if(found===false){
    if(num>sync2visible[sync2visible.length-1]){
    sync2.trigger("owl.goTo", num - sync2visible.length+2)
    }else{
    if(num - 1 === -1){
    num = 0;
    }
    sync2.trigger("owl.goTo", num);
    }
    } else if(num === sync2visible[sync2visible.length-1]){
    sync2.trigger("owl.goTo", sync2visible[1])
    } else if(num === sync2visible[0]){
    sync2.trigger("owl.goTo", num-1)
    }
    }
     
    });




/* ---------------------------------------------------
	Parallax
-------------------------------------------------- */


		sivt(function(){
			sivt.stellar({
				horizontalScrolling: false,
				verticalOffset: 0,
			});
		});


/* ---------------------------------------------------
	Lightbox
-------------------------------------------------- */


if (sivt().magnificPopup) {
	sivt('[data-lightbox=image], .lightbox').each(function(index, element) {
		sivt(this).magnificPopup({
			type:'image',
			mainClass: 'mfp-fade',
			fixedContentPos: false,
           	fixedBgPos: true,
           	overflowY: 'auto',
			removalDelay: 300,
			closeOnContentClick: true,
			
		});		
	});
	
	sivt('[data-lightbox=video], [data-lightbox=map], [data-lightbox=iframe], .lightbox-video, .lightbox-map, .lightbox-iframe').each(function(index, element) {
		sivt(this).magnificPopup({
			mainClass: 'mfp-fade',
			removalDelay: 300,
			fixedContentPos: false,
           	fixedBgPos: true,
           	overflowY: 'auto',
		  	type: 'iframe',
		  	fixedContentPos: false
		});
	});
	
	sivt('[data-lightbox=gallery], .lightbox-gallery').each(function(index, element) {
		sivt(this).magnificPopup({
			mainClass: 'mfp-fade',
			removalDelay: 300,
			fixedContentPos: false,
           	fixedBgPos: true,
           	overflowY: 'auto',
		  	type: 'image',
		  	delegate: 'a',
			gallery: {
				enabled: true
			}
		});
	});
	
	
};


/* ---------------------------------------------------
	Tooltips
-------------------------------------------------- */

        sivt(document).ready(function() {
            sivt(".ToolTip").OpieTooltip({     

            });
        }); 

/* ---------------------------------------------------
	Animation on Scroll
-------------------------------------------------- */	
		
sivt('.animation').waypoint(function(direction) {
  sivt(this).addClass('animation-active');
}, { 	offset: '100%',
triggerOnce: true });

/* ---------------------------------------------------

/* ---------------------------------------------------
	Team Members
-------------------------------------------------- */
sivt(".team-wrapper").on("click", function() {
    sivt(this).toggleClass('cardtoggle').siblings().removeClass('cardtoggle');
});

/* ---------------------------------------------------
	Counters
-------------------------------------------------- */

sivt('.counter').waypoint(function(direction) {
  sivt(this).addClass('timer');
  sivt('.timer').countTo()
}, { 	offset: '100%',
triggerOnce: true });

sivt('.timer').countTo()




/* ---------------------------------------------------
	Video BG
-------------------------------------------------- */



/* Shop Input */
sivt('.qup').on('click',function(){
    sivt('.input-quantity').val(parseInt(sivt('.input-quantity').val())+1);
});

sivt('.qdown').on('click',function(){
    sivt('.input-quantity').val(parseInt(sivt('.input-quantity').val())-1);
}); 


/* ---------------------------------------------------
	Back to Top
-------------------------------------------------- */

sivt(document).ready(function(){
 
	sivt(window).scroll(function(){
	    if (sivt(this).scrollTop() > 100) {
	        sivt('.scrollup').fadeIn();
	    } else {
	        sivt('.scrollup').fadeOut();
	    }
	});	

});

/* ---------------------------------------------------
	UnderConstruction Counter
-------------------------------------------------- */

      sivt(function() {
        var endDate = "May 12, 2015 09:03:25";

        sivt('.countdown.styled').countdown({
          date: endDate,
          render: function(data) {
            sivt(this.el).html("<div class='col-md-3 col-sm-6'><div class='counter-block'>" + this.leadingZeros(data.days, 3) + " <span>days</span></div></div><div class='col-md-3 col-sm-6'><div class='counter-block'>" + this.leadingZeros(data.hours, 2) + " <span>hrs</span></div></div><div class='col-md-3 col-sm-6'><div class='counter-block'>" + this.leadingZeros(data.min, 2) + " <span>min</span></div></div><div class='col-md-3 col-sm-6'><div class='counter-block'>" + this.leadingZeros(data.sec, 2) + " <span>sec</span></div></div>");
          }
        });


      });


/* ---------------------------------------------------
	Animate Demo - can be removed on production website
-------------------------------------------------- */
  function testAnim(x) {
    sivt('#animationSandbox').removeClass().addClass(x + ' animation animation-active').one('webkitAnimationEnd mozAnimationEnd oAnimationEnd animationEnd', function(){
      sivt(this).removeClass();
    });
  };

  sivt(document).ready(function(){
    sivt('.js--triggerAnimation').click(function(){
      var anim = sivt('.js--animations').val();
      testAnim(anim);
    });
  });



