/*
	NAME			: cascade.js
	DESCRIPTION		: ajax interface for cascading location selection in signup.tpl, edituser.tpl, advsearch.tpl
	OSDATE-VERSION	: osDate 2.1.x (LGPL)
	LICENSE			: GPL
	AUTHOR			: Darren Gates, Vijay Nair for original cascade.js, cascade_admin.js, cascade_search.js
	AUTHOR			: Ralf Strehle for this integrated and fixed version (ralf dot strehle at yahoo dot de) (osDate forum user name: exotic)
	COPYRIGHT		: 2009, by author
	SUPPORT			: by author
	
	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 2 of the License, or
	(at your option) any later version.
	
	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
	GNU General Public License for more details.
	
	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

function cascadeCountry(country)
{
	if (http && document.getElementById('state_province'))
	{
		document.getElementById('state_province').innerHTML='&nbsp;&nbsp;'+loadingTag;
		http.open('get', doc_root+'cascade.ajax.php?a=country&country='+country, true);
		http.onreadystatechange = handleResponse;
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.send(null);
	}
}

function cascadeState(country, state_province)
{
	if (http && document.getElementById('county'))
	{
		document.getElementById('county').innerHTML='&nbsp;&nbsp;'+loadingTag;
		http.open('get',doc_root+'cascade.ajax.php?a=state_province&country='+country+'&state_province='+state_province, true);
		http.onreadystatechange = handleResponse;
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.send(null);
	}
}

function cascadeCounty(country, state_province, county)
{
	if (http && document.getElementById('city'))
	{
		document.getElementById('city').innerHTML='&nbsp;&nbsp;'+loadingTag;
		http.open('get', doc_root+'cascade.ajax.php?a=county&country='+country+'&state_province='+state_province+'&county='+county, true);
		http.onreadystatechange = handleResponse;
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.send(null);
	}
}

function cascadeCity(country, state_province, county, city)
{
	if (http && document.getElementById('zip'))
	{
		document.getElementById('zip').innerHTML='&nbsp;&nbsp;'+loadingTag;
		http.open('get', doc_root+'cascade.ajax.php?a=city&country='+country+'&state_province='+state_province+'&county='+county+'&city='+city, true);
		http.onreadystatechange = handleResponse;
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.send(null);
	}
}

function cascadeCountryL(lookcountry)
{
	if (http && document.getElementById('lookstate_province'))
	{
		document.getElementById('lookstate_province').innerHTML='&nbsp;&nbsp;'+loadingTag;
		http.open('get', doc_root+'cascade.ajax.php?a=lookcountry&lookcountry='+lookcountry, true);
		http.onreadystatechange = handleResponse;
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.send(null);
	}
}

function cascadeStateL(lookcountry, lookstate_province)
{
	if (http && document.getElementById('lookcounty'))
	{
		document.getElementById('lookcounty').innerHTML='&nbsp;&nbsp;'+loadingTag;
		http.open('get', doc_root+'cascade.ajax.php?a=lookstate_province&lookcountry='+lookcountry+'&lookstate_province='+lookstate_province, true);
		http.onreadystatechange = handleResponse;
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.send(null);
	}
}

function cascadeCountyL(lookcountry, lookstate_province, lookcounty)
{
	if (http && document.getElementById('lookcity'))
	{
		document.getElementById('lookcity').innerHTML='&nbsp;&nbsp;'+loadingTag;
		http.open('get', doc_root+'cascade.ajax.php?a=lookcounty&lookcountry='+lookcountry+'&lookstate_province='+lookstate_province+'&lookcounty='+lookcounty, true);
		http.onreadystatechange = handleResponse;
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.send(null);
	}
}

function cascadeCityL(lookcountry, lookstate_province, lookcounty, lookcity)
{
	if (http && document.getElementById('lookzip'))
	{
		document.getElementById('lookzip').innerHTML='&nbsp;&nbsp;'+loadingTag;
		http.open('get', doc_root+'cascade.ajax.php?a=lookcity&lookcountry='+lookcountry+'&lookstate_province='+lookstate_province+'&lookcounty='+lookcounty+'&lookcity='+lookcity, true);
		http.onreadystatechange = handleResponse;
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.send(null);
	}
}

function cascadeZipL(lookcountry, lookzip, lookradius)
{
	if (http && document.getElementById('lookradius'))
	{
		http.open('get', doc_root+'cascade.ajax.php?a=lookzip&lookcountry='+lookcountry+'&lookzip='+lookzip+'&lookradius='+lookradius, true);
		http.onreadystatechange = handleResponse;
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.send(null);
	}
}

