// utility function to output messages
var outputdiv;

function outputMessage(msg)
{
  if (!outputdiv)
  {
    // ignore messages if output div is not defined yet
    return;
  }

  var div = outputdiv.appendChild(document.createElement('div'));
  div.appendChild(document.createTextNode(msg));
}

// utility function to display example script source
function displayexample(example)
{
  var examplescript = document.getElementById('example-' + example + '-script');
  var exampletext   = document.getElementById('example-' + example + '-text');
  var code = examplescript.innerHTML;
  exampletext.appendChild(document.createTextNode(code));
  if (document.all)
  { 
    // Internet Explorer does not escape the contents of 
    // a text node so we have to do it for IE.
    var ih = exampletext.innerHTML;
    ih = ih.replace(/</g, '&lt;');
    ih = ih.replace(/>/g, '&gt;');
    ih = ih.replace(/\n/g, '<br>');
    ih = ih.replace(/ /g, '&nbsp;');
    exampletext.innerHTML = ih;
  }
}

