<? 
session_start();
include("functions/conexion.php");
include("functions/divs.php");
include ("graphs/src/jpgraph.php");
include ("graphs/src/jpgraph_line.php");


$idticker = $_GET["idticker"];
$ticker = $_GET["ticker"];
$idhistory = $_GET["idhistory"];
$name = $_GET["name"];
$price = $_GET["price"];
$pricebefore = $_GET["pricebefore"];
$volume = $_GET["volume"];
$time = $_GET["time"];



?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Details</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="css/style.css" media="screen" />
</head>


<body>
<div id="title">
	<div id="header">
	<img src="images/money.png" alt="Money" align="left"/>
	</div>
	<div id="virtualtrade">
	<h1>      
    	<a href="index.php"><img src="images/title.png" alt="Virtual Trade"/></a>
    </h1>
	</div>
	<div id="signin">
	<?
	if(isset($_SESSION['login'])) {
		echo "<a href='/infouser.php'>".$_SESSION['login']."</a>";
		echo "&nbsp;&nbsp;";
		echo "<a href='/functions/logout.php'>Sign out</a>";
	}
	else{
	?>
	<a href="/register.php">Register</a>
	<a href="/loginindex.php">Sign in</a>
	<?
	}
	?>
	<br/>
	</div>
</div>
<div id="details">
<?
echo "<h3>".$ticker."</h3>";

if(isset($_GET["time"])){
echo "<table border='1'>";
echo "<tr><td>Company</td><td>Ticker</td><td>Change%</td><td>Price</td><td>Volume</td><td>Change</td><td>Prev Close</td><td>Date</td></tr>";
echo "<tr>";
echo "<td>";
echo $name;
echo "</td>";
echo "<td>";
echo $ticker;
echo "</td>";
echo "<td>";
$number = 100*($price-$pricebefore)/$pricebefore;
echo round($number,2)."%"; 
echo "</td>";
echo "<td>";
echo $price;
echo "</td>";
echo "<td>";
echo $volume;
echo "</td>";
echo "<td>";
echo $price-$pricebefore."£";
echo "</td>";
echo "<td>";
echo $pricebefore."£";
echo "</td>";
echo "<td>";
echo $time;
echo "</td>";
echo "</tr>";
echo "</table>";
echo "<br/>";
}
?>
<script type="text/javascript">
function check()
{
	
	number = document.getElementById("link").src.length-1;
	

	var a = document.getElementById("link").src.substring(0, number) + document.getElementById("time").value;	
	document.getElementById("link").src = a;
    
}
</script>
<?

echo "<img src='/graphs/graphic.php?idticker=".$idticker."&graph=0' id='link'>";
?>


<br/><br/>
<SELECT id="time" onChange="check()">
<OPTION value="0" selected>Today</option>
<OPTION value="1">This month</option>
<OPTION value="2">This year</option>
</SELECT>
</div>
</body>
</html>
