function Blog(id, width, height, blogName) {
    this.element = createElement(id, 'div');
    blog[blogName] = this.element;
    this.element.style.position = 'absolute';
    this.element.setDimensions(width + 'px', height + 'px');
    this.element.setCoords('0px', '0px');
    this.element.category = 'All';
    this.element.maxResults = 3;
    this.element.maxPages = 0;
    this.element.needsPaging = true;
    this.element.categories = [];
    this.element.articles = [];
    this.element.navCells = [];
    this.element.aEvents = [];
    this.element.bElements = [];
    this.element.index = 0;
    this.element.allArticles = [];
    this.element.curLoad = 0;
    this.element.needsRefresh = true;
    this.element.rpcFrame = new RPC(id + 'RPC', System.sesid);
    this.element.blogName = blogName;

    this.element.navHolder = createElement(id + 'NavHolder', 'div');
    this.element.appendChild(this.element.navHolder);
    this.element.navHolder.style.position = 'absolute';
    this.element.navHolder.setCoords(Math.round(width * .75) + 'px', '0px');
    this.element.navHolder.setDimensions(Math.round(width * .25) + 'px', '100%');
    this.element.navHolder.style.borderLeft = '1px solid #AA800A';
    this.element.navHolder.style.overflow = 'hidden';
    this.element.navHolder.style.backgroundColor = '#AA800A';

    this.element.imageLabel = createElement(id + 'ImageLabel', 'div');
    this.element.navHolder.appendChild(this.element.imageLabel);
    this.element.imageLabel.innerHTML = 'Newest Image : ';
    this.element.imageLabel.style.position = 'absolute';
    this.element.imageLabel.setCoords('0px', this.element.navHolder.getBottom() + 'px');
    this.element.imageLabel.setDimensions('100%', null);
    this.element.imageLabel.style.borderTop = '1px solid #000000';

    this.element.recentImage = createElement(id + 'RecentImage', 'img');
    this.element.navHolder.appendChild(this.element.recentImage);
    this.element.recentImage.style.position = 'absolute';
    this.element.recentImage.setCoords('0px', this.element.imageLabel.getBottom() + 'px');
    this.element.recentImage.setDimensions(Math.round(width * .25) + 'px', Math.round((width * .25) * .75) + 'px');

    this.element.aLabel = createElement(id + 'ActivityLabel', 'div');
    this.element.navHolder.appendChild(this.element.aLabel);
    this.element.aLabel.innerHTML = 'Recent Activity : ';
    this.element.aLabel.style.borderTop = '1px solid #000000';
    this.element.aLabel.style.position = 'absolute';
    this.element.aLabel.setCoords('0px', this.element.recentImage.getBottom() + 'px');
    this.element.aLabel.setDimensions('100%', null);

    this.element.activity = createElement(id + 'ActivityFeed', 'div');
    this.element.navHolder.appendChild(this.element.activity);
    this.element.activity.style.position = 'absolute';
    this.element.activity.setCoords('0px', this.element.aLabel.getBottom() + 'px');
    this.element.activity.setDimensions('100%', null);
    this.element.activity.style.fontSize = 'x-small';

    this.element.body = new Table();
    this.element.body.id = id + 'BlogBody';
    this.element.appendChild(this.element.body);
    this.element.body.style.position = 'absolute';
    this.element.body.setCoords('0px', '0px');
    this.element.body.setDimensions(Math.round(width * .75) + 'px', null);

    this.element.nav = new Table();
    this.element.navHolder.appendChild(this.element.nav);
    this.element.nav.id = id + 'BlogNav';
    this.element.nav.cellPadding = 5;
    this.element.nav.cellSpacing = 0;
    this.element.nav.style.borderStyle = 'solid';
    this.element.nav.style.borderColor = '#000000';
    this.element.nav.style.position = 'absolute';
    this.element.nav.setCoords('0px', '0px');
    this.element.nav.setDimensions('99%', null);
    this.element.nav.insertRow(0);
    this.element.nav.rows[0].insertCell(0);
    this.element.nav.rows[0].insertCell(0);
    this.element.nav.rows[0].cells[0].innerHTML = 'Categories';
    this.element.nav.rows[0].cells[0].align = 'center';
    this.element.nav.rows[0].cells[0].style.backgroundColor = '#AA800A';
    this.element.nav.rows[0].cells[0].style.borderRightWidth = 1;
    this.element.nav.rows[0].cells[1].align = 'center';
    this.element.nav.rows[0].cells[1].innerHTML = 'All';
    this.element.nav.rows[0].cells[1].name = 'All';
    this.element.nav.rows[0].cells[1].style.backgroundColor = '#AA800A';
    this.element.nav.rows[0].cells[1].style.borderLeftWidth = 1;
    this.element.nav.rows[0].cells[1].style.cursor = 'default';
    this.element.nav.rows[0].cells[1].superParent = this.element;
    this.element.nav.rows[0].cells[1].onmousedown = function() {
        this.superParent.nav_mousedown(this);
    };
    this.element.nav.rows[0].cells[1].onmouseover = function() {
        this.superParent.nav_mouseover(this);
    };
    this.element.nav.rows[0].cells[1].onmouseout = function() {
        this.superParent.nav_mouseout(this);
    };
    this.element.navCells['All'] = this.element.nav.rows[0].cells[1];

    this.element.nav_mouseover = function(e) {
        if (e.name !== this.category) {
            e.style.backgroundColor = '#FFFFFF';
        }
    };

    this.element.nav_mouseout = function(e) {
        if (e.name !== this.category) {
            e.style.backgroundColor = '#E0E0E0';
        }
    };

    this.element.nav_mousedown = function(e) {
        this.navCells[this.category].style.backgroundColor = '#E0E0E0';
        this.navCells[this.category].style.cursor = 'pointer';
        this.setCategory(e.name);
        e.style.backgroundColor = '#AA800A';
        e.style.cursor = 'default';
    };

    this.element.setPaging = function() {
        
        this.maxPages = Math.ceil(this.articles[this.category].length / this.maxResults);
        if (this.maxPages > 1) {
            for (i = 0; i < this.maxPages; i++) {
                //
            }
        } else {
        }
        this.needsPaging = false;
    };

    this.element.setInfo = function(articles, categories, img, aEvents) {
        this.recentImage.src = img;
        this.categories = [];
        this.articles = [];
        this.articles['All'] = [];
        this.navCells = [];
        this.navCells['All'] = this.nav.rows[0].cells[1];
        this.aEvents = aEvents;
        this.allArticles = articles;
        this.nav.rows[0].cells[1].innerHTML = 'All (' + articles.length + ')';
        for (i = 0; i < articles.length; i++) {
            cat = articles[i]['category']
            if (this.articles[cat] === undefined) {
                this.articles[cat] = [];
            }
            this.articles[cat][this.articles[cat].length] = articles[i];
            this.articles['All'][this.articles['All'].length] = articles[i];
        }
        for (i = 0; i < categories.length; i++) {
            this.categories[this.categories.length] = categories[i]['category'];
        }
        numRows = Math.ceil(this.categories.length / 2);
        for (i = 1; i <= numRows; i++) {
            this.nav.insertRow(i);
            this.nav.rows[i].insertCell(0);
            this.nav.rows[i].insertCell(0);
        }
        for (i = 0, curRow = 1, curCol = 0; i < this.categories.length; i++, curCol++) {
            if (curCol > 1) {
                curCol = 0;
                curRow++;
            }
            cell = this.nav.rows[curRow].cells[curCol];
            this.navCells[this.categories[i]] = cell;
            cell.align = 'center';
            cell.style.borderTopWidth = 1;
            if (curCol == 0) {
                cell.style.borderRightWidth = 1;
            } else {
                cell.style.borderLeftWidth = 1;
            }
            cell.name = this.categories[i];
            cell.superParent = this;
            cell.style.backgroundColor = this.categories[i] == this.category ? '#FFFFFF' : '#E0E0E0';
            cell.style.cursor = this.categories[i] == this.category ? 'default' : 'pointer';
            cell.onmousedown = function() {
                this.superParent.nav_mousedown(this);
            };
            cell.onmouseover = function() {
                this.superParent.nav_mouseover(this);
            };
            cell.onmouseout = function() {
                this.superParent.nav_mouseout(this);
            };
            cell.innerHTML = this.categories[i] + ' (' + this.articles[this.categories[i]].length + ')';
        }
        for (i = 0; i < aEvents.length; i++) {
            this.activity.innerHTML += "<hr width='75%' align='center' /><b>" + aEvents[i]['time'] + ":</b> " + aEvents[i]['event'];
        }
        this.maxPages = Math.ceil(this.articles[this.category].length / this.maxResults)
        this.needsRefresh = false;
    };

    this.element.setCategory = function(category) {
        this.navCells[this.category].style.backgroundColor = '#E0E0E0';
        this.navCells[this.category].style.cursor = 'pointer';
        this.index = 0;
        this.needsPaging = true;
        this.category = category;
        this.navCells[this.category].style.backgroundColor = '#FFFFFF';
        this.navCells[this.category].style.cursor = 'default';
        this.loadBlog();
    };

    this.element.setIndex = function(index) {
        this.index = index;
        this.loadBlog();
    };

    this.element.refresh = function(callBack) {
        callBack = !callBack ? false : callBack;
        this.rpcFrame.doTask('loadBlog', 'blog=' + this.blogName + '&callBack=' + callBack);
    };

    this.element.loadBlog = function() {
        if (this.needsRefresh) {
            this.refresh(true);
            return false;
        }
        if (this.needsPaging === true) {
            this.setPaging();
        }
        while (this.body.rows.length > 0) {
            this.body.deleteRow(0);
        }
        this.imageLabel.setCoords(null, this.nav.getBottom() + 'px');
        this.recentImage.setCoords(null, (this.nav.getBottom() + this.imageLabel.offsetHeight) + 'px');
        this.aLabel.setCoords(null, (this.nav.getBottom() + this.imageLabel.offsetHeight + this.recentImage.offsetHeight) + 'px');
        this.activity.setCoords(null, (this.nav.getBottom() + this.imageLabel.offsetHeight + this.recentImage.offsetHeight + this.aLabel.offsetHeight) + 'px');
        index = this.loadIndex();
        for (i = index; this.curLoad < this.maxResults && this.loadIndex() < this.articles[this.category].length; i++, this.curLoad++) {
            this.body.insertRow(this.curLoad);
            this.body.rows[this.curLoad].insertCell(0);
            el = element_from_clone(this.id + 'EntryContainer' + this.curLoad, 'HOME_BLOG_CONTAINER');
            this.replaceItemCards(el);
            this.body.rows[this.curLoad].cells[0].appendChild(el);
            el.style.width = '100%';
        }
        this.curLoad = 0;
        var hh = (this.activity.getBottom() < this.body.getBottom() ? this.body.getBottom() : this.activity.getBottom());
        hh = hh < minHeight ? minHeight : hh;
        this.navHolder.setDimensions(null, hh + 'px');
        this.style.height = this.navHolder.getBottom() + 'px';
        if (this.onload !== null) {
            this.onload();
        }
        return true;
    };

    this.element.loadIndex = function() {
        return (this.index * this.maxResults) + this.curLoad;
    };

    this.element.replaceItemCards = function(container) {
        string = '' + container.innerHTML;
        curItem = this.articles[this.category][this.loadIndex()];
        for (key in curItem) {
            if (!is_function(curItem[key])) {
                string = string.replace(('*' + key + '*'), curItem[key]);
            }
        }
        container.innerHTML = string;
    };

    this.element.getArticle = function(info) {
        if (this.category == 'All') {
            return this.allArticles[this.index][info];
        } else {
            return this.articles[this.category][this.index][info];
        }
    };

    this.element.load = function() {
        this.loadBlog();
    };

    this.element.unload = function() {
        this.navCells[this.category].style.backgroundColor = '#E0E0E0';
        this.navCells[this.category].style.cursor = 'pointer';
        this.index = 0;
        this.category = 'All';
        this.navCells[this.category].style.backgroundColor = '#FFFFFF';
        this.navCells[this.category].style.cursor = 'default';
        this.maxPages = Math.ceil(this.articles[this.category].length / this.maxResults);
    };

    this.element.refresh();

    return this.element;
}