document.observe("dom:loaded", function() {
        
        var selectedCategory = "";
        
        // Observing help menu clicks  
        $('help-submenu-container').observe('click', function(event){   
                Event.stop(event);
                var menuItem = event.findElement('a');
                var menuHref = menuItem .readAttribute('href'); 
                if ($$('#sub-help-menu a.category-selected')) {
                        $$('#sub-help-menu a.category-selected').invoke('removeClassName', 'category-selected');
                }
                
                selectedCategory = menuHref.substring(16,menuHref.length);
                loadFragment(menuHref,'help-topics-container');
                menuItem.addClassName('category-selected');
                $('help-article-container').update(); //Erase answer pane
        });                   

        // Observing questions clicks  

        $('help-topics-container').observe('click', function(event){   
                Event.stop(event);
                var topicItem = event.findElement('a');
                if (topicItem != 'undefined') {
                        var topicHref = topicItem.readAttribute('href'); 
                        if (topicHref == '/content/feedback') {
                                document.location.href = topicHref; 
                        }
                        else {
                                if ($$('#help-topics-list a.selected-topic')) {
                                        $$('#help-topics-list a.selected-topic').invoke('removeClassName', 'selected-topic');
                                } 
                                loadFragment(topicHref,'help-article-container');
                                topicItem.addClassName('selected-topic');      
                        }
                }
        });                   


        // Observing links in article container


        $('help-article-container').observe('click', function(event){   
                Event.stop(event);
                var articleItem = event.findElement('a');
                if (articleItem != 'undefined') {
                        var articleHref = articleItem.readAttribute('href'); 
                        if (articleHref == '/content/feedback') {
                                document.location.href = articleHref; 
                        }
                        else {
                                var contentPos = articleHref.indexOf('/content/');
                                if (contentPos > -1) {
                                        var forwardSlash = articleHref.lastIndexOf('/');
                                        var dashPos = articleHref.indexOf('-');
                                        var categoryType = articleHref.substring(forwardSlash+1,dashPos);
                                        var category = 'shm-'+categoryType;
                                        var topicList ='/content/support'+categoryType;
                                        if (categoryType != selectedCategory) {
                                              //  $$('#sub-help-menu a.category-selected').invoke('removeClassName', 'category-selected');
                                              //  loadFragment(topicList,'help-topics-container');
                                                document.location.href = articleHref;   
                                                
                                        }
                                        if ($$('#help-topics-list a.selected-topic')) {
                                                $$('#help-topics-list a.selected-topic').invoke('removeClassName', 'selected-topic');
                                        }
                                        loadFragment(articleHref,'help-article-container');
                                        $$('#help-topics-list a').each(function (thisTopicItem) {
                                                var thisTopicHref = thisTopicItem.readAttribute('href');
                                                if (thisTopicHref == articleHref) {
                                                        thisTopicItem.addClassName('selected-topic');
                                                        throw $break;
                                                }
                                        });
                                        }
                                else {
                                        document.location.href = articleHref;   
                                }
                        }
                }
        });  

}); // dom:loaded
