<?php 
	//error_reporting(E_ERROR|E_PARSE);
	include("../db_function.php");
	if (isset($_GET['p']))
			$p=$_GET['p'];
	else
			$p='';		
	if(isset($_GET['action']))
            $action=$_GET['action'];
	else
            $action='0';
	if(isset($_GET['search']))
            $search=$_GET['search'];
	else
            $search='0';		
	include("Visitor_Counter/counter.php");

	// Fetch Active Logos for Header Banner Slideshow
	$logo_banners = array();
	$logo_query = mysql_query("SELECT * FROM tbllogo WHERE status=1 ORDER BY id DESC");
	if ($logo_query) {
		while ($row_logo = mysql_fetch_array($logo_query)) {
			if (!empty($row_logo['image'])) {
				$logo_banners[] = $row_logo;
			}
		}
	}
	if (empty($logo_banners)) {
		$logo_banners[] = array(
			'image' => 'logo.png',
			'title' => 'Love Wedding Logo',
			'link'  => 'index.php'
		);
	}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://ogp.me/ns#" xmlns:fb="http://www.facebook.com/2008/fbml">
  <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <?php include("_tpl/share.php"); ?>
  <link rel="shortcut icon" href="images/icon.png" type="image/x-icon" />
  <meta name="keywords" content="Love Wedding, Wedding in cambodia, Wedding, www.loveweddingcam.com">
  <meta name="author" content="CITA - www.thecita.net">
  <link rel="preconnect" href="https://fonts.googleapis.com">
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
  <link href="https://fonts.googleapis.com/css2?family=Koulen&family=Roboto:ital,wght@0,100..900;1,100..900&display=swap" rel="stylesheet">
  <link rel="stylesheet" type="text/css" href="css/templates.css" /> 
  <?php include("_tpl/config.php"); ?>
  
  <script type="text/javascript">var switchTo5x=true;</script>
  <script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script>
  <script type="text/javascript">stLight.options({publisher: "ffb5bb35-25a5-4381-a999-69e4bd8ba465", doNotHash: false, doNotCopy: false, hashAddressBar: false});</script>
</head>
<body>
<div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v18.0&appId=590539854337968";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

	 <div id="bg_ann">
	    <div id="box_ann">
		   <div id="_ann_title">សេចក្តីជូនដំណឹង</div>
		   <div id="_ann_content"><div id="_ann_lamp"></div>
		   <?php $announcement = mysql_fetch_array(mysql_query("Select * From tbltext WHERE page='announcement'")); ?>
		      <ul id="webticker">			    
					<li style="height: auto; border: 0px solid #ff0000;">
					    <?php echo $announcement['detail']; ?>
					</li>	              	
			   </ul>			   
		   </div>
		</div>
	 </div>
	 <div id="main">
		<div id="cover_logo">
		   <div id="home_logo_slideshow" style="position: relative; width: 100%; height: 100%; overflow: hidden; background: #ffffff;">
				<div id="home_logo_track" style="display: flex; width: <?php echo (count($logo_banners) * 100); ?>%; height: 100%; transition: transform 0.6s cubic-bezier(0.25, 1, 0.5, 1);">
				<?php foreach ($logo_banners as $idx => $l_banner): 
					$l_link = !empty($l_banner['link']) ? $l_banner['link'] : 'index.php';
					$l_title = !empty($l_banner['title']) ? $l_banner['title'] : 'Love Wedding';
				?>
				<div class="home-logo-slide" style="width: <?php echo (100 / count($logo_banners)); ?>%; height: 100%; flex-shrink: 0; background: #ffffff;">
					<a href="<?php echo htmlspecialchars($l_link); ?>" style="display: block; width: 100%; height: 100%; text-decoration: none;">
						<img src="images/<?php echo $l_banner['image']; ?>" style="width: 100%; height: 100%; object-fit: cover; border: 0; display: block;" alt="<?php echo htmlspecialchars($l_title); ?>" />
					</a>
				</div>
				<?php endforeach; ?>
				</div>

				<?php if (count($logo_banners) > 1): ?>
				<div class="home-logo-dots" style="position: absolute; bottom: 10px; right: 15px; z-index: 20; display: flex; gap: 6px;">
					<?php foreach ($logo_banners as $idx => $l_banner): ?>
						<span class="home-logo-dot" onclick="goHomeLogoSlide(<?php echo $idx; ?>)" style="width: 11px; height: 11px; border-radius: 50%; background: <?php echo ($idx === 0) ? '#fc5ea5' : 'rgba(0,0,0,0.2)'; ?>; border: 1px solid #fc5ea5; cursor: pointer; transition: background 0.3s; display: inline-block;"></span>
					<?php endforeach; ?>
				</div>
				<script type="text/javascript">
				(function() {
					var track = document.getElementById('home_logo_track');
					var slides = document.querySelectorAll('#home_logo_slideshow .home-logo-slide');
					var dots = document.querySelectorAll('.home-logo-dots .home-logo-dot');
					if (!track || !slides || slides.length <= 1) return;
					var cur = 0;
					var stepPct = 100 / slides.length;
					window.goHomeLogoSlide = function(n) {
						cur = n;
						track.style.transform = 'translateX(-' + (cur * stepPct) + '%)';
						for (var i = 0; i < dots.length; i++) {
							if (dots[i]) {
								dots[i].style.background = (i === cur) ? '#fc5ea5' : 'rgba(0,0,0,0.2)';
							}
						}
					};
					setInterval(function() {
						cur = (cur + 1) % slides.length;
						window.goHomeLogoSlide(cur);
					}, 4000);
				})();
				</script>
				<?php endif; ?>
		   </div>
		</div>
	    <div id="cover_ads_left">
			<div id="shadow_left"></div>
			<div id="ads_left">			  
			  <?php 
			   $adv_left=mysql_query("Select * From tbladvertise WHERE type='left'"); 
			   ?>			  
			   <?php while($row_adv_left=mysql_fetch_array($adv_left)){ 
					if(!empty($row_adv_left['link'])){
						echo '<a href="'.htmlspecialchars($row_adv_left['link']).'" target="_blank"><div id="ads_img">
						<img src="images/ads/'.$row_adv_left['image'].'" alt="Left Ad" />
						</div></a>';
					}else{
						echo '<div id="ads_img">
						     <img src="images/ads/'.$row_adv_left['image'].'" alt="Left Ad" />
						</div>';
					}
				} 
			  ?>
			</div>
		</div>
		<div id="content_center">
		   <div class="clear" style="height: 6px;"></div>
		   
		   <?php include("_tpl/ads_center_top.php"); ?>
		   <div <?php if ($p=='' || $p=='home'){?> id=""<?php }else{ ?> id="txt" <?php } ?> class="box_menu"> 
		      <?php include("_tpl/menu.php"); ?>
			  <div id="menu_shadow"></div>
		   </div>
		   <div class="clear" style="height: 30px;"></div>
		   <?php
			   if ($p=='' || $p=='home'){include("_tpl/home.php");}
			   else if ($p=='service'){include("_tpl/service.php");}     
			   else if ($p=='clothes'){include('_tpl/clothes.php');}				 
			   else if ($p=='beauty_women' || $p=='beauty'){include('_tpl/beauty_women.php');}				 
			   else if ($p=='news'){include('_tpl/news.php');}				 
			   else if ($p=='all'){include('_tpl/all_des.php');}				 
			   else {include("_tpl/home.php");}
			?>
		   
		   <?php include("_tpl/ads_center_bottom.php"); ?>
		   <div id="bg_facebook_visitors">
		        <?php include("_tpl/visitor_facebook.php"); ?>		
		   </div>
		   <div class="clear" style="height: 40px;"></div>
		</div>
		<div id="cover_ads_right">
		   <div id="shadow_right"></div>
		   <div id="ads_right">		        			 
           <?php 
			   $adv_right=mysql_query("Select * From tbladvertise WHERE type='right'"); 
		   ?>			  
		   <?php while($row_adv_right=mysql_fetch_array($adv_right)){ 
				if(!empty($row_adv_right['link'])){
					    echo '<a href="'.htmlspecialchars($row_adv_right['link']).'" target="_blank"><div id="ads_img">
						     <img src="images/ads/'.$row_adv_right['image'].'" alt="Right Ad" />
						</div></a>';
					}else{
						echo '<div id="ads_img">
						   <img src="images/ads/'.$row_adv_right['image'].'" alt="Right Ad" />
						</div>';
					}
				} 
		  ?>
		   </div>
		</div>
		<div class="clear"></div>
	 </div>
	 <div id="bg_footer">
	    <?php include("_tpl/footer.php"); ?>
	 </div>
	 <div title="Go top" id="gotop"><img src="images/gotop.png" style="border: none;"/></div>
	 <div title="Go bottom" id="gobottom"><img src="images/gobottom.png" style="border: none;"/></div>
</body>
</html>
