<?php defined( '_BIGNIGHT_EXEC' ) or die( 'Restricted access' );?>

<script type="text/javascript" src="js/subscribe.js"></script>

<?php
	global $user;
	require_once("include/profile.php");
?>
<?php if (!isset($user) && empty($_GET["id"])):	
		// log on form + register form	?>
	<table width="100%">
	<tr>
		<td>
			<form name="login" method="post" action="index.php">
				<table>
					<tr><td>Username:</td><td><input type="text" size="15" name="username"><td></tr>
					<tr><td>Password:</td><td><input type="password" size="15" name="password"><td></tr>
					<tr><td>Remember Me:</td><td><input type="checkbox" name="rememberme" value="1"><td></tr>
					<tr><td></td><td><input type="submit" name="login-submit" value="Log in"></td></tr>
				</table>
			</form>
		</td>
		<td>
			<form name="register"  action="index.php" onSubmit="return validateForm()" method="post">
				<table>
					<tr><td>Username:</td><td><input type="text" size="15" name="username"><td></tr>
					<tr><td>Password:</td><td><input type="password" size="15" name="password"><td></tr>
					<tr><td>Confirm:</td><td><input type="password" name="password2"><td></tr>
					<tr><td>E-mail:</td><td><input type="text" name="email"><td></tr>
					<tr><td>Zip:</td><td><input type="text" name="zip" size="5" maxlength="5" onKeyPress="return numbersonly(this, event)"><td></tr>
					<tr><td></td><td><img id="captcha" src="securimage/securimage_show.php" alt="CAPTCHA Image" /><td></tr>
					<tr><td>Enter code:</td><td><input type="text" name="captcha_code" size="10" maxlength="6" />
					<a href="#" onclick="document.getElementById('captcha').src = 'securimage/securimage_show.php?' + Math.random(); return false">[ Different Image ]</a>
					<td></tr>
					<tr><td></td><td><input type="submit" name="register-submit" value="Register"></td></tr>
				</table>
			</form>
		</td>
	</tr>
	</table>
	  
<?php
	elseif(empty($_GET["name"])):
		if(!empty($_POST["profile-submit"])) {
			global $error;
			if(edit_profile($user["username"])) $error = "Changes saved";
			else $error = "Error saving changes";
		}
		reload_user();
		profile($user,true);	// own profile with form
	else:
		profile(get_user_by_name($_GET["name"]),false);	// users profile without form
	endif;

?>