// ===================================================================
// ParolView
// $Id: ParolView.js 3173 2009-02-13 19:21:47Z helmut $

function ParolView(element)
{
  try {
    if (typeof element == "string") element = document.getElementById(element);
    if (!element) throw("ParolView(): missing element in document");

    this.P = element;
  }
  catch (e) {
    alert("ParolView: " + e);
  }
}

ParolView.prototype._show = function(intro, text, ref)
{
  try {
    // --- compute text to show ---
    var res = "";
    if (intro) {
      res += "<p class='IL'>" + intro + "</p>";
    }
    // 2009-12-31 see styles.css [white-space-pre] - insert <br/> for IE6
    text=text.replace(/\n/g, "<br/>\n")
    
    res += "<p class='L'>" + text + "</p>"
        +  "<p class='SL'>" + ref + "</p>";

    // --- show text (even empty Parol!) ---
    this.P.innerHTML = res;
  }
  catch (e) {
    alert("ParolView._show: " + e);
  }
}

ParolView.prototype.update = function(aParol)
{
  try {
    if (!aParol) {
      this._show("", "", "");
    }
    else {
      // even for Parol.NULL
      this._show(aParol.getHtmlIL(), aParol.getHtmlL(), aParol.getSL());
    }
  }
  catch (e) {
    alert("ParolView.update: " + e);
  }
}

// === Fonts ===

ParolView.prototype.getFontSize = function()
{
  return this.P ? this.P.style.fontSize : "";
}

ParolView.prototype.getFontFamily = function()
{
  return this.P ? this.P.style.fontFamily : "";
}

ParolView.prototype.setFontSize = function(size)
{
  // size may be empty!
  if (this.P) {
    this.P.style.fontSize = size;
  }
}

ParolView.prototype.setFontFamily = function(family)
{
  if (this.P) {
    this.P.style.fontFamily = family;
  }
}

