<html style="width: 450; height: 200;">
<head>
<style type="text/css">
html, body {
  background: ButtonFace;
  color: ButtonText;
  font: 12px Tahoma,Verdana,sans-serif;
  margin-left: 10px;
  padding: 2px;
}
</style>
</head>
<title><?PHP echo $sas_lang['internal_link'] ?></title>
<script type="text/javascript">
function linkSelected(url, linkname) 
{
	var topDoc = window.top.document.forms[0];
	topDoc.f_url.value = url;
	topDoc.f_linkname.value= linkname;	
}
</script>

<?PHP

#############################################################################
#                              Site@School
# Site@School is a website management system designed for schools.
#
# link1.php 
#$Id: link1.php,v 1.1 2006/10/03 12:27:15 fstuurman Exp $
############################################################################
include ("../../../configuration/database.inc.php"); // connecting to database
mysql_connect("$db_server", "$db_username", "$db_password");
mysql_select_db("$db_name");

$query = "SELECT config_value FROM $table_configuration where config_key='url'"; // getting the site url
$result = mysql_query($query) or die_script(mysql_error());
$site_url = mysql_result($result, 0);
unset ($query);
unset ($result);
$query = "SELECT config_value FROM $table_configuration where config_key='language'"; // getting the language
$result = mysql_query($query) or die_script(mysql_error());
$language = mysql_result($result, 0);
include ("../../../languages/$language/$language.php"); // including language file
unset ($query);
unset ($result);

if (IsSet ($_GET[section]))
{
	$section = $_GET[section];
}
if (IsSet ($_GET[category]))
{
	$category = $_GET[category];
}

$query = "SELECT id, name, frontpage, invisible FROM $table_sections WHERE parent = '' ORDER BY sort";
$result = mysql_query($query) or die_script(mysql_error());

while ($section_list = mysql_fetch_array($result))
{
	$i = 1;
	print "<a href=\"link1.php?section=$section_list[0]\" style =\"color: #0000FF\">$section_list[1]</a>";

	$query1 = "SELECT id, category FROM $table_pages WHERE section = '$section' GROUP BY category"; // getting catlist
	$result2 = mysql_query($query1);

	while ($cat_list = mysql_fetch_array($result2)) //loop through categories
	{

		$category1 = htmlspecialchars(rawurlencode($cat_list[1]));

		if (!empty ($cat_list[1]) and ($section_list[0] == $section)) //only display when categrory has no blanks
		{
			if ($i == 1)
			{
				print "<ul>";
			} //only print the first time
			$i++;
			print "<li><a href=link1.php?option=pagemanager&category=$category1&section=$section>$cat_list[1]</li>";
		}
		if (($cat_list[1] == $category) and ($section_list[0] == $section))
		{
			$query1 = "SELECT id, name, module, invisible FROM $table_pages WHERE category = '$category' and section = '$section' ORDER BY sort";
			$result1 = mysql_query($query1) or die_script(mysql_error());
			print "<ul>";
			while ($page_list = mysql_fetch_array($result1))
			{
				$page_name = addslashes($page_list[1]);
				print "<li><a href=# onclick=\"javascript:linkSelected('<a href=" . $site_url . "/index.php?section=" . $section_list[0] . "&page=" . $page_list[0] . ">','" . $page_name . "');\">$page_list[1]</a></li>";
			}

			print "</ul>";
		}
	}
	if ($i > 1)
	{
		print "</ul>";
	}
	if ($i == 1)
	{
		print "<br>";
	}
}
?>
</body></html>