/* Makes */ document.addEventListener("DOMContentLoaded", function(event) { var img = document.getElementById('main-background'); if(isLoaded(img)) { var width = img.clientWidth; var height = img.clientHeight; if(width > (height * 1.50)) { img.className += ' landscape'; } } else { img.onload = function () { var width = img.clientWidth; var height = img.clientHeight; if(width > (height * 1.50)) { img.className += ' landscape'; } } } }); function isLoaded(img) { return img.complete && typeof(img.naturalHeight) !== 'undefined' && img.naturalHeight !== 0; }