var map;

function mapLoad(file) {

	var geoXml = new GGeoXml(file);
	if (GBrowserIsCompatible()) {
		map = new GMap2($("map_canvas"));
		map.setUIToDefault();
		map.setCenter(new GLatLng(46.9, 1.75), 5);
		map.addOverlay(geoXml);
		geoXml.gotoDefaultViewport(map);
	 }
}

function mapInit() {
	if (GBrowserIsCompatible()) {
		map = new GMap2($("map_canvas"));
		map.setCenter(new GLatLng(16.00, -1.00), 2);
		map.setUIToDefault();
	 }
}

function mapAddSite(x, y, nom, lien, exploitant, puissance, contructeur, modele, nbmodele, date) {
	
	var icone = new GIcon(G_DEFAULT_ICON);
	icone.image = "scripts/img/picto.gif";
	icone.shadow = "scripts/img/ombre.png";
	icone.iconSize = new GSize(21, 24);
	icone.iconAnchor = new GPoint(11, 24);
	var html = '';
	html += (exploitant != '')?'<b>Exploitant : </b>'+exploitant+'<br />':'';
	html += '<b>Puissance totale installée : </b>'+puissance+' MW<br />';
	html += (contructeur != '')?'<b>Contructeur : </b>'+contructeur+'<br />':'';
	html += (modele != '')?'<b>Type de modèle : </b>'+modele+'<br />':'';
	html += (modele != '')?'<b>Nombre d\'aérogènerateurs : </b>'+nbmodele+'<br />':'';
	html += (date != '')?'<b>Date de mise en service : </b>'+date+'<br />':'';
	
	var content = new Element('div', {
						'html': '<b>Parc : </b><a href="'+lien+'" style="color: blue; font-size: 1.1em;">'+nom+'</a>'});
	var desc = new Element('p', {
						'html': html,
						'style': 'text-align: left;margin-top:10px;'});
	desc.inject(content);
	
	var marker = new GMarker(new GLatLng(x, y), {icon:icone, title:nom});
	GEvent.addListener(marker, "click", function() {
    	marker.openInfoWindow(content);
	});

	map.addOverlay(marker);
}
