<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가 
include_once("$g4[path]/lib/thumb.lib.php");

$thumb_width = "380"; //썸네일 가로길이
$thumb_height = "240"; //썸네일 세로길이
$quality= 90; //썸네일 퀄리티
$filter[type] = 99;
$filter[arg1] = 100;
$filter[arg2] = 1;
$filter[arg3] = 2;

$list_content = "410"; //내용길이
?>
<link rel="stylesheet" href="<?=$latest_skin_path?>/css/common.css"/>
<script>var toggleType = '';</script>
<script type="text/javascript" src="<?=$latest_skin_path?>/js/banner.js"></script>
<div id="bestRolling">
	<div id="bestBanner">
<!-- 목록 -->
<? 
	for ($i=0; $i<count($list); $i++) { 
	$j = $i+1;
	$file = $list[$i][file][0][path] .'/'. $list[$i][file][0][file];
	if($list[$i][file][0][view]) { // 첨부파일이 있으면
		$src = $list[$i][file][0][path]."/".$list[$i][file][0][file];
		$thumb = thumbnail($src, $thumb_width, $thumb_height, 0, 1, $quality, 0, "",  $filter, $noimg);
	}  else { // 치에디터 파일 추출
		$edit_img = $list[$i]['wr_content'];
		if (eregi("data/cheditor4[^<>]*\.(gif|jp[e]?g|png|bmp)", $edit_img, $tmp)) {
			$file = $g4[path].'/' . $tmp[0]; // 파일명
			$thumb = thumbnail($file, $thumb_width, $thumb_height, 0, 1, $quality, 0, "",  $filter, $noimg);
		}
	}


//이미지
    if (file_exists($thumb))
        $thumfile = "<img src='{$thumb}' border='0' width='{$thumb_width} height='{$thumb_height} \>";
		else
		//이미지가 없으면
		$thumfile="<img src='{$latest_skin_path}/img/no_image.gif' width='{$thumb_width}' height='{$thumb_height}'>";
		//이미지가 아니네
        if(preg_match("/\.(swf|wma|asf)$/i","$file") && file_exists($file)){
		$thumfile = "<script>doc_write(flash_movie('$file', 'flash$i', '$thumb_width', '$thumb_height', 'transparent'));</script>"; 
	    }    
?>   
					<div id="banner<?=$j?>" class="ready">
						<div class="bestPhoto">						    
						    <a href='<?=$list[$i][href]?>'><?=$thumfile?></a>
						</div>
						<!--<div class="bestTitle1"><?//=$list[$i]['ca_name']?></div>-->
						<div class="bestTitle2"><a href='<?=$list[$i][href]?>'><?=$list[$i][subject]?></a></div>
						<div class="bestPara"><?=cut_str(strip_tags($list[$i]['wr_content']),$list_content)?></div>
					</div>
<?}?>
<? if (count($list) == 0) { echo "<div>게시물이 없습니다.</div>"; } ?>
					<ul id="bestNav">
						<li>
							<a href="#prev" class="banArrow">
								<img src="<?=$latest_skin_path?>/img/btn_best_prev_on.png" alt="prev" class="png24 on hidden"/>
								<img src="<?=$latest_skin_path?>/img/btn_best_prev_off.png" alt="prev" class="png24 off"/>
							</a>
						</li>
<? 
	for ($i=0; $i<count($list); $i++) { 
?>
						<li>
							<img src="<?=$latest_skin_path?>/img/btn_circle_red.png" alt="" class="png24 on hidden"/>
							<img src="<?=$latest_skin_path?>/img/btn_circle_gray.png" alt="" class="png24 off"/>
						</li>
<? } ?>
						<li>
							<a href="#next" class="banArrow">
								<img src="<?=$latest_skin_path?>/img/btn_best_next_on.png" alt="next" class="png24 on hidden"/>
								<img src="<?=$latest_skin_path?>/img/btn_best_next_off.png" alt="next" class="png24 off"/>
							</a>
						</li>
					</ul>
				</div>
			</div><!-- // bestRolling -->

<script type="text/javascript">
<!--
function bestBanner() {
	var $bestBanner = $('#bestBanner');
	if($bestBanner.length == 0) return;
	var num = 1;
	var timer = null;
	var beforeID = '#banner1';
	var currentID = '#banner2';
	var $ready = $('.ready', $('#bestBanner'));
	var $bestNavLi = $('#bestNav > li');
	isVideo = false;


	$ready.eq(0).removeClass('ready').addClass('active');
	$bestNavLi.eq(1).children('img:first').removeClass('hidden');
	$bestNavLi.eq(1).children('img:last').addClass('hidden');

	$('.banArrow').hover(function() {

		var $this = $(this);
		if(isMobiles()) {
			goPrevNext ($this);
		}
		activeObjViewHide($this, 'off>on', 'hidden');

	}, function() {

		var $this = $(this);
		activeObjViewHide($this, 'on>off', 'hidden');

	}).click(function() {

		var $this = $(this);
		goPrevNext ($this);

		return false;
	});

	function goPrevNext ($this) {
		$(':animated').stop(false, true);
		isVideo = false;

		var href = $this.attr('href');

		if(href == '#prev') {
			num--;
		} else {
			num++;
		}

		num = Math.abs(num);
		if(num > <?=count($list)?>) {
			num = 1;
		} else if(num == 0) {
			num = <?=count($list)?>;
		}

		currentID = '#banner'+num;
		rolling(num, beforeID, currentID, -691 , 729, 19, 24);
		beforeID = currentID;
	}

	if(!isVideo) startRoll();

	$bestBanner.hover(function() {
		stopRoll();
	}, function() {
		if(!isVideo) startRoll();
	});

	function startRoll() {
		timer = setInterval(function() {
			num++;
			num = Math.abs(num);
			if(num > <?=count($list)?>) {
				num = 1;
			} else if(num == 0) {
				num = <?=count($list)?>;
			}
			currentID = '#banner'+num;
			rolling(num, beforeID, currentID, -691 , 729, 19, 24);
			beforeID = currentID;
		}, opt.speed.ms50);
	}

	function stopRoll() {
		clearTimeout(timer);
	}

}
//-->
</script>

