<?php

include_once 'cfg/mysql.php';
connectdb();

if(isset($_GET['p']))
{
	$page = $_GET['p'];
}
else
{
	$page = 'bar';
}

if(isset($_GET['r']))
{
	$room = $_GET['r'];
	setcookie("room", "", time()-3600);
	setcookie("room", $room, time()+3600);
}
else
{
	$room = '1';
}

if(isset($_GET['d']))
{
	$description = $_GET['d'];
	setcookie("description", "", time()-3600);
	setcookie("description", $description, time()+3600);
}
else
{
	$description = 'TL1';
}

?>
	
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>SaveEnergy Leiden</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/swfobject.js"></script>
<script type="text/javascript">
swfobject.embedSWF(
  "open-flash-chart.swf", "chart",
  "100%", "300", "9.0.0", "expressInstall.swf",
  {"data-file":"graph_<?php echo $page ?>.php"});

function bar_1(chart_id)
{
	var description = "TL1";
	var room = chart_id;
	window.location = ("?p=line&r="+room+"&d="+description);
}


</script>

</head>

<body>
<div id="container">
	<div id="header">
    <img src="images/Untitled-3_01.jpg" />
    </div>


	<div id="navigation">
    <a href="index.php">Home</a> <a href="page1.php?p=bar" "style='color:#f7921c'">Grafieken</a> <a href="page2.php">Uitleg</a> <a href="page3.php">Info</a>
    </div>
    
    
    <div id="content_wrap">
    <div id="content_top">
    </div>
     <div id="content">
      <h1>Grafieken</h1>
      <h2>Uitleg</h2>
      <p>Alle energiemetingen zijn vermenigvuldigd met een factor 10^3, de temperatuurmetingen zijn onveranderd. <br /><br /> Onder de grafieken is een menu waarmee gekozen kan worden welke meting van de kamer wordt getoond.</p>
      
<div id="chart"></div>
<br />
<br />
<?php
if($page=='line')
{
	$teller=0;
	$result = mysql_query("SELECT DISTINCT description FROM sensors WHERE roomID=$room ORDER BY description asc");
	while ($row=mysql_fetch_array($result))
		{
			$menu[$teller]['description']=$row['description'];
			$teller++;
		}
		
	for($i=0;$i<count($menu);$i++)
		{
			echo'<a href=
			"page1.php?p=line&r='.$room.'&d='.$menu[$i]['description'].'">'.$menu[$i]['description'].'</a>';
		}
}
?>
     </div>
     
    <div id="content_bottom">
    </div>
  </div>
    
    
    <div id="footer">
    Save Energy Leiden is een onderdeel van het <a href="http://www.ict4saveenergy.eu/">Save Energy project</a>.
    </div>    
</div>
</body>

</html>
