
//val-ctg , val2 - page , val3 - body_number
function GoodsList(val,val2,val3,val4,val5)
{
		var req = getXMLHTTP();
		
		req.onreadystatechange = function()
		{
			
			if(req.readyState == 4)
			{
				showIndicatorLoading('close');
				stepcarousel.stepTo('mygallery',document.getElementById('body_number').value);
				if (req.status == 200)
				{
					handleGoodsListResponse(eval("("+req.responseText+")"),val2,val3,val);
					
				}
			}
			else
			{
				showIndicatorLoading('show');
			}
		}																//false´Â ¿Â·¹µðÃ¼ÀÎÁö ¹Ø¿¡ÀÖ¾î¾ß ÀÛµ¿ÇÔ
		req.open('POST',"/call/call_GoodsList.asp?ctg="+escape(val)+"&page=" + escape(val2)+"&orderby="+escape(val4)+"&TopWidth="+escape(val5),true);
	
		req.send(null);
	
};

function handleGoodsListResponse(result,val2,val3,val)
{
	
	DoGoodsView(result,val,val2,val3)

	DoPageView(result,val2,val3,val);
};

function DoGoodsView(result,val,val2,val3)
{
	//Ã¼ÀÎÁöµÉ ¹Ùµð ¼±ÅÃ
	if (val3 == 1)
	{
		BodyCenter = "body_center01";
		PageView = "page_view01"
	}
	else
	{
		BodyCenter = "body_center02";
		PageView = "page_view02"
	}
	//end

	var Body_Div = document.getElementById(BodyCenter);
	

	var listHTML =
	"<table border=0 cellspacing=0 cellpadding=0 height=100% align=center>"
	+	"<tr><td>"
	+		"<table width=100%  border=0 cellspacing=0 cellpadding=0>";

	if (result.total_page == 0)//»óÇ°ÀÌ ¾øÀ»¶§
	{
		listHTML = listHTML + "<tr align=center><td height=240>»óÇ°ÀÌ ¾ø½À´Ï´Ù.</td></tr><tr><td></td></table></td></tr></table>";
		Body_Div.innerHTML = listHTML;
	}
	else
	{
		var colscount = result.colscount;
		
		var list_length = result.list_text.length;
		var line_change = 0;
		namuji = result.list_text.length % colscount;

		for (i=0;i<result.list_text.length;i++)
		{
			
			if (val2 == result.page)
			{
				
				if (i==(colscount*line_change))//ÇÑÁÙ¿¡ 4°³¾¿
				{
					if (i==0)
					{
						line_change = line_change + 1
						listHTML = listHTML + "<tr align=center>";
					}else
					{
						line_change = line_change + 1
						listHTML = listHTML + "</tr><tr align=center>";
					}
					
				}
				
				if (result.list_text[i].standard != '')
				{
					var standard = "<br><font style=font-family:µ¸¿ò;font-size:11px;letter-spacing:-1px;color:#BFBFBF;>±Ô°Ý: "+ result.list_text[i].standard +"</font>";
				}else{ var standard = '';}
				
				//¹«·á¹è¼Û ÀÌ¹ÌÁö´Þ±â
				if (result.list_text[i].freedeli == "1" || result.list_text[i].sale_price >= 50000)
				{
					
					var list_image = "<div style='position:absolute;width:43px;height:43px;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,sizingMethod=crop,src=/img/common/freedeli_list.png);'></div><a href=javascript:body_change('"+val+".Goods="+result.list_text[i].goods_code+"');>"
								+"		<img src=/goods_img/"+ result.list_text[i].list_image+" width=130 height=130 border=0 style=cursor:hand; alt='"+result.list_text[i].full_name+"'></a>";
				}else{
					var list_image = "<a href=javascript:body_change('"+val+".Goods="+result.list_text[i].goods_code+"');>"
								+"		<img src=/goods_img/"+ result.list_text[i].list_image+" width=130 height=130 border=0 style=cursor:hand; alt='"+result.list_text[i].full_name+"'></a>";
				}
				///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				
				
				//»çÀºÇ° ÀÌ¹ÌÁö´Þ±â
				if (result.list_text[i].gift == "1")
				{
					var gift = "<div style='position:absolute;width:36px;height:12px;left:130px;top:15px;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,sizingMethod=crop,src=/img/common/gift.png);'></div>";
				}else{
					var gift = "";
				}
				///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				
				//½Å»óÇ° ÀÌ¹ÌÁö´Þ±â
				if (result.list_text[i].newgoods == "1")
				{
					var newgoods = "<div style='position:absolute;width:36px;height:12px;left:130px;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,sizingMethod=crop,src=/img/common/new.png);'></div>";
				}else{
					var newgoods = "";
				}
				///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

				listHTML = listHTML + "<td>"
				+"<table width=203 border=0 cellspacing=0 cellpadding=0><tr><td colspan=2>"
				+	"<table width=190 border=0 cellspacing=1 cellpadding=0><tr><td height=155 bgcolor=#FFFFFF valign=middle align=center>"
				+ "		<table width=130 height=130 cellpadding=0 cellspacing=0 border=0><tr><Td valign=top><div style='width:130px;height:130px;padding:0 0 0 0;position:absolute;'>"
				+			list_image + gift + newgoods + "</div><td></tr></table></td></tr></table>"
				+"		</td></tr>"
				+		"<tr><td bgcolor=#E3E3E3 height=2 colspan=2></td></tr><tr><td align=center>"
				+"		<table cellpadding=0 cellspacing=0 height=70 width=160 align=center><tr><td height=10></td></tr><tr><td align=center style='cursor:hand' class=subtit valign=top><a href=javascript:body_change('"+val+".Goods="+result.list_text[i].goods_code+"'); >"+ result.list_text[i].goods_name+"</a>"
				+			 "<br><font style='color:#BFBFBF;font-weight:bold;'>£Ü"+ GetFormatMoney(result.list_text[i].sale_price) +"</font>"+standard+"</td></tr></table></td></tr><tr><td colspan=2 height=1 bgcolor=#E3E3E3></td></tr>"
				+"</table></td>";

			

			}
			
			
			if (i==(result.list_text.length-1))
			{	
				if (namuji != 0)
				{
					for (k=0;k<colscount-namuji ;k++ )
					{
						listHTML = listHTML + "<td width=203>"
						+"<table width=203 border=0 cellspacing=0 cellpadding=0><tr><td colspan=2>"
						+	"<table width=190 border=0 cellspacing=1 cellpadding=0>"
						+"		<tr><td height=155 align=center bgcolor=#FFFFFF>"
						
						+"			</td></tr></table>"
						+"		</td></tr>"

						+		"<tr><td bgcolor=#E3E3E3 height=2 colspan=2></td></tr>"

						+"		<tr height=70><td><table><tr><td align=center style='cursor:hand' class=subtit>"
						+"		</td>"
						+"		<td align=center class=subtit></td></tr></table>"
						+"		</td></tr><tr><td colspan=2 height=1 bgcolor=#E3E3E3></td></tr>"
						+"</table>"
						
						+"</td>";
					}
				}
				
				listHTML = listHTML + "</tr></table></td></tr></table><div id="+PageView+"></div>";
			}
			
		}	
		
		Body_Div.innerHTML = listHTML;
	}
	var totalgoodscnt = document.getElementById("totalgoodscnt"+val3);
	
	if (result.total_page == 0)
	{var totalcnt = 0;}
	else{var totalcnt = result.total_cnt;}
	
	
	if (result.orderby == "1")
	{
		var orderselected = "<option value=1 selected>½Å»óÇ°¼ø</option><option value=2>ÀÎ±âµµ¼ø</option><option value=3>³·Àº°¡°Ý¼ø</option>";
	}
	else if (result.orderby == "2")
	{
		var orderselected = "<option value=1>½Å»óÇ°¼ø</option><option value=2 selected>ÀÎ±âµµ¼ø</option><option value=3>³·Àº°¡°Ý¼ø</option>";
	}
	else if (result.orderby == "3")
	{
		var orderselected = "<option value=1>½Å»óÇ°¼ø</option><option value=2>ÀÎ±âµµ¼ø</option><option value=3 selected>³·Àº°¡°Ý¼ø</option>";
	}
	totalgoodscnt.innerHTML = "Total <b>" + totalcnt + "</b>"
	+"&nbsp;&nbsp;<select onchange=javascript:GoodsOrderRe('"+val+"','"+val2+"','"+val3+"','"+result.topwidth+"'); id=goodsorderchange"+val3+">"
	
	+ orderselected
	
	+"</select>";

};
function GoodsOrderRe(val,val2,val3,val4)
{
	var goodsorderchange = document.getElementById("goodsorderchange"+val3);
	GoodsList(val,val2,val3,goodsorderchange.value,val4);
}

//val-ctg , val2 - page , val3 - body_number
function DoPageView(result,val2,val3,val)
{
	//Ã¼ÀÎÁöµÉ ¹Ùµð ¼±ÅÃ
	if (val3 == 1)
	{
		PageView = "page_view01"
	}
	else
	{
		PageView = "page_view02"
	}
	//end
	
	var temp = val.split(".");
	var temp2 = temp[temp.length-1];
	var temp3 = temp2.split("P");
	var val = "";
	for (i=0;i<temp.length-1;i++)
	{
		if (val == '')
		{
			val = val +temp[i];
		}else{
		val = val +"."+temp[i];
		}
	}
	
	var val = val+"."+temp3[0];
	
	
	
	var page_view = document.getElementById(PageView);
	var show_page_num = 10; //ÆäÀÌÁö °³¼ö
	var total_page = result.total_page;
	var page_group_cnt = result.page_group_cnt;
	var now_page_group_num = result.now_page_group_num;
	
	var show_start_page = (show_page_num * (now_page_group_num-1)+1)
	var show_page = now_page_group_num * show_page_num
	var next_page = (show_page_num * (now_page_group_num)+1);
	var before_page =(now_page_group_num-2)*show_page_num + 1;
	
	var pageHTML = "<br><table cellpadding=0 cellspacing=0 border=0 align=center><tr>";

	if (before_page > 0)
	{
		pageHTML = pageHTML + "<td width=20 align=center><a href=javascript:body_change('"+ val + "P" + before_page + "')><img src=/img/common/before_page.jpg border=0></td>";
	}
	else
	{
		pageHTML = pageHTML + "<td width=20 align=center></td>";
	}

	for (p=show_start_page;p<=show_page;p++ ){
		if (p <= total_page)
		{
			if (p == val2)
			{
				pageHTML = pageHTML + "<td align=center class=page_sel width=20><b>" + p + "</b></td>"
				
			}
			else
			{
				pageHTML = pageHTML + "<td align=center width=20><a href=javascript:body_change('"+val+"P"+p+"');>" + p + "</a></td>"
			}
			
		}
		else
		{
			pageHTML = pageHTML + "<td width=20> </td>"
		}

		
	}
	if (next_page <= total_page)
	{
		pageHTML = pageHTML + "<td width=20 align=center><a href=javascript:body_change('"+ val+"P"+next_page + "')><img src=/img/common/next_page.jpg border=0></td>"
	}
	else
	{
		pageHTML = pageHTML + "<td width=20 align=center></td>"
	}

	pageHTML = pageHTML + "</tr></table>";


	page_view.innerHTML = pageHTML;

	

};