// ################################################################################
// Top-level functions - Generic HTML builders.
// Functions for generating HTML tags and common sequences.
// ################################################################################

function fnStartOfPopup(doctitle,pathToStyleSheet)
// Top-level function. Returns a string of HTML to write to a newly-opened pop-up document
{
  var StartHTML = '';
  StartHTML += '<html>\n<head>\n'
             + '<title>' + doctitle + '</title>\n'
             + '<!-- This page dynamically generated using scripts in lib_HTML.js -->\n'
             + '<link rel="stylesheet" href="' + pathToStyleSheet + '" type="text/css">\n'
             + '</head>\n<body>\n';
  return StartHTML;
} // end fnStartOfPopup()

// ################################################################################

function fnEndOfPopup()
// Top-level function. Returns a string of HTML to write to the end of a pop-up document
{
  var EndHTML = '</body>\n</html>\n';
  return EndHTML;
} // end fnEndOfPopup

// ################################################################################

function fnTag(type,attributes,tagInnerHTML)
// Top-level function - returns a container tag of the specified type and attributes
// surrounding the specified text
{
  var tag = '<' + type + ' ' + attributes + '> ' + tagInnerHTML + ' </' + type + '>\n';
  return tag;
} // end fnTag

// ################################################################################

function fnSpecialHTML(normalHTML)
// Replaces characters in HTML code so that the code can be displayed in the document rather
// than being interpreted by the browser.
{
  var specialHTML = new String(normalHTML);
  specialHTML = specialHTML.replace(/</g,"&lt;");
  specialHTML = specialHTML.replace(/>/g,"&gt;");

  return specialHTML;
} // end fnSpecialHTML

// ################################################################################


