﻿using System;
using Composite.Functions;
using Composite.Core.Xml;
using System.Collections.Generic;
using System.Xml.Linq;

public partial class C1Function : Composite.AspNet.UserControlFunction
{
    public override string FunctionDescription
    {
        get 
        { 
            return "A demo function that outputs executes the Distributed Menu function."; 
        }
    }

    public XhtmlDocument distributedMenu { get; set; }

    protected void Page_Load(object sender, EventArgs e)
    {
        distributedMenu = FunctionFacade.Execute<XhtmlDocument>(
            FunctionFacade.GetFunction("Composite.Navigation.Distributed"),
            new Dictionary<string, object>() {
                { "Level", 1 }, { "ShowParent", false }, 
				{ "ShowChildPages", true }, { "Expand", false }, 
				{"NavigationId",  "NavigationSideBar"} });

        // removing the class attribute from the level menu's elements
        foreach (var item in distributedMenu.Descendants())
        {
            item.SetAttributeValue("class", null);
        }
    }
}