(function(){var hyperlink=document.createElement('a');hyperlink.setAttribute('href','https://www.soilweb.ca');hyperlink.setAttribute('class','logo-link');var image=document.createElement('img');image.setAttribute('src','https://lfs-pinusradiata.sites.olt.ubc.ca/files/2023/07/processes-logo.png');hyperlink.appendChild(image);var ele=document.getElementById('ubc7-unit-name').getElementsByTagName('a')[0];var parent=ele.parentNode;parent.insertBefore(hyperlink,ele);})();var mapScalingCache={};function setupMapScaling(imageSelector,areaSelector){var $navImage=jQuery(imageSelector);var $areas=jQuery(areaSelector);var img=$navImage[0];if(!img||$areas.length===0)return null;if(!mapScalingCache[imageSelector]){var originalCoords=[];$areas.each(function(index){var coords=jQuery(this).attr("coords").split(",").map(Number);originalCoords[index]=coords;});mapScalingCache[imageSelector]={img:img,originalCoords:originalCoords,areas:$areas,rescale:null};} var cache=mapScalingCache[imageSelector];function initialize(){var originalImageWidth=cache.img.naturalWidth;function rescaleAreas(){var currentWidth=$navImage.width();var scaleValue=currentWidth/originalImageWidth;cache.areas.each(function(index){var coords=cache.originalCoords[index];var scaledCoords=coords.map(function(coord){return Math.floor(coord*scaleValue);}).join(",");jQuery(this).attr("coords",scaledCoords);});} cache.rescale=rescaleAreas;rescaleAreas();jQuery(window).off("resize"+imageSelector).on("resize"+imageSelector,rescaleAreas);} if(img.complete){initialize();}else{img.onload=initialize;} return cache;} window.addEventListener("load",function(){if(document.querySelector("#nav-menumap")){setupMapScaling("#nav-menumap","#menumap area");}});mapState=0;function swapToOldest(){mapState=0;updateShownMap();} function swapToMiddle(){mapState=1;updateShownMap();} function swapToPresent(){mapState=2;updateShownMap();} function updateShownMap(){document.getElementById("map-oldest").style.display="none";document.getElementById("map-middle").style.display="none";document.getElementById("map-present").style.display="none";document.getElementById("oldest-companion").style.display="none";document.getElementById("middle-companion").style.display="none";document.getElementById("present-companion").style.display="none";let cache=null;if(mapState===0){document.getElementById("map-oldest").style.display="inline";document.getElementById("oldest-companion").style.display="inline";} else if(mapState===1){document.getElementById("map-middle").style.display="inline";document.getElementById("middle-companion").style.display="inline";cache=setupMapScaling("#map-middle","#middle-map area");} else if(mapState===2){document.getElementById("map-present").style.display="inline";document.getElementById("present-companion").style.display="inline";cache=setupMapScaling("#map-present","#present-map area");} if(cache&&typeof cache.rescale==="function"){cache.rescale();}} window.addEventListener("load",function(){if(document.querySelector(".glacier-maps")){updateShownMap();}});