if(typeof werth == 'undefined') { var werth = {}; }

werth.navigation = {

	'productsMenu': {
	
	    'getMenuItemsToDisplay': function() {
            var param = 'menuitems';
            var get = window.location.href.split("&");
            for(var i=0; i<get.length; i++) {
                if(get[i].substring(0, param.length) == param) {
                    return get[i].split("=")[1].split(",");
                }
            }
            return [];
        },
        
        'unfoldProductsMenu': function() {
            var rootId = 'menu1';
            var showLevel1Children = false;
            menuIds = this.getMenuItemsToDisplay();
            if(menuIds.length == 0) {
                menuIds = [GLOBAL_PAGE_ID];
                showLevel1Children = true;
                var cur = $('#' + rootId).find('li.cur a').get(0);
                if(typeof cur != 'undefined') {
                    menuIds.push($(cur).attr('id'));
                }
            }
            var anchors = $('#' + rootId).find('a');
            for(var i=0; i<anchors.length; i++) {
                for(var j=0; j<menuIds.length; j++) {
                    var elem = $(anchors[i]);
                    if(elem.attr('id') == menuIds[j]) {
                        elem.show();
                        var parentIsRoot = false;
                        var parentElem = $(elem.parent().get(0));
                        while(!parentIsRoot) {
                            if(parentElem.attr('id') == rootId) {
                                parentIsRoot = true;
                            }
                            parentElem.show();
                            jQuery.each(parentElem.siblings(), function() {
                                $(this).show();
                                if(this.tagName=="LI") {
                                    $(this).show().find('a').show();
                                }
                            });
                            parentElem = $(parentElem.parent().get(0));
                        }
                        if(showLevel1Children) {
                            $(elem.siblings().get(0)).show().find('> li , > li > a').show();
                        }
                    }
                }
            }
        }
	}
}
