/* utf-8 인코딩 */
function doUseCoupon(cshop_coupon_id, coupon_name)
{
	if (confirm(coupon_name + " 쿠폰을 지금 사용 하시겠습니까?") == false)
		return ;

	sendXmlHttpRequest(gURL_root + "/api/set/cshop.coupon.register", {
		cshop_coupon_id: cshop_coupon_id
	}, function(oHTTP)
	{
		var oXML = oHTTP.responseXML;

		// 오류 발생인 경우, 메시지 그대로 출력
		if (oXML.selectSingleNode("/response/code/text()").nodeValue != "0")
		{
			var message = oXML.selectSingleNode("/response/message/text()").nodeValue;
			alert(message);
			return ;
		}
		else
		{
			var data = oXML.selectSingleNode("/response/data/text()").nodeValue;
			alert(data);
			location.href = '/sites/front.php/mystudy/mylecture';
		}

	});
}

function checkCouponInfo()
{	
	var coupon_no = g('coupon_no1').value + '-' + g('coupon_no2').value + '-' + g('coupon_no3').value + '-' + g('coupon_no4').value;

	if (coupon_no.length == 3)
	{
		alert("쿠폰번호를 입력해 주세요.");
		g('coupon_no1').focus();
		return ;
	}
	else if (coupon_no.length != 19)
	{
		alert("쿠폰번호를 정확히 입력해 주세요.");
		return ;
	}

	sendXmlHttpRequest(gURL_root + "/api/set/cshop.coupon.scrap", {
		coupon_no: coupon_no
	}, function(oHTTP)
	{
		var oXML = oHTTP.responseXML;

		// 오류 발생인 경우, 메시지 그대로 출력
		if (oXML.selectSingleNode("/response/code/text()").nodeValue != "0")
		{
			var message = oXML.selectSingleNode("/response/message/text()").nodeValue;
			alert(message);
			return ;
		}
		else
		{
			var data = oXML.selectSingleNode("/response/data/text()").nodeValue;
			alert(data);
			location.href = '/sites/front.php/mystudy/couponbox?tab_id=list';
		}

	});

}


