<?php

// -----------------------------------------------------------------------
// This file is part of AROUNDMe
//
// Copyright (C) 2003 - 2007 Barnraiser
// http://www.barnraiser.org/
// info@barnraiser.org
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option) any
// later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with program; see the file COPYING. If not, write to the Free
// Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
// 02110-1301, USA.
// -----------------------------------------------------------------------

?>

<style type="text/css">
<!--
@import url(<?php echo $template_path;?>css/aroundme_form.css);
-->
</style>


<form action="index.php?amn=core_me_view" method="post" name="frm" id="id_frm">

<div class="col_left1">
	<div class="box">
		<div class="box_top">
			<?php echo $lang['hdr_account'];?><br />
		</div>

		<div class="box_mid">
			<div class="content">
				<p>
					<b><?php echo $lang['txt_general'];?></b><br />
				</p>
				
				<p>
					<?php echo $lang['txt_account_intro'];?><br />
				</p>
				
				<p>
					<label for="id_firstname"><?php echo $lang['txt_firstname'];?></label>
					<input id="id_firstname" type="text" name="user_firstname" class="input1" value="<?php echo $user['user_firstname'];?>" /><br />
				</p>
			   	
			   	<p>
					<label for="id_surname"><?php echo $lang['txt_surname'];?></label>
					<input id="id_surname" type="text" name="user_surname" class="input1" value="<?php echo $user['user_surname'];?>" /><br />
				</p>
				
				<p>
					<label for="id_dob"><?php echo $lang['txt_dob'];?></label>
					<?php echo $datedropdown;?><br />
				</p>
				
				<?php
				if (isset($locations)) {
				?>
				<p>
				<label for="id_location"><?php echo $lang['txt_location'];?></label>
				<select id="id_location" name="location_id">
				<option value="0"><?php echo $lang['txt_location'];?></option>
					
				<?php
				foreach($locations as $key => $i):
				$selected="";
				if ($user['location_id'] == $i['location_id']) {
					$selected = " selected=\"selected\"";
				}
				?>
				<option value="<?php echo $i['location_id'];?>"<?php echo $selected;?>><?php echo $i['location_name'];?></option>
				<?php
				endforeach;
				?>
				</select>		
				</p>
				<?php }?>
				
				<p>
					<b><label for="id_lang"><?php echo $lang['txt_lang_selection'];?></b></label><br />
				</p>
				
				<?php
				if (count($lang['arr_lang_name']) > 1) {
				?>
				
				<p>
					<?php
					foreach($lang['arr_lang_name'] as $key1 => $i):
	
					//find out if the language is selected
					$checked = "";
					
					foreach($user['language_ids'] as $key2 => $r):
						if ($key1 == $r) {
						   $checked = "checked=\"checked\"";
						}
					endforeach;
					?>
					<input id="id_lang" type="checkbox" name="language_ids[]" value="<?php echo $key1;?>" <?php echo $checked;?> />&nbsp;<?php echo ucfirst($i);?><br />
					<?php
					endforeach;
					?>
					<br />
				</p>
				<?php }?>
				
				<p>
					<label for="id_pref_lang"><?php echo $lang['txt_pref_lang'];?></label>
					<select name="language_id" id="id_pref_lang">
						<?php foreach($lang['arr_lang_name'] as $key => $i): ?>
						<option value="<?php echo $key;?>" <? if($user['language_id'] == $key) echo "selected";?>><?php echo ucfirst($i);?></option>
						<?php endforeach; ?>
					</select><br />
				</p>

				<?php
				if (count($templates)>1) {
				?>
				
				<p>
					<b><label for="id_templates"><?php echo $lang['txt_template'];?></label></b><br />
				</p>
				
				<p>
					<?php echo $lang['txt_template_intro'];?><br />
					<select name="template_id" id="id_templates">
					<?php
					foreach($templates as $key => $i):
					
					$selected = "";
						
					if ($user['template_id'] == $i['template_id']) {
					    $selected = "selected=\"selected\"";
					}
					?>
					<option value="<?php echo $i['template_id'];?>" <?php echo $selected;?>><?php echo $i['template_title']?></option>
					<?php
					endforeach;
					?>
					</select>
				</p>
				<?php
				}
				else {
				?>
				<input type="hidden" name="template_id" value="<?php echo $templates[0]['template_id'];?>" />
				<?php }?>
				
				<p>
					<b><label for="id_homepage"><?php echo $lang['txt_homepage'];?></b></label><br />
				</p>
				
				<p>
					<?php echo $lang['txt_homepage_intro'];?><br />
					<?php
					foreach($lang['homepage']['page'] as $key => $i):
					$selected="";
					if (isset($user['user_homepage']) && $user['user_homepage'] == $i) {
					    $selected = "checked=\"checked\"";
					}
					?>
					<input id="id_homepage" type="radio" name="user_homepage" value="<?php echo $i;?>" <?php echo $selected;?> />&nbsp;<?php echo $lang['homepage']['page_desc'][$key];?><br />
					<?php
					endforeach;
					?>
					</select>
				</p>

				<hr />
				
				<p align="right">
					<input type="submit" name="update_account" class="input_submit" value="<?php echo $lang['sub_update_account'];?>" /><br />
				</p>
			</div>
		</div>
	</div>
	
	<div class="box_bottom">
		<span class="box_bottom_right"></span>
		<span class="box_bottom_left"></span>
	</div>
	
	<?php
	if (isset($lang['user']['preference'])) {
	?>
	<div class="box">
		<div class="box_top">
			<?php echo $lang['hdr_preferences'];?><br />
		</div>

		<div class="box_mid">
			<div class="content">
				<table border="0" cellspacing="4" cellpadding="0" width="100%">
					<p>
						<?php echo $lang['txt_preferences_intro'];?><br />
					</p>
					<?php
					foreach($lang['user']['preference'] as $key => $i):
					
					if (isset($user['preferences'])) {
						$checked = "";
						unset($pref_value);
						
						foreach ($user['preferences'] as $keypref => $p):
							if ($key == $p['user_preference_id']) {
								$checked = "checked=\"checked\"";
								$pref_value = $p['user_preference_value'];
								break;
							}
						endforeach;
					}
					?>
					<tr>
						<td valign="top">
							<img src="<?php echo $template_path;?>img/dot.png" width="3" height="9" alt="" border="0" /><br />
						</td>
						<td valign="top">
							<?php echo $i;?><br />
						</td>
						<td align="right">
							<?php
							if (isset($lang['user']['pref_options'][$key])) {
							?>
							<select name="user_preferences[<?php echo $key;?>]">
							<?php
							foreach($lang['user']['pref_options'][$key] as $optionkey => $r):
							$checked = "";
							if (isset($pref_value) && $pref_value == $optionkey) {
								$checked = "selected=\"selected\"";
							}
							?>
							<option value="<?php echo $optionkey;?>" <?php echo $checked;?>><?php echo $r;?></option>
							<?php
							endforeach;
							?>
							</select>
							<?php
							}
							else {
							?>
							<input type="checkbox" name="user_preferences[<?php echo $key;?>]" value="1" <?php echo $checked;?>><br />
							<?php }?>
						</td>
					</tr>
				<?php
				endforeach;
				?>
				</table>
				
				<hr />
				
				<p align="right">
					<input type="submit" name="update_user_preferences" class="input_submit" value="<?php echo $lang['sub_update'];?>" class="button_urgent" /><br />
				</p>
			</div>
		</div>
	</div>
	
	<div class="box_bottom">
		<span class="box_bottom_right"></span>
		<span class="box_bottom_left"></span>
	</div>
	<?php }?>
</div>

<div class="col_right1">
	<div class="box">
		<div class="box_top">
			<?php echo $lang['hdr_password'];?><br />
		</div>

		<div class="box_mid">
			<div class="content">		
				<p>
					<?php echo $lang['txt_password_intro'];?><br />
				</p>
				
				<p>
					<label for="id_password1"><?php echo $lang['txt_password'];?></label>
					<input id="id_password1" type="password" name="user_password1" class="input1" size="8" value="" /><br />
				</p>
				
				<p>
					<label for="id_password2"><?php echo $lang['txt_confirm_password'];?></label>
					<input id="id_password2" type="password" name="user_password2" class="input1" size="8" value="" /><br />
				</p>
				
				<hr />
				
				<p align="right">
					<input type="submit" name="update_password" class="input_submit" value="<?php echo $lang['sub_update_password'];?>" /><br />
				</p>
			</div>
		</div>
	</div>
	
	<div class="box_bottom">
		<span class="box_bottom_right"></span>
		<span class="box_bottom_left"></span>
	</div>
	
	<div class="box">
		<div class="box_top">
			<?php echo $lang['hdr_email'];?><br />
		</div>

		<div class="box_mid">
			<div class="content">
				<p>
					<?php echo $lang['txt_email_set_intro'];?><br />
				</p>
				
				<p>
					<label for="id_email1"><?php echo $lang['txt_email'];?></label>
					<input id="id_email1" type="text" name="user_email1" size="25" class="input1" value="" /><br />
				</p>
				
				<p>
					<label for="id_email2"><?php echo $lang['txt_confirm_email'];?></label>
					<input id="id_email2" type="text" name="user_email2" size="25" class="input1" value="" /><br />
				</p>
				
				
				<p align="right">
					<i><?php echo $lang['txt_current_email'];?> <?php echo $user['user_email'];?></i><br />
				</p>
				
				<hr />
				
				<p align="right">
					<input type="submit" name="update_email" class="input_submit" value="<?php echo $lang['sub_update_email'];?>" /><br />
				</p>
			</div>
		</div>
	</div>
	
	<div class="box_bottom">
		<span class="box_bottom_right"></span>
		<span class="box_bottom_left"></span>
	</div>
	
	<div class="box">
		<div class="box_top">
			<?php echo $lang['hdr_dormant'];?><br />
		</div>

		<div class="box_mid">
			<div class="content">
				<?php echo $lang['txt_dormant_intro'];?><br />
				
				<hr />
				
				<p align="right">
					<input type="submit" name="set_dormant" class="input_submit" value="<?php echo $lang['sub_set_dormant'];?>" /><br />
				</p>
			</div>
		</div>
	</div>
	
	<div class="box_bottom">
		<span class="box_bottom_right"></span>
		<span class="box_bottom_left"></span>
	</div>
			
</div>
</form>
