//<![CDATA[

var route_html;

LANG = { 
	title_tab_1 : 'Adres',
	title_tab_2 : 'Route',
	url : 'http://www.maps.google.nl',
	van : 'Route van',
	naar : 'Route naar',
	adres : 'Adres',
	plaats : 'Plaats',
	submit : 'Toon route'
	};

	function toggleLink ( switcher , selector ){
		link = document.getElementById('routeplanner_form').getElementsByTagName("a");
		for(i=0; i<link.length; i++)	{
			link[i].style.color = '#707070';	
		}
		switch(switcher)
		{			
			case 'route_to':
				document.getElementById('route_adres_input').name = 'saddr'; 
				document.getElementById('route_locatie_input').name = 'daddr';
				selector.style.color = '#6261d8';
				break;
				
			case 'route_from':
				document.getElementById('route_adres_input').name = 'daddr'; 
				document.getElementById('route_locatie_input').name = 'saddr';
				selector.style.color = '#6261d8';	
				break;
		}
	}
		

    // Check to see if this browser can run the Google API
    if (GBrowserIsCompatible()) {
    
      // ==================================================
      // A function to create a tabbed marker and set up the event window
      function createTabbedMarker(point,html1,html2,label1,label2) {
        var marker = new GMarker(point);
        GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowTabsHtml([new GInfoWindowTab(label1,html1), new GInfoWindowTab(label2,html2)]);
        });
		marker.openInfoWindowTabsHtml([new GInfoWindowTab(label1,html1), new GInfoWindowTab(label2,html2)]);
        return marker;
      }
      // ==================================================
      var points = ebb_coordinates.split(",");      

 
      // Display the map, with some controls and set the initial location 
      var map = new GMap2(document.getElementById("googlemaps"));
      map.addControl(new GSmallZoomControl3D());
      map.addControl(new GMapTypeControl());
	  if(ebb_type_kaart == "satelliet")	map.setMapType(G_SATELLITE_MAP);
		else if(ebb_type_kaart == "beide")	map.setMapType(G_HYBRID_MAP);
		else						map.setMapType(G_NORMAL_MAP);
      map.setCenter(new GLatLng(points[0], points[1]), ebb_zoom);
    
      // ==================================================
      // Set up the tabbed markers

      var point = new GLatLng(points[0], points[1]);

	  var route_html =  "<form style='text-align:left' method=\"get\" action=\""+ LANG.url +"\" ";
	  route_html += "onsubmit=\"document.getElementById('route_adres_input').value = document.getElementById('straat_input').value +' '+ document.getElementById('routeplanner_plaats').value;\" ";
	  route_html += "id=\"routeplanner_form\" target=\"_blank\">";
	  route_html += "<input id=\"route_adres_input\" type=\"hidden\" name=\"saddr\" size=\"20\" value=\"\" />";
	  route_html += "<input id=\"route_locatie_input\" type=\"hidden\" name=\"daddr\" value=\""+ point.lat() +","+ point.lng() +" ("+ ebb_adres +")\" />";
	  route_html += "<label for=\"straat_input\">"+ LANG.adres +":</label><br /><input id=\"straat_input\" type=\"text\" name=\"straat\" size=\"30\" value=\"\" /><br />";
	  route_html += "<label for=\"routeplanner_plaats\">"+ LANG.plaats +":</label><br /><input id=\"routeplanner_plaats\" type=\"text\" name=\"plaats\" size=\"30\" value=\"\" /><br />";
	  route_html += "<div id=\"links\" style='clear:both'><a href=\"#\" style=\"color:#6261d8;\" onclick=\"toggleLink('route_to', this); return false;\" title=\""+ LANG.naar +"\">"+ LANG.naar +"</a> - ";
	  route_html += "<a href=\"#\" style=\"color:#707070;\"  return false;\" onclick=\"toggleLink('route_from', this); return false;\" title=\""+ LANG.van +"\">"+ LANG.van +"</a></div>";  
	  route_html += "<input class=\"route_button\" id=\"routeplanner_submit\" type=\"submit\" style=\"margin-top:10px;\" value=\""+ LANG.submit +"\" title=\""+ LANG.submit +"\" /><br /><br />";
	  route_html += "</form>";

      var marker = createTabbedMarker(point, ebb_html, route_html, LANG.title_tab_1, LANG.title_tab_2);
      map.addOverlay(marker);

     // var point = new GLatLng(43.65654,-79.90138);
      //var marker = createTabbedMarker(point, "is the time for all good men<br>to come to the aid of the party", "a dangerous temptation comes to us<br>in gay, fine colours", "Now", "Many");
      //map.addOverlay(marker);
    }
 
    
    // display a warning if the browser was not compatible
    else {
      alert("Sorry, the Google Maps API is not compatible with this browser");
    }
 
    // This Javascript is based on code provided by the
    // Community Church Javascript Team
    // http://www.bisphamchurch.org.uk/   
    // http://econym.org.uk/gmap/
 
    //]]>
