function getViewportHeight() {
  if (self.innerHeight) {
    // all except Explorer
    return self.innerHeight;
  }
  else if (document.documentElement && document.documentElement.clientHeight) {
    // Explorer 6 Strict Mode
    return document.documentElement.clientHeight;
  }
  else if (document.body) {
    // other Explorers
    return document.body.clientHeight;
  }
  
  return 0;
}

function setHeight(id, offset) {
  preview = document.getElementById(id);
  
  height = getViewportHeight();
  
  if (height > offset) {
    preview.style.height = (height - offset) + 'px';
  }
}

function setHeights(ids, offset) {
  height = getViewportHeight();
  
  if (height > offset) {
    for(i = 0; i < ids.length; i++) {
      element = document.getElementById(ids[i]);
      element.style.height = (height - offset) + 'px';
    }
  }
}