<?php
//------------------------------------------
//IAESTE SWEDEN COMMON WEBPAGE LAYOUT
//
//Copyright (C) 2003 IAESTE Sweden
//Created by Erik Unemyr, IAESTE LC Chalmers
//Modified by Kicki Man, IAESTE LC KTH
//
//PLEASE NOTE: Parts of the CSS template is
//taken from www.iaeste.org.
//------------------------------------------

//------------------------------------------
//INSTRUCTIONS OF USE
//
//In order to keep the consistency of the
//common layout, ONLY change things between
//the EDIT BELOW and STOP EDIT tags in this
//document!
//------------------------------------------

//------------------------------------------
//EDIT BELOW
//------------------------------------------
$committee = "IAESTE LC KTH";



$language = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
//echo 'You are using: '.$language;
if (preg_match('#^[A-Za-z0-9]*$#', $_GET['main'])){
  $main = $_GET['main'];
  if (preg_match('#^[A-Za-z0-9]*$#', $_GET['sub'])){
        $sub = $_GET['sub'];
  }

}

 
//------------------------------------------
//STOP EDIT
//------------------------------------------

//Create page layout
function createLayout() {
global $committee;
echo '<html><head><title>2004 ';
echo $committee;
echo '</title><meta http-equiv="Content-Type" ';
echo 'content="text/html; charset=iso-8859-1">';
//Template start
echo '<style type="text/css"><!--';

//Common template
echo 'body				{ font-family:Arial, Helvetica, Verdana, Sans-Serif; margin:0px; padding:0px; background-color:#191970; color:white; }';
echo 'img				{ margin:0px; border:0px; padding:0px; border-color:#FFFFFF; }';
echo 'a:link			{ background-color:#FFFFFF; color:#6484B3; text-decoration:none; }';
echo 'a:visited			{ background-color:#FFFFFF; color:#6484B3; text-decoration:none; }';
echo 'a:active			{ background-color:#FFFFFF; color:#6484B3; text-decoration:none; }';
echo 'a:hover			{ background-color:#6484B3; color:#FFFFFF; text-decoration:none; }';
echo 'p 				{ font-size: 12px; }';
echo 'li 				{ font-size: 12px; }';
echo 'table 			{ margin:0px; padding:0px; border:0px; background-color:#FFFFFF; border-color:#000000; }';
echo 'td				{ border:0px; background-color:#FFFFFF; color:#000000; vertical-align:top}';

//Top template
echo 'table.menu		{ margin:0px; padding:0px; border:0px; background-color:#191970; color:white; }';
echo 'td.menu			{ border:0px; background-color:#000051; }';
echo 'td.top			{ border-bottom: 1px solid white; border-right: 1px solid white;  background-color:#000051; }';
echo 'td.left			{ width: 40px; border-right: 1px solid white; background-color:#6484B3; }';
echo 'td.header			{ padding:10px; border-bottom: 1px solid white; background-color:#6484B3; }';
echo 'td.main			{ padding:10px; color:#000000; background-color:#FFFFFF; vertical-align:top; }';
echo 'td.right			{ padding:10px; width: 200px; border-right: 1px solid white; border-left: 1px solid white; vertical-align:top; background-color:#191970 }';
echo 'td.empty			{ width: 40px; border-right: 1px solid white; border-top: 1px solid white; background-color:#191970; }';
echo 'td.bottom			{ padding:10px; border-top: 1px solid white; border-right: 1px solid white; border-bottom: 1px solid white; background-color:#000051; }';
echo 'a.menu:link		{ background-color:#000051; color:#FFFFFF; text-decoration:none; }';
echo 'a.menu:visited	{ background-color:#000051; color:#FFFFFF; text-decoration:none; }';
echo 'a.menu:active		{ background-color:#000051; color:#FFFFFF; text-decoration:none; }';
echo 'a.menu:hover		{ background-color:#6484B3; color:#FFFFFF; text-decoration:none; }';
echo 'p.menu			{ color:white; }';

//Sub template
echo 'h1.submenu 		{ color:#FFFFFF }';
echo 'a.submenu:link	{ background-color:#6484B3; color:#FFFFFF; text-decoration:none; }';
echo 'a.submenu:visited	{ background-color:#6484B3; color:#FFFFFF; text-decoration:none; }';
echo 'a.submenu:active	{ background-color:#6484B3; color:#FFFFFF; text-decoration:none; }';
echo 'a.submenu:hover	{ background-color:#000051; color:#FFFFFF; text-decoration:none; }';

//News template
echo 'h1.news			{ color:#FFFFFF }';
echo 'p.news			{ font-size: 10px; color:#FFFFFF }';
echo 'a.news:link		{ background-color:#191970; color:#6484B3; text-decoration:none; }';
echo 'a.news:visited	{ background-color:#191970; color:#6484B3; text-decoration:none; }';
echo 'a.news:active		{ background-color:#191970; color:#6484B3; text-decoration:none; }';
echo 'a.news:hover		{ background-color:#6484B3; color:#FFFFFF; text-decoration:none; }';

echo '--></style>';
//End template

echo '</head><body>';
echo '<table class="menu" border="1" bordercolor="#FFFFFF" cellspacing="0" cellpadding="5" width="800"><tr><td class="left">&nbsp;</td><td colspan="3" class="top">';
createMenu();
echo '</td></tr><tr><td rowspan="2" class="left">&nbsp;</td><td class="header">';
createHeader();
echo '</td><td rowspan="2" class="right">';
createCalendar();
echo '</td></tr><tr><td class="main">';
createDocument();
echo '</td></tr><tr><td class="empty">&nbsp;</td><td colspan="3" class="bottom"><p><font color="#FFFFFF">&copy; ';
echo $committee;
echo '</font></p>';
echo '</td></tr></table></body></html>';
}

//Create menu
function createMenu() {
echo '<table class="menu" border="0" cellpadding="5" cellspacing="0"><td class="menu" bgcolor="#000051">';
echo '<a class="menu" href="index.php"><img hspace="5" src="./images/logoimage.gif" border"0"></a></td><td class="menu" valign="bottom" bgcolor="#000051">';
echo '<img src="./images/logotext.gif"><p class="menu">';

//------------------------------------------
//EDIT BELOW
//------------------------------------------
echo '<a class="menu" href="index.php?main=organization">About IAESTE</a> ';
echo '| <a class="menu" href="index.php?main=trainee">Trainee</a> ';
echo '| <a class="menu" href="index.php?main=student">Student @ Kth</a> ';
echo '| <a class="menu" href="index.php?main=company">F&ouml;retag</a> ';
echo '| <a class="menu" href="index.php?main=images">Images</a> ';
echo '| <a class="menu" href="index.php?main=links">Links</a> ';
echo '</p></td></table>';
//------------------------------------------
//STOP EDIT
//------------------------------------------
}

//Create header
function createHeader() {
global $main;
switch ($main) {
	//------------------------------------------
	//EDIT BELOW
	//------------------------------------------

	case 'organization':


		echo '<h1 class="submenu">About IAESTE</h1>';
		echo '<p class="menu"><a class="submenu" href="index.php?main=organization&sub=general">General</a> ';
		echo '| <a class="submenu" href="index.php?main=organization&sub=organization">Organization</a> ';
		echo '| <a class="submenu" href="index.php?main=organization&sub=committee">Committee 2006</a> ';
		echo '| <a class="submenu" href="index.php?main=organization&sub=alumni">Alumni</a> ';
		echo '| <a class="submenu" href="index.php?main=organization&sub=contact">Contact</a></p>';
	break;
	case 'trainee';
		echo '<h1 class="submenu">Trainee</h1>';
		echo '<p class="menu"><a class="submenu" href="index.php?main=trainee&sub=general">Being a trainee</a> ';
		echo '| <a class="submenu" href="index.php?main=trainee&sub=arrival">Arrival</a> ';
		echo '| <a class="submenu" href="index.php?main=trainee&sub=local">Local information</a></p>';
	break;
	case 'student';
		echo '<h1 class="submenu">Student @ Kth</h1>';
		echo '<p class="menu"><a class="submenu" href="index.php?main=student&sub=general">Möjligheter</a> ';
		echo '| <a class="submenu" href="index.php?main=student&sub=trainee">S&ouml;ka praktikplats</a> ';
		echo '| <a class="submenu" href="index.php?main=student&sub=fadder">Fadder</a> ';
		echo '| <a class="submenu" href="index.php?main=student&sub=apartment">Hyra ut l&auml;genhet</a></p>';
	break;
	case 'company';
		echo '<h1 class="submenu">F&ouml;retag</h1>';
		echo '<p class="menu"><a class="submenu" href="index.php?main=company&sub=general">Att ta emot en praktikant</a> ';
		echo '| <a class="submenu" href="index.php?main=company&sub=responsibility">Ansvar</a></p>';
	break;
	case 'images';
		echo '<h1 class="submenu">Images</h1>';
	break;
	case 'links';
		echo '<h1 class="submenu">Links</h1>';
	break;
	default:
		echo '<h1 class="submenu">Welcome</h1>';
	break;
	//------------------------------------------
	//STOP EDIT
	//------------------------------------------
}
}

//Create document
function createDocument() {
global $main;
global $sub;
switch ($main) {
	//------------------------------------------
	//EDIT BELOW
	//------------------------------------------
	case 'organization':
		switch ($sub) {
			case 'organization':
				$file = "./documents/organization/organization.html";
			break;
			case 'committee':
				$file = "./documents/organization/committee.html";
			break;
			case 'contact':
				$file = "./documents/organization/contact.html";
			break;
			case 'alumni':
				$file = "./documents/organization/alumni.html";
			break;
			default:
				$file = "./documents/organization/default.html";
			break;				
		}
	break;
	case 'trainee':
		switch ($sub) {
			case 'arrival':
				$file = "./documents/trainee/arrival.html";
			break;
			case 'local':
				$file = "./documents/trainee/local.html";
			break;
			default:
				$file = "./documents/trainee/default.html";
			break;
		}	
	break;
	case 'student':
		switch ($sub) {
			case 'fadder':
				$file = "./documents/student/fadder.html";
			break;
			case 'apartment':
				$file = "./documents/student/apartment.html";
			break;
			case 'trainee':
				$file = "./documents/student/trainee.html";
			break;
			default:
				$file = "./documents/student/default.html";
			break;
		}	
	break;
	case 'company':
		switch ($sub) {
			case 'responsibility':
				$file = "./documents/company/responsibility.html";
			break;
			default:
				$file = "./documents/company/default.html";
			break;
		}	
	break;
	case 'images':
		$file = "./documents/images/default.html";
	break;
	case 'links':
		$file = "./documents/links/default.html";
	break;
	default:
		$file = "./documents/default.html";
	break;
	//------------------------------------------
	//STOP EDIT
	//------------------------------------------
}
if (!($fp=fopen($file,"r"))) {
	echo '<p>Could not open document!</p>';
	exit;
}
while (!feof($fp)) {
	$buffer = fgetc($fp);
	echo $buffer;
}
fclose($fp);
}

//Create calendar
function createCalendar() {
echo '<h1 class="news">News</h1>';

//------------------------------------------
//EDIT BELOW
//
//This area only supports H1, P and A tags.
//ALWAYS use class="news" for all new tags
//you create.
//
//Sample news item:
//echo '<p class="news">
//<b>2003-12-24: Christmas</b><br>
//<a class="news" href="mailto:santa@
//northpole.ice">Santa</a> is coming!</p>';
//------------------------------------------
echo '<p class="news"><b>2006-09-01: No News</p>';

//------------------------------------------
//STOP EDIT
//------------------------------------------
}

//Action!
createLayout();
?>
