with (classes) {
//
with (OCP) {
//
with (Book) {
//
Book.Heading = function ()
{
 with (Heading)
 {
  this.setTitle = setTitle;
  this.setManuscript = setManuscript;
  this.setReading = setReading;
  this.setFragment = setFragment;
  this.showReading = showReading;

  this.Reading_XSLTProcessor =

  this.the_title = null;
  this.the_reading = null;
  this.reading_manuscript = null;

  with (this)
  {
   with (ownerDocument)
   {
    the_title = getElementById(id + ".the_title");
    the_reading = getElementById(id + ".the_reading");
   }
/*
   var ReadingStylesheet_Document = Application.contentDocument.implementation.createDocument(null, null, null);

   with (ReadingStylesheet_Document) { async = false; load(reading_stylesheet); }
*/
   ReadingStylesheet_Document = Application.The_LSParser.parseURI(reading_stylesheet);

   (Reading_XSLTProcessor = new XML.XSLTProcessor).importStylesheet(ReadingStylesheet_Document);
  }
 }

 return this;
}
//
// Heading.title = dom.html2.HTMLHeadingElement;
// Heading.reading = dom.html2.HTMLHeadingElement;
// Heading.manuscript = dom.html2.HTMLSpanElement;
//
Heading.reading_stylesheet = "classes/OCP/Book/Heading/reading.xsl";
//
Heading.construct = function (The_HTMLDivElement) { with (Heading) { return call(The_HTMLDivElement); }}
//
Heading.setTitle = function (title_text) { with (Heading) with (this)
{
 with (the_title)
 {
  while (lastChild) removeChild(lastChild);

  appendChild(ownerDocument.createTextNode(title_text));
 }
}}
//
Heading.setManuscript = function (this_Book_manuscript) { with (Heading) with (this)
{
 Reading_XSLTProcessor.setParameter(null, "the_manuscript", this_Book_manuscript);

 if (reading_manuscript) with (reading_manuscript)
 {
  while (lastChild) removeChild(lastChild);

  appendChild(ownerDocument.createTextNode(this_Book_manuscript));
 }
}}
//
Heading.setReading = function (Text_Element, from_positions, to_positions) { with (Heading) with (this)
{
 with (Reading_XSLTProcessor)
 {
  if (from_positions) setParameter(null, "from_positions", from_positions.toString());
  else removeParameter(null, "from_positions");

  if (to_positions) setParameter(null, "to_positions", to_positions.toString());
  else removeParameter(null, "to_positions");

  removeParameter(null, "fragment_number");
 }

 showReading(Text_Element);
}}
//
Heading.setFragment = function (Text_Element, fragment_number) { with (Heading) with (this)
{
 with (Reading_XSLTProcessor)
 {
  setParameter(null, "fragment_number", fragment_number);

  removeParameter(null, "from_positions");
  removeParameter(null, "to_positions");
 }

 showReading(Text_Element);
}}
//
Heading.showReading = function (Text_Element) { with (Heading) with (this)
{
 var Reading_Document = Reading_XSLTProcessor.transformToDocument(Text_Element.parentNode); // Safari workaround

 var rendered_reading = Application.contentDocument.importNode(Reading_Document.documentElement, true);

 replaceChild(rendered_reading, the_reading); the_reading = rendered_reading;

 reading_manuscript = the_reading.getElementsByTagName("span").item(0);
}}
//
}
//
}
//
}
