
if (typeof onloadList == 'undefined')
    onloadList = [];


function writeDate() {
    var d = new Date;
    var MN = ['January','February','March','April','May','June',
              'July','August','September','October','November','December'];
    document.writeln(MN[d.getMonth()] + ' ' + d.getDate() + ', ' + d.getFullYear());
};

function email(name,dom,aslink) {
    var addr = name + '@' + dom;
    return aslink ? '<a href="mailto' + ':' + addr + '">' + addr + '</a>' :
        addr;
}

function MSCemail() {
    document.write(email('info','mercerwood.com',true));
}

function toggleHide(id) {
    var elm = document.getElementById(id);
    
    if (elm != null && elm.style != null) {
        elm.style.display = (elm.style.display == 'none') ? '' : 'none';
    }
    return false;
}

function openMenus(ida) {
    var elm,id,i;
    for (i=0; i<ida.length; i++) {
        id = ida[i];
        elm = document.getElementById(id);
        if (elm != null && elm.style != null)
            elm.style.display = 'block';
    }
    return false;
}
    
function a_border(anc) {
    anc.onmouseout = function() {
        a.className = a.className.replace(/hover/,'');
    }
}

function _disable_menu(elm) {
    var span;
    if (elm != null) {
        if ((span = document.createElement('span')) != null) {
            span.style.fontStyle = 'italic';
            while (elm.firstChild != null) span.appendChild(elm.firstChild);
            elm.parentNode.replaceChild(span,elm);
            span.id = elm.id;
            span.style.color="#666";
            return span;
        }
    }
}            
function disable_menuID(id) {
    _disable_menu(document.getElementById(id));
}
function showActiveMenuID(id) {
    var elm = document.getElementById(id);
    if (elm != null) {
        elm = _disable_menu(elm);
        elm.style.color="black";
        elm.style.textDecoration = 'underline';
    }
}
function disable_menu_HREF(href) {
    var a,alist = document.getElementsByTagName('a');
    for (var i=0; i<alist.length; i++) {
        a = alist[i];
        if (a.href.length > 0 && a.href.indexOf(href) >= 0) {
            _disable_menu(a);
        }
    }
}

function showLater(id) {
    var a = document.getElementById(id),
        later = function() {alert("Please bear with us as we prepare content for this page.");}
    if (a != null)
        a.onclick = later;
}

function addLoad(f) {
    onloadList[onloadList.length] = f;
}
    
window.onload = function() {
    var i,
        ancl = document.getElementsByTagName('a');
    function setMo(a) {
        a.onmouseover = function() {
            a.className += ' hover';
        }
        a.onmouseout = function() {
            a.className = a.className.replace(/hover/,'');
        }
    }
    for (i=0; i<ancl.length; i++)
        setMo(ancl[i]);              
    for (i=0; i<onloadList.length; i++)
        onloadList[i]();
}

// Until they're completed:
addLoad(function() {
    var i,
        disabled = ['Newsletter','waterpolo','stm_cal',
                    'pics_2','pics_5','pics_7'];
    
    for (i=0; i<disabled.length; i++)
        disable_menuID(disabled[i]);
    showLater('Newsletter');
    showLater('waterpolo');
    showLater('stm_cal');
});

