function updateBackground() {
  screenWidth = $(window).width();
  screenHeight = $(window).height();
  var bg = jQuery("#bg");
  
  // Proporcion horizontal/vertical de la imagen
  ratio = 1.4;
  
  if (screenWidth/screenHeight > ratio) {
    $(bg).height("auto");
    $(bg).width("100%");
  } else {
    $(bg).width("auto");
    $(bg).height("100%");
  }

  if ($(bg).width() > 0) {
    $(bg).css('left', (screenWidth - $(bg).width()) / 2);
  }  
}
$(document).ready(function() {
  updateBackground();
  $(window).bind("resize", function() {
    updateBackground();
  });
});

