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

	if (arg == 1 && typeof(document.frm['quantity_override_flag']) == 'object'){
		selectbuy_action();
		if(_bIsOverride){
			document.frm.quantity_override_flag.value ='T';
		}else{
			document.frm.quantity_override_flag.value ='F';
		}
	}

    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'];
    option_msg = '»óÇ°¿É¼ÇÀ» ÀÔ·ÂÇØÁÖ¼¼¿ä';
    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 price_one = 0;
        var basic_quantity = parseInt(document.frm.quantity.value.trim());
        //var cnt = basic_quantity;
        var cnt = 0;

        // ¼±ÅÃµÈ ¿É¼Ç ±Ý¾× ÇÕ°è
        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_one += optionTotal[i]; // syjung201005 : only option price
                }
            }
        }

        if (isNaN(basic_quantity)==false && isNaN(cnt)==false)
        {
            var aPrdtInfoCur = null;
            var aPrdtInfo = new Array();
            aPrdtInfo['iBaseCnt'] = basic_quantity;
            aPrdtInfo['iBaseOptPrice'] = optionTotal[0];
            aPrdtInfo['iAddCnt'] = cnt;
            aPrdtInfo['iAddOptPriceOne'] = price_one;
            aPrdtInfo['iAddOptPriceAll'] = price;
            // price buy
            aPrdtInfoCur = getPrdtInfo4Price(aPrdtInfo, 1);
            var iTemp = (_iPrdtPriceBuy + aPrdtInfoCur['iBaseOptPrice']) * aPrdtInfoCur['iBaseCnt'];
            setApplyHtml('main_price', number_format(iTemp) + price_unit);
            if (option_multiple == 'Y') setApplyHtml('main_price_sub', number_format((_iPrdtPriceBuy * aPrdtInfoCur['iAddCnt']) + aPrdtInfoCur['iAddOptPrice'] + iTemp));
            // price custom
            aPrdtInfoCur = getPrdtInfo4Price(aPrdtInfo, 2);
            setApplyHtml('spnViewPriceCustom', number_format((_iPrdtPriceCustom + aPrdtInfoCur['iBaseOptPrice']) * aPrdtInfoCur['iBaseCnt']));
            // price org
            aPrdtInfoCur = getPrdtInfo4Price(aPrdtInfo, 4);
            var iTemp = (_iPrdtPriceBuy + aPrdtInfoCur['iBaseOptPrice']) * aPrdtInfoCur['iBaseCnt'];
            var iTemp2 = iTemp * (100 / (100 + _iPrdtTaxPercent));
            iTemp2 = Math.round(iTemp2);
            setApplyHtml('spnViewPriceOrg', number_format(iTemp2));
            // price tax
            aPrdtInfoCur = getPrdtInfo4Price(aPrdtInfo, 8);
            var iTemp = (_iPrdtPriceBuy + aPrdtInfoCur['iBaseOptPrice']) * aPrdtInfoCur['iBaseCnt'];
            var iTemp2 = iTemp * (100 / (100 + _iPrdtTaxPercent));
            iTemp2 = Math.round(iTemp2);
            setApplyHtml('spnViewPriceTax', number_format(iTemp - iTemp2));
            // price mile
            aPrdtInfoCur = getPrdtInfo4Price(aPrdtInfo, 16);
            var iTemp = _iPrdtPriceBuy;
            setApplyHtml('spnViewPriceMile', number_format(getMileNew('cm', iTemp) * aPrdtInfoCur['iBaseCnt']));
            setApplyHtml('spnViewPriceMile_cash', number_format(getMileNew('cash', iTemp) * aPrdtInfoCur['iBaseCnt']));
            setApplyHtml('spnViewPriceMile_card', number_format(getMileNew('card', iTemp) * aPrdtInfoCur['iBaseCnt']));
            setApplyHtml('spnViewPriceMile_tcash', number_format(getMileNew('tcash', iTemp) * aPrdtInfoCur['iBaseCnt']));
            setApplyHtml('spnViewPriceMile_cell', number_format(getMileNew('cell', iTemp) * aPrdtInfoCur['iBaseCnt']));
            setApplyHtml('spnViewPriceMile_mileage', number_format(getMileNew('mileage', iTemp) * aPrdtInfoCur['iBaseCnt']));
            /* syjung201005 : because of cron proc
            var iTemp = _iPrdtPriceBuy * aPrdtInfoCur['iBaseCnt'];
            setApplyHtml('spnViewPriceMile', number_format(getMileNew('cm', iTemp)));
            setApplyHtml('spnViewPriceMile_cash', number_format(getMileNew('cash', iTemp)));
            setApplyHtml('spnViewPriceMile_card', number_format(getMileNew('card', iTemp)));
            setApplyHtml('spnViewPriceMile_tcash', number_format(getMileNew('tcash', iTemp)));
            setApplyHtml('spnViewPriceMile_cell', number_format(getMileNew('cell', iTemp)));
            setApplyHtml('spnViewPriceMile_mileage', number_format(getMileNew('mileage', iTemp)));
            */
        }
    }
    catch (e) {}
}
function getMileNew( sPayType, iPriceBase )
{
    var iUnit = _aMallDesignConf.default_set_mileage ;
    var sRountType = _aMallDesignConf.set_mileage_type ;
    var aConf = _aPrdtMileConf[sPayType];
    if ( !aConf ) return 0 ;
    var iPercent = 0 ;
    if ( aConf.mileage_type == 'P' ) {
        iPercent = parseInt( aConf.mileage_value ) ;
    } else {
        return parseInt( aConf.mileage_value ) ;
    }
    var iTemp = parseInt( iPriceBase ) * iPercent / 100 ;
    if ( !iUnit ) parseInt( iTemp ) ;
    iFormatUnit = parseInt( iUnit ) * 10 ;
    if ( sRountType == 'A' ) {
        iTemp = Math.floor( iTemp / iFormatUnit ) * iFormatUnit ;
    } else if ( sRountType == 'B' ) {
        iTemp = Math.round( iTemp / iFormatUnit ) * iFormatUnit ;
    } else if ( sRountType == 'C' ) {
        iTemp = Math.ceil( iTemp / iFormatUnit ) * iFormatUnit ;
    }
    return iTemp ;
}
function getPrdtInfo4Price(aPrdtInfo, iConfFactor)
{
    var iOptFactorG = parseInt(_aMallDesignConf['md_price_view_type_po_factor']);
    var iCntFactorG = parseInt(_aMallDesignConf['md_price_view_type_pc_factor']);
    var sOptFlag = _aMallDesignConf['md_price_view_type_po_flag'];
    var sCntFlag = _aMallDesignConf['md_price_view_type_pc_flag'];
    var aRet = new Array();
    aRet['iBaseCnt'] = (sCntFlag == 'T' && (iCntFactorG & iConfFactor)) ? parseInt(aPrdtInfo['iBaseCnt']) : 1;
    aRet['iBaseOptPrice'] = (sOptFlag == 'T' && (iOptFactorG & iConfFactor)) ? parseInt(aPrdtInfo['iBaseOptPrice']) : 0;
    if (aPrdtInfo['iAddCnt'] > 0) {
        aRet['iAddCnt'] = (sCntFlag == 'T' && (iCntFactorG & iConfFactor)) ? parseInt(aPrdtInfo['iAddCnt']) : 1;
        if (aRet['iAddCnt'] == 1) {
            aRet['iAddOptPrice'] = (sOptFlag == 'T' && (iOptFactorG & iConfFactor)) ? parseInt(aPrdtInfo['iAddOptPriceOne']) : 0;
        } else {
            aRet['iAddOptPrice'] = (sOptFlag == 'T' && (iOptFactorG & iConfFactor)) ? parseInt(aPrdtInfo['iAddOptPriceAll']) : 0;
        }
    } else {
        aRet['iAddCnt'] = 0;
        aRet['iAddOptPrice'] = 0;
    }
    return aRet;
}
function setApplyHtml( sID, sHtml )
{
    //try {
        var hObj = document.getElementById( sID );
        if (hObj) {
            document.getElementById( sID ).innerHTML = sHtml ;
        }
    //} catch (e) {}
}
function applyPriceViewType()
{
    var hSpnViewPriceCustom = document.getElementById('spnViewPriceCustom');
    var hSpnViewPriceOrg = document.getElementById('spnViewPriceOrg');
    var hSpnViewPriceTax = document.getElementById('spnViewPriceTax');
    var hSpnViewPriceMile = document.getElementById('spnViewPriceMile');
}

// 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' &&  ids != '0-0-0' && otype == 'F') // syjung201005 : ???
                        price += optprice_table[ids];
                    if(ids != '' && otype == 'E')
                        price += optprice_table[ids];
                }
            }
        }

        optionTotal[tmp[1]] = parseInt(price) ? parseInt(price) : 0;

        //±Ý¾× Ç¥½Ã
        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) {}
}


// by ÇÑÁ¤¿ì
// ÀçÀÔ°í ¾Ë¸² SMS  ¿äÃ» Ã¢À» ¶ç¿î´Ù.
function sms_restock_popup(){
	if(check_frm()){
		var f = document.frm;
		window_open( '/front/php/sms_restock.php', 'sms_restock' ,200, 100, 459, 490 );
	}
}

//	¿É¼Ç°³º° °¡°Ý¿¬»ê ±èÁ¦Çö(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){}
}

//ÁÖ¹®¼ö·® Áõ°¨¹öÆ°. 2010-05-12. ¼­³ª¸®
function quantityChg(id, flag) {
	var obj = document.getElementById(id);
	if (!isNumber(obj.value)) {
		alert('¼ýÀÚÇü½ÄÀÇ µ¥ÀÌÅÍ¸¸ °¡´ÉÇÕ´Ï´Ù.');
		return false;

	} else {
		var tmp = parseInt(obj.value);
		if (flag=='up') {//Áõ°¡
			obj.value = tmp + 1;

		} else if (flag=='down') {//°¨¼Ò
			if (tmp>quantityboxCnt) obj.value = tmp - 1; //ÃÖ¼Ò¼ö·®±îÁö¸¸.
		}
	}
	return true;
}

//¼ýÀÚ¿©ºÎ Ã¼Å©. 2010-05-12. ¼­³ª¸®
function isNumber(num) {
	return (/^[0-9]+$/).test(num);
}

//	Á¶È¸¼öÁõ°¡
function view_cnt(board_no, no, id)
{
	try
	{
		if (!document.getElementById('ifrm_board_cnt')) {

			var iframe = document.createElement("iframe"); 

			iframe.setAttribute("width", "0px");
			iframe.setAttribute("height", "0px");
			iframe.setAttribute("id", "ifrm_board_cnt");

			document.getElementsByTagName('body')[0].appendChild(iframe); 
		}

		show_id = document.all[id]

		if( show_id.style.display == 'block' ) {
			document.getElementById('ifrm_board_cnt').src	=	'/front/php/iframe_hit.php?board_no='+ board_no +'&no='+ no;
		}
	}
	catch (e) {}
}

// krlee2 Ãß°¡
function comment_submit_check( form, used_name )
{
    form.target="_blank'";
    var max_length = 14;
    var comment = get_string_trim(form.comment.value);
    var comment_name = get_string_trim(form.comment_name.value);
    form.comment.value = comment;

    if (form.bbs_name_authed.value == 'F') {
        window.open('/front/php/b/pop_name_auth.php','bbs_name_auth','width=420,height=562');
        return false;
    }

    if(used_name == 'block')
    {
        form.comment_name.value = get_string_trim(form.comment_name.value);
        form.comment_passwd.value = get_string_trim(form.comment_passwd.value);

        var size1 = get_string_length(form.comment_name.value);
        var size2 = get_string_length(form.comment_passwd.value);
        if(size1 > 100) {
            alert('ÀÌ¸§À» 100byteÀÌÇÏ·Î ÀÔ·ÂÇÏ¼¼¿ä');
            form.comment_name.focus();
            return false;
        } else if (size2 > 16) {
            alert('ºñ¹Ð¹øÈ£¸¦ 16byteÀÌÇÏ·Î ÀÔ·ÂÇÏ¼¼¿ä');
            form.comment_passwd.focus();
            return false;
        }

        if(form.comment_name.value == '') {
            alert('ÀÌ¸§À» ÀÔ·ÂÇÏ¼¼¿ä');
            form.comment_name.focus();
            return false;
        }

        if(form.comment_passwd.value == '') {
            alert('ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä');
            form.comment_passwd.focus();
            return false;
        }

        if(form.comment.value == '') {
            alert('³»¿ëÀ» ÀÔ·ÂÇÏ¼¼¿ä');
            form.comment.focus();
            return false;
        }

        // 2009-05-19 : ÀÎÁõÅ° Ã¼Å© Ãß°¡ - cmc_jymaeng
        try {
            if(form.captcha.value == '') {
                if (document.getElementById("captcha_img").style.display == 'block') {
                    alert('ÀÎÁõÅ°¸¦ ÀÔ·ÂÇÏ¼¼¿ä.');
                    form.captcha.focus();
                    return false;
                }
            }
        } catch (e) {}
    }

    json_init(form,"add");
    return false;
}

function json_init(form,mode) {

    if(mode=="add") {
        var captcha = "";
        var obj_list = form.comment_point;
        var comment_point = 0 ;

        for ( var cnt = 0, len = obj_list.length ; cnt < len ; cnt++ )
        {
            if ( obj_list[cnt].checked && !obj_list[cnt].disabled )
            comment_point = obj_list[cnt].value ;
        }

        // 2009-05-19 : ÀÎÁõÅ° Ã¼Å© Ãß°¡ - cmc_jymaeng
        try {
            if (form.captcha_name.value == 'ub') var captcha = "&captcha_ub="+form.captcha_ub.value;
            else if  (form.captcha_name.value == 'qna')  var captcha ="&captcha_qna="+form.captcha_qna.value;
            else if  (form.captcha_name.value == 'free')  var captcha ="&captcha_free="+form.captcha_free.value;

        } catch (e) {}
            // syjung200907
            parma_str = "&mode=comment_add&board_no="+form.board_no.value+"&comment_name="+form.comment_name.value+"&comment_passwd="+form.comment_passwd.value+"&comment="+encodeURIComponent(form.comment.value)+"&no="+form.no.value+captcha+"&comment_point="+comment_point+"&captcha_name="+form.captcha_name.value;
            sendRequest(json_comment_insert, parma_str,'POST', '/front/php/b/board_write_a_new.php', true, true);
    }
        else if(mode=="del") {
    }
}

function json_comment_insert(oj) {
	if ( !oj || !oj.responseText ) return ; // syjung200907
    eval("var res = " + oj.responseText);

    var bbsno = 'div_comment_list_'+res.Static[7].comment_bbs_no;
    var captcha_img_name = 'captcha_img_'+res.Static[12].comment_captcha_name+'_'+res.Static[7].comment_bbs_no;
    var cbyte_span_name = 'cbyte_span'+res.Static[12].comment_captcha_name+'_'+res.Static[7].comment_bbs_no;
    comment_tpl = document.getElementsByName('div_comment_tpl')[0].value;

	// 2009-05-19 : ºñÇ¥ÁØÀ¸·Î µ¿ÀÛÇÏ´ø ºÎºÐ ¼öÁ¤ - cmc_jymaeng
	var cmt = document.getElementsByName('comment');

	if (res.Static[0].error) {
		if (res.Static[0].error) alert(res.Static[0].error);
		return ; // syjung200907
        document.location.reload();
	} else {
		comment_tpl = comment_tpl.replace(/\[ajax_comment_no\]/g,res.Static[0].comment_no);
		comment_tpl = comment_tpl.replace("[ajax_comment_name]",res.Static[1].comment_name);
		comment_tpl = comment_tpl.replace("[ajax_comment]",res.Static[4].comment_comment);
		comment_tpl = comment_tpl.replace("[ajax_comment_member_id]",res.Static[2].comment_member_id);
		comment_tpl = comment_tpl.replace("[ajax_comment_write_date]",res.Static[3].comment_write_date);
		comment_tpl = comment_tpl.replace("[ajax_comment_point_html]",res.Static[6].comment_point_html);

		if(document.getElementById(captcha_img_name)){
			document.getElementById(captcha_img_name).src = res.Static[5].comment_captcha;
		}

		document.getElementsByName('comment')[0].value="";

		ret_comment_tpl = comment_tpl;
		ret_comment_tpl = document.getElementById(bbsno).innerHTML+ret_comment_tpl;
		document.getElementById(bbsno).innerHTML=ret_comment_tpl;

	   // syjung200907
	   var obj_cmt_size_msg = document.getElementById( cbyte_span_name ) ;
	   if ( obj_cmt_size_msg ) obj_cmt_size_msg.innerHTML = '0' ;
		try {
			if(document.getElementById('blog_ck').value=="T") {
				self.resizeTo(document.body.scrollWidth, document.body.scrollHeight);
			}
		} catch (e) {}
    }

}

function get_string_trim( string )
{
    return string.replace(/(^\s*)|(\s*$)/g, "");
}

function str_limit_check( obj, max_len, cmt_name, cmt_no )
{

	var comment = obj.value;

	// syjung200907
	if ( max_len == 0 ) return ;
	if ( !max_len ) max_len = 200;
	if ( !cmt_no ) cmt_no = '' ;

  var cbyte_span_name = 'cbyte_span_' +cmt_name+'_'+cmt_no ;

	var obj_cmt_size_msg = document.getElementById( cbyte_span_name ) ;
	content_length = get_string_length( comment );

	if ( obj_cmt_size_msg ) obj_cmt_size_msg.innerHTML = content_length;

	if( content_length > max_len )
	{
		msg = '¸Þ½ÃÁö´Â ' + max_len + ' Byte ÀÌÇÏ·Î ÀÔ·ÂÇØÁÖ¼¼¿ä.';
		alert( msg );
		obj.value = substring_k(comment, max_len);

		if ( obj_cmt_size_msg ) document.getElementById(cbyte_span_name ).innerHTML = max_len;

	}
}

function get_string_length( string )
{
    var count = 0;

    var tmp_str = new String(string);
    var temp = tmp_str.length;

    var onechar;

    for ( k=0; k<temp; k++ )
    {
        onechar = tmp_str.charAt(k);

        if (escape(onechar).length > 4)
        {
            count += 2;
        }
        else
        {
            count += 1;
        }
    }

    return count;
}

var _bIsOverride = false;
//¼±ÅÃµÈ »óÇ°¸¸ ÁÖ¹®ÇÏ±â
function selectbuy_action() {
	var hFrm = document.frm;
	var sParams = '';
	var sTemp = '';
	var hTemp = '';
	if(typeof(frm['option_type']) == 'object' && typeof(frm['product_no']) == 'object') {
		sParams += '&mode=check_same_product';
		sParams += '&option_type='+hFrm.option_type.value;
		sParams += '&product_no='+hFrm.product_no.value;
		sParams += '&basket_type='+hFrm.basket_type.value;
		
		for( var i=1; i<13; i++){
			hTemp = hFrm['option'+i];
			if (hTemp){
				sTemp = hFrm['option'+i].value;
			}else{
				sTemp ='';
			}
			
			sParams += '&option'+i+'='+sTemp;;
		}
		//try {
			sendRequest( send_selectbuy, sParams, 'POST', 'basket_ajax.php', false, true ) ;
		//}catch(e){
		//}
	}

}
function send_selectbuy(oj){

	if (!oj) return;
	if (!oj.responseText) return; 

    try{
        eval( 'var aResData =' + oj.responseText );
    }catch(e){
        return;
    }
    	
	if (!aResData) return;
	if (aResData.sRetCode == 'MASK_SUCCESS') {
		if (!aResData.aData) return;
		if (aResData.aData.nexturl2) {
			var sUrl = aResData.aData.nexturl2 + '?redirect_url=' + aResData.aData.nexturl + '&basket_type=' + aResData.aData.basket_type;
		} else {
			var sUrl = aResData.aData.nexturl + '?basket_type=' + aResData.aData.basket_type;
		}
		if (sUrl) {
			document.location.href = sUrl;
		}
	} else if (aResData.sRetCode == 'PRODUCT_EXIST') {
		var iPrdtCnt= aResData.aData.iPrdtCnt;
		if (!confirm("µ¿ÀÏ»óÇ°ÀÌ Àå¹Ù±¸´Ï¿¡ " + iPrdtCnt +"°³ ÀÖ½À´Ï´Ù.\nÇÔ²² ±¸¸ÅÇÏ½Ã°Ú½À´Ï±î?")){
			_bIsOverride = true;
		}else{
			_bIsOverride = false;
		}

	}
	return;
}