// JavaScript Document

        var map = null;
          
        function GetMap()
        {
            map = new VEMap('myMap');
            map.LoadMap();

         map.AttachEvent("onmousedown",MouseHandler);
		 FindLoc();
        }   
         
          function AddPin(ll)
          {  
               pin = new VEShape(VEShapeType.Pushpin,ll);
            map.AddShape(pin);
            document.coord.lat.value = ll.Latitude;
            document.coord.long.value = ll.Longitude;  
          }  
    
        function getLatLong(layer, resultsArray, places, hasMore, veErrorMessage)
        {    
            var ll = places[0].LatLong;
            AddPin(ll);
		

        }
    
        function FindLoc()
          {
             try
             {
                 var what=document.getElementById('txtWhat').value;
                map.Find(what, document.getElementById('txtWhere').value, null, null, null, null, null, null, null, null, getLatLong);
             }
             catch(e)
             {
                alert(e.message);
             }
          }
          
      function MouseHandler(e)
      {
         if (e!=null)
         {
            /*if (e.rightMouseButton)
            {
                  var x = e.mapX;
                 var y = e.mapY;
                 var ll = map.PixelToLatLong(new VEPixel(x,y));
                  AddPin(ll);
               }*/
           }
      }