Subversion Repositories eFlore/Applications.cel

Rev

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

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