function loadXMLDoc(fname)
{
	var xmlDoc;
	// code for IE
	if (window.ActiveXObject)
	{
	  xmlDoc=new ActiveXObject("Microsoft.XMLDOM");	  
	}
	// code for Mozilla, Firefox, Opera, etc.
	else if (document.implementation 
	&& document.implementation.createDocument)
	{
	  xmlDoc=document.implementation.createDocument("","",null);
	  
	}
	else
	{
	  alert('Your browser cannot handle this script');
	}
	xmlDoc.async=false;
	xmlDoc.load(fname);
	return(xmlDoc);
}					
  function init(rootpath)
  {	
	xml=loadXMLDoc(rootpath + 'sitestructure.xml');
	xsl=loadXMLDoc(rootpath +'xsltmenu.xml');
	// code for IE
	if (window.ActiveXObject)
	 {
  	  xsl.selectSingleNode("//xsl:variable[@name='RootPath']").text=rootpath;		    
	  ex=xml.transformNode(xsl);
	  document.getElementById("menu").innerHTML=ex;

	 }
	// code for Mozilla, Firefox, Opera, etc.
	else if (document.implementation 
	&& document.implementation.createDocument)
	{
	  var nsResolver = document.createNSResolver( xsl.ownerDocument == null ? xsl.documentElement : xsl.ownerDocument.documentElement );
	  var rootPath = xsl.evaluate("//xsl:variable[@name='RootPath']", xsl, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null );
  		rootPath.singleNodeValue.textContent = rootpath;

	  xsltProcessor=new XSLTProcessor();
	  xsltProcessor.importStylesheet(xsl);
	  resultDocument = xsltProcessor.transformToFragment(xml,document);
	  document.getElementById("menu").appendChild(resultDocument);
	}

	//for expand menu to current choise
	if (document.getElementById("tomenuitem")!=null && document.getElementById("tomenuitem").innerHTML!="" )
	{
		//Reg exp to delete last number in menuitem text (if are several pages from one menu item)
	  var textInDiv = document.getElementById("tomenuitem").innerHTML.replace(/\d$/g, "");	
	  expandTo(document.getElementById(textInDiv));
	  // expandTo(document.getElementById("tomenuitem").innerHTML);
	}
				
     return true;				
			
   }
