////////////////////////////////////////////////////////////////////////////////////////////
// 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 += '<table width="100%" border="1" cellpadding="0" cellspacing="4" bordercolor="#D5D5D5"><tr><td width="24"><img src="http://www.ibizasummervillas.com/iconos_google/'+ gmarkers[i].type +'.png" alt="bar" width="24" height="24" /></td><td><a href="javascript:myclick(' + i + ')">' + gmarkers[i].name + '</a><br></td></tr></table>';
                 }
              }
          }
          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 = "http://www.ibizasummervillas.com/iconos_google/"+ 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,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

           // Zoom in and out
          html = html + '<br><a href="javascript:zoomIN('+i+');">Zoom In</a> <a href="javascript:zoomOUT();">Zoom Out</a>'

          // The info window version with the "to here" form open
          to_htmls[i] = html + 
             '<div class="popup">' +
             
             '</div>';

          // The info window version with the "from here" form open
          from_htmls[i] = html +
             '<div class="popup">' +
             
             '</div>';


          // The inactive version of the direction info
          html = html ;


          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 + ')">' + 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)