
/***********************************************************/
/*상품후기 등록*/
/***********************************************************/
function historyOk(f){
	if (!f.pTitle.value){
		alert("제목을 입력해주세요!");
		return false;
	}
	if (!f.pContent.value){
		alert("상품후기를 입력해주세요!");
		return false;
	}
	if (!f.fID.value){
		alert("로그인 후 이용해주세요!")
		return false;
	}

	f.strCode.value=1;
	return true;

}
/***********************************************************/
/*상품후기 삭제*/
/***********************************************************/
function historyDel(f,idx){
	if (confirm("삭제 하시겠습니까?"))	{
		f.strCode.value	= 2;
		f.hIndex.value	= idx;
		f.submit();
	}
}


/***********************************************************/
/*온라인구매 및 장바구니 구매 체크*/
/***********************************************************/
function OrderBuy(f,type){
	if (type==""){
		return false;
	}else{ 
		switch (type){
			case "direct" :  f.action = "/mall/MallOrder.asp";		break;
			case "cart"	  :  f.action = "/mall/MallCartPrc.asp";	break;
		}
		f.OrderType.value=type;
	}
	return true; //f.submit();
	
}

/***********************************************************/
/*장바구니 내용 수정 및 삭제*/
/***********************************************************/
function ImsiOrderChange(f,code){
	var strText = (code=="edit") ? "수정" : "삭제";
	if( confirm(strText +" 하시겠습니까?")){
		f.OrderCode.value=code;
	}else{
		return;
	}
	f.submit();
}


/***********************************************************/
/*결제방법에 따른 정보 입력란 입출력*/
/***********************************************************/
function show_table(obj){
	if( typeof(obj) == "object"){
		var obj_box = document.getElementById("pay_info_table") ?  document.getElementById("pay_info_table") :  document.all["pay_info_table"];
		//var obj_buy = document.getElementById("BuyInfo_code") ?  document.getElementById("BuyInfo_code") :  document.all["BuyInfo_code"];
		switch (obj.value){
		    case "SC0010": obj_box.style.display = 'none'; break; 	//신용카드
		    case "SC0040": obj_box.style.display = 'block'; break; 	//무통장입금
			case "SC0030": obj_box.style.display = 'none'; break; 	//계좌이체
		}
		//obj_buy.value = obj.value;	
	}
	
}

/***********************************************************/
/*배송정보=주문정보 동일 작업*/
/***********************************************************/
function OrderTake(f){
		f.tName.value=f.buyer.value;
		f.tTel1.value=f.fTel1.value;
		f.tTel2.value=f.fTel2.value;
		f.tTel3.value=f.fTel3.value;
		f.tPhone1.value=f.fPhone1.value;
		f.tPhone2.value=f.fPhone2.value;
		f.tPhone3.value=f.fPhone3.value;
		f.tPhone3.value=f.fPhone3.value;
		f.tPhone3.value=f.fPhone3.value;
		f.post.value=f.strzip.value;
		f.add1.value=f.strAddr1.value;
		f.add2.value=f.strAddr2.value;
		f.add2.select();
}
/***********************************************************/
/*온라인 주문 처리(데이콤연동)*/
/***********************************************************/
function buyFormCheck(f,type){
	//모든 정보들의 정확한 입력값확인
	if (OrderOk(f,type)==1){
		var objLayer	= document.getElementById("SeLayer") ?  document.getElementById("SeLayer") :  document.all["SeLayer"];
		var objPrcs1	= document.getElementById("Process_1") ?  document.getElementById("Process_1") :  document.all["Process_1"];
		var objPrcs2	= document.getElementById("Process_2") ?  document.getElementById("Process_2") :  document.all["Process_2"];
		objLayer.style.display = 'block';
		objPrcs1.style.display = 'block';
		objPrcs2.style.display = 'none';
		document.location.href="#";
		//window.open("","Window","top=5, left=5,width=330, height=430, status=yes, scrollbars=no,resizable=yes, menubar=no");
		//		f.action = "https://www.spaceinter.com/TotalMember/cdspace/Dacom/Dacom_Before.asp";
		f.action = "XPay/payreq.asp";
		if ($j("#orderFrame").length == 0) {
		    $j("body").append("<iframe src='' id='orderFrame' name='orderFrame' width=0 height=0 frameborder=0 ></iframe>");
		}
		f.target = "orderFrame";
		return true;
	}
	return false;
}
/***********************************************************/
/*온라인 주문 처리(데이콤연동)*/
/***********************************************************/
function UpBuyFormCheck(f){
	var objLayer	= document.getElementById("SeLayer") ?  document.getElementById("SeLayer") :  document.all["SeLayer"];
	var objPrcs1	= document.getElementById("Process_1") ?  document.getElementById("Process_1") :  document.all["Process_1"];
	var objPrcs2	= document.getElementById("Process_2") ?  document.getElementById("Process_2") :  document.all["Process_2"];
	objLayer.style.display = 'block';
	objPrcs1.style.display = 'block';
	objPrcs2.style.display = 'none';
	document.location.href="#";
	//window.open("","Window","top=5, left=5,width=330, height=430, status=yes, scrollbars=no,resizable=yes, menubar=no");
	//f.action = "https://www.spaceinter.com/TotalMember/cdspace/Dacom/Dacom_Before.asp";
	f.action = "XPay/payreq.asp";
	if ($j("#orderFrame").length == 0) {
	    $j("body").append("<iframe src='' id='orderFrame' name='orderFrame' width=0 height=0 frameborder=0 ></iframe>");
	}
	f.target = "orderFrame";
	return true;
	//f.target = "Window";
	//f.submit();
	//return false;
}

/***********************************************************/
/*온라인 주문 처리중*/
/***********************************************************/
function order_alert(){
	alert("지금 처리중입니다. 잠시만 기다려 주세요.");
	return false;
}

/***********************************************************/
/*온라인 주문 내역 확인*/
/***********************************************************/
function  OrderOk(f,type){
    //무통장입금일 경우 입금자명과 전화번호를 기재하여야함.
/*	
	if (f.BuyInfo_code.value=="CS" || !f.BuyInfo_code.value){
			if (!f.EntName.value){	
				alert("입금자 성명을 입력하여 주세요!");
				f.EntName.focus();
				return false; 
			}
			
			if (!f.EntPhone1.value || !f.EntPhone2.value || !f.EntPhone3.value ){
				alert("입금자 연락처를 입력해주세요!");
				f.EntPhone1.focus();
				return false;
			}
	}
*/	
	if(type == "True"){ //배송정보를 보여줄때 
		if(!f.tName.value){
			alert('수령자를 입력하여 주세요!');
			f.tName.focus();
			return false;
		}else if(!f.tTel1.value){
			alert('전화번호를 입력하여 주세요!');
			f.tTel1.focus();
			return false;
		}else if(!f.tTel2.value){
			alert('전화번호를 입력하여 주세요!');
			f.tTel2.focus();
			return false;
		}else if(!f.tTel3.value){
			alert('전화번호를 입력하여 주세요!');
			f.tTel3.focus();
			return false;
		}else if(CheckInt(f.tTel1) == -1){	
			alert('전화번호는 숫자만 입력가능합니다');
			f.tTel1.focus();
			f.tTel1.select();
			return false;
		}else if(CheckInt(f.tTel2) == -1){
			alert('전화번호는 숫자만 입력가능합니다');
			f.tTel2.focus();
			f.tTel2.select();
			return false;
		}else if(CheckInt(f.tTel3) == -1){
			alert('전화번호는 숫자만 입력가능합니다');
			f.tTel3.focus();
			f.tTel3.select();
			return false;
		}else if(!f.tPhone1.value){
			alert('휴대폰번호를 입력하여 주세요!');
			f.tPhone1.focus();
			return false;
		}else if(!f.tPhone2.value){
			alert('휴대폰번호를 입력하여 주세요!');
			f.tPhone2.focus();
			return false;
		}else if(!f.tPhone3.value){
			alert('휴대폰번호를 입력하여 주세요!');
			f.tPhone3.focus();
			return false;
		}else if(!f.tPhone3.value){
			alert('휴대폰번호를 입력하여 주세요!');
			f.tPhone3.focus();
			return false;
		}else if(CheckInt(f.tPhone1) == -1){
			alert('휴대폰번호는 숫자만 입력가능합니다.');
			f.tPhone1.focus();
			f.tPhone1.select();
			return false;
		}else if(CheckInt(f.tPhone2) == -1){
			alert('휴대폰번호는 숫자만 입력가능합니다.');
			f.tPhone2.focus();
			f.tPhone2.select();
			return false;
		}else if(CheckInt(f.tPhone3) == -1){
			alert('휴대폰번호는 숫자만 입력가능합니다.');
			f.tPhone3.focus();
			f.tPhone3.select();
			return false;
		}else if(!f.post.value){
			alert('우편번호를 입력하여 주세요!');
			f.post.focus();
			return false;
		}else if(!f.add1.value){
			alert('주소를 입력하여 주세요!');
			f.add1.focus();
			return false;
		}else if(!f.add2.value){
			alert('주소를 입력하여 주세요!');
			f.add2.focus();
			return false;
		}else if (!f.fEmail.value){
			alert('이메일을 등록하여 주세요!');
			f.fEmail.focus();
			return false;
		
		}
		
	}else{ 
		if (!f.fEmail.value){
			alert('이메일을 등록하여 주세요!');
			f.fEmail.focus();
			return false;
		}else if (!f.buyer.value){
			alert('주문자를 등록하여 주세요!');
			f.buyer.focus();
			return false;
		}
		
	}

	return 1;
	
}


/***********************************************************/
/*//숫자체크 (숫자아니면 에러(-1))*/
/***********************************************************/
function CheckInt(Objectname) {  
	var intErr
	var newValue = Objectname.value
	var newLength = newValue.length;

	for(var i=0; i != newLength; i++) {
		aChar = newValue.substring(i, i+1)
		if(aChar < "0" || aChar > "9")
		{
			intErr = -1;
			break;
		}
	}
	return (intErr);
}


