﻿// JScript File
    function GetMap()
    {
        try
        { 
            // If the browser is Firefox get the version number
            var ffv = 0;
            var ffn = "Firefox/"
            var ffp = navigator.userAgent.indexOf(ffn);
            if (ffp != -1)
				ffv = parseFloat(navigator.userAgent.substring(ffp + ffn.length));
            
            // If we're using Firefox 1.5 or above override the Virtual Earth drawing functions to use SVG
            if (ffv >= 1.5)
            {
              Msn.Drawing.Graphic.CreateGraphic=function(f,b) { return new Msn.Drawing.SVGGraphic(f,b) }
            }
                    
            map = new VEMap("map");
            map.LoadMap();
            map.ZoomOut();
            map.ShowMessageBox = false;
        }
        catch(ex){}
    }
	
	function AddPin(latitude, longitude, details, picSrc)
	{
        try
	    {
            var latLon = new VELatLong(parseFloat(latitude), parseFloat(longitude));
	        var pin = new VEShape(VEShapeType.Pushpin, latLon);
	        pin.SetTitle(details);
	        map.AddShape(pin);
	    }
		catch(ex){}
	}
	
	function SetCenterZoom(latitude, longitude, zoom)
	{
		try
		{
			if(latitude != 0 || longitude != 0)
				map.SetCenterAndZoom(new VELatLong(latitude, longitude), zoom);
		}
		catch(ex){}
	}
	
	function FindLocation(address)
	{
		//parameters: what, where, findType, shapeLayer, startIndex, numberOfResults, showResults, createResults,
		//					  useDefaultDisambiguation, setBestMapView, callback
		map.Find(null, address, null, null, 0, 1, false, false, false, false, AddPinAfterFind);
	}
	
	function AddPinAfterFind(shape, results, place, hasMore)
	{
        try
	    {
			if(place != null && place.length > 0)
			{
				var pin = new VEShape(VEShapeType.Pushpin, place[0].LatLong);
				if(place[0].Name != null)
				{
					var test = place[0].Name.split(", ");
					var test2 = test[0] + test[test.length - 2] + test[test.length - 1];
					var test3 = pinDescr[test2]
					pin.SetTitle(test3);
				}
				map.AddShape(pin);
	        }
	    }
	    catch(ex){}
	}