<%
  import org.exoplatform.ecm.webui.utils.Utils;
  import org.exoplatform.services.jcr.RepositoryService;
  
  def personalDrives = uicomponent.personalDrives();
  def groupDrives = uicomponent.groupDrives();
  def mainDrives = uicomponent.mainDrives();
  RepositoryService rService = uicomponent.getApplicationComponent(RepositoryService.class) ;
  String repository = rService.getCurrentRepository().getConfiguration().getName() ;    
%>
<div id="$uicomponent.id" class="UIDrivesArea">
	<div class="UIDriversAreaContainer">
    <% if (uicomponent.isFirstVisit()) {
        uicomponent.setFirstVisit(false); 
     %>
        <div class="Info" style="padding-left: 25px;font-size:12px">
          <%= _ctx.appRes("UIDrivesArea.DrivesArea.allDrives") %>
          &nbsp;<img src="/ecmexplorer/skin/webui/component/explorer/sidebar/DefaultSkin/background/DriversButton.gif" />
        </div>
    <% } %>
	  <%if(mainDrives.size() > 0) {%>
			<div class="RowDrives">
				<div class="IconArrowDrives TextTitleDriver"><%=_ctx.appRes("UIDrivesBrowser.title.GeneralDrives" )%></div>
				<%
				  for(drive in mainDrives) {
    				println("<div class=\"Drive\">");
    				if(drive.getIcon() != null && drive.getIcon().length() > 0) {
  	          String[] mainIconPath = drive.getIcon().split(":/") ;
  	    %>
  	          <div class="DriveIcon" onclick="<%=uicomponent.event("SelectDrive","${drive.name}")%>">
    	          <img src="/${uicomponent.getPortalName()}/${uicomponent.getRestName()}/jcr/${repository}/${mainIconPath[0]}/${mainIconPath[1]}" width="27" height="27" onclick="<%=uicomponent.event("SelectDrive","${drive.name}")%>"/>
    	        </div>
		          <a class="DriveLabel" href="<%=uicomponent.event("SelectDrive", Utils.formatNodeName(drive.getName()))%>"><%=uicomponent.getLabel(drive.getName())%></a>
				<%
				    } else {
				%>
				      <div class="IconDrivesDefault IconDrives${drive.workspace} DriveIcon" onclick="<%=uicomponent.event("SelectDrive","${drive.name}")%>"><span></span></div>
 				      <a class="DriveLabel" href="<%=uicomponent.event("SelectDrive", Utils.formatNodeName(drive.getName()))%>"><%=uicomponent.getLabel(drive.getName())%></a>
				<%      
				    }
				    println("</div>");
				  }
				%>
	      <div class="ClearLeft"><span></span></div>
			</div>
		<%}%>
		<%if(groupDrives.size() > 0) {%>
			<div class="RowDrives">
				<div class="IconArrowDrives TextTitleDriver"><%=_ctx.appRes("UIDrivesBrowser.title.GroupDrives" )%></div>
	        <%
	          for(groupDrive in groupDrives) {
	            println("<div class=\"Drive\">");
	  	        if(groupDrive.getIcon() != null && groupDrive.getIcon().length() > 0) {
		  		      String[] groupIconPath = groupDrive.getIcon().split(":/") ;
		      %>
			        <div class="Icon" onclick="<%=uicomponent.event("SelectDrive","${groupDrive.name}")%>">
			        	<img src="/${uicomponent.getPortalName()}/rest/jcr/${repository}/${groupIconPath[0]}/${groupIconPath[1]}" width="48" height="41" />			                				                  
			        </div>
	        <%  } else {  %>
				        <div class="IconDrivesUse DriveIcon" onclick="<%=uicomponent.event("SelectDrive","${groupDrive.name}")%>"><span></span></div>
	  			      <a class="DriveLabel" href="<%=uicomponent.event("SelectDrive","${groupDrive.name}")%>"><%=uicomponent.getGroupLabel(groupDrive.getName())%></a>
		      <%
		          }
		          println("</div>");
		        }
		      %>
	      <div class="ClearLeft"><span></span></div>
			</div>
		<%}%>	
		<%if(personalDrives.size() > 0) {%>
			<div class="RowNormal">
				<div class="IconArrowDrives TextTitleDriver"><%=_ctx.appRes("UIDrivesBrowser.title.PersonalDrives" )%></div>
        <%
          for(drive in personalDrives) {
	          println("<div class=\"Drive\">");
	          if(drive.getIcon() != null && drive.getIcon().length() > 0) {
	            String[] personalIconPath = drive.getIcon().split(":/") ;
	      %>
			        <div class="DriveIcon" onclick="<%=uicomponent.event("SelectDrive","${drive.name}")%>">
			        	<img src="/${uicomponent.getPortalName()}/rest/jcr/${repository}/${personalIconPath[0]}/${personalIconPath[1]}" alt="" width="48" height="41" />			                				                			                  
			        </div>
	      <%  } else { %>
	            <div class="IconDrives${drive.name} DriveIcon" onclick="<%=uicomponent.event("SelectDrive","${drive.name}")%>"><span></span></div>
  	          <a class="DriveLabel" href="<%=uicomponent.event("SelectDrive","${drive.name}")%>"><%=uicomponent.getLabel(drive.getName())%></a>
        <%
            }
            println("</div>");
          }
        %>
	      <div class="ClearLeft"><span></span></div>
			</div>  
		<%}%>
	</div>
</div>