﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:import href="Version_2_0/ListNoteBookItemEntries.xslt"/>
    <xsl:import href="GenericTemplates/DisplayNotes.xslt"/>
    <xsl:import href="Obsolete/Note.xslt"/>

    <xsl:template match="/">
        <xsl:variable name="Origin" select="Notes/Origin"></xsl:variable>
        <xsl:variable name="TemplatePathURL" select="Notes/TemplateURL"></xsl:variable>
        <xsl:variable name="PrimaryItemTypeID" select="normalize-space(Notes/PrimaryItemTypeID)"></xsl:variable>
        <xsl:variable name="FBPicURL" select="Notes/User/UserData/FbPicURL"/>
		<xsl:variable name="NotesPrivacyLevel" select="/Notes/Settings/NotesPrivacyLevel"></xsl:variable>
		<xsl:variable name="HostName" select="/Notes/HostName"></xsl:variable>
        <xsl:choose>
            <xsl:when test="$PrimaryItemTypeID = 18">
                <xsl:call-template name="NoteItemObsolete">
                    <xsl:with-param name="DisplayReply">
                        <xsl:text>False</xsl:text>
                    </xsl:with-param>
                    <xsl:with-param name ="TemplatePathURL" select ="Notes/TemplateURL"></xsl:with-param>
                    <xsl:with-param name ="itemID" select="Notes/Note/ItemID"></xsl:with-param>
                    <xsl:with-param name ="FirstName" select="Notes/Note/FirstName"></xsl:with-param>
                    <xsl:with-param name ="LastName" select="Notes/Note/LastName"></xsl:with-param>
                    <xsl:with-param name ="NoteDesc" select="Notes/Note/NoteDesc"></xsl:with-param>
                    <xsl:with-param name ="CreatedMinutes" select="Notes/Note/CreatedMinutes"></xsl:with-param>
                    <xsl:with-param name ="NoteDateTime" select="Notes/Note/NoteDateTime"></xsl:with-param>
                    <xsl:with-param name ="NotesUserImage" select="$FBPicURL"></xsl:with-param>                                   
                </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
                <xsl:choose>
                    <xsl:when test="$Origin = 'NoteBookComment'">
                        <xsl:call-template name="NoteBookItemEntries">
                            <xsl:with-param name="TemplateURL" select="Notes/TemplateURL"></xsl:with-param>
                            <!--<xsl:with-param name="UserName" select="Notes/Note/FirstName"></xsl:with-param>-->
                            <xsl:with-param name="UserName" select="Notes/User/UserData/DisplayName"></xsl:with-param>
							<xsl:with-param name="UserImage" select="Notes/User/UserData/FbPicURL"></xsl:with-param>
                            <xsl:with-param name="NoteDesc" select="Notes/Note/NoteDesc"></xsl:with-param>
                            <xsl:with-param name="NoteBookItemID" select="Notes/Note/ParentID"></xsl:with-param>
                            <xsl:with-param name="NoteItemID" select="Notes/Note/ItemID"></xsl:with-param>
                            <xsl:with-param name="UserID" select="Notes/Note/UserID"></xsl:with-param>
                            <xsl:with-param name="LoginUser" select="Notes/User/UserData/UserID"></xsl:with-param>
							<xsl:with-param name="CreatedDate">
								<xsl:call-template name="TimeStamp">
									<xsl:with-param name="CreatedMinutes" select="Notes/Note/CreatedMinutes"></xsl:with-param>
								</xsl:call-template>
							</xsl:with-param>
                            <xsl:with-param name="IsSecureConnection" select="Notes/IsSecureConnection"></xsl:with-param>
                        </xsl:call-template>
                      
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:apply-templates select ="Notes/Note">
                            <xsl:with-param name="DisplayReply">
                                <xsl:choose>
                                    <xsl:when test="$Origin = 'comment'">
                                        <xsl:text>False</xsl:text>
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <xsl:text>True</xsl:text>
                                    </xsl:otherwise>
                                </xsl:choose>
                            </xsl:with-param>
                            <xsl:with-param name="TemplatePathURL" select ="$TemplatePathURL"></xsl:with-param>
                            <xsl:with-param name="FbPicURL" select ="$FBPicURL"></xsl:with-param>
                            <xsl:with-param name ="itemID" select="Notes/Note/ItemID"></xsl:with-param>
                            <xsl:with-param name="IsSecureConnection" select="Notes/IsSecureConnection"></xsl:with-param>
							<xsl:with-param name="NotesPrivacyLevel" select="$NotesPrivacyLevel"></xsl:with-param>
							<xsl:with-param name="HostName" select="$HostName"></xsl:with-param> 
                        </xsl:apply-templates>
                    </xsl:otherwise>
                </xsl:choose>
               
            </xsl:otherwise>
        </xsl:choose>
       
	</xsl:template>
</xsl:stylesheet>
