/* ACTENGO éUTF8*/
// MICRO PLUGIN
(function($) {
	$.fn.initClass = function( sNewClass) {
		return this.removeClass().addClass( sNewClass);
	};
	$.fn.replaceClass = function( sOldClass, sNewClass) {
		return this.removeClass( sOldClass).addClass( sNewClass);
	};
	$.fn.hasClasses = function( aClasses) {
		var jqT = $(this), bResult = false, i = aClasses.length - 1;
		for( i; i >= 0 && ! bResult; i--) {
			bResult = jqT.hasClass( aClasses[i]);
		}
		return bResult;
	};
	$.fn.check = function(opt) {
		return this.each( function() {
			this.checked = (opt == 'toggle') ? ! this.checked : $is_true(opt, true);
		});
	};
	$.fn.selectionner = function( options) {
		var o = $.extend( {
				multiple: false,
				mode: true
			}, options),
			bMultiple = $is_true(o.multiple, false);

		return this.each( function() {
			var bMode = $is_true(o.mode, true);
			if( bMultiple) {
				this.multiple = true;
			}
			$(this).find('option').each( function() {
				this.selected = ( o.mode == 'toggle' ? !this.selected : bMode);
			});
		});
	};
	$.fn.toVisible = function( b) {
		return this.css({ visibility: $is_true(b, true) ? 'visible' : 'hidden' });
	};
	$.fn.toShow = function( b) {
		return this[ $is_true(b, true) ? 'show' : 'hide']();
	};
	$.fn.zebre = function(sSelecteur, sClass) { /*IE*/
		return ($.browser.msie && $.browser.version < 9) ? this.find( sSelecteur + ':nth-child(even)').addClass( sClass) : this;
	};
	$.fn.annulerkeyEnter = function() { // annule l'effet de la touche (sur onkeydown, up et press)
		return this.on( 'keypress keydown keyup', function(e) {
			if( e.keyCode == 13) {
				if( ! e.preventDefault) {
					e.cancelBubble = true;
					e.returnValue = false;
				} else {
					e.preventDefault();
				}
			}
		});
	};
	$.fn.collisionfenetre = function(e) {
		var d = document, db = d.body;

		return this.each( function() {
			var jqT = $(this),
				w = jqT.outerWidth(),
				h = jqT.outerHeight(),
				clientWidth = d.documentElement.clientWidth,
				clientHeight = d.documentElement.clientHeight,
				iMaxX = ( Math.max(d.documentElement.scrollLeft, db.scrollLeft) + (clientWidth != 0 ? clientWidth : db.clientWidth)),
				iMaxY = ( Math.max(d.documentElement.scrollTop, db.scrollTop) + (clientHeight != 0 ? clientHeight : db.clientHeight)),
				pageX = e.pageX || e.clientX,
				pageY = e.pageY || e.clientY;

			jqT.css({
				left: ( iMaxX < (pageX + w) ? pageX - w : pageX), // bord droit de la fenêtre trop près
				top: ( iMaxY < (pageY + h) ? pageY - h : pageY) // bas de la fenêtre trop près
			});
		});
	};
	$.fn.countCar = function() {
		return this.each( function() {
			var idCpt = this.id + '-maxlength';
			if( $id(idCpt) && ! $.data(this, 'countCar')) {
				this.maxVal = $(this).attr('maxlength');
				this.idCpt = $('#' + idCpt);
				$(this).on('keyup keypress', function() {
					var t = this,
						len = t.value.length,
						s = t.value.replace(/\r\n|\n/g,'--'), // retour chariot = 2car PHP et IE!=FF
						r = s.length - len;
					if( (len + r) > t.maxVal) {
						t.value = t.value.substring(0, t.maxVal - r);
					}
					var iLng = t.maxVal - t.value.length - r;
					t.idCpt.html( ' : ' +
						sprintf(
							pluriel(
								_lg("<strong>%s</strong> caractère restant"),
								_lg("<strong>%s</strong> caractères restants"),
								iLng),
							_lgNombre(iLng)
						)
					);
				}).data('countCar', true).trigger('keyup');
			}
		});
	};
	$.fn.contenuAjax = function( options) {
		// Options
		var o = $.extend( {
			url: '',
			type: 'get',
			data: '',
			dataType: 'html',
			place: 'append',
			loadclass: 'ajaxloading_small',
			timeout: 20000,
			success_function: null,
			success_callback: function(){},
			error_affiche: true,
			error_callback: function(){},
			complete_callback: function(){},
			beforeSend_callback: function(){}
		}, options);

		return this.each( function() {
			$.ajax({
				url: o.url,
				type: o.type,
				data: o.data,
				dataType: o.dataType,
				context: $(this),
				beforeSend : function() {
					this.addClass(o.loadclass);
					o.beforeSend_callback( this);
				},
				error: function(oXhr, sStatus, errorThrown) {
					o.error_affiche && alert( constante( oXhr.status || 'ajaxError'));
					o.error_callback( this, oXhr);
				},
				success: function(data) {
					if( $.isFunction( o.success_function)) {
						o.success_function( data, this);
					} else {
						if( o.place !== null) {
							this[o.place](data);
						}
					}
					o.success_callback(data, this);
				},
				complete: function() {
					this.removeClass(o.loadclass);
					o.complete_callback( this);
				}
			});
		});
	};
})(jQuery);

// Overlabel. En attente de placeholder HTML5 ! pb avec la verif de form, si erreur ne pas re-afficher l'overlabel
(function($) {
	$.fn.overlabel = function( options) {
		var o = $.extend({}, $.fn.overlabel.defaults, options);

		return this.each( function() {
			var jqLabel = $(this),
				id = this.htmlFor || jqLabel.attr('for');

			// Si placeholder est gérer alors pas besoin de js
			if( 'placeholder' in document.createElement('input')) {
				jqLabel.hide();
				return this;
			}

			if( id != '') {
				var JQinput = $('#' + id.replace(/\:/, '\\:'));
			} else {
				return this;
			}

			// si title on change le label
			if( JQinput.attr('title') != '') {
				jqLabel.text( JQinput.attr('title'));
			}
			jqLabel.addClass(o.label_class);

			JQinput
				.focus( function() {
					overFocus( jqLabel);
					$(this).stopTime( 'checkEmpty');
				})
				.blur( function() {
					overBlur( jqLabel, this);
				});

			// init
			overFocus( jqLabel);
			overBlur( jqLabel, JQinput);
		});
	};

	// Privé
	function overFocus( jqLabel) {
		jqLabel.hide();
	}
	function overBlur( jqLabel, oInput) {
		if( oInput.value == '') {
			jqLabel.css({ position: 'absolute', display: 'inline'});
		}
		// fixe autocomplete
		$(oInput).everyTime(500, 'checkEmpty', function() {
			if( this.value == '') {
				jqLabel.css({ position: 'absolute', display: 'inline'});
			} else {
				overFocus( jqLabel);
			}
		});
	}

	// param defaut
	$.fn.overlabel.defaults = {
		label_class: 'overlabel-defaut'
	};
})(jQuery);

// CAPSLOCK
(function($) {
	$.fn.capslock = function( options) {
		var o = $.extend({}, $.fn.capslock.defaults, options),
			jqImg = $('<div class="' + o.classe + '">' + ( o.text || _lg("Attention ! la touche «&nbsp;Verr. Maj&nbsp;» est activée.")) + '</div>')
						.hide()
						.appendTo('body')
						.click( function() { $(this).hide() });

		return this.keypress( function(e) {
			if( ((e.which >= 65 && e.which <=  90) && !e.shiftKey) ||
				((e.which >= 97 && e.which <= 122) && e.shiftKey)) { // majusule, sans shift
				var offset = $(e.target).offset();
				jqImg.css({
					top: offset.top - jqImg.outerHeight() - 20,
					left: offset.left + 2 * ( $(e.target).outerWidth() / 3) - 20
				}).show();
				$(window).one('resize', function() { jqImg.hide(); });
			} else {
				jqImg.hide();
			}
		});
	};

	$.fn.capslock.defaults = {
		classe: 'capslock',
		text: ''
	};
})(jQuery);

// TOGGLE
(function($) {
	$.fn.tog = function( options) {
		var o = $.extend({}, $.fn.tog.defaults, options),
			bCookie = false, aCookie = [];

		if( $defined(o.cookieName) && o.cookieName != '') {
			aCookie = ($.cookie( o.cookieName) || '').split('\.');
			bCookie = true;
		}

		return this.each( function() {
			var jqT = $(this),
				sId = this.id.replace(o.idName + '-', ''),
				bIsCookie = ($.inArray(sId, aCookie) != -1),
				bIsForced = ($.inArray(sId, o.forceId) != -1),
				oPanel = (o.idPanel == '' ? jqT.next() : $('#' + o.idPanel + '-' + this.id));

			// Init
			if( (o.openStart && !bIsCookie && !bIsForced) || (!o.openStart && (bIsCookie || bIsForced))) {
				jqT.addClass(o.classOpen);
				oPanel.show();
			} else {
				jqT.addClass(o.classClose);
				oPanel.hide();
			}
			// ajout le forceid en cookie si non stocké
			if( bCookie && bIsForced && sId + '' != '') {
				var iPos;
				if( (iPos = $.inArray(sId, aCookie)) == -1) {
					aCookie.push(sId);
					$.cookie( o.cookieName, aCookie.join('.'), {expires: 365});
				}
			}

			jqT.click( function(e) {
				e.preventDefault();
				var t = $(this),
					sId = this.id.replace(o.idName + '-', ''),
					oPanel = (o.idPanel == '' ? t.next() : $('#' + o.idPanel + '-' + this.id));

				if( o.animation != '') {
					oPanel.slideToggle(o.animation);
				} else {
					oPanel.toggle();
				}
				if( t.hasClass(o.classOpen)) {
					t.replaceClass( o.classOpen, o.classClose);
				} else {
					t.replaceClass( o.classClose, o.classOpen);
				}

				if( bCookie && sId + '' != '') {
					var iPos;
					if( ( iPos = $.inArray(sId, aCookie)) != -1) {
						do {
							aCookie.splice(iPos, 1);
						} while( (iPos = $.inArray(sId, aCookie)) != -1);
					} else {
						aCookie.push(sId);
					}
					$.cookie( o.cookieName, aCookie.join('.'), {expires: 365});
				}
				o.click_callback( this);
			});
		});
	};

	$.fn.tog.defaults = {
		classClose: '', // fermé
		classOpen: '', // ouvert
		openStart: false, // false = fermé, true = ouvert au démarrage
		cookieName: '', // si non vide, save ds cookie (idName obligatoire)
		idName: '', // endroit où on click: ex : html->panel-15 donc idName = panel (15 est l'indice)
		idPanel: '', // si le "contenu click" et éloigné du "contenu à ouvrir" Ex : html-> tog-panel-15 donc idPanel = tog
		forceId: [], // force des contenus au démarrage
		animation: '', // cf. slideToggle
		click_callback: function(){} // au click
	};
})(jQuery);

// inspiré de UItoTop jQuery Plugin 1.1 - http://www.mattvarone.com/web-design/uitotop-jquery-plugin/
(function($) {
	$.fn.UItoTop = function( options) {
 		var o = $.extend({}, $.fn.UItoTop.defaults, options);

		if( ! $id(o.containerID)) {
			$( '<a href="#" id="' + o.containerID + '">' + o.text + '</a>').appendTo('body').hide().click( function() {
				$('html, body').animate( { scrollTop : 0}, o.scrollSpeed, o.easingType);
				$('#' + o.containerHoverID).stop().animate({ 'opacity': 0 }, o.inDelay, o.easingType);
				return false;
			});

			$(window).scroll( function() {
				var sd = $(window).scrollTop();
				if(typeof document.body.style.maxHeight === 'undefined') {
					$('#' + o.containerID).css({
						'position': 'absolute',
						'top': sd + $(window).height() - 50
					});
				}
				if( sd > o.min) {
					$('#' + o.containerID).fadeIn( o.inDelay);
				} else {
					$('#' + o.containerID).fadeOut( o.Outdelay);
				}
			});
		}
	};

	$.fn.UItoTop.defaults = {
		text: 'To Top',
		min: 500,
		inDelay: 600,
		outDelay: 400,
		containerID: 'toTop',
		scrollSpeed: 200,
		easingType: 'linear'
	};
})(jQuery);

// MULTISELECT
// TODO : loading avec contenuAjax
(function($) {
	$.fn.multiselect = function( options) {
		var o = $.extend({}, $.fn.multiselect.defaults, options),
			aSelect = this;

		return this.change( function() {
			var iPosParent = $.inArray( this, aSelect),
				oSelectFille = aSelect[ iPosParent + 1] || null;

			if(	oSelectFille) {
				// raz de toutes les filles
				aSelect.each( function(i) {
					if( i > iPosParent) {
						this.options.length = 1;
					}
				});
				$.getJSON(
					o.url + '&' + $(this).serialize(),
					function( jSon) {
						for( var i = 0, iCount = jSon.length; i < iCount; i++) {
							oSelectFille.options[i + 1] = new Option( jSon[i].texte, jSon[i].valeur);
						}
						aSelect.prop('disabled', false).removeClass('disabled');
						oSelectFille.focus();
					}
				);
				aSelect.prop('disabled', true).addClass('disabled');
			}
		});
	}
	$.fn.multiselect.defaults = {
		url: ''
	};
})(jQuery);

/* Geolocalisation GOOGLE V3 */
var oGMAPV3_OPTION = null;
function gmapv3_async( option) {
	oGMAPV3_OPTION = option;
	$('#' + option.mapConteneur).addClass('ajaxloading_small');
	if( typeof window.google !== 'undefined' && window.google.maps) {
		return gmapv3_init();
	} else {
		$insertScript( 'http://maps.google.com/maps/api/js?sensor=false&language=' + LANGUE_META_SITE + '&callback=gmapv3_init');
	}
}
function gmapv3_init( option) {
	var o = $defined(option) ? option : oGMAPV3_OPTION;
	return new oGmapv3( o).init();
}
function oGmapv3( option) { // return objet (sauf en async)
	this.o = $.extend({
		raz: {
			mapLat:	46.5,
			mapLng:	2.4,
			mapZoom: 5,
			markerLat: 45,
			markerLng: -2
		},
		mapConteneur: null, // map
		mapH: 320,
		mapW: 'auto',
		mapLat:	46.5,
		mapLng:	2.4,
		mapTypeId: '',
		mapZoom: 5,
		mapFit: false,
		aMarker: [], // [titre || title], [champLat, champLng]
		iwTpl: null,
		conteneur: null,
		rechercher: false,
		rechercher_btn_annuler: false, // false = pas d'annulation possible ; selecteur ; 'auto' pour générer le btn automatiquement
		geolocMoi: false,
		init_callback: function(){}
	}, option);

	this.map = null;

	this.init = function() {
		var t = this;

		if( t.o.mapConteneur !== null && $id(t.o.mapConteneur)) {
			var oJQmapConteneur = $('#' + t.o.mapConteneur);

			if( t.o.conteneur !== null) {
				$('#' + t.o.conteneur).show();
			}
			oJQmapConteneur.removeClass('ajaxloading_small').css({ height: t.o.mapH, width: t.o.mapW});

			t.map = new google.maps.Map( $id(t.o.mapConteneur), {
				zoom: parseInt( t.o.mapZoom) || raz.mapZoom,
				center: new google.maps.LatLng( t.o.mapLat || t.o.raz.mapLat, t.o.mapLng || t.o.raz.mapLng),
				mapTypeId: google.maps.MapTypeId[ (t.o.mapTypeId != '' && t.o.mapTypeId !== null) ? t.o.mapTypeId.toUpperCase() : 'ROADMAP'],
				mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
				streetViewControl: true,
				scrollwheel: false
			});

			t.genererMarkers();

			if( t.o.rechercher) {
				var geocoder = new google.maps.Geocoder();

				oJQmapConteneur
					.before('<label for="geomap_recherche_geocoding_' + t.o.mapConteneur + '" class="nomarge">' + _lg('Adresse&nbsp;:') + '</label>')
					.before( $('<input/>', {
							type: 'text',
							id: 'geomap_recherche_geocoding_' + t.o.mapConteneur,
							'class': 'mInput',
							'keypress': function(e) {
								if( e.which == 13) {
									if( $.trim( this.value) == '') {
										alert( _lg('Merci de renseigner le champ «\xA0adresse\xA0»'));
									}
									return false;
								}
							}
						})
					);

				// bouton annuler si != false (auto, ou selecteur)
				if( t.o.rechercher_btn_annuler !== false) {
					if( t.o.rechercher_btn_annuler === 'auto') {
						oJQmapConteneur.before( '<input type="button" class="small_btn" id="geomap_recherche_annuler_geocoding_' + t.o.mapConteneur + '" value="' + _lg('Annuler') + '" />');
						t.o.rechercher_btn_annuler = 'geomap_recherche_annuler_geocoding_' + t.o.mapConteneur;
					}
				}

				$('#geomap_recherche_geocoding_' + t.o.mapConteneur).autocomplete( {
					source: function(request, response) {
						geocoder.geocode( { 'address': $.trim( request.term) }, function(results, status) {
							if( status == google.maps.GeocoderStatus.OK) {
								for( var i = 0; i < results.length; i++) {
									results[i].label = results[i].formatted_address;
								};
							}
							response( results);
						});
					},
					minLength: 2,
					autoFocus: true,
					focus: function( event, ui) {
						var address = ui.item;
						if( ! address) {
							return;
						}

						var oMarker = t.marker();
						oMarker.setPosition( address.geometry.location);
						t.map.setZoom(16);
						t.map.setCenter( address.geometry.location);
						t.recherche_updateChamp( oMarker);
					}
				}).data('autocomplete')._renderItem = function( ul, item) {
					return $( '<li></li>')
					.data( 'item.autocomplete', item)
					.append( '<a>' + item.label.replace( new RegExp('(?![^&;]+;)(?!<[^<>]*)('  + $.ui.autocomplete.escapeRegex(this.term) + ')(?![^<>]*>)(?![^&;]+;)', 'gi'), '<strong>$1</strong>') + '</a>')
					.appendTo( ul);
				};
			}

			// Action btn annuler recheche si besoin
			if( t.o.rechercher_btn_annuler !== false) {
				var oRechercheMarker = t.marker(); // le permier car 1 seul à placer
				$('#' + t.o.rechercher_btn_annuler).click( function() {
					t.recherche_annulerGeoloc( this);
				}).prop('disabled', ( $id(oRechercheMarker.champLat).value == '' || $id(oRechercheMarker.champLng).value == ''));
			}

			if( t.o.geolocMoi && navigator.geolocation) {
				oJQmapConteneur.before( '<span/>').prev('span').append( $('<input/>', {
						type: 'button',
						'class': 'medium_btn',
						value: _lg('Géolocalisez-moi'),
						click: function() {
							var oBtn = $(this);
							oBtn.hide().closest('span').addClass('ajaxloading_small').css({ 'padding-left': oBtn.width()});
							navigator.geolocation.getCurrentPosition( function( position) {
								var oLatLng = new google.maps.LatLng( position.coords.latitude, position.coords.longitude),
									oMarker = t.marker();

								oMarker.setPosition( oLatLng);
								t.map.setCenter( oLatLng);
								t.recherche_updateChamp( oMarker);
								oBtn.show().parent().css({ padding:0 }).removeClass();
							}, function( errorcode) {
								oBtn.show().parent().css({ padding:0 }).removeClass();
							});
						}
					})
				);
			}

			t.o.init_callback( t);
			return t;
		} else {
			return false;
		}
	};

	this.genererMarkers = function() {
		var i, t = this, bounds = new google.maps.LatLngBounds();

		// Marker
		t.o.aMarker = $.map( t.o.aMarker, function(n) {
			if( parseFloat(n.lat) && parseFloat(n.lng)) {
				var oMarker = new google.maps.Marker({
						position: new google.maps.LatLng( n.lat, n.lng),
						map: t.map,
						title: n.titre || n.title || '',
						draggable: n.draggable || false,
						champLat: n.champLat || '',
						champLng: n.champLng || ''
					});

				if( n.marker_icon && n.marker_iconSize) {
					var bFlat = true,
						oShadow = null;

					if( n.marker_shadow && n.marker_shadowSize) {
						bFlat = false;

						oShadow = new google.maps.MarkerImage(
							n.marker_shadow,
							new google.maps.Size( n.marker_shadowSize[0], n.marker_shadowSize[1]),
							new google.maps.Point( 0, 0),
							new google.maps.Point( n.marker_anchor ? n.marker_anchor[0] : parseInt( n.marker_iconSize[0]) / 2, n.marker_anchor ? n.marker_anchor[1] : n.marker_shadowSize[1])
						);
					}
					oMarker.setOptions( {
						icon: new google.maps.MarkerImage(
							n.marker_icon,
							new google.maps.Size( n.marker_iconSize[0], n.marker_iconSize[1]),
							new google.maps.Point( 0, 0),
							new google.maps.Point( n.marker_anchor ? n.marker_anchor[0] : parseInt( n.marker_iconSize[0]) / 2, n.marker_anchor ? n.marker_anchor[1] : n.marker_iconSize[1])
						),
						shadow: oShadow,
						flat: bFlat
					});
				}

				if( n.draggable) {
					google.maps.event.addListener( oMarker, 'dragend', function() {
						t.map.setCenter( oMarker.position);
						t.recherche_updateChamp( oMarker);
					});
				}

				n.marker = oMarker;  // evite d'écraser des propriétés
				bounds.extend( oMarker.getPosition());

				return n;
			}
		});

		// Template
		if( $.isFunction(t.o.iwTpl)) {
			for( i = 0, iCount = t.o.aMarker.length; i < iCount; i++) {
				var oMarker = t.o.aMarker[i].marker,
					oPag = null,
					sPagination = '';

				if( iCount > 1) {
					oPag = { uniqueID: ( new Date()).getTime() + '-geopPag' + i };

					if( i == 0) {
						oPag.oMarkerPrev = t.o.aMarker[iCount - 1].marker;
						oPag.PrevImg = 'geo_debut';
						oPag.PrevTitle = _lg('Retour au dernier');
					} else {
						oPag.oMarkerPrev = t.o.aMarker[i - 1].marker;
						oPag.PrevImg = 'geo_precedent';
						oPag.PrevTitle = _lg('Précédent');
					}
					if( i + 1 == iCount) {
						oPag.oMarkerNext = t.o.aMarker[0].marker;
						oPag.NextImg = 'geo_fin';
						oPag.NextTitle = _lg('Aller au premier');
					} else {
						oPag.oMarkerNext = t.o.aMarker[i + 1].marker;
						oPag.NextImg = 'geo_suivant';
						oPag.NextTitle = _lg('Suivant');
					}

					sPagination =
						'<div class="geo_iw_pagination" id="' + oPag.uniqueID + '"> \
							<span class="geo_iw_pagcount"><strong>' + (i + 1) + '</strong>/' + iCount + '</span> \
							<img src="' + URL_CHARTE_COMMUN + 'composant/geolocalisation/image/' + oPag.PrevImg + '.png" alt="' + oPag.PrevTitle + '" title="' + oPag.PrevTitle + '" /> \
							<img src="' + URL_CHARTE_COMMUN + 'composant/geolocalisation/image/' + oPag.NextImg + '.png" alt="' + oPag.NextTitle + '" title="' + oPag.NextTitle + '" /> \
						</div>';
				}

				var oInfoWindow = new google.maps.InfoWindow({
					content: t.o.iwTpl( t.o.aMarker[i], sPagination)
				});
				google.maps.event.addListener( oMarker, 'click', t.openInfoWindow( oInfoWindow, oMarker));
				if( oPag !== null) {
					google.maps.event.addListener( oInfoWindow, 'domready', t.domReadyInfoWindow( oInfoWindow, oPag));
				}
			}
		}

		if( t.o.mapFit && ! bounds.isEmpty()) {
			t.map.fitBounds( bounds);
		}
	};

	this.domReadyInfoWindow = function( oInfoWindow, oPag) {
		return function() {
			var jqPag = $('#' + oPag.uniqueID);

			if( jqPag.data('pag') !== true) { // bug gmap ? évite plusieurs domready
				jqPag.data('pag', true).find('img:first').click( function() {
					google.maps.event.trigger(oPag.oMarkerPrev, 'click');
				}).next('img').click( function() {
					google.maps.event.trigger(oPag.oMarkerNext, 'click');
				});
			}
		}
	};

	this.openInfoWindow = function( oInfoWindow, oMarker) {
		return function() {
			// Fermer la dernière bulle ouverte avant d'ouvrir celle demandé
			this.map.visibleInfoWindow && this.map.visibleInfoWindow.close();
			oInfoWindow.open(this.map, oMarker);
			this.map.visibleInfoWindow = oInfoWindow;
		}
	};

	this.repereId = function( oRepere, bId) {
		for( var i = 0, iCount = this.o.aMarker.length; i < iCount; i++) {
			if( this.o.aMarker[i] !== null) {
				if( this.o.aMarker[i].marker == oRepere) {
					return $is_true( bId, true) ? this.o.aMarker[i] : i;
				}
			}
		}
		return $is_true( bId, true) ? null : 0;
	};

	this.marker = function( iIndex) {
		var iId = parseInt(iIndex) ? iIndex : 0;
		return this.o.aMarker[iId].marker || 0;
	};

	// recherche
	this.recherche_updateChamp = function( oMarker) {
		if(	oMarker.champLat != '' && oMarker.champLng != '') {
			$('#' + oMarker.champLat).val( oMarker.position.lat());
			$('#' + oMarker.champLng).val( oMarker.position.lng());
		}
		this.recherche_updateMarker( oMarker);
	};

	this.recherche_annulerGeoloc = function( oBtn) {
		var t = this,
			oMarker = t.marker();

		oBtn.disabled = true;
		oMarker.setPosition( new google.maps.LatLng( t.o.raz.markerLat,t.o.raz.markerLng));
		if(	oMarker.champLat != '' && oMarker.champLng != '') {
			$('#' + oMarker.champLat + ', #' + oMarker.champLng).val( '');
		}
		t.recherche_updateMarker( oMarker);
		t.map.setZoom( t.o.raz.mapZoom);
		t.map.setCenter( new google.maps.LatLng( t.o.raz.mapLat, t.o.raz.mapLng));
	};

	this.recherche_updateMarker = function( oMarker) {
		if(	oMarker.champLat != '' && oMarker.champLng != '') {
			var t = this;
				bPLacer = $id(oMarker.champLat).value != '' && $id(oMarker.champLng).value != '';

			oMarker.setIcon( new google.maps.MarkerImage( URL_CHARTE_COMMUN + 'composant/geolocalisation/image/repere/' + ( bPLacer ? 'red-dot' : 'gray') + '.png'));
			if( t.o.rechercher_btn_annuler !== false) {
				$('#' + t.o.rechercher_btn_annuler).prop('disabled', ! bPLacer);
			}
		}
	};
}

// DEMANDE DE CONFIRMATION FAUSSE POPUP
function confirmerSuppression( options) {
	var o = $.extend({
		selecteur: 'a.jsSupprConfirm',
		message: _lg('Voulez-vous supprimer cet élément ?'),
		titre: _lg('Suppression')
	}, options);

	$(o.selecteur).click( function() {
		var lienSuppr = this.href;

		$('<div>').html( o.message).dialog({
			title: o.titre,
			modal: true,
			buttons: {
				'Supprimer': function() { $redirect(lienSuppr); },
				'Annuler': function() { $(this).dialog('close'); }
			},
			close: function() { $(this).dialog('destroy').remove(); }
		})._lgDialogBouton();
		return false;
	});
}
