<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:template match="/">
    <xsl:apply-templates select="location"/>
  </xsl:template>

  <xsl:template match="info">
  
    <xsl:variable name="page" select="../@arg0"/>
    
    <xsl:variable name="address">
        <xsl:for-each select="address/line">
          <xsl:if test="position() &gt; 1">, </xsl:if>
          <xsl:value-of select="."/>
        </xsl:for-each>
    </xsl:variable>
    
    <div style="margin-right: 6px"><b><xsl:value-of select="title"/></b></div>

    <div style="font-size: small">
      <xsl:apply-templates select="address/line"/>
    </div>
  </xsl:template>

 <xsl:template match="location">
    <xsl:apply-templates select="info"/>

     <br />
    <div style='font-size:small;' align='left'>
       <span style='font-weight:bold;'>Directions:  </span> <br />
       <a id="startTo"  style="text-decoration:none; font-weight:bold; color:black;"                          
           href="javascript:switchToFrom('startTo', 'startFrom')"> To </a>  
        / 
       <a id="startFrom" style="text-decoration:underline; font-weight:bold; color:grey;" 
           href="javascript:switchToFrom('startFrom', 'startTo')"> From </a> 
  
        <xsl:value-of select="info/title" />    
        (<xsl:value-of select="@id" />) - 
        <span id='endDirection' style="font-weight:bold"> From </span>: 
	  <br />

        <xsl:apply-templates select="ancestor::overlay" /> 
        <xsl:text>    </xsl:text>
        <input type="button" value="Go" id="locationDirections">
        <xsl:attribute name="onclick">
            getDirections(this, 
				"<xsl:value-of select="@id" />", 
			      "<xsl:value-of select="./info/title" />",
				"<xsl:value-of select="./point/@lat" />",
				"<xsl:value-of select="./point/@lng" />")
        </xsl:attribute>
        </input>
        <br />
        Or Other Address or ZIP code:
        <br />
        <input type="text" id="searchValue"/>
        <xsl:text>    </xsl:text>
        <input type="button" value="Go" id="searchDirections">
        <xsl:attribute name="onclick">
            getDirections(this, 
				"<xsl:value-of select="@id" />",
				"<xsl:value-of select="./info/title" />",
				"<xsl:value-of select="./point/@lat" />",
				"<xsl:value-of select="./point/@lng" />")
        </xsl:attribute>
        </input>
    </div>
 
 </xsl:template>

<xsl:template match="overlay">
    <select id="locationValue">
        <xsl:apply-templates select="//location/point" />
    </select>
</xsl:template>

<xsl:template match="location/point">
    <option>
    <xsl:attribute name="value">
        <xsl:value-of select="@lat" />,<xsl:value-of select="@lng" />
        +(<xsl:value-of select="ancestor::location/info/title" />)
    </xsl:attribute>
    <xsl:value-of select="ancestor::location/info/title" /> 
    (<xsl:value-of select="ancestor::location/@id" />)
    </option>
</xsl:template>

<xsl:template match="line">
   <div><xsl:value-of select="."/></div>
</xsl:template>

</xsl:stylesheet>

