    
function clsHTML()
{
  //----------------------------------------------
  //  get
  //----------------------------------------------
  //  Description:  finds a HTML node by strNode in the 
  //                current document and returns that node
  //
  //  Parameter 1:  strNode - HTML node ID to find
  //
  //  RETURN:       success(object_node), fail(null)
  //----------------------------------------------
  this.get = function(strNode)
  {
    oHTML = document.getElementById(strNode);
    if(oHTML == null){return(null);}
    return(oHTML);
  }
  
  //----------------------------------------------
  //  append
  //----------------------------------------------
  //  Description:  finds a HTML node by strNode in the 
  //                current document and appends newNode
  //
  //  Parameter 1:  strNode - HTML node ID to find
  //  Parameter 2:  newNode - new html node to append
  //
  //  RETURN:       success(true), fail(false)
  //----------------------------------------------
  this.append = function(strNode, newNode)
  {
    if(!newNode){return(false);}
    oHTML = document.getElementById(strNode);
    if(oHTML == null)
    {
      oHTML = document.getElementsByTagName(strNode);
      if(oHTML.length == 0){return(false);}
      
      oHTML = oHTML.item(0);
    }
    
    oHTML.appendChild(newNode);
    return(true);
  }

  //----------------------------------------------
  //  write
  //----------------------------------------------
  //  Description:  Searches for a strNode in the HTML where id matches
  //                strNode and updates the innerHTML with strData
  //
  //  Parameter 1:  strNode - HTML node ID to find
  //  Parameter 2:  strData - must be well formed HTML
  //
  //  RETURN:       success(true), fail(false)
  //----------------------------------------------
  this.write = function(strNode, strData)
  {
    if(!(oHTML = this.get(strNode))){return(false);}
    oHTML.innerHTML = strData;
    return(true);
  };

  //----------------------------------------------
  //  buildSelect
  //----------------------------------------------
  //  Description:  Builds a string containing a well formed HTML selectbox
  //                It will create an <option> node for each item in arrSel
  //
  //  Parameter 1:  strNode - HTML node ID to find
  //  Parameter 2:  arrSel - 2D array,  example arrSel = new Array(Array(name, id), Array(name, id));
  //  Parameter 3:  selID  - id matching the id in arrSel to put focus
  //  Parameter 4:  selID  - the id matching the id in arrSel to put focus
  //
  //  RETURN:       success(true), fail(false)
  //----------------------------------------------
  this.buildSelect = function(strNode, arrSel, selID, selName, onChange)
	{
		s = "<SELECT id='" + selName + "' name='" + selName + "' onChange=\"javascript:" + onChange + "(this);\">";
		for(var c=0;c<arrSel.length;c++)
		{
			s += "<OPTION id='" + arrSel[c][1] + "' name='" + arrSel[c][1] + "'" + (selID == c?" SELECTED":"") + " value='" + arrSel[c][1] + "'>" + arrSel[c][0] + "</OPTION>";
		}
		s += "</SELECT>";
    
    return(this.write(strNode, s));
	};
  
  this.insertOption = function(selID, optionID, index, value, text)
  {
    if(!(oHTML = this.get(selID))){return(null);}
    if((oHTML.tagName).toLowerCase() != "select"){return(null);}
    
    oOption = document.createElement("OPTION");
    oOption.setAttribute("id", optionID);
    oOption.setAttribute("name", optionID);
    oOption.setAttribute("value", value);
    oText = document.createTextNode(text);
    oOption.appendChild(oText);
    
    if(index < oHTML.childNodes.length)
    {
      oHTML.insertBefore(oOption, oHTML.childNodes.item(index));
    }
    else
    {
      oHTML.appendChild(oOption);
    }
    return;
  };
  
  this.mouseCoords = function(ev)
  {
    if(ev.pageX || ev.pageY)
    {
   		return {x:ev.pageX, y:ev.pageY}
   	}
   	return {
   		x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
   		y:ev.clientY + document.body.scrollTop  - document.body.clientTop
   	}
  };
  
  this.getSelectedNode = function(strNode)
  {
    if(!(oHTML = this.get(strNode))){return(null);}
    if((oHTML.tagName).toLowerCase() != "select"){return(null);}
    if(oHTML.options.length == 0){return(null);}
    if(oHTML.selectedIndex == -1){return(null);}
    
    return(oHTML.options[oHTML.selectedIndex]);
  };
  
  this.getSelectedValue = function(strNode)
  {
    oHTML = this.getSelectedNode(strNode);
    if(!oHTML){return(null);}
    return(oHTML.value);
  };
  
  this.getSelectedText = function(strNode)
  {
    oHTML = this.getSelectedNode(strNode);
    if(!oHTML){return(null);}
    return(oHTML.innerHTML);
  };
  
  this.getSelectedID = function(strNode)
  {
    oHTML = this.getSelectedNode(strNode);
    if(!oHTML){return(null);}
    return(oHTML.getAttribute("id"));
  };
  
  this.getSelectedIndex = function(strNode)
  {
    oHTML = this.getSelectedNode(strNode);
    if(!oHTML){return(null);}
    
    return(parseInt(oHTML.getAttribute("id")));
  };
  
  this.setSelectedIndex = function(strNode, index, id)
  {
    oHTML = this.get(strNode);
    if(!oHTML){return(false);}    
    
    oOptions = oHTML.getElementsByTagName("option");
    
    if(!index)
    {
      for(var c=0;c<oOptions.length;c++)
      {
        if(id == oOptions.item(c).value)
        {
          index = c;
          break;
        }
      }
    }
    
    len = parseInt(oOptions.length);
    if(len > index)
    {
      oHTML.selectedIndex = index;
      return(true);
    }
    return(false);
  };

}//end class

String.prototype.replaceAll = function(strMatch, strReplace)
{
  s = this;
  count = 0;
  while((s.indexOf(strMatch) >= 0) && (count++ < 1000))
  {
    s = s.replace(strMatch, strReplace);
  }
  return(s);
};
