﻿<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ddwrt2="urn:frontpage:internal">
  <xsl:output method="html" indent="no"/>
	<xsl:param name="ListID">12685153-1F02-4263-9126-E2A733938D6D</xsl:param>
	<xsl:param name="ContactID">1</xsl:param>
	<xsl:template match="/">
    	<xsl:call-template name="dvt_1"/>
  </xsl:template>
  	<xsl:template name="dvt_1">
    	<xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row" />
    	<xsl:call-template name="dvt_1.body">
      		<xsl:with-param name="Rows" select="$Rows" />
    	</xsl:call-template>
  </xsl:template>
  	<xsl:template name="dvt_1.body">
    	<xsl:param name="Rows" />
    <!-- Link to the Virtual Earth Map control JS file -->
	<script type="text/javascript" src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2"></script>    
    	<xsl:for-each select="$Rows">
      		<xsl:call-template name="dvt_1.rowview" />
    </xsl:for-each>
  </xsl:template>
  	<xsl:template name="dvt_1.rowview">
    <div id='myMap' style="position: relative; width: 650px; height: 400px;"></div>
    <script type="text/javascript">
    _spBodyOnLoadFunctionNames.push(&quot;GetMap&quot;);
         var map = null;
                  
         function GetMap()
         {
            map = new VEMap('myMap');
            map.LoadMap(null, 14, VEMapStyle.Road, false, VEMapMode.Mode2D, true, 1);
			FindLoc();
         }
                
         function AddPin(layer, resultsArray, places, hasMore, veErrorMessage)
         {
            // Add a new pushpin to the center of the map.
       		var pin = new VEPushpin(
          				1,
          				map.GetCenter(),
          				null,
          				&quot;<xsl:value-of select="@Title" />&quot;,
          				&apos;&apos;
          				);
            map.AddPushpin(pin );
         }
         
         function FindLoc()      
         {         
         	try         
         	{            
               map.Find(null,
                  '<xsl:value-of select="@WorkAddress" />&#160;<xsl:value-of select="@WorkCity" />&#160;<xsl:value-of select="@WorkState" />',
                  null, null,null,null,true,true,true,true,
                  AddPin);
         	}         
         	catch(e)         
         	{            
        	 	alert(e.message);         
        	}      
        }
    </script>
  </xsl:template>
</xsl:stylesheet>
