<?php 
//Initial DB Query
	
	$query = 'select * from authors ' 
			 ."where username ='".$_SESSION['valid_user']."'";
				 
	$result = mysql_query($query,$connection) or die(mysql_error());
	
	//Create user data variables		
	$info = mysql_fetch_array($result);
	$id = $info['id'];
	$username = $info['username'];
	$password = $info['password'];
	$fname = htmlspecialchars($info['fname']);
	$email = htmlspecialchars($info['email']);
	$displayname = htmlspecialchars($info['displayname']);
	$bio = $info['bio'];
	$gravatar = $info['gravatar'];
	$mailopt = $info['mailopt']; //0 == checked
	
	
	$sitequery = 'select * from settings;';
	$siteresult = mysql_query($sitequery,$connection) or die(mysql_error());
	
	//Create site settings variables		
	$siteinfo = mysql_fetch_array($siteresult);
	$sitetitle = $siteinfo['title'];
	$siteurl = $siteinfo['url'];
	$logo = $siteinfo['logourl'];
	$statcode = $siteinfo['statcode'];
	$minwords = $siteinfo['minwords'];
	$maxwords = $siteinfo['maxwords'];
	$skipqueue = $siteinfo['skipqueue'];

?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

	<title><?php echo $pagetitle; ?> </title>
	
	<link href="../styles/main.css" media="all" rel="stylesheet" type="text/css" />
	<!--[if lte IE 6]><link href="../styles/ie.css" media="screen" rel="stylesheet" type="text/css" /><![endif]-->
	<!--[if lte IE 7]><link href="../styles/ie.css" media="screen" rel="stylesheet" type="text/css" /><![endif]-->

<script language="javascript" type="text/javascript">
function limitText(limitField, limitCount, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		limitCount.value = limitNum - limitField.value.length;
	}
}
</script>

<!-- TinyMCE -->
<script type="text/javascript" src="../js/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript" src="../js/tiny_mce/tiny_mce_init.js"></script>
</head>


<body>

<div id="container">

<!-- HEADER -->
<div id="header">
	<div id="logo"><a href="<?php echo $siteurl; ?>" >
	<?php if ($logo) { ?><img border="0" alt="<?php echo $sitetitle; ?>" src="<?php echo $siteurl;?>/admin/images/logo/<?php echo $logo; ?>" /></a> <? } else {
	echo "<h1 style=\"padding-left: 10px;\">".$sitetitle."</h1>"; } ?>
	</div>


<div id="login-area">
	Welcome, <?php echo $fname ?> (<a href="logout.php">Logout</a>)
</div>

<div id="searchbar">
<form name="search" method="get" action="../search.php" >
	<input type="text" name="s" style="width: 155px; padding: 4px; border: 1px solid gray; margin: 0;" /> 
	<input type="submit" id="searchsubmit" value="Search" />
</form>
</div>

<div class="clear"></div>

</div>

<!-- Top Menu -->
<div id="menu">
	<ul>
		<li><a href="<?php echo $siteurl; ?>">Home</a></li>
	<?php
	// Populates the Dropdown list with all pages
	$query = "select * from pages where onmenu=0;"; 
	$result = mysql_query($query,$connection) or die(mysql_error());
	$num_results = mysql_num_rows($result);
		
	for ($i=0; $i <$num_results; $i++) { 
		$row = mysql_fetch_assoc($result); 
		echo "<li><a href=\"".$siteurl."/page.php?p=".$row['id']."\">".$row['title']."</a></li>"; 
	}
	?>
	</ul>
<br style="clear:left"/>
</div>

<div class="clear"></div>
