var ss_displayingLog = false;

function ss_showDebugLog(show) {
  if (show && !ss_displayingLog) {
    ss_displayingLog = true;
  }
  if (ss_displayingLog) {
    var el = document.getElementById('debugLogDiv');
    if (el.parentNode != document.body) {
      document.body.appendChild(el);
    }
    var size = ss_getSize();
    var height = (size['height']);
    var width = (size['width']);
    el.style.top = height / 2 + 20 + 'px';
    el.style.height = height - (height / 2) - 2 - 20 - 20 + 'px'; 
    el.style.width = width - 2 - 20 + 'px'; 
    el.style.visibility = 'visible';
    el.style.display = 'block';
    el.getElementsByTagName('h1')[0].style.top = height / 2 + 'px';
    el.getElementsByTagName('h1')[0].style.width = width + 'px'; 
  }
}

function ss_closeDebugLog() {
  document.getElementById('debugLogDiv').style.visibility = 'hidden';
  document.getElementById('debugLogDiv').style.display = 'none';
  ss_displayingLog = false;
}

function ss_getSize() {
  var myWidth = 0;
  var myHeight = 0;
 
  if (typeof window.innerWidth != 'undefined') {
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if (typeof document.documentElement != 'undefined'
    && typeof document.documentElement.clientWidth != 'undefined'
    && document.documentElement.clientWidth != 0) {
    // IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
       myWidth = document.documentElement.clientWidth;
       myHeight = document.documentElement.clientHeight;
  } else {
    // older versions of IE
    myWidth = document.getElementsByTagName('body')[0].clientWidth;
    myHeight = document.getElementsByTagName('body')[0].clientHeight;
  }
  
  myWidth = document.body.clientWidth;
  
  return { 
    "width" : myWidth,
    "height" : myHeight
  };
}

function scrollbarWidth() {
  document.body.style.overflow = 'hidden';
  var width = document.body.clientWidth;
  // Scrollbalken
  document.body.style.overflow = 'scroll';
  width -= document.body.clientWidth;
  // Der IE im Standardmode  
  if(!width) width = document.body.offsetWidth-document.body.clientWidth;

  document.body.style.overflow = '';
  return width;  
}

if (typeof dojo == "undefined") {
  window.onresize = function() {
    ss_showDebugLog(false);
  };
} else {
  dojo.connect(window, 'onresize', function() {
    ss_showDebugLog(false);
  });
}