// $Revision: 3870 $

function BeginFont(modifier, modifierVal)
{
  if(modifier != "")
  {
    return "<FONT " + modifier + "=\'" + modifierVal + "\'>";
  }
  return "<FONT>";
}

function EndFont()
{
  return "</FONT>";
}

function BeginBold()
{
  return "<b>";
}

function EndBold()
{
  return "</b>";
}

function BeginItalic()
{
  return "<i>";
}

function EndItalic()
{
  return "</i>"; 
}

function BeginP(modifier, modifierVal)
{
  if(modifier == undefined  && modifierVal == undefined)  return "<P>";
  if(modifier != "")
  {
    return "<P " + modifier + "=\'" + modifierVal + "\'>";
  }
  return "<P>";
}

function EndP()
{
  return "</P>";
}


function BeginNobr()
{
  return "<NOBR>";
}

function EndNobr()
{
  return "</NOBR>";
}

function Br()
{
  return "<BR/>";
}

function BeginDiv(modifier, modifierVal)
{
  if(modifier != "")
  {
    return "<DIV " + modifier + "=\'" + modifierVal + "\'>";
  }
  return "<DIV>";
}

function EndDiv()
{
  return "</DIV>";
}

function BeginSpan(modifier, modifierVal)
{
  if(modifier != "")
  {
    return "<SPAN " + modifier + "=\'" + modifierVal + "\'>";
  }
  return "<SPAN>";
}

function EndSpan()
{
  return "</SPAN>";
}

function Write(s)
{
  document.write(s);
  //document.writeln(s);
  //document.getElementById('Exercise').innerHTML += s;
  //alert('document = ' + document.getElementById('Exercise').innerHTML + '\ns = ' + s);
}

function AddToSection(secID, text)
{
  document.getElementById(secID).innerHTML += text;
}

function Table()
{
  this.SetTWidth = SetTWidth;
  this.SetTHeight = SetTHeight;
  this.SetTID = SetTID;
  this.SetTClass = SetTClass;
  this.SetTColor = SetTColor;
  this.ResetT = ResetT;
  this.BeginT = BeginT;
  this.BeginTable = BeginTable;
  this.EndTable = EndTable;
  this.EndTd = EndTd;
  this.BeginTr = BeginTr;
  this.EndTr = EndTr;
  this.BeginTd = BeginTd;
  this.EndTd = EndTd;
  this.SetTRowSpan = SetTRowSpan;
  this.SetTAlign = SetTAlign;
  this.SetTValign = SetTValign;
  this.SetTStyle = SetTStyle; 
  
  this.SetTCellspacing = SetTCellspacing;
  this.SetTCellpadding = SetTCellpadding;
  this.SetTColspan = SetTColspan;
  
  this.SetAutoReset = SetAutoReset;
  
  this.ResetT();
  
  this.Width = 0;
  this.Height = 0;
  this.ID = "";
  this.Class = "";
  this.BkColor = "";
  this.RowSpan = "1";
  this.Style = "";
  
  this.bAutoReset = false;
  
  this.TableCnt = 0;
  this.TrCnt = 0;
  this.TdCnt = 0;
  this.TestNotInTable = TestNotInTable;

function SetAutoReset(bVal)
{
  this.bAutoReset = bVal;
}

function SetTWidth(width)
{
  this.bWidthPresent = true;
  this.Width = width;
}

function SetTHeight(height)
{
  this.bHeightPresent = true;
  this.Height = height;  
}

function SetTID(id)
{
  this.ID = id;
  this.bIDPresent = true;
}

function SetTClass(class_)
{
  this.Class = class_;
  this.bClassPresent = true;
}

function SetTStyle(style)
{
  this.Style = style;
  this.bStyle = true;
}

function SetTColor(bkColor)
{
  this.BkColor = bkColor;
  this.bBkColorPresent = true;
}

function SetTRowSpan(rowSpan)
{
  this.RowSpan = rowSpan;
  this.bRowSpanPresent = true;
}

function SetTAlign(align)
{
  this.Align = align;
  this.bAlignPresent = true;
}

function SetTValign(valign)
{
  this.Valign = valign;
  this.bValignPresent = true;
}

function SetTCellspacing(cellspacing)
{
  this.Cellspacing = cellspacing;
  this.bCellspacing = true;
}

function SetTCellpadding(cellpadding)
{
  this.Cellpadding = cellpadding;
  this.bCellpadding = true;
}

function SetTColspan(colspan)
{
  this.Colspan = colspan;
  this.bColspan = true;
}

function ResetT()
{
  this.bWidthPresent = false;
  this.bHeightPresent = false;
  this.bIDPresent = false;
  this.bClassPresent = false;
  this.bBkColorPresent = false;
  this.bRowSpanPresent = false;
  this.bAlignPresent = false;
  this.bValignPresent = false;
  this.bCellspacing = false;
  this.bCellpadding = false;
  this.bStyle = false;
  this.bColspan = false;
}

function BeginT(element)
{

  var addStr = "";
  
  if(this.bWidthPresent)  addStr += ' width=\"' + this.Width + '\"';
  if(this.bHeightPresent)  addStr += ' height=\"' + this.Height + '\"';
  if(this.bIDPresent)  addStr += ' id=\"' + this.ID + '\"';
  if(this.bClassPresent)  addStr += ' class=\"' + this.Class + '\"';
  if(this.bBkColorPresent)  addStr += " style=\"background-color: " + this.BkColor + "\"";
  if(this.bRowSpanPresent)  addStr += " rowspan=\"" + this.RowSpan + "\"";
  if(this.bAlignPresent)  addStr += " align=\"" + this.Align + "\"";
  if(this.bValignPresent)  addStr += " valign=\"" + this.Valign + "\"";
  
  if(this.bColspan)  addStr += " colspan=\"" + this.Colspan + "\"";
  
  if(this.bCellspacing)  addStr += " cellspacing=\"" + this.Cellspacing + "\"";
  if(this.bCellpadding)  addStr += " cellpadding=\"" + this.Cellpadding + "\"";
  if(this.bStyle)  addStr += " style=\"" + this.Style + "\"";
 
  if(this.bAutoReset) this.ResetT(); 
  
  return "<" + element + addStr + ">";
}

function BeginTable()
{
  this.TableCnt++;
  return this.BeginT("table border=1");
}

function EndTable()
{
  this.TableCnt--;
  return "</table>";
}

function BeginTr()
{
  this.TrCnt++;
  return this.BeginT("tr");
}

function EndTr()
{
  this.TrCnt--;
  return "</tr>";
}

function BeginTd()
{
  this.TdCnt++;
  return this.BeginT("td");
}

function EndTd()
{
  this.TdCnt--;
  return "</td>";
}

function TestNotInTable()
{
  if(this.TableCnt == 0  &&  this.TrCnt == 0  &&  this.TdCnt == 0)
    return true;
  else return false;
}

}

function BeginCenter()
{
  return "<center>";
}

function EndCenter()
{
  return "</center>";
}

function Img(src, map, id)
{
  var str = "<img src='" + src + "'";
  
  if(map == undefined)  return str + ">";
  if(id == undefined)
    return str + " usemap='#" + map + "'>";
  return str + " usemap='#" + map + "' id='" + id +"'>";
}