function resetFields()
{
	document.forms[0].reset();
	//if (document.getElementById("commodity_spec")!=null) document.query.commodityOne.disabled=true;
}

function showDistrict(country)
{
	  var xmlHttp; try { xmlHttp=new XMLHttpRequest(); } catch (e) { try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Your browser does not support AJAX!"); return false; } } }  
		xmlHttp.onreadystatechange=function()
		{
  	  if(xmlHttp.readyState==4)
    	{
    		document.getElementById("district").innerHTML=xmlHttp.responseText;
    	}
  	}
		var responseUrl = "http://"+document.URL.split('/')[2]+"/lab/index.php/household/district/"+country+"/all";
  	xmlHttp.open("GET", responseUrl, true);
  	xmlHttp.send(null);
}

function expandCommodities(commodity)
{
	  var xmlHttp; try { xmlHttp=new XMLHttpRequest(); } catch (e) { try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Your browser does not support AJAX!"); return false; } } }  
		xmlHttp.onreadystatechange=function()
		{
  	  if(xmlHttp.readyState==4)
    	{
    		if (commodity=='all') document.getElementById("commodity_spec").innerHTML='';
    		else document.getElementById("commodity_spec").innerHTML=xmlHttp.responseText;
    	}
  	}
		var responseUrl = "http://"+document.URL.split('/')[2]+"/lab/index.php/household/expand_commodity/"+commodity+"/commoditySpecOne/resultCounter";
  	xmlHttp.open("GET", responseUrl, true);
  	xmlHttp.send(null);
  	resultCounter();
}

function resultCounter(cat)
{
	  var xmlHttp; try { xmlHttp=new XMLHttpRequest(); } catch (e) { try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Your browser does not support AJAX!"); return false; } } }  
		xmlHttp.onreadystatechange=function()
		{
  	  if(xmlHttp.readyState==4)
    	{
    		var html = "(no data available)";
    		var resultCounter = xmlHttp.responseText;
    		if (resultCounter>0) 
    		{
    			html = resultCounter+" records available";
    			document.query.submit.disabled=false;
    		}
    		else
    		{
    			document.query.submit.disabled=true;
    		}
    		document.getElementById("data_availability").innerHTML=html;
    	}
  	}
		var selCountryValue = document.query.country.options[document.query.country.selectedIndex].value;
		var selDistrictValue = document.query.district.options[document.query.district.selectedIndex].value;
		var selVariableValue = document.query.varOne.options[document.query.varOne.selectedIndex].value;
		var selUrbanruralValue = document.query.urbanrural.options[document.query.urbanrural.selectedIndex].value;
		var selTercileValue = document.query.tercile.options[document.query.tercile.selectedIndex].value;
		var selGenderValue = document.query.gender.options[document.query.gender.selectedIndex].value;
		var selCommodityValue = "All";
		var selCommoditySpecValue = "All";
		if (cat=="c") 
		{
				selCommodityValue = document.query.commodityOne.options[document.query.commodityOne.selectedIndex].value;
				selCommoditySpecValue = "Any";
				if (document.query.commodityOne.selectedIndex>0&&document.query.commoditySpecOne!=null)
				{
					selCommoditySpecValue = document.query.commoditySpecOne.options[document.query.commoditySpecOne.selectedIndex].value;
				}
				else
				{
					selCommodityValue = "All";
				}
		}
		
		var responseUrl = "http://"+document.URL.split('/')[2]+"/lab/index.php/household/result_counter/"+selCountryValue+"/"+selDistrictValue+"/"+selVariableValue+"/"+selUrbanruralValue+"/"+selTercileValue+"/"+selGenderValue+"/"+selCommodityValue+"/"+selCommoditySpecValue;
  	xmlHttp.open("GET", responseUrl, true);
  	xmlHttp.send(null);
  	/*
  	if (selVariableValue=='pppexp_food_foodlevel'||selVariableValue=='qty_food')
  	{
  			document.query.commodityOne.disabled=false;
  	}
  	else
  	{
  			document.query.commodityOne.disabled=true;
  			document.getElementById("commodity_spec").innerHTML="";
  			document.query.commodityOne.selectedIndex=0;
  	}
  	*/
}
function showInfo(x, y)
{
	  var xmlHttp; try { xmlHttp=new XMLHttpRequest(); } catch (e) { try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Your browser does not support AJAX!"); return false; } } }  
		xmlHttp.onreadystatechange=function()
		{
  	  if (xmlHttp.readyState<4)
  	  {
    		document.getElementById("info_t").innerHTML="(please wait...)";
  	  }
  	  else
    	{
    		document.getElementById("info_t").innerHTML=xmlHttp.responseText;
    	}
  	}
		var responseUrl = "http://"+document.URL.split('/')[2]+"/lab/index.php/household/info/"+x+"/"+y;
  	xmlHttp.open("GET", responseUrl, true);
  	xmlHttp.send(null);
}
function showCns(x, y)
{
	  var xmlHttp; try { xmlHttp=new XMLHttpRequest(); } catch (e) { try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Your browser does not support AJAX!"); return false; } } }  
		xmlHttp.onreadystatechange=function()
		{
  	  if (xmlHttp.readyState==4)
    	{
    		document.getElementById("info_c").innerHTML=xmlHttp.responseText;
    	}
  	}
		var responseUrl = "http://"+document.URL.split('/')[2]+"/lab/index.php/household/cns/"+x+"/"+y;
  	xmlHttp.open("GET", responseUrl, true);
  	xmlHttp.send(null);
}
function showCnt(x, y)
{
	  var xmlHttp; try { xmlHttp=new XMLHttpRequest(); } catch (e) { try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Your browser does not support AJAX!"); return false; } } }  
		xmlHttp.onreadystatechange=function()
		{
  	  if(xmlHttp.readyState==4)
    	{
    		document.getElementById("cnt").innerHTML=xmlHttp.responseText;
    	}
  	}
		var responseUrl = "http://"+document.URL.split('/')[2]+"/lab/index.php/map/cnt/"+x+"/"+y;
  	xmlHttp.open("GET", responseUrl, true);
  	xmlHttp.send(null);
}
function showAez(x, y)
{
	  var xmlHttp; try { xmlHttp=new XMLHttpRequest(); } catch (e) { try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Your browser does not support AJAX!"); return false; } } }  
		xmlHttp.onreadystatechange=function()
		{
  	  if(xmlHttp.readyState==4)
    	{
    		document.getElementById("aez").innerHTML=xmlHttp.responseText;
    	}
  	}
		var responseUrl = "http://"+document.URL.split('/')[2]+"/lab/index.php/map/aez/"+x+"/"+y;
  	xmlHttp.open("GET", responseUrl, true);
  	xmlHttp.send(null);
}
function showAdmin(x, y)
{
	  var xmlHttp; try { xmlHttp=new XMLHttpRequest(); } catch (e) { try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Your browser does not support AJAX!"); return false; } } }  
		xmlHttp.onreadystatechange=function()
		{
  	  if(xmlHttp.readyState==4)
    	{
    		document.getElementById("admin").innerHTML=xmlHttp.responseText+"<br>Household traits: (<a href='javascript:unhide(\"info_block_t\");window.scroll(0,380);'>show/hide data</a>)"+"<br>Per-capita Food Consumption: (<a href='javascript:unhide(\"info_block_c\");window.scroll(0,380);'>show/hide data</a>)";
    	}
  	}
		var responseUrl = "http://"+document.URL.split('/')[2]+"/lab/index.php/household/admin/"+x+"/"+y;
  	xmlHttp.open("GET", responseUrl, true);
  	xmlHttp.send(null);
}
function showAdmin_h(x, y)
{
	  var xmlHttp; try { xmlHttp=new XMLHttpRequest(); } catch (e) { try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Your browser does not support AJAX!"); return false; } } }  
		xmlHttp.onreadystatechange=function()
		{
  	  if(xmlHttp.readyState==4)
    	{
    		document.getElementById("admin").innerHTML=xmlHttp.responseText+"<br>Household traits: (<a href='javascript:unhide(\"info_block_t\");window.scroll(0,420);'>show/hide data</a>)";
    	}
  	}
		var responseUrl = "http://"+document.URL.split('/')[2]+"/lab/index.php/household/admin/"+x+"/"+y;
  	xmlHttp.open("GET", responseUrl, true);
  	xmlHttp.send(null);
}
function showAdmin_c(x, y)
{
	  var xmlHttp; try { xmlHttp=new XMLHttpRequest(); } catch (e) { try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Your browser does not support AJAX!"); return false; } } }  
		xmlHttp.onreadystatechange=function()
		{
  	  if(xmlHttp.readyState==4)
    	{
    		document.getElementById("admin").innerHTML=xmlHttp.responseText+"<br>Per-capita Food Consumption: (<a href='javascript:unhide(\"info_block_c\");window.scroll(0,420);'>show/hide data</a>)";
    	}
  	}
		var responseUrl = "http://"+document.URL.split('/')[2]+"/lab/index.php/household/admin/"+x+"/"+y;
  	xmlHttp.open("GET", responseUrl, true);
  	xmlHttp.send(null);
}
