﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
        <xsl:variable name ="requestingID">
            <xsl:value-of select ="normalize-space(AutoSuggest/RequestingID)"></xsl:value-of>
        </xsl:variable>
        <xsl:variable name ="requestingDiv">
            <xsl:value-of select ="normalize-space(AutoSuggest/RequestingDiv)"></xsl:value-of>
        </xsl:variable>
        <xsl:variable name ="requestingAction">
            <xsl:value-of select ="normalize-space(AutoSuggest/RequestingAction)"></xsl:value-of>
        </xsl:variable>
        <xsl:variable name ="requestingObject">
            <xsl:value-of select ="normalize-space(AutoSuggest/RequestingObject)"></xsl:value-of>
        </xsl:variable>
        <xsl:variable name ="goalID">
            <xsl:value-of select ="normalize-space(AutoSuggest/GoalID)"></xsl:value-of>
        </xsl:variable>
        <xsl:variable name ="suggestionDivID">
            <xsl:value-of select ="normalize-space(AutoSuggest/SuggestionDivID)"></xsl:value-of>
        </xsl:variable>
        <xsl:variable name ="autoSuggestTextBoxID">
            <xsl:value-of select ="normalize-space(AutoSuggest/AutoSuggestTextBoxID)"></xsl:value-of>
        </xsl:variable>
        <xsl:if test ="count(AutoSuggest/Data/Element) != 0 ">
            <xsl:for-each select ="AutoSuggest/Data/Element">
                <div style="margin-left:inherit;"
                     onClick='return AutoSuggest_SendSelectedNodeToServer(
                             "{normalize-space(ID)}",
                             "{normalize-space(MemberType)}",
                             "{normalize-space($requestingObject)}",
                             "{normalize-space($requestingID)}",
                             "{normalize-space($requestingAction)}",
                             "{normalize-space($requestingDiv)}", 
                             "{normalize-space($goalID)}",
                             "{normalize-space(Text)}",
                            "{normalize-space($suggestionDivID)}",
                            "{normalize-space($autoSuggestTextBoxID)}"
                            );'
                     onmouseover='AutoSuggest_MouseOver(this)'
                     onmouseout='AutoSuggest_MouseOut(this)'>
                    <span>
                        <xsl:value-of select ="normalize-space(Text)"/>
                    </span>
                    <span style="display:none;">
                        <xsl:value-of select ="normalize-space(ID)"/>
                    </span>
                    <span style="display:none;">
                        <xsl:value-of select ="normalize-space(MemberType)"/>
                    </span>
                </div>
            </xsl:for-each>
        </xsl:if>
        <xsl:if test ="count(AutoSuggest/Data/Element) = 0 ">
            <div class="autoSuggest">
                <span>
                    Enter e-mail address to add new user...
                </span>
                <span style="display:none;">
                    -1
                </span>
                <span style="display:none;">
                    -1
                </span>
            </div>
        </xsl:if>
    </xsl:template>
</xsl:stylesheet>
