LeftNav = {
	
	loadXML: function(xml, div, active) {

		if (window.XMLHttpRequest) {
			var xhttp = new XMLHttpRequest();
		} else {
			var xhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		xhttp.open("GET", xml, false);
		xhttp.send("");

		if(window.DOMParser)
			var xmlDoc = (new DOMParser()).parseFromString(xhttp.responseText, "text/xml");
		else {
			var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
			xmlDoc.async = 'false';
			xmlDoc.loadXML(xhttp.responseText);
		}
		if(!xmlDoc) return;

		var navDiv = document.getElementById(div);
		
		var sections = xmlDoc.getElementsByTagName('section');

		for(var i = 0; i < sections.length; i++) 
		{
			var h2 = document.createElement('H2');
			h2.innerHTML = sections[i].getAttribute('name');
			navDiv.appendChild(h2);
			
			var sectionDiv = document.createElement('DIV');
			sectionDiv.className = 'section';
			navDiv.appendChild(sectionDiv);
			
			var subcategories = sections[i].getElementsByTagName('subcategory');
			for(var j = 0; j < subcategories.length; j++)
			{
				var subcatLink = document.createElement('A');
				subcatLink.innerHTML = subcategories[j].getAttribute('name');
				subcatLink.href = subcategories[j].getAttribute('href') ? subcategories[j].getAttribute('href') : '';
				if(subcategories[j].getAttribute('href') && window.location.href.indexOf(subcategories[j].getAttribute('href')) != -1) {
					subcatLink.className = 'active';
				}

				sectionDiv.appendChild(subcatLink);

				var subItems = subcategories[j].getElementsByTagName('product');
				if(subItems && subItems.length) {
					var subcatDiv = document.createElement('DIV');
					subcatDiv.className = 'sub';
					sectionDiv.appendChild(subcatDiv);
					for(var k = 0; k < subItems.length; k++) 
					{
						var productLink = document.createElement('A');
						productLink.innerHTML = subItems[k].getElementsByTagName('name')[0].firstChild.nodeValue;
						productLink.href = subItems[k].getElementsByTagName('url')[0].firstChild.nodeValue;
						if(subItems[k].getElementsByTagName('id')[0].firstChild.nodeValue == active)
						{
							subcatLink.className = 'active';
							subcatDiv.className = 'active';
							productLink.className = 'active current';
						}
						subcatDiv.appendChild(productLink);
					}
				}
				
			}
		}
	}

};
