var HQuote = function(msg, auth) {
    this.message = msg;
    this.author = auth;
}
var messages = new Array(
new HQuote("The world of humanity is possessed of two wings: the male and the female. So long as these two wings are not equivalent in strength, the bird will not fly.", "Abdu'l-Baha"),
new HQuote("Be generous in prosperity, and thankful in adversity.", "Bahá'u'llah"),
new HQuote("The gift of God to this enlightened age is the knowledge of the oneness of mankind and of the fundamental oneness of religion.", "Abdu'l-Baha"),
new HQuote("Know ye not why We created you all from the same dust? That no one should exalt himself over the other.", "Bahá'u'llah"),
new HQuote("My first counsel is this: Possess a pure, kindly and radiant heart, that thine may be a sovereignty ancient, imperishable and everlasting.", "Bahá'u'llah"),
new HQuote("Let your vision be world-embracing.", "Bahá'u'llah"),
new HQuote("Nothing can be effected in the world, not even conceivably, without unity and agreement, and the perfect means for engendering fellowship and union is true religion.", "Abdu'l-Baha"),
new HQuote("The well-being of mankind, its peace and security, are unattainable unless and until its unity is firmly established.", "Bahá'u'llah"),
new HQuote("In this sacred Dispensation, conflict and contention are in no wise permitted. Every aggressor deprives himself of God's grace.", "Abdu'l-Baha"),
new HQuote("The purpose of religion as revealed from the heaven of God's holy Will is to establish unity and concord amongst the peoples of the world; make it not the cause of dissension and strife.", "Bahá'u'llah"),
new HQuote("Let deeds, not words, be your adorning.", "Bahá'u'llah"),
new HQuote("Let each morn be better than its eve and each morrow richer than its yesterday.", "Bahá'u'llah"),
new HQuote("The best beloved of all things in My sight is Justice.", "Bahá'u'llah"),
new HQuote("Backbiting quencheth the light of the heart, and extinguisheth the life of the soul.", "Bahá'u'llah"),
new HQuote("There can be no doubt whatever that the peoples of the world, of whatever race or religion, derive their inspiration from one heavenly Source, and are the subjects of one God.", "Bahá'u'llah"),
new HQuote("Excellence does not depend upon colour. Character is the true criterion of humanity.", "Abdu'l-Baha"),
new HQuote("The betterment of the world can be accomplished through pure and goodly deeds, through commendable and seemly conduct.", "Bahá'u'llah"),
new HQuote("The poor in your midst are My trust; guard ye My trust, and be not intent only on your own ease.", "Bahá'u'llah"),
new HQuote("So powerful is the light of unity that it can illuminate the whole earth.", "Bahá'u'llah"),
new HQuote("Religion must stand the analysis of reason. It must agree with scientific fact and proof so that science will sanction religion and religion fortify science. Both are indissolubly welded and joined in reality.", "Abdu'l-Baha"),
new HQuote("Know that in every home where God is praised and prayed to, and His Kingdom proclaimed, that home is a garden of God and an paradise of His happiness.", "Abdu'l-Baha"),
new HQuote("A kindly tongue is the lodestone of the hearts of men. It is the bread of the spirit, it clotheth the words with meaning, it is the fountain of the light of wisdom and understanding….", "Abdu'l-Baha"),
new HQuote("In the garden of thy heart plant naught but the rose of love...", "Bahá'u'llah")
);

var mainInd = 0;
var curInd = 1;

function setQuote()
{
    if (!document.getElementById("QuoteMsg") || !document.getElementById("QuoteAuth")) {
        return;
    }
    if (curInd < 0)
    {
        curInd = mainInd;
    }
    if (curInd >= messages.length) {
        curInd = 0;
    }
    var msg = messages[curInd];
    document.getElementById("QuoteMsg").innerHTML = msg.message;
    document.getElementById("QuoteAuth").innerHTML = msg.author;
    var del = 15000;
    if (curInd == mainInd) {
        del = 30000;
    }
    curInd++;
    setTimeout("setQuote()", del);
}

function changecont(td) {
    gchangecont(td, '#610727');
}
function schangecont(td) {
    gchangecont(td, '#ADA07A');
}
function gchangecont(td, act) {
    var tds = document.getElementsByTagName("TD");
    var baseNm = td.id.replace(/[0-9]+$/g, "");
    for (var i = 0; i < tds.length; i++) {
        if (tds[i].className != 'item' || !tds[i].id.match("^" + baseNm)) {
            continue;
        }
        if (tds[i] != td) {
            tds[i].style.backgroundColor = '';
            var div = document.getElementById('cont' + tds[i].id);
            if (div) {
                div.style.display = 'none';
            }
        }
    }

    td.style.backgroundColor = act;
    var div = document.getElementById('cont' + td.id);
    if (div) {
        div.style.display = '';
    }
}

function changesection(td) {
    gchangesection(td, '#610727', '#ADA07A');
}

function schangesection(td) {
    gchangesection(td, '#ADA07A', '#610727');
}

function gchangesection(td, act, nact) {
    var tds = document.getElementsByTagName("td");
    for (var i = 0; i < tds.length; i++) {
        if (tds[i].className != 'sectionitem') {
            continue;
        }
        if (tds[i] != td) {
            tds[i].style.backgroundColor = nact;
            var div = document.getElementById('cont' + tds[i].id);
            if (div) {
                div.style.display = 'none';
            }
        }
    }
    td.style.backgroundColor = act;
    var div = document.getElementById('cont' + td.id);
    if (div) {
        div.style.display = '';
    }
}

function popup(href) {
    // Change "_blank" to something like "newWindow" to load all links in the same new window
    var newWindow = window.open(href, '_blank', 'toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,width=800,height=600');
    newWindow.focus();
    return false;
}

function show(elm, id, algn) {
    var dv = document.getElementById(id);
    if (dv.style.display == 'none') {
        if (!algn) {
            dv.style.left = (relPosX(elm) + 15) + 'px';
        } else {
            dv.style.left = (relPosX(elm) - 10 - 400) + 'px';
        }
        dv.style.top = (relPosY(elm) + 15) + 'px';
        dv.style.display = '';

    } else {
        dv.style.display = 'none';
    }
}

function relPosY(elm) {
    var pos = elm.offsetTop;
    while (elm.offsetParent != null) {
        elm = elm.offsetParent;
        pos += elm.offsetTop;
        if (elm.tagName == 'BODY') break;
    }
    return pos;
}
function relPosX(elm) {
    var pos = elm.offsetLeft;
    while (elm.offsetParent != null) {
        elm = elm.offsetParent;
        pos += elm.offsetLeft;
        if (elm.tagName == 'BODY') break;
    }
    return pos;
}

function showHide(id) {
    var dv = document.getElementById(id);
    if (dv.style.display == 'none') {
        dv.style.display = '';
    } else {
        dv.style.display = 'none';
    }
}
