function popState()
{
    var states = getStates();
    for (var state in states) 
    {
        state_field = document.getElementById("state");
        state_field[state_field.length] = new Option(states[state]["name"],states[state]["id"]);
    }	
}
    
function changeState()
{
    state_field = document.getElementById("state");
    id = state_field.value;
    if(id==0)
    {
        return;
    }
    
    popCounty(id);
    
    state_info = getState(id);
    
    document.getElementById("state_fc").innerHTML=state_info["foreclosureCount"];
    document.getElementById("state_pfc").innerHTML=state_info["preForeclosureCount"];
}

function popCounty(stateId)
{
    for (x = document.getElementById("county").length; x >= 0; x--) 
    {
      document.getElementById("county")[x] = null;
    }
    county_field = document.getElementById("county");
    county_field[county_field.length] = new Option("Select A County...","0");
    var counties = getCounties(stateId);
    for (var county in counties) 
    {
        
        county_field[county_field.length] = new Option(counties[county]["name"],counties[county]["id"]);
    }	
}

function changeCounty()
{
    county_field = document.getElementById("county");
    id = county_field.value;
    
    if(id==0)
    {
        return;
    }
    
    county_info = getCounty(id);
    
    document.getElementById("county_fc").innerHTML=county_info["foreclosureCount"];
    document.getElementById("county_pfc").innerHTML=county_info["preForeclosureCount"];
}