var canvasWidth  = window.innerWidth  ? window.innerWidth  : document.documentElement.clientWidth;
var canvasHeight = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight;
var img1h = 114;
var img2h = 412;
var img1w = 750;
var img2w = 250;
function sizeWindow() {
   var h = document.getElementById("precontent").offsetHeight + document.getElementById("postcontent").offsetHeight;
   if (canvasHeight - h > 200 && canvasWidth >= document.body.offsetWidth) {
      document.getElementById("logo1").style.marginRight = "0";
      document.getElementById("contentarea").style.height = (canvasHeight - h) + "px";
      document.getElementById("contentarea").style.overflowY = "hidden";
      document.documentElement.style.overflowY = "hidden";
      var ph = canvasHeight - h;
      var pw = document.getElementById("contentarea").offsetWidth;
      var nh = img1h + img2h + 33;
      var nw = img1w + 90;
      var ith = ph - 37;
      var itw = pw - 90;
      var scale;
      if (ith * img1w > itw * (img1h+img2h)) {
      	scale = itw / img1w;
      }
      else {
      	scale = ith / (img1h+img2h);
      }
      if (scale > 1) scale = 1;
      imgw = Math.floor(img2w * scale);
      document.getElementById("img1").style.width = (imgw * 3) + "px";
      document.getElementById("img2a").style.width = imgw + "px";
      document.getElementById("img2b").style.width = imgw + "px";
      document.getElementById("img2c").style.width = imgw + "px";
      var vs = Math.floor((ph - Math.ceil(img1h * scale) - Math.ceil(img2h * scale) - 4)/7);
      document.getElementById("img1").style.marginTop = (2 * vs) + "px";
      document.getElementById("img1").style.marginBottom = (3 * vs) + "px";     
   } else {
      document.getElementById("logo1").style.marginRight = document.getElementById("contentarea").currentStyle
                             ? document.getElementById("contentarea").currentStyle.paddingRight
                             : getComputedStyle(document.getElementById("contentarea"),null).paddingRight;
      document.getElementById("contentarea").style.height = "auto";
      document.getElementById("contentarea").style.overflowY = "visible";
      document.documentElement.style.overflowY = "scroll";
      document.getElementById("img1").style.width = "90%";
      document.getElementById("img2a").style.width = "30%";
      document.getElementById("img2b").style.width = "30%";
      document.getElementById("img2c").style.width = "30%";
      document.getElementById("img1").style.marginTop = "8px";
      document.getElementById("img1").style.marginBottom = "12px";     
   }
   document.getElementById("postcontent").style.marginRight = document.getElementById("logo1").style.marginRight;
}
   
function orsz() {
   var w = window.innerWidth  ? window.innerWidth  : document.documentElement.clientWidth;
   var h = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight;
   if (w != canvasWidth || h != canvasHeight) {
      canvasWidth  = w;
      canvasHeight = h;
      sizeWindow();
   }
}

function owld() {
   sizeWindow();
   window.onresize = orsz;
}

if (!parent.frames.length) window.onload = owld;
