var shopCommon = {
	targetWindow : location,

	CatCode : "",
	PageSize : "",
	CurrPage : "",
	Order : "",
	TotPage : "",
	TotCnt : "",

	ItemCode : "",
	ListType : "",
	etc1 : "",

	FromDay : "",
	ToDay : "",

	sSearchVal : "",

	gb : "",

	strfind : "",
	strpart : "",

	setLocation : function (fld){
		var path = location.pathname + baseParam + "&c=";

		if (typeof fld.CatCode != "undefined")
			this.CatCode = fld.CatCode;
		if (typeof fld.PageSize != "undefined")
			this.PageSize = fld.PageSize;
		if (typeof fld.CurrPage != "undefined")
			this.CurrPage = fld.CurrPage;
		if (typeof fld.Order != "undefined")
			this.Order = fld.Order;
		if (typeof fld.ItemCode != "undefined")
			this.ItemCode = fld.ItemCode;
		if (typeof fld.ListType != "undefined")
			this.ListType = fld.ListType;
		if (typeof fld.etc1 != "undefined")
			this.etc1 = fld.etc1;

		if (typeof fld.FromDay != "undefined")
			this.FromDay = fld.FromDay;
		if (typeof fld.ToDay != "undefined")
			this.ToDay = fld.ToDay;

		if (typeof fld.sSearchVal != "undefined")
			this.sSearchVal = fld.sSearchVal;
		if (typeof fld.strfind != "undefined")
			this.strfind = fld.strfind;
		if (typeof fld.strpart != "undefined")
			this.strpart = fld.strpart;

		path += "&CatCode=" + this.CatCode;
		path += "&PageSize=" + this.PageSize;
		path += "&CurrPage=" + this.CurrPage;
		path += "&Order=" + this.Order;
		path += "&ItemCode=" + this.ItemCode;
		path += "&ListType=" + this.ListType;
		path += "&etc1=" + this.etc1;
		path += "&FromDay=" + this.FromDay;
		path += "&ToDay=" + this.ToDay;

		if (this.sSearchVal != "")
			path += "&sSearchVal=" + Form.escape(this.sSearchVal);
		if (this.strfind != "")
			path += "&strfind=" + Form.escape(this.strfind);
		if (this.strpart != "")
			path += "&strpart=" + Form.escape(this.strpart);

		location.href = path;
	},

	setDetailLocation : function (fld){
		var path = location.pathname + "?c=";

		if (typeof fld.ItemCode != "undefined")
			this.ItemCode = fld.ItemCode;

		path += "&ItemCode=" + this.ItemCode;

		this.targetWindow.href = path;
	},

	goItemDetail : function (fld){
		var path = "/shop/book_detail.asp?c=";

		if (typeof fld.ItemCode != "undefined")
			this.ItemCode = fld.ItemCode;

		path += "&ItemCode=" + this.ItemCode;

		this.targetWindow.href = path;
	},

	setOrder : function (gb){
		var arr = new Array();

/*
		arr[0] = ["Brand New", "NewD"];
		arr[1] = ["ABC", "ItemNameA"];
		arr[2] = ["Price↑", "PriceD"];
		arr[3] = ["Price↓", "PriceA"];
		arr[4] = ["CV↑", "PVD"];
		arr[5] = ["CV↓", "PVA"];
*/
		arr[0] = [_("shoplist_04")+"↑", "PriceD"];
		arr[1] = [_("shoplist_04")+"↓", "PriceA"];
		if (gb != "replicate"){
			//arr[2] = ["CV↑", "PVD"];
			//arr[3] = ["CV↓", "PVA"];
		}
		//arr[6] = ["BV↑", "BVD"];
		//arr[7] = ["BV↓", "BVA"];

		for (var i = 0; i <= arr.length-1; i++){
			if (this.Order == arr[i][1]){
				//document.write("<b>"+arr[i][0]+"</b>");
				document.write("<span class='txt_hot'>"+arr[i][0]+"</span>");
			}else{
				//document.write("<a style='cursor:pointer' onclick=\"shopCommon.setLocation({Order:'"+arr[i][1]+"'})\">"+arr[i][0]+"</a>");
				document.write("<a style='cursor:pointer;' onclick=\"shopCommon.setLocation({Order:'"+arr[i][1]+"'})\" class='txt_mhotlink'>"+arr[i][0]+"</a>");
			}

			if (i != arr.length-1){
				document.write(" &nbsp;l&nbsp; ");
			}
		}
	},

	setPageSize : function (){
		document.write("<select name='PageSize' id='PageSize' class='input' onchange=\"shopCommon.setLocation({PageSize:this.value, CurrPage:'1'})\">");
		document.write("<option value='12' "+this.setComp("12", this.PageSize, "selected")+">12개씩 정렬</option>");
		document.write("<option value='24' "+this.setComp("24", this.PageSize, "selected")+">24개씩 정렬</option>");
		document.write("<option value='48' "+this.setComp("48", this.PageSize, "selected")+">48개씩 정렬</option>");
		document.write("<option value='96' "+this.setComp("96", this.PageSize, "selected")+">96개씩 정렬</option>");
		//document.write("<option value='500' "+this.setComp("500", this.PageSize, "selected")+">전체</option>");
		document.write("</select>");
	},

	setListType : function (){
		var ListType;
		if (this.ListType == "img"){
			ListType = "list"
		}else{
			ListType = "img"
		}
		document.write("<a href=\"javascript:shopCommon.setLocation({PageSize:this.value, CurrPage:'1', ListType:'"+ListType+"'})\"><img src='/images/btn_"+ListType+"view"+setLang()+".gif' border='0'></a>");
	},

	setComp : function(val1, val2, ret){
		if (val1 == val2){
			return ret;
		}

		return "";
	},

	setItemElement : function(Items){
		if (Items.indexOf(";") > 0){
			document.write("<select name='ItemElement' id='ItemElement' style='width:200px' onchange=\"shopCommon.setDetailLocation({ItemCode:this.value})\">");
			var splitVal = Items.split(";");
			for (var i = 0; i <= splitVal.length-2; i++){
				var splitVal2 = splitVal[i].split(":");
				document.write("<option value='"+splitVal2[0]+"' "+this.setComp(this.ItemCode, splitVal2[0], "selected")+">"+splitVal2[1]+"</option>");
			}
			document.write("</select>");
			$('trItemElement').style.display = "";
		}else{
			$('trItemElement').style.display = "none";
		}

	},

	setItemBindsDetail : function(fld){
		if (typeof fld.ItemBinds != "undefined" && fld.ItemBinds.indexOf(";") > 0){
			var splitVal = fld.ItemBinds.split(";");

			document.write("<select name='ItemBind' id='ItemBind' onchange=\"shopCommon.setDetailLocation({ItemCode:this.value})\">");
			for (var i = 0; i <= splitVal.length-2; i++){
				var splitVal2 = splitVal[i].split(":");
				document.write("<option value='"+splitVal2[0]+"' "+this.setComp(fld.ItemCode, splitVal2[0], "selected")+">"+splitVal2[1]+"</option>");
			}
			document.write("</select>");
		}else if (typeof fld.ItemBind != "undefined"){
			document.write(fld.ItemBind);
		}
	},

	setItemBindOnchange : function(fld){
		var i = fld.i;
		var splitVal = window.event.srcElement.value.split(":");

		$('chk'+i).value = splitVal[0];
		$('ItemImage'+i).src = "http://" + splitVal[2];
		$('sRetailPrice'+i).innerHTML = putComma(splitVal[3]) + "원";
		$('sPrice'+i).innerHTML = putComma(splitVal[4]) + "원 (" + (100 - parseInt(splitVal[5])) + "%";
		if (parseInt(splitVal[7]) <= parseInt(splitVal[6]) && parseInt(splitVal[6]) != 0){
			$('sOrderQty'+i).innerHTML = "수량 <input type='text' name='OrderQty' id='OrderQty"+i+"' value='1' class='input' style='width:46px;'>";
		}else{
			$('sOrderQty'+i).innerHTML = "<font color='#FF0000'>일시품절</font>";
		}
	},

	setAllChk : function(fld){
		var obj;

		if (typeof fld.obj == "undefined")
			return;
		else
			obj = fld.obj;

		if (obj.length > 1){
			for (var i = 0; i <= obj.length-1; i++){
				if (obj[i].style.display != "none"){
					obj[i].checked = $('allChk').checked;
				}
			}
		}else{
			if (obj.style.display != "none"){
				obj.checked = $('allChk').checked;
			}
		}
	},

	setImage : function(fld){
		if (typeof fld.path != "undefined" && fld.path != "" || typeof fld.obj != "undefined"){
			if (fld.type == "Image"){
				fld.obj.src = fld.path;
			}
		}
		return;
	},

	setPage : function(fld){
		var CurrPage = parseInt(this.CurrPage);
		var TotPage = parseInt(this.TotPage);
		var PageSize = parseInt(this.PageSize);
		var deli = "";

		if (TotPage == 0){
			TotPage = 1;
		}

		var splitPageSize = 10;
		var PageStart = (parseInt((CurrPage - 1) / splitPageSize) * splitPageSize) + 1;
		var PageEnd = (parseInt((CurrPage - 1) / splitPageSize) * splitPageSize) + splitPageSize;

		var html = '';

		// 이전 10개 페이지
		if (1 < PageStart){
			html += "<a style='cursor:pointer;' onclick=\"shopCommon.setLocation({CurrPage:'"+(PageStart - splitPageSize)+"'})\"><img src='/images/btn_prev1.gif' border='0' align='absmiddle'></a>&nbsp;";
		}else{
			html += "<img src='/images/btn_prev1.gif' border='0' align='absmiddle'/>";
		}

		for (var i = PageStart; i <= PageEnd && i <= TotPage; i++){
			deli = i > 1 && i % splitPageSize != 1 ? "|" : "";

			if (CurrPage == i){
				html += deli + " <span class='pagenum txt_bold'>"+i+"</span> ";
			}else{
				html += deli + " <a style='cursor:pointer;' onclick=\"shopCommon.setLocation({CurrPage:'"+i+"'})\" class='pagenum'>"+i+"</a> ";
			}
		}

		// 이후 10개 페이지
		if (PageEnd < TotPage){
			html += "&nbsp;<a style='cursor:pointer;' onclick=\"shopCommon.setLocation({CurrPage:"+(PageStart + splitPageSize)+"})\"><img src='/images/btn_next1.gif' border='0' align='absmiddle'></a>";
		}else{
			html += "&nbsp;<img src='/images/btn_next1.gif' border='0' align='absmiddle'/>";
		}

		return html;
	},

	setCartAdd : function(fld){
		var CartType = fld.CartType;
		var ItemCode = fld.ItemCode;
		var OrderQty = "1";

		if (typeof fld.OrderQty != "undefined")
			OrderQty = fld.OrderQty;

		if (OrderQty == "" || OrderQty == "0")
			OrderQty = "1";

		//
		//var url = '/shop/CartList_A.asp';
		var url = 'CartList_A.asp';
		var pars = "";
		pars += "CartType=" + Form.escape(CartType) + "&";
		pars += "ItemCode=" + Form.escape(ItemCode) + "&";
		pars += "OrderQty=" + Form.escape(OrderQty) + "&";

		loadAjaxXML(url, pars, null, null);

	},

	setAllCartAdd : function(fld){
		var CartType = fld.CartType;
		var ecd = fld.ecd;
		var str = "";
		var strQty = "";
		var chk = document.frm1.chk;
		var Qty = document.frm1.Qty;
		var OrderQty = 1;

		if (typeof fld.OrderQty != "undefined")
			OrderQty = fld.OrderQty;

		if (ecd == "CartUpd" || ecd == "DelCart"){
			str = fld.ItemCode;
		}else if (ecd == "DelAllCart"){
			str = fld.str;
		}else{
			if (typeof chk != "object"){

			}else if (typeof chk == "object" && typeof chk.length == "undefined"){
				i = 0;
				if (chk.checked){
					str += chk.value + ';';
					if ($('Qty0') != null){
						if (Qty.value == ""){
							Qty.value = "1";
						}
						strQty += Qty.value + ';';
					}
				}
			}else{
				for (var i = 0; i <= chk.length-1; i++){
					if (chk[i].checked){
						str += chk[i].value + ';';
						if ($('Qty0') != null){
							if (Qty[i].value == ""){
								Qty[i].value = "1";
							}
							strQty += Qty[i].value + ';';
						}
					}
				}
			}
		}

		if (str == ""){
			alert(_("_shop_01"));
			return;
		}

		if (ecd == "OrderAllCart" || ecd == "OrderAllCart2"){
			CartType = "1";
		}

		//
		//var url = '/shop/CartList_AA.asp';
		var url = 'CartList_AA.asp';
		var pars = "";
		pars += "ecd=" + Form.escape(ecd) + "&";
		pars += "CartType=" + Form.escape(CartType) + "&";
		pars += "ItemCode=" + Form.escape(str) + "&";
		pars += "OrderQty=" + Form.escape(OrderQty) + "&";
		pars += "Qtys=" + Form.escape(strQty) + "&";
		if ($('SaleMemberNo') == null){
			pars += "SaleMemberNo=&";
		}else{
			pars += "SaleMemberNo=" + Form.escape($('SaleMemberNo').value) + "&";
		}

		loadAjaxXML(url, pars, null, null);

	},

	Qty_change : function(i){
		if (event.srcElement.value == "" || event.srcElement.value == "0"){
			$('chk'+i).checked = false;
		}else{
			$('chk'+i).checked = true;
		}
	},

	popUpMoveNo : function(MoveNo){
		var nWidth  = 1010;
		var nHeight = 700;
		var path = "http://www.doortodoor.co.kr/jsp/cmn/c03a_s1.jsp?invc_no=" + MoveNo;
		openHelpWindow(path, "newMessageWindow", nWidth, nHeight,"fix");
	},

	popup_set_list : function(ItemCode){
		var nWidth  = 550;
		var nHeight = 700;
		var path = "/shop/popup_set_list.asp?ItemCode=" + ItemCode;
		openHelpWindow(path, "newMessageWindow", nWidth, nHeight,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0");
	},

	popup_set_select : function(ItemCode){
		var nWidth  = 550;
		var nHeight = 700;
		var path = "/shop/popup_set_select.asp?ItemCode=" + ItemCode;
		openHelpWindow(path, "newMessageWindow", nWidth, nHeight,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0");
	},

	popup_add_select : function(ItemCode){
		var nWidth  = 900;
		var nHeight = 550;
		var path = "/shop/product/event/20071026_nby200/psp_presentlist_200.htm";
		path = "/20080414/psp_presentlist_190.htm";

		openHelpWindow(path, "newMessageWindow", nWidth, nHeight,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0");
	},

	popup_dddItem1 : function(){
		var nWidth  = 680;
		var nHeight = 510;
		var path = "/popup/hellofriend_presentlist.htm";

		openHelpWindow(path, "newMessageWindow", nWidth, nHeight,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0");
	},

	popup_friend_recommand : function(){
		var nWidth  = 468;
		var nHeight = 400;
		var path = "/shop/popup_friend_recommand.asp";
		openHelpWindow(path, "friend_recommand", nWidth, nHeight,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0");
	}
}
