$(document).ready(function() { docHeight = $(document).height(); windowWidth = $(window).width(); headerWidth = $('.header').width(); headerHeight = 304; footerHeight = 237; totalHeight = docHeight - headerHeight - footerHeight bgTop = headerHeight if ($("body").hasClass('pic1')) { bgHeight = 3109 offSet = -220 } else if ($("body").hasClass('pic2')) { bgHeight = 2929 bgTop = headerHeight + 350 offSet = -430 } else if ($("body").hasClass('pic3')) { bgHeight = 3635 bgTop = headerHeight offSet = -780 } else if ($("body").hasClass('pic4')) { bgHeight = 3618 offSet = -380 } else if ($("body").hasClass('pic5')) { bgHeight = 1296 bgTop = headerHeight + 230 offSet = -350 } else if ($("body").hasClass('pic6')) { } else if ($("body").hasClass('pic7')) { bgHeight = 964 offSet = -200 } bgLeft = ((windowWidth - headerWidth) / 2) + offSet; if (totalHeight > bgHeight) { // $("body").css('background-position', (bgLeft +'px '+ (docHeight - bgHeight - footerHeight) +'px')) // bgTop = (docHeight - bgHeight) $("body").css('background-position', (bgLeft +'px '+ bgTop +'px')) } else { $("body").css('background-position', (bgLeft +'px '+ bgTop +'px')) } if ($("body").hasClass('contact')) { windowHeight = $(window).height() contentHeight = $(".container").height(); newHeight = (windowHeight-contentHeight-40) if (newHeight > 237) $('.footer').css('height', newHeight); } $(window).resize( function() { windowWidth = $(window).width(); bgLeft = ((windowWidth - headerWidth) / 2) + offSet; if (totalHeight > bgHeight) { $("body").css('background-position', (bgLeft +'px '+ bgTop +'px')) } else { bgTop = headerHeight $("body").css('background-position', (bgLeft +'px '+ bgTop +'px')) } if ($("body").hasClass('contact')) { windowHeight = $(window).height() contentHeight = $(".container").height(); newHeight = (windowHeight-contentHeight-40) if (newHeight > 237) $('.footer').css('height', newHeight); } }); });