    var xmlhttp;
    var CsvContent = '';

    Array.prototype.count = function() {
    return this.length;
    };

    function LoadIndex() {
        loadCSV('xml/index.txt');
    }
         
    function loadCSV(url) { 
        xmlhttp=null;
        // code for Mozilla, etc. 
        if (window.XMLHttpRequest) { 
            xmlhttp=new XMLHttpRequest(); 
            } 
            // code for IE 
            else if (window.ActiveXObject) 
            { 
                xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
            } 
    
           if (xmlhttp!=null) 
           { 
             xmlhttp.onreadystatechange=state_Change; 
             xmlhttp.open("GET",url,true); 
             xmlhttp.send(null); 
           }
        else 
        { 
            alert("Your browser does not support XMLHTTP."); 
        } 
    } 

    function state_Change() { 
        // if xmlhttp shows "loaded" 
        if (xmlhttp.readyState==4) { 
            if (xmlhttp.status==200) { 
              CsvContent = xmlhttp.responseText;
              BuildLayerListHtml();
            } 
        else 
            {alert("Sorry, there was a problem retrieving index file"); } 
        } 
    } 

    function BuildLayerListHtml() {

       var SHtml = '';
       var Lines;
       var DivOpen = 0;
       Lines = CsvContent.split("\r\n");

         for (var i = 0; i < Lines.length; i++) {
            var p = new Array();
            p = Lines[i].split("|");
             if (p[0].substring(0,1) != ''){
              // if includes | submenu else menu item
              if (p.count() == 1) {
               if (DivOpen == 1) {SHtml = SHtml + '</div>'; DivOpen = 0;}
               SHtml = SHtml + '<a class="mainmenu" onmouseover="javascript:document.documentElement.style.cursor = &quot;Hand&quot;" onmouseout="javascript:document.documentElement.style.cursor = &quot;default&quot;" onclick="showHide(&quot;' + p[0] + '&quot;)">' + p[0] + '</a><div id="' + p[0] + '" class="hide">';
                DivOpen = 1;
              } else {
               SHtml = SHtml + '<a href="#" class="submenu" onclick="javascript:document.getElementById(&quot;XmlFileName&quot;).value=&quot;xml/' + p[1] + '&quot;;SaveLayerList();LoadDataFile();return(false);">' + p[0] + '</a>';
              }
            }
         }
         if (DivOpen == 1) {SHtml = SHtml + '</div>'; DivOpen = 0;}

         LayerListHtml = SHtml;
         document.getElementById("SideBar_Content").innerHTML = SHtml;

    }
    
    function SaveLayerList() {
      LayerListHtml = document.getElementById("SideBar_Content").innerHTML;
    }


