// Initialisation $(document).ready(function() { carte.init(); }); $(document).ready(function() { secteurs.init(); }); carte = { init: function() { // Clic sur la mini carte $('#zoom_carte').click(function(event) { event.preventDefault(); $('#carte_regions').slideToggle(150); $('#selection_regions').hide(); }); // Clic sur la grande carte $("area").click(function(event) { carte.clicRegion(event); }); // Clic sur un département $("selection_regions").click(function(event) { carte.clicDept(event); //alert('ok'); }); $('#ligne_recherche_departement').remove(); }, // Ouvre une région et affiche ses départements clicRegion: function(event) { var departements = ""; event.preventDefault(); //alert("ok"); $('#selection_regions').show(); var region = event.target.alt; for (i=0; i < carte.regions.length; i++) { if (carte.regions[i].nom && carte.regions[i].nom == event.target.alt) { if ($('#r' + i).length == 0) { $('#selection_regions').append('

' + carte.regions[i].nom + '

'); } for (j=0; j < carte.regions[i].departements.length; j++) { var dep = carte.regions[i].departements[j]; if ($('#d_' + dep.id).length == 0) { $('#selection_regions').append('

> ' + dep.id + ' ' + dep.nom); //majHash('departements',dep.id); //alert("majHash departements " + dep.id); } } i = 99; } } if ($('#effacer_dep').length == 0) { $('#selection_regions').prepend('

Votre sélection

Effacer tout

'); $('#effacer_dep').click(function() { $('#selection_regions').empty(); }); } //$('#selection_regions').append(departements); }, // Ouvre toutes les regions, departements non cochés OpenRegions: function(tab_dpt) { var departements = ""; var flag_inarray=0; $('#selection_regions').empty(); //event.preventDefault(); //alert("ok"); $('#selection_regions').show(); //var region = event.target.alt; //alert("nb regions = " + carte.regions.length); //alert("nb departements à cocher = " + tab_dpt.length); //$('#carte_regions').slideToggle(150); $('#carte_regions').show(); //$('#selection_regions').hide(); for (i=0; i < carte.regions.length; i++) { for (z=0; z< carte.regions[i].departements.length; z++) { if(in_array(carte.regions[i].departements[z].id, tab_dpt)){ flag_inarray=1; } } if(flag_inarray==1){ if ($('#r' + i).length == 0) { $('#selection_regions').append('

' + carte.regions[i].nom + '

'); } for (j=0; j < carte.regions[i].departements.length; j++) { var dep = carte.regions[i].departements[j]; var str_checked=""; if(in_array(dep.id, tab_dpt)){ str_checked=" checked"; //alert("cheked " + dep.id); } if ($('#d_' + dep.id).length == 0) { $('#selection_regions').append('

> ' + dep.id + ' ' + dep.nom); } } } flag_inarray=0; //i = 99; } if ($('#effacer_dep').length == 0) { $('#selection_regions').prepend('

Votre sélection

Effacer tout

'); $('#effacer_dep').click(function() { $('#selection_regions').empty(); }); } //$('#selection_regions').append(departements); }, clicDept : function(event) { var id = event.target.value; //alert(id); $("#d_" + id).remove(); //majHash('departements',id); //alert("majHash departements " + id); } } secteurs = { init : function() { $('#liste_secteurs').hide(); $('#selection_secteurs').click(function(event) { $('#liste_secteurs').slideToggle(150); }); }, recherche : function(libelle) { document.getElementById('recherche[motscles]').value += ' ' + libelle; return true; } } carte.regions = [ {"nom" : "Alsace", "departements" : [{ "id" : "67", "nom" : "Bas-Rhin"},{ "id" : "68", "nom" : "Haut-Rhin"}] }, {"nom" : "Aquitaine", "departements" : [{ "id" : "24", "nom" : "Dordogne"},{ "id" : "33", "nom" : "Gironde"},{ "id" : "40", "nom" : "Landes"},{ "id" : "47", "nom" : "Lot-Et-Garonne"},{ "id" : "64", "nom" : "Pyrenees-Atlantiques"}] }, {"nom" : "Auvergne", "departements" : [{ "id" : "03", "nom" : "Allier"},{ "id" : "15", "nom" : "Cantal"},{ "id" : "43", "nom" : "Haute-Loire"},{ "id" : "63", "nom" : "Puy-De-Dome"}] }, {"nom" : "Basse-Normandie", "departements" : [{ "id" : "14", "nom" : "Calvados"},{ "id" : "50", "nom" : "Manche"},{ "id" : "61", "nom" : "Orne"}] }, {"nom" : "Bourgogne", "departements" : [{ "id" : "21", "nom" : "Cote-d-Or"},{ "id" : "58", "nom" : "Nievre"},{ "id" : "71", "nom" : "Saone-Et-Loire"},{ "id" : "89", "nom" : "Yonne"}] }, {"nom" : "Bretagne", "departements" : [{ "id" : "22", "nom" : "Cote-d-Armor"},{ "id" : "29", "nom" : "Finistere"},{ "id" : "35", "nom" : "Ile-Et-Vilaine"},{ "id" : "56", "nom" : "Morbihan"}] }, {"nom" : "Centre", "departements" : [{ "id" : "18", "nom" : "Cher"},{ "id" : "28", "nom" : "Eure-Et-Loir"},{ "id" : "36", "nom" : "Indre"},{ "id" : "37", "nom" : "Indre-Et-Loire"},{ "id" : "41", "nom" : "Loire-Et-cher"},{ "id" : "45", "nom" : "Loiret"}] }, {"nom" : "Champagne-Ardenne", "departements" : [{ "id" : "08", "nom" : "Ardennes"},{ "id" : "10", "nom" : "Aube"},{ "id" : "52", "nom" : "Haute-Marne"},{ "id" : "51", "nom" : "Marne"}] }, {"nom" : "Corse", "departements" : [{ "id" : "20", "nom" : "Corse"}] }, {"nom" : "Departements-d-Outre-Mer", "departements" : [{ "id" : "971", "nom" : "Guadeloupe"},{ "id" : "973", "nom" : "Guyane"},{ "id" : "974", "nom" : "La-Reunion"},{ "id" : "972", "nom" : "Martinique"},{ "id" : "976", "nom" : "Mayotte"},{ "id" : "975", "nom" : "Saint-Pierre-Et-Miquelon"}] }, {"nom" : "Franche-Comte", "departements" : [{ "id" : "25", "nom" : "Doubs"},{ "id" : "70", "nom" : "Haute-Saone"},{ "id" : "39", "nom" : "Jura"},{ "id" : "90", "nom" : "Territoire-De-Belfort"}] }, {"nom" : "Haute-Normandie", "departements" : [{ "id" : "27", "nom" : "Eure"},{ "id" : "76", "nom" : "Seine-Maritime"}] }, {"nom" : "Ile-De-France", "departements" : [{ "id" : "91", "nom" : "Essonne"},{ "id" : "92", "nom" : "Hauts-De-Seine"},{ "id" : "75", "nom" : "Paris"},{ "id" : "77", "nom" : "Seine-Et-Marne"},{ "id" : "93", "nom" : "Seine-Saint-Denis"},{ "id" : "95", "nom" : "Val-d-Oise"},{ "id" : "94", "nom" : "Val-de-Marne"},{ "id" : "78", "nom" : "Yvelines"}] }, {"nom" : "Languedoc-Roussillon", "departements" : [{ "id" : "11", "nom" : "Aude"},{ "id" : "30", "nom" : "Gard"},{ "id" : "34", "nom" : "Herault"},{ "id" : "48", "nom" : "Lozere"},{ "id" : "66", "nom" : "Pyrenees-Orientales"}] }, {"nom" : "Limousin", "departements" : [{ "id" : "19", "nom" : "Correze"},{ "id" : "23", "nom" : "Creuse"},{ "id" : "87", "nom" : "Haute-Vienne"}] }, {"nom" : "Lorraine", "departements" : [{ "id" : "54", "nom" : "Meurthe-Et-Moselle"},{ "id" : "55", "nom" : "Meuse"},{ "id" : "57", "nom" : "Moselle"},{ "id" : "88", "nom" : "Vosges"}] }, {"nom" : "Midi-Pyrenees", "departements" : [{ "id" : "09", "nom" : "Ariege"},{ "id" : "12", "nom" : "Aveyron"},{ "id" : "32", "nom" : "Gers"},{ "id" : "31", "nom" : "Haute-Garonne"},{ "id" : "65", "nom" : "Hautes-Pyrenees"},{ "id" : "46", "nom" : "Lot"},{ "id" : "81", "nom" : "Tarn"},{ "id" : "82", "nom" : "Tarn-Et-Garonne"}] }, {"nom" : "Nord-Pas-De-Calais", "departements" : [{ "id" : "59", "nom" : "Nord"},{ "id" : "62", "nom" : "Pas-De-Calais"}] }, {"nom" : "Pays-De-La-Loire", "departements" : [{ "id" : "44", "nom" : "Loire-Atlantique"},{ "id" : "49", "nom" : "Maine-Et-Loire"},{ "id" : "53", "nom" : "Mayenne"},{ "id" : "72", "nom" : "Sarthe"},{ "id" : "85", "nom" : "Vendee"}] }, {"nom" : "Picardie", "departements" : [{ "id" : "02", "nom" : "Aisne"},{ "id" : "60", "nom" : "Oise"},{ "id" : "80", "nom" : "Somme"}] }, {"nom" : "Poitou-Charentes", "departements" : [{ "id" : "16", "nom" : "Charente"},{ "id" : "17", "nom" : "Charente-Maritime"},{ "id" : "79", "nom" : "Deux-Sevres"},{ "id" : "86", "nom" : "Vienne"}] }, {"nom" : "Provence-Alpes-Cote-D-Azur", "departements" : [{ "id" : "04", "nom" : "Alpes-de-Hautes-Provence"},{ "id" : "06", "nom" : "Alpes-Maritimes"},{ "id" : "13", "nom" : "Bouches-Du-Rhone"},{ "id" : "05", "nom" : "Hautes-Alpes"},{ "id" : "83", "nom" : "Var"},{ "id" : "84", "nom" : "Vaucluse"}] }, {"nom" : "Rhone-Alpes", "departements" : [{ "id" : "01", "nom" : "Ain"},{ "id" : "07", "nom" : "Ardeche"},{ "id" : "26", "nom" : "Drome"},{ "id" : "74", "nom" : "Haute-Savoie"},{ "id" : "38", "nom" : "Isere"},{ "id" : "42", "nom" : "Loire"},{ "id" : "69", "nom" : "Rhone"},{ "id" : "73", "nom" : "Savoie"}] }, {"nom" : "Territoires-d-Outre-Mer", "departements" : [{ "id" : "988", "nom" : "Nouvelle-Caledonie"},{ "id" : "987", "nom" : "Polynesie-Francaise"},{ "id" : "984", "nom" : "Terres-Australes-et-Antarctiques"},{ "id" : "986", "nom" : "Wallis-et-Futuna"}] }, ];