
function createHttpRequest(){
    if(window.ActiveXObject){
        try{
            return new ActiveXObject("Msxml2.XMLHTTP");
        }catch(e){
            try{
                return new ActiveXObject("Microsoft.XMLHTTP");
            }catch(e2){
                return null;
            }
        }       
    }else if(window.XMLHttpRequest){
        /*
        try{ 
            netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserRead');
        } catch (e){ 
            alert('Permission UniversalBrowserRead denied.');
        } 
        */               
        return new XMLHttpRequest();    
    }else{
        return null;    
    }    
}

var stylesheet = null;
var xslProc = null;

function getNavMenu(inMenu1, inMenu2, inMenu3){ 

	var xmlhttp = false;
    xmlhttp = createHttpRequest();

    if(!xmlhttp) return "Your browser is not supported";        
    
	var xmlurl = "/Common/Xml/Menu.xml";
	var xslurl = "/Common/Xsl/NavMenu.xsl";
    
    // load XML
    xmlhttp.open("GET", xmlurl, false);
    xmlhttp.send(null);

    var xmlDoc = xmlhttp.responseXML;

	var menu = xmlDoc.selectSingleNode("//menu_id") ;
	menu.setAttribute("depth1", inMenu1) ;
	menu.setAttribute("depth2", inMenu2) ;
	menu.setAttribute("depth3", inMenu3) ;

    if(window.ActiveXObject)
	{       
        // load XSL
        xmlhttp.open("GET", xslurl, false);
        xmlhttp.send(null);
             
        stylesheet = xmlhttp.responseXML;
        var tmpHtml = xmlDoc.transformNode(stylesheet);

        document.all["NavMenu"].innerHTML=tmpHtml;

	}else{
        
        // load XSL
        if(xslProc==null)
		{
            xslProc = new XSLTProcessor();
            xmlhttp.open("GET",xslurl,false);
            xmlhttp.send(null);
            xslProc.importStylesheet(xmlhttp.responseXML);
        }            

        var oResultFragment = xslProc.transformToFragment(xmlDoc,document);
        var oDiv = document.getElementById("NavMenu");        
        
		if(oDiv.childNodes.length>0)oDiv.removeChild(oDiv.childNodes[0]);
        oDiv.appendChild(oResultFragment);     
        
        var tmpHtml = oDiv.innerHTML;        

        // Æ¯¼ö¹®ÀÚ Ã³¸®(firefox¶§¹®¿¡)
        tmpHtml = replace(tmpHtml,"&lt;","<");
        tmpHtml = replace(tmpHtml,"&gt;",">");
        oDiv.innerHTML = replace(tmpHtml,"&amp;","&");                
    }   

 }