/*Author: Eddie Machado*/
(function($) {
    "use strict";
    // IE8 ployfill for GetComputed Style (for Responsive Script below)
    if (!window.getComputedStyle) {
        window.getComputedStyle = function(el, pseudo) {
            this.el = el;
            this.getPropertyValue = function(prop) {
                var re = /(\-([a-z]){1})/g;
                if (prop == 'float') prop = 'styleFloat';
                if (re.test(prop)) {
                    prop = prop.replace(re, function() {
                        return arguments[2].toUpperCase();
                    });
                }
                return el.currentStyle[prop] ? el.currentStyle[prop] : null;
            }
            return this;
        }
    }
    // as the page loads, call these scripts
    $(document).ready(function($) {
        /* getting viewport width */
        var responsive_viewport = $(window).width();
        /* if is below 481px */
        if (responsive_viewport < 481) {
        } /* end smallest screen */
        /* if is larger than 481px */
        if (responsive_viewport > 481) {
        } /* end larger than 481px */
        /* if is above or equal to 768px */
        if (responsive_viewport >= 768) {/* load gravatars */
            $('.comment img[data-gravatar]').each(function() {
                $(this).attr('src', $(this).attr('data-gravatar'));
            });
        }
        /* off the bat large screen actions */
        if (responsive_viewport > 1030) {}
// ALL CUSTOM SCRIPT HERE
/*Marquee on header*/
$(function(){$('.simple-marquee-container').SimpleMarquee({duration:100000});});		
/*Slidebar with widget*/
$('.dismiss, .overlay').on('click',function(){$('.Sidebar1').removeClass('active');$('.overlay').removeClass('active');});$('.open-menu').on('click',function(e){e.preventDefault();$('.Sidebar1').addClass('active');$('.overlay').addClass('active');$('.collapse.show').toggleClass('show');$('a[aria-expanded=true]').attr('aria-expanded','false');});
// Theme switch. codyhouse with MIT licence
var themeSwitch=document.getElementById('themeSwitch');if(themeSwitch){initTheme();themeSwitch.addEventListener('change',function(event){resetTheme();});function initTheme(){var darkThemeSelected=(localStorage.getItem('themeSwitch')!==null&&localStorage.getItem('themeSwitch')==='dark');themeSwitch.checked=darkThemeSelected;darkThemeSelected?document.body.setAttribute('class','dark'):document.body.removeAttribute('class');};function resetTheme(){if(themeSwitch.checked){document.body.setAttribute('class','dark');localStorage.setItem('themeSwitch','dark');}else{document.body.removeAttribute('class');localStorage.removeItem('themeSwitch');}};}	
// BACK TO TOP
$(window).scroll(function(){if($(this).scrollTop()>400){$('#back-top').fadeIn();}else{$('#back-top').fadeOut();}});$('#back-top').click(function(){$("html, body").animate({scrollTop:0},600);return false;});
//	CREATE 2 COLUMNS
$('.content_two_column,.ctest').columnize({width:400,columns:2,buildOnce:true,lastNeverTallest:true});
//	CREATE 3 COLUMNS
$('.ctest3').columnize({width:400,columns:3,buildOnce:true,lastNeverTallest:true});
//	CREATE 4 COLUMNS
$('.ctest4').columnize({width:400,columns:4,buildOnce:true,lastNeverTallest:true});
//	CREATE 5 COLUMNS
$('.ctest5').columnize({width:400,columns:5,buildOnce:true,lastNeverTallest:true});
//	CREATE 6 COLUMNS
$('.ctest6').columnize({width:400,columns:6,buildOnce:true,lastNeverTallest:true});
// ADD WIDTH FOR fulldiv class 
$(".fulldiv").css("width", "+=200");
// FOR SCROLL STICKY AREA
$('.sidebar').theiaStickySidebar({additionalMarginTop:30,additionalMarginBottom:30});
$('.sidebarcontent').theiaStickySidebar({additionalMarginTop:30,additionalMarginBottom:30});
$('.entry-contentadv').theiaStickySidebar({additionalMarginTop:30,additionalMarginBottom:30});
// SPAN FOR WIDGET TITLE
$(function() {
	$('.widget-title').each( function (){
		var obj_h2 = $(this);
		var h2_title = obj_h2.html();
		var words = h2_title.split(' ');
		words[0] = '<span>' + words[0] + '</span>'
		obj_h2.html( words.join( ' ' ) );
        });
    });
// SCROLLBAR READING
$(document).scroll(function (e) {
  var scrollAmount = $(window).scrollTop();
  var documentHeight = $(document).height();
  var windowHeight = $(window).height();
  var scrollPercent = (scrollAmount / (documentHeight - windowHeight)) * 100;
  var roundScroll = Math.round(scrollPercent);  
  // For scrollbar 1
  $(".scrollBar1").css("width", scrollPercent + "%");
  $(".scrollBar1 span").text(roundScroll);
});


});
/* end of as page load scripts */

})(jQuery);
/* NAV RESPONSIVE */
function myFunction() {
  var x = document.getElementById("myTopnav");
  if (x.className === "topnav") {
    x.className += " responsive";
  } else {
    x.className = "topnav";
  }
}
/*A fix for the iOS orientationchange zoom bug. Script by @scottjehl, rebound by @wilto.*/
(function(w) {
    "use strict";
    // This fix addresses an iOS bug, so return early if the UA claims it's something else.
    if (!(/iPhone|iPad|iPod/.test(navigator.platform) && navigator.userAgent.indexOf("AppleWebKit") > -1)) {
        return;
    }
    var doc = w.document;
    if (!doc.querySelector) {
        return;
    }
    var meta = doc.querySelector("meta[name=viewport]"),
        initialContent = meta && meta.getAttribute("content"),
        disabledZoom = initialContent + ",maximum-scale=1",
        enabledZoom = initialContent + ",maximum-scale=10",
        enabled = true,
        x, y, z, aig;
    if (!meta) {
        return;
    }
    function restoreZoom() {
        meta.setAttribute("content", enabledZoom);
        enabled = true;
    }
    function disableZoom() {
        meta.setAttribute("content", disabledZoom);
        enabled = false;
    }
    function checkTilt(e) {
        aig = e.accelerationIncludingGravity;
        x = Math.abs(aig.x);
        y = Math.abs(aig.y);
        z = Math.abs(aig.z);
        // If portrait orientation and in one of the danger zones
        if (!w.orientation && (x > 7 || ((z > 6 && y < 8 || z < 8 && y > 6) && x > 5))) {
            if (enabled) {
                disableZoom();
            }
        } else if (!enabled) {
            restoreZoom();
        }
    }
    w.addEventListener("orientationchange", restoreZoom, false);
    w.addEventListener("devicemotion", checkTilt, false);
})(this);