init_menu = function(g) {
    var currNav = null, currSubnav = null;

    $('div#mainNav li.nav').each(function() {
        var nav = this;

        nav.subnav = $(nav).find('ul');

        $(nav).click(function() {
            // hide previous subnav, if any
            if(currNav && currNav != nav) {
                $(currNav.subnav).BlindUp(300);
            }

            // show subnav, if any
            if($(nav.subnav).css('display') != 'block') {
                $(nav.subnav).BlindDown(300);
            }

            $(nav.subnav).find('li a').click(function() {
                if(this != currSubnav) {
                    try {
                        var imgs = images[nav.title][this.title];

                        if(imgs.length > 0) {
                            g.init_gallery(imgs);
                        }

                        if(currSubnav) {
                            $(currSubnav).removeClass('active');
                        }
                        $(this).addClass('active');

                        // get rid of annoying dotted border on focus
                        // for hyperlinks
                        this.onfocus = function() {
                            this.hideFocus = true;
                        }

                        currSubnav = this;

                        return false;
                    }
                    catch(e) {
                        alert(e.message);
                        //alert('SYSTEM ERROR: The selected category (' + nav.title + ' | ' + this.title + ') contains to images!');
                    }
                }
            });

            currNav = nav;

            return false;
        });
    });
}