<?php
if(!defined('IN_GATEWEI')){
	exit('Access Denied'); 
}
?>
<?php include($templatedir."config.inc.php");?>
<div class="sitead" id="sitead">
			<div id="adcontent">
			<?php foreach($adimgs as $key => $val){?>
				<div id="con_<?php echo $key + 1?>" style="display:<?php echo $val['display']?>"><a href="<?php echo $val['url']?>" target="_blank"><img src="<?php echo $val['imgsrc']?>" alt="<?php echo $val['imgname']?>"/></a></div>
			<?php }?>   
			</div>
</div>

<script type="text/javascript">
function setTab(curitem)
{
	itemCnt=<?php echo $imgcount?> ;
	for(i=1;i<=itemCnt;i++){
	eval("ele_hide = document.getElementById('con_" + i +"')");
	if(ele_hide) ele_hide.style.display = "none";
	}
	eval("ele_play = document.getElementById('con_" + curitem + "')");
	if(ele_play) ele_play.style.display = "block";
	
}
 function setLoop(){
  try{
   var oScroll = document.getElementById('sitead');
   oScroll.noWrap = true;
   oScroll.onmouseover = function(e){pause = true;};
   oScroll.onmouseout = function(e){pause = false;};
   setInterval('scrollTopHome()', 6000);
   }catch(e){alert(e.toString());}
 }
 function scrollTopHome(){
  if(pause) return;
  startIndex += 1;
  if(startIndex > con_num){startIndex = 1;}
  setTab(startIndex);
 } 
 var pause = false;
 var con_num = <?php echo $imgcount?> ;
 var startIndex = 1;
 setLoop();
</script>
