$(document).ready(function(){ var splashid = Math.floor(Math.random()*6); function imagecorrectwidth(){ if (screen.width <= 800){ $('#stcc').html('STCC logo'); $('#race').html('STCC Race Car'); } else{ $('#stcc').html('STCC logo'); $('#race').html('STCC Race Car'); } } imagecorrectwidth(); // Detect whether device supports orientationchange event, otherwise fall back to // the resize event. var supportsOrientationChange = "onorientationchange" in window, orientationEvent = supportsOrientationChange ? "orientationchange" : "resize"; window.addEventListener(orientationEvent, function() { imagecorrectwidth(); }, false); });