 <%@ page import="zall.bean.*" %>
 <%@ page import="java.text.SimpleDateFormat" %>
 <%
 Media media = (Media)request.getAttribute("media");
 User user = (User)session.getAttribute("user");
 %>
	<script type="text/javascript">
        jQuery(document).ready(function(){
        	
            jQuery("#modmedia_editbutton").click(function(){
            	jQuery(".modmedia_const").hide();
            	jQuery(".modmedia_edit").show();
            });
            
            jQuery("#modmedia_savebutton").click(function(){
            	jQuery("#modmedia_form").submit();
            });
        });
	</script>
 	
 	
   <DIV id="main">     
        <DIV id="container"> 
            <DIV id="content"> 
                <DIV class="hentry p1 post publish author-admin category-blogs category-companies tag-blue tag-brown comments-open pings-closed"> 
                    <TABLE id="edit-row" width="100%" border="0"><TR>
	                    <TD>
	                    	<button type="button" onClick="window.location='gallery?folder=<%=media.getFolder().getId()%>'"><img src="img/arrow_undo.png" style="width: 10px; padding-right: 5px;">...Back</button>
	                    </TD><TD>
	                    <%if( user.canEdit( media ) ){ %>
	                    	<form action="gallery?folder=<%=media.getFolder().getId() %>" method="post" align="right">                          
	                    		<input type="hidden" name="id" value="<%=media.getId() %>">
	                    		<input type="hidden" name="type" value="<%=media.getType() %>">
	                    		<button class="modmedia_edit" id="modmedia_savebutton" type="button"><img src="img/disk-black.png" style="width: 10px; padding-right: 5px;">Save</button>
	                    		<button class="modmedia_const" id="modmedia_editbutton" type="button"><img src="img/pencil.png" style="width: 10px; padding-right: 5px;">Edit</button>
	                    		<button class="modmedia_const" type="submit" name="action" value="rmmedia" onClick="return confirm ('Are you sure you want to delete this item?');"><img src="img/delete.png" style="width: 10px; padding-right: 5px;">Delete</button>
	                    	</form>	                    
	                    <%} %>
	                    </TD>
                    </TR></TABLE>
                    <DIV class="entry-content">
                    	<!-- 
                        <div id="post-ratings" class="post-ratings">
                            <img id="rating_1" src="img/rating_on.png" alt="1 Star " title="1 Star" >
                            <img id="rating_2" src="img/rating_on.png" alt="2 Stars" title="2 Stars" >
                            <img id="rating_3" src="img/rating_on.png" alt="3 Stars" title="3 Stars" >
                            <img id="rating_4" src="img/rating_on.png" alt="4 Stars" title="4 Stars" >
                            <img id="rating_5" src="img/rating_off.png" alt="5 Stars" title="5 Stars" >
                        </div>
                        
                        <div id="post-ratings-loading" class="post-ratings-loading">
                            <img src="img/loading.gif" width="16" height="16" alt="Loading ..." title="Loading ..." class="post-ratings-image">
                            &nbsp;Loading ...
                        </div>
                        -->
                        <form id="modmedia_form" action="#" method="post">                          
	                    	<input type="hidden" name="id" value="<%=media.getId() %>">
	                    	<input type="hidden" name="type" value="<%=media.getType() %>">
	                    	<input type="hidden" name="action" value="modmedia">
	                        <H1>
	                        	<SPAN class="modmedia_const"><%=media.getTitle() %></SPAN>
	                        	<SPAN class="modmedia_edit"><INPUT type="text" name="title" value="<%=media.getTitle() %>" style="width: 90%; height:30px;"></SPAN>
	                        </H1> 
	                        <P>
	                        	<SPAN class="modmedia_const">
	                        		<%=(media.getDescription()==null || media.getDescription().isEmpty() ? "&nbsp;No description available" : media.getDescription() )%>
	                        	</SPAN>
	                        	<SPAN class="modmedia_edit" width="50"><TEXTAREA name="description" style="width: 90%;"><%=(media.getDescription()==null ? "" : media.getDescription()) %></TEXTAREA></SPAN>
	                        </P>
                        </FORM>
                        <UL class="meta"> 
                            <LI class="designer"> Uploaded by: <%=media.getUser().getName() %></LI>				  					  
                            <LI class="site-link"> <A rel="source" href="<%=request.getRequestURL() %>?type=<%=media.getType() %>&id=<%=media.getId() %>"><%=request.getRequestURL() %>?type=<%=media.getType() %>&id=<%=media.getId() %></A></LI> 
                            <%if( media instanceof Image){ %> <LI class="slideshow-link"> <A rel="source" href="slideshow?id=<%=media.getId() %>">Slideshow</A> </LI> <%} %>
                            <LI align="right"> <button onClick="window.location='content?type=<%=media.getType() %>&id=<%=media.getId()%>&download'">Download</button> </LI>
                        </UL> 
                        <!-- 
                        <DIV id="nav-below" class="navigation"> 
                            <DIV class="nav-previous"><A href="" rel="prev"><SPAN class="meta-nav">&laquo;</SPAN>Back</A></DIV> 
                            <DIV class="nav-next"><A href="" rel="next">Next<SPAN class="meta-nav">&raquo;</SPAN></A></DIV> 
                        </DIV> 
                         -->
                    </DIV> 
                </DIV><!-- .post -->
     
                <DIV class="artwork-container"> 
                    <DIV class="entry-artwork">
                    	<%if( media instanceof Video ){ %>
                    		<jsp:include page="media_video.jsp" flush="false" />  
                    	<%} else{ %>
                        <A href="content?id=<%=media.getId()%>&size=large" rel="zoom">
                            <IMG src="content?id=<%=media.getId()%>&size=medium" alt="<%=media.getTitle()%>" width="500" > <!-- height="375" -->
                        </A>
                        <%} %>
                    </DIV> 
                </DIV> 
                
                
                <DIV id="comments">    
                    <DIV id="comments-list" class="comments"> 
                        <H3><SPAN><%=media.getComments().size() %></SPAN> Comments</H3>				
                        <OL>
                        	<% 
                        	SimpleDateFormat formatter = new SimpleDateFormat("HH:mm - d MMMMM yyyy ");
                        	for( Comment cm : media.getComments() ){ %>
                            <LI class="comment"> 
                                <DIV class="comment-author vcard">
                                    <IMG alt="" src="img/default-user.png" class="photo avatar avatar-80 photo" height="80" width="80"> 
                                    <SPAN class="fn n"><%=cm.getUser().getName() %></SPAN>
                                </DIV> 
                                <DIV class="comment-meta">Posted: <%=formatter.format(cm.getDate()) %></DIV> 
                                <DIV class="comment-content"> 
                                    <P><%=cm.getMessage() %></P> 
                                </DIV> 
                            </LI>
                            <% } %>
                            <!-- 
                            <LI class="comment"> 
                                <DIV class="comment-author vcard">
                                    <IMG alt="" src="img/default-user.png" class="photo avatar avatar-80 photo" height="80" width="80"> 
                                    <span class="fn n">Daniel</span>
                                </DIV>              
                                <DIV class="comment-meta">Posted August 17, 2009 at 5:32 pm</DIV> 
                                <DIV class="comment-content"> 
                                    <P>Hi man,<BR> 
                                    I love this template, but one question - how do you create the image gallery on it?</P> 
                                </DIV> 
                            </LI> 
                             -->
                        </OL>  
                        <DIV id="comments-nav-below" class="comment-navigation"> 
                             <DIV class="paginated-comments-links"></DIV> 
                        </DIV>                        
                    </DIV><!-- #comments-list .comments --> 
     

                    <DIV id="respond"> 
                        <H3>Post a Comment</H3>     				
                        <DIV id="cancel-comment-reply"><A rel="nofollow" id="cancel-comment-reply-link" href="http://www.upthemes.com/demo/gallery/?p=898#respond" style="display:none;">Click here to cancel reply.</A></DIV> 
                        <DIV class="formcontainer">
                            <FORM id="commentform" method="post">
                            	<INPUT type="hidden" name="action" value="comment">
                                <INPUT type="hidden" name="id" value="<%=media.getId() %>">
                                <INPUT type="hidden" name="type" value="<%=media.getType() %>">
                                <P id="comment-notes">HTML is not allowed, Use BBCode instead.</P> 
     							<!--  
                                <DIV id="form-section-author" class="form-section"> 
                                    <DIV class="form-label"><LABEL for="author">Name</LABEL> <SPAN class="required">*</SPAN></DIV> 
                                    <DIV class="form-input"><INPUT id="author" name="author" type="text" value="" size="30" maxlength="20" tabindex="3"></DIV> 
                                </DIV>
     
                                <DIV id="form-section-email" class="form-section"> 
                                    <DIV class="form-label"><LABEL for="email">Email</LABEL> <SPAN class="required">*</SPAN></DIV> 
                                    <DIV class="form-input"><INPUT id="email" name="email" type="text" value="" size="30" maxlength="50" tabindex="4"></DIV> 
                                </DIV>
     
                                <DIV id="form-section-url" class="form-section"> 
                                    <DIV class="form-label"><LABEL for="url">Website</LABEL></DIV> 
                                    <DIV class="form-input"><INPUT id="url" name="url" type="text" value="" size="30" maxlength="50" tabindex="5"></DIV> 
                                </DIV>
     							-->
                                <DIV id="form-section-comment" class="form-section"> 
                                    <DIV class="form-label"><LABEL for="comment">Comment</LABEL></DIV> 
                                    <DIV class="form-textarea">
                                        <TEXTAREA id="comment" name="msg" cols="45" rows="8" tabindex="6"></TEXTAREA>
                                    </DIV> 
                                </DIV><!-- #form-section-comment .form-section -->                             
                                <DIV id="form-allowed-tags" class="form-section"></DIV> 							                                   
                                <INPUT id="submit" name="submit" type="submit" value="Post Comment" tabindex="7">
                            </FORM><!-- #commentform --> 
                        </DIV><!-- .formcontainer --> 
                    </DIV><!-- #respond --> 
                </DIV><!-- #comments --> 
            </DIV><!-- #content --> 
        </DIV><!-- #container --> 
    </DIV><!-- #main -->