<?php
if(count(get_included_files()) ==1) exit("Direct access not permitted.");
$mod = basename(__FILE__, '.php');
$page->tbCss($mod);
$page->tbJs($mod);

$query="select t1.tautan,t1.idgambar,t1.judul,
		if(t2.nama_awal is null,'PILIH FILE UNTUK UPLOAD BANNER BERITA',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_linkterkait as t1
	inner join tb_dokumen as t2 on t1.idgambar=t2.id
	where t1.status=1 and jenis=1 order by t1.urutan asc";
$rsiklan=$db->loadAll($query);

$jumlahbaris=1;
?>
<div class="box_linkterkait_top">
	<div class="judul_modul_linkterkait" align="center">LINK TERKAIT</div>
	<div class="box_linkterkait_main" align="center">
	<?php
	if(sizeof($rsiklan)>0){
		$jumlahlink=6;
		$jumlahbaris=ceil((float) sizeof($rsiklan)/$jumlahlink);
		$posisilink=0;
		for($i=0;$i<$jumlahbaris;$i++){
			?>
			<div id="box_linkterkait_main_<?php echo $i;?>" class="box_linkterkait">
			<?php
			for($n=0;$n<$jumlahlink;$n++){
				$srcgambar=NPAGE.$rsiklan[$posisilink]['folder'].$rsiklan[$posisilink]['nama_baru'];
				$jarakkiri="";
				if($n!=0) $jarakkiri=".jarakkiri";
				if($posisilink<sizeof($rsiklan)){
					?>
					<div class="box_linkterkait_isi <?php echo $jarakkiri;?>" >
						<a target="_blank" href="<?php echo $rsiklan[$posisilink]['tautan'];?>">
							<div class="box_gambar_linkterkait">
								<img src="<?php echo $srcgambar;?>" />
							</div>
						</a>
					</div>
					<?php
				}
				$posisilink++;
			}
			?>
			<div style="clear: both;"></div>
			</div>
			<?php
		}
	}
	
	$hasildata=array("datalink"=>$rsiklan,"jumlahbaris"=>$jumlahbaris);
	$page->addLoad("utamalink.init(".json_encode($hasildata,true).")");
	?>
	<div style="clear: both;"></div>
	</div>
	<div class="iconr_linkterkait" onclick="utamalink.back()"></div>
	<div class="iconn_linkterkait" onclick="utamalink.next()"></div>
</div>