var smallHeader; var navHolder = $('#header-nav'); var headerContainer = $('#header-container'); var headerNavCol = $('#header-nav-col'); var navHolderDistance; var homepageContainer = $('#homepage-container'); var loginNavItems = $('.login-nav-items'); var loginTopRightNav = $('.login-top-right-nav'); var homepageImgContainer = document.getElementById('homepage-img-container'); var mobileImgContainer = document.getElementById('mobile-img-background-img'); var dlarssImage; var windowHeight; $(document).ready(function(){ isHomePage = true; RetinaCheck(); }); window.onload = function(){ isHomePage = true; processHeightAdjust('blog-title'); BindEvents(); GetHeaderDistance(); HeaderCheck(); HeaderProcess(); /* SWIPE DETECTION =============== */ $(".youtube-testimonials-wrapper").onSwipe( function(nSwipeDirection) { // If we swipe the the left if( nSwipeDirection == PH9_SWIPE_LEFT) { // Store the next video index var nNextVideoIndex = nSelectedVideoID + 1; // Store the next video button element var oTestimonialButton = $("#testimonial-button-" + nNextVideoIndex); // IF there is no button element, then start from the first slide if( !oTestimonialButton.length ) { // Set the video index nNextVideoIndex = 1; // Get the correct button oTestimonialButton = $("#testimonial-button-" + nNextVideoIndex); } // Change the testimonial video fChangeTestimonialVideo( oTestimonialButton, nNextVideoIndex ); } else // If we swipe to the right if( nSwipeDirection == PH9_SWIPE_RIGHT) { // Store the next video index var nNextVideoIndex = nSelectedVideoID - 1; // Store the next video button element var oTestimonialButton = $("#testimonial-button-" + nNextVideoIndex); // IF there is no button element, then start from the last slide if( !oTestimonialButton.length ) { // Get the total amount of slides we have and set to the index nNextVideoIndex = $(".youtube-wrapper-wrapper").length; // Get the correct button oTestimonialButton = $("#testimonial-button-" + nNextVideoIndex); } // Change the testimonial video fChangeTestimonialVideo( oTestimonialButton, nNextVideoIndex ); } }); }; function BindEvents(){ window.addEventListener("optimizedScroll", function(){ HeaderProcess(); }); window.addEventListener("optimizedResize", function(){ GetHeaderDistance(); HeaderProcess(); }); } function GetHeaderDistance(){ windowHeight = Math.max(document.documentElement.clientHeight, window.innerHeight || 0); navHolderDistance = windowHeight - 100 + 20; navHolderDistance -= navHolder.height(); } function HeaderProcess(){ if ( document.body.clientWidth >= 1250 ){ /* if fixed header activated */ if($(document).scrollTop() > navHolderDistance){ if(navHolder.css("position") != "fixed"){ navHolder.css("position","fixed"); navHolder.css("top","25px"); headerNavCol.css("height","80px"); headerNavCol.css("position","fixed"); loginNavItems.each(function(){ $(this).css("display","none"); }); loginTopRightNav.css("display","block"); } }else{ /* fixed header not actived */ if(navHolder.css("position") != "absolute" || navHolder.css("top") != "400px"){ navHolder.css("position","absolute"); navHolder.css("top","calc(100vh - 85px)"); headerNavCol.css("height","100vh"); headerNavCol.css("position","relative"); loginNavItems.each(function(){ $(this).css("display","none"); }); loginTopRightNav.css("display","block"); } } } else if(document.body.clientWidth < 1250 && document.body.clientWidth > 999 ){ if($(document).scrollTop() >= navHolderDistance){ navHolder.css("position","fixed"); navHolder.css("top","25px"); navHolder.css("text-align","right"); headerNavCol.css("height","80px"); headerNavCol.css("position","fixed"); loginNavItems.each(function(){ $(this).css("display","inline-block"); }); loginTopRightNav.css("display","none"); }else{ navHolder.css("position","absolute"); navHolder.css("top","calc(100vh - 85px)"); navHolder.css("text-align","center"); headerNavCol.css("height","100vh"); headerNavCol.css("position","relative"); loginNavItems.each(function(){ $(this).css("display","none"); }); loginTopRightNav.css("display","block"); //} } } else if(document.body.clientWidth <= 999){ $('.login-top-right-nav').css("display","none"); } } function LoadVid(){ var video = document.getElementById("homepage-vid-tag"); var mp4 = document.getElementById("homepage-video"); mp4.src = "images/AWD/Main-Video.mp4"; video.load(); } function RetinaCheck(){ if(window.devicePixelRatio >= 2 || document.body.clientWidth > 1940){ if(homepageImgContainer.style.backgroundImage != "url('./images/AWD/spencer_bg_x2.jpg')"){ dlarssImage = new Image(); dlarssImage.onload = function(){ console.log('img on load'); homepageImgContainer.style.backgroundImage = "url('./images/AWD/spencer_bg_x2.jpg')"; }; dlarssImage.src = "./images/AWD/spencer_bg_x2.jpg"; } if(mobileImgContainer.src != "./images/AWD/spencer_mob_2x.jpg"){ dlarssmobImage = new Image(); dlarssmobImage.onload = function(){ mobileImgContainer.src = dlarssmobImage.src; }; dlarssmobImage.src = "./images/AWD/spencer_mob_2x.jpg"; } } LoadVid(); } /* fChangeTestimonialVideo ======================= Simply swaps out the testimonials */ // Store the current active videoID var nSelectedVideoID = 1; function fChangeTestimonialVideo(oDOMButtonClicked, nVideo_ID) { // Set the DOM object for the button clicked to a jquery object oDOMButtonClicked = $(oDOMButtonClicked) // Remove the active status from the current button $(".buttons .active").removeClass("active"); // Add the active status to the current button clicked oDOMButtonClicked.addClass("active"); // Hide the old testimonial video $("#testimonial-video-" + nSelectedVideoID).hide(); // Show the new testimonial video $("#testimonial-video-" + nVideo_ID).show(); // Store the selected video nSelectedVideoID = nVideo_ID } /* ==== heightfix ==== */ var processHeightJsNodes = []; function processHeightAdjust() { var processHeightJsNodes = processHeightJsNodes || []; if(! processHeightJsNodes[0]){ for (i = 0; i < arguments.length; i++) { processHeightJsNodes.push(document.getElementsByClassName(arguments[i])); } } for (i = 0; i < processHeightJsNodes.length; i++) { var max = 0; var elements = []; elements = processHeightJsNodes[i]; for (x = 0; x < elements.length; x++) { elements[x].style.setProperty("height","auto"); //elements[x].removeAttribute("style"); if(elements[x].clientHeight > max) max=Math.ceil(elements[x].clientHeight); } for (y = 0; y < elements.length; y++) { elements[y].style.setProperty("height",max+"px"); } } }