Subversion Repositories eFlore/Applications.cel

Rev

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

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