﻿function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

function resizeCloth() {
  var page = document.getElementById("page");
  var w = (page.offsetWidth>document.body.scrollWidth) ? page.offsetWidth : document.body.scrollWidth;
  var h = (page.offsetHeight>document.body.scrollHeight) ? page.offsetHeight : document.body.scrollHeight;
  var cloth = document.getElementById("cloth");
  cloth.style.width = w + "px";
  cloth.style.height = h + "px";
}
addLoadEvent(function() {
  window.onresize=function() {
    resizeCloth();
  }
  resizeCloth();
  try {
    document.execCommand('BackgroundImageCache', false, true);
  } catch(e) {}
});
