var map = null;								// L'Objet GMap2
var marqueurs = [];								// Tableau des marqueurs
var mgr = null;								// L'Objet GMarkerManager
var points = [
	{lat : 42.41078355118542,
	lon : 2.058391571044922,
	tooltip : 'Cerdagne Puigmal',
	info : '<p align="center"><b>Cerdagne Puigmal<\/b><\/p><p>Mairie<br\/>66800 ERR<br\/>T&eacute;l : 00 33 (0)4 68 04 72 94 ou 00 33 (0)4 68 04 70 15<br\/>Fax : 00 33 (0)4 68 04 78 02<br\/>Site : <a href="http://www.puigmal.fr" target="_blank">www.puigmal.fr<\/a><br\/>M&eacute;l : <a href="mailto:contact@puigmal.fr">contact.puigmal.fr<\/a><\/p>'
},
{
	lat : 42.474122772511485,
	lon : 2.1004486083984375,
	tooltip : 'Espace Cambre d\'Aze',
	info : '<p align="center"><b>Espace Cambre d\'Aze<\/b><\/p><p>Office du Tourisme Intercommunal du Cambre d\'Aze<br\/>Mairie 66800 EYNE<br\/>T&eacute;l : 00 33 (0)4 68 04 61 60<br\/>Fax : 00 33 (0)4 68 04 08 40<br\/>Site : <a href="http://www.cambre-d-aze.com" target="_blank">www.cambre-d-aze.com<\/a><br\/>M&eacute;l : <a href="mailto:oti-cambredaze@orange.fr">oti-cambredaze@orange.fr<\/a><\/p>'
},
{
	lat : 42.502984199407415,
	lon : 2.039337158203125,
	tooltip : 'Font-Romeu',
	info : '<p align="center"><b>Font-Romeu<\/b><\/p><p><b>Font-Romeu<\/b><br\/>T&eacute;l : 00 33 (0)4 68 30 68 30<br\/>Fax : 00 33 (0)4 68 30 29 70<br\/>Site : <a href="http://www.font-romeu.fr" target="_blank">www.font-romeu.fr<\/a><br\/>M&eacute;l : <a href="mailto:office@font-romeu.fr">office@font-romeu.fr<\/a><\/p>'
},
{
	lat : 42.520193446554025,
	lon : 2.0619964599609375,
	tooltip : 'Pyr&eacute;n&eacute;es 2000',
	info : '<p align="center"><b>Pyr&eacute;n&eacute;es 2000<\/b><\/p><p><b>Office du Tourisme de Pyr&eacute;n&eacute;es 2000<\/b><br\/>BP 12 66210 BOLQUERE<br\/>T&eacute;l : 00 33 (0)4 68 30 12 42<br\/>Fax : 00 33 (0)4 68 30 16 84<br\/>Site : <a href="http://www.pyrenees2000.com" target="_blank">www.pyrenees2000.com<\/a><br\/>M&eacute;l : <a href="mailto:infos@pyrenees2000.com">infos@pyrenees2000.com<\/a><\/p>'
},
{
	lat : 42.61374895431491,
	lon : 2.1018218994140625,
	tooltip : 'Formigu&egrave;res',
	info : '<p align="center"><b>Formigu&egrave;res<\/b><\/p><p>Office du Tourisme<br\/>Place de la Mairie<br\/>66210 FORMIGUERES<br\/>T&eacute;l : 00 33 (0)4 68 04 47 35<br\/>Fax : 00 33 (0)4 68 04 43 51<br\/>Site : <a href="http://www.formigueres.net" target="_blank">www.formigueres.net<\/a><br\/>M&eacute;l : <a href="mailto:formigueres.tourisme@laposte.net">formigueres.tourisme@laposte.net<\/a><\/p>'
},
{
	lat : 42.57786045892046,
	lon : 2.0751285552978516,
	tooltip : 'Les Angles',
	info : '<p align="center"><b>Les Angles<\/b><\/p><p>Office du Tourisme<br\/>2, Avenue de l\'Aude<br\/>66210 LES ANGLES<br\/>T&eacute;l : 00 33 (0)4 68 04 32 76<br\/>Fax : 00 33 (0)4 68 309 309<br\/>Site : <a href="http://www.lesangles.com" target="_blank">www.lesangles.com<\/a><br\/>M&eacute;l : <a href="mailto:les-angles@les-angles.com">les-angles@les-angles.com<\/a><\/p>'
},
{
	lat : 42.541761580708744,
	lon : 2.1186447143554688,
	tooltip : 'La Quillane',
	info : '<p align="center"><b>La Quillane<\/b><\/p><p>Station de ski La Quillane<br\/>66210 LA LLAGONNE<br\/>T&eacute;l / Fax : 00 33 (0)4 68 04 22 25<br\/>Site : <a href="http://www.laquillane.fr" target="_blank">www.laquillane.fr<\/a><br\/>M&eacute;l : <a href="mailto:laquillane@wanadoo.fr">laquillane@wanadoo.fr<\/a><\/p>'
},
{
	lat : 42.54751604081074,
	lon : 1.8299102783203125,
	tooltip : 'Port&eacute;-Puymorens',
	info : '<p align="center"><b>Port&eacute;-Puymorens<\/b><\/p><p>Ch&acirc;let Accueil<br\/>66760 PORTE-PUYMORENS<br\/>T&eacute;l : 00 33 (0)4 68 04 82 41 ou 00 33 (0)4 68 04 82 16<br\/>Fax : 00 33 (0)4 68 04 85 82<br\/>Site : <a href="http://www.porte-puymorens.net" target="_blank">www.porte-puymorens.net<\/a><br\/>M&eacute;l : <a href="mailto:rmsl.porte.puymorens@wanadoo.fr">rmsl.porte.puymorens@wanadoo.fr<\/a><\/p>'
},
{
	lat : 42.6465864963202,
	lon : 2.118988037109375,
	tooltip : 'Puyvalador',
	info : '<p align="center"><b>Puyvalador<\/b><\/p><p>Immeuble Les Sorbiers<br\/>66210 PUYVALADOR<br\/>T&eacute;l : 00 33 (0)4 68 04 44 83<br\/>Fax : 00 33 (0)4 68 04 41 01<br\/>Site : <a href="http://www.puyvalador.com" target="_blank">www.puyvalador.com<\/a><br\/>M&eacute;l : <a href="mailto:station@puyvalador.com">station@puyvalador.com<\/a><\/p>'
},
{
	lat : 42.53486817758702,
	lon : 2.0935821533203125,
	tooltip : 'Espace Nordique du Capcir',
	info : '<p align="center"><b>Espace Nordique du Capcir<\/b><\/p><p>Maison du Capcir<br\/>66210 LA LLAGONNE<br\/>T&eacute;l : 00 33 (0)4 68 04 49 86<br\/>Fax : 00 33 (0)4 68 04 37 97<br\/>Site : <a href="http://www.capcir-nordique.com" target="_blank">www.capcir-nordique.com<\/a><br\/>M&eacute;l : <a href="mailto:contact@capcir-pyrenees.com">contact@capcir-pyrenees.com<\/a><\/p>'
},
{
	lat : 42.4582741818,
	lon : 2.0388926782,
	tooltip : 'Pyrénées Cerdagne',
	info : '<p align="center"><b>Pyrénées Cerdagne<\/b><\/p><p>1, Place del Roser<br\/>66800 SAILLAGOUSE<br\/>T&eacute;l : 00 33 (0)4 68 04 15 47<br\/>Site : <a href="http://www.pyrenees-cerdagne.com">www.pyrenees-cerdagne.com<\/a><br\/>M&eacute;l : <a href="mailto:contact@pyrenees-cerdagne.com">contact@pyrenees-cerdagne.com<\/a><\/p>'
}];		// La liste des informations à afficher

/* --------------------------------- Gestion des ToolTips ------------------------------------- */
function ToolTip(marker,html,width) 
{
	this.html_ = html;
	this.width_ = (width ? width + 'px' : 'auto');
	this.marker_ = marker;
}
 
ToolTip.prototype = new GOverlay();
 
ToolTip.prototype.initialize = function(map) 
{
	var div = document.createElement("div");
	div.style.display = 'none';
	map.getPane(G_MAP_FLOAT_PANE).appendChild(div);
	 
	this.map_ = map;
	this.container_ = div;
}
 
ToolTip.prototype.remove = function() 
{
	this.container_.parentNode.removeChild(this.container_);
}
 
ToolTip.prototype.copy = function() 
{
	return new ToolTip(this.html_);
}
 
ToolTip.prototype.redraw = function(force) 
{
	if (!force) return;
	 
	var pixelLocation = this.map_.fromLatLngToDivPixel(this.marker_.getPoint());
	this.container_.innerHTML = this.html_;
	this.container_.style.position = 'absolute';
	this.container_.style.left = pixelLocation.x + "px";
	this.container_.style.top = pixelLocation.y + "px";
	this.container_.style.width = this.width_;
	this.container_.style.font = 'bold 10px/10px verdana, arial, sans';
	this.container_.style.border = '1px solid black';
	this.container_.style.background = 'yellow';
	this.container_.style.padding = '4px';
	 
	//one line to desired width
	this.container_.style.whiteSpace = 'nowrap';
	if(this.width_ != 'auto') this.container_.style.overflow = 'hidden';
	this.container_.style.display = 'block';
}
 
GMarker.prototype.ToolTipInstance = null;
 
GMarker.prototype.openToolTip = function(content) 
{
	//don't show the tool tip if there is acustom info window
	if(this.ToolTipInstance == null) 
	{
		this.ToolTipInstance = new ToolTip(this,content)
		map.addOverlay(this.ToolTipInstance);
	}
}
 
GMarker.prototype.closeToolTip = function() 
{
	if(this.ToolTipInstance != null) 
	{
		map.removeOverlay(this.ToolTipInstance);
		this.ToolTipInstance = null;
	}
}
// --------------------------------- Ajout des Points
function ajoutePoint(latitude, longitude, description, tooltip)
{
	var p = new GMarker(new GLatLng(latitude, longitude), {draggable: false});
	GEvent.addListener(p, 'click', function () {
		p.openInfoWindowHtml(description);
	});
	GEvent.addListener(p,'mouseover',function() {
		p.openToolTip(tooltip);
	});
	GEvent.addListener(p,'mouseout',function() {
		p.closeToolTip();
	});
	marqueurs.push(p);
}

function ajoutPoints()
{
	mgr = new GMarkerManager(map);
	for (var i = 0; i < points.length; i++)	//>id in points)
	{
		ajoutePoint(points[i].lat, points[i].lon, points[i].info, points[i].tooltip);
	}
	mgr.addMarkers(marqueurs, 3, 17);
	mgr.refresh();
}

function gmap_load() 
{
	if (GBrowserIsCompatible()) 
	{
		map = new GMap2(document.getElementById("carte_cerdagne_capcir"));
		map.addMapType(G_PHYSICAL_MAP);
		map.addControl(new GLargeMapControl());
		map.addControl(new GScaleControl());
		map.addControl(new GMapTypeControl());
		map.setCenter(new GLatLng(42.532844281713125, 1.984405517578125), 11);
		map.setMapType(G_PHYSICAL_MAP);
		window.setTimeout(ajoutPoints, 0)
	}
}
