/*
 * Cosmetic -- Application de comarquage Service-public.fr
 * By: Valéry Febvre <infos-pratiques-devel@listes.infos-pratiques.org>
 * By: Emmanuel Raviart <infos-pratiques-devel@listes.infos-pratiques.org>
 *
 * Copyright (C) 2008, 2009 Easter-eggs & Emmanuel Raviart
 * http://wiki.infos-pratiques.org/wiki/Cosmetic
 *
 * This file is part of Cosmetic.
 *
 * Cosmetic is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * Cosmetic is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */


cosmetic.territoryAutocompleterOptions = {
    minchars: 2
};


jQuery(function () {
    cosmetic.territoryAutocompleterOptions.source = cosmetic.baseUrl + 'territoires/autocomplete'
        + '?kind=ArrondissementOfCommuneOfFrance&kind=AssociatedCommuneOfFrance&kind=CommuneOfFrance&kind=Country'
        + '&kind=DepartmentOfFrance&kind=IntercommunalityOfFrance&kind=RegionOfFrance';
    if (typeof cosmetic.gadgetId != 'undefined') {
        cosmetic.territoryAutocompleterOptions.source += '&gadget=' + cosmetic.gadgetId;
    }
    jQuery('#where-input').autocompleter(cosmetic.territoryAutocompleterOptions);
});
