// JavaScript Document
var xmlHttp
function run_query(choice,optional_id_number,optional_select_value) 
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	str=choice+","+optional_id_number+","+optional_select_value;
	if(choice=="invoice_number_select"){
		action_type="invoice_number_select";
	}
	else{
		action_type=choice;
	}
	url="ajax/query.php"; 	
	url=url+"?q="+str
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
} 
function stateChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		//alert("action type= " + action_type); //development purposes only
		switch(action_type)
		{
			case 'list_tenant': document.getElementById("tenant_information_div").innerHTML=xmlHttp.responseText; break;
			case 'list_dwelling': document.getElementById("dwelling_display_area").innerHTML=xmlHttp.responseText; break;
			case 'invoice_number_select': document.getElementById("invoice_display").innerHTML=xmlHttp.responseText; break;
			default: document.getElementById("notice_detail_div").innerHTML=xmlHttp.responseText;
		}
	}
} 
function GetXmlHttpObject()
{ 
	var objXMLHttp=null
	if (window.XMLHttpRequest)
	{
		objXMLHttp=new XMLHttpRequest()
	}
	else if (window.ActiveXObject)
	{
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	return objXMLHttp
}
