(function() {

        var Channels = window.Channels = function() {
                return new Channels.prototype.init();
        }

        var _aChannels = [];
        var _oChannelsRoot = {}, _oChannelsWrap = {};

        _aChannels = [
                {'name':'Appliance Repair & Shopping', 'path':'http://appliances.bobvila.com/'},
                {'name':'Bathrooms','path':'http://bathrooms.bobvila.com/'},
                {'name':'Bedrooms','path':'http://bedrooms.bobvila.com/'},
                {'name':'Deck, Porch & Patio','path':'http://deckandpatio.bobvila.com/'},
                {'name':'Doors & Windows','path':'http://doorsandwindows.bobvila.com/'},
                {'name':'Electrical & Home Wiring','path':'http://electrical.bobvila.com/'},
                {'name':'Finance','path':'http://finance.bobvila.com/'},
                {'name':'Fireplaces','path':'http://fireplaces.bobvila.com/'},
                {'name':'Home Plans','path':'http://homeplans.bobvila.com/'},
                {'name':'HVAC','path':'http://hvac.bobvila.com/'},
                {'name':'Kitchen Design','path':'http://kitchens.bobvila.com/'},
                {'name':'Lawn & Garden','path':'http://gardens.bobvila.com/'},
                {'name':'Paint & Wallpaper','path':'http://paintandwallpaper.bobvila.com/'},
                {'name':'Roofing & Siding','path':'http://roofingandsiding.bobvila.com/'},
                {'name':'Storm-Ready','path':'http://www.bobvila.com/StormReady/'},
                {'name':'Workshop','path':'http://workshop.bobvila.com/'}
        ];

        function InitChannels() {
                var oEl = {};
                oEl = Get.byId('viewChannels');
                _oChannelsRoot = oEl.parentNode;

                Events.add(oEl, 'mouseover', SetChannels);
                Events.add(oEl, 'mouseout', SetChannels);
        };

        function SetChannels(e) {
                var bIsOver = e.type == 'mouseover' ? true : false;

                if(!!_oChannelsWrap.nodeType == false) {
                        _oChannelsWrap = document.createElement('div');
                        _oChannelsWrap.id = 'channelsList';
                        _oChannelsWrap.className = 'hideMe';

                        var i = 0, j = _aChannels.length, k = Math.ceil(j/2);

                        sOut = '<h2><a href="/Channels/">Channels from BobVila.com</a></h2><div class="clearFix"><ul>';
                        while(i < k) { sOut += '<li><a href="'+_aChannels[i].path+'">'+_aChannels[i].name+'</a></li>'; i++; }

                        sOut += '</ul><ul>';
                        while(i < j) { sOut += '<li><a href="'+_aChannels[i].path+'">'+_aChannels[i].name+'</a></li>'; i++; }
                        sOut += '</ul></div>';

                        _oChannelsWrap.innerHTML = sOut;
                        _oChannelsRoot.appendChild(_oChannelsWrap);

                        Events.add(_oChannelsWrap, 'mouseover', function() { _oChannelsWrap.className = 'showMe'; });
                        Events.add(_oChannelsWrap, 'mouseout', function() { _oChannelsWrap.className = 'hideMe'; });
                }

                _oChannelsWrap.className = bIsOver ? 'showMe' : 'hideMe';
        };

        Channels.prototype = {
                init : function() {
                        InitChannels();
                }
        }

})();

