<?xml version="1.0" encoding="utf-8" ?>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"
	charset=utf-8 " />
<script type="text/javascript" language="javascript"><%@include file='/js/scripts.js'%></script>

<style type="text/css">
<%@include file='/css/style.css'%>
</style>
<title>Raamatukogu</title>
</head>
<body>
<spring:url value="/library/entry" var="add" />
<p id="add"><a id="links"
	href="javascript:ajaxResult('${add}','add')">Lisa uus raamat</a></p>
<form action="library" method="get"><input type="text"
	name="search" /> <input type="submit" value="Otsi" /></form>
<c:if test="${search}">
	<spring:url value="/library" var="back" />
	<p><a href="${back}">K&#245;ik</a></p>
</c:if>
<table id="table" cellpadding="3" cellspacing="1" border="1">
	<tr>
		<td id="heading">Pealkiri</td>
		<td id="heading">Autor</td>
		<td id="heading">&#381;anr</td>
		<td id="heading">T&uuml;&uuml;p</td>
		<td id="heading">Aasta</td>
		<td id="heading">Kommentaar</td>
		<td id="heading">Muuda|Kustuta</td>
	</tr>
	<c:forEach var="entry" items="${library}">
		<tr id="row${entry.id}">
			<td>${entry.title}</td>
			<td>${entry.author}</td>
			<td>${entry.genre}</td>
			<td>${entry.type}</td>
			<td>${entry.year}</td>
			<td>${entry.comment}</td>
			<spring:url value="/library/entry?id=${entry.id}" var="change" />
			<td><a href="${change}">Muuda</a> <spring:url
				value="/library/remove?id=${entry.id}" var="remove" /> <a
				href="javascript:ajaxRemoveRow('row${entry.id}','${remove}','table')">Kustuta</a>
			</td>
		</tr>
	</c:forEach>
</table>
<p>${error}</p>
</body>
</html>