function Element(element)
{
    if (element.setContent != null)
        return element;

    element.setContent       = Element.prototype.setContent;
    element.removeFromParent = Element.prototype.removeFromParent;
    element.moveToBefore     = Element.prototype.moveToBefore;
    element.replaceElement   = Element.prototype.replaceElement;
    element.moveToAfter      = Element.prototype.moveToAfter;
    element.hide             = Element.prototype.hide;
    element.show             = Element.prototype.show;
    
    element.isHidden         = false;
    element.isVisible        = Element.prototype.isVisible;
    
    return element;
}

// Sets the child nodes of the element.
//
// Parameters:
//     content: Can be a string, 
Element.prototype.setContent = function(content)
{
    setContent(this, content);
}

// Removes the element from the page.
Element.prototype.removeFromParent = function()
{
    if (this.parentNode == null)
        return;
        
    this.parentNode.removeChild(this);
};

// Moves the element onto the page before the given element.
Element.prototype.moveToBefore = function(element)
{
    element.parentNode.insertBefore(this, element);
};

// Replaces the given element with the control.
Element.prototype.replaceElement = function(element)
{
    element.parentNode.replaceChild(this, element);
};

// Moves the element onto the page after the given element.
Element.prototype.moveToAfter = function(element)
{
    element.parentNode.insertBefore(this, element.nextSibling);
};

// Hides the element.
Element.prototype.hide = function()
{
    this.style.display = "none";
    this.isHidden      = true;
};

// Unhides the control.
Element.prototype.show = function()
{
    this.style.display = "";
    this.isHidden      = false;
};

Element.prototype.isVisible = function()
{
    return !this.isHidden && (this.parentNode.isVisible == null || this.parentNode.isVisible());
}

