

/**************************************************************
* Affiche une localisation sur la carte à partir du numéro
**************************************************************/
function afficheLocalisation(numero) {
	var nombrePoint = document.getElementById('f_pointgmap').value;
	trouveLocalisations(nombrePoint,numero,1);
}

/**************************************************************
* Supprime un marqueur	
**************************************************************/
function supprimeMarqueur() {
	plus_de_marqueur = true;
	map_globale.removeOverlay(le_marqueur)
	map_globale.closeInfoWindow();
}

/**************************************************************
* Valide Si position + zoom ... (True)	
* sinon retourne False
* ne pas changer ordre des tests !
**************************************************************/
function valideCarte(longitude,latitude,zoom) {
	var retour = false;
	// si je viens de la bulle
	if (longitude){
		var je_viens_de_la_bulle=true;
	}
	// si il n'y a pas de marqueur
	if (plus_de_marqueur){
		alert("Cliquez sur la carte afin d'ajouter un marqueur");
		var longitude = '';
		var latitude = '';
		var zoom  = '';
		retour = false;
	// si je viens du bouton valider et qu'il y a un marqueur
	}else if (!longitude){
		var position = le_marqueur.getPoint();
		var longitude = position.lng();
		var latitude = position.lat();
		var zoom  = map_globale.getZoom();
		var je_viens_de_la_bulle=false;
	}
	// derniere verif position !
	if (zoom != '' & longitude!= '' & latitude != '') {
		document.getElementById('f_longitude').value = longitude;
		document.getElementById('f_latitude').value = latitude;
		document.getElementById('f_zoom').value = zoom;
		retour = true;
	}else{
		retour = false;
	}
	if (retour){
		document.leform.submit();
	}
}

/**************************************************************
* Fonction de création de points et utilisation des icones
* Affiche : doit-on ouvrir le popup ou pas ?
**************************************************************/
/*function createMarker(point,numero,detail,avis,affiche) {
	
	// Définition des style d' icones
	var icone = new GIcon();
	icone.image = _chemin_icone+'numero'+numero+'.gif';
	icone.iconSize = new GSize(30,26);
	icone.iconAnchor = new GPoint(14,14);
	icone.infoWindowAnchor = new GPoint(14,14);
			
	// Action sur le clic
	var marker = new GMarker(point, icone);
	
	// 2 onglets (détails + avis)
	var infoTabs = [];
      infoTabs.push(new GInfoWindowTab("Détails", detail));
      infoTabs.push(new GInfoWindowTab("Avis", avis));

	
	GEvent.addListener(marker, "click", function() {
		marker.openInfoWindowTabsHtml(infoTabs);
	});
	
	map_globale.addOverlay(marker);
	
	if(affiche) {
		marker.openInfoWindowTabsHtml(infoTabs);
	}

	
	// Modification du style des onglets
	GEvent.addListener(map_globale, "infowindowopen", function() {
		var divs = map_globale.getContainer().getElementsByTagName("div");
		for(var i = 0; i<divs.length; i++) {
			var height = divs[i].style.height;
			var width = divs[i].style.width;
			
			// Un onglet est un bloc de longueur 103px sur 24px de haut
			if(width=="103px"&&height=="24px") {
				var newLabel = divs[i].innerHTML;
				var newText = "";
				if(newLabel!="") {
					var newText = '<span class="tabLink">' + newLabel + '</span>';
					divs[i].innerHTML = newText;
				}
				else {
					divs[i].innerHTML = "";
				}
			}
		}
	}); 
	
	
	return marker;
}*/

/**************************************************************
* Fonctions ecrireCookie & lireCookie
**************************************************************/
function ecrireCookie(nom, valeur){
	var argv=ecrireCookie.arguments;
	var argc=ecrireCookie.arguments.length;
	var expires=(argc > 2) ? argv[2] : null;
	var path=(argc > 3) ? argv[3] : null;
	var domain=(argc > 4) ? argv[4] : null;
	var secure=(argc > 5) ? argv[5] : false;
	document.cookie=nom+"="+escape(valeur)+
	((expires==null) ? "" : ("; expires="+expires.toGMTString()))+
	((path==null) ? "" : ("; path="+path))+
	((domain==null) ? "" : ("; domain="+domain))+
	((secure==true) ? "; secure" : "");
}

function getCookieVal(offset){
	var endstr=document.cookie.indexOf (";", offset);
	if (endstr==-1) endstr=document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

function lireCookie(nom){
	var arg=nom+"=";
	var alen=arg.length;
	var clen=document.cookie.length;
	var i=0;
	while (i<clen){
		var j=i+alen;
		if (document.cookie.substring(i, j)==arg) return getCookieVal(j);
		i=document.cookie.indexOf(" ",i)+1;
		if (i==0) break;
	}
	return null;
}