var msie = navigator.userAgent.indexOf("MSIE", 0) >= 0;

function relocate() {
  window.onresize = null;

  var footer = document.getElementById("footer");
  footer.style.position = "absolute";

  if(msie) {
    setTimeout(function() {
      var bounds = footer.getBoundingClientRect();
      if(bounds.top+footer.clientHeight < document.body.clientHeight)
        footer.style.position = "relative";
      setTimeout(function() {
        window.onresize = function() {
          relocate();
        };
      }, 100);
    }, 100);
  } else {
    if(window.innerHeight < document.body.clientHeight)
      footer.style.position = "relative";
    window.onresize = function() {
      relocate();
    };
  }
}

