/*
 ****************************************************************************
 *  newjs.js
 *
 *  Since this code is not taken out of the DoubleTech Inc. library, I
 *  hereby release it into the public domain.
 *  W3C DOM, cross-browser, unobtrusive.
 *
 *  Revence 27
 *  genius-at-praize-dot-com
 *  http://revence27.faithweb.com
 *
 ****************************************************************************
 */

// All the tables in my pages are direct results of Freeservers.com. So ...
function kickTables()
{
 var tbs = document.getElementsByTagName('table');
 for(var notI = 0; notI < tbs.length; ++notI)
 {
  tbs[notI].style.display = "none";
 }
}

//  Clean event-adding.

function addEvent(who, what, clo)
{
    if(! window.__clos) window.__clos = []; //  Array to hold references ...
    if(window.attachEvent) who.attachEvent('on' + what, clo);
    else if(window.addEventListener) who.addEventListener(what, clo, true);
    window.__clos.push({o:who, c:clo, w:what});     //  ... arrange references into array ...
}

//  Makes a pic buzz about. It must have absolute positioning.                    
function buzzPic(who, start, stop, speed)
{
    
    who = document.images[who];
    who.style.left = 0;
    var rt = true;
    var buzzer = function()
    {
        window.setTimeout(buzzer, speed/1000);
    }
    window.setTimeout(buzzer, speed/1000);
}

//  Send e-mail off the page, while eluding spammers' spiders.
function sendMeMail(name, host, ext, subj, body)
{
    var m = 'mailto:' + name;    //  Tryin' to beat spammers ...
    m += '@';
    m += host;
    m += '.';
    m += ext;
    if(subj || body)
    {
        m += '?';
        if(subj) m += 'subject=' + subj;
        m += (subj && body ? '&' : '');
        if(body) m += 'body=' + body;
    }
    document.location = m;
}

//  Put the current year into the elemnts whose ID is given.
function fixYear(where)
{
    document.getElementById(where).appendChild(document.createTextNode(new Date().getFullYear()));
}

addEvent(window, 'load', function()
{
    fixYear('year');
    buzzPic('headimg', 0, 100, 1000000);
});
addEvent(window, 'unload', function()               //  ... clean up after your script.
                           {
                                for(var notI = 0, obj; notI < window.__clos.length; ++notI)
                                {
                                    obj = window.__clos[notI];
                                    if(window.detachEvent) obj.o.detachEvent('on' + obj.what);
                                    //  else if(window.removeEventListener) obj.o.removeEventListener(obj.what, true);  //  Erring, here. And I don't have a ref, now. Will check later.
                                    obj.clo = obj.what = null;
                                }
                                window.__clos = null;
                           });
