$(document).ready(function(){
    

    //---------------------------------------navbar_toggler----------------------------------------------
      $(".navbar-toggler").click(function(){
        $(".navbar-toggler").toggleClass("showtoggle");
      });
    //---------------------------------------end navbar_toggler----------------------------------------------

    //------------------------------------------Active Page-------------------------------------------------- 
      $(".menu_sec li a").filter(function() {
        return this.href == location.href.replace(/#.*/, "");
      }).parents("li").addClass("active");
    //------------------------------------------end Active Page-------------------------------------------------- 


    //------------------------------------------------------counter-----------------------------------------------
        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;
          }

        });
    //------------------------------------------------------end counter-----------------------------------------------

      var owl = $('.recent_project_rt .owl-carousel');
        owl.owlCarousel({
          margin:15,
          nav: true,
          loop: true,
          // autoplay: true,
          // autoplayTimeout: 2000,
          // autoplayHoverPause: true,
          responsive: {
            0: {
              items: 1
            },
            576: {
              items: 2
            },
            768: {
              items: 3
            },
            1200: {
              items: 4
            }      
          }
      });

      var owl = $('.feed_back_boxes .owl-carousel');
        owl.owlCarousel({
          margin:15,
          nav: true,
          loop: true,
          autoplay: true,
          autoplayTimeout: 8000,
          autoplayHoverPause: true,
          responsive: {
            0: {
              items: 1
            }    
          }
      });

      var owl = $('.headth_feed_back_lt .owl-carousel');
        owl.owlCarousel({
          margin:15,
          nav: true,
          loop: true,
          autoplay: true,
          autoplayTimeout: 8000,
          autoplayHoverPause: true,
          responsive: {
            0: {
              items: 1
            }    
          }
      });

      var owl = $('.srv_dtls_rt .owl-carousel');
        owl.owlCarousel({
          margin:15,
          nav: true,
          loop: true,
          // autoplay: true,
          // autoplayTimeout: 8000,
          // autoplayHoverPause: true,
          responsive: {
            0: {
              items: 1
            }    
          }
      });

      var owl = $('.earning_sec_lt .owl-carousel');
        owl.owlCarousel({
          margin:15,
          nav: true,
          loop: true,
          autoplay: true,
          autoplayTimeout: 8000,
          autoplayHoverPause: true,
          responsive: {
            0: {
              items: 1
            }    
          }
      });

      var owl = $('.school_management_rt .owl-carousel');
        owl.owlCarousel({
          margin:15,
          nav: true,
          loop: true,
          autoplay: true,
          autoplayTimeout: 8000,
          autoplayHoverPause: true,
          responsive: {
            0: {
              items: 1
            }    
          }
      });


      var owl = $('.brand_feture_sec .owl-carousel');
        owl.owlCarousel({
          margin:15,
          nav: true,
          loop: true,
          // autoplay: true,
          // autoplayTimeout: 2000,
          // autoplayHoverPause: true,
          responsive: {
            0: {
              items: 1
            },
            576: {
              items: 2
            },
            768: {
              items: 3
            },
            1200: {
              items: 8
            }      
          }
      });


      var owl = $('.bratyu_brands_imges .owl-carousel');
        owl.owlCarousel({
          margin:15,
          nav: true,
          loop: true,
          autoplay: true,
          autoplayTimeout: 8000,
          autoplayHoverPause: true,
          responsive: {
            0: {
              items: 1
            },
            1200: {
              items: 5
            }     
          }
      });

      var owl = $('.indsty_feed_back_rt_btm_flex .owl-carousel');
        owl.owlCarousel({
          margin:15,
          nav: true,
          loop: true,
          autoplay: true,
          autoplayTimeout: 8000,
          autoplayHoverPause: true,
          responsive: {
            0: {
              items: 1
            }    
          }
      });


      var owl = $('.real_east_feed_back_sec .owl-carousel');
        owl.owlCarousel({
          loop:true,
          margin:20,
          autoplay:true,
          nav:true,
          responsive: {
            0: {
              items: 1
            },
            576: {
              items: 1.5
            },
            992: {
              items: 2.5
            },
            1500: {
              items: 3.5
            }  
          }
      });

      var owl = $('.schol_fed_back_rt .owl-carousel');
        owl.owlCarousel({
          margin:15,
          nav: true,
          loop: true,
          autoplay: true,
          autoplayTimeout: 8000,
          autoplayHoverPause: true,
          responsive: {
            0: {
              items: 1
            },
            768: {
              items: 2
            } ,
            1200: {
              items: 2
            }     
          }
      });

      

      // The function toggles more (hidden) text when the user clicks on "Read more". The IF ELSE statement ensures that the text 'read more' and 'read less' changes interchangeably when clicked on.
        $('.moreless_button').click(function() {
          $('.moretext').slideToggle();
          if ($('.moreless_button').text() == "Read more") {
            $(this).text("Read less")
          } else {
            $(this).text("Read more")
          }
        });

      
      //--------------------------------------------scroll--------------------------------------------
        $(".blog_content").mCustomScrollbar();
      //--------------------------------------------end scroll--------------------------------------------



      $(document).on('click', '.industries_box', function(){
        $(this).addClass('active').siblings().removeClass('active')
      });
        
   

    
 });


//------------------------------------------------------top_button-----------------------------------------------
    $(window).scroll(function() {    
        var scroll = $(window).scrollTop();

        if (scroll >= 300) {
            $(".top_btn").addClass("show");
        } else {
            $(".top_btn").removeClass("show");
        }
    });
//------------------------------------------------------end top_button-----------------------------------------------

//------------------------------------------headerfixed--------------------------------------------------
  $(window).scroll(function() {    
    var scroll = $(window).scrollTop();
    if (scroll >= 30) {
        $(".header_sec").addClass("fixed");
    } else {
        $(".header_sec").removeClass("fixed");
    }
  });
//------------------------------------------end headerfixed--------------------------------------------------




$(function() {
  var countFiles = 1,
    $body = $('body'),
    typeFileArea = ['txt', 'doc', 'docx', 'ods'],
    coutnTypeFiles = typeFileArea.length;

  //create new element
  $body.on('click', '.files-wr label', function() {
    var wrapFiles = $('.files-wr'),
      newFileInput;

    countFiles = wrapFiles.data('count-files') + 1;
    wrapFiles.data('count-files', countFiles);

    newFileInput = '<div class="one-file"><label for="file-' + countFiles + '">Attach file</label>' +
      '<input type="file" name="file-' + countFiles + '" id="file-' + countFiles + '"><div class="file-item hide-btn">' +
      '<span class="file-name"></span><span class="btn btn-del-file">x</span></div></div>';
    wrapFiles.prepend(newFileInput);
  });

  //show text file and check type file
  $body.on('change', 'input[type="file"]', function() {
    var $this = $(this),
      valText = $this.val(),
      fileName = valText.split(/(\\|\/)/g).pop(),
      fileItem = $this.siblings('.file-item'),
      beginSlice = fileName.lastIndexOf('.') + 1,
      typeFile = fileName.slice(beginSlice);

    fileItem.find('.file-name').text(fileName);
    if (valText != '') {
      fileItem.removeClass('hide-btn');

      for (var i = 0; i < coutnTypeFiles; i++) {

        if (typeFile == typeFileArea[i]) {
          $this.parent().addClass('has-mach');
        }
      }
    } else {
      fileItem.addClass('hide-btn');
    }

    if (!$this.parent().hasClass('has-mach')) {
      $this.parent().addClass('error');
    }
  });

  //remove file
  $body.on('click', '.btn-del-file', function() {
    var elem = $(this).closest('.one-file');
    elem.fadeOut(400);
    setTimeout(function() {
      elem.remove();
    }, 400);
  });
});








// if no Webkit browser
// (function(){
//   let isChrome = /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor);
//   let isSafari = /Safari/.test(navigator.userAgent) && /Apple Computer/.test(navigator.vendor);
//   let scrollbarDiv = document.querySelector('.scrollbar');
//     if (!isChrome && !isSafari) {
//       scrollbarDiv.innerHTML = 'You need Webkit browser to run this code';
//     }
// })();







