<?xml version="1.0" encoding="Shift_JIS" standalone="yes"?>
<xsl:stylesheet
  version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns="http://www.w3.org/Profiles/XHTML-transitional"
>

<xsl:output method="html" encoding="Shift_JIS"/>

<xsl:template match="/">
<HTML>
<HEAD>
  <TITLE>XML BBS</TITLE>
  <SCRIPT LANGUAGE="vbscript">
  <xsl:comment>
  <![CDATA[
    Function Encode(strQuery)
      For i = 1 To Len(strQuery)
        If Asc(Mid(strQuery, i, 1)) = 13 Or Asc(Mid(strQuery, i, 1)) = 10 Then
          strEncode = strEncode  & "0"
        End If
        strEncode = strEncode & Hex(Asc(Mid(strQuery, i, 1)))
      Next
      For i = 1 To Len(strEncode) Step 2
        Encode = Encode & "%" & Mid(strEncode, i, 2)
      Next
    End Function

    Function message_onSubmit()
      message_onSubmit = False
      strTitle = document.all("title").value
      strName = document.all("name").value
      strHome = document.all("home").value
      strMail = document.all("mail").value
      strComment = document.all("comment").value
      If strName <> "" And strComment <> "" Then
        strQuery = "xmlbbs.cgi?title=" & Encode(strTitle)
        strQuery = strQuery & "&name=" & Encode(strName)
        strQuery = strQuery & "&home=" & Encode(strHome)
        strQuery = strQuery & "&mail=" & Encode(strMail)
        strQuery = strQuery & "&comment=" & Encode(strComment)
        location.href = strQuery
      Else
        Call MsgBox("名前とコメントを入力しないと投稿できません。", vbOKOnly & vbCritical)
      End If
    End Function
  ]]>
  </xsl:comment>
  </SCRIPT>
  <STYLE TYPE="text/css">
  <xsl:comment>
    TD, INPUT, SPAN { font-family:'ＭＳ Ｐゴシック'; }
    TEXTAREA { font-family:'ＭＳ ゴシック';}
    A { text-decoration:none;font-family:'ＭＳ Ｐゴシック'; }
    A:link { color:#5555cc; }
    A:active { color:#f80000; }
    A:visited { color:#555555; }
    A:hover { color:#f80000; }
  </xsl:comment>
  </STYLE>
</HEAD>
<BODY BGCOLOR="#deb887">
  <FORM ID="message">
  <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" WIDTH="100%">
    <TR>
      <TD ALIGN="center" STYLE="font-family:Verdana;font-size:20pt;font-weight:bold;">
        XML BBS
      </TD>
    </TR>
    <TR>
      <TD ALIGN="center">
        <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="2">
          <TR>
            <TD>タイトル</TD>
            <TD>
              <INPUT ID="title" TYPE="text" SIZE="70" MAXLENGTH="100"/>
            </TD>
          </TR>
          <TR>
            <TD>お名前</TD>
            <TD>
              <INPUT ID="name" TYPE="text" SIZE="70" MAXLENGTH="50"/>
            </TD>
          </TR>
          <TR>
            <TD>ホーム</TD>
            <TD>
              <INPUT ID="home" TYPE="text" SIZE="70" MAXLENGTH="150"/>
            </TD>
          </TR>
          <TR>
            <TD>Eメール</TD>
            <TD>
              <INPUT ID="mail" TYPE="text" SIZE="70" MAXLENGTH="50"/>
            </TD>
          </TR>
          <TR>
            <TD>コメント</TD>
            <TD>
              <TEXTAREA ID="comment" COLS="50" ROWS="8" WRAP="hard"></TEXTAREA>
            </TD>
          </TR>
          <TR>
            <TD COLSPAN="2" ALIGN="right">
              <INPUT TYPE="submit" VALUE="送信する"/>
              <INPUT TYPE="reset" VALUE="消去する"/>
            </TD>
          </TR>
        </TABLE>
      </TD>
    </TR>
    <TR>
      <TD ALIGN="center">
        <TABLE BORDER="0" CELLPADDING="4" CELLSPACING="4" WIDTH="90%">
          <TR>
            <TD STYLE="padding:0px;background-color:#000000;height:2px;"></TD>
          </TR>
          <xsl:for-each select="//comment">
            <TR>
              <TD>
                <SPAN STYLE="color:#5555cc;font-weight:bold;">
                  <xsl:choose>
                    <xsl:when test="@title != ''">
                        ●<xsl:value-of select="@title"/>
                    </xsl:when>
                    <xsl:otherwise>
                      ●無題
                    </xsl:otherwise>
                  </xsl:choose>
                </SPAN>
                　投稿者：
                <xsl:choose>
                  <xsl:when test="contains(@mail,'@')">
                    <A STYLE="font-weight:bold;"><xsl:attribute name="HREF">mailto:<xsl:value-of select="@mail"/></xsl:attribute>
                      <xsl:value-of select="@name"/>
                    </A>
                  </xsl:when>
                  <xsl:otherwise>
                    <SPAN STYLE="font-weight:bold;color:#b22222;">
                      <xsl:value-of select="@name"/>
                    </SPAN>
                  </xsl:otherwise>
                </xsl:choose>
                　投稿日：
                <xsl:value-of select="@date"/>
              </TD>
            </TR>
            <TR>
              <TD STYLE="padding-left:20px;padding-right:20px;line-height:14pt;">
                <xsl:copy-of select="node()"/>
              </TD>
            </TR>
            <TR>
              <TD STYLE="padding-left:20px;padding-right:20px;">
                <xsl:choose>
                  <xsl:when test="starts-with(@home,'http://')">
                    <A TARGET="_blank"><xsl:attribute name="HREF"><xsl:value-of select="@home"/></xsl:attribute>
                      <xsl:value-of select="@home"/>
                    </A>
                  </xsl:when>
                  <xsl:otherwise>
                    <BR/>
                  </xsl:otherwise>
                </xsl:choose>
              </TD>
            </TR>
            <TR>
              <TD STYLE="padding:0px;background-color:#000000;height:2px;"></TD>
            </TR>
          </xsl:for-each>
        </TABLE>
      </TD>
    </TR>
  </TABLE>
  </FORM>
</BODY>
</HTML>
</xsl:template>

</xsl:stylesheet>