//<![CDATA[
		   
// definition des variables
var map;
var geocoder;
var marker;
var html ="";
var gdir;

/*-----------------------------------------------------------------*/
/*--------------- DEFINITON DES MARKERS --------------*/
/*-----------------------------------------------------------------*/

//picto vente
    var vente = new GIcon(); /*
    vente.image = 'front/lib/images/vente.png';
    vente.shadow = 'front/lib/images/ombre.png';
    vente.iconSize = new GSize(30, 31);
    vente.shadowSize = new GSize(56, 31);
    vente.iconAnchor = new GPoint(6, 20);
    vente.infoWindowAnchor = new GPoint(5, 1); */

//picto accastillage
    var accastillage = new GIcon(); 
    accastillage.image = 'front/lib/images/accastillage.png';
    accastillage.shadow = 'front/lib/images/ombre.png';
    accastillage.iconSize = new GSize(31, 31);
    accastillage.shadowSize = new GSize(56, 31);
    accastillage.iconAnchor = new GPoint(6, 20);
    accastillage.infoWindowAnchor = new GPoint(5, 1);


//parametrage des picto suivant type
    var customIcons = [];
    customIcons["A"] = vente;
    customIcons["B"] = accastillage;

/*-----------------------------------------------------------------*/
/*--------------- CREATION DES MARKERS --------------*/
/*-----------------------------------------------------------------*/

function createMarker(point, lib, num_rue, cp_ville, tel, fax, mail, itineraire) {
	
	//choix du type de marqueur a affichier (picto)
	var marker = new GMarker(point, {title:lib});
	
	//definition de l'infos bulle
	var html = "<div style='line-height:14px'>";
		html += "<span><strong>"+ lib + "</strong></span><br />";
		html += num_rue + "<br />"+ cp_ville + "<br />";
		html += "<span><strong>T&eacute;l.</strong></span>"+ tel + "<br />";
		html += "<span><strong>Fax.</strong></span>"+ fax + "<br />";
		html += "<span><strong>Mail :</strong></span>"+ mail + "<br /><br />";
		
		html += '<span><strong>Comment venir nous voir :</strong></span>';
		html += '<form action="#" onsubmit="setDirections'+ itineraire + '(this.from.value); return false">';
		html += 'Adresse de depart:&nbsp;<br />';
		html += '<input type="text" size="10" id="fromAddress" name="from" />';
		html += '<input name="submit" type="submit" value="Itin&eacute;raire" /></form>';
		html += "<br />";
		html += "</div>";

      	//ecouteur d'evenement pr ouvrir l'info-bulle sur clic
      GEvent.addListener(marker, 'click', function() {
        marker.openInfoWindowHtml(html);
      });
	
	return marker;
}    

/*---------------------------------------------------*/
/*--------------- AFFICHAGE DES CARTES --------------*/
/*---------------------------------------------------*/

function map_contact() { 

     if (GBrowserIsCompatible()) { 

	//si le navigateur est compatible avec google map
        //definition de la carte
	map = new GMap2(document.getElementById("map_contact"));
	
	gdir = new GDirections(map, document.getElementById("directions"));
	//GEvent.addListener(gdir, "load", onGDirectionsLoad);
	//GEvent.addListener(gdir, "error", handleErrors);

	// ajoute les boutons de controle de zoom et de deplacement
	map.addControl(new GLargeMapControl()); //ligne de zoom
	map.addControl(new GMapTypeControl()); //bouton vue satellite ect..
	map.addControl(new GOverviewMapControl()); //mini-map coin inferieur
	
	//centrage de la carte
        map.setCenter(new GLatLng(43.141336,6.347716), 15);

	var bounds = new GLatLngBounds();
	
	var pointB = new GLatLng(43.136624,6.366073);
	marker = createMarker(pointB, "Espace Power / Accastillage Diffusion", "Mole Est. Nouveau Port ", "83980 Le Lavandou", "+(33)4 94 71 69 21", "+(33)4 94 71 39 41", "contact@espacepower.com", "B");
	map.addOverlay(marker); bounds.extend(pointB);

	var pointA = new GLatLng(43.141336,6.347716);
	marker = createMarker(pointA, "Espace Power / Vente & direction", "300 rue des Rapugues", "83230 BORMES LES MIMOSAS", "+(33)4 94 71 13 55", "+(33)4 94 71 13 21", "contact@espacepower.com", "A");
	map.addOverlay(marker); bounds.extend(pointA);
	
	map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds)-1);
      }   
  
  }
 
/*---------------------------------------------------*/
/*--------------- MAPPY --------------*/
/*---------------------------------------------------*/ 
  
  function setDirectionsA(fromAddress) {
      gdir.load("from: " + fromAddress + " to: " + "300 rue des Rapugues 83230 BORMES LES MIMOSAS",
                { "locale": "fr" });
    }
	
  function setDirectionsB(fromAddress) {
      gdir.load("from: " + fromAddress + " to: " + "300 rue des Rapugues 83230 BORMES LES MIMOSAS",
                { "locale": "fr" });
    }
//]]>  