<?php
require_once "maincore.php";
require_once THEMES."templates/header.php";

add_to_head('<style type="text/css">

.filmai {
	width: 160px; 
	height: 245px;
}

.filmai a {
	color: #fff;
	width: 160px;
	height: 245px;
	display: block;
	text-decoration: none;
}

.filmai a:hover {
	background-color: rgba(0, 0, 0, 0.5); /* kur 0.5 tai fono opacity*/
	height: 245px;
}

.filmai a span {
	display: none;
	width: 160px;
	padding:5px;
}

.filmai a:hover span {
	display: block;
}

</style>');

$kiek = 16; // kiek rodyti filmu puslapyje

$adresas = "http://online.ql.lt/"; // nurodom svtaines adresa pabaigoje butinai turi buti / pvz http://adresas.lt/

 
if (!isset($_GET['rowstart']) || !isnum($_GET['rowstart'])) { 
	$_GET['rowstart'] = 0; 
}

$rows = dbcount("(*)", DB_NEWS, "news_draft='0'");	

$result = dbquery(
    "SELECT * FROM ".DB_NEWS." 
     WHERE news_draft='0' ORDER BY news_datestamp DESC 
     LIMIT ".$_GET['rowstart'].",$kiek"
);
		
		
if (dbrows($result) != 0) {
$counter = 0; 
$columns = 4; // kiek filmu rodyti vienoje eiluteje

echo "<table cellpadding='0' cellspacing='0' width='100%' style='padding:5px;'><tr>";

while($data = dbarray($result)) {
	if ($counter != 0 && ($counter % $columns == 0)) { echo "</tr>\n<tr>\n"; }
	$aprasymas = trimlink($data['news_news'], 250);
	$image = $adresas."images/news/".$data['news_image'];			
	echo"<td>
		<div style='background: url($image) no-repeat;' class='filmai'>
			<a href='".BASEDIR."news.php?readmore=".$data['news_id']."'>
				<span>
					".$aprasymas."
				</span>
			</a>
		</div>
	</td>";
	$counter++;
}
echo "</tr>\n</table>\n";

}


//puslapiavimas
echo"<div align='center'>";
if ($rows > $items_per_page) {
    echo makepagenav($_GET['rowstart'], $items_per_page, $rows, 3);
}
echo"</div>";

require_once THEMES."templates/footer.php";
