#set ($page_title = 'Task Detail')
#set ($init_js = 'init();')
	<script src="$link.contextPath/resources/TaskDetail.js" language="JavaScript"></script>
    <div id="menu"> 
		<h2>Menu</h2>
		<ul>
			<li><a href="$link.setAction('/openAddForm')"><img src="$link.setRelative('/resources/skin/default/image/icon/normal16.png')"/>タスクを追加</a></li>
			<li><a href='$link.setRelative("/$task.taskId/searchUnlinked")'><img src="$link.setRelative('/resources/skin/default/image/icon/link.png')"/>タスクをリンクする</a></li>
#set ($action = $link.setRelative('/search'))
#prepareSearchTaskAction($action $taskQuery $taskPager)
	        <li><a href="$action"><img src="$link.setRelative('/resources/skin/default/image/icon/go_up.png')"/>タスク一覧に戻る</a></li>
		</ul>
	</div>
	<div id="main"> 
#errorMarkup()
#if($task)
		<div class="taskinfo" id="taskInfo">
			<form id="PropertyForm" onsubmit="return editProperty()">
				<input id="estimatedManHourTaskId" name="taskId" type="hidden" value="$task.taskId"/>
				<table class="list">
					<tr>
						<td class="statusIconLarge" colspan="2">
							<img id="statusIcon" class="status${task.statusId}-iconLarge" src="$link.setRelative('/resources/skin/default/image/spacer.gif')"/>
							<p>
#foreach($status in $statusList)
#set ($statusActive = ($status.statusId==$task.statusId))
								<a href="javascript:updateStatus($task.taskId, ${status.statusId})"><img class="status${status.statusId}" src="$link.contextPath/resources/skin/default/image/spacer.gif" /></a>
#end
							</p>
						</td>
					</tr>
					<tr> 
						<th>タスクID</th>
						<td>$task.taskId</td>
					</tr>
					<tr> 
						<th>優先度</th>
						<td class="priority${task.priority}" id="taskPriority">
							<input type="hidden" id="taskOriginalPriority" value="$task.priority">
							<div class="horizontal-priority-set" onmouseout="updatePriorityIcon('taskPriority', $('taskOriginalPriority').value)">
								<img class="icon-priority1" onmouseover="updatePriorityIcon('taskPriority', 1)" onclick="updatePriority($task.taskId, 1);" src="$link.setRelative('/resources/skin/default/image/spacer.gif')"/>
								<img class="icon-priority2" onmouseover="updatePriorityIcon('taskPriority', 2)" onclick="updatePriority($task.taskId, 2);" src="$link.setRelative('/resources/skin/default/image/spacer.gif')"/>
								<img class="icon-priority3" onmouseover="updatePriorityIcon('taskPriority', 3)" onclick="updatePriority($task.taskId, 3);" src="$link.setRelative('/resources/skin/default/image/spacer.gif')"/>
								<img class="icon-priority4" onmouseover="updatePriorityIcon('taskPriority', 4)" onclick="updatePriority($task.taskId, 4);" src="$link.setRelative('/resources/skin/default/image/spacer.gif')"/>
								<img class="icon-priority5" onmouseover="updatePriorityIcon('taskPriority', 5)" onclick="updatePriority($task.taskId, 5);" src="$link.setRelative('/resources/skin/default/image/spacer.gif')"/>
								<img class="icon-priority0" onmouseover="updatePriorityIcon('taskPriority', 0)" onclick="updatePriority($task.taskId, 0);" src="$link.setRelative('/resources/skin/default/image/spacer.gif')"/>
							</div>
						</td>
					</tr>
					<tr> 
						<th>作成日</th>
						<td id="createDate">$utils.formatDate($task.createDate)</td>
					</tr>
					<tr> 
						<th>更新日</th>
						<td id="updateDate">$utils.formatTimestamp($task.updateDate)</td>
					</tr>
					<tr id="deadEndDateContainer"> 
						<th>〆切</th>
						<td id="deadEndDateView">$utils.formatDate($task.deadEndDate)</td>
					</tr>
					<tr class="form" id="deadEndDateForm" style="display:none;"> 
						<th>〆切</th>
						<td><input id="deadEndDate" type="text" class="text" value="$utils.formatDate($task.deadEndDate)"/></td>
					</tr>
					<tr id="estimatedManHourContainer"> 
						<th>見積</th>
						<td id="estimatedManHourView">$task.estimatedManHour</td>
					</tr>
					<tr class="form" id="estimatedManHourForm" style="display:none"> 
						<th>見積</th>
						<td><input id="estimatedManHour" name="estimatedManHour" type="text" class="text" value="$task.estimatedManHour"/></td>
					</tr>
				</table>
				<a id="propertyLink" class="ajax" href="javascript:openPropertyForm()"/>変更</a>
				<p id="propertyFormButton" style="display:none">
				<input type="submit" class="submit" value="登録"/>
				<input type="reset" class="cancel" value="キャンセル" onclick="closePropertyForm()"/>
				</p>
			</form>
		</div>
		<ul class="tagList">
			<li id="tagListViewContainer">
			<ul id="tagListView">
#set ($taskTagList = $task.tagAsList)
#foreach($taskTag in $taskTagList)
				<li class="$tagMap.get($taskTag).tagTypeBean.styleClass">$taskTag</li>
#end
			</ul>
			</li>
			<li id="tagListLink"><a class="ajax" href="javascript:openTagListForm()"/>タグ編集</a></li>
			<li id="tagListFormContainer" style="display:none;">
				<form id="tagListForm" onsubmit="return editTagList()">
				<input type="hidden" id="tagListTaskId" name="taskId" value="$task.taskId"/>
				<input type="text" id="tagList" class="text" value="$task.tagList"/>
				<input type="submit" class="submit" value="登録"/>
				<input type="reset" class="cancel" value="キャンセル" onclick="closeTagListForm()"/>
				</form>
				<ul id="tagSelecter" class="tagList">
#foreach($tag in $tagList)
#set ($tagId = $tag.tagId)
					<li id="tag${tagId}" class="$utils.decode($task.hasTag($tag.name), $tag.tagTypeBean.styleClass, '')"><a href="javascript:updateTagList('tagList', 'tag${tagId}', '$tag.name', '$tag.tagTypeBean.styleClass')">$tag.name</a></li>
#end
				</ul>
			</li>
		</ul>

		<p id="contentsView" class="text">
			$utils.formatHtmlSimple($task.contents)
		</p>
		<p><a id="editContentsLink" class="ajax" href="javascript:openEditContentsForm()"/>編集</a></p>
		<p>
			<form id="editContentsForm" onsubmit="return editContents()" style="display:none">
			<input id="contentsTaskId" name="taskId" type="hidden" value="$task.taskId"/>
			<textarea id="contents" name="contents" rows="15">$task.contents</textarea>
			<div>
			<input type="submit" class="submit" value="登録"/>
			<input type="reset" class="cancel" value="キャンセル" onclick="closeEditContentsForm()"/>
			</div>
			</form>
		</p>
		<h3>Attached File</h3>
		<ul class="fileList">
			<li>
			<ul>
#foreach($attachedFile in $task.attachedFileBeans)
			<li id="file-${attachedFile.fileId}"><a href="$link.setAction('/downloadFile').addQueryData('fileId', $attachedFile.fileId)">$attachedFile.name</a><a class="deleteAction" href="javascript:deleteFile(${attachedFile.fileId},'file-${attachedFile.fileId}');"><img src="$link.contextPath/resources/skin/default/image/spacer.gif" width="16" height="16"/></a></li>
#end
			</ul>
			</li>
			<li id="uploadFileLink"><a class="ajax" href="javascript:openUploadFileForm()"/>ファイル追加</a></li>
			<li id="uploadFileForm" style="display:none">
			<form action="$link.setAction('/addFile')" method="post"  enctype="multipart/form-data">
			<input type="hidden" name="taskId" value="$task.taskId"/>
			<input name="attachedFile" type="file"/>
			<input type="submit" class="submit" value="登録"/>
			<input type="reset" class="cancel" value="キャンセル" onclick="closeUploadFileForm()"/>
			</form>
			</li>
		</ul>
		<h2 id="commentTitle">Comment</h2>
#if($task.taskCommentBeans.size() == 0)
	#set( $commentVisible = 'display:none')
#end
			<dl class="commentList" id="commentList" style="$commentVisible">
#foreach($comment in $task.taskCommentBeans)
				<dt>$comment.commentator ($utils.formatTimestamp($comment.updateDate))</dt>
				<dd>$utils.formatHtmlSimple($comment.contents)	</dd>
#end
			</dl>
			<a id="addCommentLink" class="ajax" href="javascript:openCommentForm()"/>コメント追加</a>
			<form id="CommentForm" onsubmit="return addComment()" style="display:none">
				<fieldset>
					<input id="commentTaskId" name="taskId" type="hidden" value="$task.taskId"/>
					<div>
						<label for="comment">コメント</label>
						<textarea id="comment" name="comment" rows="3"></textarea> 
					</div>
					<div>
						<label for="commenator">入力者</label>
						<input id="commentator" name="commentator" type="text" class="text"/>
					</div>
				</fieldset>
				<div class="action">
				<input type="submit" class="submit" value="登録"/>
				<input type="reset" class="cancel" value="キャンセル" onclick="closeCommentForm()"/>
				</div>
			</form>
		<h2>Linked Task</h2>
		<!--  関連タスクが存在しない場合はdisplay:noneを設定  -->
#if($task.linkedTaskList.size() == 0)
	#set( $linkedTaskVisible = 'display:none;')
#end
		<p>全$task.linkedTaskList.size()件(見積合計: $task.linkedTaskEstimatedManHourTotal)</p>
		<table id="linkedTaskList" class="list" width="99%" style="$linkedTaskVisible">
		<tr> 
			<th nowrap="nowrap">状態</th>
			<th nowrap="nowrap"><img src="$link.setRelative('/resources/skin/default/image/icon/star-off.gif')" alt="優先度"/></th>
			<th nowrap="nowrap">タスク</th>
			<th nowrap="nowrap">〆切</th>
			<th nowrap="nowrap">更新日</th>
		</tr>
#foreach($linkedTask in $task.linkedTaskList)
		<tr id="linkedTask-${linkedTask.taskId}"> 
			<td class="statusIcon">
				<img id="linkedTaskStatusIcon-${linkedTask.taskId}" class="status${linkedTask.statusId}-icon" src="$link.setRelative('/resources/skin/default/image/spacer.gif')"  alt="$linkedTask.statusBean.name"/> 
				<ul>
	#foreach($status in $statusList)
					<li><a href="javascript:updateLinkedTaskStatus(${linkedTask.taskId},${status.statusId})"><img class="status${status.statusId}" src="$link.contextPath/resources/skin/default/image/spacer.gif" alt="$status.name" /></a></li>
	#end
				</ul>
			</td>
			<td id="linkedTaskPriority-${linkedTask.taskId}" class="priority${linkedTask.priority}">
				<input type="hidden" id="linkedTaskOriginalPriority-${linkedTask.taskId}" value="${linkedTask.priority}">
				<div class="vertical-priority-set" onmouseout="updatePriorityIcon('linkedTaskPriority-${linkedTask.taskId}', $('linkedTaskOriginalPriority-${linkedTask.taskId}').value)">
					<img class="icon-priority1" onmouseover="updatePriorityIcon('linkedTaskPriority-${linkedTask.taskId}', 1)"  onclick="updateLinkedTaskPriority(${linkedTask.taskId}, 1);" src="$link.setRelative('/resources/skin/default/image/spacer.gif')"/>
					<img class="icon-priority2" onmouseover="updatePriorityIcon('linkedTaskPriority-${linkedTask.taskId}', 2)"  onclick="updateLinkedTaskPriority(${linkedTask.taskId}, 2);" src="$link.setRelative('/resources/skin/default/image/spacer.gif')"/>
					<img class="icon-priority3" onmouseover="updatePriorityIcon('linkedTaskPriority-${linkedTask.taskId}', 3)"  onclick="updateLinkedTaskPriority(${linkedTask.taskId}, 3);" src="$link.setRelative('/resources/skin/default/image/spacer.gif')"/>
					<img class="icon-priority4" onmouseover="updatePriorityIcon('linkedTaskPriority-${linkedTask.taskId}', 4)"  onclick="updateLinkedTaskPriority(${linkedTask.taskId}, 4);" src="$link.setRelative('/resources/skin/default/image/spacer.gif')"/>
					<img class="icon-priority5" onmouseover="updatePriorityIcon('linkedTaskPriority-${linkedTask.taskId}', 5)"  onclick="updateLinkedTaskPriority(${linkedTask.taskId}, 5);" src="$link.setRelative('/resources/skin/default/image/spacer.gif')"/>
					<img class="icon-priority0" onmouseover="updatePriorityIcon('linkedTaskPriority-${linkedTask.taskId}', 0)"  onclick="updateLinkedTaskPriority(${linkedTask.taskId}, 0);" src="$link.setRelative('/resources/skin/default/image/spacer.gif')"/>
				</div>
			</td>
			<td class="text">
#if($linkedTask.tagList.length() > 0)
				<ul class="tagList">
#foreach($tag in $linkedTask.tagAsList)
					<li class="$tagMap.get($tag).tagTypeBean.styleClass">$tag</li>
#end
				</ul>
#end
				$utils.formatHtmlSimple($linkedTask.contents)
				<ul class="actionList">
					<li><a class="viewAction" href='$link.setRelative("/$linkedTask.taskId/")'>閲覧</a></li>
					<li><a class="unlinkAction" href="javascript:unlinkTask($task.taskId, ${linkedTask.taskId}, 'linkedTask-${linkedTask.taskId}')">リンク削除</a></li>
					<li><a class="deleteAction" href="javascript:deleteLinkedTask(${linkedTask.taskId}, 'linkedTask-${linkedTask.taskId}')">削除</a></li>
				</ul>
				<p class="note">ID: $linkedTask.taskId, 見積: $linkedTask.estimatedManHour, 作成日: $tools.formatDate($linkedTask.createDate)</p>
			</td>
			<td>$utils.formatDate($linkedTask.deadEndDate)</td>
			<td id="linkedTaskUpdateDate-${linkedTask.taskId}">$utils.formatTimestamp($linkedTask.updateDate)</td>
		</tr>
#end
		</table>
		<p>
			<a id="addLinkedTaskLink" class="ajax" href="javascript:openLinkedTaskForm()"/>関連タスク追加</a>
			<form id="LinkedTaskForm" onsubmit="return addLinkedTask()" style="display:none">
				<input id="parentTaskId" name="taskId" type="hidden" value="$task.taskId"/>
				<fieldset>
					<div>
					<label for="linkedTaskContents">タスク </label>
					<textarea id="linkedTaskContents" name="linkedTaskContents" class="text" rows="10"></textarea>
					</div>
					<div>					
					<label for="linkedTaskTagList">タグ</label>
					<input id="linkedTaskTagList" name="linkedTaskTagList" type="text" class="text" value="" />
					<ul id="linkedTaskTagSelecter" class="tagList">
#foreach($tag in $tagList)
#set ($tagId = $tag.tagId)
						<li id="linkedTaskTag${tagId}"><a href="javascript:updateTagList('linkedTaskTagList','linkedTaskTag${tagId}','$tag.name','$tag.tagTypeBean.styleClass')">$tag.name</a></li>
#end
					</ul>
					</div>
				</fieldset>
				<div class="action">
				<input type="submit" class="submit" value="登録"/>
				<input type="reset" class="cancel" value="キャンセル" onclick="closeLinkedTaskForm()"/>
				</div>
			</form>
		</p>
#end ## if($task)
	</div>
