// JavaScript Document

	 //<![CDATA[

    function mapit(where) {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map_canvas"));
		
		if(where == null){
			map.setCenter(new GLatLng(37.134557,-96.515625), 3);
		}
       	
		map.addControl(new TextualZoomControl());
		
		var east_point = new GLatLng(40.223403,-74.935645);
		var east_text = '<div id="maptext"><h3>CSG Philadelphia</h3>'+
						'<p>Get driving directions to this Location.</p>'+
						'<span>Starting Address:</span><br />'+
						'<input type="text" id="getaddr" value="" onKeyUp="checkkey(event.which);" /><a href="javascript:mapdirections(1);"></a></div>';

		var west_point = new GLatLng(37.798771,-122.421012);
		var west_text = '<div id="maptext"><h3>CSG California</h3>'+
						'<p>Get driving directions to this Location.</p>'+
						'<span>Starting Address:</span><br />'+
						'<input type="text" id="getaddr" value="" onKeyUp="checkkey(event.which);" /><a href="javascript:mapdirections(2);"></a></div>';
		
		var marker_east = createMarker(east_point, east_text);
		var marker_west = createMarker(west_point, west_text);
      	map.addOverlay(marker_east);
		map.addOverlay(marker_west);
		if(where == 'east'){
			map.openInfoWindow(east_point, east_text);
			map.setCenter(new GLatLng(40.206797,-74.867068), 15);
		}
		//WEST COAST LINK
		if(where == 'west'){
			map.openInfoWindow(west_point, west_text);
			map.setCenter(new GLatLng(37.798771,-122.421012), 15);
		}
      }
    }
	function createMarker(point,htmltext) {
        var marker2 = new GMarker(point);
        GEvent.addListener(marker2, "click", function() {
          marker2.openInfoWindowHtml(htmltext);
        });
        return marker2;
    }
	function mapdirections(which) {
		if(which == 1){
			var submitForm = document.getElementById("submitForm_e");
			submitForm.saddr.value = document.getElementById("getaddr").value;
			submitForm.submit();
		}
		if(which == 2){
			var submitForm = document.getElementById("submitForm_w");
			submitForm.saddr.value = document.getElementById("getaddr").value;
			submitForm.submit();
		}
	}
    //]]>

var map;

function TextualZoomControl() {
    }
    TextualZoomControl.prototype = new GControl();

    // Creates a one DIV for each of the buttons and places them in a container
    // DIV which is returned as our control element. We add the control to
    // to the map container and return the element for the map class to
    // position properly.
    TextualZoomControl.prototype.initialize = function(map) {
      var container = document.createElement("div");

      var zoomInDiv = document.createElement("div");
      this.setButtonStyle_(zoomInDiv);
      container.appendChild(zoomInDiv);
      zoomInDiv.appendChild(document.createTextNode("+"));
      GEvent.addDomListener(zoomInDiv, "click", function() {
        map.zoomIn();
      });

      var zoomOutDiv = document.createElement("div");
      this.setButtonStyle_(zoomOutDiv);
      container.appendChild(zoomOutDiv);
      zoomOutDiv.appendChild(document.createTextNode("-"));
      GEvent.addDomListener(zoomOutDiv, "click", function() {
        map.zoomOut();
      });

      map.getContainer().appendChild(container);
      return container;
    }

    // By default, the control will appear in the top left corner of the
    // map with 7 pixels of padding.
    TextualZoomControl.prototype.getDefaultPosition = function() {
      return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(7, 7));
    }

    // Sets the proper CSS for the given button element.
    TextualZoomControl.prototype.setButtonStyle_ = function(button) {
		button.style.color = "#fff";
		button.style.backgroundColor = "white";
		button.style.marginBottom = "3px";
		button.style.textAlign = "center";
		button.style.width = "20px";
		button.style.height = "20px";
		button.style.cursor = "pointer";
		button.style.backgroundColor = "#3399cc";
	}
