<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Eric's golf scores</title>
<link rel="stylesheet" type="text/css" media="screen" href="../../utils/eric.css">
</head>

<body>
<b>
<%

dim oSource
dim oTrans

set oDoc = Server.CreateObject("Microsoft.XMLDOM")
set oStyle = Server.CreateObject("Microsoft.XMLDOM")

'Load the XML Document
oDoc.load(Server.MapPath("eric.gml"))

' Load the style sheet
'oStyle.load(Server.MapPath("golf.xsl"))

' apply the style sheet
'Result = oDoc.documentElement.transformNode(oStyle)

sView = Request.QueryString("view")

' default record if none is specified
if Len(sView) = 0 then
    sView = "main"
end if

sPlayer = Request.QueryString("player")
sDate = Request.QueryString("date")

select case sView

    case "players"
        DisplayPlayers()

    case "courses"
        DisplayCourses()

    case "rounds"
        DisplayRounds()

    case "round"
        DisplayRound sPlayer, sDate 

    case "main"
        DisplayMain()
        
end select


' all done
set oDoc = nothing
set oStyle  = nothing

Private Sub DisplayMain()
    
    response.write "<a href=""golf.asp?view=players"">Players</a><br>"
    response.write "<a href=""golf.asp?view=rounds"">Rounds</a><br>"
    response.write "<a href=""golf.asp?view=courses"">Courses</a><br>"

end sub

private function ConvertDate(lTime)

    iConvertBase = 2147483647
    iConvertAdd = 2147483649 + lTime

    rawDate = DateAdd("s", iConvertBase, "01/01/1900 00:00:00")
    rawDate = DateAdd("s", iConvertAdd,  FormatDateTime(rawDate))
    
    ConvertDate = rawDate
    
end function

private function SortRounds()

    'response.write "blahblahblah<br>"

    Set oRounds = oDoc.selectNodes("//IntelliGolf/Rounds/*")
    Set oIntelligolf = oDoc.selectSingleNode("//IntelliGolf")
    Set oNewNode = oDoc.createNode(1, "SortedRounds", "")
    
    oIntelligolf.appendChild(oNewNode)
    
    for each oRound in oRounds

        'response.write "blahblahblah<br>"
        'response.write oRound.Attributes.GetNamedItem("Cn").text
    
        if not (oNewNode.hasChildNodes) then
        
            oNewNode.appendChild(oRound)
            
        else
        
            iTimeStart = oRound.Attributes.GetNamedItem("St").nodeValue
            iFound = 0
            
            for each oNode in oNewNode.childNodes
            
                iTimeStartCur = oNode.Attributes.GetNamedItem("St").nodeValue
                if (int(iTimeStart) > int(iTimeStartCur)) then
                    
                    oNewNode.insertBefore oRound, oNode
                    iFound = 1
                    exit for
                    
                end if

            next
        
            if iFound = 0 then
                oNewNode.appendChild(oRound)
            end if
                    
        end if        
    next
       
end function

Private Sub DisplayRounds()
    
    SortRounds()

    'Set oNodes = oDoc.selectNodes("//IntelliGolf/Rounds/*")
    Set oNodes = oDoc.selectNodes("//SortedRounds/*")
    
    response.write "<table border=0 cellpadding=2>"
    
    response.write "<tr>"
    response.write "<td><b>Course</td>"
    response.write "<td><b>Location</td>"
    response.write "<td><b>Date</td>"
    response.write "<td><b>Players</td></tr>"

    For each oNode in oNodes
    
        sCourse = oNode.Attributes.GetNamedItem("Cn").text
        sCity = oNode.Attributes.GetNamedItem("Cc").text
        sState = oNode.Attributes.GetNamedItem("Cs").text
        sTimeStart = oNode.Attributes.GetNamedItem("St").text
        sTimeEnd = oNode.Attributes.GetNamedItem("Et").text
    
        rawDate = ConvertDate(CLng(sTimeStart))
                
        response.write "<tr>"
        response.write "<td><a href='golf.asp?view=round&date=" + sTimeStart + "'>" + sCourse + "</a></td>"
        response.write "<td>" + sCity + "," + sState + "</td>"
        response.write "<td>" + FormatDateTime(rawDate, vbShortDate) + "</td>"
 
        sPlayers = ""
        
        for each oPlayer in oNode.childNodes

            if len(sPlayers) = 0 then
        
                sPlayers = oPlayer.Attributes.GetNamedItem("N").text
            
            else
            
                sPlayers = sPlayers + ", " + oPlayer.Attributes.GetNamedItem("N").text
            
            end if
            
        next

        response.write "<td>" + sPlayers + "</td>"
        
        response.write "</tr>"
        
           
    next
        
end sub

Private function DisplayRound(sPlayer, sDate)

    sQuery = "//IntelliGolf/Rounds/Round[@St='" + sDate + "']"

    Set oRound = oDoc.selectSingleNode(sQuery)
    
    if Len(sPlayer) = 0 then
    
        set oPlayerRound = oRound.childNodes(0)
        
    else
     
        for each oRoundPlayed in oRound.childNodes
        
            sName = oRoundPlayed.Attributes.GetNamedItem("N").text
        
            if InStr(sPlayer, sName) then
                set oPlayerRound = oRoundPlayed
            end if
            
        next

    end if

    sCourse = oRound.Attributes.GetNamedItem("Cn").text
    sCity = oRound.Attributes.GetNamedItem("Cc").text
    sState = oRound.Attributes.GetNamedItem("Cs").text
    sStartTime = oRound.Attributes.GetNamedItem("St").text
    sEndTime = oRound.Attributes.GetNamedItem("Et").text

    '
    ' the header
    '
    timeStart = ConvertDate(CLng(sStartTime))
    timeEnd = ConvertDate(CLng(sEndTime))
    
    response.write "<table bgcolor=""#CCCC99"" cellpadding=4 border=0><tr><td>" + _
                   "<table><tr><td align=left colspan=2>" + _
                   "<font size=+2><b>" + sCourse + "</b></font><br>" + _
                   "<b>" + sCity + ", " + sState + "</b><br></td>" + _
                   "<td align=right valign=bottom><b>" + FormatDateTime(timeStart, vbLongDate) + _
                   "</b></td></tr><tr><td colspan=3>"
    '
    ' first row of scorecard
    '
    response.write _
        "<table border=0 cellpadding=3 bgcolor=""#336633""><tr><td>" + _
        "<table border=0 cellpadding=3 cellspacing=1 bgcolor=""#336633"">" + _
        "<tr>" + _
        "<td bgcolor=""#669966""><font color=""#FFFFCC"">HOLE</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">1</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">2</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">3</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">4</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">5</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">6</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">7</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">8</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">9</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">OUT</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">10</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">11</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">12</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">13</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">14</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">15</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">16</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">17</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">18</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">IN</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">Total</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">HCP</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">NET</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">ADJ</font></td>" + _
        "</tr>"

    '
    ' second row of score card -- tees and yardage
    '
    sQuery = "//IntelliGolf/Courses/Course[@N=""" + sCourse + """]"
    Set oCourse = oDoc.selectSingleNode(sQuery)
    
    iTee = CInt(oPlayerRound.Attributes.GetNamedItem("Te").text)

    dim oTees

    ' find tees node, there may be other nodes
    for each oTempTees in oCourse.childNodes

        if oTempTees.baseName = "Tees" then

            set oTees = oTempTees

        end if

    next

    set oTee = oTees.childNodes(iTee)
    
    sTeeName = oTee.Attributes.GetNamedItem("N").text
    
    Response.write "<tr>" + _
    "<td bgcolor=""#669966""><font color=""#FFFFCC"">" + sTeeName + "</font></td>"

    iTotal = 0
    iFront = 0
    
    for hole = 0 to 17

        if hole > 0 and not CBool (hole Mod 9) then

            response.write "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">" + CStr(iTotal) + "</font></td>"

            iFront = iTotal
            iTotal = 0
                
        end if 
                                    
        sYardage = oTee.childNodes.item(hole).Attributes.GetNamedItem("Y").text
        response.write "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">" + sYardage + "</font></td>"

        iTotal = iTotal + CInt(sYardage)

    next

    response.write "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">" + CStr(iTotal) + "</font>"
    response.write "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">" + CStr(iTotal + iFront) + "</font>"

    response.write "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC""> </font>"
    response.write "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC""> </font>"
    response.write "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC""> </font>"
    
    '
    ' scores for everbody
    '
    for each oRoundPlayed in oRound.childNodes
    
        sPlayerName = oRoundPlayed.Attributes.GetNamedItem("N").text

        response.write "<tr>" + _
                       "<td bgcolor=""#FFFFFF"">" + _
                       "<a href=""golf.asp?view=round&date=" + sDate + "&player=" + sPlayerName + """>" + sPlayerName + "</a>" + _
                       "</td>" 
        
        set oScore = oRoundPlayed.childNodes(0)
        
        iFront = 0
        iTotal = 0
        iHolesPlayed = 0
    
        for iHole = 1 to 18
        
            sQuery = "h" + CStr(iHole)
            sScore = oScore.Attributes.GetNamedItem(sQuery).text
            sPar = oTee.childNodes.item(iHole - 1).Attributes.GetNamedItem("P").text

            if iHole > 1 and not CBool (iHole Mod 10) then

                response.write "<td bgcolor=""#FFFFFF"" align=""right""><font color=""black"">" + CStr(iTotal) + "</font></td>"

                iFront = iTotal
                iTotal = 0
                
            end if 
                           
            ' adjust the color based on birdie, par or over             
            sBackground = "#FFFFFF"
            
            if (CLng(sScore) > 0) and (CLng(sScore) < (CLng(sPar) - 1)) then
                sColor = "white"
                sBackground = "#FF0000"
            elseif (CLng(sScore) < CLng(sPar)) then
                sColor = "red"
            elseif (CLng(sScore) = CLng(sPar)) then
                sColor = "blue"
            else 
                sColor = "black"
            end if
            
            iTotal = iTotal + CInt(sScore)

            if (CInt(sScore) > 0) then
                iHolesPlayed = iHolesPlayed + 1
            else
                sScore = ""
            end if
    
            response.write "<td bgcolor=""" + sBackground + """ align=""center""><font color=""" + sColor + """>" + sScore + "</font></td>"

        next

        ' back 9 total and final total
        if (iTotal > 0) then
            sScore = CStr(iTotal)
        else
            sScore = ""
        end if 
        
        response.write "<td bgcolor=""#FFFFFF"" align=""right""><font color=""black"">" + sScore + "</font></td>"
        response.write "<td bgcolor=""#FFFFFF"" align=""right""><font color=""black"">" + CStr(iTotal + iFront) + "</font></td>"

        ' filler
        response.write "<td bgcolor=""#FFFFFF"" align=""right""><font color=""black""> </font></td>"
        response.write "<td bgcolor=""#FFFFFF"" align=""right""><font color=""black""> </font></td>"
        response.write "<td bgcolor=""#FFFFFF"" align=""right""><font color=""black""> </font></td></tr>"
    
    next

    ' blank line
    response.write "<tr>"
    for i = 1 to 25
        response.write "<td bgcolor=""#FFFFFF"" align=""right""><font color=""black"">&nbsp;</font></td>"
    next
        
    '
    ' par ratings for each hole
    '
    iParThrees = 0

    Response.write "<tr>" + _
    "<td bgcolor=""#669966""><font color=""#FFFFCC"">Par</font></td>"

    iTotal = 0
    
    for hole = 0 to 17

        if hole > 0 and not CBool (hole Mod 9) then

            response.write "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">" + CStr(iTotal) +  "</font></td>"
        
            iFront = iTotal
            iTotal = 0

        end if 

        sPar = oTee.childNodes.item(hole).Attributes.GetNamedItem("P").text
        response.write "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">" + sPar + "</font></td>"

        iTotal = iTotal + CInt(sPar)

        if CInt(sPar) = 3 then

        iParThrees = iParThrees + 1  

        end if
        
    next

    response.write "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">" + CStr(iTotal) + "</font></td>"
    response.write "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">" + CStr(iTotal + iFront) + "</font>"
    response.write "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">  </font>"
    response.write "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">  </font>"
    response.write "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">  </font></td></tr>"
    
    '
    ' handicaps
    '
    Response.write "<tr>" + _
    "<td bgcolor=""#669966""><font color=""#FFFFCC"">Handicap</font></td>"

    for hole = 0 to 17

        if hole > 0 and not CBool (hole Mod 9) then

            response.write "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">  </font></td>"
            
        end if 
                                    
        sHandicap = oTee.childNodes.item(hole).Attributes.GetNamedItem("H").text
        response.write "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">" + sHandicap + "</font></td>"

    next

    response.write "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">  </font>"
    response.write "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">  </font>"
    response.write "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">  </font>"
    response.write "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">  </font>"
    response.write "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">  </font></td></tr>"
   
    '
    ' Greeens in Reg
    '
    iFront = 0
    iTotal = 0

    set oPutt = oPlayerRound.selectSingleNode("Pt")
    set oScore = oPlayerRound.childNodes(0)

    response.write "<tr><td bgcolor=""#FFFFFF"" align=""left""><font color=""black"">Greens in reg</td>"

    for iHole = 1 to 18

        sQuery = "h" + CStr(iHole)

        iScore = oScore.Attributes.GetNamedItem(sQuery).nodeValue
        iPar = oTee.childNodes.item(iHole - 1).Attributes.GetNamedItem("P").nodeValue
        iPutt = oPutt.Attributes.GetNamedItem(sQuery).nodeValue

        'response.write CStr(iHole) + " " + CStr(iScore) + " " + CStr(iPar) + " " + CStr(iPutt) + "<br>"
        
        if iHole > 1 and not CBool (iHole Mod 10) then

            if (iTotal > 0) then
                sOut = CStr(iTotal)
            else
                sOut = " " 
            end if 
            
            response.write "<td bgcolor=""#FFFFFF"" align=""right""><font color=""black"">" + sOut + "</font></td>"

            iFront = iTotal
            iTotal = 0
            
        end if 

        if iScore and ((iPar - 2) >= (iScore - iPutt)) then
            response.write "<td bgcolor=""#FFFFFF"" align=""center""><font color=""black"">x</font></td>"
            iTotal = iTotal + 1
        else
            response.write "<td bgcolor=""#FFFFFF"" align=""center""><font color=""black"">&nbsp;</font></td>"
        end if
        
    next

    ' back 9 total and final total
    response.write "<td bgcolor=""#FFFFFF"" align=""right""><font color=""black"">" + CStr(iTotal) + "</font></td>"
    response.write "<td bgcolor=""#FFFFFF"" align=""right""><font color=""black"">" + CStr(iTotal + iFront) + "</font></td>"
    
    ' percentage of greeens
    if (iHolesPlayed > 9) then 
        iHolesPlayed = 18
    else
        iHolesPlayed = 9
    end if
    
    iPercent = CLng(((iTotal + iFront) / iHolesPlayed) * 100)
    response.write "<td bgcolor=""#FFFFFF"" align=""right""><font color=""black"">" + CStr(iPercent) + "%</font></td>"

    response.write "<td bgcolor=""#FFFFFF"" align=""right""><font color=""black"">&nbsp;</font></td>"
    response.write "<td bgcolor=""#FFFFFF"" align=""right""><font color=""black"">&nbsp;</font></td>"
    
    '
    ' Putts
    '
    response.write "<tr><td bgcolor=""#FFFFFF"" align=""left""><font color=""black"">Putts</td>"

    iFront = 0
    iTotal = 0
    
    for iHole = 1 to 18

        sQuery = "h" + CStr(iHole)
        sPutt = oPutt.Attributes.GetNamedItem(sQuery).text

        if iHole > 1 and not CBool (iHole Mod 10) then

            response.write "<td bgcolor=""#FFFFFF"" align=""right""><font color=""black"">" + CStr(iTotal) + "</font></td>"

            iFront = iTotal
            iTotal = 0
                
        end if 
                                    
        response.write "<td bgcolor=""#FFFFFF"" align=""center""><font color=""black"">" + sPutt + "</font></td>"

        iTotal = iTotal + CInt(sPutt)
    
    next

    ' back 9 total and final total
    response.write "<td bgcolor=""#FFFFFF"" align=""right""><font color=""black"">" + CStr(iTotal) + "</font></td>"
    response.write "<td bgcolor=""#FFFFFF"" align=""right""><font color=""black"">" + CStr(iTotal + iFront) + "</font></td>"

    response.write "<td bgcolor=""#FFFFFF"" align=""right""><font color=""black"">&nbsp;</font></td>"
    response.write "<td bgcolor=""#FFFFFF"" align=""right""><font color=""black"">&nbsp;</font></td>"
    response.write "<td bgcolor=""#FFFFFF"" align=""right""><font color=""black"">&nbsp;</font></td>"

    
    ' Penalty strokes
    Set oPenalty = nothing
  
    iFront = 0
    iTotal = 0
      
    response.write "<tr><td bgcolor=""#FFFFFF"" align=""left""><font color=""black"">Penalty strokes</td>"

    if TypeName(oPlayerRound.selectSingleNode("Pn")) = "IXMLDOMElement" then 

        Set oPenalty = oPlayerRound.selectSingleNode("Pn")
    
        for iHole = 1 to 18
    
            sQuery = "h" + CStr(iHole)
            iPenalty = oPenalty.Attributes.GetNamedItem(sQuery).nodeValue
    
            if (iHole > 1) and not (CBool (iHole Mod 10)) then
    
                if (iTotal > 0) then
                    response.write "<td bgcolor=""#FFFFFF"" align=""right""><font color=""black"">" + CStr(iTotal) + "</font></td>"
                else
                    response.write "<td bgcolor=""#FFFFFF"" align=""right""><font color=""black""> </font></td>"
                end if
                
                iFront = iTotal
                iTotal = 0
                
            end if 

            if (iPenalty) then 

                response.write "<td bgcolor=""#FFFFFF"" align=""right""><font color=""black"">" + CStr(iPenalty) + "</font></td>"
                iTotal = iTotal + iPenalty
                
            else
            
                response.write "<td bgcolor=""#FFFFFF"" align=""right""><font color=""black"">&nbsp;</font></td>"

            end if

        next
    
        if (iTotal > 0) then
            sOut = CStr(iTotal)
        else
            sOut = " "
        end if
        response.write "<td bgcolor=""#FFFFFF"" align=""right""><font color=""black"">" + sOut + "</font></td>"
    
        if ((iTotal + iFront) > 0) then
            sOut = CStr(iTotal + iFront)
        else
            sOut = " "
        end if
        response.write "<td bgcolor=""#FFFFFF"" align=""right""><font color=""black"">" + sOut + "</font></td>"
    
        response.write "<td bgcolor=""#FFFFFF"" align=""right""><font color=""black"">&nbsp;</font></td>"
        response.write "<td bgcolor=""#FFFFFF"" align=""right""><font color=""black"">&nbsp;</font></td>"
        response.write "<td bgcolor=""#FFFFFF"" align=""right""><font color=""black"">&nbsp;</font></td>"

    else
    
        ' no penalty info
        for i = 1 to 24
            response.write "<td bgcolor=""#FFFFFF"" align=""right""><font color=""black"">&nbsp;</font></td>"
        next 
            
    end if

    ' Fairways hit
    Set oOptions = nothing
  
    iFront = 0
    iTotal = 0
      
    response.write "<tr><td bgcolor=""#FFFFFF"" align=""left""><font color=""black"">Fairways</td>"

    if TypeName(oPlayerRound.selectSingleNode("Di")) = "IXMLDOMElement" then 

        Set oOptions = oPlayerRound.selectSingleNode("Di")
    
        for iHole = 1 to 18
    
            sQuery = "h" + CStr(iHole)
            iOptions = oOptions.Attributes.GetNamedItem(sQuery).nodeValue
            iFairway = iOptions AND &h1000

            if (iHole > 1) and not (CBool (iHole Mod 10)) then
    
                if (iTotal > 0) then
                    response.write "<td bgcolor=""#FFFFFF"" align=""right""><font color=""black"">" + CStr(iTotal) + "</font></td>"
                else
                    response.write "<td bgcolor=""#FFFFFF"" align=""right""><font color=""black""> </font></td>"
                end if
                
                iFront = iTotal
                iTotal = 0
                
            end if 

            if (iFairway) then 

                response.write "<td bgcolor=""#FFFFFF"" align=""right""><font color=""black"">" + "x" + "</font></td>"
                iTotal = iTotal + 1
                
            else
            
                response.write "<td bgcolor=""#FFFFFF"" align=""right""><font color=""black"">&nbsp;</font></td>"

            end if

        next
    
        if (iTotal > 0) then
            sOut = CStr(iTotal)
        else
            sOut = " "
        end if
        response.write "<td bgcolor=""#FFFFFF"" align=""right""><font color=""black"">" + sOut + "</font></td>"
    
        if ((iTotal + iFront) > 0) then
            sOut = CStr(iTotal + iFront)
        else
            sOut = " "
        end if
        response.write "<td bgcolor=""#FFFFFF"" align=""right""><font color=""black"">" + sOut + "</font></td>"

        iPercent = CLng(((iTotal + iFront) / (iHolesPlayed - iParThrees)) * 100)
        response.write "<td bgcolor=""#FFFFFF"" align=""right""><font color=""black"">" + CStr(iPercent) + "%</font></td>"

        response.write "<td bgcolor=""#FFFFFF"" align=""right""><font color=""black"">&nbsp;</font></td>"
        response.write "<td bgcolor=""#FFFFFF"" align=""right""><font color=""black"">&nbsp;</font></td>"

    else
    
        ' no fairway info
        for i = 1 to 24
            response.write "<td bgcolor=""#FFFFFF"" align=""right""><font color=""black"">&nbsp;</font></td>"
        next 
            
    end if

    ' wrap up the tables
    response.write "</table></tr></td></table>"

    iMin = DateDiff("n", timeStart, timeEnd)

    if (iMin > 0) then
    
        iHour = Int(iMin / 60)
        iMin = iMin mod 60
    
    else
    
        iHour = 0
        iMin = 0
            
    end if
    
    timeDuration = TimeSerial(iHour, iMin, 0)

    sRating = oTee.Attributes.GetNamedItem("Mr").text
    sSlope = oTee.Attributes.GetNamedItem("Ms").text
        
    response.write "<tr><td>                                                </td><td align=middle>" + _
                   "<font size=-1>Start:&nbsp;" + FormatDateTime(timeStart, vbShortTime) + _
                   "&nbsp;&nbsp;&nbsp;Duration:&nbsp;" + FormatDateTime(timeDuration, vbShortTime) + _
                   "</font></td><td align=right><font size=-1>Course Rating " + CStr(CInt(sRating) / 10) + _
                   "&nbsp;&nbsp;&nbsp;Slope Rating " + sSlope + "</font></td></tr></table>"
    response.write "</table>"
    
end function

Private Sub DisplayPlayers()
    
    Set oNodes = oDoc.selectNodes("//IntelliGolf/Players/*")
    
    response.write "<br>Players: <br><br>"

    i = 0
    
    For each oNode in oNodes
        
        i = i + 1
        
        sFullName = oNode.Attributes.GetNamedItem("N").text
        sShortName = oNode.Attributes.GetNamedItem("S").text

        strout = sFullName + " : " + sShortName + "<br>"
            
        response.write strout
        
    Next

End Sub

Private Sub DisplayCourses()
    
    Set oNodes = oDoc.selectNodes("//IntelliGolf/Courses/*")
    
    response.write "Courses: <br><br>"
    
    i = 0
    
    For each oNode in oNodes
        
        i = i + 1
        
        sName = oNode.Attributes.GetNamedItem("N").text
        sCity = oNode.Attributes.GetNamedItem("C").text
        sState = oNode.Attributes.GetNamedItem("S").text
        sCountry = oNode.Attributes.GetNamedItem("Cy").text
        sPhone = oNode.Attributes.GetNamedItem("P").text

        strout = sName + " : " + sCity + ", " + sState + " " + sPhone + "<br>"
        
        response.write strout

        response.write _
        "<table border=0 cellpadding=2 bgcolor=""#336633""><tr><td>" + _
        "<table border=0 cellpadding=2 cellspacing=1 bgcolor=""#336633"">" + _
        "<tr>" + _
        "<td bgcolor=""#669966""><font color=""#FFFFCC"">HOLE</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">1</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">2</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">3</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">4</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">5</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">6</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">7</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">8</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">9</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">OUT</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">10</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">11</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">12</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">13</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">14</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">15</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">16</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">17</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">18</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">IN</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">Total</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">M Rating</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">M Slope</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">W Rating</font></td>" + _
        "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">W Slope</font></td>" + _
        "</tr>"

        ' old code
        'set oTees = oNode.childNodes.item(0)

        ' find the tees node
        for each oItem in oNode.childNodes

            if oItem.nodeName = "Tees" then

                set oTees = oItem

            end if
        Next

        for each oTee in oTees.childNodes
            
            sTeeName = oTee.Attributes.GetNamedItem("N").text
            sTeeRatingM = oTee.Attributes.GetNamedItem("Mr").text
            sTeeSlopeM = oTee.Attributes.GetNamedItem("Ms").text
            sTeeRatingW = oTee.Attributes.GetNamedItem("Wr").text
            sTeeSlopeW = oTee.Attributes.GetNamedItem("Ws").text

            sTeeRatingM = CStr(Int(sTeeRatingM) / 10) 
            sTeeRatingW = CStr(Int(sTeeRatingW) / 10) 

            ' yardages
            Response.write "<tr>" + _
            "<td bgcolor=""#669966""><font color=""#FFFFCC"">" + sTeeName + "</font></td>"

            iTotal = 0
            iFront = 0
            
            for hole = 0 to 17

                if hole > 0 then
                    if not CBool (hole Mod 9) then
    
                        response.write "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">" + CStr(iTotal) + "</font></td>"

                        iFront = iTotal
                        iTotal = 0
                        
                    end if
                end if 
                                            
                sYardage = oTee.childNodes.item(hole).Attributes.GetNamedItem("Y").text
                response.write "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">" + sYardage + "</font></td>"

                iTotal = iTotal + CInt(sYardage)

            next

            response.write "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">" + CStr(iTotal) + "</font>"
            response.write "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">" + CStr(iTotal + iFront) + "</font>"

            response.write "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">" + sTeeRatingM + "</font>"
            response.write "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">" + sTeeSlopeM + "</font>"
            response.write "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">" + sTeeRatingW + "</font>"
            response.write "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">" + sTeeSlopeW + "</font></td>"


            for each oHole in oTee.childNodes
            
                sHoleNum = oHole.Attributes.GetNamedItem("N").text
                sHoleYardage = oHole.Attributes.GetNamedItem("Y").text
                sHoleHandicap = oHole.Attributes.GetNamedItem("H").text
                sHolePar = oHole.Attributes.GetNamedItem("P").text

                'response.write "  " + sHoleNum + " " + sHoleYardage + " " + sHoleHandicap + " " + sHolePar + "<br>"
            
            next

    
        Next

        set oTee = oTees.childNodes.item(0)
        
        ' Pars
        Response.write "<tr>" + _
        "<td bgcolor=""#669966""><font color=""#FFFFCC"">Par</font></td>"

        iTotal = 0
        
        for hole = 0 to 17

            if hole > 0 then
                if not CBool (hole Mod 9) then

                    response.write "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">" + CStr(iTotal) +  "</font></td>"
                
                    iFront = iTotal
                    iTotal = 0
                end if
            end if 
                                        
            sPar = oTee.childNodes.item(hole).Attributes.GetNamedItem("P").text
            response.write "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">" + sPar + "</font></td>"

            iTotal = iTotal + CInt(sPar)
            
        next

        response.write "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">" + CStr(iTotal) + "</font></td>"
        response.write "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">" + CStr(iTotal + iFront) + "</font>"
        response.write "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">  </font>"
        response.write "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">  </font>"
        response.write "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">  </font>"
        response.write "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">  </font></td>"

        ' Handicap
        Response.write "<tr>" + _
        "<td bgcolor=""#669966""><font color=""#FFFFCC"">Handicap</font></td>"

        for hole = 0 to 17

            if hole > 0 then
                if not CBool (hole Mod 9) then

                    response.write "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">  </font></td>"
                
                end if
            end if 
                                        
            sHandicap = oTee.childNodes.item(hole).Attributes.GetNamedItem("H").text
            response.write "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">" + sHandicap + "</font></td>"

        next

        response.write "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">  </font>"
        response.write "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">  </font>"
        response.write "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">  </font>"
        response.write "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">  </font>"
        response.write "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">  </font>"
        response.write "<td bgcolor=""#669966"" align=center><font color=""#FFFFCC"">  </font></td>"
       
        response.write "</table></tr></td></table><br>"
    Next

End Sub

%>
</b>
</body>
</html>