﻿// JavaScript Document

//++++++++++++++++++++ Map Related Functions ++++++++++++++++++++++++++++++++++++++++++++++++++

	  var gicons = [];
      var gmarkers = [];
      var htmls = [];
      var to_htmls = [];
      var from_htmls = [];
      var i=0;
	  var map;
	  
      // Display the map, with some controls and set the initial location 
	  function load()
	  {
	      if (GBrowserIsCompatible()) 
		  {
			  map = new GMap2(document.getElementById("map"));
			  map.setCenter(new GLatLng(39.4016,-76.6052), 16);
			  map.addControl(new GLargeMapControl());
			  map.addControl(new GMapTypeControl());
		  
			  // Set up markers with info windows 
			  gicons["cdc"] = new GIcon();
			  gicons["cdc"].image = "images/mapicon.png";
			  gicons["cdc"].iconSize = new GSize(30, 30);
			  gicons["cdc"].iconAnchor = new GPoint(0, 15);
			  gicons["cdc"].infoWindowAnchor = new GPoint(40, 0);
			  var point = new GLatLng(39.4018,-76.6048);
			  var marker = createMarker(point,'Zia\'s','<h3>Cafe Troia<\/h3>31 Allegheny Ave<br \/>Towson, MD 21204<br \/>Tel:(410) 337-0133', "cdc");
		  }
	 }
	 
	  
      // A function to create the marker and set up the event window
      function createMarker(point,name,html,icontype) {
        var marker = new GMarker(point, gicons[icontype]);

        // The info window version with the "to here" form open
        to_htmls[i] = html + '<br>Directions: <b>To here<\/b> - <a href="javascript:fromhere(' + i + ')">From here<\/a>' +
           '<br>Start address:<form action="http:\/\/maps.google.com\/maps" method="get" target="_blank">' +
           '<input type="text" size="40" maxlength="40" name="saddr" id="saddr" value="" \/><br \/>' +
           '<input value="Get Directions" type="submit" \/>' +
           '<input type="hidden" name="daddr" value="13 W Allegheny Ave, Towson, MD 21204" \/>';
        // The info window version with the "to here" form open
        from_htmls[i] = html + '<br \/>Directions: <a href="javascript:tohere(' + i + ')">To here<\/a> - <b>From here<\/b>' +
           '<br>End address:<form action="http:\/\/maps.google.com\/maps" method="get"" target="_blank">' +
           '<input type="text" size="40" maxlength="40" name="daddr" id="daddr" value="" \/><br \/>' +
           '<input value="Get Directions" type="submit" \/>' +
           '<input type="hidden" name="saddr" value="13 W Allegheny Ave, Towson, MD 21204" \/>';
        // The inactive version of the direction info
        html = html + '<br \/>Directions: <a href="javascript:tohere('+i+')">To here<\/a> - <a href="javascript:fromhere('+i+')">From here<\/a>';

        GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowHtml(html);
        });
		
        gmarkers[i] = marker;
        htmls[i] = html;
        i++;
        //return marker;
		map.addOverlay(marker);
	    marker.openInfoWindowHtml(html);
        GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowHtml(html);
        });
      }

      // functions that open the directions forms
      function tohere(i) {
        gmarkers[i].openInfoWindowHtml(to_htmls[i]);
      }
      function fromhere(i) {
        gmarkers[i].openInfoWindowHtml(from_htmls[i]);
      }

//++++++++++++++++++++++++++Menu Related Functions ++++++++++++++++++++++++++++++++++++++++++

      function showmenu(menu)
      {
			switch (menu) 
			{
				case 'lunchmenu':
				  document.getElementById("lunchmenu").style.display = 'block';
		          document.getElementById("dinnermenu").style.display = 'none';
				  document.getElementById("winemenu").style.display = 'none';
				  document.getElementById("takeoutmenu").style.display = 'none';
				  break;
				case 'dinnermenu':
				  document.getElementById("lunchmenu").style.display = 'none';
		          document.getElementById("dinnermenu").style.display = 'block';
				  document.getElementById("winemenu").style.display = 'none';
				  document.getElementById("takeoutmenu").style.display = 'none';
				  break;
				case 'winemenu':
				  document.getElementById("lunchmenu").style.display = 'none';
		          document.getElementById("dinnermenu").style.display = 'none';
				  document.getElementById("winemenu").style.display = 'block';
				  document.getElementById("takeoutmenu").style.display = 'none';
				  break;
				case 'takeoutmenu':
				  document.getElementById("lunchmenu").style.display = 'none';
		          document.getElementById("dinnermenu").style.display = 'none';
				  document.getElementById("winemenu").style.display = 'none';
				  document.getElementById("takeoutmenu").style.display = 'block';
				  break;
				default: result = 'unknown';
            }
      }
      
  