// JavaScript Document
window.onresize = centerfix;

function centerfix(){
  c_fix(1000, 10000, 0, 20);
}

function c_fix(cont_x, cont_y, min_l, min_t) {
  var frame = document.getElementById("position_div");  
  var total_height = document.documentElement.clientHeight;
  var total_width = document.documentElement.clientWidth;
  var pos_y = 0;
  var pos_x = 0;
  
  if (cont_y > total_height - 2*min_t) {
    pos_y = min_t;
  } else {
    pos_y = (total_height - cont_y)/2;
  }
  
  if (cont_x > total_width - 2*min_l) {
    pos_x = min_l;
  } else {
    pos_x = (total_width - cont_x)/2;
  }
  
  frame.style.top = pos_y + "px";
  frame.style.left = pos_x + "px";

}