function addHTMLSelectOptions(topNode, select, id, name)
{
	if(topNode == null) //(topNode == 'null' || null == topNode)
		return;
		
	if(topNode.childNodes.length > 0)
	{
		for(i = 0; i < topNode.childNodes.length; i += 1)
		{
			var node = topNode.childNodes[i];
			
			var anOption = document.createElement("OPTION");
			
			select.options.add(anOption);
			anOption.value = node.getElementsByTagName(id)[0].childNodes[0].nodeValue;
			anOption.innerText = node.getElementsByTagName(name)[0].childNodes[0].nodeValue;
		}
		select.focus();
	}
}

/**
 * 2009-07-28 
 * 評分功能 - 將取得的平均值置於欄位中
 * @param responseXML 
 * @return
 */
function parseScoreXML(responseXML)
{
	var topNode = responseXML.getElementsByTagName("Scoring")[0];
		
	if(topNode == null) //(topNode == 'null' || null == topNode)
	{
		// alert("評分失敗");
		return;
	}
	
	if(topNode.childNodes.length > 0)
	{	
		//IE
		if (navigator.appName.toLowerCase().indexOf('microsoft') != -1)
		{
			var node = topNode.childNodes[0];
			document.getElementById('avg').innerText = node.childNodes[0].nodeValue;
		}
		else
		{
			//FIREFOX
			var node = topNode.childNodes[0];	
			document.getElementById('avg').textContent = node.childNodes[0].nodeValue;
		}			
	}
	document.getElementById('score_2').checked = true;
}

function genericAJAXCall(req, url, callback)
{
	var args = new Array();
	
	if(arguments.length > 3)
	{
		for(i = 0; i < arguments.length; i += 1)
		{
			args[i + 1] = arguments[i + 3];
		}	
	}

	if(req)
	{
		req.onreadystatechange = function()
		{
			if(req.readyState == 4)
			{
				if(req.status == 200)
				{	
					args[0] = req.responseXML;
					callback.apply(this, args);
				}
			}
		};
	
		req.open("GET", url, true);
		req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		req.send(null);
		
		return true;
	}
	return false;
}

