<?php
error_reporting(0);
	$nebeneinander = 2;
	$counter = 0;
	$active_page = !empty($_GET['page']) ? $_GET['page'] : 1;

	if (@$_GET['action'] == "success") 
		{ 
			echo "
					<div id='DONE'><br />
					
						<table width='80%' border='0' align='center' cellpadding='0' cellspacing='0'>
							<tr>
								<td align='center'><strong><font size='2'>Item purchase successful!!!</font></strong></td>
							</tr>
						</table>
					</div> ";
		}
?>
		  <br />
          <br />
		  <br />
		  <br />
		  <br />

			<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
              <td colspan="2" align="center" valign="top"><br /><br /></td>
            </tr>
            <tr>
              <td colspan="2" align="center" valign="top"></td>
            </tr>
			
            <tr>
			
<?php
			
			$result=mysql_query("SELECT COUNT(itemid) FROM global_shop WHERE categorie = '".$_GET['catID']."' AND isSell = '1'");

			list($entries)=mysql_fetch_row($result);
			if ($entries < 1) { echo "<td width='50%' align='center' valign='top'>no Items in this Category</td></tr></table>"; } else {
			$blaettern=new blaettern($active_page, $entries);
			$blaettern->setLinkHref('index.php?show=cashshop&catID=1&amp;page=');
			$blaettern->setDelimiter1(' ');
			$blaettern->setDelimiter3(', ');
			$blaettern->setLinkActiveMore(' style="font-size:13px;"');
			$blaettern->setLinkFirstLastText('Machst Du Seite 1', 'Machst Du Seite ganz hinten');
			$blaettern->setShowActiveLink('false');
			$blaettern->setShowFirstLast(false);
			$blaettern->setShowNextPrev(false);
			$blaettern->setEntriesPerPage(6);
			$start = ".$blaettern->getEntriesPerPage()." * ".$blaettern->getActivePage().";
			$stop = ".$blaettern->getEntriesPerPage().";
			$result=mysql_query('SELECT * FROM global_shop WHERE categorie = 5 AND isSell = 1 ORDER BY itemid DESC LIMIT '.($blaettern->getEntriesPerPage() * $blaettern->getActivePage()).', '.$blaettern->getEntriesPerPage());
			while($data = mysql_fetch_array($result))
				{
				
				
					if ($counter != 0 && ($counter % $nebeneinander == 0)) echo "</tr>\n<tr>\n";
					
					$prozent = number_format(100 / $nebeneinander);
					
					$file = strtolower($data['itempic']);
					$filename = "gfx/shop/items/".$data['itempic']."";
					if (file_exists($filename)) {
					$bild = "<img src='$filename' width='45' height='45' />";
					} else {
					$bild = "<img src='gfx/shop/items/nopic.png' width='45' height='45' />";
					}
					
					if ($_SESSION['user_eingeloggt'])
					{
					$button = "<img src='gfx/content/nocash.png' width='53' height='17' />";
					} else {
					$button = "<form id='form3' name='form2' method='post' action='action.php?action=getitem'>
					<input name='buyitemid' type='hidden' id='itemid' value='".$data['itemid']."' />
					<input name='needcash' type='hidden' id='cost' value='".$data['price']."' />
					<input name='returnid' type='hidden' id='cost' value='".$_GET['catID']."' />
					<input type='submit' name='login' value='' class='buy_bgImage' />
					</form>";
					}
					
					if ($aktmoney < $data['price'])
					{
					$button = "<img src='gfx/content/nocash.png' width='53' height='17' />";
					} else {
					$button = "<form id='form3' name='form2' method='post' action='action.php?action=getitem'>
					<input name='buyitemid' type='hidden' id='itemid' value='".$data['itemid']."' />
					<input name='needcash' type='hidden' id='cost' value='".$data['price']."' />
					<input name='returnid' type='hidden' id='cost' value='".$_GET['catID']."' />
					<input type='submit' name='login' value='' class='buy_bgImage' />
					</form>";
					}
				
							echo "
								<td width='50%' align='center' valign='top'>
									<div id='cat_bg'>
										<table width='95%' border='0' align='left' cellpadding='0' cellspacing='0'>
											<tr>
												<td width='65' rowspan='3' align='center' valign='top'>".$bild."<br /><img src='gfx/content/g-pip12px.png' width='9' height='9' /> ".$data['price']."</td>
												<td align='left' valign='top'><strong>".$data['itemshopname']."</strong></td>
											</tr>
											<tr>
												<td align='left' valign='top'>".$data['itemdesc']."</td>
											</tr>
											<tr>
												<td align='right' valign='bottom'>".$button."
												</td>
											</tr>
										</table>
									</div>
								</td>";
							$counter++;
						}
?>
			  
            </tr>

          <tr>
            <td colspan="2" align="center" valign="top" class="login"><?php echo $blaettern->create(); ?></td>
          </tr>
          </table>
<?php
}
?>