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';
    }
  }
}

function suggestSef(fromId, toId) {
  input = document.getElementById(fromId).value;
  
  temp = input.replace(/[ÅÄåä]/g, 'a');
  temp = temp.replace(/[Öö]/g, 'o');
  temp = temp.toLowerCase();
  temp = temp.replace(/\s/g, '_');
  temp = temp.replace(/[\-_]+/g, '_');
  
  outputField = document.getElementById(toId);
  
  outputField.value = temp.replace(/[^a-z0-9_\-]/g, '');
}