<xsl:stylesheet version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.Sharepoint.WebControls">
  <xsl:output method="html" indent="no" />
  <xsl:param name="PreviousLinkText">Previous</xsl:param>
  <xsl:param name="NextLinkText">Next</xsl:param>
  <xsl:param name="EditViewText">Edit View</xsl:param>
  <xsl:param name="AscendingText">Ascending</xsl:param>
  <xsl:param name="DescendingText">Descending</xsl:param>
  <xsl:param name="RetrieveDataText">Retrieve Data</xsl:param>
  <xsl:param name="ActionsText">Actions</xsl:param>
  <xsl:param name="FilterNameText">Filter name</xsl:param>
  <xsl:param name="OperatorText">Operator</xsl:param>
  <xsl:param name="AddText">Add</xsl:param>
  <xsl:param name="CurrentLCID">1033</xsl:param>
  <xsl:param name="IsRTL"></xsl:param>
  <xsl:param name="dvt_apos">'</xsl:param>
  <xsl:param name="dvt_adhocmode">sort</xsl:param>
  <xsl:param name="ClickThroughUrl" />
  <xsl:param name="dvt_url" />
  <xsl:param name="jsMenuApplication" />
  <xsl:param name="jsMenuEntity" />
  <xsl:param name="jsMenuLoadingMessage" />
  <xsl:param name="dvt_1_automode">0</xsl:param>
  <xsl:param name="filterParam" />
  <xsl:param name="dvt_firstrow">1</xsl:param>
  <xsl:param name="dvt_nextpagedata" />
  <xsl:param name="IsMenuVisible" />
  <xsl:param name="IsEditViewVisible" />
  <xsl:param name="dvt_partguid" />
  <xsl:param name="ColumnKey">Kunnr</xsl:param>
  <xsl:param name="dvt_1_form_selectkey" />
  <xsl:param name="dvt_sortdir">ascending</xsl:param>
  <xsl:param name="dvt_sortfield" />
  <xsl:param name="dvt_emptytext"></xsl:param>
  <xsl:param name="dvt_filterfields" />
  <xsl:param name="ColName_0"></xsl:param>
  <xsl:param name="ColName_1"></xsl:param>
  <xsl:param name="ColName_2"></xsl:param>
  <xsl:param name="ColName_3"></xsl:param>
  <xsl:param name="ColName_4"></xsl:param>
  <xsl:param name="ColName_5"></xsl:param>
  <xsl:param name="ColName_6"></xsl:param>
  <xsl:param name="ColName_7"></xsl:param>
  <xsl:param name="ColName_8"></xsl:param>
  <xsl:template match="/">
    <xsl:call-template name="dvt_1" />
  </xsl:template>
  <xsl:template name="dvt_1">
    <xsl:variable name="dvt_StyleName">RepForm3</xsl:variable>
    <xsl:variable name="Rows" select="/dsQueryResponse/NewDataSet/Row" />
    <xsl:variable name="dvt_RowCount" select="count($Rows)" />
    <xsl:variable name="RowLimit" select="$dvt_RowCount" />
    <xsl:variable name="FirstRow" select="$dvt_firstrow" />
    <xsl:variable name="LastRow">
      <xsl:choose>
        <xsl:when test="($FirstRow + $RowLimit - 1) &gt; $dvt_RowCount">
          <xsl:value-of select="$dvt_RowCount" />
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="$FirstRow + $RowLimit - 1" />
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <div>
      <asp:PlaceHolder id="ActionBarTable" runat="server">
        <table class="ms-toolbar" cellpadding="0" cellspacing="0" border="0" width="100%">
          <tr style="height:2em">
            <td valign="middle" style="padding-left:2px">
              <img src="_layouts/images/viewprof.gif" border="0" alt="" />
            </td>
            <td valight="middle" style="padding-left:2px; width:100%;">
              <a href="#">View Profile</a>
            </td>
          </tr>
        </table>
      </asp:PlaceHolder>
    </div>
    <table border="0" width="100%">
      <xsl:call-template name="dvt_1.body">
        <xsl:with-param name="Rows" select="$Rows" />
        <xsl:with-param name="FirstRow" select="$dvt_firstrow" />
        <xsl:with-param name="LastRow" select="$LastRow" />
      </xsl:call-template>
    </table>
  </xsl:template>
  <xsl:template name="dvt_1.body">
    <xsl:param name="Rows" />
    <xsl:param name="FirstRow" />
    <xsl:param name="LastRow" />
    <xsl:for-each select="$Rows">
      <xsl:call-template name="dvt_1.rowview" />
    </xsl:for-each>
  </xsl:template>
  <xsl:template name="dvt_1.rowview">
    <tr>
      <td>
        <table border="0" width="100%">
          <tr>
            <td class="ms-descriptiontext ms-alignright">
              <nobr>
                <xsl:value-of select="$ColName_0" />:
              </nobr>
            </td>
            <td class="ms-descriptiontext ms-alignleft" width="100%">
              <xsl:variable name="fieldValue">
                <xsl:call-template name="LFtoBR">
                  <xsl:with-param name="input">
                    <xsl:value-of select="@FullName" />
                  </xsl:with-param>
                </xsl:call-template>
              </xsl:variable>
              <xsl:copy-of select="$fieldValue" />
            </td>
          </tr>
          <tr>
            <td class="ms-descriptiontext ms-alignright">
              <nobr>
                <xsl:value-of select="$ColName_1" />:
              </nobr>
            </td>
            <td class="ms-descriptiontext ms-alignleft" width="100%">
              <xsl:variable name="fieldValue">
                <xsl:call-template name="LFtoBR">
                  <xsl:with-param name="input">
                    <xsl:value-of select="@Company" />
                  </xsl:with-param>
                </xsl:call-template>
              </xsl:variable>
              <xsl:copy-of select="$fieldValue" />
            </td>
          </tr>
          <tr>
            <td class="ms-descriptiontext ms-alignright">
              <nobr>
                <xsl:value-of select="$ColName_2" />:
              </nobr>
            </td>
            <td class="ms-descriptiontext ms-alignleft" width="100%">
              <xsl:variable name="fieldValue">
                <xsl:call-template name="LFtoBR">
                  <xsl:with-param name="input">
                    <xsl:value-of select="@Title" />
                  </xsl:with-param>
                </xsl:call-template>
              </xsl:variable>
              <xsl:copy-of select="$fieldValue" />
            </td>
          </tr>         
          <tr>
            <td class="ms-descriptiontext ms-alignright">


            </td>
            <td class="ms-descriptiontext ms-alignleft" width="100%">
              <xsl:variable name="fieldValue">
                <xsl:call-template name="LFtoBR_link">
                  <xsl:with-param name="input">
                    <xsl:value-of select="@Website" />
                  </xsl:with-param>
                </xsl:call-template>
              </xsl:variable>
              <xsl:copy-of select="$fieldValue" />
            </td>
          </tr>
           <tr>
            <td class="ms-descriptiontext ms-alignright">
              <nobr>Phone:</nobr>
            </td>
            <td class="ms-descriptiontext ms-alignleft" width="100%">
              <xsl:variable name="fieldValue">
                <xsl:call-template name="LFtoBR">
                  <xsl:with-param name="input">
                    <xsl:value-of select="@Phone" />
                  </xsl:with-param>
                </xsl:call-template>
              </xsl:variable>
              <xsl:copy-of select="$fieldValue" />
            </td>
          </tr>
          <tr>
            <td class="ms-descriptiontext ms-alignright">
              <nobr>Fax:</nobr>
            </td>
            <td class="ms-descriptiontext ms-alignleft" width="100%">
              <xsl:variable name="fieldValue">
                <xsl:call-template name="LFtoBR">
                  <xsl:with-param name="input">
                    <xsl:value-of select="@Fax" />
                  </xsl:with-param>
                </xsl:call-template>
              </xsl:variable>
              <xsl:copy-of select="$fieldValue" />
            </td>
          </tr>
          <tr>
            <td class="ms-descriptiontext ms-alignright">
              <nobr>Address:</nobr>
            </td>
            <td class="ms-descriptiontext ms-alignleft" width="100%">
              <xsl:variable name="fieldValue">
                <xsl:call-template name="LFtoBR">
                  <xsl:with-param name="input">
                    <xsl:value-of select="@AddressLine1" />
                  </xsl:with-param>
                </xsl:call-template>
              </xsl:variable>
              <xsl:copy-of select="$fieldValue" />
            </td>
          </tr>
          <xsl:if test="@AddressLine2!=''">
            <tr>
            <td class="ms-descriptiontext ms-alignright">
              
            </td>
            <td class="ms-descriptiontext ms-alignleft" width="100%">
              <xsl:variable name="fieldValue">
                <xsl:call-template name="LFtoBR">
                  <xsl:with-param name="input">
                    <xsl:value-of select="@AddressLine2"/>
                  </xsl:with-param>
                </xsl:call-template>
              </xsl:variable>
              <xsl:copy-of select="$fieldValue" />
            </td>
          </tr>
	</xsl:if>
	<xsl:if test="@AddressLine3!=''">
            <tr>
            <td class="ms-descriptiontext ms-alignright">
              
            </td>
            <td class="ms-descriptiontext ms-alignleft" width="100%">
              <xsl:variable name="fieldValue">
                <xsl:call-template name="LFtoBR">
                  <xsl:with-param name="input">
                    <xsl:value-of select="@AddressLine3"/>
                  </xsl:with-param>
                </xsl:call-template>
              </xsl:variable>
              <xsl:copy-of select="$fieldValue" />
            </td>
          </tr>
	</xsl:if>
	
            <tr>
            <td class="ms-descriptiontext ms-alignright">
              
            </td>
            <td class="ms-descriptiontext ms-alignleft" width="100%">
              <xsl:variable name="fieldValue">
                <xsl:call-template name="LFtoBR">
                  <xsl:with-param name="input">
                    <xsl:value-of select="concat(@City, ', ',@State,' ',@Zip)"/>
                  </xsl:with-param>
                </xsl:call-template>
              </xsl:variable>
              <xsl:copy-of select="$fieldValue" />
            </td>
          </tr>
          
          <tr>
            <td class="ms-descriptiontext ms-alignright">              
            </td>
            <td class="ms-descriptiontext ms-alignleft" width="100%">
              <xsl:variable name="fieldValue">
                <xsl:call-template name="LFtoBR">
                  <xsl:with-param name="input">
                  	<xsl:choose>
                  	<xsl:when test="@Country=''">United States</xsl:when>
                  	<xsl:otherwise><xsl:value-of select="@Country"/></xsl:otherwise>
                  	</xsl:choose>                    
                  </xsl:with-param>
                </xsl:call-template>
              </xsl:variable>
              <xsl:copy-of select="$fieldValue" />
            </td>
          </tr>

        </table>
      </td>
    </tr>
  </xsl:template>
  <xsl:template name="formatString">
    <xsl:param name="stringvalue" />
    <xsl:param name="separator" />
    <xsl:variable name="curStr" select="substring-after($stringvalue, $separator)" />
    <xsl:choose>
      <xsl:when test="contains($curStr, $separator)">
        <xsl:value-of select="substring-before($stringvalue, $separator)" />
        <xsl:value-of select="ddwrt:UrlEncode(@*[name()=substring-before($curStr, $separator)])" />
        <xsl:call-template name="formatString">
          <xsl:with-param name="stringvalue" select="substring-after($curStr, $separator)" />
          <xsl:with-param name="separator" select="$separator" />
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$stringvalue" />
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
  <xsl:template name="OpenActionsMenu">
    <xsl:param name="method" />
    <xsl:param name="id" />
    <xsl:param name="menuText" />
    <xsl:value-of select="$method" />
    <xsl:text>('</xsl:text>
    <xsl:value-of select="$jsMenuLoadingMessage" />
    <xsl:text>','</xsl:text>
    <xsl:value-of select="ddwrt:EcmaScriptEncode($menuText)" />
    <xsl:text>',false,'</xsl:text>
    <xsl:value-of select="$jsMenuApplication" />
    <xsl:text>','</xsl:text>
    <xsl:value-of select="$jsMenuEntity" />
    <xsl:text>','</xsl:text>
    <xsl:value-of select="ddwrt:EcmaScriptEncode($id)" />
    <xsl:text>');</xsl:text>
  </xsl:template>
  <xsl:template name="_trimLF">
    <xsl:param name="input" />
    <xsl:choose>
      <xsl:when test="starts-with($input, '&#xA;')">
        <xsl:call-template name="_trimLF">
          <xsl:with-param name="input" select="substring($input, 2)" />
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="substring($input, string-length($input), 1) = '&#xA;'">
        <xsl:call-template name="_trimLF">
          <xsl:with-param name="input" select="substring($input, 1, string-length($input)-1)" />
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$input" />
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
  <xsl:template name="_LFtoBRloop">
    <xsl:param name="input" />
    <xsl:variable name="beforeText" select="substring-before($input, '&#xA;')" />
    <xsl:choose>
      <xsl:when test="string-length($beforeText) = 0 and substring($input, 1, 1) != '&#xA;'">
        <xsl:value-of select="$input" />
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$beforeText" />
        <br />
        <xsl:call-template name="_LFtoBRloop">
          <xsl:with-param name="input" select="substring($input, string-length($beforeText)+2)" />
        </xsl:call-template>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
  <xsl:template name="LFtoBR">
    <xsl:param name="input" />
    <xsl:choose>
      <xsl:when test="substring-before($input, '&#xA;') = ''">
        <xsl:value-of select="$input" />
      </xsl:when>
      <xsl:otherwise>
        <xsl:call-template name="_LFtoBRloop">
          <xsl:with-param name="input">
            <xsl:call-template name="_trimLF">
              <xsl:with-param name="input" select="translate($input, '&#xD;', '')" />
            </xsl:call-template>
          </xsl:with-param>
        </xsl:call-template>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
    <xsl:template name="LFtoBR_link">
    <xsl:param name="input" />
    
    <a>
      <xsl:attribute name="href">
        <xsl:choose>
        <xsl:when test="contains($input,'http://')">
          <xsl:value-of select="$input"/></xsl:when>
        <xsl:otherwise>http://<xsl:value-of select="$input"/></xsl:otherwise>
       </xsl:choose>
      </xsl:attribute>
      <xsl:value-of select="$input" />
    </a>
  </xsl:template>
</xsl:stylesheet>