<?xml version="1.0"?>  
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
  <xsl:template match="/">
    <HTML>
      <HEAD>
        <STYLE>
          BODY {margin:0}
          .bg {font:8pt Verdana; background-color:#666699; color:white}
          H1 {font:bold 14pt Verdana; width:100%; margin-top:1em}
          .row {font:8pt Verdana; border-bottom:1px solid #669999}
          .header {font:bold 9pt Verdana; padding:5px; color: blue; cursor: hand}
        </STYLE>
      
       <SCRIPT><xsl:comment><![CDATA[
        function sort(field)
        {
          sortField.value = field;
  
          listing.innerHTML = source.documentElement.transformNode(stylesheet);
        }
      ]]></xsl:comment></SCRIPT>

      <SCRIPT for="window" event="onload"><xsl:comment><![CDATA[
        stylesheet = document.XSLDocument;
        source = document.XMLDocument;
        sortField = document.XSLDocument.selectSingleNode("//@order-by");
      ]]></xsl:comment></SCRIPT>
      </HEAD>

      <BODY>
	  <TABLE border="0" width="100%" cellspacing="0">
          <TR>
            <TD class="bg">
              <H1><xsl:value-of select="realestate/title"/></H1><BR /> Zip Code =  
		<xsl:value-of select="realestate/@zipcode"/>
            </TD>
          </TR>
	  <TR>
	    <TD>
	      <DIV id="listing"><xsl:apply-templates select="realestate"/></DIV>
            </TD>
	  </TR>
	</TABLE>
      </BODY>
    </HTML>
  </xsl:template>

  <xsl:template match="realestate">
    <TABLE width="100%" border="0">
      <THEAD>
	<TD width="100"><DIV class="header" onClick="sort('type')">Type</DIV></TD>
	<TD width="200"><DIV class="header" onClick="sort('address')">Address</DIV></TD>
	<TD width="100"><DIV class="header" onClick="sort('price')">Price</DIV></TD>
	<TD width="100"><DIV class="header" onClick="sort('squarefeet')">Square Feet</DIV></TD>
      </THEAD>
      <xsl:for-each select="home" order-by="type">
	<TR>
	  <TD><DIV class="row"><xsl:value-of select="type"/></DIV></TD>
	  <TD><DIV class="row"><xsl:value-of select="address"/></DIV></TD>
	  <TD><DIV class="row"><xsl:apply-templates select="price"/></DIV></TD>
	  <TD><DIV class="row"><xsl:value-of select="squarefeet"/></DIV></TD>
	</TR>
       </xsl:for-each>
     </TABLE>
  </xsl:template>

  <xsl:template match="price">
    <xsl:eval>formatNumber(this.nodeTypedValue, "$0.00")</xsl:eval>
  </xsl:template>

</xsl:stylesheet>
  
  
