/*
 *		Variables globales ETESIA
 */
	var geocoder;
	var map;
    var markersArray = [];
    var markersIdArray = [];
	var infowindowLevel = 0;
	var clickedMarker = null;
	var daClientLocation;
	var mgr;
        var initialPosition = '';
        var initialZoom = '';
        
    var block_marker = false;
    
	var currentCountry	 =	"" ;
	
	// ---> Initialisation de la MAP
		function initializeMap()
		{
			//var daLocation = getUserLocation('retour');
			geocoder	=	new google.maps.Geocoder();
			
			var centerLat			=	46;
			var centerLong			=	7;
			var centerZoom			=	4;

            var daClientLocation	=	google.loader.ClientLocation;

            if (daClientLocation != undefined)
			{
				centerLat	= 	daClientLocation.latitude;
				centerLong	=	daClientLocation.longitude;
                
				centerZoom	=	2;


/*POSITION DU CLIENT*/
                if (geocoder) {
						geocoder.geocode( {'address': daClientLocation.address.city}, function(results, status) {
							if (status == google.maps.GeocoderStatus.OK) {
                                var client_ville = results[0].geometry.location;
                                $('#your_location .location_address').append('<a href="javascript:void(0);" onclick="var client_position = new google.maps.LatLng('+client_ville.lat()+', '+client_ville.lng()+'); map.setCenter(client_position);map.setZoom(9);loadRevendeursClient(map.getBounds())">'+daClientLocation.address.city+'</a>');
                                $('#your_location').show();
                                
                                geocoder.geocode( {'address': daClientLocation.address.region}, function(results, status) {
                                    if (status == google.maps.GeocoderStatus.OK) {
                                        var client_region = results[0].geometry.location;
                                        $('#your_location .location_address').append(', <a href="javascript:void(0);" onclick="var client_position = new google.maps.LatLng('+client_region.lat()+', '+client_region.lng()+'); map.setCenter(client_position);map.setZoom(7);loadRegionsClient(map.getBounds())">'+daClientLocation.address.region+'</a>');
                                        $('#your_location').show();
                                            geocoder.geocode( {'address': daClientLocation.address.country}, function(results, status) {
                                                if (status == google.maps.GeocoderStatus.OK) {
                                                    var client_pays = results[0].geometry.location;
                                                    $('#your_location .location_address').append(', <a href="javascript:void(0);" onclick="var client_position = new google.maps.LatLng('+client_pays.lat()+', '+client_pays.lng()+'); map.setCenter(client_position);map.setZoom(6);loadRegionsClient(map.getBounds())">'+daClientLocation.address.country+'</a>');
                                                    $('#your_location').show();
                                                }
                                            });

                                    }
                                });
							}
						});
                }
                
                $('.revendeur-gotomyregion').click(function() {
                    showLoader(3000);
                    var client_position = new google.maps.LatLng(centerLat, centerLong);
                    map.setCenter(client_position);
                    map.setZoom(9);
                    loadRevendeursClient(map.getBounds());
                });
/*FIN POSITION DU CLIENT*/
			}

			var latlng = new google.maps.LatLng(centerLat, centerLong);
			
			var myOptions = {
				zoom: centerZoom,
				center: latlng,
				disableDoubleClickZoom: true,
				navigationControl: true,
                navigationControlOptions: {
                    style: google.maps.NavigationControlStyle.ZOOM_PAN
                },
                mapTypeControlOptions: {
                    style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
                },
				mapTypeId: google.maps.MapTypeId.ROADMAP
			};
			map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

			google.maps.event.addListener(map, 'zoom_changed', function() {
                $('#revendeur-tooltip').hide();
                var setted_zoom = map.getZoom();
                
				if ( (setted_zoom <= 7) && (currentCountry != "") )
				{
					loadRegions(currentCountry);
					currentCountry = "";
				}
				if ( setted_zoom <= 5 )
				{
					loadCountries();
				}
			});
			loadCountries();

                        /*INITIAL POSITION*/
                        if(initialPosition != '') {
                            if (geocoder) {
                                geocoder.geocode( {'address': initialPosition}, function(results, status) {
                                          if (status == google.maps.GeocoderStatus.OK) {
                                                 var client_pays = results[0].geometry.location;
                                                 var client_position = new google.maps.LatLng(client_pays.lat(), client_pays.lng());
                                                 map.setCenter(client_position);
                                                 if(initialZoom >= 9) {
                                                     map.setZoom(initialZoom);
                                                     loadRevendeursClient(map.getBounds());
                                                 }
                                                 if(initialZoom == 7) {
                                                     map.setZoom(7);
                                                     loadRegionsClient(map.getBounds());
                                                 }
                                                 if(initialZoom <= 6) {
                                                     map.setZoom(initialZoom);
                                                     loadCountries(map.getBounds());
                                                 }
                                          }
                                });
                            }
                        }
		}
	
	// ---> GeoLocalisation
	
	/* ---> Recuperation des limites de la ZONE (pays ou region)
	 *		la limite est stockee sous forme de chaine string separe par une virgule
	 *		SWlat, SWlong, NElat, NElong
	 */
		function getZoneBounds( bounds_zone )
		{
			if (bounds_zone != undefined )
			{
				var bounds 	=	bounds_zone.split(",");
				var SW 		=	new google.maps.LatLng(bounds[0], bounds[1]);
				var NE 		=	new google.maps.LatLng(bounds[2], bounds[3]);
				var zeBounds=	new google.maps.LatLngBounds(SW, NE);
			}
			else
			{
				var zeBounds="";
			}
			return zeBounds;
		}
	
	// ---> Debuggage JS
		function debugJS(elem)
		{
			$('.jsDebug').html($('.jsDebug').html()+elem+"<br />");
		}
				
	/* ---> 	Recherche via le geocoder
	 *			si la base ne contient aps les coords, on les stocke
	 *			on stocke egalement les limites de la zone pour le zoom
	 */			
		function searchLocation( searchAddress, action, table, theID )
		{
			var Coords = "";
					if (geocoder) {
						geocoder.geocode( {'address': searchAddress}, function(results, status) {
							if (status == google.maps.GeocoderStatus.OK) {
								
								// --> On sauve les coordonnees
									$.get(	ajaxURL+'revendeurs/ajax-revendeurs.php',
											{adresse: searchAddress,
												coords: results[0].geometry.location,
												bounds: results[0].geometry.bounds,
												command: action,
												table:	table,
												id: theID
											},
											function(data) {
												
												$('.jsDebug').html($('.jsDebug').html()+data+"<br />");
									});
									setPoint( table, results[0].geometry.location, results[0].geometry.bounds, theID);
							} else {
								//alert("Geocode was not successful for the following reason: " + status);
							}
						});
					}
		}

	/* affiche la liste des pays*/
        function loadCountries(bounds)
        {
				$('#regions').hide();
                clearOverlays();
                showLoader(1000);
                $.getJSON(	ajaxURL+'revendeurs/ajax-revendeurs.php',
                            {command: 'getPays',
                                centerLng: map.getCenter().lng(),
                                centerLat: map.getCenter().lat(),
                                dataType: 'json'},
                            function(data) {
                            // --> pour chaque pays je checke lat / long si rien, alors on golocalize

                                $('.revendeur-bottom-right').text('');
                                $('#revendeur-result span').hide();
                                $('#revendeur-result span.revendeur-result-label1').show();
                                $('#revendeur-result span.revendeur-result-nb').text(data.length).show();

                                for ( i = 0; i < data.length; i++ )
                                {
                                    var placeToSearch = data[i].bNOM;

                                    if ( (data[i].bLAT == 0) && (data[i].bLONG == 0) )
                                    {
                                        searchLocation( placeToSearch, 'save', 'pays', data[i].bID );
                                    }
                                    else
                                    {
                                        //var latlng 		= 	new google.maps.LatLng(data[i].bLAT, data[i].bLONG);
                                        var daBounds	=	getZoneBounds( data[i].bBOUNDS );
                                        data[i].bounds	=	daBounds;
                                        setPoint( 'Pays', data[i] );
                                    }
									
                                    $('.revendeur-bottom-right').append('<div class="revendeur-block-pays"><div class="title" onclick="var new_position = new google.maps.LatLng('+data[i].bLAT+', '+data[i].bLONG+'); map.setCenter(new_position); loadRegions('+data[i].bID+'); map.setZoom(7); "><img src="'+flagFolder+data[i].flag+'" />'+data[i].bNOM+'</div></div>');
                                }
                                $('.revendeur-bottom-right').append('<div class="clear"></div>');
                                $('#revendeur-result').show();
								
								
                               
								
                            });
        }
        /*Affiche la liste des revendeurs pour le pays courant*/
        function loadRegions(zeId)
        {
            clearOverlays();
            showLoader(1000);
            currentCountry = zeId;
			// --> Initialisation des deroulants
					$("#country").attr('value',zeId);
					loadSelectRegions(zeId);
			
			$.getJSON(	ajaxURL+'revendeurs/ajax-revendeurs.php',
						{command: 'getRegions',
                            id: zeId
						},
						function(data) {
						// --> pour chaque pays je checke lat / long si rien, alors on golocalize
                            /*$('#revendeur-result div span').animate({opacity: 0}, 500);
                            $('.revendeur-bottom-right').animate({opacity: 0}, 500, function(){*/
                                $('.revendeur-bottom-right').text('');
                                $('#revendeur-result span').hide();
                                $('#revendeur-result span.revendeur-result-label2').show();
                                var number_result = 0;
                                for ( i = 0; i < data.length; i++ )
                                {
                                    //if(data[i].bLAT >= latitudeFrom && data[i].bLAT <= latitudeTo && data[i].bLONG >= longitudeFrom && data[i].bLONG <= longitudeTo)
                                    //{
                                        var placeToSearch = data[i].bNOM;

                                        if ( (data[i].bLAT == 0) && (data[i].bLONG == 0) )
                                        {
                                            searchLocation( placeToSearch, 'save', 'pays', data[i].bID );
                                        }
                                        else
                                        {
                                            //var latlng 		= 	new google.maps.LatLng(data[i].bLAT, data[i].bLONG);
                                            var daBounds	=	getZoneBounds( data[i].bBOUNDS );
                                            data[i].bounds	=	daBounds;
                                            setPoint( 'Region', data[i] );
                                        }
										$('.revendeur-bottom-right').append('<div class="revendeur-block-region"><div class="title" onclick="var new_position = new google.maps.LatLng('+data[i].bLAT+', '+data[i].bLONG+'); map.setCenter(new_position); loadRevendeurs('+data[i].bID+'); map.setZoom(8); "><img src="'+markRegionGIF+'" />'+data[i].bNOM+'</div></div>');
                                        number_result++;
                                    //}
                                }
                                $('#revendeur-result span.revendeur-result-nb').text(number_result).show();
                                $('.revendeur-bottom-right').append('<div class="clear"></div>');
                                $('#revendeur-result').show();
								// -> PATHWAY
								//$('#pathwayNavMap .location_address').append('<a href="javascript:void(0);" onclick="var client_position = new google.maps.LatLng('+client_ville.lat()+', '+client_ville.lng()+'); map.setCenter(client_position);map.setZoom(9);loadRevendeurs(map.getBounds())">yeah'+daClientLocation.address.city+'</a>');
                                //$('#pathwayNavMap').css('display', 'block');
								
								
                                /*$('.revendeur-bottom-right').animate({opacity: 1}, 500);
                                $('#revendeur-result div span').animate({opacity: 1}, 500);*/
                            /*});*/
                            
						});
        }
        /*Affiche la liste des revendeurs pour la zone courante*/
        function loadRegionsClient(bounds)
        {
            clearOverlays();
            showLoader(1000);
            var latitudeFrom = '';
            var latitudeTo = '';
            var longitudeFrom = '';
            var longitudeTo = '';
            if(bounds != undefined)
            {
                latitudeFrom = map.getBounds().getSouthWest().lat();
                latitudeTo = map.getBounds().getNorthEast().lat();
                longitudeFrom = map.getBounds().getSouthWest().lng();
                longitudeTo = map.getBounds().getNorthEast().lng();
            }
			$.getJSON(	ajaxURL+'revendeurs/ajax-revendeurs.php',
						{command: 'getRegionsClient',
                            centerLng: map.getCenter().lng(),
                            centerLat: map.getCenter().lat(),
                            latitudeFrom : latitudeFrom,
                            latitudeTo : latitudeTo,
                            longitudeFrom : longitudeFrom,
                            longitudeTo : longitudeTo,
							dataType: 'json'},
						function(data) {
						// --> pour chaque pays je checke lat / long si rien, alors on golocalize
                            /*$('#revendeur-result div span').animate({opacity: 0}, 500);
                            $('.revendeur-bottom-right').animate({opacity: 0}, 500, function(){*/
                                $('.revendeur-bottom-right').text('');
                                $('#revendeur-result span').hide();
                                $('#revendeur-result span.revendeur-result-label2').show();
                                var number_result = 0;
                                for ( i = 0; i < data.length; i++ )
                                {
                                    //recheck des lat/long
                                    latitudeFrom = map.getBounds().getSouthWest().lat();
                                    latitudeTo = map.getBounds().getNorthEast().lat();
                                    longitudeFrom = map.getBounds().getSouthWest().lng();
                                    longitudeTo = map.getBounds().getNorthEast().lng();
                                    if(data[i].bLAT >= latitudeFrom && data[i].bLAT <= latitudeTo && data[i].bLONG >= longitudeFrom && data[i].bLONG <= longitudeTo)
                                    {
                                        var placeToSearch = data[i].bNOM;

                                        if ( (data[i].bLAT == 0) && (data[i].bLONG == 0) )
                                        {
                                            searchLocation( placeToSearch, 'save', 'pays', data[i].bID );
                                        }
                                        else
                                        {
                                            //var latlng 		= 	new google.maps.LatLng(data[i].bLAT, data[i].bLONG);
                                            var daBounds	=	getZoneBounds( data[i].bBOUNDS );
                                            data[i].bounds	=	daBounds;
                                            setPoint( 'Region', data[i] );
                                        }
                                        $('.revendeur-bottom-right').append('<div class="revendeur-block-region"><div class="title" onclick="var new_position = new google.maps.LatLng('+data[i].bLAT+', '+data[i].bLONG+'); map.setCenter(new_position); loadRevendeurs(map.getBounds()); map.setZoom(8); "><img src="'+markRegionGIF+'" />'+data[i].bNOM+'</div></div>');
                                        number_result++;
                                    }
                                }
                                $('#revendeur-result span.revendeur-result-nb').text(number_result).show();
                                $('.revendeur-bottom-right').append('<div class="clear"></div>');
                                $('#revendeur-result').show();
                                /*$('.revendeur-bottom-right').animate({opacity: 1}, 500);
                                $('#revendeur-result div span').animate({opacity: 1}, 500);*/
                            /*});*/

						});
        }
        /*Affiche la liste des revendeurs pour la région courante*/
        function loadRevendeurs(zeId)
        {
           clearOverlays();
            showLoader(1000);
            $("#regions").attr('value',zeId);
            $.getJSON(	ajaxURL+'revendeurs/ajax-revendeurs.php',
						{	command: 'getRevendeurs',
                            id:	zeId
						},
						function(data) {
                            /*$('#revendeur-result div span').animate({width: 'auto'}, 500);
                            $('.revendeur-bottom-right').animate({width: 'auto'}, 500, function(){*/
                                $('.revendeur-bottom-right').text('');
                                $('#revendeur-result span').hide();
                                $('#revendeur-result span.revendeur-result-label3').show();
                                // --> pour chaque pays je checke lat / long si rien, alors on golocalize
                                
								var number_result = 0;
                                for ( i = 0; i < data.length; i++ )
                                {
                                    //recheck des lat/long
										var placeToSearch = data[i].bNOM;

                                        if ( (data[i].bLAT == 0) && (data[i].bLONG == 0) )
                                        {
                                            searchLocation( placeToSearch, 'save', 'pays', data[i].bID );
                                        }
                                        else
                                        {
                                            //var latlng 		= 	new google.maps.LatLng(data[i].bLAT, data[i].bLONG);
                                            var daBounds	=	getZoneBounds( data[i].bBOUNDS );
                                            data[i].bounds	=	daBounds;
                                        }
                                        $('.revendeur-bottom-right').append('<div class="revendeur-block-revendeur"><div class="title" onclick="var new_position = new google.maps.LatLng('+data[i].bLAT+', '+data[i].bLONG+'); map.setCenter(new_position); map.setZoom(15); showTooltip(\''+data[i].nom+'\', \''+data[i].nomcomplement+'\', \''+data[i].rue+'\', \''+data[i].ruecomplement+'\', \''+data[i].codepostal+'\', \''+data[i].ville+'\', \''+data[i].tel+'\', \''+data[i].fax+'\', \''+data[i].email+'\', \''+data[i].siteweb+'\');">'+
                                        '<img src="'+markRevendeurGIF+'" />'+data[i].nom+' '+data[i].nomcomplement+'</div><div class="desc">'+data[i].rue+' '+data[i].ruecomplement+' '+data[i].codepostal+' '+data[i].ville+'<br/>'+                                '<span>'+tel+' : </span>'+((data[i].tel == '') ? '-' : data[i].tel)+'<br/>'+
                                        '<span>'+fax+' : </span>'+((data[i].fax == '') ? '-' : data[i].fax)+'<br/>'+
                                        '<span>'+siteweb+' : </span>'+((data[i].siteweb == '') ? '-' : '<a target="_blank" href="http://'+data[i].siteweb+'">'+data[i].siteweb+'</a>')+'<br/>'+
                                        '<span>'+email+' : </span>'+((data[i].email == '') ? '-' : '<a href="mailto:'+data[i].email+'">'+data[i].email+'</a>')+'<br/>'+
                                        '</div></div>');
                                        setPoint( 'Revendeurs', data[i] );
                                        number_result++;
									
                                }
                                $('#revendeur-result span.revendeur-result-nb').text(number_result).show();
                                $('.revendeur-bottom-right').append('<div class="clear"></div>');
                                $('#revendeur-result').show();
                                /*$('.revendeur-bottom-right').animate({color: '#333333'}, 500);
                                $('#revendeur-result div span').animate({color: '#333333'}, 500);*/
                            /*});*/
						});
                        
        }
        /*Affiche la liste des revendeurs pour la zone courante*/
        function loadRevendeursClient(bounds)
        {
            clearOverlays();
            showLoader(1000);
            var latitudeFrom = '';
            var latitudeTo = '';
            var longitudeFrom = '';
            var longitudeTo = '';
            if(bounds != undefined)
            {
                latitudeFrom = map.getBounds().getSouthWest().lat();
                latitudeTo = map.getBounds().getNorthEast().lat();
                longitudeFrom = map.getBounds().getSouthWest().lng();
                longitudeTo = map.getBounds().getNorthEast().lng();
            }
			$.getJSON(	ajaxURL+'revendeurs/ajax-revendeurs.php',
						{command: 'getRevendeursClient',
                            centerLng: map.getCenter().lng(),
                            centerLat: map.getCenter().lat(),
                            latitudeFrom : latitudeFrom,
                            latitudeTo : latitudeTo,
                            longitudeFrom : longitudeFrom,
                            longitudeTo : longitudeTo,
							dataType: 'json'},
						function(data) {
                            /*$('#revendeur-result div span').animate({width: 'auto'}, 500);
                            $('.revendeur-bottom-right').animate({width: 'auto'}, 500, function(){*/
                                $('.revendeur-bottom-right').text('');
                                $('#revendeur-result span').hide();
                                $('#revendeur-result span.revendeur-result-label3').show();
                                // --> pour chaque pays je checke lat / long si rien, alors on golocalize
                                var number_result = 0;
                                for ( i = 0; i < data.length; i++ )
                                {
                                    //recheck des lat/long
                                    latitudeFrom = map.getBounds().getSouthWest().lat();
                                    latitudeTo = map.getBounds().getNorthEast().lat();
                                    longitudeFrom = map.getBounds().getSouthWest().lng();
                                    longitudeTo = map.getBounds().getNorthEast().lng();
                                    if(data[i].bLAT >= latitudeFrom && data[i].bLAT <= latitudeTo && data[i].bLONG >= longitudeFrom && data[i].bLONG <= longitudeTo)
                                    {
                                        var placeToSearch = data[i].bNOM;

                                        if ( (data[i].bLAT == 0) && (data[i].bLONG == 0) )
                                        {
                                            searchLocation( placeToSearch, 'save', 'pays', data[i].bID );
                                        }
                                        else
                                        {
                                            //var latlng 		= 	new google.maps.LatLng(data[i].bLAT, data[i].bLONG);
                                            var daBounds	=	getZoneBounds( data[i].bBOUNDS );
                                            data[i].bounds	=	daBounds;
                                        }
                                        $('.revendeur-bottom-right').append('<div class="revendeur-block-revendeur"><div class="title" onclick="var new_position = new google.maps.LatLng('+data[i].bLAT+', '+data[i].bLONG+'); map.setCenter(new_position); map.setZoom(15); showTooltip(\''+data[i].nom+'\', \''+data[i].nomcomplement+'\', \''+data[i].rue+'\', \''+data[i].ruecomplement+'\', \''+data[i].codepostal+'\', \''+data[i].ville+'\', \''+data[i].tel+'\', \''+data[i].fax+'\', \''+data[i].email+'\', \''+data[i].siteweb+'\');">'+
                                        '<img src="'+markRevendeurGIF+'" />'+data[i].nom+' '+data[i].nomcomplement+'</div><div class="desc">'+data[i].rue+' '+data[i].ruecomplement+' '+data[i].codepostal+' '+data[i].ville+'<br/>'+                                '<span>'+tel+' : </span>'+((data[i].tel == '') ? '-' : data[i].tel)+'<br/>'+
                                        '<span>'+fax+' : </span>'+((data[i].fax == '') ? '-' : data[i].fax)+'<br/>'+
                                        '<span>'+siteweb+' : </span>'+((data[i].siteweb == '') ? '-' : '<a target="_blank" href="http://'+data[i].siteweb+'">'+data[i].siteweb+'</a>')+'<br/>'+
                                        '<span>'+email+' : </span>'+((data[i].email == '') ? '-' : '<a href="mailto:'+data[i].email+'">'+data[i].email+'</a>')+'<br/>'+
                                        '</div></div>');
                                        setPoint( 'Revendeurs', data[i] );
                                        number_result++;
                                    }
                                }
                                $('#revendeur-result span.revendeur-result-nb').text(number_result).show();
                                $('.revendeur-bottom-right').append('<div class="clear"></div>');
                                $('#revendeur-result').show();
                                /*$('.revendeur-bottom-right').animate({color: '#333333'}, 500);
                                $('#revendeur-result div span').animate({color: '#333333'}, 500);*/
                            /*});*/
						});

        }

	/* ---> 	Affichage d'un point
	 *			si la base ne contient aps les coords, on les stocke
	 *			on stocke egalement les limites de la zone pour le zoom
	 */		
				function setPoint(context, dataZone)
				{
                    
					if(markersIdArray[dataZone.bID] != 'in_place')
                    {
                        var daIcon = (context == 'Region') ? markRegion : (context == 'Revendeurs') ? markRevendeur : flagFolder+dataZone.flag;

                        var position 	= 	new google.maps.LatLng(dataZone.bLAT, dataZone.bLONG);
                        var title_marker = dataZone.bNOM;
                        if(title_marker == undefined)
                        {
                                title_marker = dataZone.nom;
                        }

                        var marker 		= 	new google.maps.Marker({
                            map: map,
                            icon: daIcon,
                            position: position,
                            title: title_marker,
                            bounds: dataZone.bounds,
                            id:	dataZone.bID
                        });
                        markersArray.push(marker);
                        markersIdArray[dataZone.bID] = 'in_place';
                        switch (context) {
                            case 'Pays' :google.maps.event.addListener(marker, 'click', function() {
                                                    map.setZoom(7);
                                                    map.setCenter(position);
                                                    loadRegions(dataZone.bID);
                                                });
                                                break;
                            case 'Region' :google.maps.event.addListener(marker, 'click', function() {
                                                    map.setZoom(8);
                                                    map.setCenter(position);
                                                    loadRevendeurs(dataZone.bID);
                                                });
                                                break;
                            case 'Revendeurs' :google.maps.event.addListener(marker, 'click', function() {
                                                    map.setCenter(this.position);
                                                    map.setZoom(15);
                                                    showTooltip(dataZone.nom, dataZone.nomcomplement, dataZone.rue, dataZone.ruecomplement, dataZone.codepostal, dataZone.ville, dataZone.tel, dataZone.fax, dataZone.email, dataZone.siteweb)
                                                });
                                                break;
                        }
                    }
				}
                /*-Supprime les marker-*/
                function clearOverlays() {
                      if (markersArray) {
                        for (i in markersArray) {
                          markersArray[i].setMap(null);
                        }
                      }
                      if (markersIdArray) {
                        for(i in markersIdArray) {
                          markersIdArray[i] = '';
                        }
                      }
                 }
                 /*Affiche la tooltip sur la map*/
                 function showTooltip(nom, nomcomplement, rue, ruecomplement, codepostal, ville, telephone, _fax, _email, _siteweb)
                 {
                    $('#revendeur-tooltip-title').text('').append(rue+' '+ruecomplement+' '+codepostal+' '+ville+'<div class="desc">'+
                                                '<span> - '+tel+'</span> : '+((telephone == '') ? '-' : telephone)+'<br/>'+
                                                '<span> - '+fax+'</span> : '+((_fax == '') ? '-' : _fax)+'<br/>'+
                                                '<span> - '+siteweb+'</span> : '+((_siteweb == '') ? '-' : '<a target="_blank" href="http://'+_siteweb+'">'+_siteweb+'</a>')+'<br/>'+
                                                '<span> - '+email+'</span> : '+((_email == '') ? '-' : '<a href="mailto:'+_email+'">'+_email+'</a>')+
                                                '</div>');
                    $('#revendeur-tooltip-desc').text(nom+' '+nomcomplement);
                    $('#revendeur-tooltip').show();

                 }
                 /*Recharge la liste des régions*/
                 function loadSelectRegions(idPays)
                 {
                    
					
					$.getJSON(	ajaxURL+'revendeurs/ajax-revendeurs.php',
						{command: 'getRegionsSelect',
                            id: idPays,
							dataType: 'json'},
						function(data) {
                            if(data.length>0) {
                                $('#regions').html('');
                                $('#regions').append('<option value="">'+select_regions+'</option>');
                                for ( i = 0; i < data.length; i++ )
                                {
                                    $('#regions').append('<option value="'+data[i].bID+'">'+data[i].bNOM+'</option>');
                                }
                                $('#regions').show();
                            }
                            else
                            {
                                $('#regions').html('');
                                $('#regions').append('<option value="">'+select_regions+'</option>');
                                $('#regions').hide();
                            }
							//setPoint( 'Region', data[i] );
							//loadRegions(idPays);
						});
					
					
                 }
                 /*On se positionne sur le pays/région sélectionné*/
                 function letsLocate()
                 {
                     var idPays = $('#country').val();
					 var idRegions = $('#regions').val();
                     if(idRegions != "" && idRegions != undefined)
                     { //recherche d'une région
                            $.getJSON(	ajaxURL+'revendeurs/ajax-revendeurs.php',
                                {command: 'getSpecificRegion',
                                    id: idRegions,
                                    dataType: 'json'},
                                function(data) {
                                    if(data.length>0) {
                                        for ( i = 0; i < data.length; i++ ) {
											var latlng = new google.maps.LatLng(data[i].bLAT, data[i].bLONG);
                                            map.setZoom(8);
                                            map.setCenter(latlng);
                                            loadRevendeurs(idRegions);
                                        }
                                    }

                                });
                     }
                     else if(idPays != "" && idPays != undefined)
                     { //recherche d'un pays
                            $.getJSON(	ajaxURL+'revendeurs/ajax-revendeurs.php',
                                {command: 'getSpecificPays',
                                    id: idPays,
                                    dataType: 'json'},
                                function(data) {
                                    if(data.length>0) {
                                        for ( i = 0; i < data.length; i++ ) {
                                            var latlng = new google.maps.LatLng(data[i].bLAT, data[i].bLONG);
                                            map.setZoom(7);
                                            map.setCenter(latlng);
											loadRegions(idPays);
                                        }
                                    }
                                    
                                });
                     }
                     else
                     { //retour aux valeurs initiales de la carte
                            var daClientLocation	=	google.loader.ClientLocation;
                            var centerLat			=	35;
                            var centerLong			=	0;
                            var centerZoom			=	4;
                            if (daClientLocation != undefined)
                            {
                                centerLat	= 	daClientLocation.latitude;
                                centerLong	=	daClientLocation.longitude;
                                centerZoom	=	4;
                            }
                            var latlng = new google.maps.LatLng(centerLat, centerLong);
                            map.setZoom(centerZoom);
                            map.setCenter(latlng);
                     }
                 }
                 function showLoader(time)
                 {
                     if(block_marker == false) {
                         block_marker = true;
                         $('#map_loader').css({opacity: 1}).show().animate({opacity: 0}, time, function() {$('#map_loader').hide();block_marker = false;});
                     }
                 }
