<?php get_header();

if(isset($_GET['author_name'])) :
$curauth = get_userdatabylogin($author_name);
get_userdatabylogin(get_the_author_login());
(get_the_author_login());
else :
$curauth = get_userdata(intval($author));
endif;

global $current_user; get_currentuserinfo();

?>

<h1 class="page-title"><?php echo $curauth->user_identity; ?>'<?php _e('s', 'gp_lang'); ?> <?php _e('Profile', 'gp_lang'); ?></h1>

<div id="content">
	
	<div class="profile-avatar">

		<?php echo get_avatar($curauth->ID, '60'); ?>
			
		<div class="edit-profile-link"><?php if($curauth->ID == $user_ID) { ?><a href="#edit-profile" rel="prettyPhoto"><?php _e('Edit Profile', 'gp_lang'); ?></a><?php } else { ?>&nbsp;<?php } ?></div>

		<div id="edit-profile" class="hidden">
			<?php include('edit-profile.php'); ?>			
		</div>
	
	</div>
	
	<div class="profile-details">
	
		<p><strong><?php _e('Member Since', 'gp_lang'); ?>:</strong> <?php echo date_i18n(get_option('date_format'), strtotime($curauth->user_registered)); ?></p>
		
		<?php if($curauth->user_url != "" && $curauth->user_url != "http://") { ?><p><strong><?php _e('Website', 'gp_lang'); ?>:</strong> <a href="<?php echo $curauth->user_url; ?>"><?php echo $curauth->user_url; ?></a></p><?php } ?>

		<?php if($curauth->aim != "") { ?><p><strong><?php _e('AIM', 'gp_lang'); ?>:</strong> <?php echo $curauth->aim; ?></p><?php } ?>
		
		<?php if($curauth->yim != "") { ?><p><strong><?php _e('Yahoo', 'gp_lang'); ?>:</strong> <?php echo $curauth->yim; ?></p><?php } ?>

		<?php if($curauth->jabber_google != "") { ?><p><strong><?php _e('Jabber / Google Talk', 'gp_lang'); ?>:</strong> <?php echo $curauth->jabber_google; ?></p><?php } ?>
		
		<?php if($curauth->user_description) { ?><p><strong><?php _e('Bio', 'gp_lang'); ?>:</strong> <?php echo $curauth->user_description; ?></p><?php } ?>

	</div>
			
	<!--Begin Following-->
	<?php if($curauth->ID == $user_ID) { ?>
	
		<div class="profile-box items-following">
		
			<h3><?php _e('Items You Follow', 'gp_lang'); ?></h3>
						
			<div class="profile-content">

				<?php $favorite_post_ids = wpfp_get_users_favorites();
				if($favorite_post_ids) { ?>
				
						<?php foreach ($favorite_post_ids as $o) : $p = get_post($o); if ($p->post_status == 'publish') { ?>	
						
							<div class="profile-item">
			
								<!--Begin Image-->
								<?php if(has_post_thumbnail($o)) { ?>					
									<div class="post-thumbnail">
										<a href="<?php get_permalink($o); ?>" title="<?php echo $p->post_title; ?>">
											<?php $image = vt_resize(get_post_thumbnail_id($o), '', 50, 0, true); ?>
											<img src="<?php echo $image[url]; ?>" width="<?php echo $image[width]; ?>" height="<?php echo $image[height]; ?>" alt="<?php if(get_post_meta(get_post_thumbnail_id($o), '_wp_attachment_image_alt', true)) { echo get_post_meta(get_post_thumbnail_id($o), '_wp_attachment_image_alt', true); } else { echo $p->post_title; } ?>" />		
										</a>				
									</div>					
								<?php } ?>
								<!--End Image-->
	
								<a href="<?php echo get_permalink($o); ?>" title="<?php echo $p->post_title; ?>"><?php echo $p->post_title; ?></a>
							
							</div>
							
						<?php } endforeach; ?>
		
				<?php } else { ?>
				
					<div class="profile-item">
						<strong><?php _e('You are not currently following any items.', 'gp_lang'); ?></strong>
					</div>
				
				<?php } ?>
			
			</div>
				
		</div>
				
	<?php } ?>
	<!--End Following-->

	<!--Begin Recent Posts-->
	<?php query_posts('post_type=any&author='.$curauth->ID.'&showposts=10'); if (have_posts()) : ?>
	
		<div class="profile-box recent-posts">
		
			<h3><?php _e('Recent Posts', 'gp_lang'); ?></h3>
			
			<div class="profile-content">
			
				<?php while (have_posts()) : the_post(); ?>
					
					<div class="profile-item">
						<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
						<div class="post-meta"><?php the_time(get_option('date_format')); ?></div>
					</div>
					
				<?php endwhile; ?>
			
			</div>
			
		</div>
				
	<?php endif; wp_reset_query(); ?>
	<!--End Recent Posts-->
	
	<!--Begin Recent Comments-->			
	<?php
	$thisauthor = get_userdata(intval($author));
	$querystr = "SELECT comment_ID, comment_post_ID, post_title, comment_content
	FROM $wpdb->comments, $wpdb->posts
	WHERE user_id = $thisauthor->ID
	AND comment_post_id = ID
	AND comment_approved = 1
	ORDER BY comment_ID DESC
	LIMIT 10";
	$comments_array = $wpdb->get_results($querystr, OBJECT); if ($comments_array): ?>

		<div class="profile-box recent-comments">
	
			<h3><?php _e('Recent Comments', 'gp_lang'); ?></h3>
	
			<div class="profile-content">

				<?php foreach ($comments_array as $comment):setup_postdata($comment); ?>
				
					<div class="profile-item">
						<a href="<?php echo get_permalink($comment->comment_post_ID); ?>" title="<?php echo $comment->post_title; ?>"><?php comment_excerpt($comment->comment_ID); ?></a>
						<div class="post-meta"><?php echo $comment->post_title; ?></div>
					</div>
					
				<?php endforeach; ?>
			
			</div>
			
		</div>
	
	<?php endif; ?>
	<!--End Recent Comments-->
	
</div>

<?php get_sidebar(); ?>

<?php get_footer(); ?>