/*

WordPress Hack

----------------------------------

Wrap all document in to following.

jQuery(document).ready(function($) {

	...

});

*/

jQuery(document).ready(function($) {

/*On LP page load modal Start*/
// $(window).on('load', function() {
//   setTimeout(function() {
//     if ($('body').hasClass('page-id-2009')) {
//         $('#costumModal9').modal('show');
//     }
//   }, 3000);
        
//     });
$(window).on('load', function() {
  if (localStorage.getItem("hasCodeRunBefore") === null) {
		setTimeout(function() {
			if ($('body').hasClass('page-id-2466')) {
				$('#costumModal9').modal('hide');
			}
			else{
				$('#costumModal9').modal('show');
			};
		}, 5000);
        localStorage.setItem("hasCodeRunBefore", true);
    }     
    });
	
	
	
	
/*On LP page load modal End*/
	
// Close Button of Modal On Mobile Screen Starts
// 
$(".modalClose").on('click', function(){

	$('body').removeClass('modal-open');
	$('body').addClass('modal-closed');
	$("#costumModal9").modal('hide');
	$("#costumModal9").removeClass('in');
	$(".modal-backdrop").remove();
	
});
	
// Close Button of Modal On Mobile Screen Ends

// Mobile Sub Menu Open JS
$(document).ready(function(){
	$("#menu-header-mobile-menu li").on('click', function(){
// 		$('#menu-header-mobile-menu li').removeClass('active');
		$(this).toggleClass("active");
	});
});
// Mobile Sub Menu Open JS Ends

	
$(document).ready(function(e) {

/* To add and remove active class on clicked li of navigation. */

var selector = 'nav li';



$(selector).on('click', function(){

    $(selector).removeClass('active');

    $(this).addClass('active');

});

/* END */



/* To add class first and last on first and last of all li. */

$('ul').children('li:first-child').addClass('first');

$('ul').children('li:last-child').addClass('last');

/* END */



});

/*Bootstrap menu on hover*/

// Bootstrap menu magic

  /*$(window).resize(function() {

    if ($(window).width() < 768) {

      $(".dropdown-toggle").attr('data-toggle', 'dropdown');

    } else {

      $(".dropdown-toggle").removeAttr('data-toggle dropdown');

    }

  });*/
	
	// Select all elements with the class 'myButton'
// const buttons = document.querySelectorAll('.designBtn');
// buttons.forEach(button => {
//     button.addEventListener('click', function(event) {
//         event.preventDefault(); // Prevent default behavior if needed
//         alert('Button clicked!');
//     });
// });

/*Bootstrap menu on hover*/

/* === Sticky Menu === 

    (function () {

        var nav = $('header');

        var scrolled = false;



        $(window).scroll(function () {



            if (110 < $(window).scrollTop() && !scrolled) {

                nav.addClass('sticky animated fadeInDown').animate({ 'margin-top': '0px' });



                scrolled = true;

            }



            if (110 > $(window).scrollTop() && scrolled) {

                nav.removeClass('sticky animated fadeInDown').css('margin-top', '0px');



                scrolled = false;

            }

        });

    }());*/

// 			menu hover 
$(document).ready(function(){
  var $trs = $('.web-development');
  $trs.hover(
    function() {
      var i = $(this).index() + 1;
      $trs.addClass('hover');
    },
    function() {
      var i = $(this).index() + 1;
      $trs.removeClass('hover');
    }
  ); 
});

	
	$(document).ready(function(){
  var $trs = $('.ios-development');
  $trs.hover(
    function() {
      var i = $(this).index() + 1;
      $trs.addClass('hover');
    },
    function() {
      var i = $(this).index() + 1;
      $trs.removeClass('hover');
    }
  ); 
});
	
		$(document).ready(function(){
  var $trs = $('.graphics-design');
  $trs.hover(
    function() {
      var i = $(this).index() + 1;
      $trs.addClass('hover');
    },
    function() {
      var i = $(this).index() + 1;
      $trs.removeClass('hover');
    }
  ); 
});
	
		$(document).ready(function(){
  var $trs = $('.woocommerce-development');
  $trs.hover(
    function() {
      var i = $(this).index() + 1;
      $trs.addClass('hover');
    },
    function() {
      var i = $(this).index() + 1;
      $trs.removeClass('hover');
    }
  ); 
});
// menu hover
			// Search

	jQuery( '#search-button' ).click( function () {

		console.log( "Open Search, Search Centered" );

		$( "div.mk-fullscreen-search-overlay" ).addClass( "mk-fullscreen-search-overlay-show" );

	} );

	jQuery( "a.mk-fullscreen-close" ).click( function () {

		console.log( "Closed Search" );

		$( "div.mk-fullscreen-search-overlay" ).removeClass( "mk-fullscreen-search-overlay-show" );

	} );

	
  /*Search End*/
// 	full screen menu
	
// 	full screen menu
	
	window.onload = function () {
  const bars = document.querySelector(".bars");
  const menu = document.querySelector(".menu");
  bars.addEventListener("click", function (e) {
    this.classList.toggle("active");
    if (this.classList.contains("active")) {
      gsap.to(".menu-mob", {
        duration: 0.1,
        display: "flex",
        ease: "expo.in"
      });
      gsap.to(".navBefore", {
        duration: 0.5,
        marginLeft: "0",
        ease: "expo.in"
      });
      gsap.to(".nav", {
        duration: 0.8,
        marginLeft: "0",
        delay: 0.3,
        ease: "expo.in"
      });
      gsap.to(".mobile-header .menu-header-mobile-menu-container .menu", {
        duration: 1,
        opacity: "1",
        delay: 0.8,
        ease: "expo.in"
      });
    } else {
      gsap.to(".navigation", {
        duration: 0.2,
        opacity: "0",
        ease: "expo.in"
      });
      gsap.to(".nav", {
        duration: 1,
        marginLeft: "100%",
        delay: 0.3,
        ease: "expo.in"
      });
      gsap.to(".navBefore", {
        duration: 1,
        marginLeft: "100%",
        delay: 0.5,
        ease: "expo.in"
      });
      gsap.to(".menu-mob", {
        duration: 1,
        display: "none",
        delay: 1,
        ease: "expo.in"
      });
    }
  });
};
	

	
// 	SIde Menu Ends
// 	full screen menu ended
	
// 	Case Study Slider Starts	
	$(document).ready(function() {
// Swiper: Slider
    new Swiper('.caseStudy-container', {
        loop: true,
        navigation: {
        nextEl: '.swiper-button-next',
        prevEl: '.swiper-button-prev',
   		},
		speed: 1000,
    	autoplay: {
        delay: 3000,
    	},
        slidesPerView: 2.5,
        paginationClickable: true,
        spaceBetween: 20,
        centeredSlides: true,
        breakpoints: {
            1920: {
                slidesPerView: 2.5,
                spaceBetween: 30
            },
            1028: {
                slidesPerView: 2,
                spaceBetween: 30
            },
            280: {
                slidesPerView: 1,
                spaceBetween: 10
            }
        }
    });
});
// 	Case Study Slider Ends	

	// 	Technology Swiper on Mobile Screen Starts	
	$(document).ready(function() {
// Swiper: Slider
    new Swiper('.techSwiper-container', {
        loop: true,
        navigation: {
        nextEl: '.swiper-button-next',
        prevEl: '.swiper-button-prev',
   		},
		speed: 1000,
    	autoplay: {
        delay: 3000,
    	},
        slidesPerView: 1,
        paginationClickable: true,
        spaceBetween: 20,
    });
});
// 	Technology Swiper on Mobile Screen (LP PAge)	
	
	// 	Logo Study Slider Starts	
	$(document).ready(function() {
// Swiper: Slider
    new Swiper('.logo-container', {
        loop:true,
        navigation: {
        nextEl: '.swiper-button-next',
        prevEl: '.swiper-button-prev',
   		},
		speed: 1000,
    	autoplay: {
        delay: 3000,
    	},
        slidesPerView: 5,
        paginationClickable: true,
        spaceBetween: 20,
        
        breakpoints: {
            1920: {
                slidesPerView: 5,
                spaceBetween: 30
            },
            1028: {
                slidesPerView: 5,
                spaceBetween: 30
            },
            480: {
                slidesPerView: 2,
                spaceBetween: 10
            },
			  280: {
                slidesPerView: 1.5,
                spaceBetween: 10,
				centeredSlides: false
            }
        }
    });
});
// 	Logo Slider Ends	

	
	
	
//  Language SWiper Starts

	$(document).ready(function() {
// Swiper: Slider
    new Swiper('.languageSlider-container', {
		loop: true,
        navigation: {
        nextEl: '.swiper-button-next',
        prevEl: '.swiper-button-prev',
   		},
		speed: 1000,
    	autoplay: {
        delay: 3000,
    	},
        slidesPerView: 4,
        paginationClickable: true,
        spaceBetween: 20,
        breakpoints: {
            1920: {
                slidesPerView: 4,
                spaceBetween: 30
            },
            1028: {
                slidesPerView: 4,
                spaceBetween: 30
            },
            280: {
                slidesPerView: 1,
                spaceBetween: 10
            }
        }
    });
});

//  Language SWiper Ends

//  Review SWiper Starts

	$(document).ready(function() {
// Swiper: Slider
    new Swiper('.reviewSlider-container', {
        navigation: {
        nextEl: '.swiper-button-next',
        prevEl: '.swiper-button-prev',
   		},
		speed: 1000,
    	autoplay: {
        delay: 3000,
    	},
        slidesPerView: 4,
        paginationClickable: true,
        spaceBetween: 20,
        breakpoints: {
            1920: {
                slidesPerView: 4,
                spaceBetween: 30
            },
            1028: {
                slidesPerView: 4,
                spaceBetween: 30
            },
			 991: {
                slidesPerView: 2,
                spaceBetween: 30
            },
			 767: {
                slidesPerView: 2,
                spaceBetween: 30
            },
            480: {
                slidesPerView: 1,
                spaceBetween: 10
            },
			280: {
                slidesPerView: 1,
                spaceBetween: 10
            }
        }
    });
});

//  Review SWiper Ends

// 	Counter Js Starts
	
	(function ($) {
	$.fn.countTo = function (options) {
		options = options || {};

		return $(this).each(function () {
			// set options for current element
			var settings = $.extend({}, $.fn.countTo.defaults, {
				from:            $(this).data('from'),
				to:              $(this).data('to'),
				speed:           $(this).data('speed'),
				refreshInterval: $(this).data('refresh-interval'),
				decimals:        $(this).data('decimals')
			}, options);

			// how many times to update the value, and how much to increment the value on each update
			var loops = Math.ceil(settings.speed / settings.refreshInterval),
				increment = (settings.to - settings.from) / loops;

			// references & variables that will change with each update
			var self = this,
				$self = $(this),
				loopCount = 0,
				value = settings.from,
				data = $self.data('countTo') || {};

			$self.data('countTo', data);

			// if an existing interval can be found, clear it first
			if (data.interval) {
				clearInterval(data.interval);
			}
			data.interval = setInterval(updateTimer, settings.refreshInterval);

			// initialize the element with the starting value
			render(value);

			function updateTimer() {
				value += increment;
				loopCount++;

				render(value);

				if (typeof(settings.onUpdate) == 'function') {
					settings.onUpdate.call(self, value);
				}

				if (loopCount >= loops) {
					// remove the interval
					$self.removeData('countTo');
					clearInterval(data.interval);
					value = settings.to;

					if (typeof(settings.onComplete) == 'function') {
						settings.onComplete.call(self, value);
					}
				}
			}

			function render(value) {
				var formattedValue = settings.formatter.call(self, value, settings);
				$self.text(formattedValue);
			}
		});
	};

	$.fn.countTo.defaults = {
		from: 0,               // the number the element should start at
		to: 0,                 // the number the element should end at
		speed: 1000,           // how long it should take to count between the target numbers
		refreshInterval: 100,  // how often the element should be updated
		decimals: 0,           // the number of decimal places to show
		formatter: formatter,  // handler for formatting the value before rendering
		onUpdate: null,        // callback method for every time the element is updated
		onComplete: null       // callback method for when the element finishes updating
	};

	function formatter(value, settings) {
		return value.toFixed(settings.decimals);
	}
}(jQuery));

    jQuery(function ($) {
     
      // start all the timers
      $('.timer').each(count);
      
      // restart a timer when a button is clicked
      $( window ).scroll(function () {
    if($(window).scrollTop() > 300 && $(window).scrollTop() < 850)
    {
       $('.timer').each(count);
     }
      });
      
      function count(options) {
        var $this = $(this);
        options = $.extend({}, options || {}, $this.data('countToOptions') || {});
        $this.countTo(options);
      }
    });

// Counter Js Ends
});

// custom cursor js

const hoverRegions = document.querySelectorAll('.hover-row');

const cursor = document.querySelector('.cursor');

let mouseX = 0;

let mouseY = 0;



// Initially hide the cursor

cursor.style.opacity = 0;



// Set up event listeners for each hover region

hoverRegions.forEach(hoverRegion => {

  hoverRegion.addEventListener("mouseenter", function (e) {

    // Show the cursor and track mouse position

    cursor.style.opacity = 1;

    mouseX = e.clientX;

    mouseY = e.clientY;

    // Update cursor position using GSAP or any other method

    gsap.set(cursor, {

      css: {

        left: mouseX,

        top: mouseY

      }

    });

  });



  hoverRegion.addEventListener("mousemove", function (e) {

    // Update cursor position as mouse moves within the region

    mouseX = e.clientX;

    mouseY = e.clientY;

    gsap.set(cursor, {

      css: {

        left: mouseX,

        top: mouseY

      }

    });

  });



  hoverRegion.addEventListener("mouseleave", function () {

    // Hide the cursor when leaving the region

    cursor.style.opacity = 0;

  });

});




// swiper slider js
var swiper = new Swiper(".mySwiper", {
  grabCursor: true,
  speed : 1000,
  autoplay: {
    delay: 2500,
    disableOnInteraction: false,
  },
  pagination: {
    el: ".swiper-pagination",
    clickable: true,
  },
  breakpoints: {
    640: {
      slidesPerView: 2,
      spaceBetween: 20,
    },
    768: {
      slidesPerView: 4,
      spaceBetween: 40,
    },
    1024: {
      slidesPerView: 5,
      spaceBetween: 30,
    },
    1800: {
      slidesPerView: 4,
      spaceBetween:30,
    },
  },
});



// swiper slider js


document.getElementById('tabSelect').addEventListener('change', function() {
  var selectedTab = this.value;

  // Get all tabs
  var tabs = document.querySelectorAll('.tab-pane');

  // Remove active class from all tabs
  tabs.forEach(function(tab) {
    tab.classList.remove('active');
  });

  // Add active class to the selected tab
  var selectedContent = document.getElementById(selectedTab);
  if (selectedContent) {
    selectedContent.classList.add('active');
  }
});

// Get all nav links
// Function to handle tab activation
function handleTabActivation(containerClass) {
  var containers = document.querySelectorAll(containerClass);

  containers.forEach(function(container) {
    var navLinks = container.querySelectorAll('.nav-link');

    navLinks.forEach(function(link) {
      link.addEventListener('click', function(event) {
        // Remove active class from all links within the container
        navLinks.forEach(function(link) {
          link.classList.remove('active');
        });

        // Add active class to the clicked link
        this.classList.add('active');
      });
    });
  });
}

// counter scrole
 var counted = 0;
$(window).scroll(function() {

  var oTop = $('#counter').offset().top - window.innerHeight;
  if (counted == 0 && $(window).scrollTop() > oTop) {
    $('.count').each(function() {
      var $this = $(this),
        countTo = $this.attr('data-count');
      $({
        countNum: $this.text()
      }).animate({
          countNum: countTo
        },

        {

          duration: 2000,
          easing: 'swing',
          step: function() {
            $this.text(Math.floor(this.countNum));
          },
          complete: function() {
            $this.text(this.countNum);
            //alert('finished');
          }

        });
    });
    counted = 1;
  }

});
// counter scrole

// Activate tabs for the first set
handleTabActivation('.first-tabs');

// Activate tabs for the second set
handleTabActivation('.second-tabs');




// web development page tabs
// document.addEventListener('DOMContentLoaded', function() {
//     function switchTabsToAccordion() {
//         var windowWidth = window.innerWidth;

//         // Check if the window width is less than or equal to 1024px (tablet size)
//         if (windowWidth <= 1024) {
//             // Find all Elementor tab widgets
//             document.querySelectorAll('.elementor-tabs-wrapper').forEach(function(tabsWrapper) {
//                 tabsWrapper.querySelectorAll('.elementor-tab-title').forEach(function(tabTitle) {
//                     // Add click event to toggle accordion behavior
//                     tabTitle.addEventListener('click', function() {
//                         var isActive = tabTitle.classList.contains('elementor-active');
//                         // Remove active class from all tab titles and contents
//                         tabsWrapper.querySelectorAll('.elementor-tab-title').forEach(function(title) {
//                             title.classList.remove('elementor-active');
//                         });
//                         tabsWrapper.querySelectorAll('.elementor-tab-content').forEach(function(content) {
//                             content.style.display = 'none';
//                         });

//                         // Add active class to the clicked tab title and corresponding content
//                         if (!isActive) {
//                             tabTitle.classList.add('elementor-active');
//                             tabTitle.nextElementSibling.style.display = 'block';
//                         }
//                     });
//                 });
//             });
//         }
//     }

//     // Run the function on page load and window resize
//     switchTabsToAccordion();
//     window.addEventListener('resize', switchTabsToAccordion);
// });


