//////////////////////////////////////////////////////////////////////////////////////////
//
// This script is concieved and created by Jesse Schulman (http://year2032.com). (c) 2006 
//
// He cut and pasted a lot from others. Feel free to use this script in any way you like. 
//
//                                                                                        
//
// This program is free software; you can redistribute it and/or modify it under the      
//
// terms of the GNU General Public License as published by the Free Software Foundation;  
//
// either version 2 of the License, or (at your option) any later version.                
//
//                                                                                        
//
// This program is distributed in the hope that it will be useful, but WITHOUT ANY        
//
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A        
//
// PARTICULAR PURPOSE.  See the GNU General Public License for more details.              
//
//                                                                                        
//
// http://www.gnu.org/licenses/gpl.html                                                   
//
//////////////////////////////////////////////////////////////////////////////////////////
//

// Function for the Markers(color)

	
function Markers(color){

	
map.closeInfoWindow();

	   
var panel = document.getElementById("sidebar");
           
panel.innerHTML = null;
           
var sidebar_html = "";


	   
if (document.getElementById(color).checked==false) { 
// hide the marker
	      
for (var i=0;i<gmarkers.length;i++) {
	         
if (gmarkers[i].type==color)  {
	            
map.removeOverlay(gmarkers[i]);
	         }
	      }
	   } else { 
// show the marker again
	      
for (var i=0;i<gmarkers.length;i++) {
	         
if (gmarkers[i].type==color)  {
	            
map.addOverlay(gmarkers[i]);
	         }
	      }
	   }

	   
for (var i=0; i<gmarkers.length;i++) {
              
if (document.getElementById(gmarkers[i].type).checked)  {
                 
if (gmarkers[i].type != "purple") {
                    
sidebar_html += '<a href="javascript:myclick(' + i + ')">' + gmarkers[i].departement + ' - ' + gmarkers[i].ville + ' - ' + gmarkers[i].name + '</a><br>';
                 }
              }
          }
          panel.innerHTML = sidebar_html;
	}
	

// END of Function for the Markers(color)


// Function for the coloredRideshareIcon(iconColor)

	
function coloredRideshareIcon(iconColor) {
	   
var color;
	   
if ((typeof(iconColor)=="undefined") || (iconColor==null)) {
	      
color = "green" 
	   } else { 
	      
color = iconColor; 
	   }
	   
if (!icons[iconColor]) {
	      
var icon = new GIcon(baseIcon);
	      
icon.image = "mm_20_"+ color +".png";
	      
icons[iconColor]=icon;
	
	   } 
	   
return icons[iconColor];
	}


// END of Function for the coloredRideshareIcon(iconColor)



// Function to create the marker and set up the event window - createMarker(point,office,name,html,iconStr)

        
function createMarker(point,departement,ville,office,name,html,iconStr) {
           
var icon = coloredRideshareIcon(iconStr);
	   
var marker = new GMarker(point,icon);
           
if (iconStr) {
	      
marker.type = iconStr;
           } else {
              
marker.type = "purple";
           }
           
marker.name = office

;
marker.departement = departement

;
marker.ville = ville

;
// Zoom in and out
          
html = html + '<br><a href="javascript:zoomIN('+i+');">Zoom [+]</a> <a href="javascript:zoomOUT();">Retour à la carte initiale</a>'

          
// The info window version with the "to here" form open
          
// to_htmls[i] = html + 
             '<div class="popup">' +
             '<br>Trajets: <b>Vers ce lieu</b> - <a href="javascript:fromhere(' + i + ')">A partir de ce lieu</a>' +
             '<form action="http://maps.google.com/maps" method="get" target="_blank">' +
             '<input type="text" SIZE=50 MAXLENGTH=60 name="saddr" id="saddr" value="Adresse de départ (numéro, rue, ville)" style="background-color: #DEDEDE" onClick="javascript:this.form.saddr.select();" /><br>' +
             '<INPUT value="Voir l\'itin&#233;raire" TYPE="SUBMIT">' +
             '<input type="hidden" name="daddr" value="' + point.lat() + ',' + point.lng() + "(" + name + ")" + 
             '"/>' +
             '</div>';

          
// "to" modifié en supprimant "name"
to_htmls[i] = html + 
             '<div class="popup">' +
             '<br>Trajets: <b>Vers ce lieu</b> - <a href="javascript:fromhere(' + i + ')">A partir de ce lieu</a>' +
             '<form action="http://maps.google.com/maps" method="get" target="_blank">' +
             '<input type="text" SIZE=50 MAXLENGTH=60 name="saddr" id="saddr" value="Adresse de départ (numéro, rue, ville)" style="background-color: #DEDEDE" onClick="javascript:this.form.saddr.select();" /><br>' +
             '<INPUT value="Voir l\'itin&#233;raire" TYPE="SUBMIT">' +
             '<input type="hidden" name="daddr" value="' + point.lat() + ',' + point.lng() +            '"/>' +
             '</div>';

          
// The info window version with the "from here" form open
          
// "from" modifié en supprimant "name"
//from_htmls[i] = html +
             '<div class="popup">' +
             '<br>Trajets: <a href="javascript:tohere(' + i + ')">Vers ce lieu</a> - <b>A partir de ce lieu</b>' +
             '<form action="http://maps.google.com/maps" method="get"" target="_blank">' +
             '<input type="text" SIZE=50 MAXLENGTH=60 name="daddr" id="daddr" value="Adresse d\'arrivée (numéro, rue, ville)" style="background-color: #DEDEDE" onClick="javascript:this.form.daddr.select();" /><br>' +
             '<INPUT value="Voir l\'itin&#233;raire" TYPE="SUBMIT">' +
             '<input type="hidden" name="saddr" value="' + point.lat() + ',' + point.lng() + "(" + name + ")" +
             '"/>' +
             '</div>';


          
from_htmls[i] = html +
             '<div class="popup">' +
             '<br>Trajets: <a href="javascript:tohere(' + i + ')">Vers ce lieu</a> - <b>A partir de ce lieu</b>' +
             '<form action="http://maps.google.com/maps" method="get"" target="_blank">' +
             '<input type="text" SIZE=50 MAXLENGTH=60 name="daddr" id="daddr" value="Adresse d\'arrivée (numéro, rue, ville)" style="background-color: #DEDEDE" onClick="javascript:this.form.daddr.select();" /><br>' +
             '<INPUT value="Voir l\'itin&#233;raire" TYPE="SUBMIT">' +
             '<input type="hidden" name="saddr" value="' + point.lat() + ',' + point.lng() +
             '"/>' +
             '</div>';


          
// The inactive version of the direction info
          
html = html + '<br>Trajets: <a href="javascript:tohere('+i+')">Vers ce lieu</a> - <a href="javascript:fromhere('+i+')">A partir de ce lieu</a>';


          GEvent.addListener(marker, "click", function() {
            marker.openInfoWindowHtml(html);
          });

          
// add a line to the sidebar html
          
if (marker.type != "purple") {
                    
sidebar_html += '<a href="javascript:myclick(' + i + ')">' + departement + office + '</a><br>';
          }

      
//    panel = document.getElementById("sidebar");
      
//    panel.innerHTML = sidebar_html;

          
gmarkers[i] = marker;
          
htmls[i] = html;
          
i++;
          
return marker;
        }


// END of Function to create the marker and set up the event window - createMarker(point,office,name,html,iconStr)
