var m_option_cnt = 1;  // Ãß°¡ ¿É¼Ç °³¼ö (¿É¼Ç ´ÙÁß ¼±ÅÃ ±â´É »ç¿ë½Ã)

var naverChk_soldout_flag = 'T'; //³×ÀÌ¹öÃ¼Å©¾Æ¿ô Ç°Àý¿¡ µû¸¥ Ç¥½Ã¿©ºÎ
var naverChk_dlv_flag     = 'T'; //³×ÀÌ¹öÃ¼Å©¾Æ¿ô ÇØ¿Ü¹è¼Û¿¡ µû¸¥ Ç¥½Ã¿©ºÎ
/*
    ¼ö·® Á¶Àý±â´É
    @modify ÃÖÈ¯È£ <hhchoi@simplexi.com>
    @date 2008-06-30
*/
function quantity_control()
{
    if(typeof(document.relationProd['basket_info[]'].length) == 'undefined') {
            if(window.event.srcElement == document.relationProd["up"]){
                document.relationProd["quantity1"].value = eval(document.relationProd["quantity1"].value)+1;
            }

            if(window.event.srcElement == document.relationProd["down"] && document.relationProd["quantity1"].value > 1){
                document.relationProd["quantity1"].value = eval(document.relationProd["quantity1"].value)-1;
            }

    } else {
        for(i=0; i < document.relationProd["quantity1[]"].length; i++){
            if(window.event.srcElement == document.relationProd["up"][i]){
                document.relationProd["quantity1[]"][i].value = eval(document.relationProd["quantity1[]"][i].value)+1;
            }

            if(window.event.srcElement == document.relationProd["down"][i] && document.relationProd["quantity1[]"][i].value > 1){
                document.relationProd["quantity1[]"][i].value = eval(document.relationProd["quantity1[]"][i].value)-1;
            }
        } //end for
    }
}

/*
    °ü·Ã»óÇ° Àå¹Ù±¸´Ï ´ã±â Ãß°¡
    @modify ÃÖÈ¯È£ <hhchoi@simplexi.com>
    @date 2008-07-14
*/

function add_basket( arg, cmd )
{
    var multi_option_data = '';
    // Ãß°¡ Ä¿¸Çµå°¡ ÀÖ´Ù¸é ±âÁ¸ Ã¼Å©·ÎÁ÷Àº ¼öÇàÇÏÁö ¾ÊÀ½
    // ¸ÖÆ¼»óÇ°¸¸ ´ã´Â´Ù¸é 
    if( cmd || check_frm() )
    {
        frm.command.value = ( cmd ) ? cmd : 'add';
        frm.redirect.value = arg ;
        if(frm.option13 != undefined){
            alert('»óÇ°¿É¼ÇÀº 15°³±îÁö¸¸ °¡´ÉÇÕ´Ï´Ù.\n°ü¸®ÀÚ¿¡ ¹®ÀÇÇÏ½Ê½Ã¿ä');
            return;
        }

        if(typeof(frm['relation_product']) == 'object') {
                if(frm.relation_product.value == "yes") {
                    value = relation_product();
                    if(value == "no") {
                        return;
                    }
                }
        }

        if(typeof(document.forms['relationProd']) == 'object') {

           //¼­·Î ´Ù¸¥ ÆûÀÎµ¥ ¼­ºê¹ÔÇÏ°Ô µÇ¸é ¸ðµç °ªµéÀÌ ³Ñ¾î°¡¾ßµÇ±â ¶§¹®¿¡ ¾Æ·¡¿Í°°ÀÌ Ã³¸®
           if(typeof(oFrm['basket_info[]'].length) == 'undefined') {
                if(document.relationProd["basket_info[]"].checked == true)
                {

                    //»ç¿ëÀÚ ¿É¼Ç³Ñ±è(no°¡ ¾Æ´Ò°æ¿ì
                    if(document.relationProd["option_use[]"].value != "no"){
                        temp_product_no = document.relationProd["basket_info[]"].value.split("|");
                        product_no = temp_product_no[0];

                        if(document.relationProd["option_use[]"].value == 1) {
                            if(typeof(document.relationProd["user_option_"+product_no]) == "object") {
                                input = document.createElement("INPUT");
                                input.setAttribute("type", "hidden");
                                input.setAttribute("name", "user_option_"+product_no);
                                input.setAttribute("value", document.relationProd['user_option_'+product_no].value);
                                frm.appendChild(input);
                            }
                        } else {
                            if(typeof(document.relationProd["user_option_"+product_no+"[]"]) == "object") {
                                for(j=0;j<document.relationProd["user_option_"+product_no+"[]"].length;j++){
                                    input = document.createElement("INPUT");
                                    input.setAttribute("type", "hidden");
                                    input.setAttribute("name", "user_option_"+product_no+"[]");
                                    input.setAttribute("value", document.relationProd['user_option_'+product_no+'[]'][j].value);
                                    frm.appendChild(input);
                                }
                            }
                        }

                        if(typeof(document.relationProd['user_option_name_'+product_no]) == "object") {
                            input = document.createElement("INPUT");
                            input.setAttribute("type", "hidden");
                            input.setAttribute("name", "user_option_name_"+product_no);
                            input.setAttribute("value", document.relationProd['user_option_name_'+product_no].value);
                            frm.appendChild(input);
                        }

                    }

                    //»óÇ°Á¤º¸¸¦ ÆûÀÌ¸§relationProd¿¡¼­ ÆûÀÌ¸§ frmÀ¸·Î ³Ñ±è
                    input = document.createElement("INPUT");
                    input.setAttribute("type", "hidden");
                    input.setAttribute("name", "basket_info[]");
                    input.setAttribute("value", document.relationProd["basket_info[]"].value);
                    frm.appendChild(input);
                }
           } else {
                for(i=0;i<document.relationProd["basket_info[]"].length;i++){
                    if(document.relationProd["basket_info[]"][i].checked == true)
                    {

                        //»ç¿ëÀÚ ¿É¼Ç³Ñ±è(no°¡ ¾Æ´Ò°æ¿ì
                        if(document.relationProd["option_use[]"][i].value != "no"){
                            temp_product_no = document.relationProd["basket_info[]"][i].value.split("|");
                            product_no = temp_product_no[0];

                            if(document.relationProd["option_use[]"][i].value == 1) {
                                if(typeof(document.relationProd["user_option_"+product_no]) == "object") {
                                    input = document.createElement("INPUT");
                                    input.setAttribute("type", "hidden");
                                    input.setAttribute("name", "user_option_"+product_no);
                                    input.setAttribute("value", document.relationProd['user_option_'+product_no].value);
                                    frm.appendChild(input);
                                }
                            } else {
                                if(typeof(document.relationProd["user_option_"+product_no+"[]"]) == "object") {
                                    for(j=0;j<document.relationProd["user_option_"+product_no+"[]"].length;j++){
                                        input = document.createElement("INPUT");
                                        input.setAttribute("type", "hidden");
                                        input.setAttribute("name", "user_option_"+product_no+"[]");
                                        input.setAttribute("value", document.relationProd['user_option_'+product_no+'[]'][j].value);
                                        frm.appendChild(input);
                                    }
                                }
                            }

                            if(typeof(document.relationProd['user_option_name_'+product_no]) == "object") {
                                input = document.createElement("INPUT");
                                input.setAttribute("type", "hidden");
                                input.setAttribute("name", "user_option_name_"+product_no);
                                input.setAttribute("value", document.relationProd['user_option_name_'+product_no].value);
                                frm.appendChild(input);
                            }

                        }

                        //»óÇ°Á¤º¸¸¦ ÆûÀÌ¸§relationProd¿¡¼­ ÆûÀÌ¸§ frmÀ¸·Î ³Ñ±è
                        input = document.createElement("INPUT");
                        input.setAttribute("type", "hidden");
                        input.setAttribute("name", "basket_info[]");
                        input.setAttribute("value", document.relationProd["basket_info[]"][i].value);
                        frm.appendChild(input);
                    }
                }
           }
        }

        // 2009-07-01 Ãß°¡ ¿É¼Ç ÇÊ¼ö °ª Ã¼Å©  - ±ÇÇõÃµ
        for (i=1;i<m_option_cnt;i++) {
            divstatus = document.getElementById('m_option_'+i).style.display;
            if (divstatus=='block') {
                multi_option_data += '^' + document.getElementById('quantity_' + i).value;
                for (var j =0; j < optionInfo.id.length; j++) {
                    if (optionInfo.type[j]=='selectbox') {
                       var vfrm = document.getElementById('selectbox_' + i + '_' + (j+1));
                       multi_option_data += '|' + vfrm.options[vfrm.selectedIndex].value ;
                    } else {
                       multi_option_data += '|' + document.getElementById('inputbox_' + i + '_' + (j+1)).value;
                    }
                }
            }
        }

        frm.multi_option_data.value = multi_option_data;

        document.frm.submit();
    }
}


/*
    Ã¼Å©µÈ »óÇ°¸¸ Àå¹Ù±¸´Ï¿¡ ³Ö±â À§ÇØ ÇÊ¿ä°ªÀ» ±¸ºÐÀÚ·Î Ãß°¡½ÃÅ²´Ù
    ÀÌ¹Ì ¹è¿­·Î µé¾îÀÖ´Â °ª : »óÇ°ÄÚµå|Ä«Å×°í¸®ÄÚµå|»óÇ°Á¾·ù|ÃÖ¼Ò±¸¸Å¼ö·®|»óÇ°ÀÌ¸§|»óÇ°°¡°Ý
    Ãß°¡ ½ÃÅ°´Â °ª          : ¼ö·®|¿É¼Ç°³¼ö|¿É¼Ç¼±ÅÃ°ª
    @author ÃÖÈ¯È£ <hhchoi@simplexi.com>
    @date 2008-04-07
*/
function relation_product()
{
    oFrm = document.forms['relationProd'];

    _chkCnt = 0;
    var option_msg = "ÇÊ¼ö ¿É¼ÇÀ» ¼±ÅÃÇØ ÁÖ¼¼¿ä.";

    if(typeof(oFrm['basket_info[]'].length) == 'undefined') {
        if (oFrm['basket_info[]'].checked == true) {
            var temp = oFrm["basket_info[]"].value.split("|");
            var product_min = temp[3];

            //ÇÊ¼ö ¿É¼Ç Ã¼Å©
            if(oFrm["option_use[]"].value != "no") {
                if(oFrm["option_use[]"].value>1) {
                      option_name = 'option_'+temp[0]+'[]';

                      for(j=0;j<oFrm[option_name].length;j++)
                      {
                           if(oFrm[option_name][j].value == "") {
                                alert(option_msg);
                                oFrm[option_name][j].focus();
                                return "no";
                            }
                      }

                } else {
                    option_name = 'option_'+temp[0];

                    if(oFrm[option_name].value == "") {
                        alert(option_msg);
                            oFrm[option_name].focus();
                            return "no";
                    }
                }
            }

            //Ã¼Å©µÈ °Í¸¸ ¼ö·® Ã¼Å©
            if(oFrm['basket_info[]'].length > 1) {
                quantity = oFrm["quantity1[]"];
            } else {
                quantity = oFrm["quantity1"];
            }

            if (!quantity.value)
            {
                alert ('¼ö·®À» ÀÔ·ÂÇØ ÁÖ½Ê½Ã¿À.');
                quantity.focus();
                return "no";
            }

            for (j = 0; j < quantity.value.length; j++) {
                if (! (quantity.value.charAt(j) >= '0' && quantity.value.charAt(j) <= '9')){
                    alert ('¼ö·®Àº ¼ýÀÚ¸¸ °¡´ÉÇÕ´Ï´Ù.');
                    quantity.select();
                    return "no";
                }
            }

            if (parseInt(quantity.value) < product_min)
            {
                 alert ('ÃÖ¼Ò ÁÖ¹®¼ö·®Àº ' + product_min + ' ÀÔ´Ï´Ù.');
                 quantity.focus();
                 return "no";
            }

            if (oFrm['basket_info[]'].checked == true) {
                oFrm["basket_info[]"].value = oFrm["basket_info[]"].value + "|" + oFrm["quantity1"].value;

                if(oFrm["option_use[]"].value != "no") {

                    temp = oFrm["basket_info[]"].value.split("|");

                    if(oFrm["option_use[]"].value>1) {
                        option_name = 'option_'+temp[0]+'[]';

                        oFrm["basket_info[]"].value = oFrm["basket_info[]"].value + "|" + oFrm[option_name].length;

                        for(j=0;j<oFrm[option_name].length;j++)
                        {
                            oFrm["basket_info[]"].value = oFrm["basket_info[]"].value + "|" + oFrm[option_name][j].value;
                        }

                    } else {
                        option_name = 'option_'+temp[0];

                        oFrm["basket_info[]"].value = oFrm["basket_info[]"].value + "|1";
                        oFrm["basket_info[]"].value = oFrm["basket_info[]"].value + "|" + oFrm[option_name].value;
                    }
                }

            }
        }
    } else {

        for(i=0;i<oFrm['basket_info[]'].length;i++) {

            if (oFrm['basket_info[]'][i].checked == true) {

                var temp = oFrm["basket_info[]"][i].value.split("|");
                var product_min = temp[3];

                if(oFrm["option_use[]"][i].value != "no") {

                    if(oFrm["option_use[]"][i].value>1) {
                        option_name = 'option_'+temp[0]+'[]';

                        for(j=0;j<oFrm[option_name].length;j++)
                        {
                            if(oFrm[option_name][j].value == "") {
                                alert(option_msg);
                                oFrm[option_name][j].focus();
                                return "no";
                            }
                        }

                    } else {
                        option_name = 'option_'+temp[0];

                        if(oFrm[option_name] && oFrm[option_name].value == "") {
                            alert(option_msg);
                            oFrm[option_name].focus();
                            return "no";
                        }
                    }
                }

                //Ã¼Å©µÈ °Í¸¸ ¼ö·® Ã¼Å©
                if(oFrm['basket_info[]'].length > 1) {
                    quantity = oFrm["quantity1[]"][i];
                } else {
                    quantity = oFrm["quantity1"][i];
                }

                if (!quantity.value)
                {
                    alert ('¼ö·®À» ÀÔ·ÂÇØ ÁÖ½Ê½Ã¿À.');
                    quantity.focus();
                    return "no";
                }

                for (j = 0; j < quantity.value.length; j++) {

                    if (! (quantity.value.charAt(j) >= '0' && quantity.value.charAt(j) <= '9'))
                    {
                        alert ('¼ö·®Àº ¼ýÀÚ¸¸ °¡´ÉÇÕ´Ï´Ù.');
                        quantity.select();
                        return "no";
                    }
                }

                if (parseInt(quantity.value) < product_min)
                {
                    alert ('ÃÖ¼Ò ÁÖ¹®¼ö·®Àº ' + product_min + ' ÀÔ´Ï´Ù.');
                    quantity.focus();
                    return "no";
                }
            }
        }

        for(i=0;i<oFrm['basket_info[]'].length;i++) {
            if (oFrm['basket_info[]'][i].checked == true) {

                oFrm["basket_info[]"][i].value = oFrm["basket_info[]"][i].value + "|" + oFrm["quantity1[]"][i].value;       //¼ö·®

                if(oFrm["option_use[]"][i].value != "no") {

                    temp = oFrm["basket_info[]"][i].value.split("|");

                    if(oFrm["option_use[]"][i].value>1) {
                        option_name = 'option_'+temp[0]+'[]';

                        //¿É¼ÇÁ¾·ù¼ö
                        oFrm["basket_info[]"][i].value = oFrm["basket_info[]"][i].value + "|" + oFrm[option_name].length;

                        for(j=0;j<oFrm[option_name].length;j++)
                        {
                            //¿É¼Ç¼±ÅÃ°ª
                            oFrm["basket_info[]"][i].value = oFrm["basket_info[]"][i].value + "|" + oFrm[option_name][j].value;
                        }

                    } else {
                        option_name = 'option_'+temp[0];

                        oFrm["basket_info[]"][i].value = oFrm["basket_info[]"][i].value + "|1";
                        if ( oFrm[option_name] )
                            oFrm["basket_info[]"][i].value = oFrm["basket_info[]"][i].value + "|" + oFrm[option_name].value;
                    }
                }

            }
        } // end of for
    }
}

//¼¼Æ®»óÇ° ¸ðµÎ Ã¼Å©
//ÃÖÈ¯È£ <hhchoi@simplexi.com> date 2008-09-10
function chkRelProd()
{
    var delvTypeValue = '';
    //ÇØ¿Ü¹è¼ÛÀÌ ¼±ÅÃµÇ¾î ÀÖÀ¸¸é ¼¼Æ®»óÇ°Àº ¼±ÅÃÀÌ ¾ÈµÇ°Ô Ã³¸®
    if(document.frm.delvType != undefined){
        for(i=0;i<document.frm.elements.length;i++) {
            if (document.frm.elements[i].type == 'radio') {
                if (document.frm.elements[i].name == 'delvType' && document.frm.elements[i].checked == true) {
                    delvTypeValue = document.frm.elements[i].value;
                }
            }
        }

    }

    if(delvTypeValue != "B" ) {
        if(document.relationProd.rel_check_all.checked) {
            var value = true;
        } else {
            var value = false;
        }
        for(i=0;i<document.relationProd.elements.length;i++) {
            if (document.relationProd.elements[i].type == 'checkbox') {
                if (document.relationProd.elements[i].name == 'basket_info[]') {
                    document.relationProd.elements[i].checked = value;
                }
            }
        }
    } else {
        relationProd.rel_check_all.checked = false;
        for(i=0;i<document.relationProd.elements.length;i++) {
            if (document.relationProd.elements[i].type == 'checkbox') {
                if (document.relationProd.elements[i].name == 'basket_info[]') {
                    document.relationProd.elements[i].checked = false;
                }
            }
        }

        alert('ÇØ¿Ü¹è¼Û ¼³Á¤½Ã ¼¼Æ®»óÇ° ±¸¸Å°¡ ºÒ°¡´ÉÇÕ´Ï´Ù.');
    }

}

//¼¼Æ®»óÇ°°³º° Ã¼Å©
//ÃÖÈ¯È£ <hhchoi@simplexi.com> date 2008-09-10
function set_product_check(obj)
{
    var delvTypeValue = '';
    //ÇØ¿Ü¹è¼ÛÀÌ ¼±ÅÃµÇ¾î ÀÖÀ¸¸é ¼¼Æ®»óÇ°Àº ¼±ÅÃÀÌ ¾ÈµÇ°Ô Ã³¸®
    if(document.frm.delvType != undefined){
        for(i=0;i<document.frm.elements.length;i++) {
            if (document.frm.elements[i].type == 'radio') {
                if (document.frm.elements[i].name == 'delvType' && document.frm.elements[i].checked == true) {
                    delvTypeValue = document.frm.elements[i].value;
                }
            }
        }

    }

    if(delvTypeValue == "B") {
        obj.checked = false;
        alert('ÇØ¿Ü¹è¼Û ¼³Á¤½Ã ¼¼Æ®»óÇ° ±¸¸Å°¡ ºÒ°¡´ÉÇÕ´Ï´Ù.');
    }

}

//ÇØ¿Ü ¹è¼Û ¼±ÅÃ½Ã °ü·Ã»óÇ°ÀÌ ÀÖÀ¸¸é °æ°íÃ¢
function delv_check(obj)
{
	// syjung200908 : try
	try {
    var cnt = 0;
    for(i=0;i<document.relationProd.elements.length;i++) {
        if (document.relationProd.elements[i].type == 'checkbox') {
            if (document.relationProd.elements[i].name == 'basket_info[]' && document.relationProd.elements[i].checked == true) {
                cnt++
            }
        }
    }

    if(cnt != 0) {
       for(i=0;i<document.frm.elements.length;i++) {
            if (document.frm.elements[i].type == 'radio') {
                if (document.frm.elements[i].name == 'delvType') {
                    if(document.frm.elements[i].value == "A") {
                        document.frm.elements[i].checked = true;
                    }
                }
            }
        }

       alert('ÇØ¿Ü¹è¼ÛÀº ¼¼Æ®»óÇ° ±¸¸Å°¡ ºÒ°¡´ÉÇÕ´Ï´Ù.');
    }
	} catch ( e ) {}

    check_naverchk('B');

}

function check_frm()
{
    if (arguments[0] != undefined){
        var service_mode = arguments[0];
    }else{
        var service_mode = "";
    }

    // ¿É¼ÇÇÊ¼ö ¼±ÅÃÇ×¸ñÃ¼Å©
    var neededfrm;
    var divstatus;
    if(service_mode == "nv"){
        var option_msg = "ÇÊ¼ö ¿É¼ÇÀ» ¼±ÅÃÇØ ÁÖ¼¼¿ä.";
    }else{
        var option_msg = "»óÇ° ¿É¼ÇÀ» ¼±ÅÃÇØ ÁÖ¼¼¿ä.";
    }

    // by jsyoon ÇÊ¼ö¼±ÅÃ¿É¼Ç Ã¼Å© 05/11/17
    if(frm.nids != undefined){
        if(frm.nids.length == undefined){
            neededfrm = eval("document.frm." + frm.nids.value);
            if(neededfrm.value == '0') {
                alert(option_msg);
                neededfrm.focus();
                return false;
            }

            // 2009-07-01 Ãß°¡ ¿É¼Ç ÇÊ¼ö °ª Ã¼Å© - ±ÇÇõÃµ
            for (i=1;i<m_option_cnt;i++) {
                divstatus = document.getElementById('m_option_'+i).style.display;
                neededfrm = document.getElementById('selectbox_'+i+'_1');
                if (divstatus=='block' && neededfrm.value == '0') {
                    alert(option_msg);
                    neededfrm.focus();
                    return false;
                }

                if (chkQuantity(document.getElementById('quantity_'+i))==false) {
                    return false
                }
            }

        } else {
            for(var i =0; i < frm.nids.length; i++){
                neededfrm = eval("document.frm." + frm.nids[i].value);
                if(neededfrm.value == '0') {
                    alert(option_msg);
                    neededfrm.focus();
                    return false;
                }
            }

            // 2009-07-01 Ãß°¡ ¿É¼Ç ÇÊ¼ö °ª Ã¼Å©  - ±ÇÇõÃµ
            for (i=1;i<m_option_cnt;i++) {
                divstatus = document.getElementById('m_option_'+i).style.display;
                if (divstatus=='block') {
                    for (var j =0; j < optionInfo.multi_needed.length; j++) {
                        if (optionInfo.multi_needed[j]=='T') {
							if (optionInfo.type[j]=='selectbox') {
								neededfrm = document.getElementById('selectbox_'+i+'_'+(j+1));
								if (neededfrm.value == '0') {
									alert(option_msg);
									neededfrm.focus();
									return false;
								}
							}else{
								neededfrm = document.getElementById('inputbox_'+i+'_'+(j+1));
								if (neededfrm.value == '') {
									alert(option_msg);
									neededfrm.focus();
									return false;
								}
							}
                        }
                    }
                    if (chkQuantity(document.getElementById('quantity_'+i))==false) {
                        return false
                    }
                }
            }
        }
    } else {
		// 2009-07-01 Ãß°¡ ¿É¼Ç ÇÊ¼ö °ª Ã¼Å©  - ±ÇÇõÃµ
		for (i=1;i<m_option_cnt;i++) {
			divstatus = document.getElementById('m_option_'+i).style.display;
			if (divstatus=='block') {
				for (var j =0; j < optionInfo.multi_needed.length; j++) {
					if (optionInfo.multi_needed[j]=='T') {
						if (optionInfo.type[j]=='selectbox') {
							neededfrm = document.getElementById('selectbox_'+i+'_'+(j+1));
							if (neededfrm.value == '0') {
								alert(option_msg);
								neededfrm.focus();
								return false;
							}
						}else{
							neededfrm = document.getElementById('inputbox_'+i+'_'+(j+1));
							if (neededfrm.value == '') {
								alert(option_msg);
								neededfrm.focus();
								return false;
							}
						}
					}
				}
				if (chkQuantity(document.getElementById('quantity_'+i))==false) {
					return false
				}
			}
		}
	}

    // by jsyoon ¿É¼Ç¹®±¸ Å©±â Ã¼Å©


    // by ÀÌ°æ¶õ 2008-01-30
    // option_add Ã¼Å© ¼öÁ¤
    _optAddObj1 = frm['option_add'];

    if( typeof(_optAddObj1) == 'object') {

            if(typeof(_optAddObj1.length) == 'undefined'){
                var txtval = frm['add_option_name'].value;
                var bsize = 0;

                bsize = 255 - str_size_check(txtval) - 1;
                if(_optAddObj1.value == ''){
                    alert(option_msg);
                    _optAddObj1.focus();
                    return false;
                }

                if(!check_byte(_optAddObj1, bsize, "¿É¼Ç¹®±¸´Â ÇÑ±Û " + Math.floor(bsize / 2) + "ÀÚÀÌ³»·Î¸¸ ÀÔ·Â°¡´ÉÇÕ´Ï´Ù.")){
                    _optAddObj1.focus();
                    return false;
                }
        }else{
        _aTmp = frm['add_option_name'].value.split(";");

        for(i=0;i<_aTmp.length;i++) {
            _tmpObj = frm['option_add['+i+']'];

            if(typeof(_tmpObj) != 'undefined'){
                    var txtval = _aTmp[i];
                    var bsize = 0;

                    bsize = 255 - str_size_check(txtval) - 1;
                    if(!_tmpObj.value.length){
                        alert(option_msg);
                        _tmpObj.focus();
                        return false;
                    }

                    if(!check_byte(_tmpObj, bsize, "¿É¼Ç¹®±¸´Â ÇÑ±Û " + Math.floor(bsize / 2) + "ÀÚÀÌ³»·Î¸¸ ÀÔ·Â°¡´ÉÇÕ´Ï´Ù.")){
                        _tmpObj.focus();
                        return false;
                    }
                }
        }

        }
    } else {
        _aTmp = frm['add_option_name'].value.split(";");

        for(i=0;i<_aTmp.length;i++) {
            _tmpObj = frm['option_add['+i+']'];

            if(typeof(_tmpObj) != 'undefined'){
                    var txtval = _aTmp[i];
                    var bsize = 0;

                    bsize = 255 - str_size_check(txtval) - 1;
                    if(!_tmpObj.value.length){
                        alert(option_msg);
                        _tmpObj.focus();
                        return false;
                    }

                    if(!check_byte(_tmpObj, bsize, "¿É¼Ç¹®±¸´Â ÇÑ±Û " + Math.floor(bsize / 2) + "ÀÚÀÌ³»·Î¸¸ ÀÔ·Â°¡´ÉÇÕ´Ï´Ù.")){
                        _tmpObj.focus();
                        return false;
                    }
                }
        }
    }

    if (chkQuantity(frm.quantity)==false)
    {
        return false;
    }

    return true;
}

function chkQuantity(quantity) {
    if (!quantity.value)
    {
        alert ('¼ö·®À» ÀÔ·ÂÇØ ÁÖ½Ê½Ã¿À.');
        quantity.focus();
        return false;
    }

    for (i = 0; i < quantity.value.length; i++)
    {
        if (! (quantity.value.charAt(i) >= '0' && quantity.value.charAt(i) <= '9'))
        {
            alert ('¼ö·®Àº ¼ýÀÚ¸¸ °¡´ÉÇÕ´Ï´Ù.');
            quantity.select();
            return false;
        }
    }

    if (parseInt(quantity.value) < frm.product_min.value)
    {
        alert ('ÃÖ¼Ò ÁÖ¹®¼ö·®Àº ' + frm.product_min.value + ' ÀÔ´Ï´Ù.');
        quantity.select();
        return false;
    }
}
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" );
}

///2008-12-18 DOMÀ¸·Î ¼öÁ¤ -±è¿µÈÆ
function changeImage(img_url, width, height){
    // 2009-06-17 : ºñÇ¥ÁØÀ¸·Î µÇ¾î ÀÖ´ø °ÍÀ» ¼öÁ¤ - ¸Í ÁØ¿µ
    document.getElementsByName('big_img')[0].src        = img_url;
    document.getElementsByName('big_img')[0].width    = width;
    document.getElementsByName('big_img')[0].height    = height;
       return;
}

// »óÇ°ÀÇ º¹ÇÕÇü, Á¶ÇÕÇüº°·Î ¿É¼Ç ¾ÆÀÌµð¸¦ °¡Á®¿À´Â ÇÔ¼ö
// by jsyoon 05/11/17
function get_option_ids(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();
}

String.prototype.trim = function() {
    return this.replace(/^\s+|\s+$/g,"");
}

// 2009-06-30 ¿É¼ÇÃß°¡ ½ºÅ©¸³Æ® - ±Ç Çõ Ãµ
function makeOption () {
    try {
        if (optionInfo.id.length>0) {
            var multi_option_html = "";
            var html = '<div id="m_option_' + m_option_cnt + '" style="display:block;padding-top:10px;">';

            for (i=0; i<optionInfo.id.length; i++) {
                var baseTag = "";
                if (optionInfo.type[i]=='selectbox') {
                    var optionTag = "";
                    baseTag = document.getElementById('c_3_u4ms').value;
                    var f = document.getElementsByName(optionInfo.id[i])[0];
                    for (x=0; x<f.length; x++) {
                        optionTag +="<option value='" + f.options[x].value + "'> "+ f.options[x].text + "</option>";
                    }
                    baseTag = baseTag.replace(/\{\$multi_option_title\}/g, optionInfo.name[i]);
                    baseTag = baseTag.replace(/\{\$multi_selectbox_name\}/g, m_option_cnt + "_" + (i+1));
                    baseTag = baseTag.replace(/\{\$multi_selectbox_option\}/g, optionTag);

                } else {
                    baseTag = document.getElementById('c_3_u4mi').value;
                    baseTag = baseTag.replace(/\{\$multi_option_title\}/g, optionInfo.name[i]);
                    baseTag = baseTag.replace(/\{\$multi_inputbox_name\}/g, m_option_cnt + "_" + (i+1));
                }

                multi_option_html += baseTag;
            }

            var table = document.getElementById('c_3_u4mt').value;
            // selectbox,inputbox ¿É¼Ç ¼¼ÆÃ
            table = table.replace(/\{\$multi_option_html\}/g, multi_option_html);
            // ¼ö·® display À¯¹«
            var multi_quantity_display = (quantitybox=='text') ? 'block' : 'none';
            table = table.replace(/\{\$multi_quantity_display\}/g, multi_quantity_display);
            table = table.replace(/\{\$multi_quantitybox_type\}/g, quantitybox);
            if (quantitybox=='hidden')
                table = table.replace(/\{\$multi_quantitybox_cnt\}/g, '1');
            else
                table = table.replace(/\{\$multi_quantitybox_cnt\}/g, quantityboxCnt);
            table = table.replace(/\{\$multi_quantity_name\}/g, m_option_cnt);
            // »èÁ¦ ¹öÆ° div id µî·Ï
            table = table.replace(/\{\$multi_div_id\}/g, m_option_cnt);
            html += table + "</div>";

            document.getElementById('multiple').innerHTML += html;
            // Ãß°¡µÈ ¿É¼Çº° °¡°ÝÇÕ°è¸¦ À§ÇØ 0À¸·Î ¼¼ÆÃ
            optionTotal[m_option_cnt] = 0;
            m_option_cnt++;

            priceInnerHtml ();

            // ºÐ¸®¼± display = block
            document.getElementById('multiple_line').style.display = 'block';
        }
    } catch (e) {}
}

// 2009-07-01 ±Ý¾×°è»ê - ±Ç Çõ Ãµ
function priceInnerHtml () {
    // ¿É¼ÇÀÌ ÀÖÀ»¶§
    try
    {
        var price = 0;
        var basic_quantity = parseInt(document.frm.quantity.value.trim());
        var cnt = basic_quantity;

        // ¼±ÅÃµÈ ¿É¼Ç ±Ý¾× ÇÕ°è
        for (i=0; i<optionTotal.length; i++) {
            if (i==0) {
                price += optionTotal[i] * basic_quantity;
            } else {
                // Ãß°¡µÈ ¿É¼ÇÁß '»èÁ¦'ÇÏÁö ¾ÊÀº ¿É¼Ç °³¼ö ÆÄ¾Ç
                if (document.getElementById('m_option_' + i ).style.display == 'block'){
                    cnt += parseInt(document.getElementById('quantity_' + i ).value.trim());
                    price += optionTotal[i] * parseInt(document.getElementById('quantity_' + i ).value.trim());
                }
            }
        }

        if (isNaN(basic_quantity)==false && isNaN(cnt)==false)
        {
            // ÆÇ¸Å°¡ Ç¥½Ã
            base_price_html.innerHTML = number_format((base_price + optionTotal[0]) * basic_quantity) + price_unit;

            // ´ÙÁß ¿É¼Ç¼±ÅÃ ±â´É »ç¿ë½Ã ÇÏ´Ü 'ÃÑ »óÇ°±Ý¾×'
            if (option_multiple=='Y') {
                var base_price_sub_html = document.getElementById('main_price_sub');
                if (base_price_sub_html != null) {
                    base_price_sub_html.innerHTML = number_format((base_price * cnt) + price) + price_unit;
                }
            }
        }
    }
    catch (e) {}
}

// 2009-07-01 »èÁ¦½Ã ÃÊ±âÈ­( ·¹ÀÌ¾î, ±Ý¾×)
function optionDivControl (idx) {
    var divBlockCnt = 0;
    document.getElementById('m_option_' + idx ).style.display='none';

    // ºÐ¸®¼± display = none
    for (i=1;i<m_option_cnt;i++) {
        if (document.getElementById('m_option_' + i ).style.display == 'block') {
            divBlockCnt++;
            break;
        }
    }
    if (divBlockCnt==0) {
        document.getElementById('multiple_line').style.display = 'none';
    }

    // ¿É¼Ç Ãß°¡ ±Ý¾× ÃÊ±âÈ­
    optionTotal[idx] = 0;
    priceInnerHtml ();
}

// 2009-06-30 Ãß°¡µÈ ¿É¼Ç ¼±ÅÃ½Ã ' ÃÑ »óÇ°±Ý¾×/ÆÇ¸Å°¡ ' ¼öÁ¤ - ±Ç Çõ Ãµ
function optionMultiple(selectbox) {
    try {
        var ids = '';
        var price = 0;
        var tmp = selectbox.id.split('_');

        if(otype == 'T'){
            ids = multi_get_option_ids(selectbox);
            if(manage_stock != 'C' && optstock_table[ids] <= 0) {
                base_price_html.innerHTML = '<font color=red>Ç°Àý</font>';
                return;
            } else if(ids.length != 0) {
                price = optprice_table[ids];
            }
        }

        if(otype == 'F' || otype == 'E'){
            if(frm.opid.length == undefined){
                ids = multi_get_option_ids(selectbox);
                if(ids != '0-0-0' && otype == 'F')
                    price = optprice_table[ids];
                if(ids != '' && otype == 'E')
                    price = optprice_table[ids];
            } else {
                for(var i = 0; i < frm.opid.length; i++){
                    ids = multi_get_option_ids(document.getElementsByName('selectbox_'+tmp[1]+'_'+ (i+1))[0]);
                    if(ids != '0-0-0' && otype == 'F')
                        price += optprice_table[ids];
                    if(ids != '' && otype == 'E')
                        price += optprice_table[ids];
                }
            }
        }

        optionTotal[tmp[1]] = parseInt(price);

        //±Ý¾× Ç¥½Ã
        priceInnerHtml(price_unit);

    } catch (e) {};
}

function multi_get_option_ids(selectbox) {

    var retval = '';
    var tmpval;
    var tmp = selectbox.id.split('_');

    // Á¶ÇÕÇüÀÎ°æ¿ì
    if(otype == 'T') {
        if(frm.opid.length == undefined){
            tmpval = selectbox.options[selectbox.selectedIndex].value;
            if(tmpval == 0) return '';
            return  tmpval + "-0-0";
        }

        for(var i =0; i < 3; i++) {
            var selfrm = document.getElementsByName('selectbox_'+tmp[1]+'_'+ (i+1))[0];
            if(selfrm == undefined){
                    tmpval = 0;
            } else {
                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 == (tmp[2] - 1)) {
                tmpval = selectbox.options[selectbox.selectedIndex].value;
            } else {
                tmpval = 0;
            }
            if(i == 0)
                retval =+ tmpval;
            else
                retval = retval + "-" + tmpval;
        }
    } else if(otype == 'E'){
        tmpval = selectbox.options[selectbox.selectedIndex].value;
        if(tmpval == 0) return '';

        retval = tmp[2] + "-" + tmpval;
    }
    return retval;

}
function cyConnect(mallId,prdNo,cate_no,sid){

	var strUrl = "http://api.cyworld.com/openscrap/shopping/v1/?";
	//strUrl += "xu=" + escape("http://www2.1300k.com/shop/makeGoodsXml/makeGoodsXml.php?f_goodsno="+prdNo+"&cate_no="+cate_no);
	//strUrl += "&sid=s0200002";

	strUrl += "xu=" + escape("http://"+mallId+".cafe24.com/front/php/ghost_mall/makeCyworldPrdXml.php?product_no="+prdNo+"&cate_no="+cate_no+"&sid="+sid);
	strUrl += "&sid="+sid;

	var strOption = "width=450,height=410";

	var objWin = window.open(strUrl, 'cyopenscrap',  strOption);
	objWin.focus();

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

function nv_add_basket(arg)
{
    if(arg=="1"){
        if( check_frm('nv') ){
            document.frm.nv_hidden_flag.value = 'order';
            document.frm.action = "order_navercheckout_a.php";
            document.frm.submit();
        }
    } else {
        product_no = document.frm.product_no.value;
        window.open("basket_navercheckout_a.php?product_no="+product_no, "navercheckout_basket", 'scrollbars=yes,status=no,toolbar=no,width=450,height=300');
    }
}

function check_naverchk(arg) {
    if(arg=="A"){
        naverChk_soldout_flag = "T";
    }else{
        naverChk_soldout_flag = 'F';
    }
    set_display_naverchk();
}

function set_display_naverchk(){
    try {
        if(document.getElementById('NaverChk_Button') != null){

            if(naverChk_soldout_flag == 'F' || naverChk_dlv_flag == 'F'){
                document.getElementById('NaverChk_Button').style.display = "none";
            } else {
                document.getElementById('NaverChk_Button').style.display = "block";
            }
        }
    } catch (e) {}
}


//	¿É¼Ç°³º° °¡°Ý¿¬»ê ±èÁ¦Çö(JHKim01_3)(»ý¼º) 2010-01-28
function ass_get_option_ids(prod_no, type) {

	try
	{
		var key			=	"";
		var val			=	"";
		var op_price	=	"";
		var price		=	"";
		var totalPrice	=	"";
		var dom			=	"";
		var html		=	"";

		//	ÀúÀåµÈ¿É¼Ç
		if (type == "E") {

			dom	=	document.getElementById('option_'+ prod_no);
			key	=	dom.options[dom.selectedIndex].value;

			op_price	=	eval("ass_optprice_table_"+ prod_no +"['"+ key +"']");
			price		=	eval("ass_price_" + prod_no);
			if (typeof(op_price) != 'undefined' && typeof(price * 1) == 'number') {

				totalPrice	=	(op_price * 1) + (price * 1);
			}
			else if (typeof(price * 1) == 'number') {

				totalPrice	=	(price * 1);
			}
		}
		//	º¹ÇÕÇü
		else if (type == "F") {

			if(typeof(document.getElementsByName('option_'+ prod_no)[0]) != 'undefined') {

				dom	=	document.getElementsByName('option_'+ prod_no);

				val	=	dom[0].options[dom[0].selectedIndex].value;
				val	=	(val != '') ? val : '0';
				key	=	val + "-0-0";

				op_price	=	eval("ass_optprice_table_"+ prod_no +"['"+ key +"']");

				if (typeof(op_price) != 'undefined') {
					totalPrice	=	(totalPrice * 1) + (op_price * 1);
				}
			}
			else {

				dom	=	document.getElementsByName('option_'+ prod_no +'[]');

				for(var i = 0 ; i < dom.length ; i++) {

					val	=	dom[i].options[dom[i].selectedIndex].value;
					val	=	(val != '') ? val : '0';

					if (i == 0) {
							key	=	val + "-0-0";
					}
					else if (i == 1) {
							key	=	"0-" + val + "-0";
					}
					else if (i == 2) {
							key	=	"0-0-" + val;
					}

					op_price	=	eval("ass_optprice_table_"+ prod_no +"['"+ key +"']");

					if (typeof(op_price) != 'undefined') {
						totalPrice	=	(totalPrice * 1) + (op_price * 1);
					}
				}
			}

			price	=	eval("ass_price_" + prod_no) * 1;

			if (typeof(price) == 'number') {

				totalPrice	=	(totalPrice * 1) + (price * 1);
			}
		}
		//	Á¶ÇÕÇü
		else if (type == "T") {		

			if(typeof(document.getElementsByName('option_'+ prod_no)[0]) != 'undefined') {

				dom	=	document.getElementsByName('option_'+ prod_no);

				val	=	dom[0].options[dom[0].selectedIndex].value;
				val	=	(val != '') ? val : '0';
				key	=	val + "-0-0";
			}
			else {

				dom	=	document.getElementsByName('option_'+ prod_no +'[]');

				for(var i = 0 ; i < 3 ; i++) {

					if (typeof(dom[i]) != 'undefined') {

						val	=	dom[i].options[dom[i].selectedIndex].value;
						val	=	(val != '') ? val : '0';
					}
					else {

						val	=	'0';
					}

					if (i == 0) {
						key	+=	val;
					}
					else {
						key	+=	"-" + val;
					}
				}
			}

			op_price	=	eval("ass_optprice_table_"+ prod_no +"['"+ key +"']");
			price		=	eval("ass_price_" + prod_no);

			if (typeof(op_price) != 'undefined' && typeof(price * 1) == 'number') {

				totalPrice	=	(op_price * 1) + (price * 1);
			}
			else if (typeof(price * 1) == 'number') {

				totalPrice	=	(price * 1);
			}
		}

		html	=	product_price_design.replace("[price]", number_format(totalPrice));
		document.getElementById("opt_price_" + prod_no).innerHTML	=	html;
	}
	catch (e){}
}