<?php
if (!isset($_SESSION))
{
	session_start();
}
require_once('header.php');
function add_cat($cat)
{
	echo "<center><img src='hotel/images/catalogus/logo/".$cat.".gif'></center><br>";
	$catalog = halen_array("SELECT * FROM catalogus WHERE id=".$cat.";");
	echo $catalog['desc'];
}
function add_buy($furni_list)
{
	echo "<table width='516' cellspacing='0' cellpadding='0' border='0' class='tabel'>";
	echo "<tbody>";
	$count1 = 1;
	$boven = "";
	$onder = "";
	eval('$meubels = array('.$furni_list.');');
	$meubelinfo = array();
	$aantal = sizeof($meubels);
	$aantal2 = ceil($aantal/3);
	for ($i = 0; $i < $aantal; $i++)
	{
		$meubelinfo[$i] = array();
		$meubel = $meubels[$i];
		$cat_array = explode("_", $meubel);
		$cat = $cat_array[0];
		$catnr = $cat_array[1];
		$meubelinfo[$i]['cat'] = $cat;
		$meubelinfo[$i]['catnr'] = $catnr;
		$meubelinfo[$i]['name'] = halen("SELECT naam FROM prijslijst WHERE cat='".$cat."' AND catnr='".$catnr."';");
		$meubelinfo[$i]['price'] = halen("SELECT prijs FROM prijslijst WHERE cat='".$cat."' AND catnr='".$catnr."';");
	}
	for ($i2 = 0; $i2 < $aantal2; $i2++)
	{
		for ($i = ($i2*3); $i < (($i2*3)+3); $i++)
		{
			if($count1 == 1)
			{
				echo '<tr>';
				echo '<td width="172" valign="middle" height="133" background="img/koop_home_boven.gif" align="center" style="background-repeat: no-repeat;">';
				echo '<img src="hotel/images/items/'.$meubelinfo[$i]['cat'].'/'.$meubelinfo[$i]['catnr'].'/1.gif">';
				echo '</td>';
				echo '<td width="172" valign="middle" height="133" background="img/koop_home_boven.gif" align="center" style="background-repeat: no-repeat;">';
				if(($i+1) >= ($aantal))
				{
					// niets
				}
				else
				{
					echo '<img src="hotel/images/items/'.$meubelinfo[($i+1)]['cat'].'/'.$meubelinfo[($i+1)]['catnr'].'/1.gif">';
				}
				echo '</td>';
				echo '<td width="172" valign="middle" height="133" background="img/koop_home_boven.gif" align="center" style="background-repeat: no-repeat;">';
				if(($i+2) >= ($aantal))
				{
					// niets
				}
				else
				{
					echo '<img src="hotel/images/items/'.$meubelinfo[($i+2)]['cat'].'/'.$meubelinfo[($i+2)]['catnr'].'/1.gif">';
				}
				echo '</td>';
				echo '</tr>';
				echo '<tr>';
				$count1 = 2;
			}
			if($i >= ($aantal))
			{
				echo '<td width="172" valign="top" height="65" background="img/koop_home_onder.gif" align="center" style="background-repeat: no-repeat;"><div style="width: 116px;"><div id="purchase_1">';
				echo '</div>';
				echo '</div></td>';
			}
			else
			{
				echo '<td width="172" valign="top" height="65" background="img/koop_home_onder.gif" align="center" style="background-repeat: no-repeat;"><div style="width: 116px;"><div id="purchase_1">';
				echo '<b>'.$meubelinfo[$i]['name'].'</b><br>'.$meubelinfo[$i]['price'].' Credit(s)<br><br>';
				echo "<img src='img/koop.gif' style='cursor: pointer;' onclick='buy_home(".$meubelinfo[$i]['cat'].", ".$meubelinfo[$i]['catnr'].", ".$meubelinfo[$i]['price'].")'>";
				echo '</div>';
				echo '</div></td>';
			}
		}
		$count1 = 1;
	}
	echo '</tr>';
	echo '</tbody>';
	echo '</table>';
}
if ($aangemeld == "ja")
{
	echo "<script>jouwnaam='".$_SESSION['naam']."'; jouwpass='".halen("SELECT wachtwoord FROM members WHERE naam='".$_SESSION['naam']."'")."';</script>";
	echo "<br><hr>";
	echo "Je hebt nog <b><span id='jouw_geld'>".halen("SELECT money FROM members WHERE naam='".$_SESSION['naam']."'")."</span> Credit(s)</b>.<br><br>";
	echo "<script src='javascript/koop_home.js'></script>";
	add_cat(24);
	echo "<br>";
	add_buy("'24_1', '24_2', '24_3', '24_4', '24_5', '24_6', '24_7', '24_8', '24_9', '24_10', '24_11', '24_12', '24_13', '24_14', '24_15', '24_16', '24_17', '24_18', '24_19', '24_20', '24_21', '24_22', '24_24', '24_24', '24_25', '24_26', '24_27', '24_28', '24_29', '24_30', '24_31', '24_32', '24_33', '24_34'");
	echo "<br><br>";
	add_cat(36);
	echo "<br>";
	add_buy("'36_31', '36_11', '36_12', '36_13', '36_14', '36_15', '36_16', '36_17', '36_18', '36_19', '36_20', '36_21', '36_22', '36_23', '36_24', '36_25', '36_26', '36_27', '36_28', '36_29'");
	echo "<br><br>";
	echo "<hr>";
}
else
{
	echo "Oeps! Hiervoor moet je aangemeld zijn!";
}
require_once('footer.php');
?>