<%
  import org.exoplatform.wiki.webui.UIWikiPortlet;  
%>

<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.isHasNextVersion() ? 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">
        <% if(uicomponent.isHasNextVersion()) { %>
          <span class="Label"><%= _ctx.appRes("UIWikiVersionSelect.label.viewing-old-version-info"); %></span>
		  <a href="javascript:eXo.wiki.UIWikiAjaxRequest.makeNewHash('#');" class="Title"><%= _ctx.appRes("UIWikiVersionSelect.label.CurrentVersion"); %></a>
        <% } else { %>
          <span class="Label"><%= _ctx.appRes("UIWikiVersionSelect.label.viewing-current-version-info"); %></span>
        <% } %>
  
		<div class="ActionLink">
		  <% if(uicomponent.isHasNextVersion()) { %>
		    <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="BCBT" 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.isHasNextVersion()) { %>
	    <a class="BCBT" href="javascript:eXo.wiki.UIWikiAjaxRequest.makeNewHash('#$uicomponent.VIEW_REVISION/$nextVersionNumber');"><%= _ctx.appRes("UIWikiVersionSelect.label.Next"); %></a>
	    <a id="$nextVersionNumberLinkId" onclick="$nextVersionsLink"></a>
	  <% } %>
	</div>
</div>