/* 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 */ /* NAVIGATION ========== */ // This function toggles the navigation bar on mobile function ToggleNavigation() { // Toggle the class $(".header-bottom").toggleClass("disabled"); } // Store if we have requested the animation from or not var bHasRequestedAnimationFrame = false; // Store if we are on desktop or not var bIsOnDesktop = true; // Called when the window resized function OnWindowResize() { // If the window is greater than the bootstrap md if ( $(window).width() >= 769 ) { // If we have gone from mobile to desktop, or if the desktop state hasn't been propperly declared if( !bIsOnDesktop || bIsOnDesktop && bHasRequestedAnimationFrame == false ) { // If the header bottom is disabled if( $(".header-bottom").hasClass("disabled") ) { // Remove the class $(".header-bottom").removeClass("disabled"); } } // Set the variable to store that we are on desktop bIsOnDesktop = true; } // If the window is on mobile else { // If we have gone from desktop to mobile if( bIsOnDesktop ) { // If the header bottom is not disabled if( !$(".header-bottom").hasClass("disabled") ) { // Add the class $(".header-bottom").addClass("disabled"); } } // Set the variable to store that we are on desktop bIsOnDesktop = false; } // Set the animation frame state bHasRequestedAnimationFrame = false; } // Call to set the inital state OnWindowResize(); /* NAVIGATION END ============== */ // Scroll to contact form function ScrollToContactForm() { $([document.documentElement, document.body]).animate({ scrollTop: $("#ContactForm").offset().top - 200 }, 1000); } // Function to request a quote function QuoteRequest() { // Store the name var sName = $("#sName").val(); // Store the telephone var sTel = $("#sTel").val(); // Store the company name var sCompany = $("#sCompany").val(); // Store the email var sEmail = $("#sEmail").val(); // Store the enquiry var sEnquiry = $("#sEnquiry").val(); // Store the privacy policy if it was checked or not var bPrivacyPolicy = $("#bPrivacyPolicy").prop("checked"); // Store to google captcha response var sResponse = grecaptcha.getResponse( $('#recaptcha1').attr('data-widget-id') ); // Stor the error var sError = ""; // If the input name is empty if( sName.trim() == "" ) { // Set the error sError += " - Your Name
"; } // If the input tel is empty if( sTel.trim() == "" ) { // Set the error sError += " - Tel
"; } // If the input company is empty if( sCompany.trim() == "" ) { // Set the error sError += " - Company
"; } // If the input company is empty if( sEmail.trim() == "" ) { // Set the error sError += " - Email
"; } // If the input company is empty if( sEnquiry.trim() == "" ) { // Set the error sError += " - Enquiry
"; } // If the privacy policy isn't set if( !bPrivacyPolicy ) { // Set the error sError += " - You must agree to the privacy policy
"; } // If there is an error if( sError != "" ) { // output the error fShowPageMessage("Your request couldn't be sent. Please check the following fields;
" + sError); // Reset google recaptcha grecaptcha.reset( $('#recaptcha1').attr('data-widget-id') ); // Return to exit function return false; } // If there was no problem with the google recaptcha if (sResponse.length > 0 ) { // Submit the AJAX $.ajax ( { url : "ajax/quote-request.php", data : { sName : sName, sTel : sTel, sCompany : sCompany, sEmail : sEmail, sEnquiry : sEnquiry, gRecaptchaResponse : sResponse }, type : 'post', success : function (sResult ) { // Store the result and trim sResult = sResult.trim(); // If the result is 1 if( sResult == "1") { // Alert fShowPageMessage("Please tick the I'm not a robot box"); } else // If the result is 2 if( sResult == "2" ) { // Alert fShowPageMessage("Your enquiry couldn't be sent. Please ensure that all fields are correctly set"); } else // If the result is 3 if( sResult == "3" ) { // Alert fShowPageMessage("An error has occured, please try again."); } else // If the result is 999 if( sResult == "999" ) { // Alert fShowPageMessage("Thank you for your message. We will be in touch shortly."); } // Reset google recaptcha grecaptcha.reset( $('#recaptcha1').attr('data-widget-id') ); } }); } // If there was a problem with the google recaptcha else { // Alert to tick the box fShowPageMessage("Please tick the I'm not a robot box"); } } $(document).ready(function() { // On window resize $(window).on('resize', function() { // If we haven't requested the animation frame if( !bHasRequestedAnimationFrame ) { // Request it requestAnimationFrame( OnWindowResize ); // Store that we have requested it bHasRequestedAnimationFrame = true; } }); 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(); }); } }); function fLangChange($sLangAbbr, $sSURL) { var $bChange = 0; var $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; } /* COOKIE CUTTER - The "I accept cookies" legal disclaimer */ $(function(){ $.cookieCuttr(); }); // FOOTER SUBSCRIBE FORM // ===================== jQuery(document).ready(function(){ $('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 { // Check if they've ticked the privacy policy box if(!$("#bNewsletter_PrivacyPolicy").is(":checked")) { alert("Please tick the Privacy Policy box to confirm you've read our Privacy Policy before continuing."); } 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 for siging up to our mailing list!"); fShowPageMessage("Thank you for siging up 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',''); } }); } } }); }); // 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; } window.addEventListener('message', fReceiveMessage, false); function fReceiveMessage(e) { // only pass the message on if it's a valid ID var oValidCSSPattern = /^[a-zA-Z0-9\-]*$/; if(oValidCSSPattern.test(e.data)) { fScrollToDiv(e.data); } } // SCROLL TO DIV // ============== var fScrollToDivOffset = (function(){return 100;}); function fScrollToDiv($sCSSID) { var $oCSSSelector = $("#"+$sCSSID); $(".highlighted-div").removeClass("highlighted-div"); if($oCSSSelector.length > 0) { $oCSSSelector.addClass("highlightable-div"); $oCSSSelector.addClass("highlighted-div"); setTimeout(function(){ $oCSSSelector.removeClass("highlighted-div"); }, 2000); $('html,body').animate({ scrollTop: $oCSSSelector.offset().top-fScrollToDivOffset() }, 500); setTimeout(function(){ $('html,body').animate({ scrollTop: $oCSSSelector.offset().top-fScrollToDivOffset() }, 1); }, 600); } } $(window).on("load", function(){ parent.postMessage("loaded","*"); }); 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"); } } } function fShowPageMessage(sPageMessage, bHideCloseButton = false){ $("#page-message").html(sPageMessage); $("#page-message-modal").modal('show'); $('body').addClass("no-padding"); $('#page-message-modal').addClass("no-padding"); if (bHideCloseButton==true) { document.getElementById('modalCloseButton').style.display='none'; } else { document.getElementById('modalCloseButton').style.display=''; } } function fShowPageMessages() { if(aMessages.length > 0) { var sMessage = aMessages.shift(); fShowPageMessage(sMessage); $('#page-message-modal').on('hidden', function () { fShowPageMessages(); }); } } function fShowPageMessage_HTMLFromURL(sURLToGrabHTMLFrom, bHideCloseButton = false){ $.get( sURLToGrabHTMLFrom, function( data ) { $("#page-message").html(data); $("#page-message-modal").modal('show'); $('body').addClass("no-padding"); $('#page-message-modal').addClass("no-padding"); if (bHideCloseButton==true) { document.getElementById('modalCloseButton').style.display='none'; } else { document.getElementById('modalCloseButton').style.display=''; } }); }