function LocationBlock(servicePath, stateId, countyId, cityId)
{
	this._servicePath = servicePath;
	this._stateId = stateId;
	this._countyId = countyId;
	this._cityId = cityId;
	
	var self = this;
	
	$('#' + stateId).change(function(e) { self.StateChanged(e); } );
	$('#' + countyId).change(function(e) { self.CountyChanged(e); } );
	
	this.ClearCounties = function()
	{
		var ddl = $('#' + this._countyId);
		ddl.html('');
		ddl.append('<option value="">&lt;select county&gt;</option>');
	}

	this.ClearCities = function()
	{
		var ddl = $('#' + this._cityId);
		ddl.html('');
		ddl.append('<option value="">&lt;select city&gt;</option>');
	}
	
	this.FillSelect = function(id, result)
	{
		var ddl = $('#' + id).get(0);
		ddl.disabled = false;
		
		for (var i = 0; i < result.length; i++)
		{
			var item = result[i];
			var option = new Option(item, item);
			ddl.options.add(option);
		}
	}
	
	this.StateChanged = function(e)
	{
		this.ClearCounties();
		this.ClearCities();

		var ddl = e.target;
		var index = ddl.selectedIndex;		
		if (index <= 0)
			return;
			
		$('#' + this._countyId).attr('disabled', true);
	
		Sys.Net.WebServiceProxy.invoke(this._servicePath, "GetCounties", false, 
			{ stateCode: ddl.options[index].value },
				Function.createDelegate(this, this.StateChangedCallBack));
	}
	
	this.StateChangedCallBack = function(result)
	{
		this.FillSelect(this._countyId, result);
	}
	
	this.CountyChanged = function(e)
	{
		this.ClearCities();
	
		var index = e.target.selectedIndex;
		if (index <= 0)
			return;
		
		$('#' + this._cityId).attr('disabled', true);
		
		var stateSelect = $('#' + stateId).get(0);
		var stateIndex = stateSelect.selectedIndex;
			
		Sys.Net.WebServiceProxy.invoke(this._servicePath, "GetCities", false, 
			{ stateCode: stateSelect.options[stateIndex].value, county: e.target.options[index].value },
				Function.createDelegate(this, this.CountyChangedCallBack));
	}

	this.CountyChangedCallBack = function(result)
	{
		this.FillSelect(this._cityId, result);
	}	
}
