var contentWidth=0;
var contentHeight=0;
var timer;
var navHeight=156;
var headerHeight=0;
var footerHeight=45;
var sidebarWidth=220;
var chromeHeight=headerHeight+footerHeight;
function dbug(theString){
  document.getElementById('content').innerHTML=theString;
  }
function init(){
  contentWidth=window.innerWidth-300;
  contentHeight=window.innerHeight-chromeHeight;
  sizeTick();
  timer=window.setInterval("sizeTick()", 300);
  }
function sizeTick(){
  if(window.innerWidth!= undefined){
    newWidth=window.innerWidth;
    newHeight=window.innerHeight;
    }
  else{
    var B= document.body, D= document.documentElement;
    //alert(D.clientWidth+", "+B.clientWidth);

    newWidth=Math.max(D.clientWidth, B.clientWidth);
    newHeight=Math.max(D.clientHeight, B.clientHeight);
    }
  
  //dbug(newWidth+", "+newHeight);


  newWidth-=sidebarWidth;
  newHeight-=chromeHeight;



  //alert('wtf?');
  //if(newWidth<1040){newHeight-=15;}
  //if(newHeight<625){newHeight=625;}
  //document.getElementById('headline').innerHTML=newHeight+" "+newWidth;
  if((newWidth != contentWidth)||(newHeight != contentHeight)){
    contentHeight=newHeight;
    contentWidth=newWidth;
    screenLayout();
    
    }
  }
function screenLayout(){
  document.getElementById("content").style.width=contentWidth+"px";
  document.getElementById("content").style.height=contentHeight+"px";
  sidebarHeight=contentHeight+headerHeight;
  document.getElementById("sidebar").style.height=sidebarHeight+"px";
  navTop=sidebarHeight-navHeight-40;
  document.getElementById("nav").style.marginTop=navTop+"px";
  }
window.getWinSize= function(){
    if(window.innerWidth!= undefined){
        return [window.innerWidth, window.innerHeight];
    }
    else{
        var B= document.body, 
        D= document.documentElement;
        return [Math.max(D.clientWidth, B.clientWidth),
        Math.max(D.clientHeight, B.clientHeight)];
    }
}

