Subversion Repositories eFlore/Applications.cel

Rev

Rev 1435 | Rev 1442 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1435 Rev 1438
1
/*+--------------------------------------------------------------------------------------------------------+*/
1
/*+--------------------------------------------------------------------------------------------------------+*/
2
// PARAMÊTRES et CONSTANTES
2
// PARAMÊTRES et CONSTANTES
3
// Mettre à true pour afficher les messages de débogage
3
// Mettre à true pour afficher les messages de débogage
4
var DEBUG = false; 
4
var DEBUG = false; 
5
/**
5
/**
6
 * Indication de certaines variables ajoutée par php
6
 * Indication de certaines variables ajoutée par php
7
* var communeImageUrl ;
7
* var communeImageUrl ;
8
* var pointImageUrl ;
8
* var pointImageUrl ;
9
* var groupeImageUrlTpl ;
9
* var groupeImageUrlTpl ;
10
*/
10
*/
11
var pointsOrigine = null;
11
var pointsOrigine = null;
12
var boundsOrigine = null;
12
var boundsOrigine = null;
13
var markerClusterer = null;
13
var markerClusterer = null;
14
var map = null;
14
var map = null;
15
var infoBulle = new google.maps.InfoWindow();
15
var infoBulle = new google.maps.InfoWindow();
16
var stations = null;
16
var stations = null;
17
var pointClique = null;
17
var pointClique = null;
18
var carteCentre = new google.maps.LatLng(25, 10);
18
var carteCentre = new google.maps.LatLng(25, 10);
19
var carteOptions = {
19
var carteOptions = {
20
	zoom: 3,
20
	zoom: 3,
21
	center:carteCentre,
21
	center:carteCentre,
22
	mapTypeId: google.maps.MapTypeId.ROADMAP,
22
	mapTypeId: google.maps.MapTypeId.ROADMAP,
23
	mapTypeControlOptions: {
23
	mapTypeControlOptions: {
24
		mapTypeIds: ['OSM', 
24
		mapTypeIds: ['OSM', 
25
		             google.maps.MapTypeId.ROADMAP, 
25
		             google.maps.MapTypeId.ROADMAP, 
26
		             google.maps.MapTypeId.HYBRID, 
26
		             google.maps.MapTypeId.HYBRID, 
27
		             google.maps.MapTypeId.SATELLITE, 
27
		             google.maps.MapTypeId.SATELLITE, 
28
		             google.maps.MapTypeId.TERRAIN]
28
		             google.maps.MapTypeId.TERRAIN]
29
	}
29
	},
-
 
30
	zoomControlOptions: {
-
 
31
        style: google.maps.ZoomControlStyle.LARGE,
-
 
32
        position: google.maps.ControlPosition.LEFT_CENTER
-
 
33
    },
-
 
34
    panControl: false
30
};			
35
};			
31
var osmMapType = new google.maps.ImageMapType({
36
var osmMapType = new google.maps.ImageMapType({
32
	getTileUrl: function(coord, zoom) {
37
	getTileUrl: function(coord, zoom) {
33
		return "http://tile.openstreetmap.org/" +
38
		return "http://tile.openstreetmap.org/" +
34
		zoom + "/" + coord.x + "/" + coord.y + ".png";
39
		zoom + "/" + coord.x + "/" + coord.y + ".png";
35
	},
40
	},
36
	tileSize: new google.maps.Size(256, 256),
41
	tileSize: new google.maps.Size(256, 256),
37
	isPng: true,
42
	isPng: true,
38
	alt: "OpenStreetMap",
43
	alt: "OpenStreetMap",
39
	name: "OSM",
44
	name: "OSM",
40
	maxZoom: 19
45
	maxZoom: 19
41
});
46
});
42
var ctaLayer = null;
47
var ctaLayer = null;
43
var pagineur = {'limite':300, 'start':0, 'total':0, 'stationId':null, 'format':'tableau'};
48
var pagineur = {'limite':300, 'start':0, 'total':0, 'stationId':null, 'format':'tableau'};
44
var station = {'commune':'', 'obsNbre':0};
49
var station = {'commune':'', 'obsNbre':0};
45
var obsStation = new Array();
50
var obsStation = new Array();
46
var obsPage = new Array();
51
var obsPage = new Array();
47
var taxonsCarte = new Array();
52
var taxonsCarte = new Array();
48
var mgr = null;
53
var mgr = null;
49
var marqueursCache = new Array();
54
var marqueursCache = new Array();
50
var zonesCache = new Array();
55
var zonesCache = new Array();
51
var requeteChargementPoints;
56
var requeteChargementPoints;
52
var urlVars = null;
57
var urlVars = null;
53
/*+--------------------------------------------------------------------------------------------------------+*/
58
/*+--------------------------------------------------------------------------------------------------------+*/
54
// INITIALISATION DU CODE
59
// INITIALISATION DU CODE
55
 
60
 
56
//Déclenchement d'actions quand JQuery et le document HTML sont OK
61
//Déclenchement d'actions quand JQuery et le document HTML sont OK
57
$(document).ready(function() {
62
$(document).ready(function() {
58
	initialiserWidget();
63
	initialiserWidget();
59
});
64
});
60
 
65
 
61
function initialiserWidget() {
66
function initialiserWidget() {
62
	urlVars = getUrlVars();
67
	urlVars = getUrlVars();
63
	definirTailleTitre();
68
	definirTailleTitre();
-
 
69
	centrerTitreEtStats();
64
	initialiserAffichageCarte();
70
	initialiserAffichageCarte();
65
	initialiserAffichagePanneauLateral();
71
	initialiserAffichagePanneauLateral();
66
	initialiserCarte();
72
	initialiserCarte();
67
	initialiserGestionnaireMarqueurs()
73
	initialiserGestionnaireMarqueurs()
68
	initialiserInfoBulle();
74
	initialiserInfoBulle();
69
	initialiserFormulaireContact();
75
	initialiserFormulaireContact();
70
	chargerLimitesCommunales();
76
	chargerLimitesCommunales();
71
	attribuerListenerCarte();
77
	attribuerListenerCarte();
72
	programmerRafraichissementCarte();
78
	programmerRafraichissementCarte();
73
}
79
}
74
 
80
 
75
function getUrlVars()
81
function getUrlVars()
76
{
82
{
77
    var vars = [], hash;
83
    var vars = [], hash;
78
    if(window.location.href.indexOf('?') != -1) {
84
    if(window.location.href.indexOf('?') != -1) {
79
	    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
85
	    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
80
	    for(var i = 0; i < hashes.length; i++)
86
	    for(var i = 0; i < hashes.length; i++)
81
	    {
87
	    {
82
	        hash = hashes[i].split('=');
88
	        hash = hashes[i].split('=');
83
	        vars.push(hash[0]);
89
	        vars.push(hash[0]);
84
	        vars[hash[0]] = hash[1];
90
	        vars[hash[0]] = hash[1];
85
	    }
91
	    }
86
    }
92
    }
87
    return vars;
93
    return vars;
88
}
94
}
89
 
95
 
90
/*+--------------------------------------------------------------------------------------------------------+*/
96
/*+--------------------------------------------------------------------------------------------------------+*/
91
// AFFICHAGE GÉNÉRAL
97
// AFFICHAGE GÉNÉRAL
92
 
98
 
93
function afficherTitreCarte() {
99
function afficherTitreCarteEtStats() {
94
	if (stations != null && taxonsCarte.length > 0) {
100
	if (stations != null && taxonsCarte.length > 0) {
95
		var obsNbre = stations.stats.observations;
101
		var obsNbre = stations.stats.observations;
96
		var obsNbreFormate = obsNbre;
102
		var obsNbreFormate = obsNbre;
97
		if(obsNbre != 0) {
103
		if(obsNbre != 0) {
98
		    obsNbreFormate = stations.stats.observations.formaterNombre();
104
		    obsNbreFormate = stations.stats.observations.formaterNombre();
99
		}
105
		}
100
		var plteNbre = taxonsCarte.length;
106
		var plteNbre = taxonsCarte.length;
101
		var plteNbreFormate = plteNbre;
107
		var plteNbreFormate = plteNbre;
102
		if(plteNbre != 0) {
108
		if(plteNbre != 0) {
103
		    plteNbreFormate = taxonsCarte.length.formaterNombre();
109
		    plteNbreFormate = taxonsCarte.length.formaterNombre();
104
		}
110
		}
105
		var communeNbre = stations.stats.communes;
111
		var communeNbre = stations.stats.communes;
106
		var communeNbreFormate = communeNbre;
112
		var communeNbreFormate = communeNbre;
107
		if(communeNbre != 0) {
113
		if(communeNbre != 0) {
108
		   communeNbreFormate = stations.stats.communes.formaterNombre();
114
		   communeNbreFormate = stations.stats.communes.formaterNombre();
109
		}
115
		}
110
		var stationNbre = stations.stats.stations;
116
		var stationNbre = stations.stats.stations;
111
		var stationNbreFormate = stationNbre;
117
		var stationNbreFormate = stationNbre;
112
		if(stationNbre != 0) {
118
		if(stationNbre != 0) {
113
		  	stationNbreFormate = stations.stats.stations.formaterNombre();
119
		  	stationNbreFormate = stations.stats.stations.formaterNombre();
114
		}
120
		}
115
	
121
	
116
		var titre = obsNbreFormate+' observation';
122
		var stats = obsNbreFormate+' observation';
117
		titre += (obsNbre > 1) ? 's' : '' ;
123
		stats += (obsNbre > 1) ? 's' : '' ;
118
 
124
 
119
		if(photos_seulement == 1) {
125
		if(photos != null && photos == 1) {
120
			titre += ' avec photos ';
126
			stats += ' avec photos ';
121
		}
127
		}
122
		
128
		
123
		titre += ' sur '+(stationNbre+ communeNbre)+' station';
129
		stats += ' sur '+(stationNbre+ communeNbre)+' station';
124
		titre += (stationNbre > 1) ? 's' : '' ;
130
		stats += (stationNbre > 1) ? 's' : '' ;
125
 
131
 
126
		if (nt == '*') {
132
		if (nt == '*') {
127
			titre += ' parmi '+plteNbreFormate+' plante';
133
			stats += ' parmi '+plteNbreFormate+' plante';
128
			titre += (plteNbre > 1) ? 's' : '' ;
134
			stats += (plteNbre > 1) ? 's' : '' ;
129
		} else {
135
		} else {
130
			if($('.taxon-actif .taxon').text() != '') {
136
			if($('.taxon-actif .taxon').text() != '') {
131
				var element = $('.taxon-actif .taxon').clone();
137
				var element = $('.taxon-actif .taxon').clone();
132
				element.children().remove();
138
				element.children().remove();
133
		        var taxon = element.text();
139
		        var taxon = element.text();
134
				titre += ' pour '+taxon;
140
		        stats += ' pour '+taxon;
135
			} else {
141
			} else {
136
				if (taxonsCarte[0]) {
142
				if (taxonsCarte[0]) {
137
					var taxon = taxonsCarte[0];
143
					var taxon = taxonsCarte[0];
138
					titre += ' pour '+taxon.nom;
144
					stats += ' pour '+taxon.nom;
139
				}
145
				}
140
			}
146
			}
141
		}
147
		}
-
 
148
		
-
 
149
		$('#pl-indication-filtre').html('Filtrer parmi <br />'+plteNbre+'<br />plantes');
142
		
150
		$('#zone-stats').show();
143
		$('#carte-titre-infos').text(titre);
151
		$('#zone-stats > h1').text(stats);
-
 
152
	}
144
	}
153
	centrerTitreEtStats();
-
 
154
}
145
}
155
 
146
 
156
var tailleTitreOriginelle = null;
147
function definirTailleTitre() {
157
function definirTailleTitre() {
148
	var largeurViewPort = $(window).width();
158
	var largeurViewPort = $(window).width();
149
	var taille = null;
159
	var taille = null;
150
	if (largeurViewPort < 400) {
160
	if (largeurViewPort < 400) {
151
		taille = '0.8';
161
		taille = '0.8';
152
	} else if (largeurViewPort >= 400 && largeurViewPort < 800) {
162
	} else if (largeurViewPort >= 400 && largeurViewPort < 800) {
153
		taille = '1.0';
163
		taille = '1.0';
154
	} else if (largeurViewPort >= 800) {
164
	} else if (largeurViewPort >= 800) {
155
		taille = '1.6';
165
		taille = '1.6';
156
	}
166
	}
-
 
167
	
-
 
168
	// Aménagement de la taille de police selon l'écran
157
	$("#carte-titre").css('font-size', taille+'em');
169
	$("#carte-titre").css('font-size', taille+'em');
-
 
170
	$("#zone-stats h1").css('font-size', taille+'em');
-
 
171
	
-
 
172
	// Dimensionnement du titre et du logo
-
 
173
	if(urlLogo != "null") {
-
 
174
		hauteurLogo = $('#logo img').height();
-
 
175
		// Redimensionnement du logo s'il est trop grand
-
 
176
		// on perd en qualité mais ça vaut mieux que de casser l'affichage
-
 
177
		if(hauteurLogo > 60) {
-
 
178
			hauteurLogo = 60;
-
 
179
			$('#logo img').height(60);
-
 
180
		}
-
 
181
		
-
 
182
		if(hauteurLogo == 0) {
-
 
183
			$('#logo img').load(function(event) {
-
 
184
				definirTailleTitre();
-
 
185
			});
-
 
186
			return;
-
 
187
		}
-
 
188
		
-
 
189
		largeurLogo = $('#logo img').width();
-
 
190
		largeurTitre = $('#carte-titre-infos').width();
-
 
191
		
-
 
192
		$('#zone-titre').css("height", (hauteurLogo)+"px");
-
 
193
		$('#zone-titre').css("width", (largeurLogo+largeurTitre+16)+"px");
-
 
194
		
-
 
195
		if(titreCarte != 'null' && titreCarte != 0) {
-
 
196
			$('#carte-titre-infos').css("position", "absolute");
-
 
197
			$('#carte-titre-infos').css("left", (largeurLogo+16)+"px");
-
 
198
			$('#carte-titre-infos').css("top", (hauteurLogo/2 - 8)+"px");
-
 
199
		}
-
 
200
	}
-
 
201
}
-
 
202
 
-
 
203
function centrerTitreEtStats() {
-
 
204
	var largeurViewPort = $(window).width();
-
 
205
	var largeurTitre = $('#zone-titre').width();
-
 
206
	var marge = (largeurViewPort - largeurTitre)/2;
-
 
207
	$('#zone-titre').css("margin-left",marge);
-
 
208
	
-
 
209
	var largeurStats = $('#zone-stats').width();
-
 
210
	var marge = (largeurViewPort - largeurStats)/2;
-
 
211
	$('#zone-stats').css("left",marge);
158
}
212
}
159
 
213
 
160
/*+--------------------------------------------------------------------------------------------------------+*/
214
/*+--------------------------------------------------------------------------------------------------------+*/
161
// CARTE
215
// CARTE
162
 
216
 
163
function initialiserAffichageCarte() {
217
function initialiserAffichageCarte() {
164
	$('#carte').height($(window).height() - 35);
218
	$('#carte').height($(window).height());
165
	$('#carte').width($(window).width() - 24);
219
	$('#carte').width($(window).width());
166
 
-
 
167
	if (nt != '*') {
-
 
168
		$('#carte').css('left', 0);
-
 
169
	}
-
 
170
}
220
}
171
 
221
 
172
function initialiserCarte() {
222
function initialiserCarte() {
173
	map = new google.maps.Map(document.getElementById('carte'), carteOptions);
223
	map = new google.maps.Map(document.getElementById('carte'), carteOptions);
174
	// Ajout de la couche OSM à la carte
224
	// Ajout de la couche OSM à la carte
175
	map.mapTypes.set('OSM', osmMapType);
225
	map.mapTypes.set('OSM', osmMapType);
176
}
226
}
177
 
227
 
178
function initialiserGestionnaireMarqueurs() {
228
function initialiserGestionnaireMarqueurs() {
179
	mgr = new MarkerManager(map);
229
	mgr = new MarkerManager(map);
180
}
230
}
181
 
231
 
182
function chargerLimitesCommunales() {
232
function chargerLimitesCommunales() {
183
	if (urlsLimitesCommunales != null) {
233
	if (urlsLimitesCommunales != null) {
184
		for (urlId in urlsLimitesCommunales) { 
234
		for (urlId in urlsLimitesCommunales) { 
185
			var url = urlsLimitesCommunales[urlId];
235
			var url = urlsLimitesCommunales[urlId];
186
			ctaLayer = new google.maps.KmlLayer(url, {preserveViewport: true});
236
			ctaLayer = new google.maps.KmlLayer(url, {preserveViewport: true});
187
			ctaLayer.setMap(map);
237
			ctaLayer.setMap(map);
188
		}
238
		}
189
	}
239
	}
190
}
240
}
191
 
241
 
192
var listener = null;
242
var listener = null;
193
var timer = null;
243
var timer = null;
194
function attribuerListenerCarte() {
244
function attribuerListenerCarte() {
195
	listener = google.maps.event.addListener(map, 'bounds_changed', function(){
245
	listener = google.maps.event.addListener(map, 'bounds_changed', function(){
196
		programmerRafraichissementCarte();
246
		programmerRafraichissementCarte();
197
	});
247
	});
198
	listener = google.maps.event.addListener(map, 'zoom_changed', function(){
248
	listener = google.maps.event.addListener(map, 'zoom_changed', function(){
199
		programmerRafraichissementCarte();
249
		programmerRafraichissementCarte();
200
	});
250
	});
201
}
251
}
202
function programmerRafraichissementCarte() {
252
function programmerRafraichissementCarte() {
203
	if(timer != null) {
253
	if(timer != null) {
204
        window.clearTimeout(timer);
254
        window.clearTimeout(timer);
205
    }
255
    }
206
	if(requeteChargementPoints != null) {
256
	if(requeteChargementPoints != null) {
207
		requeteChargementPoints.abort();
257
		requeteChargementPoints.abort();
208
	}
258
	}
209
	timer = window.setTimeout(function() {
259
	timer = window.setTimeout(function() {
210
		if(map.getBounds() != undefined) {
260
		if(map.getBounds() != undefined) {
211
			var zoom = map.getZoom();
261
			var zoom = map.getZoom();
212
			var lngNE = map.getBounds().getNorthEast().lng();
262
			var lngNE = map.getBounds().getNorthEast().lng();
213
			var lngSW = map.getBounds().getSouthWest().lng()
263
			var lngSW = map.getBounds().getSouthWest().lng()
214
			if(map.getBounds().getNorthEast().lng() < map.getBounds().getSouthWest().lng()) {
264
			if(map.getBounds().getNorthEast().lng() < map.getBounds().getSouthWest().lng()) {
215
				lngNE = 176;
265
				lngNE = 176;
216
				lngSW = -156;
266
				lngSW = -156;
217
			}
267
			}
218
			var NELatLng = (map.getBounds().getNorthEast().lat())+'|'+(lngNE);
268
			var NELatLng = (map.getBounds().getNorthEast().lat())+'|'+(lngNE);
219
			var SWLatLng = (map.getBounds().getSouthWest().lat())+'|'+(lngSW);
269
			var SWLatLng = (map.getBounds().getSouthWest().lat())+'|'+(lngSW);
220
			chargerMarqueurs(zoom, NELatLng, SWLatLng);
270
			chargerMarqueurs(zoom, NELatLng, SWLatLng);
221
		} else {
271
		} else {
222
			programmerRafraichissementCarte();
272
			programmerRafraichissementCarte();
223
		}
273
		}
224
    }, 400);		
274
    }, 400);		
225
}
275
}
226
 
276
 
227
var marqueurs = new Array();
277
var marqueurs = new Array();
228
function chargerMarqueurs(zoom, NELatLng, SWLatLng) {
278
function chargerMarqueurs(zoom, NELatLng, SWLatLng) {
229
	var url = stationsUrl+
279
	var url = stationsUrl+
230
		'&zoom='+zoom+
280
		'&zoom='+zoom+
231
		'&ne='+NELatLng+
281
		'&ne='+NELatLng+
232
		'&sw='+SWLatLng;
282
		'&sw='+SWLatLng;
233
	
283
	
234
	if(infoBulleOuverte) {
284
	if(infoBulleOuverte) {
235
		return;
285
		return;
236
	}
286
	}
237
	
287
	
238
	if(requeteChargementPoints != null) {
288
	if(requeteChargementPoints != null) {
239
		requeteChargementPoints.abort();
289
		requeteChargementPoints.abort();
240
		cacherMessageChargementPoints();
290
		cacherMessageChargementPoints();
241
	}
291
	}
242
	
292
	
243
	afficherMessageChargementPoints();
293
	afficherMessageChargementPoints();
244
	requeteChargementPoints = $.getJSON(url, function(data) {
294
	requeteChargementPoints = $.getJSON(url, function(data) {
245
		rafraichirMarqueurs(data);
295
		rafraichirMarqueurs(data);
246
		cacherMessageChargementPoints();
296
		cacherMessageChargementPoints();
247
	});
297
	});
248
}
298
}
249
 
299
 
250
function afficherMessageChargementPoints() {
300
function afficherMessageChargementPoints() {
251
	$('#zone-chargement-point').css('display','block');
301
	$('#zone-chargement-point').css('display','block');
252
}
302
}
253
 
303
 
254
function cacherMessageChargementPoints() {
304
function cacherMessageChargementPoints() {
255
	$('#zone-chargement-point').css('display','none');
305
	$('#zone-chargement-point').css('display','none');
256
}
306
}
257
 
307
 
258
premierChargement = true;
308
premierChargement = true;
259
function doitCentrerCarte() {
309
function doitCentrerCarte() {
260
	return premierChargement && urlVars != null && urlVars.length > 0;
310
	return premierChargement && urlVars != null && urlVars.length > 0;
261
}
311
}
262
 
312
 
263
function rafraichirMarqueurs(data) {
313
function rafraichirMarqueurs(data) {
264
	$.each(marqueurs, function(index, marqueur) {
314
	$.each(marqueurs, function(index, marqueur) {
265
		marqueur.setMap(null);
315
		marqueur.setMap(null);
266
	});
316
	});
267
	marqueurs = new Array();
317
	marqueurs = new Array();
268
	
318
	
269
	stations = data;
319
	stations = data;
270
	afficherTitreCarte();
320
	afficherTitreCarteEtStats();
271
	
321
	
272
	$.each(stations.points, function (index, station) {		
322
	$.each(stations.points, function (index, station) {		
273
		if(station != null) {
323
		if(station != null) {
274
			var nouveauMarqueur = creerMarqueur(station);
324
			var nouveauMarqueur = creerMarqueur(station);
275
			marqueurs.push(nouveauMarqueur);
325
			marqueurs.push(nouveauMarqueur);
276
		}
326
		}
277
	});
327
	});
278
	
328
	
279
	if(doitCentrerCarte()) {
329
	if(doitCentrerCarte()) {
280
		premierChargement = false;
330
		premierChargement = false;
281
		var bounds = new google.maps.LatLngBounds();
331
		var bounds = new google.maps.LatLngBounds();
282
		var latMax = new google.maps.LatLng(data.stats.coordmax.latMax, data.stats.coordmax.lngMax);
332
		var latMax = new google.maps.LatLng(data.stats.coordmax.latMax, data.stats.coordmax.lngMax);
283
		var latMin = new google.maps.LatLng(data.stats.coordmax.latMin, data.stats.coordmax.lngMin);
333
		var latMin = new google.maps.LatLng(data.stats.coordmax.latMin, data.stats.coordmax.lngMin);
284
		bounds.extend(latMax);
334
		bounds.extend(latMax);
285
		bounds.extend(latMin);
335
		bounds.extend(latMin);
286
		rendrePointsVisibles(bounds);	
336
		rendrePointsVisibles(bounds);	
287
	}
337
	}
288
}
338
}
289
 
339
 
290
function creerMarqueur(station) {
340
function creerMarqueur(station) {
291
	var titre = '';
341
	var titre = '';
292
	if(station.nbreMarqueur) {
342
	if(station.nbreMarqueur) {
293
		titre = station.nbreMarqueur+' points renseignés';
343
		titre = station.nbreMarqueur+' points renseignés';
294
	} else {
344
	} else {
295
		if(station.nom) {
345
		if(station.nom) {
296
			titre = station.nom;
346
			titre = station.nom;
297
		}
347
		}
298
	}
348
	}
299
	
349
	
300
	var icone = attribuerImageMarqueur(station['id'], station['nbreMarqueur']);
350
	var icone = attribuerImageMarqueur(station['id'], station['nbreMarqueur']);
301
	var latLng = new google.maps.LatLng(station['lat'], station['lng']);
351
	var latLng = new google.maps.LatLng(station['lat'], station['lng']);
302
	var marqueur = new google.maps.Marker({
352
	var marqueur = new google.maps.Marker({
303
		position: latLng,
353
		position: latLng,
304
		icon: icone,
354
		icon: icone,
305
		title: ''+titre,
355
		title: ''+titre,
306
		map: map,
356
		map: map,
307
		stationInfos: station
357
		stationInfos: station
308
	});
358
	});
309
	attribuerListenerClick(marqueur, station['id']);
359
	attribuerListenerClick(marqueur, station['id']);
310
	marqueur.setMap(map);
360
	marqueur.setMap(map);
311
    return marqueur;
361
    return marqueur;
312
}
362
}
313
 
363
 
314
function rendrePointsVisibles(bounds) {
364
function rendrePointsVisibles(bounds) {
315
	map.setCenter(bounds.getCenter());
365
	map.setCenter(bounds.getCenter());
316
	map.fitBounds(bounds);
366
	map.fitBounds(bounds);
317
}
367
}
318
 
368
 
319
function attribuerImageMarqueur(id, nbreMarqueur) {
369
function attribuerImageMarqueur(id, nbreMarqueur) {
320
	var marqueurImage = null;
370
	var marqueurImage = null;
321
	if (etreMarqueurCommune(id)) {
371
	if (etreMarqueurCommune(id)) {
322
		marqueurImage = new google.maps.MarkerImage(communeImageUrl, new google.maps.Size(24, 32));
372
		marqueurImage = new google.maps.MarkerImage(communeImageUrl, new google.maps.Size(24, 32));
323
	} else if (etreMarqueurStation(id)) {
373
	} else if (etreMarqueurStation(id)) {
324
		marqueurImage = new google.maps.MarkerImage(pointImageUrl, new google.maps.Size(16, 16));
374
		marqueurImage = new google.maps.MarkerImage(pointImageUrl, new google.maps.Size(16, 16));
325
	} else if (etreMarqueurGroupe(id)) {
375
	} else if (etreMarqueurGroupe(id)) {
326
		var type = 0;
376
		var type = 0;
327
		var largeur = 0;
377
		var largeur = 0;
328
		var hauteur = 0;
378
		var hauteur = 0;
329
		if (nbreMarqueur != null) {
379
		if (nbreMarqueur != null) {
330
			if (nbreMarqueur >= 2 && nbreMarqueur < 100 ) {
380
			if (nbreMarqueur >= 2 && nbreMarqueur < 100 ) {
331
				type = '1';
381
				type = '1';
332
				largeur = 53;
382
				largeur = 53;
333
				hauteur = 52;
383
				hauteur = 52;
334
			} else if (nbreMarqueur >= 100 && nbreMarqueur < 1000 ) {
384
			} else if (nbreMarqueur >= 100 && nbreMarqueur < 1000 ) {
335
				type = '2';
385
				type = '2';
336
				largeur = 56;
386
				largeur = 56;
337
				hauteur = 55;
387
				hauteur = 55;
338
			} else if (nbreMarqueur >= 1000 && nbreMarqueur < 10000 ) {
388
			} else if (nbreMarqueur >= 1000 && nbreMarqueur < 10000 ) {
339
				type = '3';
389
				type = '3';
340
				largeur = 66;
390
				largeur = 66;
341
				hauteur = 65;
391
				hauteur = 65;
342
			} else if (nbreMarqueur >= 10000 && nbreMarqueur < 20000 ) {
392
			} else if (nbreMarqueur >= 10000 && nbreMarqueur < 20000 ) {
343
				type = '4';
393
				type = '4';
344
				largeur = 78;
394
				largeur = 78;
345
				hauteur = 77;
395
				hauteur = 77;
346
			} else if (nbreMarqueur >= 20000) {
396
			} else if (nbreMarqueur >= 20000) {
347
				type = '5';
397
				type = '5';
348
				largeur = 66;
398
				largeur = 66;
349
				hauteur = 65;
399
				hauteur = 65;
350
			}
400
			}
351
		}
401
		}
352
		groupeImageUrl = groupeImageUrlTpl.replace(/\{type\}/, type);
402
		groupeImageUrl = groupeImageUrlTpl.replace(/\{type\}/, type);
353
		groupeImageUrl = groupeImageUrl.replace(/\{nbre\}/, nbreMarqueur);
403
		groupeImageUrl = groupeImageUrl.replace(/\{nbre\}/, nbreMarqueur);
354
		marqueurImage = new google.maps.MarkerImage(groupeImageUrl, new google.maps.Size(largeur, hauteur));
404
		marqueurImage = new google.maps.MarkerImage(groupeImageUrl, new google.maps.Size(largeur, hauteur));
355
	}
405
	}
356
	return marqueurImage
406
	return marqueurImage
357
}
407
}
358
 
408
 
359
function attribuerListenerClick(marqueur, id) {
409
function attribuerListenerClick(marqueur, id) {
360
	if (etreMarqueurCommune(id) || etreMarqueurStation(id)) {
410
	if (etreMarqueurCommune(id) || etreMarqueurStation(id)) {
361
		google.maps.event.addListener(marqueur, 'click', surClickMarqueur);
411
		google.maps.event.addListener(marqueur, 'click', surClickMarqueur);
362
	} else if (etreMarqueurGroupe(id)) {
412
	} else if (etreMarqueurGroupe(id)) {
363
		google.maps.event.addListener(marqueur, 'click', surClickGroupe);
413
		google.maps.event.addListener(marqueur, 'click', surClickGroupe);
364
	}
414
	}
365
}
415
}
366
 
416
 
367
function surClickMarqueur(event) {
417
function surClickMarqueur(event) {
368
 
418
 
369
	if(infoBulleOuverte) {
419
	if(infoBulleOuverte) {
370
	    infoBulle.close();
420
	    infoBulle.close();
371
	}
421
	}
372
  
422
  
373
	pointClique = this;
423
	pointClique = this;
374
	infoBulle.open(map, this);
424
	infoBulle.open(map, this);
375
	actualiserPagineur();
425
	actualiserPagineur();
376
	
426
	
377
	var limites = map.getBounds();
427
	var limites = map.getBounds();
378
	var centre = limites.getCenter();
428
	var centre = limites.getCenter();
379
	var nordEst = limites.getNorthEast();
429
	var nordEst = limites.getNorthEast();
380
	var centreSudLatLng = new google.maps.LatLng(nordEst.lat(), centre.lng());
430
	var centreSudLatLng = new google.maps.LatLng(nordEst.lat(), centre.lng());
381
	map.panTo(centreSudLatLng);
431
	map.panTo(centreSudLatLng);
382
	
432
	
383
	afficherInfoBulle();
433
	afficherInfoBulle();
384
}
434
}
385
 
435
 
386
function surClickGroupe() {
436
function surClickGroupe() {
387
	map.setCenter(this.getPosition());
437
	map.setCenter(this.getPosition());
388
	var nouveauZoom = map.getZoom() + 2;
438
	var nouveauZoom = map.getZoom() + 2;
389
	map.setZoom(nouveauZoom);
439
	map.setZoom(nouveauZoom);
390
	mgr.clearMarkers();
440
	mgr.clearMarkers();
391
}
441
}
392
 
442
 
393
function etreMarqueurGroupe(id) {
443
function etreMarqueurGroupe(id) {
394
	var groupe = false;
444
	var groupe = false;
395
	var motif = /^GROUPE/;
445
	var motif = /^GROUPE/;
396
	if (motif.test(id)) {
446
	if (motif.test(id)) {
397
		groupe = true;
447
		groupe = true;
398
	}
448
	}
399
	return groupe;
449
	return groupe;
400
}
450
}
401
 
451
 
402
function etreMarqueurCommune(id) {
452
function etreMarqueurCommune(id) {
403
	var commune = false;
453
	var commune = false;
404
	var motif = /^COMMUNE:/;
454
	var motif = /^COMMUNE:/;
405
	if (motif.test(id)) {
455
	if (motif.test(id)) {
406
		commune = true;
456
		commune = true;
407
	}
457
	}
408
	return commune;
458
	return commune;
409
}
459
}
410
 
460
 
411
function etreMarqueurStation(id) {
461
function etreMarqueurStation(id) {
412
	var station = false;
462
	var station = false;
413
	var motif = /^STATION:/;
463
	var motif = /^STATION:/;
414
	if (motif.test(id)) {
464
	if (motif.test(id)) {
415
		station = true;
465
		station = true;
416
	}
466
	}
417
	return station;
467
	return station;
418
}
468
}
419
 
469
 
420
function deplacerCarteSurPointClique() {
470
function deplacerCarteSurPointClique() {
421
	map.panTo(pointClique.position);
471
	map.panTo(pointClique.position);
422
}
472
}
423
 
473
 
424
/*+--------------------------------------------------------------------------------------------------------+*/
474
/*+--------------------------------------------------------------------------------------------------------+*/
425
// INFO BULLE
475
// INFO BULLE
426
var infoBulleOuverte = false;
476
var infoBulleOuverte = false;
427
function initialiserInfoBulle() {
477
function initialiserInfoBulle() {
428
	google.maps.event.addListener(infoBulle, 'domready', initialiserContenuInfoBulle);
478
	google.maps.event.addListener(infoBulle, 'domready', initialiserContenuInfoBulle);
429
	google.maps.event.addListener(infoBulle, 'closeclick', surFermetureInfoBulle);
479
	google.maps.event.addListener(infoBulle, 'closeclick', surFermetureInfoBulle);
430
	google.maps.event.addListener(infoBulle, 'content_changed', definirLargeurInfoBulle);
480
	google.maps.event.addListener(infoBulle, 'content_changed', definirLargeurInfoBulle);
431
}
481
}
432
 
482
 
433
function surFermetureInfoBulle() {
483
function surFermetureInfoBulle() {
434
	infoBulleOuverte = false;
484
	infoBulleOuverte = false;
435
	programmerRafraichissementCarte();
485
	programmerRafraichissementCarte();
436
}
486
}
437
 
487
 
438
function centrerInfoBulle() {
488
function centrerInfoBulle() {
439
	var limites = map.getBounds();
489
	var limites = map.getBounds();
440
	var centre = limites.getCenter();
490
	var centre = limites.getCenter();
441
	var nordEst = limites.getNorthEast();
491
	var nordEst = limites.getNorthEast();
442
	var centreSudLatLng = new google.maps.LatLng(nordEst.lat(), centre.lng());
492
	var centreSudLatLng = new google.maps.LatLng(nordEst.lat(), centre.lng());
443
	map.panTo(centreSudLatLng);
493
	map.panTo(centreSudLatLng);
444
}
494
}
445
 
495
 
446
function afficherInfoBulle() {
496
function afficherInfoBulle() {
447
	var obsHtml = $("#tpl-obs").html();
497
	var obsHtml = $("#tpl-obs").html();
448
	var largeur = definirLargeurInfoBulle();
498
	var largeur = definirLargeurInfoBulle();
449
	obsHtml = obsHtml.replace(/\{largeur\}/, largeur);
499
	obsHtml = obsHtml.replace(/\{largeur\}/, largeur);
450
	infoBulle.setContent(obsHtml);
500
	infoBulle.setContent(obsHtml);
451
	chargerObs(0, 0);
501
	chargerObs(0, 0);
452
	infoBulleOuverte = true;
502
	infoBulleOuverte = true;
453
}
503
}
454
 
504
 
455
function definirLargeurInfoBulle() {
505
function definirLargeurInfoBulle() {
456
	var largeurViewPort = $(window).width();
506
	var largeurViewPort = $(window).width();
457
	var lageurInfoBulle = null;
507
	var lageurInfoBulle = null;
458
	if (largeurViewPort < 800) {
508
	if (largeurViewPort < 800) {
459
		largeurInfoBulle = 400;
509
		largeurInfoBulle = 400;
460
	} else if (largeurViewPort >= 800 && largeurViewPort < 1200) {
510
	} else if (largeurViewPort >= 800 && largeurViewPort < 1200) {
461
		largeurInfoBulle = 500;
511
		largeurInfoBulle = 500;
462
	} else if (largeurViewPort >= 1200) {
512
	} else if (largeurViewPort >= 1200) {
463
		largeurInfoBulle = 600;
513
		largeurInfoBulle = 600;
464
	}
514
	}
465
	return largeurInfoBulle;
515
	return largeurInfoBulle;
466
}
516
}
467
 
517
 
468
function afficherMessageChargement(element) {
518
function afficherMessageChargement(element) {
469
	if ($('#chargement').get() == '') {
519
	if ($('#chargement').get() == '') {
470
		$('#tpl-chargement').tmpl().appendTo(element);
520
		$('#tpl-chargement').tmpl().appendTo(element);
471
	}
521
	}
472
}
522
}
473
 
523
 
474
function afficherMessageChargementTitreInfoBulle() {
524
function afficherMessageChargementTitreInfoBulle() {
475
	$("#obs-station-titre").text("Chargement des observations");	
525
	$("#obs-station-titre").text("Chargement des observations");	
476
}
526
}
477
 
527
 
478
function supprimerMessageChargement() {
528
function supprimerMessageChargement() {
479
	$('#chargement').remove();
529
	$('#chargement').remove();
480
}
530
}
481
 
531
 
482
function chargerObs(depart, total) {
532
function chargerObs(depart, total) {
483
	if (depart == 0 || depart < total) {
533
	if (depart == 0 || depart < total) {
484
		var limite = 300;
534
		var limite = 300;
485
		if (depart == 0) {
535
		if (depart == 0) {
486
			viderTableauObs();
536
			viderTableauObs();
487
		}
537
		}
488
		
538
		
489
		var urlObs = observationsUrl+'&start={start}&limit='+limite;
539
		var urlObs = observationsUrl+'&start={start}&limit='+limite;
490
		urlObs = urlObs.replace(/\{stationId\}/g, encodeURIComponent(pointClique.stationInfos.id));
540
		urlObs = urlObs.replace(/\{stationId\}/g, encodeURIComponent(pointClique.stationInfos.id));
491
		if (pointClique.stationInfos.type_emplacement == 'communes') {
541
		if (pointClique.stationInfos.type_emplacement == 'communes') {
492
			urlObs = urlObs.replace(/commune=%2A/g, formaterParametreCommunePourRequete(pointClique.stationInfos.nom));
542
			urlObs = urlObs.replace(/commune=%2A/g, formaterParametreCommunePourRequete(pointClique.stationInfos.nom));
493
		}
543
		}
494
		urlObs = urlObs.replace(/\{nt\}/g, nt);
544
		urlObs = urlObs.replace(/\{nt\}/g, nt);
495
		urlObs = urlObs.replace(/\{start\}/g, depart);
545
		urlObs = urlObs.replace(/\{start\}/g, depart);
496
		
546
		
497
		$.getJSON(urlObs, function(observations){
547
		$.getJSON(urlObs, function(observations){
498
			surRetourChargementObs(observations, depart, total);
548
			surRetourChargementObs(observations, depart, total);
499
			chargerObs(depart+limite, observations.total);
549
			chargerObs(depart+limite, observations.total);
500
		});
550
		});
501
	}
551
	}
502
}
552
}
503
 
553
 
504
function formaterParametreCommunePourRequete(nomCommune) {
554
function formaterParametreCommunePourRequete(nomCommune) {
505
	var chaineRequete = "";
555
	var chaineRequete = "";
506
	if(nomCommune.indexOf("(", 0) !== false) {
556
	if(nomCommune.indexOf("(", 0) !== false) {
507
		var infosCommune = nomCommune.split("(");
557
		var infosCommune = nomCommune.split("(");
508
		var commune = infosCommune[0];
558
		var commune = infosCommune[0];
509
		chaineRequete = 'commune='+encodeURIComponent($.trim(commune));
559
		chaineRequete = 'commune='+encodeURIComponent($.trim(commune));
510
	} else {
560
	} else {
511
		chaineRequete = 'commune='+encodeURIComponent($.trim(nomCommune));
561
		chaineRequete = 'commune='+encodeURIComponent($.trim(nomCommune));
512
	}
562
	}
513
	return chaineRequete;
563
	return chaineRequete;
514
}
564
}
515
 
565
 
516
function viderTableauObs() {
566
function viderTableauObs() {
517
	obsStation = new Array();	
567
	obsStation = new Array();	
518
	surClicPagePagination(0, null);
568
	surClicPagePagination(0, null);
519
}
569
}
520
 
570
 
521
function surRetourChargementObs(observations, depart, total) {
571
function surRetourChargementObs(observations, depart, total) {
522
	obsStation = obsStation.concat(observations.observations);
572
	obsStation = obsStation.concat(observations.observations);
523
	if (depart == 0) {
573
	if (depart == 0) {
524
		actualiserInfosStation(observations);
574
		actualiserInfosStation(observations);
525
		creerTitreInfoBulle();
575
		creerTitreInfoBulle();
526
		surClicPagePagination(0, null);	
576
		surClicPagePagination(0, null);	
527
	}
577
	}
528
	
578
	
529
	afficherPagination();
579
	afficherPagination();
530
	actualiserPagineur();
580
	actualiserPagineur();
531
	selectionnerOnglet("#obs-vue-"+pagineur.format);
581
	selectionnerOnglet("#obs-vue-"+pagineur.format);
532
}
582
}
533
 
583
 
534
function actualiserInfosStation(infos) {
584
function actualiserInfosStation(infos) {
535
	pointClique.stationInfos.commune = infos.commune;
585
	pointClique.stationInfos.commune = infos.commune;
536
	pointClique.stationInfos.obsNbre = infos.total;
586
	pointClique.stationInfos.obsNbre = infos.total;
537
}
587
}
538
 
588
 
539
function creerTitreInfoBulle() {
589
function creerTitreInfoBulle() {
540
	$("#obs-total").text(station.obsNbre);
590
	$("#obs-total").text(station.obsNbre);
541
	$("#obs-commune").text(station.commune);
591
	$("#obs-commune").text(station.commune);
542
	var titre = '';
592
	var titre = '';
543
	titre += pointClique.stationInfos.obsNbre+' observation';
593
	titre += pointClique.stationInfos.obsNbre+' observation';
544
	titre += (pointClique.stationInfos.obsNbre > 1) ? 's': '' ;
594
	titre += (pointClique.stationInfos.obsNbre > 1) ? 's': '' ;
545
	titre += ' pour ';
595
	titre += ' pour ';
546
	if (etreMarqueurCommune(pointClique.stationInfos.id)) {
596
	if (etreMarqueurCommune(pointClique.stationInfos.id)) {
547
		nomStation = 'la commune : ';
597
		nomStation = 'la commune : ';
548
	} else {
598
	} else {
549
		nomStation = 'la station : ';
599
		nomStation = 'la station : ';
550
	}
600
	}
551
	titre += pointClique.stationInfos.nom;
601
	titre += pointClique.stationInfos.nom;
552
	$("#obs-station-titre").text(titre);	
602
	$("#obs-station-titre").text(titre);	
553
}
603
}
554
 
604
 
555
function actualiserPagineur() {
605
function actualiserPagineur() {
556
	pagineur.stationId = pointClique.stationInfos.id;
606
	pagineur.stationId = pointClique.stationInfos.id;
557
	pagineur.total = pointClique.stationInfos.obsNbre;
607
	pagineur.total = pointClique.stationInfos.obsNbre;
558
	// Si on est en mode photo on reste en mode liste quelque soit le 
608
	// Si on est en mode photo on reste en mode liste quelque soit le 
559
	// nombre de résultats
609
	// nombre de résultats
560
	if (pagineur.total > 4 && photos_seulement != 1) {
610
	if (pagineur.total > 4 && photos != 1) {
561
		pagineur.format = 'tableau';
611
		pagineur.format = 'tableau';
562
	} else {
612
	} else {
563
		pagineur.format = 'liste';
613
		pagineur.format = 'liste';
564
	}
614
	}
565
}
615
}
566
 
616
 
567
function afficherPagination(observations) {
617
function afficherPagination(observations) {
568
	$(".navigation").pagination(pagineur.total, {
618
	$(".navigation").pagination(pagineur.total, {
569
		items_per_page:pagineur.limite,
619
		items_per_page:pagineur.limite,
570
		callback:surClicPagePagination,
620
		callback:surClicPagePagination,
571
		next_text:'Suivant',
621
		next_text:'Suivant',
572
		prev_text:'Précédent',
622
		prev_text:'Précédent',
573
		prev_show_always:false,
623
		prev_show_always:false,
574
		num_edge_entries:1,
624
		num_edge_entries:1,
575
		num_display_entries:4,
625
		num_display_entries:4,
576
		load_first_page:true
626
		load_first_page:true
577
	});
627
	});
578
}
628
}
579
 
629
 
580
function surClicPagePagination(pageIndex, paginationConteneur) {
630
function surClicPagePagination(pageIndex, paginationConteneur) {
581
	var index = pageIndex * pagineur.limite;
631
	var index = pageIndex * pagineur.limite;
582
	var indexMax = index + pagineur.limite;
632
	var indexMax = index + pagineur.limite;
583
	pagineur.depart = index;
633
	pagineur.depart = index;
584
	obsPage = new Array();
634
	obsPage = new Array();
585
    for(index; index < indexMax; index++) {
635
    for(index; index < indexMax; index++) {
586
    	obsPage.push(obsStation[index]);
636
    	obsPage.push(obsStation[index]);
587
    }
637
    }
588
    
638
    
589
    supprimerMessageChargement();
639
    supprimerMessageChargement();
590
    mettreAJourObservations();
640
    mettreAJourObservations();
591
	return false;
641
	return false;
592
}
642
}
593
 
643
 
594
function mettreAJourObservations() {
644
function mettreAJourObservations() {
595
	$("#obs-"+pagineur.format+"-lignes").empty();
645
	$("#obs-"+pagineur.format+"-lignes").empty();
596
   	$("#obs-vue-"+pagineur.format).css('display', 'block');
646
   	$("#obs-vue-"+pagineur.format).css('display', 'block');
597
   	$(".obs-conteneur").css('counter-reset', 'item '+pagineur.depart);
647
   	$(".obs-conteneur").css('counter-reset', 'item '+pagineur.depart);
598
	$("#tpl-obs-"+pagineur.format).tmpl(obsPage).appendTo("#obs-"+pagineur.format+"-lignes");
648
	$("#tpl-obs-"+pagineur.format).tmpl(obsPage).appendTo("#obs-"+pagineur.format+"-lignes");
599
	
649
	
600
	// Actualisation de Fancybox
650
	// Actualisation de Fancybox
601
	ajouterFormulaireContact("a.contact");
651
	ajouterFormulaireContact("a.contact");
602
	if (pagineur.format == 'liste') {
652
	if (pagineur.format == 'liste') {
603
		ajouterGaleriePhoto("a.cel-img");
653
		ajouterGaleriePhoto("a.cel-img");
604
	}
654
	}
605
}
655
}
606
 
656
 
607
function initialiserContenuInfoBulle() {
657
function initialiserContenuInfoBulle() {
608
	afficherMessageChargement('#observations');
658
	afficherMessageChargement('#observations');
609
	cacherContenuOnglets();
659
	cacherContenuOnglets();
610
	afficherOnglets();
660
	afficherOnglets();
611
	ajouterTableauTriable("#obs-tableau");
661
	ajouterTableauTriable("#obs-tableau");
612
	afficherTextStationId();
662
	afficherTextStationId();
613
	corrigerLargeurInfoWindow();
663
	corrigerLargeurInfoWindow();
614
}
664
}
615
 
665
 
616
function cacherContenuOnglets() {
666
function cacherContenuOnglets() {
617
	$("#obs-vue-tableau").css("display", "none");
667
	$("#obs-vue-tableau").css("display", "none");
618
	$("#obs-vue-liste").css("display", "none");
668
	$("#obs-vue-liste").css("display", "none");
619
}
669
}
620
 
670
 
621
function afficherOnglets() {
671
function afficherOnglets() {
622
	var $tabs = $('#obs').tabs();
672
	var $tabs = $('#obs').tabs();
623
	$('#obs').bind('tabsselect', function(event, ui) {
673
	$('#obs').bind('tabsselect', function(event, ui) {
624
		if (ui.panel.id == 'obs-vue-tableau') {
674
		if (ui.panel.id == 'obs-vue-tableau') {
625
			surClicAffichageTableau();
675
			surClicAffichageTableau();
626
		} else if (ui.panel.id == 'obs-vue-liste') {
676
		} else if (ui.panel.id == 'obs-vue-liste') {
627
			surClicAffichageListe();
677
			surClicAffichageListe();
628
		}
678
		}
629
	});
679
	});
630
	if (pointClique.stationInfos.nbre > 4) {
680
	if (pointClique.stationInfos.nbre > 4) {
631
		$tabs.tabs('select', "#obs-vue-tableau");
681
		$tabs.tabs('select', "#obs-vue-tableau");
632
	} else {
682
	} else {
633
		$tabs.tabs('select', "#obs-vue-liste");
683
		$tabs.tabs('select', "#obs-vue-liste");
634
	}
684
	}
635
	
685
	
636
}
686
}
637
 
687
 
638
function selectionnerOnglet(onglet) {
688
function selectionnerOnglet(onglet) {
639
	$(onglet).css('display', 'block');
689
	$(onglet).css('display', 'block');
640
	$('#obs').tabs('select', onglet);
690
	$('#obs').tabs('select', onglet);
641
}
691
}
642
 
692
 
643
function afficherTextStationId() {
693
function afficherTextStationId() {
644
	$('#obs-station-id').text(pointClique.stationInfos.id);
694
	$('#obs-station-id').text(pointClique.stationInfos.id);
645
}
695
}
646
 
696
 
647
function corrigerLargeurInfoWindow() {
697
function corrigerLargeurInfoWindow() {
648
	$("#info-bulle").width($("#info-bulle").width() - 17);
698
	$("#info-bulle").width($("#info-bulle").width() - 17);
649
}
699
}
650
 
700
 
651
function surClicAffichageTableau(event) {
701
function surClicAffichageTableau(event) {
652
	pagineur.format = 'tableau';
702
	pagineur.format = 'tableau';
653
	mettreAJourObservations();
703
	mettreAJourObservations();
654
	mettreAJourTableauTriable("#obs-tableau");
704
	mettreAJourTableauTriable("#obs-tableau");
655
}
705
}
656
 
706
 
657
function surClicAffichageListe(event) {
707
function surClicAffichageListe(event) {
658
	pagineur.format = 'liste';
708
	pagineur.format = 'liste';
659
	mettreAJourObservations();
709
	mettreAJourObservations();
660
	ajouterGaleriePhoto("a.cel-img");
710
	ajouterGaleriePhoto("a.cel-img");
661
}
711
}
662
 
712
 
663
function ajouterTableauTriable(element) {
713
function ajouterTableauTriable(element) {
664
	// add parser through the tablesorter addParser method 
714
	// add parser through the tablesorter addParser method 
665
	$.tablesorter.addParser({ 
715
	$.tablesorter.addParser({ 
666
		// Définition d'un id unique pour ce parsseur 
716
		// Définition d'un id unique pour ce parsseur 
667
		id: 'date_cel', 
717
		id: 'date_cel', 
668
		is: function(s) { 
718
		is: function(s) { 
669
			// doit retourner false si le parsseur n'est pas autodétecté
719
			// doit retourner false si le parsseur n'est pas autodétecté
670
			return /^\s*\d{2}[\/-]\d{2}[\/-]\d{4}\s*$/.test(s);
720
			return /^\s*\d{2}[\/-]\d{2}[\/-]\d{4}\s*$/.test(s);
671
		}, 
721
		}, 
672
		format: function(date) { 
722
		format: function(date) { 
673
			// Transformation date jj/mm/aaaa en aaaa/mm/jj
723
			// Transformation date jj/mm/aaaa en aaaa/mm/jj
674
			date = date.replace(/^\s*(\d{2})[\/-](\d{2})[\/-](\d{4})\s*$/, "$3/$2/$1");
724
			date = date.replace(/^\s*(\d{2})[\/-](\d{2})[\/-](\d{4})\s*$/, "$3/$2/$1");
675
			// Remplace la date par un nombre de millisecondes pour trier numériquement
725
			// Remplace la date par un nombre de millisecondes pour trier numériquement
676
			return $.tablesorter.formatFloat(new Date(date).getTime());
726
			return $.tablesorter.formatFloat(new Date(date).getTime());
677
		}, 
727
		}, 
678
		// set type, either numeric or text 
728
		// set type, either numeric or text 
679
		type: 'numeric' 
729
		type: 'numeric' 
680
	});
730
	});
681
	$(element).tablesorter({ 
731
	$(element).tablesorter({ 
682
        headers: { 
732
        headers: { 
683
			1: { 
733
			1: { 
684
            	sorter:'date_cel' 
734
            	sorter:'date_cel' 
685
        	} 
735
        	} 
686
    	} 
736
    	} 
687
	});
737
	});
688
}
738
}
689
 
739
 
690
function mettreAJourTableauTriable(element) {
740
function mettreAJourTableauTriable(element) {
691
	$(element).trigger('update');
741
	$(element).trigger('update');
692
}
742
}
693
 
743
 
694
function ajouterGaleriePhoto(element) {
744
function ajouterGaleriePhoto(element) {
695
	$(element).fancybox({
745
	$(element).fancybox({
696
		transitionIn:'elastic',
746
		transitionIn:'elastic',
697
		transitionOut:'elastic',
747
		transitionOut:'elastic',
698
		speedIn	:600, 
748
		speedIn	:600, 
699
		speedOut:200,
749
		speedOut:200,
700
		overlayShow:true,
750
		overlayShow:true,
701
		titleShow:true,
751
		titleShow:true,
702
		titlePosition:'inside',
752
		titlePosition:'inside',
703
		titleFormat:function (titre, currentArray, currentIndex, currentOpts) {
753
		titleFormat:function (titre, currentArray, currentIndex, currentOpts) {
704
			var motif = /urn:lsid:tela-botanica[.]org:cel:img([0-9]+)$/;
754
			var motif = /urn:lsid:tela-botanica[.]org:cel:img([0-9]+)$/;
705
			motif.exec(titre);
755
			motif.exec(titre);
706
			var id = RegExp.$1;
756
			var id = RegExp.$1;
707
			var info = $('#cel-info-'+id).clone().html();
757
			var info = $('#cel-info-'+id).clone().html();
708
			var tpl = 
758
			var tpl = 
709
				'<div class="cel-legende">'+
759
				'<div class="cel-legende">'+
710
				'<p class="cel-legende-vei">'+'Image n°' + (currentIndex + 1) + ' sur ' + currentArray.length +'<\/p>'+	
760
				'<p class="cel-legende-vei">'+'Image n°' + (currentIndex + 1) + ' sur ' + currentArray.length +'<\/p>'+	
711
				(titre && titre.length ? '<p>'+info+'<\/p>' : '' )+
761
				(titre && titre.length ? '<p>'+info+'<\/p>' : '' )+
712
				'<\/div>';
762
				'<\/div>';
713
			return tpl;
763
			return tpl;
714
		}
764
		}
715
	}).live('click', function(e) {
765
	}).live('click', function(e) {
716
		if (e.stopPropagation) {
766
		if (e.stopPropagation) {
717
			e.stopPropagation();
767
			e.stopPropagation();
718
		}
768
		}
719
		return false;
769
		return false;
720
	});
770
	});
721
}
771
}
722
 
772
 
723
function ajouterFormulaireContact(element) {
773
function ajouterFormulaireContact(element) {
724
	$(element).fancybox({
774
	$(element).fancybox({
725
		transitionIn:'elastic',
775
		transitionIn:'elastic',
726
		transitionOut:'elastic',
776
		transitionOut:'elastic',
727
		speedIn	:600, 
777
		speedIn	:600, 
728
		speedOut:200,
778
		speedOut:200,
729
		scrolling: 'no',
779
		scrolling: 'no',
730
		titleShow: false,
780
		titleShow: false,
731
		onStart: function(selectedArray, selectedIndex, selectedOpts) {
781
		onStart: function(selectedArray, selectedIndex, selectedOpts) {
732
			var element = selectedArray[selectedIndex];
782
			var element = selectedArray[selectedIndex];
733
 
783
 
734
			var motif = / contributeur-([0-9]+)$/;
784
			var motif = / contributeur-([0-9]+)$/;
735
			motif.exec($(element).attr('class'));
785
			motif.exec($(element).attr('class'));
736
			var id = RegExp.$1;
786
			var id = RegExp.$1;
737
			//console.log('Destinataire id : '+id);
787
			//console.log('Destinataire id : '+id);
738
			$("#fc_destinataire_id").attr('value', id);
788
			$("#fc_destinataire_id").attr('value', id);
739
		
789
		
740
			var motif = / obs-([0-9]+) /;
790
			var motif = / obs-([0-9]+) /;
741
			motif.exec($(element).attr('class'));
791
			motif.exec($(element).attr('class'));
742
			var id = RegExp.$1;
792
			var id = RegExp.$1;
743
			//console.log('Obs id : '+id);
793
			//console.log('Obs id : '+id);
744
			chargerInfoObsPourMessage(id);
794
			chargerInfoObsPourMessage(id);
745
		},
795
		},
746
		onCleanup: function() {
796
		onCleanup: function() {
747
			//console.log('Avant fermeture fancybox');
797
			//console.log('Avant fermeture fancybox');
748
			$("#fc_destinataire_id").attr('value', '');
798
			$("#fc_destinataire_id").attr('value', '');
749
			$("#fc_sujet").attr('value', '');
799
			$("#fc_sujet").attr('value', '');
750
			$("#fc_message").text('');
800
			$("#fc_message").text('');
751
		},
801
		},
752
		onClosed: function(e) {
802
		onClosed: function(e) {
753
			//console.log('Fermeture fancybox');
803
			//console.log('Fermeture fancybox');
754
			if (e.stopPropagation) {
804
			if (e.stopPropagation) {
755
				e.stopPropagation();
805
				e.stopPropagation();
756
			}
806
			}
757
			return false;
807
			return false;
758
		}
808
		}
759
	});
809
	});
760
}
810
}
761
 
811
 
762
function chargerInfoObsPourMessage(idObs) {
812
function chargerInfoObsPourMessage(idObs) {
763
	var nomSci = jQuery.trim($(".cel-obs-"+idObs+" .nom-sci:eq(0)").text());
813
	var nomSci = jQuery.trim($(".cel-obs-"+idObs+" .nom-sci:eq(0)").text());
764
	var date = jQuery.trim($(".cel-obs-"+idObs+" .date:eq(0)").text());
814
	var date = jQuery.trim($(".cel-obs-"+idObs+" .date:eq(0)").text());
765
	var lieu = jQuery.trim($(".cel-obs-"+idObs+" .lieu:eq(0)").text());
815
	var lieu = jQuery.trim($(".cel-obs-"+idObs+" .lieu:eq(0)").text());
766
	var sujet = "Observation #"+idObs+" de "+nomSci;
816
	var sujet = "Observation #"+idObs+" de "+nomSci;
767
	var message = "\n\n\n\n\n\n\n\n--\nConcerne l'observation de \""+nomSci+'" du "'+date+'" au lieu "'+lieu+'".';
817
	var message = "\n\n\n\n\n\n\n\n--\nConcerne l'observation de \""+nomSci+'" du "'+date+'" au lieu "'+lieu+'".';
768
	$("#fc_sujet").attr('value', sujet);
818
	$("#fc_sujet").attr('value', sujet);
769
	$("#fc_message").text(message);
819
	$("#fc_message").text(message);
770
}
820
}
771
 
821
 
772
function initialiserFormulaireContact() {
822
function initialiserFormulaireContact() {
773
	//console.log('Initialisation du form contact');
823
	//console.log('Initialisation du form contact');
774
	$("#form-contact").validate({
824
	$("#form-contact").validate({
775
		rules: {
825
		rules: {
776
			fc_sujet : "required",
826
			fc_sujet : "required",
777
			fc_message : "required",
827
			fc_message : "required",
778
			fc_utilisateur_courriel : {
828
			fc_utilisateur_courriel : {
779
				required : true,
829
				required : true,
780
				email : true}
830
				email : true}
781
		}
831
		}
782
	});
832
	});
783
	$("#form-contact").bind("submit", envoyerCourriel);
833
	$("#form-contact").bind("submit", envoyerCourriel);
784
	$("#fc_annuler").bind("click", function() {$.fancybox.close();});
834
	$("#fc_annuler").bind("click", function() {$.fancybox.close();});
785
	
835
	
786
}
836
}
787
 
837
 
788
function envoyerCourriel() {
838
function envoyerCourriel() {
789
	//console.log('Formulaire soumis');
839
	//console.log('Formulaire soumis');
790
	if ($("#form-contact").valid()) {
840
	if ($("#form-contact").valid()) {
791
		//console.log('Formulaire valide');
841
		//console.log('Formulaire valide');
792
		//$.fancybox.showActivity();
842
		//$.fancybox.showActivity();
793
		var destinataireId = $("#fc_destinataire_id").attr('value');
843
		var destinataireId = $("#fc_destinataire_id").attr('value');
794
		var urlMessage = "http://www.tela-botanica.org/service:annuaire:Utilisateur/"+destinataireId+"/message"
844
		var urlMessage = "http://www.tela-botanica.org/service:annuaire:Utilisateur/"+destinataireId+"/message"
795
		var erreurMsg = "";
845
		var erreurMsg = "";
796
		var donnees = new Array();
846
		var donnees = new Array();
797
		$.each($(this).serializeArray(), function (index, champ) {
847
		$.each($(this).serializeArray(), function (index, champ) {
798
			var cle = champ.name;
848
			var cle = champ.name;
799
			cle = cle.replace(/^fc_/, '');
849
			cle = cle.replace(/^fc_/, '');
800
			
850
			
801
			if (cle == 'sujet') {
851
			if (cle == 'sujet') {
802
				champ.value += " - Carnet en ligne - Tela Botanica";
852
				champ.value += " - Carnet en ligne - Tela Botanica";
803
			}
853
			}
804
			if (cle == 'message') {
854
			if (cle == 'message') {
805
				champ.value += "\n--\n"+
855
				champ.value += "\n--\n"+
806
					"Ce message vous est envoyé par l'intermédiaire du widget carto "+
856
					"Ce message vous est envoyé par l'intermédiaire du widget carto "+
807
					"du Carnet en Ligne du réseau Tela Botanica.\n"+
857
					"du Carnet en Ligne du réseau Tela Botanica.\n"+
808
					"http://www.tela-botanica.org/widget:cel:carto";
858
					"http://www.tela-botanica.org/widget:cel:carto";
809
			}
859
			}
810
			
860
			
811
			donnees[index] = {'name':cle,'value':champ.value};
861
			donnees[index] = {'name':cle,'value':champ.value};
812
		});
862
		});
813
		$.ajax({
863
		$.ajax({
814
			type : "POST",
864
			type : "POST",
815
			cache : false,
865
			cache : false,
816
			url : urlMessage,
866
			url : urlMessage,
817
			data : donnees,
867
			data : donnees,
818
			beforeSend : function() {
868
			beforeSend : function() {
819
				$(".msg").remove();
869
				$(".msg").remove();
820
			},
870
			},
821
			success : function(data) {
871
			success : function(data) {
822
				$("#fc-zone-dialogue").append('<pre class="msg info">'+data.message+'</pre>');
872
				$("#fc-zone-dialogue").append('<pre class="msg info">'+data.message+'</pre>');
823
			},
873
			},
824
			error : function(jqXHR, textStatus, errorThrown) {
874
			error : function(jqXHR, textStatus, errorThrown) {
825
				erreurMsg += "Erreur Ajax :\ntype : "+textStatus+' '+errorThrown+"\n";
875
				erreurMsg += "Erreur Ajax :\ntype : "+textStatus+' '+errorThrown+"\n";
826
				reponse = jQuery.parseJSON(jqXHR.responseText);
876
				reponse = jQuery.parseJSON(jqXHR.responseText);
827
				if (reponse != null) {
877
				if (reponse != null) {
828
					$.each(reponse, function (cle, valeur) {
878
					$.each(reponse, function (cle, valeur) {
829
						erreurMsg += valeur + "\n";
879
						erreurMsg += valeur + "\n";
830
					});
880
					});
831
				}				
881
				}				
832
			},
882
			},
833
			complete : function(jqXHR, textStatus) {
883
			complete : function(jqXHR, textStatus) {
834
				var debugMsg = '';
884
				var debugMsg = '';
835
				if (jqXHR.getResponseHeader("X-DebugJrest-Data") != '') {
885
				if (jqXHR.getResponseHeader("X-DebugJrest-Data") != '') {
836
					debugInfos = jQuery.parseJSON(jqXHR.getResponseHeader("X-DebugJrest-Data"));
886
					debugInfos = jQuery.parseJSON(jqXHR.getResponseHeader("X-DebugJrest-Data"));
837
					if (debugInfos != null) {
887
					if (debugInfos != null) {
838
						$.each(debugInfos, function (cle, valeur) {
888
						$.each(debugInfos, function (cle, valeur) {
839
							debugMsg += valeur + "\n";
889
							debugMsg += valeur + "\n";
840
						});
890
						});
841
					}
891
					}
842
				}
892
				}
843
				if (erreurMsg != '') {
893
				if (erreurMsg != '') {
844
					$("#fc-zone-dialogue").append('<p class="msg">'+
894
					$("#fc-zone-dialogue").append('<p class="msg">'+
845
							'Une erreur est survenue lors de la transmission de votre message.'+'<br />'+
895
							'Une erreur est survenue lors de la transmission de votre message.'+'<br />'+
846
							'Vous pouvez signaler le disfonctionnement à <a href="'+
896
							'Vous pouvez signaler le disfonctionnement à <a href="'+
847
							'mailto:cel@tela-botanica.org'+'?'+
897
							'mailto:cel@tela-botanica.org'+'?'+
848
							'subject=Disfonctionnement du widget carto'+
898
							'subject=Disfonctionnement du widget carto'+
849
							"&body="+erreurMsg+"\nDébogage :\n"+debugMsg+
899
							"&body="+erreurMsg+"\nDébogage :\n"+debugMsg+
850
							'">cel@tela-botanica.org</a>.'+
900
							'">cel@tela-botanica.org</a>.'+
851
							'</p>');
901
							'</p>');
852
				}
902
				}
853
				if (DEBUG) {
903
				if (DEBUG) {
854
					console.log('Débogage : '+debugMsg);
904
					console.log('Débogage : '+debugMsg);
855
				}
905
				}
856
				//console.log('Débogage : '+debugMsg);
906
				//console.log('Débogage : '+debugMsg);
857
				//console.log('Erreur : '+erreurMsg);
907
				//console.log('Erreur : '+erreurMsg);
858
			}
908
			}
859
		});
909
		});
860
	}
910
	}
861
	return false;
911
	return false;
862
}
912
}
863
/*+--------------------------------------------------------------------------------------------------------+*/
913
/*+--------------------------------------------------------------------------------------------------------+*/
864
// PANNEAU LATÉRAL
914
// PANNEAU LATÉRAL
865
 
915
 
866
function initialiserAffichagePanneauLateral() {
-
 
867
	$('#panneau-lateral').height($(window).height() - 35);
-
 
868
	
916
function initialiserAffichagePanneauLateral() {	
869
	if (nt == '*') {
917
	if (nt == '*') {
870
		$('#pl-ouverture').bind('click', afficherPanneauLateral);
918
		$('#pl-ouverture').bind('click', afficherPanneauLateral);
871
		$('#pl-fermeture').bind('click', cacherPanneauLateral);
919
		$('#pl-fermeture').bind('click', cacherPanneauLateral);
872
	} else {
920
	} else {
873
		$('#panneau-lateral').width(0);
921
		$('#panneau-lateral').width(0);
874
		$('#carte').width('100%');
922
		$('#carte').width('100%');
875
	}
923
	}
876
	chargerTaxons(0, 0);
924
	chargerTaxons(0, 0);
877
}
925
}
878
 
926
 
879
function chargerTaxons(depart, total) {
927
function chargerTaxons(depart, total) {
880
	if (depart == 0 || depart < total) {
928
	if (depart == 0 || depart < total) {
881
		var limite = 7000;
929
		var limite = 7000;
882
		//console.log("Chargement des taxons de "+depart+" à "+(depart+limite));
930
		//console.log("Chargement des taxons de "+depart+" à "+(depart+limite));
883
		var urlTax = taxonsUrl+'&start={start}&limit='+limite;
931
		var urlTax = taxonsUrl+'&start={start}&limit='+limite;
884
		urlTax = urlTax.replace(/\{start\}/g, depart);
932
		urlTax = urlTax.replace(/\{start\}/g, depart);
885
		$.getJSON(urlTax, function(infos) {
933
		$.getJSON(urlTax, function(infos) {
886
			taxonsCarte = taxonsCarte.concat(infos.taxons);
934
			taxonsCarte = taxonsCarte.concat(infos.taxons);
887
			//console.log("Nbre taxons :"+taxonsCarte.length);
935
			//console.log("Nbre taxons :"+taxonsCarte.length);
888
			chargerTaxons(depart+limite, infos.total);
936
			chargerTaxons(depart+limite, infos.total);
889
		});
937
		});
890
	} else {
938
	} else {
891
		if (nt == '*') {
939
		if (nt == '*') {
892
			afficherTaxons();
940
			afficherTaxons();
893
		}
941
		}
894
		afficherTitreCarte();
942
		afficherTitreCarteEtStats();
895
	}
943
	}
896
}
944
}
897
 
945
 
898
function afficherTaxons() {
946
function afficherTaxons() {
899
	$(".plantes-nbre").text(taxonsCarte.length);
947
	$(".plantes-nbre").text(taxonsCarte.length);
900
	$("#tpl-taxons-liste").tmpl({'taxons':taxonsCarte}).appendTo("#pl-corps");
948
	$("#tpl-taxons-liste").tmpl({'taxons':taxonsCarte}).appendTo("#pl-corps");
901
	$('.taxon').live('click', filtrerParTaxon);
949
	$('.taxon').live('click', filtrerParTaxon);
902
}
950
}
903
 
951
 
904
 
952
 
905
function afficherPanneauLateral() {
953
function afficherPanneauLateral() {
-
 
954
	$('#panneau-lateral').height($(window).height());
906
	$('#panneau-lateral').width(300);
955
	$('#panneau-lateral').width(300);
907
	$('#pl-contenu').css('display', 'block');
956
	$('#pl-contenu').css('display', 'block');
908
	$('#pl-ouverture').css('display', 'none');
957
	$('#pl-ouverture').css('display', 'none');
909
	$('#pl-fermeture').css('display', 'block');
958
	$('#pl-fermeture').css('display', 'block');
910
	$('#carte').css('left', '300px');
959
	$('#panneau-lateral').css("top","0");
911
 
960
 
912
	google.maps.event.trigger(map, 'resize');
961
	google.maps.event.trigger(map, 'resize');
913
};
962
};
914
 
963
 
915
function cacherPanneauLateral() {
964
function cacherPanneauLateral() {
-
 
965
	$('#panneau-lateral').height("60px");
916
	$('#panneau-lateral').width(24);
966
	$('#panneau-lateral').width("83px");
917
	$('#pl-contenu').css('display', 'none');
967
	$('#pl-contenu').css('display', 'none');
918
	$('#pl-ouverture').css('display', 'block');
968
	$('#pl-ouverture').css('display', 'block');
919
	$('#pl-fermeture').css('display', 'none');
969
	$('#pl-fermeture').css('display', 'none');
920
	$('#carte').css('left', '24px');
-
 
921
	
970
	
922
	google.maps.event.trigger(map, 'resize');
971
	google.maps.event.trigger(map, 'resize');
923
};
972
};
924
 
973
 
925
function filtrerParTaxon() {
974
function filtrerParTaxon() {
926
	var ntAFiltrer = $('.nt', this).text();
975
	var ntAFiltrer = $('.nt', this).text();
927
	infoBulle.close();
976
	infoBulle.close();
928
	var zoom = map.getZoom();
977
	var zoom = map.getZoom();
929
	var NELatLng = map.getBounds().getNorthEast().lat()+'|'+map.getBounds().getNorthEast().lng();
978
	var NELatLng = map.getBounds().getNorthEast().lat()+'|'+map.getBounds().getNorthEast().lng();
930
	var SWLatLng = map.getBounds().getSouthWest().lat()+'|'+map.getBounds().getSouthWest().lng();
979
	var SWLatLng = map.getBounds().getSouthWest().lat()+'|'+map.getBounds().getSouthWest().lng();
931
	
980
	
932
	$('#taxon-'+nt).removeClass('taxon-actif');
981
	$('#taxon-'+nt).removeClass('taxon-actif');
933
	if (nt == ntAFiltrer) {
982
	if (nt == ntAFiltrer) {
934
		nt = '*';
983
		nt = '*';
935
		stationsUrl = stationsUrl.replace(/num_taxon=[*0-9]+/, 'num_taxon='+nt);
984
		stationsUrl = stationsUrl.replace(/num_taxon=[*0-9]+/, 'num_taxon='+nt);
936
		chargerMarqueurs(zoom, NELatLng, SWLatLng);
985
		chargerMarqueurs(zoom, NELatLng, SWLatLng);
937
	} else {
986
	} else {
938
		stationsUrl = stationsUrl.replace(/num_taxon=[*0-9]+/, 'num_taxon='+ntAFiltrer);
987
		stationsUrl = stationsUrl.replace(/num_taxon=[*0-9]+/, 'num_taxon='+ntAFiltrer);
939
		url = stationsUrl;
988
		url = stationsUrl;
940
		url += '&zoom='+zoom+
989
		url += '&zoom='+zoom+
941
			'&ne='+NELatLng+
990
			'&ne='+NELatLng+
942
			'&sw='+SWLatLng;
991
			'&sw='+SWLatLng;
943
		requeteChargementPoints = $.getJSON(url, function (stationsFiltrees) {
992
		requeteChargementPoints = $.getJSON(url, function (stationsFiltrees) {
944
			stations = stationsFiltrees;
993
			stations = stationsFiltrees;
945
			nt = ntAFiltrer;
994
			nt = ntAFiltrer;
946
			$('#taxon-'+nt).addClass('taxon-actif');
995
			$('#taxon-'+nt).addClass('taxon-actif');
947
			rafraichirMarqueurs(stations);
996
			rafraichirMarqueurs(stations);
948
		});
997
		});
949
	}
998
	}
950
};
999
};
951
 
1000
 
952
/*+--------------------------------------------------------------------------------------------------------+*/
1001
/*+--------------------------------------------------------------------------------------------------------+*/
953
// FONCTIONS UTILITAIRES
1002
// FONCTIONS UTILITAIRES
954
 
1003
 
955
function ouvrirPopUp(element, nomPopUp, event) {
1004
function ouvrirPopUp(element, nomPopUp, event) {
956
	var options = 
1005
	var options = 
957
		'width=650,'+
1006
		'width=650,'+
958
		'height=600,'+
1007
		'height=600,'+
959
		'scrollbars=yes,'+
1008
		'scrollbars=yes,'+
960
		'directories=no,'+
1009
		'directories=no,'+
961
		'location=no,'+
1010
		'location=no,'+
962
		'menubar=no,'+
1011
		'menubar=no,'+
963
		'status=no,'+
1012
		'status=no,'+
964
		'toolbar=no';
1013
		'toolbar=no';
965
	var popUp = window.open(element.href, nomPopUp, options);
1014
	var popUp = window.open(element.href, nomPopUp, options);
966
	if (window.focus) {
1015
	if (window.focus) {
967
		popUp.focus();
1016
		popUp.focus();
968
	}
1017
	}
969
	return arreter(event);
1018
	return arreter(event);
970
};
1019
};
971
 
1020
 
972
function ouvrirNouvelleFenetre(element, event) {
1021
function ouvrirNouvelleFenetre(element, event) {
973
	window.open(element.href);
1022
	window.open(element.href);
974
	return arreter(event);
1023
	return arreter(event);
975
}
1024
}
976
 
1025
 
977
function arreter(event) {
1026
function arreter(event) {
978
	if (event.stopPropagation) {
1027
	if (event.stopPropagation) {
979
		event.stopPropagation();
1028
		event.stopPropagation();
980
	} else if (window.event) {
1029
	} else if (window.event) {
981
		window.event.cancelBubble = true;
1030
		window.event.cancelBubble = true;
982
	}
1031
	}
983
	if (event.preventDefault) {
1032
	if (event.preventDefault) {
984
		event.preventDefault();
1033
		event.preventDefault();
985
	}
1034
	}
986
	event.returnValue = false;
1035
	event.returnValue = false;
987
	return false;
1036
	return false;
988
}
1037
}
989
 
1038
 
990
/**
1039
/**
991
 * +-------------------------------------+
1040
 * +-------------------------------------+
992
 * Number.prototype.formaterNombre
1041
 * Number.prototype.formaterNombre
993
 * +-------------------------------------+
1042
 * +-------------------------------------+
994
 * Params (facultatifs):
1043
 * Params (facultatifs):
995
 * - Int decimales: nombre de decimales (exemple: 2)
1044
 * - Int decimales: nombre de decimales (exemple: 2)
996
 * - String signe: le signe precedent les decimales (exemple: "," ou ".")
1045
 * - String signe: le signe precedent les decimales (exemple: "," ou ".")
997
 * - String separateurMilliers: comme son nom l'indique
1046
 * - String separateurMilliers: comme son nom l'indique
998
 * Returns:
1047
 * Returns:
999
 * - String chaine formatee
1048
 * - String chaine formatee
1000
 * @author	::mastahbenus::
1049
 * @author	::mastahbenus::
1001
 * @author	Jean-Pascal MILCENT <jpm@tela-botanica.org> : ajout détection auto entier/flotant
1050
 * @author	Jean-Pascal MILCENT <jpm@tela-botanica.org> : ajout détection auto entier/flotant
1002
 * @souce	http://www.javascriptfr.com/codes/FORMATER-NOMBRE-FACON-NUMBER-FORMAT-PHP_40060.aspx
1051
 * @souce	http://www.javascriptfr.com/codes/FORMATER-NOMBRE-FACON-NUMBER-FORMAT-PHP_40060.aspx
1003
 */
1052
 */
1004
Number.prototype.formaterNombre = function (decimales, signe, separateurMilliers) {
1053
Number.prototype.formaterNombre = function (decimales, signe, separateurMilliers) {
1005
	var _sNombre = String(this), i, _sRetour = "", _sDecimales = "";
1054
	var _sNombre = String(this), i, _sRetour = "", _sDecimales = "";
1006
	
1055
	
1007
	function is_int(nbre) {
1056
	function is_int(nbre) {
1008
		nbre = nbre.replace(',', '.');
1057
		nbre = nbre.replace(',', '.');
1009
		return !(parseFloat(nbre)-parseInt(nbre) > 0);
1058
		return !(parseFloat(nbre)-parseInt(nbre) > 0);
1010
	}
1059
	}
1011
 
1060
 
1012
	if (decimales == undefined) {
1061
	if (decimales == undefined) {
1013
		if (is_int(_sNombre)) {
1062
		if (is_int(_sNombre)) {
1014
			decimales = 0;
1063
			decimales = 0;
1015
		} else {
1064
		} else {
1016
			decimales = 2;
1065
			decimales = 2;
1017
		}
1066
		}
1018
	}
1067
	}
1019
	if (signe == undefined) {
1068
	if (signe == undefined) {
1020
		if (is_int(_sNombre)) {
1069
		if (is_int(_sNombre)) {
1021
			signe = '';
1070
			signe = '';
1022
		} else {
1071
		} else {
1023
			signe = '.';
1072
			signe = '.';
1024
		}
1073
		}
1025
	}
1074
	}
1026
	if (separateurMilliers == undefined) {
1075
	if (separateurMilliers == undefined) {
1027
		separateurMilliers = ' ';
1076
		separateurMilliers = ' ';
1028
	}
1077
	}
1029
	
1078
	
1030
	function separeMilliers (sNombre) {
1079
	function separeMilliers (sNombre) {
1031
		var sRetour = "";
1080
		var sRetour = "";
1032
		while (sNombre.length % 3 != 0) {
1081
		while (sNombre.length % 3 != 0) {
1033
			sNombre = "0"+sNombre;
1082
			sNombre = "0"+sNombre;
1034
		}
1083
		}
1035
		for (i = 0; i < sNombre.length; i += 3) {
1084
		for (i = 0; i < sNombre.length; i += 3) {
1036
			if (i == sNombre.length-1) separateurMilliers = '';
1085
			if (i == sNombre.length-1) separateurMilliers = '';
1037
			sRetour += sNombre.substr(i, 3) + separateurMilliers;
1086
			sRetour += sNombre.substr(i, 3) + separateurMilliers;
1038
		}
1087
		}
1039
		while (sRetour.substr(0, 1) == "0") {
1088
		while (sRetour.substr(0, 1) == "0") {
1040
			sRetour = sRetour.substr(1);
1089
			sRetour = sRetour.substr(1);
1041
		}
1090
		}
1042
		return sRetour.substr(0, sRetour.lastIndexOf(separateurMilliers));
1091
		return sRetour.substr(0, sRetour.lastIndexOf(separateurMilliers));
1043
	}
1092
	}
1044
	
1093
	
1045
	if (_sNombre.indexOf('.') == -1) {
1094
	if (_sNombre.indexOf('.') == -1) {
1046
		for (i = 0; i < decimales; i++) {
1095
		for (i = 0; i < decimales; i++) {
1047
			_sDecimales += "0";
1096
			_sDecimales += "0";
1048
		}
1097
		}
1049
		_sRetour = separeMilliers(_sNombre) + signe + _sDecimales;
1098
		_sRetour = separeMilliers(_sNombre) + signe + _sDecimales;
1050
	} else {
1099
	} else {
1051
		var sDecimalesTmp = (_sNombre.substr(_sNombre.indexOf('.')+1));
1100
		var sDecimalesTmp = (_sNombre.substr(_sNombre.indexOf('.')+1));
1052
		if (sDecimalesTmp.length > decimales) {
1101
		if (sDecimalesTmp.length > decimales) {
1053
			var nDecimalesManquantes = sDecimalesTmp.length - decimales;
1102
			var nDecimalesManquantes = sDecimalesTmp.length - decimales;
1054
			var nDiv = 1;
1103
			var nDiv = 1;
1055
			for (i = 0; i < nDecimalesManquantes; i++) {
1104
			for (i = 0; i < nDecimalesManquantes; i++) {
1056
				nDiv *= 10;
1105
				nDiv *= 10;
1057
			}
1106
			}
1058
			_sDecimales = Math.round(Number(sDecimalesTmp) / nDiv);
1107
			_sDecimales = Math.round(Number(sDecimalesTmp) / nDiv);
1059
		}
1108
		}
1060
		_sRetour = separeMilliers(_sNombre.substr(0, _sNombre.indexOf('.')))+String(signe)+_sDecimales;
1109
		_sRetour = separeMilliers(_sNombre.substr(0, _sNombre.indexOf('.')))+String(signe)+_sDecimales;
1061
	}
1110
	}
1062
	return _sRetour;
1111
	return _sRetour;
1063
}
1112
}
1064
 
1113
 
1065
function debug(objet) {
1114
function debug(objet) {
1066
	var msg = '';
1115
	var msg = '';
1067
	if (objet != null) {
1116
	if (objet != null) {
1068
		$.each(objet, function (cle, valeur) {
1117
		$.each(objet, function (cle, valeur) {
1069
			msg += cle+":"+valeur + "\n";
1118
			msg += cle+":"+valeur + "\n";
1070
		});
1119
		});
1071
	} else {
1120
	} else {
1072
		msg = "La variable vaut null.";
1121
		msg = "La variable vaut null.";
1073
	}
1122
	}
1074
	console.log(msg);
1123
	console.log(msg);
1075
}
1124
}