/* =================================
------------------------------------
	Arcade - Architecture
	Version: 1.0
 ------------------------------------ 
 ====================================*/



'use strict';

var window_w = $(window).innerWidth();


$(window).on('load', function() { 
	/*------------------
		Preloder
	--------------------*/
	$(".loader").fadeOut(); 
	$("#preloder").delay(400).fadeOut("slow");

	__portfolio(); // call portfolio function
	
    
});

	
(function($) {

	/*------------------
		Navigation
	--------------------*/
	$('.nav-switch').on('click', function(event) {
		
		$('.nav-menu').slideToggle(400);
		event.preventDefault();
	});
    
	/*------------------
		Background set
	--------------------*/
	$('.set-bg').each(function() {
		var bg = $(this).data('setbg');
		$(this).css('background-image', 'url(' + bg + ')');
	});


	/*------------------
		Hero Slider
	--------------------*/
	var hero_s = $(".hero-slider");
    hero_s.owlCarousel({
        loop: true,
		autoplay:true,
		autoplaySpeed:50,
        margin: 0,
        nav: false,
        items: 1,
        dots: false,
        animateOut: 'fadeOutLeft',
    	animateIn: 'fadeInRight',
        navText: ['<i class="fa fa-long-arrow-left"></i> PREV', 'NEXT<i class="fa fa-long-arrow-right"></i>'],
        smartSpeed: 1200,
        autoHeight: false,
        //autoplay: true,
        mouseDrag: false,
        onInitialized: function() {
        	var a = this.items().length;
        	if(a < 10){
            	$("#snh-1").html("<span>01" + " / </span>0" + a);
       		} else{
       			$("#snh-1").html("<span>01" + " / </span>" + a);
       		}
        }
    }).on("changed.owl.carousel", function(a) {
        var b = --a.item.index, a = a.item.count;
        if(a < 10){
        	$("#snh-1").html("<span>0" + ( 1 > b ? b + a : b > a ? b - a : b) + " / </span>0" + a);
    	} else{
    		$("#snh-1").html("<span> "+ (1 > b ? b + a : b > a ? b - a : b) + " / </span>" + a);
    	}
    });



	/*------------------
		Projects Slider
	--------------------*/
	var project = $('#projects-carousel').owlCarousel({
		nav: true,
		loop: true,
		margin:20,
		navText: ['<i class="fa fa-long-arrow-left"></i> PREV', 'NEXT<i class="fa fa-long-arrow-right"></i>'],
		responsive:{
			0:{
				items:1,
				margin: 0
			},
			600:{
				items:2
			},
			800:{
				items:2
			},
			992:{
				items:3
			},
			1200:{
				items:4
			},
		}
	});
	/* animate filter */
	var owlAnimateFilter = function(even) {
		$(this)
		.addClass('__loading')
		.delay(70 * $(this).parent().index())
		.queue(function() {
			$(this).dequeue().removeClass('__loading')
		});
	}
	/* Projects filter */
	$('.projects-filter-nav li').on('click', function(e) {
		var filter_data = $(this).data('filter');

		/* return if current */
		if($(this).hasClass('btn-active')) return;

		/* active current */
		$(this).addClass('btn-active').siblings().removeClass('btn-active');

		/* Filter */
		project.owlFilter(filter_data, function(_owl) { 
			$(_owl).find('.single-project').each(owlAnimateFilter); 
		});
	});



	/*------------------
		Brands Slider
	--------------------*/
	$('#client-carousel').owlCarousel({
		nav: false,
		loop: true,
		margin:20,
		autoplay: true,
		responsive:{
			0:{
				items:1,
				margin: 0
			},
			600:{
				items:3
			},
			800:{
				items:4
			},
			992:{
				items:4
			},
			1200:{
				items:5
			},
		}
	});



	/*------------------
		Review Slider
	--------------------*/
	var test_s = $("#test-slider");
    test_s.owlCarousel({
        loop: true,
        margin: 0,
        nav: false,
        items: 1,
        dots: false,
        autoplay: true,
        onInitialized: function() {
        	var a = this.items().length;
        	if(a < 10){
            	$("#snh-2").html("<span>01" + "/ </span>0" + a);
       		} else{
       			$("#snh-2").html("<span>01" + "/ </span>" + a);
       		}
        }
    }).on("changed.owl.carousel", function(a) {
        var b = --a.item.index, a = a.item.count;
        if(a < 10){
        	$("#snh-2").html("<span>0" + ( 1 > b ? b + a : b > a ? b - a : b) + "/ </span>0" + a);
    	} else{
    		$("#snh-2").html("<span> "+ (1 > b ? b + a : b > a ? b - a : b) + "/ </span>" + a);
    	}
    });



    /*------------------
		Service Slider
	--------------------*/
	$('.service-slider').owlCarousel({
        loop: true,
        margin: 0,
        nav: false,
        items: 1,
        dots: true,
        autoplay: true,
    });



	/*------------------
		Popup
	--------------------*/
	$('.img-popup').magnificPopup({
		type: 'image',
		mainClass: 'img-popup-warp',
		removalDelay: 400,
	});


	/*------------------
		Accordions
	--------------------*/
	$('.panel-link').on('click', function (e) {
		$('.panel-link').parent('.panel-header').removeClass('active');
		var $this = $(this).parent('.panel-header');
		if (!$this.hasClass('active')) {
			$this.addClass('active');
		}
		e.preventDefault();
	});



	//Set progress circle 1
	$("#progress1").circleProgress({
		value: 0.75,
		size: 195,
		thickness: 20,
		fill: "#baff00",
		emptyFill: "rgba(0, 0, 0, 0)"
	});
	//Set progress circle 2
	$("#progress2").circleProgress({
		value: 0.83,
		size: 195,
		thickness: 20,
		fill: "#baff00",
		emptyFill: "rgba(0, 0, 0, 0)"
	});
	//Set progress circle 3
	$("#progress3").circleProgress({
		value: 0.25,
		size: 195,
		thickness: 20,
		fill: "#baff00",
		emptyFill: "rgba(0, 0, 0, 0)"
	});
	//Set progress circle 4
	$("#progress4").circleProgress({
		value: 0.95,
		size: 195,
		thickness: 20,
		fill: "#baff00",
		emptyFill: "rgba(0, 0, 0, 0)"
	});
    $( "#readmore1" ).click(function() {
	 
 	  $( "#readmoretext1" ).toggle( "slow", function() {		

    });
});
   $( "#readmore2" ).click(function() {
      $( "#readmoretext2" ).toggle( "slow", function() {
		;
    });
});
 $( "#readmore3" ).click(function() {
      $( "#readmoretext3" ).toggle( "slow", function() {
		;
    });
 });
 $( "#readmore4" ).click(function() {
      $( "#readmoretext4" ).toggle( "slow", function() {
		;
    });
 });
 $( "#readmore5" ).click(function() {
      $( "#readmoretext5" ).toggle( "slow", function() {
		;
    });
 });
 $( "#readmore6" ).click(function() {
      $( "#readmoretext6" ).toggle( "slow", function() {
		;
    });
});


})(jQuery);


/*------------------
	Portfolio 
--------------------*/
function __portfolio(){

	portfolio_item_size();

	$(window).on('resize', function(){
		portfolio_item_size();
	});


	var $container = $('#portfolio');
	$container.isotope({
		itemSelector: '.grid-item',
		percentPosition: true,
		masonry: {
			columnWidth: '.grid-sizer'
		}
	});

	// portfolio filter nav
	$('.portfolio-filter li').on("click", function(){
		$(".portfolio-filter li").removeClass("active");
		$(this).addClass("active");				 
		var selector = $(this).attr('data-filter');
		$container.isotope({
				filter: selector,
				animationOptions: {
				duration: 750,
				easing: 'linear',
				queue: false,
			}
		});
		return false;
	});
}

/*------------------
	Portfolio grid
--------------------*/
function portfolio_item_size(){
	$('#portfolio').find('.grid-item').each(function() {
		var pi_height1 = $(this).outerWidth(true),
		pi_height2 = pi_height1/2;
		
		if($(this).hasClass('grid-long') && window_w > 991){
			$(this).css('height', pi_height2);
		}else{
			$(this).css('height', Math.abs(pi_height1));
		}
	});
}

wow = new WOW({
    boxClass: 'wow', // default
    animateClass: 'animated', // default
    offset: 0, // default
    mobile: true, // default
    live: true // default
})

  new WOW().init();
  wow.init();
  
setInterval(function(){ 
   // toggle the class every five second
   $('#csop1').toggleClass('blink');  
   setTimeout(function(){
     // toggle back after 1 second
     $('#csop1').toggleClass('blink'); 
     	 
   },2000)
   var numAnim = new CountUp("szam1", 0, 33);
   if (!numAnim.error) {
		numAnim.start();
	} else {
		console.error(numAnim.error);
	}
},3000);

// setTimeout(function(){
	setInterval(function(){ 
	   // toggle the class every five second
	   $('#csop2').toggleClass('blink');  
	   
	   setTimeout(function(){
		 // toggle back after 1 second
		 $('#csop2').toggleClass('blink');  
	   },2000)
     var numAnim2 = new CountUp("szam2", 0, 2);
     if (!numAnim2.error) {
		numAnim2.start();
	} else {
		console.error(numAnim2.error);
	}
},3000);
 //},500);
 
 //setTimeout(function(){
		 // toggle back after 1 second
		  
	setInterval(function(){ 
			   // toggle the class every five second
			   $('#csop3').toggleClass('blink');  
			   setTimeout(function(){
				 // toggle back after 1 second
				 $('#csop3').toggleClass('blink'); 
				
			   },2000)
			    var numAnim3 = new CountUp("szam3", 0, 1);
     if (!numAnim3.error) {
		numAnim3.start();
	} else {
		console.error(numAnim3.error);
	}

	},3000);
 //},1000)
 
 //setTimeout(function(){
	setInterval(function(){ 
				   // toggle the class every five second
				   $('#csop4').toggleClass('blink');  
				   setTimeout(function(){
					 // toggle back after 1 second
					 $('#csop4').toggleClass('blink');  
				   },2000)
				    var numAnim4 = new CountUp("szam4", 0, 2);
				 if (!numAnim4.error) {
					numAnim4.start();
				} else {
					console.error(numAnim4.error);
				}

	},3000);			 
//},1500)