Detecting screen / device

Return true/false if we are on a mobile device (all 1 line).

var isMobile = navigator.userAgent.toLowerCase().indexOf('mobile') > 0 ? true : false;

Get the browser window dimensions.

var w = window.innerWidth;    
var h = window.innerHeight;

Detect if the window has resized (such as a phone/tablet being rotated) and adjust our width/height settings accordingly.

function adjustSize() {
   w = window.innerWidth;
   h = window.innerHeight;
window.onresize = adjustSize;