<%	
	import org.exoplatform.services.organization.User ;
	import org.exoplatform.faq.webui.FAQUtils;
	import org.exoplatform.ks.common.user.CommonContact;
%>
<div class="UIViewUserProfile $uicomponent.id">
<% uiform.begin() %>
<%	
	User user = uiform.getUser() ;
	String userName = user.getUserName() ;
	CommonContact contact = uiform.getContact(userName) ;
	java.text.SimpleDateFormat dateFormatter = new java.text.SimpleDateFormat(", hh:mm a");
  String      createdDate  = FAQUtils.getLongDateFormat(user.getCreatedDate());
  String      fullName     = contact.getFullName();
  String      birthDay     = contact.getBirthday();
  String      location     = contact.getCity();
  String      firstName    = contact.getFirstName();
  String      lastName     = contact.getLastName();
  String      email        = contact.getEmailAddress();
  String      gender       = contact.getGender();
  String      jobTitle     = contact.getJob();
  String      workPhone    = contact.getWorkPhone();
  String      homePhone    = contact.getHomePhone();
  String      siteOfUser   = contact.getWebSite();
  boolean     isCity       = false;
	if(!FAQUtils.isFieldEmpty(contact.getCity())) {isCity = true; location = contact.getCity();}
	if(!FAQUtils.isFieldEmpty(contact.getCountry())) {
		if(isCity) location = location + ", ";
		location = location + contact.getCountry() ;
	}
	if(FAQUtils.isFieldEmpty(fullName)){
	  fullName = firstName + " " + lastName;
	}
%>
	<div class="ViewUserProfileContainer">
		<div class="TitleBar">
			<div class="TitleIcon">
				<%=_ctx.appRes("UIViewUserProfile.label.ViewUserProfileOf");%>: <span class="UserLabel " >$fullName</span>
			</div>
		</div>
		<div class="ViewContainer">
			<table class="TablePost" cellspacing="0" border="0" cellpadding="0">
				<tbody>
					<tr>
						<td class="UserContainer">
							<div class="UserContent">
								<img src="<%=uiform.getAvatarUrl(userName);%>" class="ImgAvatarBorder" alt="<%=_ctx.appRes("UISettingForm.label.Avatar")%>"/>
								<div class="Rank">$fullName</div>
								<div class="InfoUser">
									<div><%=_ctx.appRes("UIViewUserProfile.label.JoinDate");%>: $createdDate</div>
									<div><%=_ctx.appRes("UIViewUserProfile.label.LastLoginTime");%>: <%=FAQUtils.getLongDateFormat(user.getLastLoginTime()) + dateFormatter.format(user.getLastLoginTime());%> </div>
								</div>
							</div>
						</td>
						<td class="ProfileContainer">
							<table class="TablePost" cellspacing="0" border="0" cellpadding="0">
								<tbody>
								<% 
									if(!FAQUtils.isFieldEmpty(email)) {
									  email = "<a href=\"mailto:"+email+"\">"+email+"</a>" ;
									}
									if (!FAQUtils.isFieldEmpty(siteOfUser)) {
                    String []websites = FAQUtils.splitForFAQ(siteOfUser) ;
                    siteOfUser = "";
                    for (int i = 0; i < websites.length; ++i) {
                      siteOfUser += "<a href=\"" + websites[i] +"\" onclick=\"window.open(this.href); return false;\">"+ websites[i] +"</a> " ;
                    }
                  }
									String []labels = uiform.getLabelProfile();	
									String []contents = [userName, firstName, lastName, birthDay, gender, email,
										jobTitle, location, workPhone, homePhone, siteOfUser]; 
									int i = 0 ;
									for(label in labels) {
										String content = "";
										content = contents[i];
										if(content == null) content = "";
										++i ;
								%>
									<tr>
										<td class="Label">$label:</td>
										<td class="LabelProfile"><span>$content</span></td>
									</tr>
								<%} %>
								</tbody>
							</table>
						</td>
					</tr>
				</tbody>
			</table>
		</div>
	</div>
	
	<div class="UIAction">
      <a href="javascript:void(0);" onclick="<%=uicomponent.event("Close");%>" class="ActionButton LightBlueStyle"><%=_ctx.appRes("UIAnswersPortlet.action.Close");%></a>
    </div>
<%uiform.end()%>
</div>
