<?php
/** 
* @package	Galeria Suczawa 2009 
* @file		gallery.php
* @version	$Id$
* @author	chp1994 <chp1994@gmail.com>
* @link 	http://suczawa.ath.cx/
**/

$page= (isset($_GET['page'])) ? intval($_GET['page']) : 0;

$xhtml = preg_match('/application\/xhtml\+xml(?![+a-z])(;q=(0\.\d{1,3}|[01]))?/i', 
$_SERVER['HTTP_ACCEPT'], $xhtml) && (isset($xhtml[2])?$xhtml[2]:1) > 0 || 
strpos($_SERVER["HTTP_USER_AGENT"], "W3C_Validator")!==false || 
strpos($_SERVER["HTTP_USER_AGENT"], "WebKit")!==false;
header('Content-Type: '.($xhtml ? 'application/xhtml+x' : 'text/ht').'ml; charset="utf-8"');

require('./init.php');

echo '<?xml version="1.0" encoding="utf-8"?>';

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl">
<head>
	<title>Galeria Suczawa 2009</title>
	<link type="text/css" href="style.css" rel="stylesheet" />
	<script type="text/javascript">
	sciezka = 'http://' + '<?= $_SERVER['HTTP_HOST']; ?>' + '/sg/robocze/';
	</script>
	<script type="text/javascript" src="script.js"><!-- AJAX Library by chp1994(c) //--></script>
</head>
<body onload="javascipt:init()">
	<div id="page">
		<div id="images_outer">
			<table id="images"><tr>
			<?php
				//$sql = "SELECT * FROM `photos` LIMIT ".($page*$per_page).", $per_page";
				$sql = "SELECT * FROM `photos` $limit";
				if (!$result = $DB->query($sql))
				{
		    			blad('Nie mozna pobrac zdjec uzytkownikow!');
				}
				
				for($i=$page*$per_page; $row = $result->fetch_assoc(); $i++)
			 	{
					echo '<td class="image_outer" onclick="javascript:previewImage('.($row['id']).')"><img alt="'.$row['photo_name'].'" src="images/upload/'.$row['thumb_name'].'" class="image" /></td>';
					if($i%3==2 && $i!=$count-1) echo '</tr><tr>';
				
		    		}
				while($i%3) {
					$i++;
					echo '<td class="image_outer_black">&nbsp;</td>';
				}
			?>
			</tr>
			</table>
		</div>
		<div id="pages_outer">
			<div id="pages">Strony: 
		<?php
		GenerujListeStron();
		?>
			</div>
		</div>
		<div id="disp">
			<div id="disp_middle">
			<div id="disp_inner">
				<div><h3 id="disp_name"> </h3></div>
				<div id="disp_top">
					<img id="disp_prev" src="images/prev.png" onclick="javascript:prev()" alt="Poprzedni"></img>
					<a id="disp_a" href=""><img id="disp_img" src="" alt="Zdjecie" /></a>
					<img id="disp_next" src="images/next.png" onclick="javascript:next()" alt="Nastepny"></img>			
				</div>
				<div id="disp_info"></div>
				<div><b>Autor:</b> <a id="disp_author"> </a></div>
				<a id="disp_close" onclick="javascript:closeDisp()">Zamknij</a>
			</div>
			</div>
		</div>
		<div id="icons">
			<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml11" alt="Valid XHTML 1.1" height="31" width="88" /></a>
			<a href="http://jigsaw.w3.org/css-validator/check/referer"><img width="88px" height="31px" src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Poprawny CSS!" /></a>
		</div>
	</div>
</body>
</html>
