function windowWidth() {
  var iWidth = 0;
  if (document.compatMode && document.compatMode == 'CSS1Compat') {
    if (window.opera) {
    	iWidth = document.body.clientWidth || 0;
    } else {
    	iWidth = document.documentElement.clientWidth || 0;
    }
  } else {
  	iWidth = window.innerWidth || document.body.clientWidth ||
  	 document.documentElement.clientWidth || 0;
  }
	return iWidth;
}

function windowHeight() {
  var iHeight = 0;
  if (document.compatMode && document.compatMode == 'CSS1Compat') {
    if (window.opera) {
    	iHeight = document.body.clientHeight || 0;
    } else {
    	iHeight = document.documentElement.clientHeight || 0;
    }
  } else {
  	iHeight = window.innerHeight || document.body.clientHeight ||
  	 document.documentElement.clientHeight || 0;
  }
	return iHeight;
}

function resizeWindow(iWidth, iHeight) {
  try {
    window.resizeTo(iWidth, iHeight);
    var iNewWidth = iWidth;
    var iNewHeight = iHeight;
    while (windowWidth() < iWidth) {
      iNewWidth += 10;
      window.resizeTo(iNewWidth, iNewHeight);
    }
    while (windowWidth() > iWidth) {
      iNewWidth--;
      window.resizeTo(iNewWidth, iNewHeight);
    }
    while (windowHeight() < iHeight) {
      iNewHeight += 10;
      window.resizeTo(iNewWidth, iNewHeight);
    }
    while (windowHeight() > iHeight) {
      iNewHeight--;
      window.resizeTo(iNewWidth, iNewHeight);
    }
  } catch (oException) {}
}

var oContainer = document.getElementById('container');

function resizeToContent() {
  if (window.sizeToContent) {
    window.sizeToContent();
  } else {
    resizeWindow(oContainer.offsetWidth, oContainer.offsetHeight);
  }
}
