﻿
var xmlDoc = null;

function initTraverse(file) {
        loadXML(file);
        var doc=xmlDoc.documentElement;
        traverse(doc);
}

function loadXML(xmlFile) {
        if (window.ActiveXObject) { 
		xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
	    }
	    else if (document.implementation.createDocument) { 
		    xmlDoc=document.implementation.createDocument("","",null);
	    }
	    else {
		    alert('script error');
	    }
        xmlDoc.async="false";
        xmlDoc.onreadystatechange=verify;
        xmlDoc.load(xmlFile);
}

function verify() { 
        if(xmlDoc.readyState!=4)
                return false; 
}

function traverse(tree) {
        
        var imagesPath = '/global/support/en/us/PublishingImages/';
        var sURL = new String;
        sURL = location.href;
       
        if(tree.hasChildNodes()) {
                
                var ni = document.getElementById('breadcrumbDiv');
                var newdiv = document.createElement('<div>');
                var middlediv = document.createElement('<div>');
                var theHTML = new String;
                
                for(var k=0; k<tree.childNodes.length; k++)
                {
                      if(sURL == tree.childNodes[k].attributes[1].value)
                      {
                          theHTML += "<div style=\"float: left;\"><img id=\"BtnSupport\" Src=\""+imagesPath+"trailLeft.png\" type=\"button\" onclick=\"javascript:window.location='"+ tree.attributes[0].value +"';\" /></div>";
                          theHTML += "<div style=\"float: left;\" class=\"trailMiddle\">";
                          theHTML +=  tree.childNodes[k].attributes[0].value ;
                          theHTML += "</div>";
                          theHTML += "<img Src=\""+imagesPath+"trailRight.png\"></img>";
                          middlediv.innerHTML = theHTML;
                          newdiv.innerHTML += middlediv.outerHTML;
                          ni.appendChild(newdiv);
                          return;
                                      
                      } 
                      else
                      {
                                                 
                            for(var i=0; i<tree.childNodes[k].childNodes.length; i++){
                                  if(sURL == tree.childNodes[k].childNodes[i].attributes[1].value)
                                  {
                                      theHTML += "<div style=\"float: left;\"><img id=\"BtnSupport\" Src=\""+imagesPath+"trailLeft.png\" type=\"button\" onclick=\"javascript:window.location='"+ tree.attributes[0].value +"';\" /></div>";
                                      theHTML += "<div style=\"float: left;\" class=\"trailMiddle\">";
                                      theHTML += "<a href=" + tree.childNodes[k].attributes[1].value + " class=trailItem >" + tree.childNodes[k].attributes[0].value+"</a>";
                                      theHTML += "<img  Src=\""+imagesPath+"trailArrow.jpg\" />";
                                      theHTML += tree.childNodes[k].childNodes[i].attributes[0].value;
                                      theHTML += "</div>";
                                      theHTML += "<img Src=\""+imagesPath+"trailRight.png\" />";
                                      middlediv.innerHTML = theHTML;
                                      newdiv.innerHTML += middlediv.outerHTML;
                                      ni.appendChild(newdiv);   
                                      return;
                                  
                                  }
                                  else
                                  {
                               
                                    for(var j=0; j<tree.childNodes[k].childNodes[i].childNodes.length; j++)  {
                                        if( sURL == tree.childNodes[k].childNodes[i].childNodes[j].attributes[0].value){
                                            theHTML += "<div style=\"float: left;\"><img id=\"BtnSupport\" Src=\""+imagesPath+"trailLeft.png\" type=\"button\" onclick=\"javascript:window.location='"+ tree.attributes[0].value +"';\" ></img></div>";
                                            theHTML += "<div style=\"float: left;\" class=\"trailMiddle\">";
                                            theHTML += "<a href=" + tree.childNodes[k].attributes[1].value + " class=\"trailItem\" >" + tree.childNodes[k].attributes[0].value+"</a>";
                                            theHTML += "<img Src=\""+imagesPath+"trailArrow.jpg\"></img>";
                                            theHTML += "<a href=" + tree.childNodes[k].childNodes[i].attributes[1].value + " class=\"trailItem\" >" + tree.childNodes[k].childNodes[i].attributes[0].value+"</a>";
                                            theHTML += "<img Src=\""+imagesPath+"trailArrow.jpg\"></img>";
                                            theHTML += tree.childNodes[k].childNodes[i].childNodes[j].text;
                                            theHTML += "</div>";
                                            theHTML += "<img Src=\""+imagesPath+"trailRight.png\"></img>";
                                            middlediv.innerHTML = theHTML;
                                            newdiv.innerHTML += middlediv.outerHTML;
                                            ni.appendChild(newdiv);   
                                            return;
                                        }
                                    
                                        
                                    }  
                              } 
                        
                        }
                  }
                  
             }
                    
                
        }
       
}







