<?php
ob_start();
header('Refresh: 1800');
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: private, no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
if($this->session->userdata('jenis_pengadilan')==1){
	$cssKiri="kotak_kiri";
	$cssKanan="kotak_kanan";
} else if ($this->session->userdata('jenis_pengadilan')==2){
	$cssKiri="kotak_kiri3";
	$cssKanan="kotak_kanan3";
} else if ($this->session->userdata('jenis_pengadilan')==3){
	$cssKiri="kotak_kiri2";
	$cssKanan="kotak_kanan2";
} else if ($this->session->userdata('jenis_pengadilan')==4){
	$cssKiri="kotak_kiri2";
	$cssKanan="kotak_kanan2";
}
function strposa($haystack, $needle, $offset=0) {
    if(!is_array($needle)) $needle = array($needle);
    foreach($needle as $query) {
        if(strpos(strtolower($haystack), strtolower($query), $offset) !== false) return true; // stop on first true result
    }
    return false;
}
$smarttv = array('AppleCoreMedia', 'AppleTV', 'CrKey', 'Roku', 'TV');
$ua = $_SERVER['HTTP_USER_AGENT'];
$isSmartTV = strposa($ua, $smarttv, 1)?true:false;
?>
<style>
*{font-family:Century Gothic, sans-serif;}
body{ }
#contain,#contain_pid  {
  height:100%;
  <?php 
	if(!$isSmartTV){
		echo 'overflow-y: hidden;';
	}
  ?>  
}
#table_scroll,#table_scroll_pid {
  width: 100%;
  margin-top: 10px;
  margin-bottom: 10px;
  border-collapse: collapse;
}

.th { font: bold 20px "Century Gothic", Century Gothic, Geneva, AppleGothic, sans-serif; color: white; font-weight: bold; color: #EEEEEE; border-right: 1px solid #C1DAD7; border-bottom: 1px solid #C1DAD7; border-top: 1px solid #C1DAD7; letter-spacing: 2px; text-transform: uppercase; text-align: center; padding: 5px 5px 5px 5px; background: green; }
.td { font: bold 18px "Century Gothic", Century Gothic, Geneva, AppleGothic, sans-serif; color: white; border-right: 0.1em solid #C1DAD7; border-bottom: 0.1em solid #C1DAD7; border-left: 0.1em solid #C1DAD7; border-top: 0.1em solid #C1DAD7; padding: 6px 6px 6px 6px; }
.kotak_kiri{
    float:left;
	width:48.5%;
    height:80%;
    border-right: 15px solid #444;
    padding: 10px;
	position:relative;
}

.kotak_kanan{
     float:right;
     width:47.5%;
     height:80%;
     padding-right: 10px;
	 position:relative;
}

.kotak_kiri2{
    float:left;
	width:39%;
    height:86%;
}

.kotak_kanan2{
	float:right;
    width:60%;
    height:86%;
    padding-right: 10px;
    position: relative;
}
.kotak_kiri3{
    float:left;
	width:60%;
    height:80%;
	position:relative;
}

.kotak_kanan3{
	float:right;
    width:39%;
    height:86%;
	padding-right: 10px;
    position: relative;
}

.footer span{
	position: absolute;
	float:right;
	right: 30px;
	background: #222;
	border:1px solid #111;
	padding:10px;
	top:-35px;
	text-shadow: 0 1px 0 #ccc, 0 1px 0 #c9c9c9;
	color: #fff;
	text-align: left;
	font-size: 30px;
	border-radius:3px;
	box-shadow: 2px 2px 3px #000;
}


</style>
<script type="text/javascript" src="<?php echo base_url();?>resources/js/jquery-1.7.1.min.js"></script>
<div style="width:100%;height:100%">
	<div class="<?php echo $cssKiri; ?>">
		<?php if($this->session->userdata('jenis_pengadilan')==1 OR $this->session->userdata('jenis_pengadilan')==2){ ?>
		<?php
		if($slidePidana->num_rows==0){
			echo "<div id='contain_pid' align='center' style='color:#fff;'><b><h1>TIDAK ADA JADWAL SIDANG</h1></b></div>";
		} else {
			$a=0;
			if($isSmartTV){
				echo '<marquee direction="up" scrolldelay="150" height="100%">';
			}
			echo '<div id="contain_pid">';
			foreach ($slidePidana->result() as $rowPidana) {
				$a++;
				$alurPerkara = $rowPidana->IDAlurPerkara;
				if($alurPerkara=='119'){
					$judulPihak1="PEMOHON";
					$judulPihak2="TERHOHON";
				} else {
					$judulPihak1=($this->session->userdata('jenis_pengadilan')==2)?"ODITUR":"PENUNTUT UMUM";
					$judulPihak2="TERDAKWA";
				}

				echo "<table cellspacing='0' align='center' border='1' id='table_scroll_pid'>";
				echo "<tr>";
				echo "<td class='td' style='width:5%;' rowspan='8' align='center'>".$a."</td>";
				echo "<td class='td' style='width:25%;'>NO PERKARA</td>";
				echo "<td class='td' style='width:70%; color:red;'>".$rowPidana->noPerkara."</td>";
				echo "</tr>";
				if($this->session->userdata('jenis_pengadilan')==2){
				echo "<tr>";
				echo "<td class='td' style='width:25%;'>JAM SIDANG</td>";
				echo "<td class='td' style='width:70%;'>".$rowPidana->jamSidang."</td>";
				echo "</tr>";	
				echo "<tr>";
				echo "<td class='td' style='width:25%;'>MAJELIS HAKIM</td>";
				echo "<td class='td' style='width:70%;'>".$rowPidana->namaHakim."</td>";
				echo "</tr>";
				echo "<tr>";
				echo "<td class='td' style='width:25%;'>PANITERA</td>";
				echo "<td class='td' style='width:70%;'>".$rowPidana->namaPanitera."</td>";
				echo "</tr>";
				}

				echo "<tr>";
				echo "<td class='td' style='width:25%;'>".$judulPihak1."</td>";
				echo "<td class='td' style='width:70%;'>".$rowPidana->pihak1."</td>";
				echo "</tr>";
				echo "<tr>";
				echo "<td class='td' style='width:25%;'>".$judulPihak2."</td>";
				echo "<td class='td' style='width:70%;'>".$rowPidana->pihak2."</td>";
				echo "</tr>";
				echo "<tr>";
				echo "<td class='td' style='width:25%;'>AGENDA SIDANG</td>";
				echo "<td class='td' style='width:70%;'>".$rowPidana->agendaSidang."</td>";
				echo "</tr>";
				echo "<tr>";
				echo "<td class='td' style='width:25%;'>RUANG SIDANG</td>";
				echo "<td class='td' style='width:70%;'>".(!empty($rowPidana->ruangSidang)?"$rowPidana->ruangSidang":"Belum Ditentukan")."</td>";
				echo "</tr>";
				echo "</table>";
				echo "<br/>";
			}
			echo "<br/>";
			echo "<br/>";
			echo "<br/>";
			echo "<br/>";
			echo "</div>";
			if($isSmartTV){
				echo '</marquee>';
			}
		}
		?>
		<?php } else { ?>
			<div class="sp-container" >
            	<div class="sp-content">
            			<br/>
                    	<div class="sp-globe"></div>
                        <h2 class="frame-1">SELAMAT DATANG DI</h2>
                        <h2 class="frame-2"><?php echo $this->session->userdata('namaPN'); ?></h2>
                        <div class="sp-globe"></div>
                        <br/><br/><br/><br/><br/><br/><br/><br/><br/>
                        <h2 class="frame-3">PELAYANAN PRIMA</h2>
                        <h2 class="frame-4">PUTUSAN BERKUALITAS</h2>
                </div>
            </div>
		<?php } ?>
	</div>

	<div class="<?php echo $cssKanan; ?>">
		<?php 
		if($this->session->userdata('jenis_pengadilan')==1 OR $this->session->userdata('jenis_pengadilan')==3 OR $this->session->userdata('jenis_pengadilan')==4){
			if($this->session->userdata('jenis_pengadilan')==3){
				if($isSmartTV){
					echo '<marquee direction="up" scrolldelay="150" height="100%">';
				}
			echo '<div id="contain">';
				if($slidePerdata->num_rows==0){
					echo "<table cellspacing='0' align='center' border='1'>";
					echo "<tr>";
					echo "<td class='td' style='width:5%;' align='center'>JADWAL SIDANG TERBUKA UNTUK UMUM</td>";
					echo "</tr>";
					echo "</table>"; 
					echo "<div align='center' style='color:#fff;'><b><h1>TIDAK ADA JADWAL SIDANG</h1></b></div>";
				} else {
				$b=0;
				
					echo "<table cellspacing='0' align='center' border='1'>";
					echo "<tr>";
					echo "<td class='td' style='width:5%;'align='center'>JADWAL SIDANG TERBUKA UNTUK UMUM</td>";
					echo "</tr>";
					echo "</table>";
					
				foreach ($slidePerdata->result() as $rowPerdata) { $b++;
					echo "<table id='table_scroll' cellspacing='0' align='center' border='1'>";
					echo "<tr>";
					echo "<td class='td' style='width:5%;' rowspan='5' align='center'>".$b."</td>";
					echo "<td class='td' style='width:25%;'>NO PERKARA</td>";
					echo "<td class='td' style='width:70%; color:red;'>".$rowPerdata->noPerkara."</td>";
					echo "</tr>";
					echo "<tr>";
					echo "<td class='td' style='width:25%;'>HAKIM /<br/>PANITERA PENGGANTI</td>";
					echo "<td class='td' style='width:70%;'>".$rowPerdata->namaHakim."<br/>PP: ".$rowPerdata->namaPanitera."</td>";
					echo "</tr>";
					echo "<tr>";
					echo "<td class='td' style='width:25%;'>PIHAK</td>";
					echo "<td class='td' style='width:70%;'>Penggugat : " .$rowPerdata->penggugat."<br /> Tergugat : ".$rowPerdata->tergugat."<br /> ".$rowPerdata->turut_tergugat."</td>";
					echo "</tr>";
					echo "<tr>";
					echo "<td class='td' style='width:25%;'>AGENDA SIDANG</td>";
					echo "<td class='td' style='width:70%;'>".$rowPerdata->agendaSidang."</td>";
					echo "</tr>";
					echo "<tr>";
					echo "<td class='td' style='width:25%;'>RUANG SIDANG</td>";
					echo "<td class='td' style='width:70%;'>".(!empty($rowPerdata->ruangSidang)?"$rowPerdata->ruangSidang":"Belum Ditentukan")."</td>";
					echo "</tr>";
					echo "</table>";
					echo "<br/>";
				}
					
			}
			if($slidePersiapan->num_rows > 0){
				$c=0;
					echo "<table cellspacing='0' align='center' border='1'>";
					echo "<tr>";
					echo "<td class='td' style='width:5%;' align='center'>JADWAL PEMERIKSAAN PERSIAPAN</td>";
					echo "</tr>";
					echo "</table>";
				foreach ($slidePersiapan->result() as $rowPersiapan) { $c++;
					echo "<table id='table_scroll' cellspacing='0' align='center' border='1'>";
					echo "<tr>";
					echo "<td class='td' style='width:5%;' rowspan='5' align='center'>".$c."</td>";
					echo "<td class='td' style='width:25%;'>NO PERKARA</td>";
					echo "<td class='td' style='width:70%; color:red;'>".$rowPersiapan->noPerkara."</td>";
					echo "</tr>";
					echo "<tr>";
					echo "<td class='td' style='width:25%;'>HAKIM /<br/>PANITERA PENGGANTI</td>";
					echo "<td class='td' style='width:70%;'>".$rowPersiapan->namaHakim."<br/>PP: ".$rowPersiapan->namaPanitera."</td>";
					echo "</tr>";
					echo "<tr>";
					echo "<td class='td' style='width:25%;'>PIHAK</td>";
					echo "<td class='td' style='width:70%;'>".$rowPersiapan->paraPihak."</td>";
					echo "</tr>";
					echo "<tr>";
					echo "<td class='td' style='width:25%;'>AGENDA SIDANG</td>";
					echo "<td class='td' style='width:70%;'>".$rowPersiapan->agendaSidang."</td>";
					echo "</tr>";
					echo "<tr>";
					echo "<td class='td' style='width:25%;'>RUANG SIDANG</td>";
					echo "<td class='td' style='width:70%;'>RUANG PEMERIKSAAN PERSIAPAN</td>";
					echo "</tr>";
					echo "</table>";
					echo "<br/>";
				}
			}
			echo '</div>';
			if($isSmartTV){
				echo '</marquee>';
			}
			}else if($this->session->userdata('jenis_pengadilan')==1 OR $this->session->userdata('jenis_pengadilan')==4){
				if($slidePerdata->num_rows==0){
					echo "<div id='contain' align='center' style='color:#fff;'><b><h1>TIDAK ADA JADWAL SIDANG</h1></b></div>";
				} else {
					$b=0;
					if($isSmartTV){
						echo '<marquee direction="up" scrolldelay="150" height="100%">';
					}
					echo '<div id="contain">';
					foreach ($slidePerdata->result() as $rowPerdata) { $b++;
						$alurPerkara = $rowPerdata->IDAlurPerkara;
						if($alurPerkara=='2' || $alurPerkara=='10' || $alurPerkara=='12' || $alurPerkara=='13' || $alurPerkara=='14' || $alurPerkara=='16' || $alurPerkara=='622'){
						$judulPihak1nya="Pemohon";
						$judulPihak2nya="Termohon";
						} else {
						$judulPihak1nya="Penggugat";
						$judulPihak2nya="Tergugat";
						}
					
						echo "<table cellspacing='0' align='center' border='1px' id='table_scroll'>";
						echo "<tr style='border-bottom=1px solid #fff'>";
						echo "<td class='td' style='width:5%;' rowspan='5' align='center'>".$b."</td>";
						echo "<td class='td' style='width:25%;'>NO PERKARA</td>";
						echo "<td class='td' style='width:70%; color:yellow;'>".$rowPerdata->noPerkara."</td>";
						echo "</tr>";				
						/**
						echo "<tr>";
						echo "<td class='td' style='width:25%;'>PIHAK</td>";
						echo "<td class='td' style='width:70%;'>Penggugat : " .$rowPerdata->penggugat."<br /> Tergugat : ".$rowPerdata->tergugat."<br /> ".$rowPerdata->turut_tergugat."</td>";
						echo "</tr>";
						**/
						echo "<tr>";
						echo "<td class='td' style='width:25%;'>".$judulPihak1nya."</td>";
						echo "<td class='td' style='width:70%;'>".$rowPerdata->penggugat."</td>";
						echo "</tr>";
						echo "<tr>";
						echo "<td class='td' style='width:25%;'>".$judulPihak2nya."</td>";
						echo "<td class='td' style='width:70%;'>".$rowPerdata->tergugat."<br />".$rowPerdata->turut_tergugat."</td>";
						echo "</tr>";
						
						echo "<tr>";
						echo "<td class='td' style='width:25%;'>AGENDA SIDANG</td>";
						echo "<td class='td' style='width:70%;'>".$rowPerdata->agendaSidang."</td>";
						echo "</tr>";
						echo "<tr style='border-bottom=1px solid #fff'>";
						echo "<td class='td' style='width:25%;'>RUANG SIDANG</td>";
						echo "<td class='td' style='width:70%;'>".(!empty($rowPerdata->ruangSidang)?"$rowPerdata->ruangSidang":"Belum Ditentukan")."</td>";
						echo "</tr>";
						echo "</table>";
						echo "<br/>";
					}
					echo "<br/>";
					echo "<br/>";
					echo "<br/>";
					echo "<br/>";
					echo '</div>';
					if($isSmartTV){
						echo '</marquee>';
					}
				}			
			}				
		}else{ ?>
			<div class="sp-container" >
            	<div class="sp-content">
            			<br/>
                    	<div class="sp-globe"></div>
                        <h2 class="frame-1">SELAMAT DATANG DI</h2>
                        <h2 class="frame-2"><?php echo $this->session->userdata('namaPN'); ?></h2>
                        <div class="sp-globe"></div>
                        <br/><br/><br/><br/><br/><br/><br/><br/><br/>
                        <h2 class="frame-3">PELAYANAN PRIMA</h2>
                        <h2 class="frame-4">PUTUSAN BERKUALITAS</h2>
                </div>
            </div>
		<?php } ?>
	</div>
</div>

<?php 
$tickerCaption="Berita MA RI";
$tickerTipe="mari";
if($this->session->userdata('jenis_pengadilan')==1){
	$tickerCaption="Berita Badilum";
	$tickerTipe="badilum";
}else if($this->session->userdata('jenis_pengadilan')==2 || $this->session->userdata('jenis_pengadilan')==3 ){
	$tickerCaption="Berita Badimiltun";
	$tickerTipe="badimiltun";
}else if($this->session->userdata('jenis_pengadilan')==4){
	$tickerCaption="Berita Badilag";
	$tickerTipe="badilag";
}

if($this->session->userdata('jenis_pengadilan')==1 && !$isSmartTV){
?>
<script>
$(document).ready(function() {
  gulunginBro("contain_pid",1,20);
  gulunginBro("contain",1,20);
});
</script>

<?php }else if($this->session->userdata('jenis_pengadilan')==2 && !$isSmartTV) {?>
<script>
$(document).ready(function() {
  gulunginBro("contain_pid",1,20);
});
</script>
<?php }else {
	if(!$isSmartTV){
?>
<script>
$(document).ready(function() {
  gulunginBro("contain",1,20);
});
</script>
<?php }} ?>

<link rel="stylesheet" type="text/css" href="resources/slideshow/newsTicker/ticker.css">
<div class="footer" style="z-index:99;position: absolute;bottom:0px;width: 100%;height:30px;">
<div class="ticker-container">
  <div class="ticker-caption">
    <p><?php echo $tickerCaption; ?></p>
  </div>
<?php if($isSmartTV){?>
  <div id="zenews" style="font-size: 1.2em;"></div>
<?php }else{?>
	<ul id="zenews">
		<li>&nbsp;</li>
	</ul>
<?php }?>
</div>
<span class="clock"></span>
</div>
<script src="resources/slideshow/newsTicker/jquery.li-scroller.1.0.js"></script>
<script>
var myjson;
var jam;
$(document).ready(function(){
	loadingNews();
	clock();
});
<?php if(!$isSmartTV){?>
function gulunginBro(idGulungan, step=5, speed=150){
	if(document.getElementById(idGulungan) === false){return}
	var stripHeight = 0;
	var $pidContainer = $(document.getElementById(idGulungan));
	var containerTop = $pidContainer.position().top;
	var containerHeight = $pidContainer.parent().height();
	var containerBottom = containerTop + containerHeight;
	$pidContainer.find("table").each(function(i){
				stripHeight += $(this).outerHeight(true) +40;
				});
	/*			
	console.log("Strip Height : "+stripHeight);
	console.log("Container Top : "+containerTop);
	console.log("Container Height : "+containerHeight);
	console.log("Container Bottom : "+containerBottom);
	*/
	if(stripHeight < containerBottom){return}
	
	$pidContainer.css({"width":"95%","z-index":-2,"height":stripHeight,"position":"absolute", "top":containerBottom});
	setInterval(function(){
		var tail = $pidContainer.position().top + stripHeight;
		if(tail <= containerTop){
			$pidContainer.css({"z-index":-2,"position":"absolute", "top":containerBottom});
		}
		var top = parseFloat($pidContainer.position().top) - step;
		$pidContainer.css({"z-index":-2,"position":"absolute", "top":top+"px"});
		/*
		console.log("top : "+top);
		console.log("tail : "+tail);
		*/
	}, speed);
}

<?php }?>

function loadingNews(){
	var container = $('#zenews');
	var spinner = loadingProgress('Mengambil Berita ...');
	var datanews = '';
	/*
	$.ajax({
		type: "POST",
		url: "resources/slideshow/newsTicker/",
		data: "tipe=<?php echo $tickerTipe;?>",
		success: function( data ) {
			clearInterval(spinner);
			$('#zenews').html('');
			$.each(data.items, function(i, f) {
				var shortdesc = f.description_text.substr(0, 100);
				datanews = datanews+f.title+'</li>&nbsp;&#8212;&#8212;&nbsp;';
				<?php if(!$isSmartTV){?>
				container.append('<li>'+ f.title +'</li>&nbsp;&#8212;&#8212;&nbsp;');
				<?php }?>
			});
			<?php if($isSmartTV){?>
				container.append('<marquee direction="left" scrolldelay="100" width="100%">'+ datanews +'</marquee>');
			<?php }?>
			myjson = data.items;
			<?php if(!$isSmartTV){?>
			$("ul#zenews").liScroll();
			<?php }?>
		},
		error: function() {
			container.html('Gagal mengambil berita'); return;
		},
		dataType: "json",
		crossDomain: "true"
	});
	*/
	$.post('resources/slideshow/newsTicker/', {tipe:'<?php echo $tickerTipe;?>'})
	.done(function( data ) {
		clearInterval(spinner);
		$('#zenews').html('');
		$.each(data.items, function(i, f) {
			var shortdesc = f.description_text.substr(0, 100);
			datanews = datanews+f.title+'</li>&nbsp;&#8212;&#8212;&nbsp;';
			<?php if(!$isSmartTV){?>
			container.append('<li>'+ f.title +'</li>&nbsp;&#8212;&#8212;&nbsp;');
			<?php }?>
		});
		<?php if($isSmartTV){?>
			container.append('<marquee direction="left" scrolldelay="100" width="100%">'+ datanews +'</marquee>');
		<?php }?>
		myjson = data.items;
		<?php if(!$isSmartTV){?>
		$("ul#zenews").liScroll();
		<?php }?>
	})
	.fail(function() {
		container.html('Gagal mengambil berita'); return;
	});
	
}

function loadingProgress(msg){
	var i=0;
	var spinner = setInterval( function() {
	i++;
	var text = msg;
    if ( i==1 ){text = text +" /";
    }else if(i==2){text = text +" -";
	}else if(i==3){text = text +" \\";
	}else if(i==4){text = text +" |";
	}else if(i==5){text = text +" /";
	}else if(i==6){text = text +" -";
	}else if(i==7){text = text +" \\";
	}else if(i==8){text = text +" |";
	}else if(i>8){i=0;}
	$('#zenews').html('<li>'+text+'</li>');
	
    }, 200);
	return spinner;
}

function clock(){
	var now     = new Date();
	var hour    = now.getHours();
	var minutes = now.getMinutes();
	var second = now.getSeconds();
	hour = hour < 10 ? '0'+hour : hour;
	minutes = minutes < 10 ? '0'+minutes : minutes;
	second = second < 10 ? '0'+second : second;
	$(".clock").html(hour+":"+minutes+":"+second);
	jam=setTimeout('clock()', 1000);
	setInterval(function(){ window.location.reload(true); },60*60*1000);
}
</script>