<?php
if(count(get_included_files())==1) exit("Direct access not permitted.");
$mod = basename(__FILE__, '.php');
$page->tbCss($mod);
$query="select t1.`id`,
			t1.`tanggal`,
			t1.`idkategori`,
			t1.`nama`,
			t1.`keterangan`,
			t1.`idgambar`,
			t1.`status`,
			t3.nama as kategori,
			if(t2.nama_awal is null,'PILIH FILE UNTUK UPLOAD GAMBAR',t2.nama_awal) as nama_awal,
			if(t2.nama_baru is null,'',t2.nama_baru) as nama_baru,
			if(t2.folder is null,'',t2.folder) as folder
		from tb_album as t1
		left join tb_dokumen as t2 on t1.idgambar=t2.id
		inner join tb_album_kategori as t3 on t1.idkategori=t3.id
		where t1.status=1 order by rand() limit 0,8";
$rsgallery=$db->loadAll($query);
$jumlahgallery=sizeof($rsgallery);
$datagallery=array();
for($i=0;$i<$jumlahgallery;$i++){
	$datagambar=NPAGE.$rsgallery[$i]['folder'].$rsgallery[$i]['nama_baru'];
	ob_start();
	?>
	<a href="<?php echo NPAGE.'album/?id='.$rsgallery[$i]['id'];?>">
		<div class="box_gallery">
			<img src="<?php echo $datagambar;?>" />
			<div class="box_gallery_bg"></div>
		</div>
	</a>
	<?php
	$obj=ob_get_clean();
	array_push($datagallery,$obj);
}
?>
<div class="box_gallery_utama" align="center">
	<div class="head_judul_gallery" align="left">Album Gallery</div>
	<div align="center;" class="head_deskripsi_gallery"></div>
	
	<div class="box_data_gallery">
		<?php
		if(sizeof($datagallery)>0){
			for($i=0;$i<sizeof($datagallery);$i++){
				echo $datagallery[$i];
			}
		}
		?>
		<div style="clear: both;"></div>
	</div>
</div>