$(document).ready(function() { var supportsCssBackgroundResize = function () { if (!$.browser.msie) { return true; } var version = parseInt($.browser.version, 10); var minimumSupportedVersion = 9; return version >= minimumSupportedVersion; } if (!supportsCssBackgroundResize()) { $(window).resize(function () { backgroundResize(); }); backgroundResize(); } }); function runScrolling() { //$('div#panel').css('overflow','hidden'); $('div#panel').jScrollPane(); } function backgroundResize() { var windowWidth = $(window).width(); var windowHeight = $(window).height(); var backgroundImage = function () { var originalWidth = 1920; var originalHeight = 1200; var image = function () { var imageElement = $('img', $('div#background-picture')); if (imageElement.length === 0) { var pathToImage = $('div#background-picture').css('background-image').replace(/"/g,"").replace(/url\(|\)$/ig, ""); $('div#background-picture').append(''); $('div#background-picture img#background').css ({'position':'absolute'}); imageElement = $('img', $('div#background-picture')); } return imageElement; }; var aspectRatio = function () { return originalWidth / originalHeight; }; var positioningProperties = function () { var windowWidth = $(window).width(); var windowHeight = $(window).height(); var windowAspectRatio = windowWidth / windowHeight; var width, height, left, top; if (windowAspectRatio > aspectRatio()) { width = windowWidth+20; height = Math.ceil(windowWidth / aspectRatio())+20; left = 0; top = 0 - ((height - windowHeight) / 2); } else { width = Math.ceil(windowHeight * aspectRatio())-20; height = windowHeight+20; left = 0 - ((width - windowWidth) /2); top = 0; } return { 'width':width + 'px', 'height':height + 'px', 'left':left, 'top':top } }; var setPosition = function () { image().css(positioningProperties()); }; this.setPosition = function () { setPosition(); }; }; var currentBackgroundImage = new backgroundImage(); currentBackgroundImage.setPosition(); }