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;
            }
            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) {
    var sItemCode = document.getElementById('prd_item_code');
    var frm = document.frm;

    if (!sItemCode.value) {
        alert('상품의 옵션을 선택해 주세요');
        return;
    }

    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;
        }
    }

    // 네이버 체크아웃
    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);
            if(cfa){
                return true;
            }else{
                return false;
            }

        }
    }

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

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

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

    if (frm['quantity'+sPrdCode]) {
        if (parseInt(frm['product_min'+sPrdCode].value) > 0) {
            if (parseInt(frm['quantity'+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['quantity'+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 + ' 입니다.');
            frm['quantity'+sPrdCode].select();
            return false;
        }
    }

    if (parseInt(frm['product_buy_qty'+sPrdCode].value) > 1) {
        var iBuyQty = frm['quantity'+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();
}

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 {
        var oObj = null;

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

        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) {
                        sNode.parentNode.style.display = 'none';
                        //'<font style="font-weight:bold;font-style:normal;color:red">품절</font>';
                        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');
                    }
                    return false;
                }
                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')) {
                            document.getElementById('main_opt_price').removeChild(document.getElementById('oSoldElementArea'));
                            sNode.parentNode.style.display = 'block';
                        }

                        if (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 = 'block';
                        }
                        sNode.innerHTML = priceFormat(orgPrice, pay_currency, ',');
                        setOrgItemPrice(orgPrice);
                        setMemDiscountCalc();
                        reloadPriceCalc();
                    } catch(e) {}
                }
            }
        } catch(e) {
            oItemObj.value = '';
        }
    }

    return true;
}

function setOrgItemPrice(price) {
    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 calcProductPrice()
{
    // 선택된 상품 정보를 가져온다.
    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 totalPrice = 0;
    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);
            }
        }

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

    var oPriceObj = document.getElementById('assign_prd_sale_price_text');

    if(oPriceObj && document.frm.p_sale_price_type.value != 'M') {
        oPriceObj.innerHTML = priceFormat(totalPrice, pay_currency, ',');
        setOrgItemPrice(totalPrice)
    }
}

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

    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;
            }

            // 가격 계산
            calcProductPrice();

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

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

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) {

    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;
                }
            }
        }

        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);
    */
}

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;
}

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

function nv_add_basket(arg)
{
    createHiddenIframe();

    if(arg=="1"){
        if( check_frm('', 'nv') ){
            document.frm.nv_hidden_flag.value = 'order';
//            frm.target = 'hidden_ifr';
            frm.command.value = 'naver';
            document.frm.submit();
        }
    } else {
        if(!check_frm('', 'nv')) return false;

        product_no = document.frm.product_no.value;
        prd_item_code = document.frm.prd_item_code.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) {}
}

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;
    if (document.getElementById('assign_prd_discount_price_text')) {
        document.getElementById('assign_prd_discount_price_text').innerHTML = priceFormat(document.getElementById('assign_prd_discount_price').value * document.getElementById('quantity_0').value, 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 * document.getElementById('quantity_0').value, pay_currency, ',');
    }
}