function LoadJslbAjax(){
    if(typeof(sendRequest)=='undefined' && typeof(createHttpRequest)=='undefined'){
        document.write('<scr'+'ipt type="text/javascript" src="/js/front19/common/jslb_ajax.js"></scr'+'ipt>');
    }
}
LoadJslbAjax();

function comment_del(iNo){
    msg = "정말로 삭제 하시겠습니까?";

    if( !confirm( msg ) )
    {
        return false;
    }

    if(iNo){
        var frm = document.afternote_frm;
        frm.mode.value = 'del';
        frm.no.value = iNo;
        frm.submit();
    }
}

function go_submit()
{
    var aForm = document.afternote_frm;
    if (!aForm.writer_name.value) {
        alert('작성자를 입력하세요.');
        aForm.writer_name.focus();
        return false;
    }
    if (!aForm.passwd.value) {
        alert('비밀번호를 입력하세요.');
        aForm.passwd.focus();
        return false;
    }
    if (!aForm.content.value) {
        alert('내용을 입력하세요.');
        aForm.content.focus();
        return false;
    }

    aForm.subject.value = aForm.subject.value.replace('MEMBER_NAME', aForm.writer_name.value);

    return true;
}

function viewImageNew(name, url, no, board_no) {
    window.open('/Front/Board/?url=PreviewImage&name='+encodeURI(name)+'&image='+url+'&no='+no+'&board_no='+board_no, 'view_image', 'width=0, height=0');
}

function viewImage(no, url) {
    window.open('/Front/Board/?url=PreviewImage&name='+encodeURI(document.getElementById('dWriter'+no).innerHTML)+'&image='+url, 'view_image', 'width=0, height=0');
}

function stringToHex (s) {
    s = encodeURI(s);
    var r = "0x";
    var hexes = new Array ("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f");
    for (var i=0; i<s.length; i++) {r += hexes [s.charCodeAt(i) >> 4] + hexes [s.charCodeAt(i) & 0xf];}
    return r;
}

function add_basket( arg )
{
    createHiddenIframe();

    // 세트상품일경우
    // 김형민(New 세트)
    var p_set_prd_flag = document.frm.p_set_prd_flag.value;
    if(p_set_prd_flag == 'T') {
        if(newBasketSetPrd(arg)) {
            frm.target = 'hidden_ifr';
            frm.command.value = 'add';
            frm.redirect.value = arg ;
            frm.product_url.value = document.location.href;
            frm.submit();
        }
    } else {
        if( check_frm() )
        {
            frm.target = 'hidden_ifr';
            frm.command.value = 'add';
            frm.redirect.value = arg ;
            frm.product_url.value = document.location.href;
            if(frm.option13 != undefined){
                alert('상품옵션은 15개까지만 가능합니다.\n관리자에 문의하십시요');
                return;
            }
            
            var obj = document.getElementsByName('optVal[]');
        	
        	if (obj.length > 0) {
        		document.getElementById('prd_item_code').outerHTML = '';        		        		
        	}        	
            frm.submit();
        }
    }
    
   
}

/**
 * 첨부파일 삭제
 */
function del_and_reupload(oSelf, sTargetId, no){

    var myform = eval('document.afternote_frm'+no+'.'+sTargetId);
    if(oSelf.checked==true) myform.disabled = false;
        else myform.disabled = true;

}

function add_wish_lists(product_no, main_cate_no) {
    if (check_frm()) {
        var frm = document.frm;
        var orgAction = frm.action;
        var orgTarget = frm.target;
        createHiddenIframe();
        frm.action = '/Front/Product/?url=wish';
        frm.target = 'hidden_ifr';
        frm.submit();
        frm.action = orgAction;
        frm.target = orgTarget;
    }
}

function setDelvPayment() {
    var frm = document.frm;
    var idx = frm.delv_payment_option.selectedIndex;
    var sValue = frm.delv_payment_option.options[idx].value;
    //delvType
    if (sValue == 'C' && frm.delvType) {
        if (document.getElementById('delvTypeB').checked === true) {
            alert('해외배송일 경우에는 배송비가 선결제만 가능합니다.');
            frm.delv_payment_option.options[2].selected = true;
        }
    }
    frm.delv_payment.value = frm.delv_payment_option.options[idx].value;
}

function setDelvPaymentForeign(sType)
{
    var frm = document.frm;
    if (sType == 'B' && frm.delv_payment_option) {//해외배송인데 착불이면 에러
        var idx = frm.delv_payment_option.selectedIndex;
        if (frm.delv_payment_option.options[idx].value != 'P') {
            alert('해외배송일 경우에는 배송비가 선결제만 가능합니다.');
            frm.delv_payment_option.options[2].selected = true;
            frm.delv_payment.value = 'P';
        }
    }

    // 네이버 체크아웃
    check_naverchk(sType);
}

function check_frm(sPrdCode) {

    // new 세트 상품일 경우 - 김형민
    var bNewSet = (arguments[1] && arguments[1] == 'newSet') ? true : false;

    if (sPrdCode) {
        var frm = document.set_prd_list;
        if(bNewSet) frm = document.frm;
        iPrdItemTypeTmp = eval('iPrdItemType' + sPrdCode);
        iOptionsLenTmp = eval('iOptionsLen' + sPrdCode);
        sOptionsTmp = eval('sOptions' + sPrdCode);
    } else {
        var frm = document.frm;
        var sPrdCode = '';
        iPrdItemTypeTmp = iPrdItemType;
        iOptionsLenTmp = iOptionsLen;
        sOptionsTmp = sOptions;
        //var key = getItemKey();
        //alert(iPrdItemType);
        /*if (sOptions['content'][key]['pi_sold'] == 'F') {
            alert('선택하신 상품은 품절 상품입니다.');
            return false;
        }*/
    }

    if (iPrdItemTypeTmp != 1) {
        for (var i=0; i < iOptionsLenTmp; i++) {
            oObj = document.getElementById('option' + sPrdCode + i);
            if (oObj.options.selectedIndex < 1 && oObj.options[oObj.options.selectedIndex].value == '') {
                alert('필수 옵션이 선택되지 않았습니다.');
                oObj.focus();
                return false;
            }
        }
    }

    if (iPrdItemTypeTmp != '1') {
        var key = getItemKey(iOptionsLenTmp, sPrdCode, '', arguments[1]);
        if (sOptionsTmp['content'][key] == undefined || !sOptionsTmp['content'][key]) {
            alert('선택하신 상품은 품절 상품입니다.');
            return false;
        }
        if (key && (sOptionsTmp['content'][key]['pi_sold'] == 'F' || sOptionsTmp['content'][key]['pi_sell_flag'] == 'T')) {
            alert('선택하신 상품은 품절 상품입니다.');
            return false;
        }
    }

    if (frm['p_sale_price_type'+sPrdCode].value == 'M') {
        alert("이 상품은 일시적으로 판매가 중지된 상품입니다.");
        return false;
    }

    if (frm['p_sell_flag'+sPrdCode].value == 'F') {
        alert('선택하신 상품은 품절 상품입니다.');
        return false;
    }

    if (parseInt(frm['product_price'+sPrdCode].value) <= 0) {
        alert('상품가격이 0원 이하인 상품은 구매하실 수 없습니다.');
        return false;
    }

    if (frm.delv_payment_option) {
        var idx = frm.delv_payment_option.selectedIndex;
        if (document.frm.delv_payment.value == '' || document.frm.delv_payment.value == 'B' || frm.delv_payment_option.options[idx].value == '') {
            alert('배송비 결제 여부를 선택하세요');
            return false;
        } else {
            document.frm.delv_payment.value = frm.delv_payment_option.options[idx].value;
        }
    }

    if (document.getElementById('delvTypeA') && document.getElementById('delvTypeB')) {
        if (document.getElementById('delvTypeB').checked === true && frm.delv_payment.value == 'C') {
            alert('배송비가 착불일경우에는 해외배송을 할수 없습니다.');
            return false;
        }
    }

    // by jsyoon 옵션문구 크기 체크
    //추가옵션 분석후 다시...khlee2
    if(frm.option_add != undefined && frm['add_option_name'+sPrdCode] != undefined) {
        var txtval = frm['add_option_name'+sPrdCode].value
        var bsize = 0;
        bsize = 255 - str_size_check(txtval) - 1;
        if(!frm.option_add.value.length) {
            alert('필수옵션이 선택되지 않았습니다');
            return false;
        }

        if(!check_byte(frm.option_add, bsize, "옵션문구는 한글 " + Math.floor(bsize / 2) + "자이내로만 입력가능합니다.")){
            frm.option_add.focus();
            return false;
        }
    }

    if (sPrdCode == '' && document.getElementById('add_option_cnt') && document.getElementById('add_option_cnt').value > 0) {
        var iAddOptCnt = document.getElementById('add_option_cnt').value;
        for(var i=0; i < iAddOptCnt; i++) {
            if (frm['option_add['+i+']'].value == '') {
                alert('필수옵션이 선택되지 않았습니다');
                frm['option_add['+i+']'].focus();
                return false;
            } else {
                if(!check_byte(frm['option_add['+i+']'], 255, "옵션문구는 한글 " + Math.floor(255 / 2) + "자이내로만 입력가능합니다.")){
                    frm.option_add.focus();
                    return false;
                }
            }
        }
    }

    var addDiv = document.getElementById('addDiv');
    var arr = new Array();
    if (addDiv) {
        arr = addDiv.getElementsByTagName("TABLE");
    }


    if(!sPrdCode){
        if(arr.length==0){

        }else{
            var cfa = check_frm_arr(arr.length, arr);
            if(cfa){
                return true;
            }else{
                return false;
            }

        }
    }

    //세트상품일경우는 수량입력 key값이 틀림
    var sPrdQtyCode = 'quantity';
    
    if (frm['p_set_prd_flag'] && frm['p_set_prd_flag'].value == 'T') {
        sPrdQtyCode = 'set_product_qty_';
    }

    if (frm[sPrdQtyCode+sPrdCode]) {
        if (! frm[sPrdQtyCode+sPrdCode].value) {
            alert ('수량을 입력해 주십시오.');
            frm[sPrdQtyCode+sPrdCode].focus();
            return false;
        }

        for (i = 0; i < frm[sPrdQtyCode+sPrdCode].value.length; i++) {
            if (! (frm[sPrdQtyCode+sPrdCode].value.charAt(i) >= '0' && frm[sPrdQtyCode+sPrdCode].value.charAt(i) <= '9')) {
                alert ('수량은 숫자만 가능합니다.');
                frm[sPrdQtyCode+sPrdCode].select();
                return false;
            }
        }
        if (parseInt(frm[sPrdQtyCode+sPrdCode].value) < 1) {
            alert('주문수량은 1개 이상이어야 합니다.');
            frm[sPrdQtyCode+sPrdCode].select();
            return false;
        }
    }

    if (!frm['prd_item_code'+sPrdCode].value) {
        alert('필수 옵션이 선택되지 않았습니다.');
        return false;
    }

    if (frm[sPrdQtyCode+sPrdCode]) {
        if (parseInt(frm['product_min'+sPrdCode].value) > 0) {
            if (parseInt(frm[sPrdQtyCode+sPrdCode].value) < parseInt(frm['product_min'+sPrdCode].value)) {
                alert ('최소 주문수량은 ' + frm['product_min'+sPrdCode].value + ' 입니다.');
                frm.quantity.select();
                return false;
            }
        }

        if (parseInt(frm['product_max'+sPrdCode].value) > 0) {
            if (parseInt(frm[sPrdQtyCode+sPrdCode].value) > parseInt(frm['product_max'+sPrdCode].value)) {
                alert('최대 구매수량은 ' + frm['product_max'+sPrdCode].value + ' 입니다.');
                frm['quantity'+sPrdCode].select();
                return false;
            }
        }
    }/* else {
        if (parseInt(frm['product_min'+sPrdCode].value) > 1) {
            alert ('최소 주문수량은 ' + frm['product_min'+sPrdCode].value + ' 입니다.' + sPrdCode);
            frm[sPrdQtyCode+sPrdCode].select();
            return false;
        }
    }*/

    if (parseInt(frm['product_buy_qty'+sPrdCode].value) > 1) {
        var iBuyQty = frm[sPrdQtyCode+sPrdCode].value;
        if ((iBuyQty % frm['product_buy_qty'+sPrdCode].value) != 0)    {
            alert('주문 수량단위는 ' + frm['product_buy_qty'+sPrdCode].value + "단위 입니다.");
            return false;
        }
    }

    return true;
}

/**
  * 비밀글 내용 가져오기
  */
function getAjaxList( idx, board_no ) {
    var password = eval('document.all.password_' + idx + '.value');
    var url = "/Front/Board/?url=GetSecretContent" + "&secret_passwd=" + password + "&no=" + idx + "&board_no=" + board_no;
    var content = eval('(' + getHttprequest(url) + ')');

    if (content[1] == '1') {
        obj = eval('document.all.content_' + idx);
        obj.innerHTML = content[0];
    }else {
        alert(content[0]);
        return;
    }
}

function review_read( id )
{
    show_id = document.all[id]

    if( show_id.style.display == 'block' )
    {
        show_id.style.display = 'none'
    }
    else
    {
        show_id.style.display = 'block'
    }
}

function recommend_mail_pop( product_no, category_no, display_group )
{

        //alert('추천메일보내기 준비중입니다.');

        option = "'toolbar=no," +
                "location=no," +
                "directories=no," +
                "status=no," +
                "menubar=no," +
                "scrollbars=yes," +
                "resizable=yes," +
                "width=576," +
                "height=568," +
                "top=300," +
                "left=200"

    filename = "/front/php/recommend_mail/recommend_mail.php?product_no=" + product_no + "&category_no=" + category_no;
    filename += "&display_group=" + display_group

        open_window( filename, option, "recommend_mail_pop" );
}

function changeImage(img_url, width, height){
    /// 이미지의 실제 크기와 비교하여 이미지 미리보기 크기를 지정해줌 2009-04-

    var big_img = document.getElementsByName('big_img')[0];
    if(width) {
        big_img.width = width;
    } else {
        big_img.removeAttribute('width');
    }
    if(height) {
       big_img.height = height;
    } else {
        big_img.removeAttribute('height');
    }

    big_img.src = img_url;

    event.toElement.onmouseout = function() {
        big_img.src = document.frm.product_org_img.value;
    }
    return;
}

// 상품의 복합형, 조합형별로 옵션 아이디를 가져오는 함수
// by jsyoon 05/11/17
function get_option_ids(otype, idx) {
    var count = 0;
    var thisfrm = document.frm;
    var selfrm;
    var retval = '';
    var tmpval;

    // 조합형인경우
    if(otype == 'T') {
        if(thisfrm.opid.length == undefined){
            selfrm = eval("document.frm." + thisfrm.opid.value);
            tmpval = selfrm.options[selfrm.options.selectedIndex].value;
            if(tmpval == 0)
                return '';
            return  tmpval + "-0-0";
        }
        for(var i =0; i < 3; i++) {
            if(thisfrm.opid[i] == undefined){
                    tmpval = 0;
            } else {
                selfrm = eval("document.frm." + thisfrm.opid[i].value);
                tmpval = selfrm.options[selfrm.options.selectedIndex].value;
                // 옵션중 선택되지 않은 항목이 있는경우 return
                if(tmpval == 0)
                    return '';
            }

            if(i == 0)
                retval =+ tmpval;
            else
                retval = retval + "-" + tmpval;
        }
        // 복합형인경우
    } else if(otype == 'F'){
        for(var i =0; i < 3; i++) {
            if(i == (idx - 1)) {
                if(thisfrm.opid.length == undefined)
                    selfrm = eval("document.frm." + thisfrm.opid.value);
                else
                    selfrm = eval("document.frm." + thisfrm.opid[i].value);
                tmpval = selfrm.options[selfrm.options.selectedIndex].value;
            } else {
                tmpval = 0;
            }
            if(i == 0)
                retval =+ tmpval;
            else
                retval = retval + "-" + tmpval;
        }
    } else if(otype == 'E'){
        if(thisfrm.opid.length == undefined)
        {
            selfrm = eval("document.frm." + thisfrm.opid.value);
        }
        else
        {
            selfrm = eval("document.frm." + thisfrm.opid[(idx - 1)].value);
        }

        tmpval = selfrm.options[selfrm.options.selectedIndex].value;
            if(tmpval == 0)
            return '';
        retval = idx + "-" + tmpval;

    }
    return retval;
}

function coupon_apply(no)
{
    var frm = eval("document.coupon_" + no);
    frm.submit();
}

function setReviewWrite(product_no, main_cate_no, display_group, flag)
{
    if (flag == 'O') {
        var text = "상품평은 해당상품의 주문내역이 있을시 작성가능합니다.\n\n주문페이지로 이동하시겠습니까?";
        if (confirm(text) === true) {
            document.location.href='/Front/Myshop/?url=orders';
        }
    } else {
        document.location.href='/Front/Board/?url=write&board_no=4&product_no=' + product_no + '&main_cate_no=' + main_cate_no + '&display_group=' + display_group;
    }
}


function view_stock_list(iCnt, sPrdCode) {
    window.open('/Front/Product/?url=Stocklist&product_no=' + sPrdCode, '', 'width=440, height=300, scrollbars=yes, resizable=no');
}

function chkSetProd()
{
    var frm = document.set_prd_list;
    var field = frm['setPrdListAdd[]'];
    var chkLen = field.length;
    if (chkLen) {
        for (var i=0; i < chkLen; i++) {
            if (field[i].checked === true) {
                field[i].checked = false;
            } else {
                field[i].checked = true;
            }
        }
    } else {
        if (field.checked === true) {
            field.checked = false;
        } else {
            field.checked = true;
        }
    }
}

function changeSetPrdCnt(mod, sPrdCode)
{
    var el = document.getElementById('quantity_' + sPrdCode);
    var qty = parseInt(el.value);
    if (mod == 'up') {
        el.value = qty + 1;
    } else if (mod == 'down') {
        if (qty < 2) {
            alert('1개 이상 선택하셔야 합니다.');
            return false;
        } else {
            el.value = qty - 1;
        }
    }
    reloadPriceCalc();
}

// 옵션 수량 변경 (2011-05-04, shmin)
function changeSetSubPrdCnt(mod, id)
{
    var el = document.getElementById(id);
    var qty = parseInt(el.value);
    if (mod == 'up') {
        el.value = qty + 1;
    } else if (mod == 'down') {
        if (qty < 2) {
            alert('1개 이상 선택하셔야 합니다.');
            return false;
        } else {
            el.value = qty - 1;
        }
    }
    reloadPriceCalc();
}

function getItemKey(iOptionsLenTmp, sPrdCodeTmp, that_num)
{
    // new 세트 상품일 경우 - 김형민
    var bNewSet = (arguments[3] && arguments[3] == 'newSet') ? true : false;

    var aOptTitle = new Array();
    /*for (var i = 0; i < iOptionsLen; i++) {
        oObj = document.getElementById('option' + i);
        tmpTitle = oObj.options[oObj.options.selectedIndex].value.split('::');
        for (var j=0; j < tmpTitle.length; j++) {
            title = tmpTitle[j].split('||');
            aOptTitle.push(title[1]);
        }
    }*/
    var bResult = true;
    var aTmpOpt = new Array(0, 0);
    var arr = new Array();;

    var addDiv = document.getElementById('addDiv');
    if(addDiv){
        arr = addDiv.getElementsByTagName("TABLE");
    }
    if (that_num){
        aTmpOpt = that_num.split('||');
    }

    if (sPrdCodeTmp) {
        var frm = document.set_prd_list;
        if(bNewSet) frm = document.frm;

    } else {
        var frm = document.frm;
    }

    for (var i = 0; i < iOptionsLenTmp; i++) {
        if(arr.length==0){
            oObj = frm['option' + sPrdCodeTmp + i];
        } else {
            oObj = frm['option' + sPrdCodeTmp + i][aTmpOpt[0]];
            if (!oObj.options) oObj = frm['option' + sPrdCodeTmp + i];
        }

        if (oObj.options.selectedIndex < 1 && oObj.options[oObj.options.selectedIndex].value == '') {
            bResult = false;
            break;
        }
    }

    if (bResult === true) {

        for (var i = 0; i < iOptionsLenTmp; i++) {
            if(arr.length==0){
                oObj = frm['option' + sPrdCodeTmp + i];
            } else {
                oObj = frm['option' + sPrdCodeTmp + i][aTmpOpt[0]];
                if (!oObj.options) oObj = frm['option' + sPrdCodeTmp + i];
            }
            tmpTitle = oObj.options[oObj.options.selectedIndex].value.split('::');
            for (var j=0; j < tmpTitle.length; j++) {
                tmpTitle[j] = ''+tmpTitle[j];
                var title = tmpTitle[j].split('||');
                if (title[1]) {
                    aOptTitle.push(title[1]);
                }
            }
        }
    }

    return aOptTitle.join('%2C');
}

function setItem(that) {			
    var pay_currency = document.frm.pay_currency.value;
    var that_num = '';
    var arr = new Array();
    if(!that){
        v_opt_num=0;
        opt_num=0;

    }else{
        that_num = parentCheck(that);
        that_num_sp = that_num.split("||");
        v_opt_num = that_num_sp[0];
        opt_num = that_num_sp[1];
    }

    if (document.getElementById('p_sale_price_type').value == 'M') return;
 
    if (iPrdItemType == '1') {
    } else {
    
        //재입고 sms 버튼 감추기준다
        if(document.getElementById('smsStockImg'))document.getElementById('smsStockImg').style.display="none";

        var oObj = null;

        var oPriceObj = document.getElementById('assign_prd_sale_price_text');
        var orgPrice = document.frm.product_price.value.replace(/,/gi, '')        

        if (oPriceObj) {
            var sNode = oPriceObj
        } else {
            var sNode = null;
        }

        var addDiv = document.getElementById('addDiv');
        if(addDiv){
            arr = addDiv.getElementsByTagName("TABLE");
        }

        if (arr.length == 0) {
            var oItemObj = document.getElementById('prd_item_code');
        } else {
            var oItemObj = document.frm['prd_item_code'][v_opt_num];
        }

        try {
            var key = getItemKey(iOptionsLen, '', that_num);
  
            if (key != '') {
                if (sNode != null && (sOptions['content'][key] == undefined || !sOptions['content'][key] || sOptions['content'][key]['pi_sold'] == 'F' || sOptions['content'][key]['pi_sell_flag'] == 'T')) {

                    /*for (var i = 0; i < iOptionsLen; i++) {
                        oObj = document.getElementById('option' + i);
                        //oObj.selectedIndex = 0;
                    }*/
                    oItemObj.value = '';                   

                    if (v_opt_num == 0) {
                        if(!document.frm.category_key) {
                            sNode.parentNode.style.display = 'none';
                        }
                        //'<font style="font-weight:bold;font-style:normal;color:red">품절</font>';
                        //풀절일때 재입고 sms 버튼 보여준다                               
                        if(document.getElementById('smsStockImg'))document.getElementById('smsStockImg').style.display="";
                        if(document.getElementById('optname'))document.getElementById('optname').innerHTML = decodeURIComponent(key);
                        if(sOptions['content'][key] && document.getElementById('s_prd_item_code'))document.getElementById('s_prd_item_code').value = sOptions['content'][key]['pi_item_code'];
                        
                        if (!document.getElementById('oSoldElementArea')) {
                            try {
                                var oSoldElement = document.createElement('SPAN');
                                oSoldElement.style.fontWeight = 'bold';
                                oSoldElement.style.fontStyle = 'normal';
                                oSoldElement.style.color = 'red';
                                oSoldElement.id = 'oSoldElementArea';
                                oSoldElement.innerText = ' 품절';
                                document.getElementById('main_opt_price').appendChild(oSoldElement);
                                
                               
                            } catch(e) {}
                        }
                            // 네이버 체크아웃
                            check_naverchk('B');
                    }
                    if(!document.frm.category_key) {
                        return false;
                    }
                }
                if (sOptions['content'][key]) oItemObj.value = sOptions['content'][key]['pi_item_code'];
               
                if (v_opt_num == 0) {
                    try {
                        //var price = obj.childNodes[1].innerHTML.replace(',', '');
                        if (document.getElementById('oSoldElementArea') && sOptions['content'][key]['pi_sold'] == 'T') {

                            document.getElementById('main_opt_price').removeChild(document.getElementById('oSoldElementArea'));
                            sNode.parentNode.style.display = 'inline';
                        }

                        if (sOptions['content'][key] && sOptions['content'][key]['pi_opt_price'] > 0) {
                            var price = parseFloat(orgPrice) + parseFloat((sOptions['content'][key]['pi_opt_price_type'] + sOptions['content'][key]['pi_opt_price']));
                            sNode.innerHTML =  priceFormat(price, pay_currency, ',');
                            setOrgItemPrice(price);                            
                        } else {                        	
                            sNode.innerHTML = priceFormat(orgPrice, pay_currency, ',');
                            setOrgItemPrice(orgPrice);
                        }
                        setMemDiscountCalc(oItemObj.value);
                        reloadPriceCalc();

                            // 네이버 체크아웃
                            check_naverchk('B');
                    } catch(e) {}
                }
                // 네이버 체크아웃
                check_naverchk('A');
            } else {
                if (v_opt_num == 0) {
                    try {
                        if (document.getElementById('oSoldElementArea')) {
                            document.getElementById('main_opt_price').removeChild(document.getElementById('oSoldElementArea'));
                            sNode.parentNode.style.display = 'inline';
                        }
                        sNode.innerHTML = priceFormat(orgPrice, pay_currency, ',');
                        setOrgItemPrice(orgPrice);
                        setMemDiscountCalc();
                        reloadPriceCalc();
                    } catch(e) {}
                }
            }
        } catch(e) {
            oItemObj.value = '';
        }
    }

    return true;
}

function setOrgItemPrice(price) {
    if(document.getElementById('opt_price_flag')) {
        if (document.getElementById('assign_prd_sale_price') && document.getElementById('opt_price_flag').value == 'T') {
            document.getElementById('assign_prd_sale_price').value = price;
        }
    } else {
        if (document.getElementById('assign_prd_sale_price')) {
            document.getElementById('assign_prd_sale_price').value = price;
        }
    }
}

function setMemDiscountCalc(sStr) {
    var oDiscountFields = document.getElementById('assign_prd_discount_price_text');
    if (!oDiscountFields) return;
    var sItemCode = '';
    if (sStr) {
        sItemCode = sStr;
    }
    var params = "&product_no="+document.frm.product_no.value+"&sItemCode="+sItemCode;
    sendRequest(setDcMileage, params, 'POST', '/Front/Product/?url=setDiscountPrice&', true, true);
}

function setDcMileage(oj) {
    if (oj) {
        eval('var res = ' + oj.responseText);
        var pay_currency = document.frm.pay_currency.value;
        //var oPriceObj = document.getElementById('assign_prd_discount_price_text');
        var oMileagePrice = document.getElementById('detail_mileage_price');
        //oPriceObj.innerHTML = res.dc_price.replace(/ /gi, '');
        if (oMileagePrice) {
            oMileagePrice.innerHTML = res.mileage.replace(/ /gi, '');
        }

        if (document.getElementById('assign_prd_discount_price')) {
            document.getElementById('assign_prd_discount_price').value = res.dc_price.replace(/,/gi, '');
        }
        reloadPriceCalc();
    }
}

/**
* 세트 상품 - 김형민
*/
function newBasketSetPrd(arg) {
    var frm = document.frm;
    var iPrdLen = frm['newSetPrdAdd[]'].length;
    var aPrdCode = new Array();
    var bResult = true;

    for (var i=0; i < iPrdLen; i++) {
        if (frm['newSetPrdAdd[]'][i].checked === true) {
            aPrdCode.push(frm['newSetPrdAdd[]'][i].value);
        }
    }

    if (aPrdCode.length < 1) {
        alert('장바구니에 담을 세트상품을 선택해 주세요');
        return false;
    }

    // 세트 구매 시 최소 구매 개수 확인
    var p_set_each_buy_flag = frm['p_set_each_buy_flag'].value;
    var p_set_each_buy_cnt = frm['p_set_each_buy_cnt'].value;
    // 세트상품 개별구매 가능 여부
    if(p_set_each_buy_flag == 'T') {
        // 최소 개별 구매수
        if(p_set_each_buy_cnt > aPrdCode.length) {
            alert('최소 개별 구매 상품수는 '+p_set_each_buy_cnt+'개 입니다.');
            return false;
        }
    }

    for (var i=0; i < aPrdCode.length; i++) {
        if (check_frm(aPrdCode[i], 'newSet') == false) {
            bResult = false;
            break;
        }
    }

    //원래상품 현재보고있는상품 체크
    if (bResult != false) {
        bResult = check_frm();
    }

    if (bResult === false) {
        return false;
    }

    return true;
}


function setPriceSetProduct(obj)
{
    eval('var rs = ' + obj.responseText);

    if (document.getElementById('assign_prd_sale_price_text')) {
        document.getElementById('assign_prd_sale_price_text').innerHTML = rs.sale_price;
    }

    if (document.getElementById('assign_prd_discount_price_text')) {
        document.getElementById('assign_prd_discount_price_text').innerHTML = rs.discount_price;
    }

    document.frm.product_price.value = rs.discount_price.replace(/,/gi, '');
}

function checkNumberEC(val)
{
    if (isNaN(val)) { return false; } 
	var pattern = /^[0-9]+$/;
    return (pattern.test(val)) ? true : false;
}

function setSetPrdCheckQty(oObj)
{
    if(checkNumberEC(oObj.value) == false) {
        oObj.value = 1;
	    event.returnValue=false; 
    } else {
        calcProductPrice();
    }
}

/**
* 세트상품 가격 계산
*/
function calcProductPrice()
{
    //세트상품 갯수
    var iSetPrdCnt = document.frm['newSetPrdAdd[]'].length;
    //선택된 세트상품코드
    var aCheckedSetPrd = new Array();
    //선택된 상품이 옵션이 선택되었을경우나 단품일경우 아이템코드
    var aCheckedSetItem = new Array();
    //해당 상품의 갯수
    var aCheckedSetCnt = new Array();
    var sPrdCode = '';
    for (var iCnt = 0; iCnt < iSetPrdCnt; iCnt++) {
        //alert(document.frm['newSetPrdAdd[]'][iCnt].value);
        if (document.frm['newSetPrdAdd[]'][iCnt].checked == true) {
            sPrdCode = document.frm['newSetPrdAdd[]'][iCnt].value;

            aCheckedSetPrd.push(sPrdCode);
            aCheckedSetItem.push(document.frm['prd_item_code' + sPrdCode].value);
            if (document.frm['set_product_qty_' + sPrdCode]) {
                aCheckedSetCnt.push(document.frm['set_product_qty_' + sPrdCode].value);
            } else {
                aCheckedSetCnt.push(1);
            }
        }
    }

    var params = '&aCheckedSetCnt='+aCheckedSetCnt.join('|')+'&aCheckedSetItem=' + aCheckedSetItem.join('|') + '&aCheckedSetPrd=' + aCheckedSetPrd.join('|') + '&sPrdCode=' + document.frm.product_no.value;
    
    sendRequest(setPriceSetProduct, params,'POST', '/Front/Product/?url=Setdiscountpriceset', true, false);

    
    /*var sSetPrdCodes = document.getElementById('p_set_prd_code_list').value;

    if (sSetPrdCodes != '') {
        var  aSetPrdCodes = sSetPrdCodes.split('|');
        var iCnt = 0;

        for (iCnt = 0; iCnt < aSetPrdCodes.length; iCnt++) {
            //alert(aSetPrdCodes[iCnt]);
        }
    }*/
    // 선택된 상품 정보를 가져온다.
    /*var frm = document.frm;
    var pay_currency = frm['pay_currency'].value;
    var iPrdLen = frm['newSetPrdAdd[]'].length;
    var aPrdCode = new Array();
    for (var i=0; i < iPrdLen; i++) {
        if (frm['newSetPrdAdd[]'][i].checked === true) {
            aPrdCode.push(frm['newSetPrdAdd[]'][i].value);
        }
    }

    // new 세트 값
    var sSetPriceCalc = frm['p_set_price_calc'].value;
    var sSetPrdInfo = frm['p_set_prd_info'].value;
    var jsonPrdInfo = eval("(" + sSetPrdInfo + ")");

    var salePer = jsonPrdInfo.value;
    var cutType = jsonPrdInfo.cutting;
    var cutRound = jsonPrdInfo.cutting_round;

    var totalSalePrice = 0; // 총 판매가.20100614
    var totalDiscountPrice = 0; // 총 할인가.20100614
    for(var k=0; k<aPrdCode.length; k++)
    {
        var sTmpPrdCode = aPrdCode[k];
        var sTmpPrice = frm['product_price'+sTmpPrdCode].value;

        var iPrdItemTypeTmp = eval('iPrdItemType' + sTmpPrdCode);
        var iOptionsLenTmp = eval('iOptionsLen' + sTmpPrdCode);
        var sOptionsTmp = eval('sOptions' + sTmpPrdCode);

        // 단일 상품이 아닐경우
        if(iPrdItemTypeTmp != '1') {
            var oObj = null;
            var aOptTitle = new Array();

             for (var i = 0; i < iOptionsLenTmp; i++) {
                oObj = document.getElementById('option' + sTmpPrdCode + i);
                tmpTitle = oObj.options[oObj.options.selectedIndex].value.split('::');
                for (var j=0; j < tmpTitle.length; j++) {
                    title = tmpTitle[j].split('||');
                    aOptTitle.push(title[1]);
                }
            }

            try
            {
                var key = aOptTitle.join('%2C');
                var tmpOptPrice = sOptionsTmp['content'][key]['pi_opt_price'];
                var tmpOptPriceType = sOptionsTmp['content'][key]['pi_opt_price_type'];

                // 옵션 가격 계산
                sTmpPrice = parseFloat(sTmpPrice) + parseFloat(tmpOptPriceType+tmpOptPrice);
            }
            catch (e)
            {
            }
        }

        var salePrice = 0;
        if(sSetPriceCalc == 'D') {
            salePrice = Number(sTmpPrice) * (Number(salePer) / 100);
            if(cutType == 'A' || cutType == 'B') {
                salePrice = (cutType == 'A') ? (Math.floor(salePrice / cutRound) * cutRound) : (Math.round(salePrice / cutRound) * cutRound);
            }
        }
        
        // 판매가. 20100614
        totalSalePrice += Number(sTmpPrice);
        // 할인 상품 가격
        totalDiscountPrice +=  Number(sTmpPrice) - salePrice;
    }

    var oSalePriceObj = document.getElementById('assign_prd_sale_price_text');
    var oDiscountPriceObj = document.getElementById('assign_prd_discount_price_text');
    
    // 판매가.20100614
    if(oSalePriceObj && document.frm.p_sale_price_type.value != 'M') {
        oSalePriceObj.innerHTML = priceFormat(totalSalePrice, pay_currency, ',');
        setOrgItemPrice(totalSalePrice)
    }
    // 할인가.20100614
    if (oDiscountPriceObj && document.frm.p_sale_price_type.value != 'M') {
        oDiscountPriceObj.innerHTML = priceFormat(totalDiscountPrice, pay_currency, ',');
    }*/
}

/**
* 세트 상품, 품목 선택 시 여부에 따른 가격 재설정
*
*/
function checkSetPrd(el, sOptionalFlag)
{
    //if(el) var el = null;

    if (sOptionalFlag == 'T') {
        alert('해당 상품은 필수선택 항목입니다.');
         el.checked = true;
    }

    /*if (document.frm.p_set_each_buy_flag.value == 'F') {
        el.checked = true;
    }*/

    // 가격 계산
    calcProductPrice();

    /*
    // 선택된 상품 정보를 가져온다.
    var frm = document.frm;
    var iPrdLen = frm['newSetPrdAdd[]'].length;
    var aPrdCode = new Array();

    for (var i=0; i < iPrdLen; i++) {
        if (frm['newSetPrdAdd[]'][i].checked === true) {
            aPrdCode.push(frm['newSetPrdAdd[]'][i].value);
        }
    }

    var pay_currency = frm['pay_currency'].value;        // 국가

    // new 세트 값
    var sSetPriceCalc = frm['p_set_price_calc'].value;
    var sSetPrdInfo = frm['p_set_prd_info'].value;
    var jsonPrdInfo = eval("(" + sSetPrdInfo + ")");

    var salePer = jsonPrdInfo.value;
    var cutType = jsonPrdInfo.cutting;
    var cutRound = jsonPrdInfo.cutting_round;

    var totalPrice = 0;
    for(var i=0; i<aPrdCode.length; i++)
    {
        var sTmpPrdCode = aPrdCode[i];
        var tmpPrice = frm['product_price'+sTmpPrdCode].value;
        try
        {
            if(aOptPrice[sTmpPrdCode]['opt_price'] > 0)  {
                var tmpOptPrice = aOptPrice[sTmpPrdCode]['opt_price'];
                var tmpOptPriceType = aOptPrice[sTmpPrdCode]['opt_price_type'];
                tmpPrice = parseFloat(tmpPrice) + parseFloat(tmpOptPriceType+tmpOptPrice);
            }
        }
        catch (e)
        {
        }

        var salePrice = 0;
        if(sSetPriceCalc == 'D') {
            salePrice = Number(tmpPrice) * (Number(salePer) / 100);
            if(cutType == 'A' || cutType == 'B') {
                salePrice = (cutType == 'A') ? (Math.floor(salePrice / cutRound) * cutRound) : (Math.round(salePrice / cutRound) * cutRound);
            }
        }

        // 할인 상품 가격
        totalPrice +=  Number(tmpPrice) - salePrice;
    }

    var oPriceObj = document.getElementById('main_opt_price');
    var nodes = oPriceObj.childNodes;

    var sNode = null;
    if(oPriceObj && nodes[0].tagName.toLocaleLowerCase() == 'font') {
        sNode = nodes[0];
    }

    if(sNode) {
        sNode.innerHTML = setPayLocation(priceFormat(totalPrice, pay_currency, ','), frm.pg_disp_type.value, pay_currency);
    }

    return false;
    */
}

function setItemNew(iCnt, sPrdCode)
{
    var frm = document.frm;

    var iPrdLen = frm['newSetPrdAdd[]'].length;
    var isChecked = false;
    for (var i=0; i < iPrdLen; i++) {
        if (frm['newSetPrdAdd[]'][i].value == sPrdCode && frm['newSetPrdAdd[]'][i].checked === true) {
            isChecked = true;
            break;
        }
    }

    var iPrdItemTypeTmp = eval('iPrdItemType' + sPrdCode);
    var iOptionsLenTmp = eval('iOptionsLen' + sPrdCode);
    var sOptionsTmp = eval('sOptions' + sPrdCode);

    if(!isChecked) {
        alert('상품을 선택하신 후 옵션을 선택해 주세요.');
        var oSel = document.getElementById('option' + sPrdCode + iCnt);
        oSel.selectedIndex = 0;
        return false;
    }

    if (iPrdItemTypeTmp == '1') {
    } else {
        var oObj = null;
        var aOptTitle = new Array();

        for (var i = 0; i < iOptionsLenTmp; i++) {
            oObj = document.getElementById('option' + sPrdCode + i);
            tmpTitle = oObj.options[oObj.options.selectedIndex].value.split('::');
            for (var j=0; j < tmpTitle.length; j++) {
                title = tmpTitle[j].split('||');
                aOptTitle.push(title[1]);
            }
        }

        try {
            var key = aOptTitle.join('%2C');
            if (sOptionsTmp['content'][key]['pi_sold'] == 'F') {
                alert('품절된 상품입니다.');
                for (var i = 0; i < iOptionsLenTmp; i++) {
                    oObj = document.getElementById('option' + sPrdCode + i);
                    oObj.selectedIndex = 0;
                }
                document.getElementById('prd_item_code'+sPrdCode).value = '';
                return false;
            }

            document.getElementById('prd_item_code'+sPrdCode).value = sOptionsTmp['content'][key]['pi_item_code'];

        } catch(e) {
            document.getElementById('prd_item_code'+sPrdCode).value = '';
        }
    }
    // 가격 계산
    calcProductPrice();
}

function basketSetPrd(type) {
    var frm = document.set_prd_list;
    var iPrdLen = frm['setPrdListAdd[]'].length;
    var aPrdCode = new Array();
    var bResult = true;

    if (iPrdLen) {
        for (var i=0; i < iPrdLen; i++) {
            if (frm['setPrdListAdd[]'][i].checked === true) {
                aPrdCode.push(frm['setPrdListAdd[]'][i].value);
            }
        }
    } else {
        if (frm['setPrdListAdd[]'].checked === true) {
            aPrdCode.push(frm['setPrdListAdd[]'].value);
        }
    }

    if (aPrdCode.length < 1) {
        alert('장바구니에 담을 세트상품을 선택해 주세요');
        return false;
    }

    for (var i=0; i < aPrdCode.length; i++) {
        if (check_frm(aPrdCode[i]) == false) {
            bResult = false;
            break;
        }
    }

    //원래상품 현재보고있는상품 체크
    if (bResult != false) {
        bResult = check_frm();
    }

    if (bResult === false) {
        return false;
    } else {
        createHiddenIframe();

        frm.target = 'hidden_ifr';
        frm.setrediect.value = type ;
        frm.setcommand.value='setbasket';

        //옵션별추가 선택으로 인한 수정
        var arr=new Array();
        var addDiv = document.getElementById('addDiv');
        if(addDiv){
            arr = addDiv.getElementsByTagName("TABLE");
        }

        if(arr.length==0){
            frm.setorgproduct.value = document.frm.prd_item_code.value;
            if (document.frm.quantity) {
                frm.setorgproductqty.value = document.frm.quantity.value;
            }
        }else{
            /*
            for(i=0;i<=arr.length;i++){
                frm.setorgproduct.value += document.frm['prd_item_code'][i].value+",";
            }
            */

            var inqa = document.frm;
            var qa = inqa.getElementsByTagName("input");
            var aItemCodes = new Array();
            var aItemQty = new Array();
            for(i=0;i<qa.length;i++){
                if(qa[i].name=="quantity[]") aItemQty.push(qa[i].value);//frm.setorgproductqty.value += qa[i].value+",";
                if(qa[i].name=="prd_item_code[]") aItemCodes.push(qa[i].value);//frm.setorgproduct.value += qa[i].value+",";
            }

            frm.setorgproductqty.value = aItemQty.join('|');
            frm.setorgproduct.value = aItemCodes.join('|');

        }
        /*frm.setorgproduct.value = document.frm.prd_item_code.value;
        if (document.frm.quantity) {
            frm.setorgproductqty.value = document.frm.quantity.value;
        }*/
        frm.action='/Front/Basket/?url=Basket';

        var len = frm.product_url.length;

        if (len) {
            frm.product_url[len-1].value = document.location.href;
        } else {
            frm.product_url.value = document.location.href;
        }


        frm.submit();
    }
}

function setItem2(iCnt, sPrdCode) {
    var pay_currency = document.frm.pay_currency.value;
    var iPrdItemTypeTmp = eval('iPrdItemType' + sPrdCode);
    var iOptionsLenTmp = eval('iOptionsLen' + sPrdCode);
    var sOptionsTmp = eval('sOptions' + sPrdCode);
    if (iPrdItemTypeTmp == '1') {
    } else {
        var oObj = null;
        var aOptTitle = new Array();

        for (var i = 0; i < iOptionsLenTmp; i++) {
            oObj = document.getElementById('option' + sPrdCode + i);
            tmpTitle = oObj.options[oObj.options.selectedIndex].value.split('::');
            for (var j=0; j < tmpTitle.length; j++) {
                title = tmpTitle[j].split('||');
                aOptTitle.push(title[1]);
            }
        }
        try {
            var key = aOptTitle.join('%2C');
            if (sOptionsTmp['content'][key]['pi_sold'] == 'F') {
                alert('품절된 상품입니다.');
                for (var i = 0; i < iOptionsLenTmp; i++) {
                    oObj = document.getElementById('option' + sPrdCode + i);
                    oObj.selectedIndex = 0;
                }
                document.getElementById('prd_item_code'+sPrdCode).value = '';
                return false;
            }

            document.getElementById('prd_item_code'+sPrdCode).value = sOptionsTmp['content'][key]['pi_item_code'];


            try {
                /*var obj = document.getElementById('main_opt_price'+sPrdCode);
                var orgPrice = document.frm.product_price.value.replace(',', '');

                //var price = obj.childNodes[1].innerHTML.replace(',', '');

                if (sOptions['content'][key]['pi_opt_price'] > 0) {
                    obj.childNodes[1].innerHTML =  priceFormat(parseFloat(orgPrice) + parseFloat((sOptions['content'][key]['pi_opt_price_type'] + sOptions['content'][key]['pi_opt_price'])), pay_currency, ',');
                } else {
                    obj.childNodes[1].innerHTML = priceFormat(orgPrice, pay_currency, ',');
                }*/
            } catch(e) {}

        } catch(e) {
            document.getElementById('prd_item_code'+sPrdCode).value = '';
        }
    }
}


function check_frm_arr(len, arr) {


    for (i=0; i < arr.length; i++) {
        var oObj = arr[i].getElementsByTagName('select');
        var iLen = oObj.length;
        for (iCnt = 0; iCnt < iLen; iCnt++) {
            if (oObj[iCnt].selectedIndex < 1) {
                alert('필수 옵션이 선택되지 않았습니다');
                oObj[iCnt].select();
                return false;
            }
            var key = getItemKey(iOptionsLenTmp, '', parentCheck(oObj[iCnt]));
            if (sOptionsTmp['content'][key] == undefined || !sOptionsTmp['content'][key]) {
                alert('선택하신 상품은 품절 상품입니다.');
                return false;
            }
            if (key && (sOptionsTmp['content'][key]['pi_sold'] == 'F' || sOptionsTmp['content'][key]['pi_sell_flag'] == 'T')) {
                alert('선택하신 상품은 품절 상품입니다.');
                return false;
            }            
        }
    }

    var frm = document.frm;
    var sPrdCode = '';
      for(i=0;i<=len;i++){
        if (frm['quantity'+sPrdCode][i]) {
            if (! frm['quantity'+sPrdCode][i].value) {
                alert ('수량을 입력해 주십시오.');
                frm['quantity'+sPrdCode][i].focus();
                return false;
            }

            for (i2 = 0; i2 < frm['quantity'+sPrdCode][i2].value.length; i2++) {
                if (! (frm['quantity'+sPrdCode][i].value.charAt(i2) >= '0' && frm['quantity'+sPrdCode][i].value.charAt(i2) <= '9')) {
                    alert ('수량은 숫자만 가능합니다.');
                    frm['quantity'+sPrdCode][i].select();
                    return false;
                }
            }
            if (parseInt(frm['quantity'+sPrdCode][i].value) < 1) {
                alert('주문수량은 1개 이상이어야 합니다.');
                frm['quantity'+sPrdCode][i].select();
                return false;
            }
        }

        if (!frm['prd_item_code'+sPrdCode][i].value) {
            alert('선택하신 상품은 품절 상품입니다.');
            return false;
        }


        if (frm['quantity'+sPrdCode][i]) {
            if (parseInt(frm['quantity'+sPrdCode][i].value) < parseInt(frm['product_min'+sPrdCode].value)) {
                alert ('최소 주문수량은 ' + frm['product_min'+sPrdCode].value + ' 입니다.');
                frm['quantity'+sPrdCode][i].select();
                return false;
            }

            if (parseInt(frm['product_max'+sPrdCode].value) > 0) {
                if (parseInt(frm['quantity'+sPrdCode][i].value) > parseInt(frm['product_max'+sPrdCode].value)) {
                    alert('최대 구매수량은 ' + frm['product_max'+sPrdCode].value + ' 입니다.');
                    frm['quantity'+sPrdCode][i].select();
                    return false;
                }
            }
        } else {
            /*if (parseInt(frm['quantity'+sPrdCode].value) < parseInt(frm['product_min'+sPrdCode].value)) {
                alert ('최소 주문수량은 ' + frm['product_min'+sPrdCode].value + ' 입니다.');
                frm['quantity'+sPrdCode].select();
                return false;
            }

            if (parseInt(frm['product_max'+sPrdCode].value) > 0) {
                if (parseInt(frm['quantity'+sPrdCode].value) > parseInt(frm['product_max'+sPrdCode].value)) {
                    alert('최대 구매수량은 ' + frm['product_max'+sPrdCode].value + ' 입니다.');
                    frm['quantity'+sPrdCode].select();
                    return false;
                }
            }*/
        }
        /**
         * 주문 수량 단위는  form 넘어가는 /front/php/basket.php  파일에서 체크가 된다. 
         * 하단 로직은 javascript 에러 나는 로직이라 주석처리.
         * [상점 운영방식 설정] - [상품 옵션별 추가 구매 사용 여부] 설정값의  Type A , Type B , 미사용 모두 테스트 완료.
         * 2011.10.04 mkhwang
        if (parseInt(frm['product_buy_qty'+sPrdCode].value) > 1) {
            var iBuyQty = frm['quantity'+sPrdCode][i].value;
            if ((iBuyQty % frm['product_buy_qty'+sPrdCode].value) != 0)    {
                alert('주문 수량단위는 ' + frm['product_buy_qty'+sPrdCode].value + "단위 입니다.");
                return false;
            }
        }*/

    }

    return true;
}

// 욥션별 추가 구매

var item_count = '';

function cellAdd(){
    //var tr = $A($$('#'+name+' tr'));
    /*
    var ahm = document.getElementById('ahm');
    var ahm2 = document.getElementById('ahm2');
    ahm2.rows[0].cells[0].innerHTML = ahm.innerHTML;
    */

    var addArray = new Array();
    var addNameArray = new Array();

    prd_item_cnt = frm.prd_item_cnt.value;
    item_count = prd_item_cnt;

    //prd_item_code 배열로 변경
    var  prd_item_code= document.getElementById('prd_item_code');
    prd_item_code.setAttribute("name","prd_item_code[]","0");

    var  quantity= document.frm.quantity;
    var  quantity= document.frm.getElementsByTagName("input");
    //var  quantity= document.getElementById('quantity');

    for(i=0;i<quantity.length;i++){
        if(quantity[i].name=="quantity"){
            //quantity.setAttribute("name","quantity[]","0");
            quantity[i].name="quantity[]";
        }
    }


    for(i=0; i< prd_item_cnt; i++){
        var sNamehtml = document.getElementById('optionName'+i);
        addNameArray[i] = sNamehtml.innerHTML;
        //var addto = document.createElement("<select id='option"+i+"' name='option"+i+"[]' onchange='checkOpt(this);setItem(this);'>");
        var addto = document.createElement("<select onchange='checkOpt(this);setItem(this);'>");
        addto.id="option"+i;
        addto.name="option"+i+"[]";

        //addto.setAttribute("onchange","checkOpt(this);setItem(this);","0");
        var shtml = document.getElementById('option'+i);
        for(i2=0;i2<shtml.length;i2++){
            addto.options[i2] = new Option(shtml.options[i2].text,shtml.options[i2].value);
        }
        addArray[i]  = addto;

        shtml.setAttribute("name","option"+i+"[]","0");
    }


    //var addTable = document.createElement("<table style='border:1px solid #f2f2f2; background:#fcfcfc;' id=''>");
    var addTable = document.createElement("<table>");
    addTable.style.border="1px solid #f2f2f2";
    addTable.style.background="#fcfcfc";
    addTable.id='';

    var addTbody = document.createElement("<tbody>");
    addTable.appendChild(addTbody);

    for(i=0; i<addArray.length; i++){
        var addTr = document.createElement("<tr>");

        var addTdName = document.createElement("<td>");
        addTdName.width="100";
        addTdName.innerHTML = addNameArray[i];

        var addTdName2_1 = document.createElement("<td>");
        addTdName2_1.width="3";
        addTdName2_1.innerHTML = "<img src='http://img0001.echosting.cafe24.com/front/type_b/image/common/bul_07.gif'>";

        var addTdName2_2 = document.createElement("<td>");
        addTdName2_2.width="2";
        addTdName2_2.innerHTML = ":";

        var addTd = document.createElement("<td>");
        addTd.width="200";
        /*
        addArray[i].setAttribute('title', i);
        addArray[i].onchange = function(){
            var objId = 'option' + this.getAttribute('title');
            var obj = document.getElementById(objId);
            checkOpt(obj);
            setItem(obj);
        }
        */

        addTd.appendChild(addArray[i]);
        addTr.appendChild(addTdName2_1);
        addTr.appendChild(addTdName);
        addTr.appendChild(addTdName2_2);
        addTr.appendChild(addTd);
        addTbody.appendChild(addTr);
    }


    var addTr3 = document.createElement("<tr>");

    var addTdName3 = document.createElement("<td>");
    addTdName3.width="3";
    addTdName3.innerHTML = "<img src='http://img0001.echosting.cafe24.com/front/type_b/image/common/bul_07.gif'>";
    addTr3.appendChild(addTdName3);


    var addTdName3 = document.createElement("<td>");
    addTdName3.width="3100";
    addTdName3.innerHTML = "수량";
    addTr3.appendChild(addTdName3);

    var addTdName3 = document.createElement("<td>");
    addTdName3.width="2";
    addTdName3.innerHTML = ":";
    addTr3.appendChild(addTdName3);

    var addTdName3 = document.createElement("<td>");
    addTdName3.width="200";
    addTdName3.innerHTML = "<input class='input01' type='text' size='3' value='1' name='quantity[]' onkeydown='if(event.keyCode==13) return false;'>";
    addTr3.appendChild(addTdName3);

    var addTdName3 = document.createElement("<td>");
    addTdName3.width="2";
    addTdName3.innerHTML = "<span onclick='cellDel(this)' style='cursor:hand'>X</span>";

    var addHid = document.createElement("<input>");
    addHid.type='hidden';
    addHid.name='prd_item_code[]';
    addHid.id='prd_item_code';
    addHid.value='';
    addTdName3.appendChild(addHid);

    addTr3.appendChild(addTdName3);



    addTbody.appendChild(addTr3);

    var addDiv = document.getElementById('addDiv');
    addDiv.appendChild(addTable);

    /*
    var tbody = $(name).getElementsByTagName("TBODY");
    var cpEle = tbody[1].cloneNode(true);
    var arr = cpEle.getElementsByTagName("INPUT");

    for (var i = 0; i < arr.length; i++) {
        arr[i].setAttribute("VALUE", "",0);
        if(arr[i].type=="hidden")arr[i].setAttribute("VALUE", "N",0);
    }
    $(name).appendChild(cpEle);
    */
}

// 옵션 추가 TypeB 이벤트 (2011-05-11, shmin)
function optTypeB(cnt) {
	if (chkDup()) {
		setItem();
		chkOption(cnt);
	}
}

// 옵션 선택 상태 체크 (2011-05-06, shmin)
function chkOption(cnt) {	
	for(i=0; i<cnt; i++){                               
        //var selOption = document.getElementById('option'+i)[document.getElementById('option'+i).selectedIndex].text;                
        if (document.getElementById('option'+i).selectedIndex == '') return false;                    
    }    
		
	optionAdd();	
}

// 옵션 중복 선택 체크 (2011-05-09, shmin)
function chkDup() {
	var obj = document.getElementsByName('optVal[]');
	
	if (obj.length > 0) {
		var opt_cnt = frm.prd_item_cnt.value;
		var selOptions = '';
		
		for (i=0; i<opt_cnt; i++) {			
			var selOption = document.getElementById('option'+i)[document.getElementById('option'+i).selectedIndex].text;  
			if (document.getElementById('option'+i).selectedIndex == '') return false;        
	        selOptions += ', ' + selOption;	        
		}
				
		for (j=0; j<obj.length; j++) {			
			if (selOptions.substring(1) == obj[j].value) {
				alert('중복 선택된 옵션이 있습니다.');												
				return false;
			}
		}
	}
	
	return true;
}

// 옵션 추가(TypeB) (2011-05-04, shmin)
function optionAdd(){  		
    var addArray = new Array();
    var addNameArray = new Array();

    prd_item_cnt = frm.prd_item_cnt.value;
    item_count = prd_item_cnt;
    
    //prd_item_code 배열로 변경
    var prd_item_code = document.getElementById('prd_item_code');
    prd_item_code.setAttribute("name","prd_item_code[]","0");
    
    if (document.getElementById('oSoldElementArea')) {		
		if (document.getElementById('oSoldElementArea').innerText == ' 품절') {
			alert('품절 상품입니다.');			
			// 추가할 상품이 품절일 경우 옵션 선택값이 최종 추가 옵션값으로 변경 (2011-05-25, shmin)
        	if (document.getElementsByName('optVal[]').length > 0) {
        		var lastIndex = eval(document.getElementsByName('optVal[]').length)-1;
        		var aTempIndex = document.getElementsByName('orioptionIndex[]')[lastIndex].value.split('|');
        		
        		for (i=0; i<item_count; i++) {
        			document.getElementById('option'+i).selectedIndex = aTempIndex[i];
        		}
        		
        		document.frm['prd_item_code'][0].value = document.frm['prd_item_code'][lastIndex+1].value;        		
    		// 추가된 옵션이 없을 경우 옵션 선택값 초기화 (2011-05-25, shmin)
        	} else {        		
        		for (i=0; i<item_count; i++) {			        			 
        			document.getElementById('option'+i).selectedIndex = 0                	           
        		}
        	}
        	
			return false;
		}
	}    
        
    var quantity = document.getElementById("quantity_0");
    quantity.setAttribute("name","quantity[]","0");
    

    // 가격 표기 추출(2011-05-06, shmin)
    if (document.getElementById('main_opt_price') == undefined) {
    	var valueType = '';
    } else {
    	var valueType = document.getElementById('main_opt_price').innerHTML.replace(document.getElementById('assign_prd_sale_price_text').innerHTML, '');        
        valueType = valueType.replace(/<[a-z|\/]+[^<>]*>/gi, '');
    }    
    
    if (valueType.length > 1) valueType = valueType.substring(1);
                       
    for(i=0; i< prd_item_cnt; i++){
        var sNamehtml = document.getElementById('optionName'+i);
        addNameArray[i] = sNamehtml.innerHTML;
        var addto = document.createElement("<select onchange='checkOpt(this);setItem(this);'>");
        addto.id="option"+i;
        addto.name="option"+i+"[]";

        //addto.setAttribute("onchange","checkOpt(this);setItem(this);","0");
        var shtml = document.getElementById('option'+i);
        for(i2=0;i2<shtml.length;i2++){
            addto.options[i2] = new Option(shtml.options[i2].text,shtml.options[i2].value);
        }
        addArray[i]  = addto;

        shtml.setAttribute("name","option"+i+"[]","0");
    }


    var addTable = document.createElement("<table>");
    addTable.style.border="1px solid #f2f2f2";
    addTable.style.background="#fcfcfc";
    addTable.id='';

    var addTbody = document.createElement("<tbody>");
    addTable.appendChild(addTbody);

    var selOptions = ''; 
    var selOption = '';
    var selIndexs = '';
    var selIndex = '';
    var tempKey = '';
    var aTempKey = new Array();
    
    for(i=0; i<addArray.length; i++){                               
        selOption = document.getElementById('option'+i)[document.getElementById('option'+i).selectedIndex].text;
        selIndex = document.getElementById('option'+i).selectedIndex;
        tempKey = document.getElementById('option'+i)[document.getElementById('option'+i).selectedIndex].value.split('||');
        if (document.getElementById('option'+i).selectedIndex == '') return false;        
        selOptions += ', ' + selOption;   
        selIndexs += '|' + selIndex;
        aTempKey.push(tempKey[1]);
    }
         
    // 옵션별 가격 계산 (2011-05-13, shmin)  
    if (!document.getElementById('typeB_prdPrice')) {    	
    	var typeBinput = document.createElement("<input>");
    	typeBinput.type='hidden';
    	typeBinput.name='typeB_prdPrice';
    	typeBinput.id='typeB_prdPrice';
    	
    	if (document.getElementById('assign_prd_discount_price').value > 0) {
    		typeBinput.value = parseFloat(document.getElementById('assign_prd_discount_price').value);
        } else {
        	typeBinput.value = parseFloat(document.getElementById('product_price').value);
        }
    	
    	document.body.appendChild(typeBinput);
    }
        
    var typebOptprice = eval(document.getElementById('typeB_prdPrice').value);
                  
    if (sOptions['content'][aTempKey.join('%2C')] && sOptions['content'][aTempKey.join('%2C')]['pi_opt_price'] > 0) {
    	typebOptprice += parseFloat((sOptions['content'][aTempKey.join('%2C')]['pi_opt_price_type'] + sOptions['content'][aTempKey.join('%2C')]['pi_opt_price']));
    }
        
    var addTr3 = document.createElement("<tr>");

    var addTdName3 = document.createElement("<td rowspan='2'>");
    addTdName3.width="3";
    addTdName3.innerHTML = "<img src='http://img0001.echosting.cafe24.com/front/type_b/image/common/bul_07.gif'>";
    addTr3.appendChild(addTdName3);

    var addTdName3 = document.createElement("<td rowspan='2'>");
    addTdName3.width="150";
    addTdName3.innerHTML = "<input type='text' name='optVal[]' value='"+selOptions.substring(1)+"' style='width:150px;border:0px;font-size:12px;font-weight:bold;color:#555555;' />";
    addTr3.appendChild(addTdName3);    
    
    var addTdName3 = document.createElement("<td align='right' rowspan='2'>");
    addTdName3.width="50";
    addTdName3.innerHTML = "<input type='hidden' name='orioptionPrice[]' value='" + typebOptprice + "' />";
    addTdName3.innerHTML += "<input type='hidden' name='orioptionIndex[]' value='" + selIndexs.substring(1) + "' />";
    addTdName3.innerHTML += "<input class='input01' type='text' size='1' value='" + quantity.value +"' name='quantity[]' style='ime-mode:disabled' onkeypress='chkNumeric();' onkeyup='reOptionPrice(this, \""+valueType+"\");' maxlength='3' />";
    addTr3.appendChild(addTdName3);               
        
    var addTdName3 = document.createElement("<td align='right'>");
    addTdName3.width="10";
    addTdName3.innerHTML = "<input type='button' style='background: url(\"http://img0001.echosting.cafe24.com/front/type_b/image/button/basket_up.gif\") no-repeat; width:11px; height:9px; border:0px; cursor:pointer;' name='up[]' onclick=\"optchangeSetPrdCnt(this, 'up', '"+valueType+"');\" />";
    addTr3.appendChild(addTdName3);
    
    var addTdName3 = document.createElement("<td align='right' rowspan='2'>");
    addTdName3.width="60";
    addTdName3.innerHTML = "<input type='text' name='optionPrice[]' style='width:70px;border:0px;text-align:right;font-size:12px;font-weight:bold;color:#555555;' value='" + number_format(typebOptprice) + "' /><strong>" + valueType + "</strong>";
    addTr3.appendChild(addTdName3);         
                  
    var addTdName3 = document.createElement("<td rowspan='2'>");
    addTdName3.width="12";
    addTdName3.innerHTML = "<span onclick='cellDel(this);totalOptPrice(\""+valueType+"\");' style='cursor:hand'><img src='http://img.cafe24.com/img1/front/common/icon_del.gif' /></span>";
    
    var addHid = document.createElement("<input>");
    addHid.type='hidden';
    addHid.name='prd_item_code[]';
    addHid.id='prd_item_code';
    addHid.value=prd_item_code.value;
    addTdName3.appendChild(addHid);

    addTr3.appendChild(addTdName3);
    
    var addTr4 = document.createElement("<tr>");
    
    var addTdName4 = document.createElement("<td align='right'>");
    addTdName4.width="10";
    addTdName4.innerHTML = "<input type='button' style='background: url(\"http://img0001.echosting.cafe24.com/front/type_b/image/button/basket_down.gif\") no-repeat; width:11px; height:9px; border:0px; cursor:pointer;' name='down[]' onclick=\"optchangeSetPrdCnt(this, 'down', '"+valueType+"');\" style='cursor:pointer' />";
    addTr4.appendChild(addTdName4);
       
    addTbody.appendChild(addTr3);
    addTbody.appendChild(addTr4);

    var addDiv = document.getElementById('addDiv');
    addDiv.appendChild(addTable);
        
    totalOptPrice(valueType);
}

// 옵션별 가격 재계산(2011-05-06, shmin)
function reOptionPrice(obj, valueType) {
	if (obj.value == '') obj.value = 1;	
	var m = objIndexVal(obj);    
    var f = document.getElementsByName('optionPrice[]')[m-1];
    var	p = document.getElementsByName('orioptionPrice[]')[m-1].value.replace(/,/gi, '')    
    var s = eval(p) * eval(obj.value);
                
    f.value = number_format(s);        
    totalOptPrice(valueType);
}

// 옵션별 수량 조정 (2011-05-09, shmin)
function optchangeSetPrdCnt(obj, mod, valueType) {	
	var m = objIndexVal(obj);      
	var el = document.getElementsByName('quantity[]')[m];
	document.getElementsByName('quantity[]')[m].focus();
    var qty = parseInt(el.value);
    if (mod == 'up') {
        el.value = qty + 1;
    } else if (mod == 'down') {
        if (qty < 2) {
            alert('1개 이상 선택하셔야 합니다.');
            return false;
        } else {
            el.value = qty - 1;
        }
    }
    
    var f = document.getElementsByName('optionPrice[]')[m];
    var	p = document.getElementsByName('orioptionPrice[]')[m].value.replace(/,/gi, '')    
    var s = eval(p) * el.value;
                
    f.value = number_format(s);        
    totalOptPrice(valueType);
}

// 오브젝트 인덱스 값 가져오기 (2011-05-09, shmin)
function objIndexVal(obj) {
	var m = 0; 
    var rtn = -1; 
    for(i=0;i<obj.form.length;i++) { 
        if(obj.form[i].name != obj.name) continue; 
        if(obj.form[i] == obj) 
        { 
            rtn=m; 
            break; 
        } 
        m++; 
    }
    
    return m;
}

// 총 상품 금액 (2011-05-06, shmin)
function totalOptPrice(valueType) {
	document.getElementById('optTotalTr').style.display = 'block';
	document.getElementById('typeB').value = 1;
	var optPrice = document.getElementsByName('optionPrice[]');
	var tmpPrice = 0;
    
	for (i=0;i<optPrice.length;i++) {		
		tmpPrice += eval(optPrice[i].value.replace(/,/gi, ''));
	}
		
	document.getElementById('optTotalPrice').innerHTML = number_format(tmpPrice) + valueType;
}

// 숫자만 입력(2011-05-04, shmin)
function chkNumeric() {	
	if((event.keyCode<48)||(event.keyCode>57)) 
	    event.returnValue=false; 
}

// Number_Format 구현 (2011-05-06, shmin)
function number_format(str) { 
	str+=''; 
	
	var objRegExp = new RegExp('(-?[0-9]+)([0-9]{3})');  
	
	while(objRegExp.test(str))  
	{ 
		str = str.replace(objRegExp, '$1,$2'); 
	}  
	
	return str;
} 



function parentCheck(that){

    var parentID = that.parentNode;
    while(1){
        if(parentID.nodeName=="TABLE"){
            break;
        }
        parentID = parentID.parentNode;
    }
    var addDiv = document.getElementById('addDiv');
    var arr = addDiv.getElementsByTagName("TABLE");

    for (var i = 0; i < arr.length; i++) {
          if(arr[i] == parentID){
              return (i+1)+"||"+arr.length;
          }
    }

}

function checkOpt(that){

    that_num = parentCheck(that);
    that_num_sp = that_num.split("||");

    v_opt_num = that_num_sp[0];
    opt_num = that_num_sp[1];

    var at = true;
    for(i=0;i<item_count;i++){
        if(!document.frm['option'+i][0].value){
            at = false;
        }
    }
    if(at == false){
        alert('상위 옵션부터 선택해 주세요');
        for(i=0;i<item_count;i++){
            document.frm['option'+i][v_opt_num].selectedIndex=0;
        }
    }



    var opt_val = new Array();
    for(i=0;i<item_count;i++){
        if(!document.frm['option'+i][v_opt_num].value)return false;
        opt_val[i]=document.frm['option'+i][v_opt_num].value;
    }

    if(opt_num==0){
        return false;
    }else{
        for(i=0;i<=opt_num;i++){
            if(v_opt_num != i){
                var tf = false;
                for(i2=0;i2<item_count;i2++){
                    var ch_value = document.frm['option'+i2][i].value;
                    if(ch_value == opt_val[i2]){
                        tf = true;
                    }else{
                        tf = false;
                        break;
                    }
                }

                if(tf==true){
                    alert('중복 선택된 옵션이 있습니다');
                    for(i2=0;i2<item_count;i2++){
                        document.frm['option'+i2][v_opt_num].selectedIndex=0;
                    }
                    document.frm['prd_item_code'][v_opt_num].value="";
                    return false;

                }
            }

        }
    }

}

function cellDel(that){

    that_num = parentCheck(that);
    that_num_sp = that_num.split("||");

    v_opt_num = that_num_sp[0];

    var addDiv = document.getElementById('addDiv');
    addDiv.removeChild(addDiv.childNodes[v_opt_num-1]);

}

function CyworldConnect(sid, url) {	
    window.open('http://api.cyworld.com/openscrap/shopping/v1/?sid='+sid+'&xu=' + escape(url), 'cyopenscrap', 'width=450, height=410');
    return false;
}

// Cyworld 스크랩 로그, 2010-10-20(shmin)
function CyworldClickLog(no, name, id) {	
	var url = './?url=setSnsStatics&product_no='+no+'&product_name='+name+'&id='+id;        	    
	var str = getHttprequest(url);
	if (str!='ok') { /* 로그 누적 실패  */ }
    return false;    
}

function openNateInfo(num){
    if (num == "1"){
        document.getElementById('divNate').style.display="none";
    }else{
        document.getElementById('divNate').style.display="";
    }
}

// 네이버 체크아웃 구매, 찜하기
function nv_add_basket(arg)
{
    createHiddenIframe();

    var sUrl = "/Front/Product/?url=getLinkTargetAjax";
    var linkTarget = getHttprequest(sUrl);       
    var p_set_prd_flag = document.frm.p_set_prd_flag.value;
    
    if(arg=="1"){  
    	if(p_set_prd_flag == 'T') {
    		// 세트 상품 체크아웃 구매 (2011-07-11, shmin)
            if(newBasketSetPrd(arg)) {                
                document.frm.nv_hidden_flag.value = 'order';
                if (linkTarget == 'T') frm.target = '_blank';
                frm.command.value = 'naver';
                document.frm.submit();
            }
    	} else {    	
	        // 해당 상품만 구매
	        if(checkOldSetPrd() === false) {
	            if( check_frm('', 'nv') ){
	                document.frm.nv_hidden_flag.value = 'order';
	    //            frm.target = 'hidden_ifr';
	                if (linkTarget == 'T') frm.target = '_blank';
	                frm.command.value = 'naver';
	                                              	
	                document.frm.submit();
	            }
	        // old 세트 상품 구매
	        } else {
	            nv_add_basket_set();
	        }
    	}
    } else {
        if(!check_frm('', 'nv')) return false;

        product_no = document.frm.product_no.value;
        prd_item_code = document.frm.prd_item_code.value;
        if(prd_item_code == undefined) {
            prd_item_code = document.frm.prd_item_code[0].value;
        }
        var url = "/Front/Basket/?url=Basket&command=naverbasket&product_no="+product_no+"&prd_item_code="+prd_item_code+"&nv_back_url="+encodeURIComponent(document.location.href);
        window.open(url, "navercheckout_basket", 'scrollbars=yes,status=no,toolbar=no,width=450,height=300');
    }
}

function nv_buy()
{
    nv_add_basket(1);
}

function nv_basket()
{
    nv_add_basket(2);
}

function check_naverchk(arg){
    try {
        if(document.getElementById('NaverChk_Button') != null){
            if(arg=="A"){
                document.getElementById('NaverChk_Button').style.display = "block";
            }else{
                document.getElementById('NaverChk_Button').style.display = "none";
            }
        }
    } catch (e) {}
}

// 네이버 체크아웃 old 세트 상품 구매
function nv_add_basket_set()
{
    var frm = document.set_prd_list;
    var iPrdLen = frm['setPrdListAdd[]'].length;
    var aPrdCode = new Array();
    var bResult = true;

    if (iPrdLen) {
        for (var i=0; i < iPrdLen; i++) {
            if (frm['setPrdListAdd[]'][i].checked === true) {
                aPrdCode.push(frm['setPrdListAdd[]'][i].value);
            }
        }
    } else {
        if (frm['setPrdListAdd[]'].checked === true) {
            aPrdCode.push(frm['setPrdListAdd[]'].value);
        }
    }

    for (var i=0; i < aPrdCode.length; i++) {
        if (check_frm(aPrdCode[i]) == false) {
            bResult = false;
            break;
        }
    }
    
    //원래상품 현재보고있는상품 체크
    if (bResult != false) {
        bResult = check_frm();
    }

    if (bResult === false) {
        return false;
    } else {
        createHiddenIframe();

        //frm.target = 'hidden_ifr';
        frm.setrediect.value = '1';
        frm.setcommand.value='naver';
        //frm.command.value='naver';

        //옵션별추가 선택으로 인한 수정
        var arr=new Array();
        var addDiv = document.getElementById('addDiv');
        if(addDiv){
            arr = addDiv.getElementsByTagName("TABLE");
        }

        if(arr.length==0){
            frm.setorgproduct.value = document.frm.prd_item_code.value;
            if (document.frm.quantity) {
                frm.setorgproductqty.value = document.frm.quantity.value;
            }
        }else{
            var inqa = document.frm;
            var qa = inqa.getElementsByTagName("input");
            var aItemCodes = new Array();
            var aItemQty = new Array();
            for(i=0;i<qa.length;i++){
                if(qa[i].name=="quantity[]") aItemQty.push(qa[i].value);//frm.setorgproductqty.value += qa[i].value+",";
                if(qa[i].name=="prd_item_code[]") aItemCodes.push(qa[i].value);//frm.setorgproduct.value += qa[i].value+",";
            }

            frm.setorgproductqty.value = aItemQty.join('|');
            frm.setorgproduct.value = aItemCodes.join('|');

        }
        
        /*frm.setorgproduct.value = document.frm.prd_item_code.value;
        if (document.frm.quantity) {
            frm.setorgproductqty.value = document.frm.quantity.value;
        */
        
        // 사용자 지정 옵션
        // 진짜 어쩔수 없이 이렇게 한다....젠장할...;; - by 김형민  2010-06-21
        // 사용자 지정 옵션이 100개이상 없을거라고 생각하고, 개수까지 체크 후 break
        var aOptionAdd = new Array();
        for(var i=0; i<100; i++) {        
        	if(document.frm['option_add['+i+']'] != undefined) {
        		aOptionAdd.push(document.frm['option_add['+i+']'].value);
        	} else {
        		break;
        	}
        }
        var sOldOptionAdd = '';
        if(aOptionAdd.length > 0) sOldOptionAdd = aOptionAdd;
        
        // 배송비 결제
        var delv_payment = document.frm.delv_payment.value;

        frm.action='/Front/Basket/?url=Basket&sOptionAdd='+encodeURI(sOldOptionAdd)+'&delv_payment='+delv_payment;

        var len = frm.product_url.length;

        if (len) {
            frm.product_url[len-1].value = document.location.href;
        } else {
            frm.product_url.value = document.location.href;
        }


        frm.submit();
    }
}

// old 세트 상품중 선택한 상품이 있는지 확인
function checkOldSetPrd()
{
    var isOldSetPrd = false;
    try
    {
        var aPrdCode = new Array();
        var frm = document.set_prd_list;
        var iPrdLen = frm['setPrdListAdd[]'].length;

        if (iPrdLen) {
            for (var i=0; i < iPrdLen; i++) {
                if (frm['setPrdListAdd[]'][i].checked === true) {
                    aPrdCode.push(frm['setPrdListAdd[]'][i].value);
                }
            }
        } else {
            if (frm['setPrdListAdd[]'].checked === true) {
                aPrdCode.push(frm['setPrdListAdd[]'].value);
            }
        }
        if (aPrdCode.length > 0) return true;
    }
    catch (e)
    {
        isOldSetPrd = false;
    }
    return isOldSetPrd;
}

function fileAddition()
{
    for (var i=1; i<=5; i++) {
        if (i == 5) {
            alert('이미지는 5개까지 첨부 가능합니다.');
        } else {
            if (document.getElementById('file_tr'+i).style.display == "none") {
                document.getElementById('file_tr'+i).style.display = "block";
                break;
            }
        }
    }
}

function showFullContents(iNo)
{
    document.getElementById('dContentFull'+iNo).style.display = 'inline';
    document.getElementById('dContentCut'+iNo).style.display = 'none';
}

function hideFullContents(iNo)
{
    document.getElementById('dContentFull'+iNo).style.display = 'none';
    document.getElementById('dContentCut'+iNo).style.display = 'inline';
}

function showFullContentsNew(iNo)
{
    if (document.getElementById('dContentFull'+iNo).style.display == 'none') {
        document.getElementById('dContentFull'+iNo).style.display = 'inline';
    } else {
        document.getElementById('dContentFull'+iNo).style.display = 'none';
    }
}

function hideFullContentsNew(iNo)
{
    document.getElementById('dContentFull'+iNo).style.display = 'none';
}

/**
 * 글 삭제
 */
function doDeleteAction(o)
{
    var childNode = o.parentNode.childNodes;
    for (var i = 0; i < childNode.length; i++) {
        if (childNode[i].name == 'u30pw') {
            document.getElementById('password').value = childNode[i].value;
        }
    }

    document.getElementById('afternote_frm').submit();
}

/**
 * 삭제 폼 보이기 (비회원)
 */
function showDeleteForm(no)
{
    document.getElementById('mode').value = 'del';
    document.getElementById('no').value = no;
    document.getElementById('dDelete'+no).innerHTML = document.getElementById('u30').innerHTML;
}

/**
 * 직접 삭제 (회원)
 */
function doDeleteDirectly(no)
{
    if (confirm('정말 삭제하시겠습니까?')) {
        document.getElementById('mode').value = 'del';
        document.getElementById('no').value = no;
        document.getElementById('afternote_frm').submit();
    }
}

/**
 * 수정 폼 보이기
 */
function showModifyForm(no)
{
    var u31 = document.getElementById('u31');
    var textarea = u31.getElementsByTagName('TEXTAREA');
    textarea[0].value = document.getElementById('dContentFull'+no).innerHTML;

    var writer = u31.getElementsByTagName('INPUT');
    for (var i = 0; i < writer.length; i++) {
        if (writer[i].name == 'u31name') {
            writer[i].value = document.getElementById('dWriter'+no).innerText;
        }
    }

    var btn = u31.getElementsByTagName('IMG');
    btn[0].onclick = 'doModifyAction('+no+')';

    document.getElementById('dModify'+no).innerHTML = document.getElementById('u31').innerHTML;
}

/**
 * 답변 폼 보이기
 */
function showReplyForm(no)
{
    var u31 = document.getElementById('u31');
    var btn = u31.getElementsByTagName('IMG');
    btn[0].onclick = 'doReplyAction('+no+')';

    document.getElementById('dDelete'+no).innerHTML = document.getElementById('u31').innerHTML;
}

/**
 * 글 수정
 */
function doModifyAction(no)
{
    var dModify = document.getElementById('dModify'+no);

    var textarea = dModify.getElementsByTagName('TEXTAREA');
    document.getElementById('content').value = textarea[0].value;

    var input = dModify.getElementsByTagName('INPUT');
    for (var i = 0; i < input.length; i++) {
        if (input[i].name == 'u31name') {
            document.getElementById('writer_name').value = input[i].value;
        } else if (input[i].name == 'u31pw') {
            document.getElementById('password').value = input[i].value;
        }
    }

    if (document.getElementById('dPoint'+no)) {
        var point = document.getElementsByName('point');
        for (i = 0; i < point.length; i++) {
            if (point[i].value == document.getElementById('dPoint'+no).value) {
                point[i].checked = 'checked';
            } else {
                point[i].checked = '';
            }
        }
    }

    document.getElementById('mode').value = 'update';
    document.getElementById('no').value = no;
    document.getElementById('afternote_frm').submit();
}

/**
 * NEW 수정 폼 보이기
 */
function showModifyFormNew(no)
{
    document.getElementById('dModifyFull'+no).style.display = 'block';
}

/**
 * 수정 폼 숨기기
 */
function hideModifyForm(no)
{
    document.getElementById('dModifyFull'+no).style.display = 'none';
}

/**
 * NEW 글 수정
 */
function doModifyActionN(no)
{
    var dModify = document.getElementById('dModifyFull'+no);

    var textarea = dModify.getElementsByTagName('TEXTAREA');
    if (!textarea[0].value) {
        alert('내용을 입력하세요');
        textarea[0].focus();
        return false;
    }
    var input = dModify.getElementsByTagName('INPUT');
    for (var i = 0; i < input.length; i++) {
        if (input[i].name == 'writer_name') {
            if (!input[i].value) {
                alert('이름을 입력하세요');
                input[i].focus();
                return false;
            }
        } else if (input[i].name == 'passwd') {
            if (!input[i].value) {
                alert('비밀번호를 입력하세요');
                input[i].focus();
                return false;
            }
        }
    }
    document.getElementById('afternote_frm'+no).subject.value = document.getElementById('afternote_frm'+no).subject.value.replace('MEMBER_NAME', document.getElementById('afternote_frm'+no).writer_name.value);
    document.getElementById('afternote_frm'+no).submit();
}

/**
 * 이미지미리보기
 */
function file_div_display(div_id,show_flag) {
    if(show_flag=="T") {
        document.getElementById(div_id).style.display="";
    }
    else {
        document.getElementById(div_id).style.display="none";
    }
}

/**
 * 답변
 */
function doReplyAction(no)
{
    var dModify = document.getElementById('dModify'+no);

    var textarea = dModify.getElementsByTagName('TEXTAREA');
    document.getElementById('content').value = textarea[0].value;

    var input = dModify.getElementsByTagName('INPUT');
    for (var i = 0; i < input.length; i++) {
        if (input[i].name == 'u31name') {
            document.getElementById('writer_name').value = input[i].value;
        } else if (input[i].name == 'u31pw') {
            document.getElementById('password').value = input[i].value;
        }
    }

    document.getElementById('mode').value = 'reply';
    document.getElementById('no').value = no;
    document.getElementById('afternote_frm').submit();
}

function showLayer(sObj, o)
{
    var oPos = cumulativeOffset(o);

    oDiv = document.getElementById(sObj);
    oDiv.style.left = oPos[0];
    oDiv.style.top = oPos[1];
    oDiv.style.display = 'inline';
}

function hideLayer(sObj)
{
    oDiv = document.getElementById(sObj);
    oDiv.style.display = 'none';
}

function cumulativeOffset(element)
{
    var valueT = 0, valueL = 0;

    do {
        valueT += element.offsetTop || 0;
        valueL += element.offsetLeft || 0;
        element = element.offsetParent;
    } while (element);

    return [valueL, valueT];
}

function reloadPriceCalc()
{
    var pay_currency = document.frm.pay_currency.value;
    var quantity = 1;
    
    //상품 상세 페이지에 수량 항목을 표시하지 않으면 오류 발생하여, 수량을 표시하지 않을 경우에는 1개로 인식하게 합니다. - smyeo
    if (document.getElementById('quantity_0')) {
        quantity = document.getElementById('quantity_0').value;
    }
     
    if (document.getElementById('assign_prd_discount_price_text')) {
        document.getElementById('assign_prd_discount_price_text').innerHTML = priceFormat(document.getElementById('assign_prd_discount_price').value * quantity, pay_currency, ',');
    }
    if (document.getElementById('assign_prd_sale_price_text')) {
        document.getElementById('assign_prd_sale_price_text').innerHTML = priceFormat(document.getElementById('assign_prd_sale_price').value * quantity, pay_currency, ',');
    }
}

function checkOrgImageFile(sOrgImageFile, bt_idx, bf_idx)
{
    if (sOrgImageFile) {
        var params = '&filename=' + sOrgImageFile + '&bt_idx=' + bt_idx + '&bf_idx=' + bf_idx;
        sendRequest(checkImage, params,'POST', '/Front/Product/?url=Imagecheck', true, false);
    }
}

function checkImage(obj)
{
    eval('var rs = ' + obj.responseText);

    if (rs.RESULT !== false) {
        try {
            if (document.getElementById('board_img_' + rs.bt_idx + '_' + rs.bf_idx)) {
                document.getElementById('board_img_' + rs.bt_idx + '_' + rs.bf_idx).src=rs.filename;
            } else {
                document.getElementById('board_img_' + rs.bt_idx).src=rs.filename;
            }
        } catch(e) {
            return false;
        }
    }
}

function smsStock(){
    var frm = document.smsStockForm;
    var s_prd_code = frm.s_prd_code.value; 
    var s_prd_item_code = frm.s_prd_item_code.value;  
    var s_product_name = frm.s_product_name.value; 
    //var sImg = encodeURIComponent(frm.sImg.value); 
    var sImg="";
    var sMemID = frm.sMemID.value;
    var sMemName = frm.sMemName.value; 
    
    if(!frm.ss_cellphone1.value || !frm.ss_cellphone2.value || !frm.ss_cellphone2.value){
        alert('휴대폰 번호를 등록해 주세요');
        return false;
    }
    var s_cellphone = frm.ss_cellphone1.value+'-'+frm.ss_cellphone2.value+'-'+frm.ss_cellphone3.value; 
   
    ss_check = 'F';
    if(frm.ss_check.checked==true)ss_check = 'T';
    var params = "&s_prd_code="+s_prd_code+"&s_prd_item_code="+s_prd_item_code+"&s_product_name="+encodeURIComponent(s_product_name)+"&sImg="+sImg+"&sMemID="+sMemID+"&sMemName="+encodeURIComponent(sMemName)+"&s_cellphone="+s_cellphone+"&ss_check="+ss_check;
    //document.write(params);
    var rtn = sendRequest(smsStockBack, params, 'POST', '/Front/Product/?url=smsStock&', true, true);    
}

function smsStockBack(oj) {
    var txt = oj.responseText;  
    if(txt.replace(/(^\s*)|(\s*$)/g, "")=='T'){
        alert('요청되었습니다');
    }else{
        alert('요청실패하였습니다.');
    }
    
    document.getElementById('smsStock').style.display='none';
}

function couponSelectPopup(prd_no, cate_no)
{
    var url = '/Front/Product/?url=Couponselect&prd_no='+prd_no+'&cate_no='+cate_no;
    window.open(url, 'coupon_select', 'scrollbars=no,status=no,toolbar=no,width=600,height=200');
}

function couponSelect()
{
    var pay_currency = opener.document.frm.pay_currency.value;
    var iSalePrice = opener.document.getElementById('assign_prd_sale_price').value;
    var sCouponValue = document.getElementById('coupon_select').value;
    var aCouponValue = sCouponValue.split('|');
    var aRound = new Array();
    
    if(aCouponValue[0]) {
        if(aCouponValue[1] == 'W') {
            iReturnPrice = iSalePrice - aCouponValue[0];
        } else {
            aRound['D'] = -1;
            aRound['H'] = -2;
            aRound['U'] = -3;
            iReturnPrice = iSalePrice - (iSalePrice * (aCouponValue[0] / 100));
            iReturnPrice = iReturnPrice * Math.pow(10,aRound[aCouponValue[2]]); 
            iReturnPrice = Math.round(iReturnPrice); 
            iReturnPrice = iReturnPrice/Math.pow(10,aRound[aCouponValue[2]]); 
        }
        
        opener.document.getElementById('coupon_price').innerHTML = priceFormat(iReturnPrice, pay_currency, ',')+'원';
        window.close();
    } else {
        alert('쿠폰을 선택 해주세요.');
    }
}

function showNaverCashShowAccumPopup(sId)
{
	window.open('https://customer.cash.naver.com/customer/showAccumulation/' + sId, 'NaverCashAccum', 'width=400,height=400,status=no,resizable=no');
	return;
}

var isSubmit = false;   // 중복 요청 방지를 위한 flag
/**
 * 상품별 투표 댓글목록 보기
 */
function showPollCommentListAjax(iBulletinNo, sTargetDivId, sPageTargetDivId, iPage)
{
    if(isSubmit === false) {
        isSubmit = true;
        
        var sParams = '&url=Pollcommentlist&bulletin_no='+iBulletinNo+'&target_div_id='+sTargetDivId+'&page_target_div_id='+sPageTargetDivId+'&poll_comment_page='+iPage;
        sendRequest(showPollCommentListCallback, sParams, 'POST', '/Front/Product/index.php', true, true);
    } else {
        alert('처리중입니다.');
        return false;
    }
}

/**
 * 상품별 투표 댓글목록 출력
 */
function showPollCommentListCallback(responseObj)
{
    try {
        eval('var res = '+responseObj.responseText);
        document.getElementById(res['target_div']).innerHTML = res['comment_html'];
        document.getElementById(res['page_target_div']).innerHTML = res['page_html'];
    } catch (e) {
        alert('답글 목록을 불러오는중 오류가 발생하였습니다.');
    }
    isSubmit = false;
}

/**
 * 상품별 투표 게시물 수정 폼 보기
 */
function showPollBulletinModifyFormAjax(iBulletinNo, sTargetDivId)
{
    if(isSubmit === false) {
        isSubmit = true;
        
        var sParams = '&url=Pollbulletinmodifyform&bulletin_no='+iBulletinNo+'&target_div_id='+sTargetDivId;
        sendRequest(showPollBulletinModifyFormCallback, sParams, 'POST', '/Front/Product/index.php', true, true);
    } else {
        alert('처리중입니다.');
        return false;
    }
}

/**
 * 상품별 투표 게시물 수정 폼 출력
 */
function showPollBulletinModifyFormCallback(responseObj)
{
    try {
        eval('var res = '+responseObj.responseText);
        document.getElementById(res['target_div']).innerHTML = res['form_html'];
    } catch (e) {
        alert('폼 생성중 오류가 발생하였습니다.');
    }
    isSubmit = false;
}

/**
 * 상품별 투표 게시물 답글 폼 보기
 */
function showPollCommentFormAjax(iBulletinNo, sTargetDivId)
{
    if(isSubmit === false) {
        isSubmit = true;
        
        var sParams = '&url=Pollcommentform&bulletin_no='+iBulletinNo+'&target_div_id='+sTargetDivId;
        sendRequest(showPollCommentFormCallback, sParams, 'POST', '/Front/Product/index.php', true, true);
    } else {
        alert('처리중입니다.');
        return false;
    }
}

/**
 * 상품별 투표 게시물 답글 폼 출력
 */
function showPollCommentFormCallback(responseObj)
{
    try {
        eval('var res = '+responseObj.responseText);
        document.getElementById(res['target_div']).innerHTML = res['form_html'];
    } catch (e) {
        alert('폼 생성중 오류가 발생하였습니다.');
    }
    isSubmit = false;
}

/**
 * 상품별 투표 게시물 삭제
 */
function delPollBulletin(iBulletinNo)
{
    return confirm('정말 삭제하시겠습니까?');
}

/**
 * 요청된 div의 innerHTML을 clear
 */
function clearDiv(sTargetDivId)
{
    if (document.getElementById(sTargetDivId)) {
        document.getElementById(sTargetDivId).innerHTML='';
    }
}

/**
 * 글자수 체크
 */
function chkStringLength(obj, maxLength)
{
    try {
        if (obj.value.length > maxLength) {
            alert(maxLength+'자 까지 입력 가능합니다.');
            obj.value = obj.value.substring(0,maxLength);
            obj.focus();
        }
    } catch (e) {
        var i=0;
    }
}

/**
 * 상품별 투표 게시물 폼 체크
 */
function chkPollBulletinForm(obj)
{
    if (!obj.poll_bulletin_no) {
        // 신규 게시물 작성
        var sCookieData = getCookie('prd_poll_prd_code');
        var aCookieData = sCookieData.split(',');
        for (var i=0; i<aCookieData.length; i++) {
            if (aCookieData[i] == obj.product_code.value) {
                alert('이미 투표하신 상품입니다.');
                return false;
            }
        }
    }

    if (obj.prd_poll_writer_name.value.length == 0) {
        alert('작성자명을 입력해 주세요.');
        obj.prd_poll_writer_name.focus();
        return false;
    }
    
    if (obj.prd_poll_contents.value.length == 0) {
        alert('내용을 입력해 주세요.');
        obj.prd_poll_contents.focus();
        return false;
    }
    return true;
}

/**
 * 상품별 투표 게시물 추천여부 체크
 */
function chkPollRecommended(iBulletinNo)
{
    var sCookieData = getCookie('prd_poll_bulletin_idx');
    var aCookieData = sCookieData.split(',');
    for (var i=0; i<aCookieData.length; i++) {
        if (aCookieData[i] == iBulletinNo) {
            alert('이미 추천하신 게시물입니다.');
            return false;
        }
    }
    return true;
}

/**
 * 로그인 필요 메세지 출력 및 리다이렉트
 */
function redirectLoginPage(sRedirectUrl)
{
    if (sRedirectUrl != '') {
        alert('로그인 후 사용 가능합니다');
        document.location = sRedirectUrl;
    } else {
        alert('작성 권한이 없습니다.');
    }
    return false;
}

//comment modify/secret comment view
var commentControlTarget = '';
function getCommentPasswordForm(iCommentIdx)
{
    if (commentControlTarget != '') {
        alert('처리중입니다.');
    } else {
        commentControlTarget = iCommentIdx;
        sParams = "&url=commentPasswordForm&comment_no="+iCommentIdx;
        sendRequest(setCommentPasswordForm, sParams,'POST', '/Front/Board/', true, true);
    }
}

function setCommentPasswordForm(obj)
{
    document.getElementById('comment_control_area_'+commentControlTarget).style.display = '';
    document.getElementById('comment_control_area_'+commentControlTarget).innerHTML = obj.responseText;
    commentControlTarget = '';
}

var secretCommentReadTarget = '';
var secretCommentModifyTarget = '';
function chkCommentPassword(oForm, iCommentIdx, isModifyMode)
{
    if (secretCommentReadTarget != '') {
        alert('처리중입니다.');
    } else {
        var iCommentNo = oForm.comment_no.value;
        var sPassword = oForm.comment_passwd.value;
        secretCommentReadTarget = iCommentIdx;
        if (isModifyMode == 'T') {
            secretCommentModifyTarget = iCommentIdx;
        } else {
            isModifyMode = 'F';
        }

        try {
            // SSL
            var ssl_callback_fn = function(output){
                var sParams = "&url=commentPasswordCheck&isModifyMode="+isModifyMode+"&"+AuthSSL.key+"="+output;
                sendRequest(setSecretCommentContents, sParams, 'POST', '/Front/Board/', true, true);
            };
            if (AuthSSL_encode(oForm, ["comment_no", "comment_passwd"], ssl_callback_fn) == true) {
                return false;
            }
        } catch (e) {}

        // HTTP
        var sParams = "&url=commentPasswordCheck&comment_no="+iCommentNo+"&"+"comment_passwd="+sPassword+"&isModifyMode="+isModifyMode;
        sendRequest(setSecretCommentContents, sParams,'POST', '/Front/Board/', true, true);
    }

    return false;
}

function setSecretCommentContents(obj)
{
    var sChkCode = obj.responseText;
    sChkCode = sChkCode.replace(/[\r\n\s]/, '');
    var aErrorCode = {
            'ERROR_8001' : '해당 댓글의 읽기 권한이 없습니다.',
            'ERROR_8002' : '잘못된 비밀번호입니다.',
            'ERROR_9001' : '잘못된 댓글정보입니다. 관리자에게 문의하여 주세요.'
    };
    
    if (sChkCode == '') {
        alert('알 수 없는 오류입니다. 관리자에게 문의하여 주세요.');
        secretCommentReadTarget = '';
        return false;
    }

    if (aErrorCode[sChkCode]) {
        alert(aErrorCode[sChkCode]);
        secretCommentReadTarget = '';
        return false;
    } else {
        if (document.getElementById('secret_comment_'+secretCommentReadTarget)) {
            document.getElementById('secret_comment_'+secretCommentReadTarget).innerHTML = obj.responseText;
        }
        if (secretCommentModifyTarget == secretCommentReadTarget) {
            getCommentModifyForm(secretCommentModifyTarget);
        } else {
            document.getElementById('comment_control_area_'+secretCommentReadTarget).style.display = 'none';
        }

        secretCommentReadTarget = '';
        secretCommentModifyTarget = '';
        return true;
    }
}

function getCommentModifyForm(iCommentIdx)
{
    if (commentControlTarget != '') {
        alert('처리중입니다.');
    } else {
        commentControlTarget = iCommentIdx;
        sParams = "&url=commentModifyForm&comment_no="+iCommentIdx;
        sendRequest(setCommentModifyForm, sParams,'POST', '/Front/Board/', true, true);
    }
}

function setCommentModifyForm(obj)
{
    var sChkCode = obj.responseText;
    sChkCode = sChkCode.replace(/[\r\n\s]/, '');
    var aErrorCode = {
            'ERROR_8001' : '해당 댓글의 수정 권한이 없습니다.',
            'ERROR_9001' : '잘못된 댓글정보입니다. 관리자에게 문의하여 주세요.'
    };
    
    if (sChkCode == '') {
        alert('알 수 없는 오류입니다. 관리자에게 문의하여 주세요.');
        commentControlTarget = '';
        return false;
    }
    
    if (aErrorCode[sChkCode]) {
        alert(aErrorCode[sChkCode]);
        commentControlTarget = '';
        return false;
    } else {
        document.getElementById('comment_control_area_'+commentControlTarget).style.display = '';
        document.getElementById('comment_control_area_'+commentControlTarget).innerHTML = obj.responseText;
        commentControlTarget = '';
        return true;
    }
}

function setCommentModifyDao(oForm)
{
    if (isSubmit != false) {
        alert('처리중입니다.');
    } else {
        isSubmit = true;

        var iCommentNo = oForm.comment_no.value;
        var sPassword = oForm.comment_passwd.value;
        var sName = oForm.comment_name.value;
        var sContents = oForm.comment.value;

        var sIsSecret = 'F';

        if (oForm.is_secret) {
            for (var i=0; i<oForm.is_secret.length; i++) {
                if (oForm.is_secret[i].checked === true) {
                    sIsSecret = oForm.is_secret[i].value;
                }
            }
        }

        try {
            // SSL
            var ssl_callback_fn = function(output){
                var sParams = "&url=Commentmodify&is_secret="+sIsSecret+"&"+AuthSSL.key+"="+output;
                sendRequest(getCommentModifyResult, sParams, 'POST', '/Front/Board/', true, true);
            };
            if (AuthSSL_encode(oForm, ["comment_no", "comment_passwd", "comment_name", "comment"], ssl_callback_fn) == true) {
                return false;
            }
        } catch (e) {}

        // HTTP
        var sParams = "&url=Commentmodify&comment_no="+iCommentNo+"&comment_passwd="+sPassword+"&comment_name="+sName+"&comment="+sContents+"&is_secret="+sIsSecret;
        sendRequest(getCommentModifyResult, sParams,'POST', '/Front/Board/', true, true);
    }

    return false;
}

function getCommentModifyResult(obj)
{
    var sChkCode = obj.responseText;
    sChkCode = sChkCode.replace(/[\r\n\s]/, '');
    var aErrorCode = {
            'ERROR_0000' : '댓글이 수정되었습니다.',
            'ERROR_8001' : '해당 댓글의 수정 권한이 없습니다.',
            'ERROR_9001' : '잘못된 댓글정보입니다. 관리자에게 문의하여 주세요.',
            'ERROR_9003' : '지정된 댓글이 존재하지 않습니다.',
            'ERROR_9999' : '알 수 없는 오류입니다. 관리자에게 문의하여 주세요.'
    };

    if (aErrorCode[sChkCode]) {
        alert(aErrorCode[sChkCode]);
        isSubmit = false;
        if (sChkCode == 'ERROR_0000') {
            // 수정 성공시 reload
            location.reload();
        }
        return false;
    } else {
        alert(aErrorCode['ERROR_9999']);
        isSubmit = false;
        return false;
    }
    return false;
}

/**
 * 상품조르기
 */
function badger_product()
{
    var prd = '';
    var badger_url = '/Front/Badger/?prd=';

    if(document.getElementsByName('prd_item_code').length > 1) {
        for(var i = 0 ; i < document.getElementsByName('prd_item_code').length ; i++)
        {
            prd += document.getElementsByName('prd_item_code')[i].value + ';';
        }
        
        window.open(badger_url+prd, 'badger', 'width=690,height=700,scrollbars=yes');
    } else if(document.getElementById('prd_item_code').value) {
        window.open(badger_url+document.getElementById('prd_item_code').value, 'badger', 'width=700,height=700,scrollbars=yes');
    } else {
        alert('필수 옵션이 선택되지 않았습니다.');
    }
}
