//
// Ajax functions for WASC
//
// Jae H. Park
//
// Rev. August, 20 2008
//

function GetXmlhttpObject()
{
    var xmlHttp=null;
    
    try
    {
        // Firefox, Opera 8.0+, Safari
        xmlHttp = new XMLHttpRequest();
    }catch(e)
    {
        // Internet Explorer
        try
        {
            xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
        }catch(e)
        {
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
    
    }
    
    return xmlHttp;
}


function menu_init_ajax()
{
	
	this.func = function()
	{
		menu_init(0,12,1,-20,10);
	}
}

function menu_ajax(id, url, nextfunc)
{

	this.func = function()
	{
	 	 
		 var xmlHttp_menu = GetXmlhttpObject();
		 
		 if(xmlHttp_menu==null)
		 {
	        document.getElementById(id).innerHTML = "<p><b>Your browser does not support AJAX</b></p>";
	        return;
	     }
	             
	         
	     xmlHttp_menu.onreadystatechange = function()
		 {
		    if(xmlHttp_menu.readyState==4)
		    {	       	      			    
		      	document.getElementById(id).innerHTML =  xmlHttp_menu.responseText;		      	
		      	nextfunc.func();
		      							      		      
		    }else{
		      	//alert('error.');
		    }
		 };
	
	     xmlHttp_menu.open("GET", url,true);
		 xmlHttp_menu.send(null);    
	};
	
}
