﻿
var htmlContent;
EachXMLDocument = function() {

var xmlDoc = LoadXML("Resources/XML/ProductMenu.xml?code="+new Date().getDate());
    if (xmlDoc == null) {
        return;
    } 
    if (xmlDoc.documentElement == null) {
        return;
    }
    var contentHTML = "";
    var parentNodeList = xmlDoc.documentElement.childNodes;
    for (var index = 0; index < parentNodeList.length; index++) {
        if (parentNodeList[index].nodeType == 1) {
             var link="#";
             if (parentNodeList[index].attributes.length >=2) {
                 link=parentNodeList[index].attributes[1].value;
             }
            if (parentNodeList[index].attributes.length != 0) {
                contentHTML += '<li ><a href="' + link + '" style="color:#000000;" class="MenuHead">' + parentNodeList[index].attributes[0].value + '</a>';
                contentHTML += "</li>";
                contentHTML += EchchItemByDocuemnt(parentNodeList[index], "");
            }
        }
    }
    document.write(contentHTML);

}
var parentNodeID;
EchchItemByDocuemnt = function(node, nodeContent) {
    var parentNodeList = node.childNodes;
    for (var index = 0; index < parentNodeList.length; index++) {
        if (parentNodeList[index].nodeType == 1) {
            var link = "#";
            if (parentNodeList[index].attributes.length >= 2) {
                link = parentNodeList[index].attributes[1].value;
            }
            if (parentNodeList[index].childNodes.length != 0) {
                nodeContent += '<li><a href="'+link+'"><img src="Resources/Images/dot.png" style="border:0;vertical-align:2px;"/>&nbsp;&nbsp;<span>' + parentNodeList[index].attributes[0].value + '</span></a>';
            }
            else {
                nodeContent += '<li><a  href="' + link + '"><img src="Resources/Images/dot.png" style="border:0;visibility:hidden;"/>&nbsp;&nbsp;' + parentNodeList[index].attributes[0].value + '</a>';

            }
            if (parentNodeList[index].childNodes.length != 0) {
                nodeContent += '<ul>';
                nodeContent = EchchItemByDocuemnt(parentNodeList[index], nodeContent);
                nodeContent += "</ul>";
            }
            nodeContent += "</li>";
        }

    }
    return nodeContent;

}

var currentObj;
DisplayUlContent = function(obj, tag) {

    if (obj.nextSibling != null && obj.nextSibling.nodeType == 1) {
        currentObj = obj.nextSibling;
        obj.nextSibling.style.display = "";
    }

} 
