﻿var xmlHttp;

// XHR 객체를 생성한다.
function createXMLHttpRequest() {
    if(window.ActiveXObject) {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    } else if(window.XMLHttpRequest) {
        xmlHttp = new XMLHttpRequest();
    }
}
//최종가격을 쓸 스판엘리먼트를 정의
var span_id;

// 해당상품의 최종가격을 조회를 한다.
function getlastprice(goods_num,count_id,coupon_id,fiMember_Key,span_id) {
var goods_num = goods_num;
var count_id = count_id;
var coupon_id = coupon_id;
var goods_coupon = "";
var goods_count ="";

var type1 ="";
var selOption ="";
var selOption2 ="";


if (document.getElementById(coupon_id))
{
var goods_coupon = document.getElementById(coupon_id).options[document.getElementById(coupon_id).selectedIndex].value;
}

if (document.getElementById(count_id))
{
var goods_count =document.getElementById(count_id).options[document.getElementById(count_id).selectedIndex].value;
}

if (document.getElementById("type1"))
{
var type1 =document.getElementById("type1").options[document.getElementById("type1").selectedIndex].value;
}
if (document.getElementById("selOption"))
{
var selOption =document.getElementById("selOption").options[document.getElementById("selOption").selectedIndex].value;
}
if (document.getElementById("selOption2"))
{
var selOption2 =document.getElementById("selOption2").options[document.getElementById("selOption2").selectedIndex].value;
}


var fiMember_Key = fiMember_Key;
var param="goods_num="+goods_num+"&goods_count="+goods_count+"&type1="+type1+"&selOption="+selOption+"&selOption2="+selOption2+"&goods_coupon="+goods_coupon+"&fiMember_Key="+fiMember_Key;
var url = "/include/Include.lastprice_xml.asp";

//alert(param);
if (goods_num)// 상품이 없으면 계산중지
	{
		createXMLHttpRequest();
		xmlHttp.onreadystatechange = handleStateChange3;
		xmlHttp.open("POST", url, true);
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlHttp.send(param);
	}
}

// 요청 처리 콜백 함수
function handleStateChange3() {
	if(xmlHttp.readyState == 4) {
        if(xmlHttp.status == 200) {        
         // alert( xmlHttp.responseText); 
		   parselastprice();			
        }
    }
}

// 요청의 결과를 테이블 형태로 동적으로 출력한다.
function parselastprice() {
    var xmlDoc = xmlHttp.responseXML;
	var lastprice_info = xmlDoc.getElementsByTagName("lastprice_info");
	var lastprice = lastprice_info[0].getAttribute("LASTPRICEsum");
	var point = lastprice_info[0].getAttribute("POINT");
	//alert(lastprice);
	//alert(span_id); 
	document.getElementById("last_price").innerHTML= "결제액 : "+ lastprice +"원" ;
	document.getElementById("last_price_point").innerHTML= "("+point+"원 적립)" ;  

	
}

