<%
  import org.exoplatform.wiki.webui.UIWikiPortlet;  
%>
<h4 class="titleInfo"><%= _ctx.appRes("UIWikiVersionSelect.label.view-version") %></h4>
<div class="uiWikiVersionSelect" id="$uicomponent.id">
  <%
    String viewCurrentVersionLink = uicomponent.event(uicomponent.VIEW_CURRENT_VERSION);
    String compareLink = uicomponent.event(uicomponent.COMPARE_ACTION);
    String restoreLink = uicomponent.event(uicomponent.RESTORE_ACTION, uicomponent.versionName);
    String viewHistoryLink = uicomponent.event(uicomponent.SHOW_HISTORY);
    String previousVersionsLink = uicomponent.isHasPreviousVersion() ? uicomponent.event(uicomponent.PREVIOUS_VERSION) : null;
    String nextVersionsLink = uicomponent.hasNextVersion() ? uicomponent.event(uicomponent.NEXT_VERSION) : null;
    String currentVersion = _ctx.appRes("UIWikiVersionSelect.label.Vesion").replace("{0}", uicomponent.versionName);
    String prevVersionNumber = "";
    if ( uicomponent.isHasPreviousVersion()) {
      prevVersionNumber = (--Integer.valueOf(uicomponent.versionName)).toString();
    }
    String nextVersionNumber = (++Integer.valueOf(uicomponent.versionName)).toString();
      
    String prevVersionLinkId = UIWikiPortlet.WIKI_PORTLET_ACTION_PREFIX + uicomponent.VIEW_REVISION + "/" + prevVersionNumber;
    String nextVersionNumberLinkId = UIWikiPortlet.WIKI_PORTLET_ACTION_PREFIX + uicomponent.VIEW_REVISION + "/" + nextVersionNumber;
    String viewHistoryLinkId = UIWikiPortlet.WIKI_PORTLET_ACTION_PREFIX + uicomponent.SHOW_HISTORY;
    String compareLinkId = UIWikiPortlet.WIKI_PORTLET_ACTION_PREFIX + uicomponent.COMPARE_ACTION;
  %>
  <div class="decorationVersion well">
    
        <% if(uicomponent.hasNextVersion()) { %>
          <div><span><%= _ctx.appRes("UIWikiVersionSelect.label.viewing-old-version-info"); %></span>
		  <a href="javascript:eXo.wiki.UIWikiAjaxRequest.makeNewHash('#');"><strong><%= _ctx.appRes("UIWikiVersionSelect.label.CurrentVersion"); %></strong></a></div>
        <% } else { %>
          <div><%= _ctx.appRes("UIWikiVersionSelect.label.viewing-current-version-info"); %></div>
        <% } %>
  
		<div class="actionLink">
		  <% if(uicomponent.hasNextVersion()) { %>
		    <a href="javascript:eXo.wiki.UIWikiAjaxRequest.makeNewHash('#$uicomponent.COMPARE_ACTION');" ><%= _ctx.appRes("UIWikiVersionSelect.label.CompareWithCurrent"); %></a>&nbsp;|&nbsp;
			<% if (uicomponent.renderRestoreRevisionActions()) { %>
			  &nbsp;|&nbsp;
			<% } %>
		  <% } %>
		  <a id="$compareLinkId" onclick="$compareLink" style="display:none"></a>
		  <a href="javascript:eXo.wiki.UIWikiAjaxRequest.makeNewHash('#$uicomponent.SHOW_HISTORY');" ><%= _ctx.appRes("UIWikiVersionSelect.label.ViewPageHistory"); %></a>
		  <a id="$viewHistoryLinkId" onclick="$viewHistoryLink" style="display:none"></a>
		</div>
	</div>
	<div class="breadcum">
	  <% if(previousVersionsLink != null) { %>
        <a class="btn" href="javascript:eXo.wiki.UIWikiAjaxRequest.makeNewHash('#$uicomponent.VIEW_REVISION/$prevVersionNumber');" ><%= _ctx.appRes("UIWikiVersionSelect.label.Previous"); %></a>
        <a  id="$prevVersionLinkId" onclick="$previousVersionsLink"></a>
      <% } %>
      
	  <span class="Label"><%= "&nbsp;&nbsp;" +  currentVersion + "&nbsp;&nbsp;" %></span> 
	  
	  <% if(uicomponent.hasNextVersion()) { %>
	    <a class="btn" href="javascript:eXo.wiki.UIWikiAjaxRequest.makeNewHash('#$uicomponent.VIEW_REVISION/$nextVersionNumber');" ><%= _ctx.appRes("UIWikiVersionSelect.label.Next"); %></a>
	    <a id="$nextVersionNumberLinkId" onclick="$nextVersionsLink"></a>
	  <% } %>
	</div>
	<hr/>
</div>