﻿
function showAddress(address, map)
{  
    var geocoder = new GClientGeocoder();
    var icon = new GIcon();
    
    icon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";
    icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
    
    icon.iconSize = new GSize(12, 20);
    icon.shadowSize = new GSize(22, 20);
    icon.shadowSize = new GSize(1, 1);
    
    icon.iconAnchor = new GPoint(6, 20);
    icon.infoWindowAnchor = new GPoint(5, 1);
   
	geocoder.getLatLng(    address,

	function(point) 
	{      
		if (!point) 
		{
			alert(address + " not found");      
		}
		else 
		{
			map.setCenter(point, 15);

			var marker = new GMarker(point,icon);
			map.addOverlay(marker);
		}    
	}  
			);
}
		
function showMapControls(map)
{
    function TextualZoomControl() {}
	TextualZoomControl.prototype = new GControl();

	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;
	}
	
	TextualZoomControl.prototype.getDefaultPosition = function() 
	{  
		return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(7, 7));
	}

	TextualZoomControl.prototype.setButtonStyle_ = function(button) 
	{  
		button.style.color = "#0000cc";  
		button.style.backgroundColor = "white";  
		button.style.font = "small Arial";  
		button.style.border = "1px solid black";  
		button.style.padding = "2px";  
		button.style.marginBottom = "3px";  
		button.style.textAlign = "center";  
		button.style.width = "auto";  
		button.style.cursor = "pointer";
	}
	
	map.addControl(new GSmallMapControl(),new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(10, 10)));
	map.addControl(new GMapTypeControl(),new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(10, 10)));
	
	map.addControl(new GScaleControl(),new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(20, 20)));
	map.addControl(new GOverviewMapControl(),new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(10, 30)));
	
}		
		
function load()
{
	if (GBrowserIsCompatible())
	{
		var ADDRESS;
		var QS;
		var map = new GMap2(document.getElementById("map"));

		QS = unescape(document.location.search);

		ADDRESS = QS.substring(QS.indexOf("=",1) + 1,QS.lenght);
		ADDRESS = ADDRESS.replace("+/g/i"," ");
		ADDRESS = ADDRESS.replace("?","");

		if (ADDRESS == "")
		{
			ADDRESS = "1688 Cordova St., Los Angeles, CA 90007";
		}
		
        showMapControls(map);
		showAddress(ADDRESS,map);
		
	}
}



