// fonction necessaire à la carte google
var icon = new GIcon();
icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
icon.iconSize = new GSize(17, 18);
icon.shadowSize = new GSize(0, 0);
icon.iconAnchor = new GPoint(7, 7);
icon.infoWindowAnchor = new GPoint(2, 1);
// icones differentes en fonction de l etape
var tabIcones = new Array("/images/house.gif","/images/pillule_depart2.gif","/images/pillule_arrivee2.gif","/images/star.gif")



function createMarker(point, info, sens) {
  var marker = new GMarker(point, icon);
  icon.image = tabIcones[sens];
  
  GEvent.addListener(marker, "click", function() {
    marker.openInfoWindowHtml(""+info);
  });
  return marker;
}


// fonction qui permet la creation des markers des aeroports en Europe
function Jean_createMarket(point,infos){

  var opts = {icon: icon,clickable: true,title: name};

  var newPoint = point;
  var marker = new LabeledMarker(newPoint, opts);

  GEvent.addListener(marker, "click", function() {
    var html = '<table class=\"bluebox\" cellspacing=\"0\" width=\"200\"><tr><td align=\"center\"><b>'+ infos['name'] +'</b></td></tr><tr class=\"L1\"><td><b>&nbsp;'+ infos['nbVols'] +'</b> vols depuis cet aéroport</td></tr><tr><td align=\"center\"><a href=\"/low+cost+'+ infos['ville'] +'+'+ infos['code'] +'.html\" class=\"tetiereMini\"><img src=\"/images/arrow_right.gif\" border=\"0\">&nbsp;<b>Plus de détails</b></a></td></tr></table>';
    marker.openInfoWindowHtml(html);
  });
  GEvent.addListener(marker, "mouseover", function() {
    marker.setImage('/images/pillule_arrivee2.gif');
  });
  GEvent.addListener(marker, "mouseout", function() {
    marker.setImage('/images/pillule_depart2.gif');
  });
  
return marker;
}

// cette fonction genere un parcours sur une map en fonction du tableau qui lui ai envoyé
function genereTraceMap(tabMap){
  // tabMap = array("type"=>(ville,apt),"longitude"=>(float),"latitude"=>(float));
  map.clearOverlays();
  var polyOptions = {geodesic:true};
    
  for(var i=0;i<4;i++){
    if(typeof(tabMap[i][1]) != "undefined"){
      var latlng = new GLatLng(tabMap[i][1],tabMap[i][2]);
      if(tabMap[i][0] == 'ville')
        var txt = 'Ville de '+tabMap[i][3];
      else
        var txt = 'Aéroport de '+tabMap[i][3]; 
      map.addOverlay(createMarker(latlng, txt, i));
      
      if(i>0){
      var polyline = new GPolyline([
            new GLatLng(prevLat, prevLong),
            new GLatLng(tabMap[i][1], tabMap[i][2])
            ],"#74A8F5", 5, 1, polyOptions);
          map.addOverlay(polyline);
      }
      var prevLat = tabMap[i][1];
      var prevLong = tabMap[i][2];             
    }
  }
  
  afficheOnglet('map');
}
