/* PxPlus service JavaScript utiliti library */

function PlusQryTable(sQry, sTblId, sInpId, sOpts, sHost)
{	var xhr=new XMLHttpRequest();
	xhr.onreadystatechange = function()
		{	if (this.readyState == 4)
			{	if (this.status == 200) document.getElementById(sTblId).innerHTML = this.responseText;
			}
		}

	var sReq = "";
	if (sHost) sReq = sHost;
	
	sReq += "/services/qry.pxp?qry="+sQry+"&type=table";
	
	if (sInpId) 
	{	var oInp = document.getElementById(sInpId);
		if (oInp) sReq += "&%25"+sInpId+"="+encodeURIComponent(oInp.value);
	}
	else
	{	sReq += "&_rnd=" + Math.round(Math.random() * 100000000);
	}
	
	if (sOpts) sReq+= "&"+ sOpts;
		
	xhr.open('GET', sReq);
	xhr.send(null);
	
	xhr = null;
}
	
