$(document).ready(function(){

  $("div.content-wrapper").hide();
  setTimeout("setBackground()",100);
  setTimeout("setBackground()",200);
  setTimeout("setBackground()",500);
  setTimeout("setBackground()",1000);

  $(window).resize(function(){setBackground()});
});

function setBackground()
{
  var backgroundRatio = 1.65;
  var browserHeight = $(window).height();
  var browserWidth = $(window).width();
  var browserRatio = browserWidth/browserHeight;

  var background = $("div.background");
  var content = $("div.content-wrapper");

  if(browserWidth < 950 && browserHeight < 625 ) {
    var fixedWidth = 950;
    background.width(fixedWidth+"px");
    background.height(fixedWidth/backgroundRatio+"px");
    content.width(background.width()+"px");
    content.height(background.height()+"px");
    if($("div.content-wrapper:hidden").length > 0) $("div.content-wrapper").fadeIn();
    return;
  }

  if(browserRatio < backgroundRatio) {
    background.height(browserHeight+"px");
    background.width(Math.round(browserHeight*backgroundRatio)+"px");
    content.height(background.height()+"px");
    content.width(background.width()+"px");
  } else {
    background.width("100%");
    background.height("auto");
    content.width(background.width()+"px");
    content.height(background.height()+"px");
  }

  if($("div.content-wrapper:hidden").length > 0) $("div.content-wrapper").fadeIn();

}
