// <!-- menu script -->
jQuery(document).ready(function() {
 /*  Dropdown menus*/   
    function thDropdownMenu() {
        var wWidth = jQuery(window).width();
        if(wWidth > 1024) {
            jQuery('.navigation ul.sub-menu, .navigation ul.children').hide();
            var timer;
            var delay = 100;
            jQuery('.navigation li').hover( 
              function() {
                var $this = jQuery(this);
                timer = setTimeout(function() {
                    $this.children('ul.sub-menu, ul.children').slideDown('fast');
                }, delay);
                
              },
              function() {
                jQuery(this).children('ul.sub-menu, ul.children').hide();
                clearTimeout(timer);
              }
            );
        } else {
            jQuery('.navigation li').unbind('hover');
            jQuery('.navigation li.active > ul.sub-menu, .navigation li.active > ul.children').show();
        }
    }
    thDropdownMenu();
    jQuery(window).resize(function() {
        thDropdownMenu();
    });
    // Super Slides
    if ( jQuery( "#slspeed" ).length ) {

    if ( jQuery( "#slspeed" ).length ) {
        if(jQuery('#slspeed').attr('sliderspeed')>1){
            var newspeed = jQuery("#txt_slidespeed").val();
        }else{
               var newspeed =  false; 
        }
                jQuery('#slides_full').superslides({
                animation: 'fade',
                slide_easing: 'easeInOutCubic',
                play:newspeed,
            });

              var $slides = jQuery('#slides_full');
            Hammer($slides[0]).on("swipeleft", function(e) {
                $slides.data('superslides').animate('next');
            });
            Hammer($slides[0]).on("swiperight", function(e) {
                $slides.data('superslides').animate('prev');
            });
            $slides.superslides({
                hashchange: false
            });
     }       
 }
 /* Vertical menus toggles*/
    jQuery('.widget .menu-menu-1-container, .navigation .menu').addClass('toggle-menu');
    jQuery('.toggle-menu ul.sub-menu, .toggle-menu ul.children').addClass('toggle-submenu');
    jQuery('.toggle-menu ul.sub-menu').parent().addClass('toggle-menu-item-parent');
    jQuery('.toggle-menu .toggle-menu-item-parent').append('<span class="toggle-caret"><i class="fa fa-plus"></i></span>');
    jQuery('.toggle-caret').click(function(e) {
        e.preventDefault();
        jQuery(this).parent().toggleClass('active').children('.toggle-submenu').slideToggle('fast');
    });
// Responsive Navigation
/* <![CDATA[ */
var themehunk_customscript = {"responsive":"1","nav_menu":"secondary"};
/* ]]> */
if (themehunk_customscript.responsive && themehunk_customscript.nav_menu != 'none') {
    jQuery(document).ready(function($){
        // merge if two menus exist
        if (themehunk_customscript.nav_menu == 'both') {
            jQuery('.navigation').not('.mobile-menu-wrapper').find('.menu').clone().appendTo('.mobile-menu-wrapper').hide();
        }    
        jQuery('.toggle-mobile-menu').click(function(e) {
            e.preventDefault();
            e.stopPropagation();
            jQuery('body').toggleClass('mobile-menu-active');
        });
jQuery(document).on('DOMMouseScroll mousewheel', '.mobile-menu-wrapper', function(ev) {
            var $this = jQuery(this),
                scrollTop = this.scrollTop,
                scrollHeight = this.scrollHeight,
                height = $this.height(),
                delta = (ev.type == 'DOMMouseScroll' ?
                    ev.originalEvent.detail * -40 :
                    ev.originalEvent.wheelDelta),
                up = delta > 0;
        
            var prevent = function() {
                ev.stopPropagation();
                ev.preventDefault();
                ev.returnValue = false;
                return false;
            }

            if ( jQuery('a#pull').css('display') !== 'none' ) { // if toggle menu button is visible ( small screens )
        
              if (!up && -delta > scrollHeight - height - scrollTop) {
                  // Scrolling down, but this will take us past the bottom.
                  $this.scrollTop(scrollHeight);
                  return prevent();
              } else if (up && delta > scrollTop) {
                  // Scrolling up, but this will take us past the top.
                  $this.scrollTop(0);
                  return prevent();
              }
            }
        });
    }).on('click', function(event) {

        var $target = jQuery(event.target);
        if ( ( $target.hasClass("fa") && $target.parent().hasClass("toggle-caret") ) ||  $target.hasClass("toggle-caret") ) {// allow clicking on menu toggles
            return;
        }

        jQuery('body').removeClass('mobile-menu-active');
    });
}  
    
});
// end menu script
// slider script
(function(jquery) {
    jQuery(window).load(function() {
        var newspeed = jQuery("#txt_slidespeed").val();
        jQuery('.flexslider').flexslider({
            animation: "fade",
            controlNav: false,
            directionNav: false,
            animationSpeed: 1000,
            fadeFirstSlide: false,
            slideshowSpeed: newspeed,

        });
        setTimeout(function() {
            jquery('body').addClass('loaded');
        }, 1000);
    });


})(jQuery);
// end slider script
// Scroll down header
jQuery(window).scroll(function() {
    var scroll = jQuery(window).scrollTop();

    if (scroll >= 100) {
        jQuery(".header").addClass('smaller');
    } else {
        jQuery(".header").removeClass("smaller");
    }
});



// isotop-portfolio script
function plf_AjaxRequest(data, method) {
        return;
    }
    (function(jquery) {
        jQuery(window).load(function() {
            jquery('.lfb-load-more').css("display", "none");
            var jquerygrid = jquery('.grid').isotope({
                filter: '*'
            });

            jquery(".pl-portfolio").click(function() {
                jquery(".is-checked").removeClass('active');
            });

            jquery(".is-checked").click(function() {
                var $grid = jquery('.grid').isotope({
                    filter: '*'
                });
            });
            jquery(".pl-portfolio").click(function() {
                jquery('.lfb-load-more').css("display", "none");
                var $pl_totalcat = jquery('.portfolio-navi').attr('pfl_perpage');
                var $input = jquery(this);
                var data_filter = $input.attr("data-filter");
                var class_filter = $input.attr("class");
                var $post_count = $input.attr("post_count");
                if ($pl_totalcat < $post_count) {
                    jquery('.lfb-load-more').css("display", "block");
                    jquery(".lfb-load-more").attr("cate-slug", data_filter.replace(/\./g, ""));
                }
                var jquerygrid = jquery(".grid").isotope({
                    filter: data_filter
                });
            });
            jquery(".lfb-load-more").click(function() {
                var $pl_totalcat = jquery('.lfb-load-more').attr('cate-slug');
                var $lfb_page = jquery('.lfb-load-more').attr('lfb-page');
                var $plf_data = "post_page=" + $lfb_page + "&cate_slug=" + $pl_totalcat + "&action=portfoliolite_portfolio_ajax";
                jquery.ajax({
                    url: frontendajax.ajaxurl,
                    type: 'POST',
                    data: $plf_data,
                    cache: false
                }).success(function(response) {
                    if (response != 1) {
                        var $lfb_page_new = parseInt($lfb_page) + 1;
                        jquery(".lfb-load-more").attr("lfb-page", $lfb_page_new);
                        var $newItems = jquery(response);
                        jquery('.grid').append($newItems).isotope('appended', $newItems);
                    } else {
                        jquery('.lfb-load-more').css("display", "none");
                    }
                });

            });

        });
    })(jQuery);
// isoptop-portfolio script end
(function(jquery) {
    jquery(window).load(function() {
        if (jquery('#back-to-top').length) {
            var scrollTrigger = 100, // px
                backToTop = function() {
                    var scrollTop = jquery(window).scrollTop();
                    if (scrollTop > scrollTrigger) {
                        jquery('#back-to-top').addClass('show');
                    } else {
                        jquery('#back-to-top').removeClass('show');
                    }
                };
            backToTop();
            jquery(window).on('scroll', function() {
                backToTop();
            });
            jquery('#back-to-top').on('click', function(e) {
                e.preventDefault();
                jquery('html,body').animate({
                    scrollTop: 0
                }, 700);
            });
        }
    });
})(jQuery);
// scroll to section
(function(jquery) {
    jquery(document).ready(function() {
        jquery("#Link").click(function() {
            jquery("#form-subscriber").show();
            jquery("#Link").hide();
        });


        jquery("#arrow-down").on("click", function(e) {
            e.preventDefault();
            var hgte = jQuery('.header').height();
            var nextAnchor = this.hash.replace("#", "");
            var gotoPoint = jquery("#" + nextAnchor).position().top - 50;
            jquery('body').animate({
                scrollTop: gotoPoint
            }, 'normal');
        });
    });
})(jQuery);
// map auto scroll function
(function(jquery) {
    jquery(document).ready(function() {
        jquery('.map').click(function() {
            jquery('.map iframe').css("pointer-events", "auto");
        });

        jquery(".map").mouseleave(function() {
            jquery('.map iframe').css("pointer-events", "none");
        });
    });
})(jQuery);
/*testimonials slider*/
(function(jquery) {
    jQuery(document).ready(function(jQuery) {
        jquery('.bxslider').bxSlider({
            mode: 'fade',
            auto: true,
            autoControls: true,
            adaptiveHeight: true,
        });


    });


}(jQuery));

/* End testimonials slider*/
//search
(function(jquery) {
    jquery(document).ready(function() {
        var submitIcon = jquery('.searchbox-icon');
        var inputBox = jquery('.searchbox-input');
        var searchBox = jquery('.searchbox');
        var isOpen = false;
        submitIcon.click(function() {
            if (isOpen == false) {
                searchBox.addClass('searchbox-open');
                inputBox.focus();
                isOpen = true;
            } else {
                searchBox.removeClass('searchbox-open');
                inputBox.focusout();
                isOpen = false;
            }
        });
        submitIcon.mouseup(function() {
            return false;
        });
        searchBox.mouseup(function() {
            return false;
        });
        jquery(document).mouseup(function() {
            if (isOpen == true) {
                jquery('.searchbox-icon').css('display', 'block');
                submitIcon.click();
            }
        });
    });

    function buttonUp() {
        var inputVal = jquery('.searchbox-input').val();
        inputVal = jquery.trim(inputVal).length;
        if (inputVal !== 0) {
            jquery('.searchbox-icon').css('display', 'none');
        } else {
            jquery('.searchbox-input').val('');
            jquery('.searchbox-icon').css('display', 'block');
        }
    }
})(jQuery);
// fancybox
(function(jquery) {
    jquery(document).ready(function() {
        /* Apply fancybox to multiple items */

        jquery("a.iframe").fancybox({
            'transitionIn': 'elastic',
            'transitionOut': 'elastic',
            'speedIn': 1000,
            'speedOut': 500,
            'overlayShow': true,
            'width': 1000, // or whatever you want
            'height': 1000, // or whatever you want
            'autoHeight': true,
            'scrolling': 'no',
            'autoscale': true,
            'autoSize': false,
        });
    });
})(jQuery);
// smooth scroll and active Link
(function(jquery) {
    function validUrlCheck(url){
  var url_validate = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
 return url_validate;
}

if (jQuery(".home").length) {
         jQuery('.menu li a:first').addClass('active');
         jQuery(document).on("scroll", onScroll);

         function onScroll(event) {
             var scrollPos = jQuery(document).scrollTop();
             if (scrollPos >= 100) {
                 jQuery('a.page-scroll').each(function() {
                     var currLink = jQuery(this);
                     var url = currLink.attr("href");
                     var url_validate = validUrlCheck(url);
                     if (!url_validate.test(url) && jQuery(url).length) {
                         var refElement = jQuery(currLink.attr("href"));
                         if (refElement.position().top - 100 <= scrollPos && refElement.position().top - 100 + refElement.height() > scrollPos) {
                             jQuery('.navigation ul li a').removeClass('active');
                             currLink.addClass("active");

                         }
                     }
                 });
             } else {
                 jQuery('.menu li a').removeClass('active');
                 jQuery('.menu li a:first').addClass('active');
             }
         }
     }
jQuery('a.page-scroll').bind('click', function(event) {
            var $anchor = jQuery(this);
            var url = $anchor.attr('href');
            var url_validate = validUrlCheck(url);
            var hgt = jQuery('.header').height();
            if(!url_validate.test(url)){
              if ( jQuery( url ).length ) {
            jQuery('html, body').stop().animate({
            scrollTop: jQuery(url).offset().top - 50
        }, 1500, 'easeInOutExpo');
        event.preventDefault();
       }
      }
    });
})(jQuery);
///start pallaxx
jQuery(function() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
        (function(n) {
            n.viewportSize = {}, n.viewportSize.getHeight = function() {
                return t("Height")
            }, n.viewportSize.getWidth = function() {
                return t("Width")
            };
            var t = function(t) {
                var f, o = t.toLowerCase(),
                    e = n.document,
                    i = e.documentElement,
                    r, u;
                return n["inner" + t] === undefined ? f = i["client" + t] : n["inner" + t] != i["client" + t] ? (r = e.createElement("body"), r.id = "vpw-test-b", r.style.cssText = "overflow:scroll", u = e.createElement("div"), u.id = "vpw-test-d", u.style.cssText = "position:absolute;top:-1000px", u.innerHTML = "<style>@media(" + o + ":" + i["client" + t] + "px){body#vpw-test-b div#vpw-test-d{" + o + ":7px!important}}<\/style>", r.appendChild(u), i.insertBefore(r, e.head), f = u["offset" + t] == 7 ? i["client" + t] : n["inner" + t], i.removeChild(r)) : f = n["inner" + t], f
            }
        })(this);


        (function($) {

            // Setup variables
            $window = $(window);
            $body = $('body');

            //FadeIn all sections   

            function adjustWindow() {

                // Init Skrollr
                var s = skrollr.init({
                    render: function(data) {

                        //Debugging - Log the current scroll position.
                        //console.log(data.curTop);
                    }
                });

                // Get window size
                winH = $window.height();

                // Keep minimum height 550
                if (winH <= 550) {
                    winH = 550;
                }


            }

        })(jQuery);
    } else {
        (function(n) {
            n.viewportSize = {}, n.viewportSize.getHeight = function() {
                return t("Height")
            }, n.viewportSize.getWidth = function() {
                return t("Width")
            };
            var t = function(t) {
                var f, o = t.toLowerCase(),
                    e = n.document,
                    i = e.documentElement,
                    r, u;
                return n["inner" + t] === undefined ? f = i["client" + t] : n["inner" + t] != i["client" + t] ? (r = e.createElement("body"), r.id = "vpw-test-b", r.style.cssText = "overflow:scroll", u = e.createElement("div"), u.id = "vpw-test-d", u.style.cssText = "position:absolute;top:-1000px", u.innerHTML = "<style>@media(" + o + ":" + i["client" + t] + "px){body#vpw-test-b div#vpw-test-d{" + o + ":7px!important}}<\/style>", r.appendChild(u), i.insertBefore(r, e.head), f = u["offset" + t] == 7 ? i["client" + t] : n["inner" + t], i.removeChild(r)) : f = n["inner" + t], f
            }
        })(this);


        (function($) {

            // Setup variables
            $window = $(window);
            $body = $('body');

            //FadeIn all sections   
            $body.imagesLoaded(function() {
                setTimeout(function() {

                    // Resize sections
                    adjustWindow();

                    // Fade in sections
                    $body.removeClass('loading').addClass('loaded');

                }, 800);
            });

            function adjustWindow() {

                // Init Skrollr
                var s = skrollr.init({
                    render: function(data) {

                        //Debugging - Log the current scroll position.
                        //console.log(data.curTop);
                    }
                });
                // Get window size
                winH = $window.height();
                // Keep minimum height 550
                if (winH <= 550) {
                    winH = 550;
                }
            }
        })(jQuery);
    }
});
// skill scroll down
(function(jquery) {
    jquery(window).scroll(function() {
        /* Check the location of each desired element */
        jquery('.chart').each(function(i) {
            var bottom_of_object = jquery(this).offset().top + jquery(this).outerHeight();
            var bottom_of_window = jquery(window).scrollTop() + jquery(window).height();
            /* If the object is completely visible in the window, fade it in */
            if (bottom_of_window > bottom_of_object) {

                jquery('.chart').easyPieChart({
                    easing: 'easeOutElastic',
                    size: 160,
                    barColor: "#22a7f0",
                    trackColor: "#e9e9e9",
                    scaleColor: false,
                    lineWidth: 20,
                    lineCap: 'butt',
                    animate: 2000,
                    onStep: function(from, to, percent) {
                        jquery(this.el).find('.percent').text(Math.round(percent));
                    }
                });
            }
        });
    });
})(jQuery);
// header setting

if (!document.getElementsByClassName('static').length){
    // var hdr = jQuery(".header").height();  
    jQuery(".blog-top").css({
        "margin-top":"70px",});
    }
else{
jQuery(".blog-top").css({
        "margin-top": "0px",});
    }


// animation-wow
(function(jquery) {
    jquery(document).ready(function() {
        wow = new WOW({
            animateClass: 'animated',
            offset: 100,
            callback: function(box) {
                // console.log("WOW: animating <" + box.tagName.toLowerCase() + ">")
            }
        });
        wow.init();
    });
})(jQuery);