<?
//DB연결
$dblink = SetConn($_conf_db["main_db"]);

if($_REQUEST[st]=="new"){
	$order_by = " A.idx DESC ";
}else if($_REQUEST[st]=="hit"){
	$order_by = " A.hit DESC ";
}else if($_REQUEST[st]=="name"){
	$order_by = " A.g_name ";
}else if($_REQUEST[st]=="hprice"){
	$order_by = " length(A.price) DESC, A.price DESC ";
}else if($_REQUEST[st]=="lprice"){
	$order_by = " length(A.price) ASC, A.price ASC ";
}else{
	$order_by = " A.sort_num DESC, A.idx DESC ";
}



//best상품 리스트
$arrBestList = getGoodListBaseNFileFromCat(
	mysql_real_escape_string($_REQUEST["cat_no"]), 
	$order_by, "best", "Y", 
	"4", "", "Y");

//$arrList = getGoodListBaseNFileFromCat(mysql_real_escape_string($_REQUEST["cat_no"]), " A.sort_num DESC, A.idx DESC ", "", "", "4", "", "Y");

$scale = "8";
//상품 리스트
$arrList = getGoodListBaseNFileFromCat(
	mysql_real_escape_string($_REQUEST["cat_no"]), 
	$order_by, 
	mysql_real_escape_string($_REQUEST[sw]), 
	mysql_real_escape_string($_REQUEST[sk]), 
	$scale, $_REQUEST[offset],"Y");

//전체 카테고리 가져오기
$arrAllCategory = getCategoryAll();


//현재 카테고리 정보
$arrCategoryInfo = getCategoryInfo(mysql_real_escape_string($_REQUEST["cat_no"]));
$arrCatCode = explode("/", $arrCategoryInfo["list"][0]["cat_code"]);

//서브 카테고리 목록
$categorySubList = getCategoryList(mysql_real_escape_string($arrCatCode[0]));

$arrCategoryImg = getCategoryAllimage();

$pages=intval($arrList["total"]/9); 
if ($arrList["total"] % 9) { 
	$pages++; 
} 

//SetDisConn($dblink);
?>
	
	
	<div class="contain">
		<div id="contentArea">
		<div class="sub-title mgb30">
			<h2>제품검색</h2>
			<div class="path">Home &gt; 제품검색</div>
		</div>
		<div class="real-cont">
			<div class="mgb20"><strong class="f-c-red">"<?=$sk?>"로 검색한 결과</strong>, <strong class="f-c-black">총 <?=number_format($arrList["total"])?>개의 제품</strong>이 등록되어 있습니다.</div>
			<!--// content -->

			<!--// 리스트 -->
			<div class="goods-list">
				<?if($arrList['list']['total'] > 0){?>
				<ul>
				<?for ($i=0;$i<$arrList['list']['total'];$i++) {
					$arrCat[$i] = explode("/", $arrList["list"][$i]["cat_code"]);

					// 아이콘표시
					$array_part_icons=explode("|",$arrList['list'][$i]['icons']);
					// 상품아이콘(히트,뉴,추천....)		
					$temp_part_icons="";
					if (count($array_part_icons)>0){				
						for($k=0;$k<count($array_part_icons);$k++){
							if ($array_part_icons[$k]){
								$temp_part_icons.="<img src='/uploaded/shop_icons/".$array_part_icons[$k]."'> ";				
							}
						}
					}
					if($i%4==0){echo "</ul><ul>";}
				?>
				<li>
					<div class="thumb"><a href="/shop.php?goPage=GoodDetail&g_code=<?=$arrList['list'][$i]['g_code']?>&cat_no=<?=$cat_no?>"><img src="/uploaded/shop_good/<?=$arrList['list'][$i]['idx']?>/l_<?=$arrList['list'][$i]['re_name']?>" width="248" height="248" alt="" /></a></div>
					<?=$temp_part_icons?>
					<div class="title">
						<a href="/shop.php?goPage=GoodDetail&g_code=<?=$arrList['list'][$i]['g_code']?>&cat_no=<?=$cat_no?>"><strong>[<?=stripslashes($arrAllCategory[$arrCat[$i][0]])?>] <br></strong><?=stripslashes($arrList['list'][$i]['g_name'])?></a>
					</div>
					<div class="price"><?=number_format($arrList['list'][$i]['price'])?>원</div>
				</li>
				<?}?>
				</ul>
				<?}else{?>
				<ul>등록된 상품이 없습니다.</ul>
				<?}?>
			</div>

			<div class="paginate">
				<?=pageNavigation($arrList['total'],$scale,$pagescale,$offset,"cat_no=".$_REQUEST["cat_no"]."&sw=".$_REQUEST[sw]."&sk=".$_REQUEST[sk]."&st=".$_REQUEST[st]."&goPage=".$_REQUEST[goPage])?>
			</div>
			<!-- 리스트 //-->
			<!-- content //-->
		</div>
	</div>