function selectRubrique(rubrique)
{
	if(rubrique == 'enfance')
	{
		$('enfance').style.display = 'block';
		$('enfance_img').src = '/images/puce_couleur1b.gif';
		$('culture').style.display = 'none';
		$('culture_img').src = '/images/puce_couleur1.gif';
		$('sport').style.display = 'none';
		$('sport_img').src = '/images/puce_couleur1.gif';
		$('administration').style.display = 'none';
		$('administration_img').src = '/images/puce_couleur1.gif';
		$('pratique').style.display = 'none';
		$('pratique_img').src = '/images/puce_couleur1.gif';
		$('social').style.display = 'none';
		$('social_img').src = '/images/puce_couleur1.gif';
	}
	if(rubrique == 'sport')
	{
		$('enfance').style.display = 'none';
		$('enfance_img').src = '/images/puce_couleur1.gif';
		$('culture').style.display = 'none';
		$('culture_img').src = '/images/puce_couleur1.gif';
		$('sport').style.display = 'block';
		$('sport_img').src = '/images/puce_couleur1b.gif';
		$('administration').style.display = 'none';
		$('administration_img').src = '/images/puce_couleur1.gif';
		$('pratique').style.display = 'none';
		$('pratique_img').src = '/images/puce_couleur1.gif';
		$('social').style.display = 'none';
		$('social_img').src = '/images/puce_couleur1.gif';
	}
	if(rubrique == 'culture')
	{
		$('enfance').style.display = 'none';
		$('enfance_img').src = '/images/puce_couleur1.gif';
		$('culture').style.display = 'block';
		$('culture_img').src = '/images/puce_couleur1b.gif';
		$('sport').style.display = 'none';
		$('sport_img').src = '/images/puce_couleur1.gif';
		$('administration').style.display = 'none';
		$('administration_img').src = '/images/puce_couleur1.gif';
		$('pratique').style.display = 'none';
		$('pratique_img').src = '/images/puce_couleur1.gif';
		$('social').style.display = 'none';
		$('social_img').src = '/images/puce_couleur1.gif';
	}
	if(rubrique == 'administration')
	{
		$('enfance').style.display = 'none';
		$('enfance_img').src = '/images/puce_couleur1.gif';
		$('culture').style.display = 'none';
		$('culture_img').src = '/images/puce_couleur1.gif';
		$('sport').style.display = 'none';
		$('sport_img').src = '/images/puce_couleur1.gif';
		$('administration').style.display = 'block';
		$('administration_img').src = '/images/puce_couleur1b.gif';
		$('pratique').style.display = 'none';
		$('pratique_img').src = '/images/puce_couleur1.gif';
		$('social').style.display = 'none';
		$('social_img').src = '/images/puce_couleur1.gif';
	}
	if(rubrique == 'pratique')
	{
		$('enfance').style.display = 'none';
		$('enfance_img').src = '/images/puce_couleur1.gif';
		$('culture').style.display = 'none';
		$('culture_img').src = '/images/puce_couleur1.gif';
		$('sport').style.display = 'none';
		$('sport_img').src = '/images/puce_couleur1.gif';
		$('administration').style.display = 'none';
		$('administration_img').src = '/images/puce_couleur1.gif';
		$('pratique').style.display = 'block';
		$('pratique_img').src = '/images/puce_couleur1b.gif';
		$('social').style.display = 'none';
		$('social_img').src = '/images/puce_couleur1.gif';
	}
	if(rubrique == 'social')
	{
		$('enfance').style.display = 'none';
		$('enfance_img').src = '/images/puce_couleur1.gif';
		$('culture').style.display = 'none';
		$('culture_img').src = '/images/puce_couleur1.gif';
		$('sport').style.display = 'none';
		$('sport_img').src = '/images/puce_couleur1.gif';
		$('administration').style.display = 'none';
		$('administration_img').src = '/images/puce_couleur1.gif';
		$('pratique').style.display = 'none';
		$('pratique_img').src = '/images/puce_couleur1.gif';
		$('social').style.display = 'block';
		$('social_img').src = '/images/puce_couleur1b.gif';
	}
}



function afficheRubrique(id,page,commune)
{
	
	for(i=213000060;i<213000084;i++)
	{
		$(''+i+'').style.backgroundColor = '#f5faf9';	
	}
	
	$(''+id+'').style.backgroundColor = '#a8a8a8';
	
	$('GoogleMapBarr').style.display = 'none';	
	$('pasResultat').style.display = 'none';
	
	if(commune == 'Dambach-la-Ville'){
		commune = 'Dambach_la_Ville';	
	}
	
	new Ajax.Updater(
						'infosServices', 
						'/ajax/annuaire_LEI/rubriqueAnnuaireService.php',
							{
								method:'post',
								parameters:'id='+id+'&page='+page,
								onLoading: attenteLEI,
								onComplete: affichDivGM
							}
					);
}

function attenteLEI()
{
	$('attenteLEI').style.display = 'block';
	
}

var markers = new Array();
var windows = new Array();
var contents = new Array();
var map = null;
var id_ouvert;

function affichDivGM(xml)
{
	
	
	retourxml=xml.responseXML;
	
	if(retourxml.getElementsByTagName('point').length == 0)
	{
		$('attenteLEI').style.display = 'none';
		$('GoogleMapBarr').style.display = 'none';
		$('pasResultat').style.display = 'block';
	}
	else
	{
	$('pasResultat').style.display = 'none';
	$('attenteLEI').style.display = 'none';	
	
	$('GoogleMapBarr').style.display = 'block';	
	
	
//	if (GBrowserIsCompatible())
		{

				var gmarkers = [];
				var htmls = [];
				var to_htmls = [];
				var from_htmls = [];
				var i=0;
				
				
				var latlng = new google.maps.LatLng(48.380277,7.492222);
				var myOptions = {
				  zoom: 11,
				  center: latlng,
				  mapTypeId: google.maps.MapTypeId.HYBRID 
				};
				map = new google.maps.Map(document.getElementById("GoogleMapBarr"), myOptions);
				


				// Create a base icon for all of our markers that specifies the shadow, icon dimensions, etc.
			/*	var baseIcon = new GIcon(G_DEFAULT_ICON);
				baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
				//baseIcon.iconSize = new GSize(20, 34);
				baseIcon.shadowSize = new GSize(37, 34);
				//baseIcon.iconAnchor = new GPoint(9, 34);
				//baseIcon.infoWindowAnchor = new GPoint(9, 2);*/
				
				function createMarker(point,name,html,index)
				{
					  var image = new google.maps.MarkerImage("/images/icones_google_map/pin" + index + ".png", new google.maps.Size(16, 27), new google.maps.Point(0,0), new google.maps.Point(8,27));

					
				/*	var numberIcon = new GIcon(G_DEFAULT_ICON);
					numberIcon.image = "/images/icones_google_map/pin" + index + ".png";
					numberIcon.iconSize =  new GSize(16, 27);
					numberIcon.shadowSize = new GSize(30, 27);
					markerOptions = { icon:numberIcon };*/

					
			/*		var marker = new GMarker(point,markerOptions);

						GEvent.addListener(marker, "click", function() {
																	 
						marker.openInfoWindowHtml(html);
						colorier(index);
						id_ouvert = index;
						
					});*/
					var marker = new google.maps.Marker({
						position: point,
						map: map,
					//	shadow: shadow,
						icon: image,
					//	shape: shape,
						title: name,
						zIndex: index
					});
					contents[index-1] = html;
					
					google.maps.event.addListener(marker, 'click', function() {
						var infowindow = new google.maps.InfoWindow({
							content: contents[index-1]
						});
						infowindow.open(map,marker);
						colorier(index);
						id_ouvert = index;
					});

					return marker;
				}
				
				retourxml=xml.responseXML;
				
				var nb = retourxml.getElementsByTagName('point').length;
				
				/*GEvent.addListener(lMap, "infowindowclose", function(){
					$('resultat_'+id_ouvert).style.background = 'none';
				});*/
				google.maps.event.addListener(map, 'infowindowclose', function() {
					$('resultat_'+id_ouvert).style.background = 'none';
				});
				
				
					for (var l = 0; l<nb; l++) {
						
						
					
						var lat = retourxml.getElementsByTagName('lat')[l].firstChild.nodeValue;
						var long = retourxml.getElementsByTagName('long')[l].firstChild.nodeValue;		
						var nom = retourxml.getElementsByTagName('nom')[l].firstChild.nodeValue;
						//commune[l] = retourxml.getElementsByTagName('commune')[l].firstChild.nodeValue;
						var adresse = retourxml.getElementsByTagName('adresse')[l].firstChild.nodeValue;
						var tel = retourxml.getElementsByTagName('tel')[l].firstChild.nodeValue;
						var email = retourxml.getElementsByTagName('email')[l].firstChild.nodeValue;
						var url = retourxml.getElementsByTagName('url')[l].firstChild.nodeValue;
						var id = retourxml.getElementsByTagName('id')[l].firstChild.nodeValue;
						var num = retourxml.getElementsByTagName('index')[l].firstChild.nodeValue;
								
						
						
					//	var point = new GLatLng(lat[l],long[l]);
						var point = new google.maps.LatLng(lat,long);
						var contenus = "<p align=center style='color:black'><b>"+nom+"</b></p>";
						if (adresse != '')
						{
							contenus += "<img src='/images/picto_adresse_services.jpg' alt='Adresse' title='Adresse' />&nbsp;"+adresse+"<br/>";
						}
						if (tel != '')
						{
							contenus += "<img src='/images/picto_contact_services.jpg' alt='Contact title='Contact />&nbsp;&nbsp;"+tel+"<br/>";
						}
						if (email != '')
						{
							contenus += "<img src='/images/picto_mail_services.jpg' alt='Courriel' title='Courriel' />&nbsp;<a href='mailto:"+email+"'>"+email+"</a><br/>";
						}
						if (url != '')
						{
							contenus += "<img src='/images/picto_site_services.jpg' alt='URL' title='URL' />&nbsp;&nbsp;<a href='http://"+url+"' target='_blank'>"+url+"</a><br/>";
						}
						markers[l] = createMarker(point,nom,contenus,l+1);
						//lMap.addOverlay(markers[l]);
											
					}
				
		}
/*		else
		{
			alert("Desole mais l'API Google Map n'est pas compatible avec votre navigateur");
		}*/
	}
	
	affichListe();
	
}

function affichListe(){
	
	
	new Ajax.Updater(
						'listeServices', 
						'/ajax/annuaire_LEI/listeService.php',
							{
								method:'post',
								parameters:'test=1'
							}
					); 
	$('selectRubrique').style.display = 'none';
	$('comHaut__commune').style.backgroundImage = 'url(/images/ot/encart_haut_service_resulta.jpg)';
	$('listeServices').style.display = 'block';
	
}

function ouvrirMarker(id){
//	markers[id-1].openInfoWindowHtml(contenus[id-1]);
var infowindow = new google.maps.InfoWindow({
	content: contents[id-1]
});
infowindow.open(map,markers[id-1]);
	colorier(id);
	id_ouvert = id;
}

function colorier(i){
	i = i.toString();
	$('resultat_' + i).style.backgroundColor = '#cccccc';
	
	document.location.href = '#resultat_' + i;
}
