function getXmlHttp(func)
{
	x = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
	
	if(!x)
	{
		alert("Please upgrade your browser.");
		return;
	}
	
	x.onreadystatechange = func;
	
	return x;
}

function fetchResult(sFile, func)
{
	displayLoading();
	
	xmlHttp = getXmlHttp(func);
	xmlHttp.open("GET", sFile , true);
	xmlHttp.send(null);
}

function displayLoading()
{
	document.getElementById("idLoadingDevice").style.display = "block";
}

function removeLoading()
{
	document.getElementById("idLoadingDevice").style.display = "none";
}


//=======================================================================
// ACTUAL FUNCTIONS
//=======================================================================

function fetchMenuItems() 
{
	if(x.readyState == 4 || x.readyState == "complete")
	{
		var obj = document.getElementById("idMenuDispOrder");
		var sContents = x.responseText;
		
		if(sContents != "")
		{
			obj.options.length = 0;
			
			var aLines = sContents.split("\n");
			for(var i = 0; i < aLines.length; i++)
			{
				var aLine = aLines[i].split(";");
				var oOption = document.createElement("option");
				oOption.className = aLine[0];
				var oText = document.createTextNode(aLine[2]);
				
				oOption.value = aLine[1];
				oOption.appendChild(oText);
				obj.appendChild(oOption);
			}
		}
		removeLoading();
	}
}
