<%@page import="org.w3c.dom.*" %>
<%@page import="com.aurigma.web.imageuploader.DemoData"%>
<%@ page pageEncoding="UTF-8" %>
<div class="sidebar">
    <%
	DemoData demoData = (DemoData) pageContext.getAttribute("demodata");
	Node menu = demoData.getMenuXml().getDocumentElement();
    %>
    <%
	for (int i = 0; i < menu.getChildNodes().getLength(); i++) {
	    Node level1Node = menu.getChildNodes().item(i);
	    if (!"siteMapNode".equals(level1Node.getNodeName())) {
		continue;
	    }
    %>
    <h2><a href="#"><%= level1Node.getAttributes().getNamedItem("title").getTextContent()%></a></h2>
    <ul class="side-menu">
        <%
	    for (int j = 0; j < level1Node.getChildNodes().getLength(); j++) {
		Node level2Node = level1Node.getChildNodes().item(j);
		if (!"siteMapNode".equals(level2Node.getNodeName())) {
		    continue;
		}
		NamedNodeMap attributes = level2Node.getAttributes();
        %>
        <li class="<%= demoData.isSelectedDemo(level2Node) ? "selected" : ""%>">
            <a href="<%= demoData.getRootUrl() + "/" + attributes.getNamedItem("url").getTextContent()%>">
                <%= attributes.getNamedItem("title").getTextContent()%>
            </a>
            <div class="hint">
                <%= demoData.getShortDescription(attributes.getNamedItem("demo").getTextContent())%>
            </div>
        </li>
        <% }%>
    </ul>
    <%
	}
    %>
</div>