/* 
   Removes all children (previous text) and replaces 
   them with the new text.

   Parameters:
   * element: The element where the new text should be inserted
   * textToInsert: The new text to be inserted.
 */
function replaceText(element, textToInsert)
{   
   while(element.firstChild != null)
      element.removeChild(element.firstChild);

   var newTextNode = document.createTextNode(textToInsert);
   element.appendChild(newTextNode);
}


/* 
   Removes all children (previous text) and replaces 
   them with the new text (parameter texToInsert).

   A linebreak-element is also inserted after the
   new textNode.

   Parameters:
   * element: The element where the new text should be inserted
   * textToInsert: The new text to be inserted.
 */
function replaceTextLine(element, textToInsert)
{   
   while(element.firstChild != null)
      element.removeChild(element.firstChild);

   var newTextNode = document.createTextNode(textToInsert);
   element.appendChild(newTextNode);

   var newLineBreak = document.createElement("br");
   element.appendChild(newLineBreak);
}


/* Appends the given text (parameter texToInsert) into the element "element".

   Parameters:
   * element: The element where the new text should be inserted
   * textToInsert: The text to be inserted.
 */
function appendText(element, textToInsert)
{   
   var newTextNode = document.createTextNode(textToInsert);
   element.appendChild(newTextNode);
}


/* Appends the given text (parameter texToInsert) into the element "element".
   A linebreak-element is also inserted after the new textNode.

   Parameters:
   * element: The element where the new text should be inserted
   * textToInsert: The text to be inserted.
 */
function appendTextLine(element, textToInsert)
{   
   var newTextNode = document.createTextNode(textToInsert);
   element.appendChild(newTextNode);

   var newLineBreak = document.createElement("br");
   element.appendChild(newLineBreak);
}