

var __aspxRPHeaderTextContainerIDSuffix = "_RPHT";
var __aspxRPContentElementIDSuffix = "_RPC";
var __aspxRPGroupBoxCaptionIDSuffix = "_GBC";
var ASPxClientRoundPanel = _aspxCreateClass(ASPxClientPanel, {
    constructor: function(name) {
        this.constructor.prototype.constructor.call(this, name);
        this.headerTextContainer = null;
        this.headerTextEmpty = false;
        this.contentElement = null;
        this.isGroupBox = false;
    },
    
    GetContentElement: function() {
        if (this.contentElement == null)
            this.contentElement = this.GetChild(__aspxRPContentElementIDSuffix);
        return this.contentElement;
    },
    GetGroupBoxCaptionElement: function() {
        if (this.groupBoxCaptionElement == null)
            this.groupBoxCaptionElement = this.GetChild(__aspxRPGroupBoxCaptionIDSuffix);
        return this.groupBoxCaptionElement;
    },
    GetHeaderTextContainer: function() {
        if (this.headerTextContainer == null)
            this.headerTextContainer = document.getElementById(this.name + __aspxRPHeaderTextContainerIDSuffix);
        return this.headerTextContainer;
    },
    GetHeaderText: function() {
        return !this.headerTextEmpty ? this.GetHeaderTextInternal() : "";
    },
    SetHeaderText: function(text) {
        var textContainer = this.GetHeaderTextContainer();
        if (_aspxIsExistsElement(textContainer)) {
            if (_aspxIsExists(text) && _aspxTrim(text) == "") {
                this.headerTextEmpty = true;
                textContainer.innerHTML = "&nbsp;";
            } else {
                this.headerTextEmpty = false;
                textContainer.innerHTML = _aspxIsExists(text) ? text : "";
            }
        }
    },
    GetHeaderTextInternal: function() {
        var textContainer = this.GetHeaderTextContainer();
        return _aspxIsExistsElement(textContainer) ? textContainer.innerHTML : null;
    },
    
    GetContentHtml: function(){
        var contentElement = this.GetContentElement();
        if (_aspxIsExistsElement(contentElement)) {
            if (this.isGroupBox)
                var caption = this.RemoveGroupBoxCaptionElement();
            var contentHTML = contentElement.innerHTML;
            if (this.isGroupBox)
                this.RestoreGroupBoxCaptionElement(caption);
            return contentHTML;
        }
        return null;
    },
    SetContentHtml: function(html){
        var contentElement = this.GetContentElement();
        if (_aspxIsExistsElement(contentElement)) {
            if (this.isGroupBox)
                var caption = this.RemoveGroupBoxCaptionElement();
            contentElement.innerHTML = html;
            if (this.isGroupBox)
                this.RestoreGroupBoxCaptionElement(caption);
        }
    },
    
    RemoveGroupBoxCaptionElement: function() {
        var captionElement = this.GetGroupBoxCaptionElement();
        return (_aspxIsExists(captionElement)) ?
            captionElement.parentNode.removeChild(captionElement) : null;
    },
    RestoreGroupBoxCaptionElement: function(captionElement) {
        var contentElement = this.GetContentElement();
        if (_aspxIsExists(contentElement)) {
            if (contentElement.hasChildNodes())
                contentElement.insertBefore(captionElement, contentElement.firstChild);
            else
                contentElement.appendChild(captionElement);
        }
    }
});