function Foreclosure() {}

Foreclosure.Initialize = function(properties)
{
	Foreclosure.properties = properties;
	$('#StateSelect').change(Foreclosure.HandleStateSelect);
	$('#CountySelect').change(Foreclosure.HandleCountySelect);

	//Foreclosure.HandleStateSelect({callback:Foreclosure.HandleCountySelect});
}

Foreclosure.HandleStateSelect = function(eventObj)
{
	var parameters = {Action:'PopulateDropDownSelectCounty', StateAbbreviation:$('#StateSelect').val()};
	if (Util.isBlank(parameters.StateAbbreviation)) { return; }
	$('#CountySelect').html('<option value="">Loading...</option>');
	$('#CitySelect').html('<option value="">Select City</option>');
	$('#CountySelect').load(Foreclosure.properties.AppPath, parameters, eventObj.callback);
}

Foreclosure.HandleCountySelect = function()
{
        var parameters = {Action:'PopulateDropDownSelectCity', CountyId:$('#CountySelect').val()};
	if (Util.isBlank(parameters.CountyId)) { return; }
	$('#CitySelect').html('<option value="">Loading...</option>');
        $('#CitySelect').load(Foreclosure.properties.AppPath, parameters);
}

/*******************************  Utility Class *********************************************/

function Util() { }

Util.isBlank = function(string_data)
{
        if (string_data.replace(/\s/g, "") == "") { return true; }
        return false;
}

Util.objectInspect = function(object, showAll, lineBreak)
{
        if (!lineBreak) { lineBreak = "\n"; }
        var msg = '';
        for (var i in object)
        {
                if (!showAll && !object.hasOwnProperty(i)) { continue; }
                msg += i + ': ' + object[i] + lineBreak;
        }
        return msg;
}

Util.alertInspect = function(object, showAll) { alert(Util.objectInspect(object, showAll)); }
