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



function afficheRubrique(id,page)
{
	
	for(i=213000060;i<213000084;i++)
	{
		$(''+i+'').style.backgroundColor = '#f5faf9';	
	}
	
	$(''+id+'').style.backgroundColor = '#a8a8a8';
	
		
	$('GoogleMapBarr').style.display = 'none';	
	$('pasResultat').style.display = 'none';
	
	new Ajax.Updater(
						'infosServices', 
						'http://www.pays-de-barr.fr/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 contenus = new Array();

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 lMap = new GMap2(document.getElementById("GoogleMapBarr"));
				lMap.enableDoubleClickZoom();
				lMap.enableContinuousZoom();
				lMap.addControl(new GLargeMapControl());
				lMap.addControl(new GMapTypeControl());
				
				//Coordonnes de Stotzheim 
				lMap.setCenter(new GLatLng(48.380277,7.492222), 11);

				// 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 numberIcon = new GIcon(G_DEFAULT_ICON);
					numberIcon.image = "http://www.pays-de-barr.fr/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;
						
					});
						
					gmarkers[i] = marker;
					htmls[i] = html;
					i++;
					return marker;
				}
				
				retourxml=xml.responseXML;
				
				var nb = retourxml.getElementsByTagName('point').length;
				
				
				GEvent.addListener(lMap, "infowindowclose", function(){
					
					$('resultat_'+id_ouvert).style.background = 'none';
					
					
				});
				
					for (var l = 0; l<nb; l++) {
						
						nom = new Array();
						lat = new Array();
						long = new Array();
						commune = new Array();
						adresse = new Array();
						tel = new Array();
						email = new Array();
						url = new Array();
						id = new Array();
						num = new Array();
					
						lat[l] = retourxml.getElementsByTagName('lat')[l].firstChild.nodeValue;
						long[l] = retourxml.getElementsByTagName('long')[l].firstChild.nodeValue;		
						nom[l] = retourxml.getElementsByTagName('nom')[l].firstChild.nodeValue;
						//commune[l] = retourxml.getElementsByTagName('commune')[l].firstChild.nodeValue;
						adresse[l] = retourxml.getElementsByTagName('adresse')[l].firstChild.nodeValue;
						tel[l] = retourxml.getElementsByTagName('tel')[l].firstChild.nodeValue;
						email[l] = retourxml.getElementsByTagName('email')[l].firstChild.nodeValue;
						url[l] = retourxml.getElementsByTagName('url')[l].firstChild.nodeValue;
						id[l] = retourxml.getElementsByTagName('id')[l].firstChild.nodeValue;
						num[l] = retourxml.getElementsByTagName('index')[l].firstChild.nodeValue;
								
						
						
						var point = new GLatLng(lat[l],long[l]);
						contenus[l] = "<p align=center style='color:black'><b>"+nom[l]+"</b></p>";
						if (adresse[l] != '')
						{
							contenus[l] += "<img src='http://www.pays-de-barr.fr/images/picto_adresse_services.jpg' alt='Adresse' title='Adresse' />&nbsp;"+adresse[l]+"<br/>";
						}
						if (tel[l] != '')
						{
							contenus[l] += "<img src='http://www.pays-de-barr.fr/images/picto_contact_services.jpg' alt='Contact title='Contact />&nbsp;"+tel[l]+"<br/>";
						}
						if (email[l] != '')
						{
							contenus[l] += "<img src='http://www.pays-de-barr.fr/images/picto_mail_services.jpg' alt='Courriel' title='Courriel' />&nbsp;<a href='mailto:"+email[l]+"'>"+email[l]+"</a><br/>";
						}
						if (url[l] != '')
						{
							contenus[l] += "<img src='http://www.pays-de-barr.fr/images/picto_site_services.jpg' alt='URL' title='URL' />&nbsp;&nbsp;<a href='http://"+url[l]+"' target='_blank'>"+url[l]+"</a><br/>";
						}
						
						
						markers[l] = createMarker(point,"hdr",contenus[l],num[l]);
						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', 
						'http://www.pays-de-barr.fr/ajax/annuaire_LEI/listeService.php',
							{
								method:'post',
								parameters:'test=1'
							}
					); 
	$('selectRubrique').style.display = 'none';
	$('comHaut').style.backgroundImage = 'url(http://www.pays-de-barr.fr/images/encart_haut_service_resulta.jpg)';
	$('listeServices').style.display = 'block';
	
}

function ouvrirMarker(id){
	markers[id-1].openInfoWindowHtml(contenus[id-1]);
	colorier(id);
	id_ouvert = id;
}

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




