<!-- #include virtual="/_vir0001/common_asp/dblib.asp" -->
<!-- #include virtual="/_vir0001/common_asp/usersession_web.asp" -->
<!-- #include virtual="/_vir0001/all_site/common_include.asp" -->
<!-- #include virtual="/top.asp" -->




<%

	if (request("ini")="yes" and thisCategory="0") or (thisSite="all" and iniCategory=0 and thisCategory=0) or thisCategory="957" then
		response.redirect("/")
	end if





	sql = make_querystring(request.querystring)

	blocksize = 20
	pagesize  = viewPage
	gotopage = defaultvalue(request("gotopage"),1)
	orderB = defaultValue(request("orderB"),0)
%>


<!-- #include virtual="/_vir0001/all_site/best3.asp" -->
<%


		if thisCategory = "1" then '//º£½ºÆ®50 »óÇ°

			sql_item=" "

			tb_name = "(select top 50 A.id,A.goods_name,A.goods_model,ori_count,count_ori_last,count_amori_last,c.subject,C.img_date,B.pack_content_id,B.sunser,D.subject brand_subject " & _
					"	from [petitelin_CRM]..[view_pack_content_web] A " & _
					" inner join [petitelin_CRM]..[pack_sunser] B on A.id = B.pack_content_id " & _
					" left outer join (select pack_content_id,max(subject) as subject, max(wdate) img_date from [petitelin_CRM]..[pack_photo] where sunser=1 group by pack_content_id) C on A.id=C.pack_content_id  " & _
					" left outer join category D on A.categoryMD = D.id  " & _
					"	where B.category_id = 1 order by B.sunser asc) A "
			key_field = " id "
			select_item = " * "
			select case orderB
				case "0"
					orderby = " sunser "
				case "1"
					orderby = " id desc "
				case "2"
					orderby = " ori_count asc "
				case "3"
					orderby = " ori_count desc "
			end select

			recordcount = cnt_Rs(key_field,tb_name,sql_item,oconn)

			set adoRs = make_page_sql(pagesize,gotopage,key_field,tb_name,sql_item,orderby,select_item,oconn)

		Else


			cateVal = thisCategory
			If thisCategory = 213 Then
				cateVal = "N" '//new
			ElseIf thisCategory = 933 Then
				cateVal = "A" '//Awesome
			ElseIf thisCategory = 205 Then
				cateVal = "W" '//Weekly
			ElseIf thisCategory = 25 Then
				cateVal = "G" '//Gift
			End If
			cateGubun = getCategory(cateVal)

			tmp_orderB = orderB
			If moneyChange Then
				If orderB  = 2 Then
					tmp_orderB = 4
				ElseIf orderB  = 3 Then
					tmp_orderB = 5
				End if
			End If

			
			Set exeQuery = new arrayPush
			exeQuery.append(" SELECT B.pack_content_id, B.old_id, B.category_site_id, B.brand_subject, thumbnail1, thumbnail2, thumbnail3, thumbnail10, gift_thumbnail, ")
			exeQuery.append(" 		isoption, best, new, elindeal, ready, ori_count, count_ori_last, count_amori_last, goods_model, A.title, A.sunser, A.gubun  ")
			exeQuery.append(" FROM [petitelin_CRM]..[pack_list] A WITH (NOLOCK)")
			exeQuery.append(" INNER JOIN [petitelin_CRM]..[pack_list_detail] B WITH (NOLOCK) ON A.pack_content_id=B.pack_content_id ")
			exeQuery.append(" where A.gubun ='"& cateGubun &"' and A.gubun_id ='"& thisCategory &"' ")

			tb_name = "("& exeQuery.toString() &")A" 
			select_item = "*"
			key_field = "pack_content_id"
			orderby = "sunser asc , pack_content_id desc "

			If tmp_orderB = 1 Then '//½ÅÁ¦Ç°¼ø
				orderby = "pack_content_id desc "
			ElseIf tmp_orderB = 2 Then '//³·Àº°¡°Ý¼ø ÀÏ¹Ý
				orderby = "count_ori_last asc "
			ElseIf tmp_orderB = 3 Then 
				orderby = "count_ori_last desc "
			ElseIf tmp_orderB = 4 Then '//³·Àº°¡°Ý¼ø ¿ì¼ö
				orderby = "count_amori_last asc "
			ElseIf tmp_orderB = 5 Then 
				orderby = "count_amori_last desc "
			End If 


			recordcount = cnt_Rs(key_field,tb_name,sql_item,oconn)
			set adoRs = make_page_sql(pagesize,gotopage,key_field,tb_name,sql_item,orderby,select_item,oconn)
		
		end if

		pagecount = int((recordcount-1)/pagesize) + 1
		intnum=recordcount-((gotopage-1)*pagesize)


		do while not adoRs.eof
			pack_content_id_array = pack_content_id_array & adoRs("pack_content_id") &","
		adoRs.movenext
		loop

		if not(adoRs.bof and adoRs.eof) then
			adoRs.movefirst
		end if


		if thisSite="all" or thisCategory ="0" then 'Á¾ÇÕ¸ô »çÀÌÆ®, all product
			addURL = web_querystring2(request.querystring) &"&iniCategory="&iidCate

			'// 2015-04-23 »óÀ§ ´ë¸Þ´º (º£½ºÆ®50:1, ÇÒÀÎ»óÇ°:205, ½Å»óÇ°:213)¿¡¼­ Á¤·Ä(ÀÎ±â¼ø, ½Å»óÇ°¼ø, ³·Àº°¡°Ý¼ø, ³ôÀº°¡°Ý¼ø) Å¬¸¯ ½Ã ¸ÞÀÎÀ¸·Î ³Ñ¾î°¡´Â Çö»óÀ» ¹æÁöÇÏ±â À§ÇØ¼­ ¾Æ·¡¿Í °°ÀÌ Ãß°¡ÇÑ´Ù.
			'If request("category_etc_id") = 1 Or request("category_etc_id") = 205 Or request("category_etc_id") = 213 Then
			If request("category_etc_id") <> "" Then
				addURL = addURL & "&category_etc_id="&request("category_etc_id")
			End If

		%>
		

		<!--   <div class="itm-hd">
        <span class="total-item-num"><span class="num"><%=recordcount%></span> Items</span>
        <select class="item-order type2" onchange="javascript:location.href=this.value">
			<option value="?orderb=0<%=addURL%>"<% if request("orderb") = "0" then %> selected<% end if %>>ÀÎ±â¼ø</option>
			<option value="?orderb=1<%=addURL%>"<% if request("orderb") = "1" then %> selected<% end if %>>½Å»óÇ°¼ø</option>
			<option value="?orderb=2<%=addURL%>"<% if request("orderb") = "2" then %> selected<% end if %>>³·Àº°¡°Ý¼ø</option>
			<option value="?orderb=3<%=addURL%>"<% if request("orderb") = "3" then %> selected<% end if %>>³ôÀº°¡°Ý¼ø</option>
        </select>
      </div>-->


		<!--<table width="100%" cellpadding="0" cellspacing="0">
		<tr><td>
			<a href="?orderb=0<%=addURL%>"><img src="/image/align_01<% if orderB=0 then %>on<% end if %>.jpg" width="57" border="0" /></a>
			<a href="?orderb=1<%=addURL%>"><img src="/image/align_02<% if orderB=1 then %>on<% end if %>.jpg" width="65" border="0" /></a>
			<a href="?orderb=2<%=addURL%>"><img src="/image/align_03<% if orderB=2 then %>on<% end if %>.jpg" width="75" border="0" /></a>
			<a href="?orderb=3<%=addURL%>"><img src="/image/align_04<% if orderB=3 then %>on<% end if %>.jpg" width="66" border="0" /></a>
		</td><td align="right" style="color:#a0a0a0">
		ÃÑ <b style="color:#00CC00"><%=recordcount%></b>°³ »óÇ°ÀÌ µî·ÏµÇ¾î ÀÖ½À´Ï´Ù.
		</td></tr></table>
		<hr noshade="yes" size="1" style="color:#e0e0e0">-->
		<% end if %>



	<div class="items sub-c">
		<div class="itm-hd">
			<span class="total-item-num"><span class="num"><%=recordcount%></span> Items</span>
			<select class="item-order type2" onchange="javascript:location.href=this.value">
				<option value="?orderb=0<%=addURL%>"<% if request("orderb") = "0" then %> selected<% end if %>>ÀÎ±â¼ø</option>
				<option value="?orderb=1<%=addURL%>"<% if request("orderb") = "1" then %> selected<% end if %>>½Å»óÇ°¼ø</option>
				<option value="?orderb=2<%=addURL%>"<% if request("orderb") = "2" then %> selected<% end if %>>³·Àº°¡°Ý¼ø</option>
				<option value="?orderb=3<%=addURL%>"<% if request("orderb") = "3" then %> selected<% end if %>>³ôÀº°¡°Ý¼ø</option>
			</select>
		</div>
<%
		'end if
	'end if
%>
		<div class="itm-ul">
			<!-- { block for repeat items } -->
<%
	If Not(adoRs.bof and adoRs.eof) Then
		do while not adoRs.eof
			thumbsrc = imgDivideNew(adoRs("thumbnail1")) &"middle/"& adoRs("thumbnail1")
%>
			<div class="itms" style="cursor:pointer" onclick="goHref(<%=adoRs("pack_content_id")%>,'<%=adoRs("thumbnail1")%>')">
				<div style="position:absolute;cursor:pointer;border:solid 0px <%=imageBorder%>;">
					<div style="position: absolute;" id="photo_<%=adoRs("pack_content_id")%>" name="photo_<%=adoRs("pack_content_id")%>"></div>
					<div style="position: absolute;" id="photo1_<%=adoRs("pack_content_id")%>" name="photo1_<%=adoRs("pack_content_id")%>"></div>
					<div style="position: absolute;" id="photo2_<%=adoRs("pack_content_id")%>" name="photo2_<%=adoRs("pack_content_id")%>"></div>
					<div style="position: absolute;" id="photo3_<%=adoRs("pack_content_id")%>" name="photo3_<%=adoRs("pack_content_id")%>"></div>
				</div>
				<img class="img" src="<%=thumbsrc%>" alt="img<%=i%>">
				<div class="cate"><%=replace(adoRs("brand_subject"), "#","")%></script></div>
				<p class="item-description" id="iconID<%=adoRs("pack_content_id")%>" name="iconID<%=adoRs("pack_content_id")%>"><%=replace(adoRs("goods_model"),"^","<br>")%></p>
				<div class="price">
<%
			If moneyChange Then
				now_count_last = adoRs("count_amori_last")
			Else
				now_count_last = adoRs("count_ori_last")
			End If

			If adoRs("ori_count") = now_count_last Then
%>
					<p class="now-price" id="promotion_ID<%=adoRs("pack_content_id")%>" name="promotion_ID<%=adoRs("pack_content_id")%>"><%=formatnumber(now_count_last,0)%></p>
<%
			else
%>
				
					<em class="list-price" id="ori_count<%=adoRs("pack_content_id")%>" name="ori_count<%=adoRs("pack_content_id")%>"><%=formatnumber(adoRs("ori_count"),0)%></em>
					<p class="now-price" id="promotion_ID<%=adoRs("pack_content_id")%>" name="promotion_ID<%=adoRs("pack_content_id")%>"><%=formatnumber(now_count_last,0)%>
						<span><%= FormatNumber((formatnumber(adoRs("ori_count"),0) - formatnumber(now_count_last,0)) / formatnumber(adoRs("ori_count"),0) * 100,0) %>%</span>
					</p>
				
<%
			end if
%>
				</div>
			</div>
<%
			adoRs.movenext
			i = i + 1
		loop
	end if
%>
			<!-- { end repeat } -->
		</div>



	<div id="paging"class="itm-pg">
	<%=whittlePageUtils("gotoPage","",gotoPage,blockSize,pageCount,SQL,"<span class='btn-page prev'></span>","<span class='btn-page next'></span>")%>
	</div>


<%
	'---------------°èÀý¿¡ µû¸¥ »óÇ° ÀÏ½Ã Æó¼â (ÇöÀçÀû¿ë:½º³ë¿ìÁ¦Ç°[587], µàÀÌ½ºÆ® ½º³ë¿ì¶óÀÎ[744])---------------------
	'if thisSite <> "all" and (instr("@000@","@"& thisCategory &"@")>0 and  thisCategory <>"" and  thisCategory <>"0") then
	if instr("@1343@","@"& thisCategory &"@")>0  and thisCategory <>"" and  thisCategory <>"0" Then

		'response.write ("<table width='100%'><tr><td align='center'><img src='https://img.essenlue.com/Amoretto/seasonoff/2022_" & thisCategory & ".jpg'></td></tr></table><br><br>")
%>
	<%end If
		'---------------ÀÏ½Ã Æó¼â Á¾·á----------------------
%>

<%'##################################################### ³»¿ë ##################################################### %>
<!-- #include virtual="/bottom.asp" -->
<!-- #include virtual="/_vir0001/all_site/popup_new.asp" -->

<script language="javascript">
function MM_openBrWindow(val) {
	window.open("/_vir0001/process/shopviewimg.asp?pack_content_id="+val,"","width=900,height=510,resizable=yes")
}

function goHref(id,img) {
	if ("<%=request("category_etc_id")%>" !== "")
	{
		category_etc_id =  "&category_etc_id=<%=request("category_etc_id")%>"
	} else {
		category_etc_id = ""
	}

<% if thisSite = "all" then %>
	location.href="/_vir0001/process/shopview_2016.asp?iniCategory=<%=iniCategory%>&thisCategory=<%=thisCategory%>&pack_content_id="+id+category_etc_id;
<% else %>
	var newWindow = window.open("about:blank");
	newWindow.location.href="https://www.whittlestore.com/_vir0001/process/shopview_2016.asp?thisCategory=<%=thisCategory%>&pack_content_id="+id+category_etc_id;
<% end if %>
}

<%
if pack_content_id_array<>"" then

	if meWork then
		response.write ("//$$$"& pack_content_id_array) & chr(13)
		response.write ("//$$$"& pack_content_id_array2)
	end if


	dim strQuery
	set strQuery = new arrayPush

	procName = "[petitelin_CRM]..[proc_shopmain_icon]"
	arrParam1 = array(pack_content_id_array)
	arrParam2 = array("pack_content_id_array")
	arrParamLong = null
	execOrder = "list"
	set Rs = GetRecordSetByProc(oConn, procName, arrParam1, arrParam2, arrParamLong, execOrder)

	if not(Rs.bof and Rs.eof) then
		do while not Rs.eof
%>
			for (var iconI=0 ; iconI<document.getElementsByName("iconID<%=Rs("pack_content_id")%>").length ; iconI++) {
				if (document.getElementsByName("iconID<%=Rs("pack_content_id")%>")[iconI].innerHTML.indexOf("icon_endtitle")==-1){
					document.getElementsByName("iconID<%=Rs("pack_content_id")%>")[iconI].innerHTML += "<img src='partImages/icon_soldout.gif' align='absmiddle'>&nbsp;"
					
					// Ç°Àý½Ã ÇÒÀÎ°¡°ÝÀÌ ¾Æ´Ñ RRP·Î Ç¥½ÃÇÔ.
					document.getElementsByName("ori_count<%=Rs("pack_content_id")%>")[iconI].style.display = "none"
					document.getElementsByName("promotion_ID<%=Rs("pack_content_id")%>")[iconI].innerHTML = document.getElementsByName("ori_count<%=Rs("pack_content_id")%>")[iconI].innerHTML;
					document.getElementsByName("promotion_ID<%=Rs("pack_content_id")%>")[iconI].style.color = "#000000"
				}
			}
<%

		Rs.movenext
		loop
	end if



	set strQuery = new arrayPush
	strQuery.append("select A.pack_content_id,isnull(C.discount_ratio,0) as discount_ratio,isnull(C.amodiscount_ratio,0) as amodiscount_ratio,isnull(money,0) as money,isnull(ready,'n') as ready,location from [petitelin_CRM]..[view_promotion] C ")
	strQuery.append("inner join (select * from [petitelin_CRM]..[promotion_pack] where pack_content_id>0 and pack_content_id in ("& pack_content_id_array & pack_content_id_array2 &"0)) A on C.id=A.promotion_id order by C.id asc")
	execOrder = "list"
	set Rs = SetDatabaseByblank(oConn, strQuery.tostring, execOrder)


	if not(Rs.bof and Rs.eof) then
		do while not Rs.eof 
%>
			thisOri = parseInt(document.getElementsByName("ori_count<%=Rs("pack_content_id")%>")[0].innerHTML)
<%
			if moneyChange and Rs("amodiscount_ratio")>0 and Rs("money")=0 then 'money=0 - ÇÒÀÎÀ²ÀÌ ÀÖ¾îµµ ¼îÇÎ±¸¸Å¾×ÀÌ ÀÏÁ¤ ±Ý¾×ÀÌ ³Ñ¾î°¡´Â °æ¿ì¿¡´Â ÇÒÀÎÀ²À» Ç¥½ÃÇÏÁö ¾Ê´Â´Ù.
%>
				for (var i=0 ; i<document.getElementsByName("promotion_ID<%=Rs("pack_content_id")%>").length ; i++) {
					document.getElementsByName("promotion_ID<%=Rs("pack_content_id")%>")[i].innerHTML = make_money(thisOri - thisOri*<%=Rs("amodiscount_ratio")%>/100)
				}
<%
			elseif Rs("discount_ratio")>0 and Rs("money")=0 then 
%>
				for (var i=0 ; i<document.getElementsByName("promotion_ID<%=Rs("pack_content_id")%>").length ; i++) {
					document.getElementsByName("promotion_ID<%=Rs("pack_content_id")%>")[i].innerHTML = make_money(thisOri - thisOri*<%=Rs("discount_ratio")%>/100)
				}
<%
			end if

			if Rs("ready")="y" and Rs("location")<>3 then
%>
				for (var iconI=0 ; iconI<document.getElementsByName("iconID<%=Rs("pack_content_id")%>").length ; iconI++) {
					document.getElementsByName("iconID<%=Rs("pack_content_id")%>")[iconI].innerHTML = "<img src='partImages/reserverico.gif' align='absmiddle'>&nbsp;"
				}
<%
			end if
		Rs.movenext
		loop
	end if







end if
%>

</script>