/**
 * Filename: boss.js
 * Created by: Taproot Foundation
 * Author: Rohit Nafday <rohit@rohitsrealm.com>
 * Date: 2007-07-14
 * Notes: Main JS for self-sufficiency.org
 */

add_event(window, 'load', init);  // initialize on window load

function add_event(obj, type, fn) {
    if(obj.addEventListener) {
        obj.addEventListener(type, fn, false);
        return true;
    } else if(obj.attachEvent) {
        return obj.attachEvent("on" + type, fn);
    } else {
        return false;
    }
}

function init() {
    build_menu();  // properly color menu
    return true;
}

function build_menu() {
    var url = document.location.toString();

    if(url.match("what")) {
        $('nm-what-we-do').firstDescendant().addClassName('selected');
    } else if(url.match("help")) {
        $('nm-how-to-help').firstDescendant().addClassName('selected');
    } else if(url.match("current")) {
        $('nm-whats-happening-now').firstDescendant().addClassName('selected');
    } else if(url.match("about")) {
        $('nm-about-us').firstDescendant().addClassName('selected');
    } else {
        $('nm-home').firstDescendant().addClassName('selected');
    }

    return true;
}
