/* THIS IS GLOBALLY INCLUDED ON EVERY PAGE. SO PUT STUFF HERE YOU NEED TO BE ON *EVERY* PAGE OF THE WEBSITE Previously called inc-htmlheader.js */ $(document).ready(function(){ // Disable Bootstraps IE-breaking accessibility JS $.fn.modal.Constructor.prototype.enforceFocus = function () { }; if($('.datePicker').length) { $('.datePicker').datepicker({ minDate: 0, dateFormat: 'dd/mm/yy' }); } if($('.LangClose').length) { $('.LangClose').click(function(){ document.cookie="LanguageWidgetClose=1;path=/"; $("#LangSelect").remove(); }); } if($("#CurrencySelector").length) { $("#CurrencySelector").on("change",function(){ var oDate = new Date(); oDate.setTime(oDate.getTime() + (30*24*60*60*1000)); var sExpires = "expires="+oDate.toUTCString(); document.cookie="nCurrency_ID="+$(this).val()+"; path=/"; location.reload(); }); } $('form#footerNewsletter').submit(function(e){ // stop form submitting (page load) e.preventDefault(); // get the name (if is exists) var emailName = ""; if($('input[name="sNewsName"]').length) emailName = $('input[name="sNewsName"]').val(); // get email address var emailAddress = $('input[name="sNewsEmailAddress"]').val(); // Check email address length if(emailAddress.length < 10) { alert("Your email address isn't valid"); } else { // ajax it $.ajax({ data: {sEmailName:emailName, sEmailAddress: emailAddress}, type: 'post', url: 'ajax/newsletter_exec.php', success: function(data) { // Append goal information to head $('head').append(data); // Alert user of sign up success alert("Thank you. You have been successfully added to our mailing list."); // Clear the form if($('input[name="sNewsName"]').length) $('input[name="sNewsName"]').val(""); $('input[name="sNewsEmailAddress"]').val(""); $('input[name="sNewsEmailAddress"]').css('background-color',''); } }); } }); }); function fLangChange($sLangAbbr, $sSURL) { $bChange = 0; $sNewURL = window.location.href; aLanguages.forEach(function($sTempLangAbbr){ console.log($sTempLangAbbr); if(window.location.href.indexOf("/"+$sTempLangAbbr+"/")>=0) { $sNewURL = $sNewURL.replace("/"+$sTempLangAbbr+"/","/"+$sLangAbbr+"/"); $bChange = 1; } }); if(!$bChange) { $sNewURL=$sSURL+$sLangAbbr+"/"; } window.location = $sNewURL; } // EMAIL CHECK // ============== function fCheckEmail(email) { var re = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i; if(!re.test(email)) return "invalid"; else return true; } // SCROLL TO DIV // ============== $(window).on("load", function(){ parent.postMessage("loaded","*"); }); function fValidateEmail(email) { var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; return re.test(email); } // CUSTOM JS //======================= //initalise variables var headerSpacer = document.getElementById("header-spacer"); var headerNavCol = document.getElementById("header-nav-col"); var smallHeader = false; var isHomePage = false; //THROTTLE FUNCTION ;(function() { //declared throttle function var throttle = function(type, name, obj) { //if obj attribute is not defined then make it equal to window obj = obj || window; var running = false; //new function var func = function() { //if its firing retun if (running) { return; } running = true; //limit turn off using request animation frame requestAnimationFrame(function() { //trigger the custom event obj.dispatchEvent(new CustomEvent(name)); running = false; }); }; obj.addEventListener(type, func); }; //comment out either of these if you dont need them throttle ("scroll", "optimizedScroll"); throttle("resize", "optimizedResize"); })(); window.onload = function(){ window.addEventListener("optimizedScroll", function(){ HeaderCheck(); }); }; function HeaderCheck(){ if(!isHomePage){ if(document.body.scrollTop > 130 && !smallHeader){ headerNavCol.style.height = "36px"; headerSpacer.style.height = "92px"; smallHeader = true; } if(document.body.scrollTop < 130 && smallHeader){ headerNavCol.style.height = "62px"; headerSpacer.style.height = "118px"; smallHeader = false; } } } $('.hmbgr-menu').click(function(){ $('#mobile-nav').toggleClass('mobile-nav-display'); if($('#mobile-nav').hasClass('mobile-nav-display')){ $('.hmbgr-menu > i') } })