var isIE = navigator.userAgent.toLowerCase().indexOf("msie") > -1;
var isMoz = document.implementation && document.implementation.createDocument;
var xmlhttp = newHttpRequest();

function newHttpRequest()
{
	var _xmlhttp;
	if (window.XMLHttpRequest)
	  {// code for all new browsers
	  _xmlhttp=new XMLHttpRequest();
	  }
	else if (window.ActiveXObject)
	  {// code for IE5 and IE6
	  _xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	 else
	  {
	  alert("Your browser does not support XMLHTTP.");
	  }
	  return _xmlhttp;
}
  
function ValueOf(id)
{
	var e = document.getElementById(id);
	switch (e.type) {
	case "checkbox":
	case "radio":
		return e.checked;
	default:
		return e.value;
	}
}

function element(id)
{
	return document.getElementById(id);
}

function loadXML(xmlFile)
{
	var _xmlhttp = newHttpRequest();
	_xmlhttp.open('GET', xmlFile, false);
	//xmlhttp.overrideMimeType('text/xml');
	_xmlhttp.send(null);
	var xml = _xmlhttp.responseXML;
	if (!xml) {
		alert("Unable to load "+xmlFile);
		return null;
	}
	return xml;
}

function transformXML(xmlDoc, xslDoc, element)
{
	if (isIE) {
		var e = document.getElementById(element);
		if (e) {
			var content = xmlDoc.transformNode(xslDoc);
			e.innerHTML = content;
		}
	} else {
		var XSLT = new XSLTProcessor;
		XSLT.importStylesheet(xslDoc);
		var e = document.getElementById(element);
		if (e) {
			e.innerHTML = "";
			e.appendChild(XSLT.transformToFragment(xmlDoc, document));
		}
	}
}

function getTransformedXML(xmlDoc, xslDoc)
{
	if (isIE) {
		return xmlDoc.transformNode(xslDoc);
	} else {
		var XSLT = new XSLTProcessor;
		XSLT.importStylesheet(xslDoc);
		return XSLT.transformToFragment(xmlDoc, document);
	}
}

function GetUrlArg(name)
{
	var idx=document.location.href.indexOf(name+'=');
	if (idx<=0) return null;
	var argstr=document.location.href.substring(idx+name.length+1);
	idx = argstr.indexOf('&');
	return idx>=0?argstr.substring(0, idx):argstr;
}