const swiper = new Swiper('.testimonial-swiper', { // Optional parameters loop: true, direction: 'horizontal', slidesPerView: 3, slidesPerGroup: 3, spaceBetween: 30, loopFillGroupWithBlank: true, preloadImages: false, watchOverflow: true, lazy: true, breakpoints: { 320: { slidesPerView: 1, slidesPerGroup: 1 }, 768: { slidesPerView: 2, slidesPerGroup: 2 }, 1201: { slidesPerView: 3, slidesPerGroup: 3 } }, // If we need pagination pagination: { el: '.swiper-pagination', clickable: true }, // Navigation arrows navigation: { nextEl: '.swiper-button-next', prevEl: '.swiper-button-prev', }, }); let navStickyBar = document.getElementById('stickyNavbarAutonation'); let nextSection = navStickyBar.parentElement.nextElementSibling; let urlArray = window.location.href.split('/'); let urlParam = urlArray.pop() || urlArray.pop(); let navLinkNames = ["our-purpose", "drive-pink", "one-autonation", "sustainability"]; let navLinks = document.querySelectorAll(".sticky-nav-link"); console.log(urlParam); window.addEventListener('scroll', checkToAddSticky); addActive(urlParam, navLinkNames, navLinks); function addActive(param, linkNames, navLinks) { for(let i = 0; i < linkNames.length; i++) { if (param === linkNames[i]) { navLinks[i].classList.add('active'); if (i >= 2) { navStickyBar.scrollLeft += navLinks[i].getBoundingClientRect().left; } break; } } } function checkToAddSticky() { let check = isOutOfViewport(navStickyBar); let textCheck = isOutOfViewport(nextSection); if (textCheck.top) { if ( !navStickyBar.classList.contains("sticky") ) { navStickyBar.style.opacity = "0"; } navStickyBar.classList.add('sticky'); nextSection.style.paddingTop = '75px'; setTimeout(function() { navStickyBar.style.transition = "all 1s"; navStickyBar.style.opacity = "1"; }, 500); } else if (!textCheck.top) { navStickyBar.classList.remove('sticky'); navStickyBar.style.opacity = "1"; nextSection.style.paddingTop = '0px'; navStickyBar.style.transition = "none"; } } function isOutOfViewport(elem) { // Get element's bounding var bounding = elem.getBoundingClientRect(); // Check if it's out of the viewport on each side var out = {}; out.top = bounding.top < 0; out.left = bounding.left < 0; out.bottom = bounding.bottom > (window.innerHeight || document.documentElement.clientHeight); out.right = bounding.right > (window.innerWidth || document.documentElement.clientWidth); out.any = out.top || out.left || out.bottom || out.right; out.all = out.top && out.left && out.bottom && out.right; return out; } window.onunload = function () { window.scrollTo(0, 0); }; window.scrollTo(0, 0); const counter = document.getElementById('counter'); console.log('7',counter); if (counter !== null) { counter.innerHTML = commaFormatted(getStartingCount()); const speed = 200; var counterFlag = true; const stickyBar = document.querySelector('.drive-pink-donate-bar'); const banner = document.querySelector('.video-container'); const offset = stickyBar.getBoundingClientRect(); const bannerOffset = banner.getBoundingClientRect(); const counterOffset = counter.getBoundingClientRect(); const videoControl = document.querySelector('#videoControl'); let video = document.querySelector('#OurPurpose_Drivepink_hero-video'); videoControl.addEventListener('click', function() { video = document.querySelector('#OurPurpose_Drivepink_hero-video'); toggleVideoPlay(video, videoControl); }); window.addEventListener('scroll', function() { if (window.pageYOffset > bannerOffset.bottom) { stickyBar.style.position = 'fixed'; stickyBar.style.bottom= '25px'; stickyBar.style.right= '20px'; stickyBar.style.zIndex = 1000; stickyBar.style.opacity= 1; } else { stickyBar.style.position = 'fixed'; stickyBar.style.top = ''; stickyBar.style.zIndex = -1; stickyBar.style.opacity= 0; } if (inViewport(counter) && counterFlag) { updateCounter(); counterFlag = false; } }); } function toggleVideoPlay(videoEle, videoControlEle) { if (videoEle.paused) { videoEle.play(); videoControlEle.classList.remove('play'); videoControlEle.classList.add('pause'); } else { videoEle.pause(); videoControlEle.classList.remove('pause'); videoControlEle.classList.add('play'); } } function inViewport(elem) { let bounding = elem.getBoundingClientRect(); return ( bounding.top >= 0 && bounding.left >= 0 && bounding.bottom <= (window.innerHeight || document.documentElement.clientHeight) && bounding.right <= (window.innerWidth || document.documentElement.clientWidth) ); } function getMonthsPassed() { const startDate = new Date(2021, 12, 1); // month start at 0 const currentDate = new Date(); const monthDifference = (currentDate.getFullYear() - startDate.getFullYear()) * 12 + (currentDate.getMonth() - startDate.getMonth()); return monthDifference; }; //console.log('getMonthsPassed = ' + getMonthsPassed()); /* Tealium Scripts */ function tealiumScriptDonateNow() { let clickdata = { "category_l1":"MLP", "category_l2":"Drive Pink", "category_l3":"(not set)", "category_l4":"(not set)", "event":"donate_now", "event_category":"EngagementType", "event_action":"EngagementType_MLP|||Click", "event_label":"Donate Now", "event_value":"1", "pagegroup":"mlp" }; window.utag_data = clickdata; window.utag.link(window.utag_data); } function tealiumScriptFindStore() { let clickdata = { "category_l1":"MLP", "category_l2":"Drive Pink", "category_l3":"(not set)", "category_l4":"(not set)", "event":"find_store", "event_category":"EngagementType", "event_action":"EngagementType_MLP|||Click", "event_label":"Find a Store", "event_value":"1", "pagegroup":"mlp" }; window.utag_data = clickdata; window.utag.link(window.utag_data); } function tealiumScriptShopNow() { let clickdata = { "category_l1":"MLP", "category_l2":"Drive Pink", "category_l3":"(not set)", "category_l4":"(not set)", "event":"shop_now", "event_category":"EngagementType", "event_action":"EngagementType_MLP|||Click", "event_label":"Shop Now", "event_value":"1", "pagegroup":"mlp" }; window.utag_data = clickdata; window.utag.link(window.utag_data); } function tealiumScriptPinkEvents() { let clickdata = { "category_l1":"MLP", "category_l2":"Drive Pink", "category_l3":"(not set)", "category_l4":"(not set)", "event":"drv_pink_events", "event_category":"EngagementType", "event_action":"EngagementType_MLP|||Click", "event_label":"DRV Pink Events", "event_value":"1", "pagegroup":"mlp" }; window.utag_data = clickdata; window.utag.link(window.utag_data); } /* End of Tealium Scripts */ function getIncrement() { var today = new Date(); let firstDayOfMonth = new Date(today.getFullYear(), today.getMonth(), 1); let nextMonth; let target; if (today.getMonth() === 11) { nextMonth = 0; target = new Date(today.getFullYear() + 1, nextMonth, 1); } else { nextMonth = today.getMonth() + 1; target = new Date(today.getFullYear(), nextMonth, 1); } target = new Date("04/01/2023"); //const target = new Date(2020, nextMonth, 1); // month start at 0 //target = new Date ("2/26/2021"); //today= new Date ("11/01/2021"); let donationTarget = +counter.getAttribute('data-target'); //donationTarget += (getMonthsPassed() + 1) * 50000; const startingCount = getStartingCount(); //console.log(startingCount); let remaining = donationTarget - startingCount; let timeBetween = Math.abs(today.getTime() - target.getTime()); let timeBetweenBeginningMonthToEndMonth = Math.abs(firstDayOfMonth.getTime() - target.getTime()); let daysBetween = timeBetween / (1000 * 3600 * 24); let daysBetweenBeginningMonthToEndMonth = timeBetweenBeginningMonthToEndMonth / (1000 * 3600 * 24); let daysPassed = Math.abs(daysBetween - daysBetweenBeginningMonthToEndMonth); if (daysPassed < 1) { return 1; } if (daysBetween === 0 || today > target) { return 0; } else { let amountEachDay = Math.ceil(remaining / daysBetweenBeginningMonthToEndMonth); let currentIncrement = amountEachDay * Math.floor(daysPassed); //return Math.ceil(remaining / daysBetween); return currentIncrement; } } function getStartingCount() { return 35000000; } function commaFormatted(amount) { numObj = new Intl.NumberFormat('en-US'); output = numObj.format('' + amount); return output; } function updateCounter() { let target = +counter.getAttribute('data-target'); const currentCount = counter.innerText.replace(/,/g, ''); const count = +currentCount; let increment = getIncrement(); if (increment === 0) { increment = target - count; } if (increment === 1) { increment = 0; } const todaysCount = count + increment; //const incrementBy = increment / speed; const incrementBy = increment; //updateCountTicker(counter, count, target, todaysCount, incrementBy); //updateCounterNumber(count, target, todaysCount, speed); animateValue("counter", count, todaysCount, 1); } function updateCountTicker(counter, count, target, todaysCount, incrementBy) { if (count < target && count < todaysCount) { //counter.innerText = Math.ceil(count + incrementBy); let result = commaFormatted(Math.ceil(count + incrementBy)); counter.innerText = result; count = +(counter.innerText.replace(/,/g, '')); setTimeout(updateCountTicker(counter, count, target, todaysCount, incrementBy), 1); } else if (count >= target) { counter.innerText = commaFormatted(target); } } function animateValue(id, start, end, duration) { if (end === getStartingCount()) { return; } var range = end - start; var current = start; var numDigits = getDigits(Math.abs(end - start)); var incrementBy = 3; for (let i = 0; i < numDigits; i++) { incrementBy = incrementBy + '0'; } var increment = end > start? +incrementBy: -(+incrementBy); var stepTime = Math.abs(Math.floor(duration / range)); var obj = document.getElementById(id); var timer = setInterval(function() { current += increment; obj.innerHTML = commaFormatted(current); if (current >= end) { clearInterval(timer); obj.innerHTML = commaFormatted(end); } }, stepTime); function getDigits(num) { let count = 0; if (num >= 1) { ++count; } while (num / 10 >= 1) { num /= 10; ++count; } if (count < 3) { return count; } else if (count - 3 > 3) { return 3; } else { return count - 3; } } } document.addEventListener('DOMContentLoaded', function () { if (window.hideYTActivated) return; let onYouTubeIframeAPIReadyCallbacks = []; for (let playerWrap of document.querySelectorAll(".hytPlayerWrap")) { let playerFrame = playerWrap.querySelector("iframe"); let tag = document.createElement('script'); tag.src = "https://www.youtube.com/iframe_api"; let firstScriptTag = document.getElementsByTagName('script')[0]; firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); let onPlayerStateChange = function (event) { if (event.data == YT.PlayerState.ENDED) { playerWrap.classList.add("ended"); } else if (event.data == YT.PlayerState.PAUSED) { playerWrap.classList.add("paused"); } else if (event.data == YT.PlayerState.PLAYING) { playerWrap.classList.remove("ended"); playerWrap.classList.remove("paused"); } }; let player; onYouTubeIframeAPIReadyCallbacks.push(function () { player = new YT.Player(playerFrame, {events: {'onStateChange': onPlayerStateChange}}); }); playerWrap.addEventListener("click", function () { let playerState = player.getPlayerState(); if (playerState == YT.PlayerState.ENDED) { player.seekTo(0); } else if (playerState == YT.PlayerState.PAUSED || playerState === YT.PlayerState.CUED) { player.playVideo(); } }); } window.onYouTubeIframeAPIReady = function () { for (let callback of onYouTubeIframeAPIReadyCallbacks) { callback(); } }; window.hideYTActivated = true; }); let charityDropdown = document.querySelector('#partnerSelection'); let donateLink = document.querySelector('#donateLink'); let partnerLogo = document.querySelector('#partnerLogo'); let partnerTitle = document.querySelector('#partner-title'); let partnerState = document.querySelector('#partner-state'); let nationalCheck = document.querySelector('#nationalCheck'); let nationalCheckLabel = document.querySelector('#nationalCheckLabel'); let localCheck = document.querySelector('#localCheck'); let localCheckLabel = document.querySelector('#localCheckLabel'); let nationalOptions = document.querySelectorAll("#partnerSelection option[data-type='national']"); let localOptions = document.querySelectorAll("#partnerSelection option[data-type='local']"); let linkDict = {}; let linkTitle = {}; let linkState = {}; linkDict["partner-logo-background"] = ""; linkDict["american-cancer-society"] = "https://donate3.cancer.org/?campaign=search&utm_source=google&utm_medium=cpc&utm_campaign=%5BB%5D+American+Cancer+Society+-+Exact&utm_term=american%20cancer%20society%20donation&utm_id=go_cmp-11361949398_adg-117026194931_ad-472778322667_aud-533884399911:kwd-820214106_dev-c_ext-_prd-_mca-_sig-CjwKCAjwrqqSBhBbEiwAlQeqGtn7veMHHWkuOUskS1u8OWkUn7q5kn93hGVtCQVDFmCrqTRiIlPcjRoCMwwQAvD_BwE&gclid=CjwKCAjwrqqSBhBbEiwAlQeqGtn7veMHHWkuOUskS1u8OWkUn7q5kn93hGVtCQVDFmCrqTRiIlPcjRoCMwwQAvD_BwE"; linkDict["bcrf"] = "https://give.bcrf.org/give/58223/#!/donation/checkout"; linkDict["cleveland-clinic"] = "https://my.clevelandclinic.org/florida/giving/campaign/cancer-center"; linkDict["cure"] = "https://curechildhoodcancer.org/donate/"; linkDict["dolphins-challenge"] = "https://dolphins.donordrive.com/index.cfm?fuseaction=donate.event&eventID=524"; linkDict["gbr"] = "https://secure.acsevents.org/site/SPageServer/?pagename=relay_donate_now&FR_ID=100628&fr_id=100628"; linkDict["lemons-of-love"] = "https://www.paypal.com/donate/?cmd=_s-xclick&hosted_button_id=FSD54PMZNEMMC&source=url"; linkDict["memorial"] = "https://www.mhs.net/about/foundation/give/donate"; linkDict["moffitt"] = "https://give.moffitt.org/site/Donation2?1722.donation=form1&df_id=1722&mfc_pref=T"; linkDict["pediatric-cancer-foundation"] = "https://nationalpcf.org/"; linkDict["nsu"] = "https://www.nova.edu/give/index.html?area=Research&designation=AutoNation%20Institute%20for%20Breast%20and%20Solid%20Tumor%20Research"; linkDict["pediatric-cancer-research"] = "https://cure.pcrf-kids.org/give/388114/#!/donation/checkout"; linkDict["pheonix"] = "https://secure.phoenixchildrensfoundation.org/site/Donation2;jsessionid=00000000.app30122a?df_id=6481&mfc_pref=T&6481.donation=form1&utm_source=phoenixchildrens.org&utm_medium=referral&utm_campaign=donation-campaign-2020-evergreen&utm_content=donate-button-header&NONCE_TOKEN=FAFFA7C0DC0A75AC193E508F5333CA69"; linkDict["wokc"] = "https://donatenow.networkforgood.org/wokc"; //linkDict["vFoundation"] = "https://donate.v.org/give/353765/?_ga=2.87398616.1996718082.1649103265-289952309.1624386817#!/donation/checkout?c_src=Homepage&c_src2=DonateButton"; linkDict["zero"] = "https://support.zerocancer.org/site/Donation2?df_id=3820&mfc_pref=T&3820.donation=form1"; linkTitle["partner-logo-background"] = ""; linkTitle["american-cancer-society"] = "American Cancer Society"; linkTitle["bcrf"] = "BCRF"; linkTitle["cleveland-clinic"] = "Cleveland Clinic"; linkTitle["cure"] = "CURE Childhood Cancer"; linkTitle["dolphins-challenge"] = "Dolphins Challenge Cancer"; linkTitle["gbr"] = "Great Big Relay"; linkTitle["lemons-of-love"] = "Lemons of Love"; linkTitle["memorial"] = "Memorial Cancer Institute"; linkTitle["moffitt"] = "Moffit Cancer Center"; linkTitle["pediatric-cancer-foundation"] = "National Pediatric Cancer Foundation"; linkTitle["nsu"] = "NSU"; linkTitle["pediatric-cancer-research"] = "Pediatric Cancer Research Foundation"; linkTitle["pheonix"] = "Phoenix Children's"; linkTitle["wokc"] = "WOKC"; //linkTitle["vFoundation"] = "V Foundation"; linkTitle["zero"] = "ZERO Cancer"; linkState["partner-logo-background"] = ""; linkState["american-cancer-society"] = "National"; linkState["bcrf"] = "National"; linkState["cleveland-clinic"] = "National"; linkState["cure"] = "Atlanta"; linkState["dolphins-challenge"] = "South Florida"; linkState["gbr"] = "Orlando"; linkState["lemons-of-love"] = "Chicago"; linkState["memorial"] = "South Florida"; linkState["moffitt"] = "Tampa/Clearwater"; linkState["pediatric-cancer-foundation"] = "Houston"; linkState["nsu"] = "South Florida"; linkState["pediatric-cancer-research"] = "Irvine, Ca"; linkState["pheonix"] = "Phoenix"; linkState["wokc"] = "Dallas"; //linkState["vFoundation"] = "National"; linkState["zero"] = "National"; if (typeof(charityDropdown) != 'undefined' && charityDropdown != null) { charityDropdown.addEventListener("change", function(e) { updatePartnerLogo(e.target.value); updatePartnerText(e.target.value); if (e.target.value === 'partner-logo-background') { donateLink.disabled = true; } else { donateLink.disabled = false; } }); nationalCheck.addEventListener('click', function() { changeDisplay(nationalCheck, localCheck, nationalOptions, localOptions); }); nationalCheckLabel.addEventListener('keypress', function(e) { if (e.keyCode === 13) { nationalCheck.click(); } }); localCheck.addEventListener('click', function() { changeDisplay(nationalCheck, localCheck, nationalOptions, localOptions); }); localCheckLabel.addEventListener('keypress', function(e) { if (e.keyCode === 13) { localCheck.click(); } }); donateLink.addEventListener('click', function() { navigateToDonationLink(charityDropdown, linkDict); }); } function updatePartnerLogo(charityVal) { partnerLogo.style.backgroundImage = "url(https://www.autonation.com/~/media/Images/LandingPages/drive-pink/charity-logos/" + charityVal + ".png)"; } function updatePartnerText(charityVal) { partnerTitle.innerHTML = linkTitle[charityVal]; partnerState.innerHTML = linkState[charityVal]; } function navigateToDonationLink(select, dict) { let link = linkDict[select.value]; window.open(link, "_blank"); } function changeDisplay(national, local, nOptions, lOptions) { if (national.checked) { displayOptions(nOptions, "block"); } else { displayOptions(nOptions, "none"); } if (local.checked) { displayOptions(lOptions, "block"); } else { displayOptions(lOptions, "none"); } } function displayOptions(options, displaySetting) { for (let i = 0; i < options.length; i++) { options[i].style.display = "" + displaySetting; } }