<?php
/*
Template Name: My Profile
*/
?>

<?php if (is_user_logged_in()) { ?>

<?php get_header(); ?>

	<?php if (have_posts()) : ?>
	<?php while (have_posts()) : the_post(); ?>
	<?php dt_breadcrumb(); ?>
	
	<div class="maincol">
	
		<!--
		#	header
		-->
		<div class="archiveheader">
			<h1><?php the_author_meta('display_name', $current_user->ID); ?></h1>
			<p><?php _e('This is your personal profile page. You can view or update your profile information.','news'); ?></p>
		</div>
	
		<div class="profileview">
		
			<div class="user_image">
			<?php echo get_avatar(get_the_author_meta('user_email', $current_user->ID), $size = '80'); ?>
			<p><?php _e('This is your image as it will appear to other users. To create or update your personal image you have to create an account at <a href="http://gravatar.com/">Gravatar</a>.','news'); ?></p>
			<div class="clear"></div>
			</div>
			
			<span class="new_section"><?php _e('View/edit account information','news'); ?></span>
			
			<div class="edit_section">
				<span class="edit_label"><?php _e('Your Username','news'); ?></span>
				<span class="edit_field"><?php the_author_meta('user_login', $current_user->ID); ?></span>
				<span class="edit_text"></span>
				<span class="edit_result"></span>
				<div class="clear"></div>
			</div>
			<div class="edit_section">
				<span class="edit_label"><?php _e('Your e-mail address','news'); ?></span>
				<span class="edit_field"><?php the_author_meta('user_email', $current_user->ID); ?></span>
				<span class="edit_text"><a href="#edit" id="user_email"><?php _e('Edit','news'); ?></a></span>
				<span class="edit_result"></span>
				<div class="clear"></div>
			</div>
			<div class="edit_section">
				<span class="edit_label"><?php _e('Your Password','news'); ?></span>
				<span class="edit_field"></span>
				<span class="edit_text"><a href="#edit" id="user_pass"><?php _e('Edit','news'); ?></a></span>
				<span class="edit_result"></span>
				<div class="clear"></div>
			</div>
			
			<span class="new_section"><?php _e('View/edit profile information','news'); ?></span>
			
			<div class="edit_section">
				<span class="edit_label"><?php _e('Display name publicly as','news'); ?></span>
				<span class="edit_field"><?php the_author_meta('display_name', $current_user->ID); ?></span>
				<span class="edit_text"><a href="#edit" id="display_name"><?php _e('Edit','news'); ?></a></span>
				<span class="edit_result"></span>
				<div class="clear"></div>
			</div>
			<div class="edit_section">
				<span class="edit_label"><?php _e('First Name','news'); ?></span>
				<span class="edit_field"><?php the_author_meta('first_name', $current_user->ID); ?></span>
				<span class="edit_text"><a href="#edit" id="first_name"><?php _e('Edit','news'); ?></a></span>
				<span class="edit_result"></span>
				<div class="clear"></div>
			</div>
			<div class="edit_section">
				<span class="edit_label"><?php _e('Last Name','news'); ?></span>
				<span class="edit_field"><?php the_author_meta('last_name', $current_user->ID); ?></span>
				<span class="edit_text"><a href="#edit" id="last_name"><?php _e('Edit','news'); ?></a></span>
				<span class="edit_result"></span>
				<div class="clear"></div>
			</div>
			<div class="edit_section">
				<span class="edit_label"><?php _e('Nickname','news'); ?></span>
				<span class="edit_field"><?php the_author_meta('nickname', $current_user->ID); ?></span>
				<span class="edit_text"><a href="#edit" id="nickname"><?php _e('Edit','news'); ?></a></span>
				<span class="edit_result"></span>
				<div class="clear"></div>
			</div>
			
			<span class="new_section"><?php _e('View/edit contact information','news'); ?></span>
			
			<div class="edit_section">
				<span class="edit_label"><?php _e('Your Website','news'); ?></span>
				<span class="edit_field"><?php the_author_meta('user_url', $current_user->ID); ?></span>
				<span class="edit_text"><a href="#edit" id="user_url"><?php _e('Edit','news'); ?></a></span>
				<span class="edit_result"></span>
				<div class="clear"></div>
			</div>
			<div class="edit_section">
				<span class="edit_label"><?php _e('AOL','news'); ?></span>
				<span class="edit_field"><?php the_author_meta('aim', $current_user->ID); ?></span>
				<span class="edit_text"><a href="#edit" id="aim"><?php _e('Edit','news'); ?></a></span>
				<span class="edit_result"></span>
				<div class="clear"></div>
			</div>
			<div class="edit_section">
				<span class="edit_label"><?php _e('Yahoo IM','news'); ?></span>
				<span class="edit_field"><?php the_author_meta('yim', $current_user->ID); ?></span>
				<span class="edit_text"><a href="#edit" id="yim"><?php _e('Edit','news'); ?></a></span>
				<span class="edit_result"></span>
				<div class="clear"></div>
			</div>
			<div class="edit_section">
				<span class="edit_label"><?php _e('Google Talk','news'); ?></span>
				<span class="edit_field"><?php the_author_meta('jabber', $current_user->ID); ?></span>
				<span class="edit_text"><a href="#edit" id="jabber"><?php _e('Edit','news'); ?></a></span>
				<span class="edit_result"></span>
				<div class="clear"></div>
			</div>
			
			<span class="new_section"><?php _e('View/edit biographical info','news'); ?></span>

			<div class="edit_section">
				<span class="edit_field2"><?php the_author_meta('description', $current_user->ID); ?></span>
				<span class="edit_text2"><a href="#edit" id="description"><?php _e('Edit','news'); ?></a></span>
				<span class="edit_result"></span>
				<div class="clear"></div>
			</div>

		</div>

	</div>
	
	<?php get_sidebar(); ?><div class="clear"></div>
	
	<?php endwhile; ?>
	<?php else : ?>
	<?php endif; ?>
	
<script type="text/javascript">
(function($) {

	$(".edit_text a").click(function(){
		var field_value = $(this).parent().prev('span').text(); // default
		var input_value = $(this).parent().prev('span').children().val(); // modified
		if ($(this).text() == '<?php _e('Edit','news'); ?>') {
			$(this).text('<?php _e('Save','news'); ?>');
			$(this).parent().prev('span').html('<input type="text" value="' + field_value + '" />');
			$(this).parent().prev('span').children().focus();
		} else {
			$(this).text('<?php _e('Edit','news'); ?>');
			$(this).parent().prev('span').text(input_value);
			// change the User data
			var datatype = $(this).attr('id');
			$(this).parent().next('span').html('<img src="<?php bloginfo('template_directory'); ?>/images/loading2.gif" alt="" />');
			$(this).parent().next('span').load('<?php bloginfo('template_directory'); ?>/ModifyData.php?' + datatype + '=' + encodeURI(input_value));
		}
	});
	
	$(".edit_text2 a").click(function(){
		var field_value = $(this).parent().prev('span').text(); // default
		var input_value = $(this).parent().prev('span').children().val(); // modified
		if ($(this).text() == '<?php _e('Edit','news'); ?>') {
			$(this).text('<?php _e('Save','news'); ?>');
			$(this).parent().prev('span').html('<textarea>' + field_value + '</textarea>');
			$(this).parent().prev('span').children().focus();
		} else {
			$(this).text('<?php _e('Edit','news'); ?>');
			$(this).parent().prev('span').text(input_value);
			// change the User data
			var datatype = $(this).attr('id');
			$(this).parent().next('span').html('<img src="<?php bloginfo('template_directory'); ?>/images/loading2.gif" alt="" />');
			$(this).parent().next('span').load('<?php bloginfo('template_directory'); ?>/ModifyData.php?' + datatype + '=' + encodeURI(input_value));
		}
	});

}) (jQuery);
</script>

<?php get_footer(); ?>

<?php } ?>