<%@ Control Language="c#" %>
<%@ Register TagPrefix="ComponentArt" Namespace="ComponentArt.Web.UI" Assembly="ComponentArt.Web.UI" %>
<%@ Register TagPrefix="CS" Namespace="CommunityServer.Controls" Assembly="CommunityServer.Controls" %>
<%@ Register TagPrefix="CSD" Namespace="CommunityServer.Discussions.Controls" Assembly="CommunityServer.Discussions" %>
<%@ Import Namespace="CommunityServer.Components" %>
<%@ Import Namespace="CommunityServer.Controls" %>
<%@ Import Namespace="CommunityServer" %>

<script language="C#" runat="server">

protected override void OnLoad (EventArgs e) 
{
	base.OnLoad(e);

	CSContext context = CSContext.Current;
	User user;
	
	if (context.UserID > -1)
		user = Users.GetUser(context.UserID, false);
	else if (!Globals.IsNullorEmpty(Context.Request.QueryString["UserName"]))
		user = Users.FindUserByUsername(Context.Request.QueryString["UserName"]);
	else
		user = context.User;
		
	if (!context.User.IsAnonymous && user != null && user.UserID != -1)
	{
		FavoriteUserLink.UserID = user.UserID;
		FavoriteUserLink.FavoriteType = FavoriteType.User;
	}
	else
	{
		FavoriteUserLink.Visible = false;
		FavoriteLinkContainer.Visible = false;
	}
		
	if (!context.User.IsAnonymous && user != null && !user.IsAnonymous && Users.EnablePM(context.User)) 
    {
		PrivateMessageLink.NavigateUrl = Globals.GetSiteUrls().PrivateMessage(user.UserID); 
		PrivateMessageLink.Text = String.Format(CommunityServer.Components.ResourceManager.GetString("Profile_SendPrivateMessage"), user.DisplayName);
    }
    else
    {
		PrivateMessageLink.Visible = false;
	}
		
	if (user != null && !Globals.IsNullorEmpty(user.Profile.WebLog)) 
    {
		BlogLink.NavigateUrl = user.Profile.WebLog;
		BlogLink.Text = String.Format(ResourceManager.GetString("Profile_ViewUserBlog"), user.DisplayName);
    }
    else
    {
		BlogLink.Visible = false;
	}
	
	if (user != null && !Globals.IsNullorEmpty(user.Profile.WebAddress)) 
    {
		WebLink.NavigateUrl = user.Profile.WebAddress;
		WebLink.Text = String.Format(ResourceManager.GetString("Profile_ViewUserWebSite"), user.DisplayName);
    }
    else
    {
		WebLink.Visible = false;
	}
	
	if (user != null && !Globals.IsNullorEmpty(user.Profile.WebGallery)) 
    {
		GalleryLink.NavigateUrl = user.Profile.WebGallery;
		GalleryLink.Text = String.Format(ResourceManager.GetString("Profile_ViewUserGallery"), user.DisplayName);
    }
    else
    {
		GalleryLink.Visible = false;
	}
	
	if (user != null) 
    {
		SearchLink.NavigateUrl = Globals.GetSiteUrls().SearchByUser(user.UserID);
		SearchLink.Text = String.Format(ResourceManager.GetString("Profile_SearchUserPosts"), user.DisplayName);
    }
    else
    {
		SearchLink.Visible = false;
	}
}

</script>

<div class="CommonSidebarArea">
	<h4 class="CommonSidebarHeader"><cs:ResourceControl runat="server" ResourceName="Profile_Options_Title" /></h4>
	<div class="CommonSidebarContent">
		<ul class="CommonSidebarList">
			<CS:ListItemLink runat="server" id="PrivateMessageLink" Target="_blank" />
			<li runat="server" id="FavoriteLinkContainer"><CS:FavoriteLinkButton id="FavoriteUserLink" runat="server" /></li>
			<CS:ListItemLink runat="server" Target="_blank" id="WebLink" />
			<CS:ListItemLink runat="server" Target="_blank" id="BlogLink" />
			<CS:ListItemLink runat="server" Target="_blank" id="GalleryLink" />
			<CS:ListItemLink runat="server" Target="_blank" id="SearchLink" />
		</ul>
	</div>
</div>
		