/*
** Functions to support the dynamic manipulation of
** HTML elements
*/

/*
 * Dynamically adds an HTML element within given parent
 * and places at the end.  This assumes that all additional
 * styles/properties/behavior will be done by the caller.
 * 
 * parent: The parent or id in which to append the element
 * tagName: The tag name of the element to create, e.g., "DIV"
 * display: Display style attribute.  Defaults to "none", i.e., hidden
 * className: Style class to assign
 */
function awpxCreateElement(parent, tagName, display, className) 
{
  var el = awpxGetElement(parent);
  var child = document.createElement(tagName);
  if(el.tagName == "INPUT") {
    alert("Cannot create element: " + tagName);
  }
  if(!display)
  {
    display = "none";
  }
  child.style.display = display;

  if(className) {
    child.className = className;
  }

  el.appendChild(child);
  return child;
}

/*
 * Dynamically removes the specified HTML element from it's parent
 * child: The child or id of the child to remove
 */
function awpxRemoveElement(child)
{
  var el = awpxGetElement(child);
  var parent = el.parentNode;
  parent.removeChild(el);
}
