var eqCounter = 0;

function EqualColumns() {
    this.eqa = 0;
    this.eqth = 0;
    this.eqtw = 0;

    var c, e, el;
    if (document.getElementById) {
        this.blocks = new Array();
        for (i = 0; i < arguments.length; i += 2) {
            el = null;
            c = document.getElementById(arguments[i]);
            if (c) {
                e = c.getElementsByTagName(arguments[i + 1]);
                if (e) {
                    el = e[e.length - 1];
                    if (!el.id) {
                        el.id = "myeq" + (eqCounter++);
                    }
                }
            }
            if (c && el) {
                this.blocks.push(c);
                this.blocks.push(el);
            }
        }
        this.startCalculate();
    }
}

EqualColumns.prototype.startCalculate = function () {
    if (this.eqth != document.body.offsetHeight || this.eqtw != document.body.offsetWidth) {
        this._startCalculate();
    }
}

EqualColumns.prototype._startCalculate = function () {
    var i, oh, h = 0, tg, el, np, dA = this.blocks, an = this.eqa;
    if (dA && dA.length) {
        for (i = 0; i < dA.length; i += 2) {
            dA[i + 1].style.paddingBottom = '';
        }
        for (i = 0; i < dA.length; i += 2) {
            oh = dA[i].offsetHeight;
            h = (oh > h) ? oh : h;
        }
        for (i = 0; i < dA.length; i += 2) {
            oh = dA[i].offsetHeight;
            if (oh < h) {
                np = h - oh;
                dA[i + 1].style.paddingBottom = np + "px";
            }
        }
        this.eqa = 1;
        this.eqth = document.body.offsetHeight;
        this.eqtw = document.body.offsetWidth;
    }
}
/////////////////////////////////////////////////////////////////
var selectedTab = -1;
function bloggingDHTMLInit() {
    try {
        new EqualColumns('dhtml-tab1', 'div', 'dhtml-tab2', 'div');
    } catch (e) { }
    try {
        document.getElementById("dhtml-message").style.display = "none";
        document.getElementById("dhtml-block").style.visibility = "visible";
        document.getElementById("dhtml-block").style.height = "auto";
        document.getElementById("dhtml-tab1").style.display = "none";
        document.getElementById("dhtml-tab2").style.display = "none";
        document.getElementById("dhtml-tab" + active_tab).style.display = "block";
    } catch (e) { }
    try {
        // {{{ init tabs
        var tabs = document.getElementById("dhtml-menu").getElementsByTagName("A");
        var selectedTab = active_tab;
        for (var i = 0, len = tabs.length; i < len; i++) {
            tabs[i].onclick = function () {
                var clickedTab = Number(this.parentNode.getAttribute("rel").replace(/tab/, ""));
                if (clickedTab !== selectedTab) {
                    tabs[selectedTab - 1].parentNode.className = ""; // remove selected state
                    tabs[clickedTab - 1].parentNode.className = "active"; // set selected state
                    document.getElementById("dhtml-tab" + selectedTab).style.display = "none";
                    document.getElementById("dhtml-tab" + clickedTab).style.display = "block";
                    selectedTab = clickedTab;
                }
                return false;
            }
        }
    } catch (e) { }
}
addEvent(window, "load", bloggingDHTMLInit)

