function initHighlight() {
    if (!document.getElementsByTagName){ return; }
    var allfields = document.getElementsByTagName("input");

    // loop through all input tags and add events
    for (var i=0; i<allfields.length; i++){
        var field = allfields[i];
        if ((field.getAttribute("type") == "text") || (field.getAttribute("type") == "password") ) {
            field.onfocus = function () {this.className += ' highlightActiveField';}
            field.onmouseover = function () {this.className += ' highlightActiveField';}
            field.onblur = function () {this.className = this.className.replace(/ *highlightActiveField/g, '');}
            field.onmouseout = function () {this.className = this.className.replace(/ *highlightActiveField/g, '');}
        }
    }
}

function initHighlightButton() {
    if (!document.getElementsByTagName){ return; }
    var allfields = document.getElementsByTagName("button");

    // loop through all input tags and add events
    for (var i=0; i<allfields.length; i++){
        var field = allfields[i];
        field.onfocus = function () {this.className += ' highlightActiveFieldButton';}
        field.onmouseover = function () {this.className += ' highlightActiveFieldButton';}
        field.onblur = function () {this.className = this.className.replace(/ *highlightActiveFieldButton/g, '');}
        field.onmouseout = function () {this.className = this.className.replace(/ *highlightActiveFieldButton/g, '');}
    }
}

// Nifty function to add onload events without overwriting
// ones already there courtesy of the lovely and talented
// Simon Willison http://simon.incutio.com/
function addLoadEvent(func) {   
    var oldonload = window.onload;
    if (typeof window.onload != 'function'){
        window.onload = func;
    } else {
        window.onload = function(){
        oldonload();
        func();
        }
    }
}

addLoadEvent(initHighlight);
addLoadEvent(initHighlightButton);