<%--
 * Copyright by Intland Software
 *
 * All rights reserved.
 *
 * This software is the confidential and proprietary information
 * of Intland Software. ("Confidential Information"). You
 * shall not disclose such Confidential Information and shall use
 * it only in accordance with the terms of the license agreement
 * you entered into with Intland.
 *
 * $Revision$ $Date$
--%>



<%@ taglib uri="jstl-c" prefix="c" %>
<%@ taglib uri="jstl-fmt" prefix="fmt" %>
<%@ taglib uri="taglib" prefix="tag" %>
<%@ taglib uri="uitaglib" prefix="ui" %>

<%@ page import="com.intland.codebeamer.Config"%>

<%
	response.setContentType(Config.getContentType());
%>

<%
	int counter = 1;
%>

<c:set var="chat_id" value="${param.chat_id}" />

<tag:pollChat var="messages" chat_id="${chat_id}" />

<c:set var="user" value="${pageContext.request.userPrincipal}" />

<HTML>
<HEAD>

<LINK REL="stylesheet" HREF="<ui:urlversioned value="/stylesheet/CB-Style.css" />" TYPE="text/css"/>
<LINK REL="stylesheet" HREF="<ui:urlversioned value="/stylesheet/chat.css" />" TYPE="text/css"/>

<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">

<!--
function reload()
{
	window.location.reload();
}
<c:if test="${!empty user}">
	<c:out value="setInterval('reload()',${sessionScope.chatPollingPeriod * 1000});" escapeXml="false" />
</c:if>

//-->
</SCRIPT>

</HEAD>

<BODY onLoad="window.location.hash='#last_message'" bgcolor="white" link="#000000" vlink="#000000" alink="#000000" topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">


<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0">

<c:forEach items="${messages}" var="message" varStatus="status">

	<TR VALIGN="top" CLASS="<%=((counter % 2) == 0 ? "even" : "odd")%>">
		<TD>&nbsp;</TD>

		<TD NOWRAP><tag:userLink user_id="${message.submitter}" target="_blank" />&nbsp;</TD>

		<TD NOWRAP WIDTH="95%">&nbsp;<fmt:formatDate value="${message.submittedAt}"
			timeZone="${user.timeZone}"
			pattern="h:mm a" />&nbsp;</TD>
	</TR>

	<TR VALIGN="top" CLASS="<%=((counter++ % 2) == 0 ? "even" : "odd")%>">
		<TD>&nbsp;</TD>

		<TD COLSPAN="2" WIDTH="95%"><c:out value="${message.message}" />&nbsp;</TD>
	</TR>

	<c:if test="${!status.last}">
		<TR>
			<TD HEIGHT="5"></TD>
		</TR>
	</c:if>

</c:forEach>

</TABLE><A NAME="last_message"></A>&nbsp;

<ui:delayedScript flush="true" />
</BODY>

</HTML>