// Set the array of messages var messageArray = ["Driven by a passion to make cities places for people to thrive", "Delivering regeneration from vision to experience", "Integrating infrastructure, places and people", "A practical approach to delivering a consistent vision", "Creating social, environmental and economic value"]; var i = 1; // Update the message every 10 seconds var x = setInterval(function() { // Check i is still within bounds //alert(messageArray.length); if (i >= messageArray.length) { i = 0; } // Display next message var myElement = document.getElementById("message"); myElement.innerHTML = '' + messageArray[i++] + ''; }, 10000); //Scroll Button var mButton; //Get the button function loadButton() { mybutton = document.getElementById("topBtn"); } // When the user scrolls down 20px from the top of the document, show the button window.onscroll = function() {scrollFunction()}; function scrollFunction() { if ((document.body.scrollTop > 128 || document.documentElement.scrollTop > 128) && (document.body.scrollTop < (document.body.scrollHeight - document.documentElement.clientHeight - 48))) { mybutton.style.display = "block"; } else { mybutton.style.display = "none"; } } // When the user clicks on the button, scroll to the top of the document function topFunction() { document.body.scrollTop = 0; document.documentElement.scrollTop = 0; } //Master onload function function MainOnload() { loadButton(); }