var main, code;
var refresh = 3600 * 1000;

function layout () {
	var winW,winH;
	if (document.all) {
	  if (document.documentElement.clientHeight) {
			winW = document.documentElement.clientWidth;
			winH = document.documentElement.clientHeight;
    } else {
			winW = document.body.clientWidth;
			winH = document.body.clientHeight;
    }
	} else {
	  winW = window.innerWidth;
	  winH = window.innerHeight;
	}
	main.style.top = Math.floor(winH/2-250) + "px";
	main.style.left = Math.floor(winW/2-389) + "px";
}

function init () {
  main = document.getElementById("main");
  code = document.getElementById("code_field");
  if (document.getElementById("pagelist")) {
    // if on home page, adjust links so target
    // varies by time; then visited links reset
    // after a while
    var now = new Date();
    var ts = "?t=" + Math.floor(now.getTime()/refresh);
    var links = document.getElementsByTagName("a");
    for (var i=0;i<links.length;i++) {
      links[i].href += ts;
      links[i].style.visibility = "visible";
    }
  }
  layout();
}

window.onload=init;
window.onresize=layout;
