window.addEvent
('domready', function() {
    Element.remove($('findLocationCity'));
    if ($('bigForm'))
    {
        cityLabelText = $('findLocationCityLabel').getText();
        Element.remove($('findLocationCityLabel'));
    }
    $('findLocationButton').setProperty('disabled','disabled');
    $('findLocationButton').setStyle('color','#7DAECC');
    
    $('findLocationCounty').addEvent
    ('change', function(e) {
		var action = 'ajax/ajax.cities.php?countyid=' + $('findLocationCounty').value;
		var myAjax = new Ajax
        (action, {
			method: 'get',
			onComplete: function(cities)
            {
                if (cities != '')
                {
                    if (!$('findLocationCity'))
                    {
                        var citySelect = new Element
                        ('select', {
                            'class': 'select',
                            'name': 'city',
                            'id': 'findLocationCity'
                        });
                        citySelect.injectAfter('findLocationCounty');
                        if ($('bigForm'))
                        {
                            var cityLabel = new Element
                            ('label', {
                                'for': 'city',
                                'id': 'findLocationCityLabel'
                            });
                            cityLabel.injectAfter('findLocationCounty');
                            $('findLocationCityLabel').setText(cityLabelText);
                        }
                    }
                    else
                    {
                        $('findLocationCity').empty();
                    }
                    var citiesArray = cities.split(',');
                    $A(citiesArray).each
                    (
                        function(cityData)
                        {
                            var cityDataArray = cityData.split(':');
                            var option = new Element('option');
                            option.setProperty("value", cityDataArray[0]);
                            option.setHTML(cityDataArray[1]);
                            $('findLocationCity').adopt(option);
                        }
                    )
                    $('findLocationButton').removeProperty('disabled');
                    $('findLocationButton').setStyle('color','#FFFFFF');;
                }
                else
                {
                    if ($('bigForm'))
                    {
                        Element.remove($('findLocationCityLabel'));
                    }
                    Element.remove($('findLocationCity'));
                    $('findLocationButton').setProperty('disabled','disabled');
                    $('findLocationButton').setStyle('color','#7DAECC');
                }
			}
        }).request();
    });
});