function PostData(strURL, strResultFunc)
{
	var xmlHttpReq = CreateReqInstance();
	xmlHttpReq.open('POST', strURL, true);
	xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlHttpReq.onreadystatechange = function() 
	{
		if (xmlHttpReq.readyState == 4) 
		{
			eval(strResultFunc + '(xmlHttpReq.responseText);');
		}
	};
	xmlHttpReq.send(null);
}

function moreData(strURL, strResultFunc, strId)
{
	var xmlHttpReq = CreateReqInstance();
	xmlHttpReq.open('POST', strURL, true);
	xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlHttpReq.onreadystatechange = function() 
	{
		if (xmlHttpReq.readyState == 4) 
		{
			eval(strResultFunc + '(\'' + strId + '\',xmlHttpReq.responseText);');
		}
	};
	xmlHttpReq.send(null);
}

function welcome(strId,text)
{
d = document.getElementById(strId);
d.innerHTML=' '+text+' ';
};

function doReport(){
s = document.getElementById('start').value;
e = document.getElementById('end').value;
rid=document.getElementById('rid').value;
url = '/DMCMS/index.php?mod=reports&s='+s+'&e='+e+'&rid='+rid;
moreData(url,'welcome','results');
};

function saveReport(){
s = document.getElementById('start').value;
e = document.getElementById('end').value;
rid=document.getElementById('rid').value;
url = '/DMCMS/index.php?mod=reports&s='+s+'&e='+e+'&rid='+rid+'&d=1';
document.location=url;
};

function CreateReqInstance()
{
	var xmlHttpReq = false;

	// Mozilla/Safari
	if(window.XMLHttpRequest)
	{
		xmlHttpReq = new XMLHttpRequest();
		//xmlHttpReq.overrideMimeType('text/xml');
	}
	// IE
	else if(window.ActiveXObject)
	{
		xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}

	return xmlHttpReq;
};

function fileUpload(fname){
//str = '<iframe name="hiddenframe" src="about:blank" style="border:0;width:0;height:0;position:absolute;"></iframe>';
var bodyTag = document.getElementsByTagName('body')[0]; 
ifm = document.createElement('iframe'); 
ifm.name = fname+'-frame'; 
ifm.style = 'border:0;width:0;height:0;position:absolute;'; 
ifm.src = "about:blank"; 
bodyTag.appendChild(script);
};

function ParseXML(XMLString)
{
	// Check for IE not existing
	if(typeof DOMParser == "undefined")
	{
		DOMParser = function () {};

		DOMParser.prototype.parseFromString = function (str)
		{
			var d = new ActiveXObject("MSXML.DomDocument");
			d.loadXML(str);
			return d;
		};
	}

	// Mozilla-based, Safari, etc.
	var parser = new DOMParser();

	return parser.parseFromString(XMLString, "text/xml");
};
