var countryStatesConn = new XHConn();

function toggleT(_w,_h)
{
	if (el = document.getElementById(_w))
	{
		el.style.visibility = (_h ? 'visible' : 'hidden');
	}
}

function toggleD(_w,_h)
{
	if (el = document.getElementById(_w))
	{
		el.style.display = (_h ? '' : 'none');
	}
}

function setStatesResponse (stateId, stateOtherId, xmlhttp)
{
  var stateObj = document.getElementById (stateId);
  var stateOtherObj = document.getElementById (stateOtherId);
  var stateOtherDelimeter = document.getElementById (stateOtherId + '_delim');
  if (! stateObj || ! stateOtherObj || ! stateOtherDelimeter) return ;

	var hasStates = (xmlhttp.responseText != '');

  if (hasStates)
  {
    eval (xmlhttp.responseText);
    for (var i = 0; i < statesList.length / 2 - 1; i++ )
			stateObj.options[stateObj.options.length] = new Option(statesList[i * 2 + 1], statesList[i * 2]);
  }

	toggleD (stateId, hasStates);
	toggleD (stateOtherId, ! hasStates);
	toggleD (stateOtherId + '_delim', false);
	stateObj.disabled = ! hasStates;
}
function toggleOtherState (e, stateOtherId)
{
	var showOtherState = (e == '-1');

	toggleD (stateOtherId, showOtherState);
	toggleD (stateOtherId + '_delim', showOtherState);
}
function clearStates (stateId)
{
  var stateObj = document.getElementById (stateId);
  if (stateObj) stateObj.options.length = 0;
}