/*
	NAME        : cascade.js
	DESCRIPTION : ajax interface for cascading location selection in signup.tpl and edituser.tpl
	MOD-VERSION : 1.0.0.0
	LICENSE     : GPL
	BASED ON    : osDate 2.0.8.1 and 2.1.1 (LGPL)
	AUTHOR      : Darren Gates, Vijay Nair
	AUTHOR      : Ralf Strehle (ralf DOT strehle AT yahoo DOT de) (osDate forum user name: exotic)
	COPYRIGHT   : by author
	SUPPORT     : by author
*/

function cascadeCountry(tpl, country)
{
	if (document.getElementById('state_province') != null)
	{
		http.open('get', 'cascade.php?a=country&tpl=' + tpl + '&country=' + country);
		document.getElementById('state_province').innerHTML='&nbsp;&nbsp;'+loadingTag;
		http.onreadystatechange = handleResponse;
		http.send(null);
	}
}

function cascadeState(tpl, country, state_province)
{
	if (document.getElementById('county') != null)
	{
		http.open('get', 'cascade.php?a=state_province&tpl=' + tpl + '&country=' + country + '&state_province=' + state_province);
		document.getElementById('county').innerHTML='&nbsp;&nbsp;'+loadingTag;
		http.onreadystatechange = handleResponse;
		http.send(null);
	}
}

function cascadeCounty(tpl, country, state_province, county)
{
	if (document.getElementById('city') != null)
	{
		http.open('get', 'cascade.php?a=county&tpl=' + tpl + '&country=' + country + '&state_province=' + state_province + '&county=' + county);
		document.getElementById('city').innerHTML='&nbsp;&nbsp;'+loadingTag;
		http.onreadystatechange = handleResponse;
		http.send(null);
	}
}

function cascadeCity(tpl, country, state_province, county, city)
{
	if (document.getElementById('zip') != null)
	{
		http.open('get', 'cascade.php?a=city&tpl=' + tpl + '&country=' + country + '&state_province=' + state_province + '&county=' + county + '&city=' + city);
		document.getElementById('zip').innerHTML='&nbsp;&nbsp;'+loadingTag;
		http.onreadystatechange = handleResponse;
		http.send(null);
	}
}

function cascadeCountryL(tpl, lookcountry)
{
	if (document.getElementById('lookstate_province') != null)
	{
		http.open('get', 'cascade.php?a=lookcountry&tpl=' + tpl + '&lookcountry=' + lookcountry );
		document.getElementById('lookstate_province').innerHTML='&nbsp;&nbsp;'+loadingTag;
		http.onreadystatechange = handleResponse;
		http.send(null);
	}
}

function cascadeStateL(tpl, lookcountry, lookstate_province)
{
	if (document.getElementById('lookcounty') != null)
	{
		http.open('get', 'cascade.php?a=lookstate_province&tpl=' + tpl + '&lookcountry=' + lookcountry + '&lookstate_province=' + lookstate_province);
		document.getElementById('lookcounty').innerHTML='&nbsp;&nbsp;'+loadingTag;
		http.onreadystatechange = handleResponse;
		http.send(null);
	}
}

function cascadeCountyL(tpl, lookcountry, lookstate_province, lookcounty)
{
	if (document.getElementById('lookcity') != null)
	{
		http.open('get', 'cascade.php?a=lookcounty&tpl=' + tpl + '&lookcountry=' + lookcountry + '&lookstate_province=' + lookstate_province + '&lookcounty=' + lookcounty);
		document.getElementById('lookcity').innerHTML='&nbsp;&nbsp;'+loadingTag;
		http.onreadystatechange = handleResponse;
		http.send(null);
	}
}

function cascadeCityL(tpl, lookcountry, lookstate_province, lookcounty, lookcity)
{
	if (document.getElementById('lookzip') != null)
	{
		http.open('get', 'cascade.php?a=lookcity&tpl=' + tpl + '&lookcountry=' + lookcountry + '&lookstate_province=' + lookstate_province + '&lookcounty=' + lookcounty + '&lookcity=' + lookcity);
		document.getElementById('lookzip').innerHTML='&nbsp;&nbsp;'+loadingTag;
		http.onreadystatechange = handleResponse;
		http.send(null);
	}
}

function cascadeZipL(tpl, lookcountry, lookzip)
{
	if (document.getElementById('lookradius') != null)
	{
		http.open('get', 'cascade.php?a=lookzip&tpl=' + tpl + '&lookcountry=' + lookcountry + '&lookzip=' + lookzip);
		http.onreadystatechange = handleResponse;
		http.send(null);
	}
}

