<?php
if (!defined("root")) {
	define("root", $_SERVER['DOCUMENT_ROOT']);
}
session_start();
require(root."/_common.php");
require(root."/_lib/db.php");
require(root."/_lib/main.php");
#require(root."/mobileDetect/Mobile_Detect.php");
require(root."/_lib/bootstraps.php");
$page_id = "promo";
$page_title = "Promo";
$url = trim(cekpost(cleanQuery(isset($_REQUEST["url"])?$_REQUEST["url"]:""), ""));
require(root."/_tpl/html_begin.php");
require(root."/_tpl/tag_head.php");
#require(root."/_tpl/ie_style_exception.php");
/*
 * begin
 * additional style
 * */
cout('<style type="text/css">');
cout('');
cout('</style>');
/*
 * end
 * additional style
 * 
 * v
 * v
 * closing tag head
 * 
 * */
require(root."/_tpl/body_open.php");
cout('<div class="container-fluid common-page">');
	cout('<div class="page-slideshow-container">');
		cout('<div class="page-slideshow dynamic-slide call-1"></div>');
	cout('</div><!--/.page-slideshow-container-->');
	cout('<div class="container-custom-fluid game-lists">');
		cout('<div class="page-big-title">Promotions</div>');
		$rs=array();$q="SELECT * FROM s_promo WHERE isactive=1 ORDER BY tanggal";
		#$rs = callRS($q);
		callRS($rs, $q);
		
		cout('<div class="owl-carousel">');
		for ($i=0;$i<count($rs);$i++) {
			$rsf=array(); $qf="SELECT * FROM u_files WHERE kdpromo='".$rs[$i]["kd"]."'";
			#$rsf = callRS($qf);
			callRS($rsf, $qf);
			
			$rsf=array(); $qf="SELECT * FROM u_files WHERE kdpromo='".$rs[$i]["kd"]."'";
			#$rsf = callRS($qf);
			callRS($rsf, $qf);
			$path = $resized = $isrc = $ititle = $ialt = "";
			if (count($rsf)!=0) {
				$path = str_replace("../../", "/", $rsf[0]["full_path"]);
				$resized = str_replace(".".$rsf[0]["file_ext"]."", "_800.".$rsf[0]["file_ext"]."", $path);
				$resized = $resized."?".time();
				$isrc = $resized;
				$ititle = $rsf[0]["image_title"];
				$ialt = $rsf[0]["image_alt"];
			}
			
			$isi = str_replace("\n", "<br/>", $rs[$i]["isi"]);
			$isi = str_replace("<br/><li>", "<li>", $isi);
			$isi = str_replace("<br/></ol>", "</ol>", $isi);
			$isi = str_replace("<br/></ul>", "</ul>", $isi);
			cout('<div class="row for-footer">');
				cout('<div class="special-box">');
					cout('<div class="row">');
						cout('<div class="col-md-12">');
							if (count($rsf)!=0) {
								cout('<div style="margin:5px;"><img src="'.$isrc.'" alt="" class="img-responsive center-block" /></div>');
							}
						cout('</div><!--/.col-md-12-->');
						cout('<div class="col-md-12">');
							cout('<div class="panel panel-danger text-center greet" style="margin:10px 0;">');
								cout('<div class="panel-heading">'.$rs[$i]["judul"].'</div>');
							cout('</div><!-- /.panel -->');
						cout('</div><!--/.col-md-12-->');
						cout('<div class="col-md-12">');
							cout($isi);
						cout('</div><!--/.col-md-12-->');
					cout('</div><!--/.row-->');
				cout('</div><!--/.special-box-->');
			cout('</div><!--/.row for-footer-->');
		}#end for ($i=0;$i<count($rs);$i++)
		cout('</div><!--/.owl-carousel-->');
		cout('<script>');
			cout('$(window).load(function(){');
				cout('var containerWidth = $(".game-lists").width();');
				cout('$(".game-lists").css({ "width":containerWidth+"px" });');
				cout('setTimeout(function(){');
					cout('var owl = $(".owl-carousel");');
					cout('owl.owlCarousel({');
						cout('margin:10,');
						if (count($rsg)>4) {
							#cout('loop:true,');
						} else {
							cout('items:'.count($rsg).',');
						}
						#cout('autoplay:true,');
						#cout('autoplayTimeout:4000,');
						#cout('autoplayHoverPause:false,');
						cout('responsive:{');
							cout('0:{ items:1 },');
							cout('600:{ items:3 },');
							cout('1000:{ items:4 }');
						cout('}');
					cout('});');
				cout('}, 100);');
			cout('});');
		cout('</script>');
	cout('</div><!--/.container-custom-fluid game-lists-->');
cout('</div><!--/.container-fluid common-page-->');

require(root."/_tpl/body_close.php");
?>