function loadXMLDoc(dname) {
	if (window.XMLHttpRequest) {
  		xhttp=new XMLHttpRequest();
  	} else {
  		xhttp=new ActiveXObject("Microsoft.XMLHTTP");
  	}
	xhttp.open("GET",dname,false);
	xhttp.send("");
	return xhttp.responseXML;
}

function buildmenu(xmlfile, xslfile, divid) {
	xml=loadXMLDoc(xmlfile);
	xsl=loadXMLDoc(xslfile);
	// code for IE
	if (window.ActiveXObject) {
	    ex = xml.transformNode(xsl);
  		document.getElementById(divid).innerHTML=ex;
  	}
	// code for Mozilla, Firefox, Opera, etc.
	else if (document.implementation && document.implementation.createDocument) {
  		xsltProcessor=new XSLTProcessor();
  		xsltProcessor.importStylesheet(xsl);
  		resultDocument = xsltProcessor.transformToFragment(xml,document);
  		document.getElementById(divid).appendChild(resultDocument);
	}
	$("#" + divid + " ul").each(function(index) {
		$(this).find('li:first').addClass('first');	
		$(this).find('li:last').addClass('last');	
	});	
}
