var product_required_options_index=1;
var product_add_options_index=1;
var commerce_action="";
var order_cancel_popup="";
var move_check=false;
var commerce_price_type=2;
var commerce_currency1="$";
var currency_number1=2;
var commerce_currency2="원";
var currency_number2=0;
function addCart(pid,param){
if(checkProductOptions()){
commerce_action="add_cart";
if(typeof(param)=='undefined'||param==null)	param="";
sendCommerceData(commerce_action,pid,param);
}}
function addCheckout(type, pid, count, param){
if(mb_options["use_guest_order"]=="0"&&!mb_is_login){
alert("로그인이 필요한 기능입니다 (로그인 페이지로 이동합니다)");
moveURL(mb_urls["login"]);
return;
}
if(type!="direct"||checkProductOptions()){
if(typeof(param)=='undefined'||param==null)	param="";
var board_pid="";
var check_count=0;
commerce_action="cart_checkout";
if(typeof(count)!=='undefined'&&count!="") param=param+"&order_count="+count;
if(typeof(pid)!=='undefined'&&pid!=""){
board_pid=pid;
}
if(type=="one"){
check_count=1;
}else if(type=="direct"){
commerce_action="direct_checkout";
check_count=1;
}else{
if(type=="all"){
jQuery("input:checkbox", jQuery("#tbl_board_list")).prop("checked", true);
}
check_count=jQuery("input[name='check_array[]']").filter(":checked").length;
}
if(check_count>0){
if(type=="one"||type=="select"){
if(type=="one"){
jQuery("input:checkbox", jQuery("#tbl_board_list")).prop("checked", false);
jQuery("table td input:checkbox[value='"+pid+"']").prop("checked", true);
}
var productTarget;
jQuery("table td input[name='check_array[]']").each(function(index){
productTarget=jQuery(this).closest("tr");
if(jQuery(this).is(":checked")){
productTarget.find('input[type="hidden"]').prop("disabled", false);
}else{
productTarget.find('input[type="hidden"]').prop("disabled", true);
}}
);
}
sendCommerceData(commerce_action,board_pid,param);
}else{
showAlertPopup({"code":"1000","message":"주문할 상품을 선택해 주세요"});
}}
}
function addCheckout_direct(pid,param){
if(typeof(param)=='undefined'||param==null)	param="";
addCheckout("direct", pid, "", param);
}
function addWishlist(pid,param){
if(!mb_is_login){
showConfirmPopup("로그인이 필요한 기능입니다<br>로그인 페이지로 이동하시겠습니까?", {}, function(){
moveURL(mb_urls["login"]);
});
}else{
if(typeof(param)=='undefined'||param==null)	param="";
commerce_action="add_wishlist";
sendCommerceData(commerce_action,pid,param);
}}
function checkProductListOptions(pid){
showConfirmPopup("옵션선택이 있는 상품입니다.<br>상품 옵션을 선택해 주세요.", {}, function(){
moveURL("./?vid="+pid);
});
}
function checkProductOptions(){
var message="";
if(jQuery("input[name='order_count']").length>0&&isNaN(jQuery("input[name='order_count']").val())){
message="주문수량을 입력해 주세요";
alert(message);
return false;
}
if(jQuery("input[name='order_options1']").length>0&&jQuery("input[name='order_options1']").val()==""){
message=jQuery("input[name='order_options1']").parent().prev().text()+"을 입력해 주세요";
alert(message);
jQuery("input[name='order_options1']").focus();
return false;
}
if(jQuery("input[name='order_options2']").length>0&&jQuery("input[name='order_options2']").val()==""){
message=jQuery("input[name='order_options2']").parent().prev().text()+"을 입력해 주세요";
alert(message);
jQuery("input[name='order_options2']").focus();
return false;
}
if(jQuery("input[name='order_options3']").length>0&&jQuery("input[name='order_options3']").val()==""){
message=jQuery("input[name='order_options3']").parent().prev().text()+"을 입력해 주세요";
alert(message);
jQuery("input[name='order_options3']").focus();
return false;
}
if(jQuery("#use_product_options").val()=="0")
return true;
if(jQuery("select[name='product_required_options_select[]']").length>0&&jQuery("input[name='product_required_options[]']").length==0){
if(jQuery("select[name='product_required_options_select2[]']").length>0&&jQuery("input[name='product_required_options2[]']").length==0){
alert("옵션을 선택 또는 입력해 주세요");
return false;
}else if(jQuery("select[name='product_required_options_select2[]']").length==0){
alert("옵션을 선택 또는 입력해 주세요");
return false;
}}
if(jQuery("select[name='product_required_options_select2[]']").length>0&&jQuery("input[name='product_required_options2[]']").length==0){
if(jQuery("select[name='product_required_options_select[]']").length>0&&jQuery("input[name='product_required_options[]']").length==0){
alert("옵션을 선택 또는 입력해 주세요");
return false;
}else if(jQuery("select[name='product_required_options_select[]']").length==0){
alert("옵션을 선택 또는 입력해 주세요");
return false;
}}
return true;
}
function addCartMove(pid){
commerce_action="add_cart";
move_check=true;
sendCommerceData(commerce_action,pid);
}
function showCommerceDeleteConfirm(type, pid){
showConfirmPopup("삭제하시겠습니까?", {}, function(){
var data="mode=cart&board_action=delete&board_name="+mb_options["board_name"]+"&board_pid="+pid;
sendDataRequest(mb_urls["board_api"], data, sendCartDeleteHandler);
});
}
function sendCartDeleteHandler(response, state){
if(response&&response.state=="success"){
moveURL("reload");
}else{
showAlertPopup(response);
}}
function selectCartProduct(){
var sale_price=0;
var regular_price=0;
var options_price=0;
var discount=0;
var shipping_cost=0;
var max_shipping_cost=0;
var shipping_check=false;
var product_type="";
var productTarget;
var input_count=1;
jQuery("input[name='check_array[]']").each(function(index){
if(jQuery(this).is(":checked")){
productTarget=jQuery(this).closest("tr");
if(jQuery(".mc-order-count-modify",productTarget).length>0){
input_count=parseInt(jQuery(".mc-order-count-modify",productTarget).val());
if(input_count==0){
input_count=1;
}}else{
input_count=1;
}
product_type=jQuery("input[name='product_type_array[]']",productTarget).val();
if(product_type.indexOf('shipping')==0) shipping_check=true;
options_price=(parseFloat(jQuery("input[name='o_options_price_array[]']",productTarget).val()));
sale_price=sale_price+(parseFloat(jQuery("input[name='o_sale_price_array[]']",productTarget).val())*input_count)+options_price;
regular_price=regular_price+(parseFloat(jQuery("input[name='o_regular_price_array[]']",productTarget).val())*input_count)+options_price;
s_cost=parseFloat(jQuery("input[name='shipping_cost_array[]']",productTarget).val());
shipping_cost=shipping_cost+s_cost;
if(max_shipping_cost<s_cost) max_shipping_cost=s_cost;
}}
);
discount=regular_price - sale_price;
if(mb_options["commerce_item_type"]=="all"&&!shipping_check){
shipping_cost=0;
}else if(parseFloat(mb_options["free_shipping_order"])!=0&&parseFloat(mb_options["free_shipping_order"])<=sale_price){
shipping_cost=0;
}else if(mb_options["commerce_item_type"]=="virtual"||mb_options["commerce_item_type"]=="file"||mb_options["commerce_item_type"]=="video"){
shipping_cost=0;
}else if(mb_options["commerce_item_type"]=="all"||mb_options["commerce_item_type"]=="shop"){
shipping_cost=parseFloat(mb_options["shipping_cost"]);
if(max_shipping_cost>shipping_cost) 		shipping_cost=max_shipping_cost;
}
if(commerce_price_type==2){
jQuery("#billing_regular_price1").html(jQuery.number(regular_price,currency_number2)+commerce_currency2);
jQuery("#billing_discount1").html(jQuery.number(discount,currency_number2)+commerce_currency2);
jQuery("#billing_order_price1").html(jQuery.number(sale_price,currency_number2)+commerce_currency2);
jQuery("#billing_regular_price2").html(jQuery.number(regular_price,currency_number2)+commerce_currency2);
jQuery("#billing_shipping_cost2").html(jQuery.number(shipping_cost,currency_number2)+commerce_currency2);
jQuery("#billing_discount2").html(jQuery.number(discount,currency_number2)+commerce_currency2);
jQuery("#billing_order_price2").html(jQuery.number((sale_price+shipping_cost),currency_number2)+commerce_currency2);
}else{
jQuery("#billing_regular_price1").html(commerce_currency1+jQuery.number(regular_price,currency_number1));
jQuery("#billing_discount1").html(commerce_currency1+jQuery.number(discount,currency_number1));
jQuery("#billing_order_price1").html(commerce_currency1+jQuery.number(sale_price,currency_number1));
jQuery("#billing_regular_price2").html(commerce_currency1+jQuery.number(regular_price,currency_number1));
jQuery("#billing_shipping_cost2").html(commerce_currency1+jQuery.number(shipping_cost,currency_number1));
jQuery("#billing_discount2").html(commerce_currency1+jQuery.number(discount,currency_number1));
jQuery("#billing_order_price2").html(commerce_currency1+jQuery.number((sale_price+shipping_cost),currency_number1));
}
if(!shipping_check){
jQuery("#cart_order_box1").show();
jQuery("#cart_order_box2").hide();
}else{
jQuery("#cart_order_box1").hide();
jQuery("#cart_order_box2").show();
}}
function selectSalesTableProduct(){
var sale_price=0;
var order_price=0;
var shipping_cost=0;
jQuery("input[name='check_array[]']").each(function(index){
if(jQuery(this).is(":checked")){
sale_price=sale_price+parseFloat(jQuery("input[name='sale_price_array[]']").get(index).value);
order_price=order_price+parseFloat(jQuery("input[name='order_price_array[]']").get(index).value);
shipping_cost=shipping_cost+parseFloat(jQuery("input[name='shipping_cost_array[]']").get(index).value);
}}
);
if(commerce_price_type==2){
jQuery("#st_sale_price").html(jQuery.number(sale_price,currency_number2)+commerce_currency2);
jQuery("#st_shipping_cost").html(jQuery.number(shipping_cost,currency_number2)+commerce_currency2);
jQuery("#st_selling_price").html(jQuery.number(order_price,currency_number2)+commerce_currency2);
}else{
jQuery("#st_sale_price").html(commerce_currency1+jQuery.number(sale_price,currency_number1));
jQuery("#st_shipping_cost").html(commerce_currency1+jQuery.number(shipping_cost,currency_number1));
jQuery("#st_selling_price").html(commerce_currency1+jQuery.number(order_price,currency_number1));
}}
function sendCommerceData(action,pid,param,callback){
var sendCallback;
if(typeof(callback)==='undefined') sendCallback=sendCommerceDataHandler;
else if(typeof(callback)==='function') sendCallback=callback;
var board_pid="";
if(typeof(pid)!=='undefined'&&pid!="") board_pid=pid;
else board_pid=mb_options["pid"];
var data=jQuery('#'+mb_options["board_name"]+'_form_board_'+mb_options["mode"]).serialize();
data=data+"&board_name="+mb_options["board_name"]+"&board_pid="+board_pid+"&mode=commerce&board_action="+action;
if(typeof(param)!=='undefined'&&param!="") data=data+"&"+param;
sendDataRequest(mb_urls["commerce_api"], data, sendCallback);
}
function sendCommerceOrderState(pid,order,state,callback){
var sendCallback;
if(typeof(callback)==='undefined') sendCallback=sendCommerceDataHandler;
else if(typeof(callback)==='function') sendCallback=callback;
order_cancel_popup="";
var msg="변경하시겠습니까?";
var text1='';
var text2='신청하기';
if(order=="cancelled_order"){
text1="주문 취소";
msg="주문을 취소하시겠습니까?";
}else if(order=="return_request"){
if(order==state){
text1="반품 신청";
msg="반품을 신청하시겠습니까?";
}else msg="반품신청을 취소하시겠습니까?";
}else if(order=="exchange_request"){
if(order==state){
text1="교환 신청";
msg="교환을 신청하시겠습니까?";
}else msg="교환신청을 취소하시겠습니까?";
}else if(order=="refund_request"){
if(order==state){
text1="환불 신청";
msg="환불을 신청하시겠습니까?";
}else msg="환불신청을 취소하시겠습니까?";
}
var cancel_reason_option=jQuery(".mb-board input[name='cancel_reason_"+pid+"']").val();
if(text1!=""&&typeof(cancel_reason_option)!=='undefined'&&cancel_reason_option!=''){
order_cancel_popup=text1;
var pop_body='<div class="mb-order-cancel-popup" style="padding:0px 0px 16px;width:100%;width:300px;background-color:#FFF;;">';
pop_body		+='<div class="mb-commerce-pop" style="position:relative;margin-bottom:13px;"><div class="pop-title-head" style="font-size: 16px !important;padding: 9px 0 9px;border-bottom: 1px solid #999;background-color: #525252;color: #FFF;font-weight: 600 !important;">'+text1+'</div></div>';
pop_body		+='<div style="padding:5px 0px 5px;width:250px;margin:0 auto;">';
pop_body		+='<div style="padding-bottom:3px; font-size:15px;font-weight:600;line-height:1.4;text-align:left;">1. '+text1+' 이유를 선택해 주세요</div>';
pop_body		+='<div style="text-align:left;line-height:2.1 !important;padding-left:1px;">';
var cancel_array=cancel_reason_option.split(",");
for(i=0;i<cancel_array.length;i++){
pop_body		+='<div><label for="mb_myorder_cancel'+(i+1)+'" style="font-size:14px !important;"><input type="radio" name="mb_myorder_cancel_reason" style="width:16px !important;height:16px !important;" id="mb_myorder_cancel'+(i+1)+'" value="'+cancel_array[i]+'"> '+cancel_array[i]+'</label></div>';
}
pop_body		+='<div><label for="mb_myorder_cancel_etc" style="font-size:14px !important;"><input type="radio" name="mb_myorder_cancel_reason" style="width:16px !important;height:16px !important;" id="mb_myorder_cancel_etc" value="기타"> 기타</label> <input style="width:150px;" name="mb_myorder_cancel_text" id="mb_myorder_cancel_text" title="" value="" type="text" onclick="document.getElementById(\'mb_myorder_cancel_etc\').checked=true;return false;"></div>';
pop_body		+='</div>';
if(order=="return_request"||order=="refund_request"){
var pay_method=jQuery(".mb-board input[name='pay_method_"+pid+"']").val();
var pay_state=jQuery(".mb-board input[name='pay_state_"+pid+"']").val();
if((pay_method=="bank"||pay_method=="v_bank")&&pay_state=="complete"){
pop_body		+='<div class="" style="padding-top:18px;">';
pop_body		+='<div style="padding-bottom:3px; font-size:15px;font-weight:600;line-height:1.4;text-align:left;">2. 환불 계좌번호</div>';
pop_body		+='<textarea style="width:100%;height:60px;"  name="mb_myorder_bank_account" id="mb_myorder_bank_account" placeholder="환불 받으실 계좌번호를 입력해 주세요"></textarea>';
pop_body		+='</div>';
}}
pop_body		+='<div class="btn-box-center" style="padding-top:24px;">';
pop_body		+='<a href="javascript:;" id="mb_pop_confirm_cancel" onclick="hidePopupBox()" class="btn btn-default btn-cancel margin-right-10"><span>취소하기</span></a>';
pop_body		+='<a href="javascript:;" id="mb_pop_confirm_ok" onclick="sendCommerceModifyStateData(\''+pid+'\',\''+order+'\',\''+state+'\')" class="btn btn-default btn-ok"><span>'+text2+'</span></a>';
pop_body		+='</div>';
pop_body		+='</div>';
pop_body		+='</div>';
showPopupBox("Html", '',pop_body);
}else{
if(confirm(msg)){
sendCommerceModifyStateData(pid,order,state,sendCallback);
}}
}
function sendCommerceModifyStateData(pid,order,state,callback){
var sendCallback;
if(typeof(callback)==='undefined') sendCallback=sendCommerceDataHandler;
else if(typeof(callback)==='function') sendCallback=callback;
if(typeof(pid)==='undefined'&&pid!="") return;
commerce_action="modify_order_state";
var cancel_reason="";
if(jQuery(".mb-order-cancel-popup input[name='mb_myorder_cancel_reason']").length>0){
cancel_reason=jQuery(".mb-order-cancel-popup input[name='mb_myorder_cancel_reason']:checked").val();
if(typeof(cancel_reason)==='undefined'||cancel_reason==''){
alert("신청 이유를 선택해주세요");
return;
}else{
if(cancel_reason=='기타'){
cancel_reason=jQuery(".mb-order-cancel-popup input[name='mb_myorder_cancel_text']").val();
}
if(typeof(cancel_reason)==='undefined'||cancel_reason==''){
alert("신청 이유를 입력해주세요");
return;
}}
if(jQuery(".mb-order-cancel-popup #mb_myorder_bank_account").length>0){
var bank_account=jQuery(".mb-order-cancel-popup #mb_myorder_bank_account").val();
if(bank_account!=''){
if(cancel_reason!=undefined&&cancel_reason!=''){
cancel_reason	+=":"+bank_account;
}else{
cancel_reason=bank_account;
}}else{
alert("환불 받으실 계좌번호를 입력해 주세요");
return;
}}
}
var data="board_name="+mb_options["board_name"]+"&board_pid="+pid+"&mode=commerce&board_action="+commerce_action+"&order_state="+state+"&cancel_reason="+encodeURIComponent(cancel_reason);
if(!mb_is_login){
if(jQuery("input[name='order_password']").length>0){
data		+='&order_pw='+encodeURIComponent(jQuery("input[name='order_password']").val());
}else if(jQuery("#order_password").length>0){
data		+='&order_pw='+encodeURIComponent(jQuery("#order_password").val());
}}
sendDataRequest(mb_urls["commerce_api"], data, sendCallback);
}
function sendCommerceOrderConfirm(pid,order,product_pid,callback){
var sendCallback;
if(typeof(callback)==='undefined') sendCallback=sendCommerceDataHandler;
else if(typeof(callback)==='function') sendCallback=callback;
var msg="변경하시겠습니까?";
if(order=="order_confirm"){
msg="구매를 확정하시겠습니까?";
commerce_action="order_confirm_modify";
}else if(order=="order_confirm_request"){
msg="구매확정을 요청하시겠습니까??";
commerce_action="order_confirm_request";
}else if(order=="order_confirm_pending"){
msg="구매확정을 보류하시겠습니까??";
commerce_action="order_confirm_pending";
}
if(confirm(msg)){
if(typeof(pid)==='undefined'&&pid!="") return;
var data="board_name="+mb_options["board_name"]+"&board_pid="+pid+"&mode=commerce&board_action="+commerce_action;
if(!mb_is_login&&jQuery("input[name='order_password']").length>0){
data		+='&order_pw='+jQuery("input[name='order_password']").val();
}
sendDataRequest(mb_urls["commerce_api"], data, sendCallback);
}}
function setCartCountInput(pid, type, name, obj){
if(typeof(type)==='undefined') type="";
var target=jQuery("input[name='"+name+"']");
var count=target.val().replace(/[^0-9]/g,"");
if(count==""||count=="0") count=1;
count=parseInt(count);
if(type=="plus"){
target.val(count+1);
}else if(type=="minus"){
if(count>1){
target.val(count-1);
}}else{
if(typeof(obj)!=='undefined'){
count=jQuery(obj).val().replace(/[^0-9]/g,"");
if(count==""||count=="0") count=1;
target.val(count);
}}
count=target.val().replace(/[^0-9]/g,"");
if(count==""||parseInt(count)<=0){
target.val(1);
count=1;
}
var productTarget=jQuery(target).closest("tr");
var input_count=parseInt(jQuery(".mc-order-count-modify",productTarget).val());
var options_price=(parseFloat(jQuery("input[name='o_options_price_array[]']",productTarget).val()));
var sale_price=(parseFloat(jQuery("input[name='o_sale_price_array[]']",productTarget).val())*input_count)+options_price;
var regular_price=(parseFloat(jQuery("input[name='o_regular_price_array[]']",productTarget).val())*input_count)+options_price;
jQuery(".mc-regular-price .mb-number",productTarget).html(jQuery.number(regular_price,currency_number2));
jQuery(".mc-sale-price .mb-number",productTarget).html(jQuery.number(sale_price,currency_number2));
selectCartProduct();
var data="mode=list&board_action=multi_modify_cart2&board_name=commerce_cart&cart_pid="+pid+"&count="+count;
sendDataRequest2(mb_urls["commerce_api"], data, sendCartCountInputHandler);
}
function sendCartCountInputHandler(response, state){
if(response.state=="success"){
if(typeof(response.message)!=='undefined'&&response.message!=""){
alert(response.message);
}}else{
showAlertPopup(response);
}}
function checkCartOrderCount(args){
jQuery(".mc-order-count-modify").each(function(index){
if(this.value==""||parseInt(this.value)<=0){
jQuery(this).val(1);
}}
);
jQuery('#'+mb_options["board_name"]+'_form_board_list input[name=board_pid]').val(args.board_pid);
jQuery('#'+mb_options["board_name"]+'_form_board_list input[name=board_action]').val(args.board_action);
sendFormDataRequest(jQuery('#'+mb_options["board_name"]+'_form_board_list'), mb_urls["commerce_api"], sendBoardListDataHandler);
}
function setCommerceCartItemCount(count){
jQuery(".mb-product-cart-count .mb-number").text(count);
}
function sendCommerceDataHandler(response, state){
if(response&&response.state=="success"){
if(typeof(response.message)!=='undefined'&&response.message!="")
alert(response.message);
if(commerce_action=="direct_checkout"||commerce_action=="cart_checkout"){
moveURL(mb_urls["commerce_billing"]);
}else if(commerce_action=="modify_order_state"){
if(order_cancel_popup!=""){
alert("신청하신 내용이 정상적으로 접수되었습니다");
}
moveURL("reload");
}else if(commerce_action=="modify_order_confirm"){
moveURL("reload");
}else if(commerce_action=="order_confirm_modify"||commerce_action=="order_confirm_request"||commerce_action=="order_confirm_pending"){
moveURL("reload");
}else if(commerce_action=="add_cart"){
if(move_check){
moveURL(mb_urls["commerce_cart"]);
}else{
if(typeof(response.data)!=='undefined'){
if(typeof(response.data.item_count)!=='undefined'&&response.data.item_count!=""){
setCommerceCartItemCount(response.data.item_count);
}
if(typeof(sendConversionTracking)==='function'){
sendConversionTracking("add_to_cart", response.data);
}}
showConfirmPopup("장바구니에 담겼습니다<br>지금 확인하시겠습니까?", {}, function(){
moveURL(mb_urls["commerce_cart"]);
});
}}else if(commerce_action=="add_wishlist"){
if(typeof(response.data)!=='undefined'){
if(typeof(sendConversionTracking)==='function'){
sendConversionTracking("add_to_wishlist", response.data);
}}
showConfirmPopup("위시리스트에 담겼습니다<br>지금 확인하시겠습니까?", {}, function(){
moveURL(mb_urls["commerce_wishlist"]);
});
}else if(commerce_action.indexOf('use_coupon')==0||commerce_action=="create_coupon"||commerce_action=="delete_coupon"){
moveURL("reload");
}}else{
showAlertPopup(response);
}
move_check=false
}
function checkAddShipping(obj){
if(jQuery(obj).is(":checked")){
jQuery("#shipping_cost").val(parseFloat(jQuery("#shipping_cost").val())+parseFloat(jQuery("#add_shipping_cost").val()));
}else{
jQuery("#shipping_cost").val(parseFloat(jQuery("#shipping_cost").val())-parseFloat(jQuery("#add_shipping_cost").val()));
}
checkBillingPrice('shipping');
}
function setOrderCheckboxAll(){
if(jQuery("#order_check_all").is(":checked")){
jQuery(":checkbox", jQuery(".mc-billing-pay-check-box")).prop("checked", true);
}else{
jQuery(":checkbox", jQuery(".mc-billing-pay-check-box")).prop("checked", false);
}}
function checkMaxInputValue(obj,max){
if(typeof(max)!=='undefined'){
if(max<parseInt(jQuery(obj).val())){
jQuery(obj).val(max);
}}
}
function checkMaxPoint(obj,max){
var order_price=parseFloat(jQuery("#order_price").val());
var use_point=parseFloat(jQuery("#use_point").val());
if(use_point>0){
order_price=order_price+use_point;
}
var coupon_discount=parseFloat(jQuery("#coupon_discount").val());
if(coupon_discount!=0){
if(max>coupon_discount){
max=max-coupon_discount;
}}
if(typeof(max)!=='undefined'){
if(max<parseInt(jQuery(obj).val())){
jQuery(obj).val(max);
}}
}
function useOrderPoint(min,max,type){
var input_point=0;
if(jQuery("#input_point").val()!=""){
input_point=parseFloat(jQuery("#input_point").val());
}
var order_price=parseFloat(jQuery("#order_price").val());
var use_point=parseFloat(jQuery("#use_point").val());
if(use_point>0){
order_price=order_price+use_point;
}
var coupon_discount=parseFloat(jQuery("#coupon_discount").val());
if(coupon_discount!=0){
if(max>coupon_discount){
max=max-coupon_discount;
}}
if(type==2){
if(jQuery("input[name='use_max_point']").is(":checked")) input_point=max;
else input_point=0;
}else{
if(max<input_point) input_point=max;
}
jQuery("#input_point").val(input_point);
if(input_point==""){
input_point=0;
jQuery("#input_point").val(input_point);
}
if(input_point!=0&&input_point<min){
alert("최소 "+ min+"P 이상이 되어야 사용이 가능합니다");
jQuery("#input_point").val("0");
}else{
jQuery("#use_point").val(parseFloat(input_point));
checkBillingPrice('point');
}}
var checkCouponPrice=0;
function useDiscountCoupon(obj,value){
var coupon_discount=value;
var order_price=parseFloat(jQuery("#order_price").val());
var check_price=order_price+checkCouponPrice;
if(coupon_discount>check_price){
coupon_discount=check_price;
}
jQuery("#coupon_discount").val(coupon_discount);
checkBillingPrice('coupon');
checkCouponPrice=value;
}
function checkBillingPrice(type){
if(type!='coupon'){
jQuery("#coupon_discount").val(checkCouponPrice);
}
var o_price=(parseInt(parseFloat(jQuery("#regular_price").val())*100)-parseInt(parseFloat(jQuery("#discount").val())*100)-parseInt(parseFloat(jQuery("#use_point").val())*100)-parseInt(parseFloat(jQuery("#coupon_discount").val())*100)+parseInt(parseFloat(jQuery("#shipping_cost").val())*100))/100;
jQuery("#order_price").val(o_price);
var regular_price1=jQuery("#regular_price").val();
var order_price1=jQuery("#order_price").val();
var discount1=parseFloat(jQuery("#discount").val())+parseFloat(jQuery("#use_point").val())+parseFloat(jQuery("#coupon_discount").val());
var shipping_cost1=jQuery("#shipping_cost").val();
if(commerce_price_type==2){
jQuery("#billing_regular_price").html(jQuery.number(regular_price1,currency_number2)+commerce_currency2);
jQuery("#billing_order_price").html(jQuery.number(order_price1,currency_number2)+commerce_currency2);
jQuery("#billing_discount").html(jQuery.number(discount1,currency_number2)+commerce_currency2);
jQuery("#billing_shipping_cost").html(jQuery.number(shipping_cost1,currency_number2)+commerce_currency2);
jQuery("#billing_regular_price2").html(jQuery.number(regular_price1,currency_number2)+commerce_currency2);
jQuery("#billing_order_price2").html(jQuery.number(order_price1,currency_number2)+commerce_currency2);
jQuery("#billing_discount2").html(jQuery.number(discount1,currency_number2)+commerce_currency2);
jQuery("#billing_shipping_cost2").html(jQuery.number(shipping_cost1,currency_number2)+commerce_currency2);
}else{
jQuery("#billing_regular_price").html(commerce_currency1+' '+jQuery.number(regular_price1,currency_number1));
jQuery("#billing_order_price").html(commerce_currency1+jQuery.number(order_price1,currency_number1));
jQuery("#billing_discount").html(commerce_currency1+jQuery.number(discount1,currency_number1));
jQuery("#billing_shipping_cost").html(commerce_currency1+jQuery.number(shipping_cost1,currency_number1));
jQuery("#billing_regular_price2").html(commerce_currency1+' '+jQuery.number(regular_price1,currency_number1));
jQuery("#billing_order_price2").html(commerce_currency1+jQuery.number(order_price1,currency_number1));
jQuery("#billing_discount2").html(commerce_currency1+jQuery.number(discount1,currency_number1));
jQuery("#billing_shipping_cost2").html(commerce_currency1+jQuery.number(shipping_cost1,currency_number1));
}}
function useOrderMoney(min,max){
var input_money=0;
if(typeof(max)!=='undefined'){
if(jQuery("input[name='use_max_money']").is(":checked")) input_money=max;
else input_money=0;
jQuery("#input_money").val(input_money);
}else{
input_money=parseFloat(jQuery("#input_money").val());
}
if(input_money==""){
input_money=0;
jQuery("#input_money").val(input_money);
}
if(input_money!=0&&input_money<min){
alert("최소 "+ min+"원 이상이 되어야 사용이 가능합니다");
}else{
jQuery("#use_money").val(parseFloat(input_money));
checkBillingPrice('money');
}}
function sendOrderData(obj){
var data=jQuery('#commerce_order_form').serialize();
if(typeof(obj)=='object') data=data+"&"+jQuery(obj).serialize();
data=data+"&mode=commerce";
sendDataRequest(mb_urls["commerce_api"], data, sendOrderDataHandler);
}
function sendOrderDataHandler(response, state){
if(response&&response.state=="success"){
var msg='주문이 완료되었습니다';
if(typeof(response.data)!=='undefined'&&typeof(response.data.pay_state)!=='undefined'&&response.data.pay_state=="complete"){
msg='결제가 완료되었습니다';
}
showAlertPopup({"code":"1000","message":msg},function(){
moveURL(mb_urls["commerce_order_result"]);
});
}else{
closeOrderStep();
showAlertPopup(response);
}}
function sendOrderData2(){
var data=jQuery('#commerce_order_form').serialize();
sendDataRequest(mb_urls["commerce_api"], data, sendOrderData2Handler);
}
function sendOrderData2Handler(response, state){
if(response&&response.state=="success"){
moveURL(mb_urls["commerce_order_result"]);
}else{
showAlertPopup(response);
}}
function getSellerMenu(uid,pid){
var menu_options="*";
if(select_menu==uid+"_"+pid){
select_menu="";
hideInfoBox();
}else{
sendSellerMenu(uid,menu_options,event);
select_menu=uid+"_"+pid;
}}
function showSellerMenu(data){
var menu_head=data["head"];
var menu_body="";
var menu_foot=data["foot"];
menu_head=menu_head+'<div class="pop-info-head">'+data["user"]["name"]+'</div>';
menu_body='<ul class="pop-info-body list-unstyled">';
if(data["body"].length>0){
jQuery.each(data["body"], function(key,value){
menu_body=menu_body+'<li>'+value+'</li>';
});
menu_body=menu_body+'</ul>';
showPopupBox("Info","",('<div class="pop-user-menu">'+menu_head+menu_body+menu_foot+'</div>'),{"position":"click","bg":false,"eventX":eventX,"eventY":eventY});
}}
function sendSellerMenu(uid,option,event){
if(typeof(event)!=='undefined'){
eventX=event.clientX;
eventY=event.clientY;
}
if(option=="*") option="search,info,email,homepage,blog";
var param="mode=commerce&board_action=menu&board_name="+mb_options["board_name"]+"&pid="+uid+"&option="+option+"&list_type="+mb_options["list_type"]+"&page="+mb_options["page"];
if(jQuery('#'+mb_options["board_name"]+'_form_board_search')) param=param+"&"+jQuery('#'+mb_options["board_name"]+'_form_board_search').serialize();
sendDataRequest(mb_urls["commerce_api"], param, sendSellerMenuHandler);
}
function sendSellerMenuHandler(response, state){
if(response&&response.state=="success"){
showSellerMenu(response.data);
}else{
showAlertPopup(response);
}}
function sendCommerceExcelData(fields,titles,param){
var data="mode=commerce&board_action=table_data&board_name="+mb_options["board_name"]+"&fields="+encodeURIComponent(fields)+"&titles="+encodeURIComponent(titles)+"&list_type="+mb_options["list_type"]+"&page="+mb_options["page"];
if(typeof(param)!=='undefined'&&param!="") data=data+"&"+param;
if(jQuery("input[name='check_array[]']").filter(":checked").length>0){
var select_pid=jQuery("input[name='check_array[]']").filter(":checked").map(function(){return jQuery(this).val();}).get().join(",");
data=data+"&select_pid="+select_pid;
}else{
if(jQuery('#'+mb_options["board_name"]+'_form_board_search')) data=data+"&"+jQuery('#'+mb_options["board_name"]+'_form_board_search').serialize();
}
sendDataRequest(mb_urls["commerce_api"], data, sendCommerceExcelDataHandler);
}
function sendCommerceExcelDataHandler(response, state){
if(response&&response.state=="success"){
var date=new Date();
today_date=date.getFullYear()+""+(date.getMonth()+1).to2()+""+(date.getDate()).to2();
var sendForm=document.createElement('form');
sendForm.method='post';
sendForm.action=mb_urls["home"]+"/?mb_trigger=file";
var h1=document.createElement('input');
h1.type='hidden';h1.name='file_name';h1.value=mb_options["board_name"]+"_"+today_date+'.xls';
sendForm.appendChild(h1);
var h2=document.createElement('input');
h2.type='hidden';h2.name='file_content';h2.value=response.data;
sendForm.appendChild(h2);
var h3=document.createElement('input');
h3.type='hidden';h3.name='file_type';h3.value="application/vnd.ms-excel";
sendForm.appendChild(h3);
document.body.appendChild(sendForm);
sendForm.submit();
}else{
showAlertPopup(response);
}}
function selectCommerceProductRequiredOption(){
var option_text=new Array();
var option_value=new Array();
var option_price_sum=0;
var check_option=true;
jQuery("select[name='product_required_options_select[]']").each(function(index){
if(jQuery(this).val()==""){ check_option=false;return false;	}
option_value=jQuery(this).val().split("||");
if(option_value[0]) option_text.push(option_value[0]);
if(option_value[1]) option_price_sum=option_price_sum+parseFloat(option_value[1]);
});
if(!check_option) return;
var select_text=option_text.join(" / ");
var is_exist=false;
jQuery("input[name='product_required_options[]']").each(function(index){
if(jQuery(this).val()==select_text+"||"+option_price_sum){
var count=parseInt(jQuery("input[name='product_required_options_count[]']").eq(index).val());
is_exist=true;
jQuery("input[name='product_required_options_count[]']").eq(index).val(count+1);
}});
if(!is_exist){
var input_id="product_required_options"+product_required_options_index;
var option_price_text="";
if(commerce_price_type==2){
option_price_text=jQuery.number((parseFloat(jQuery("#product_sale_price").val())+option_price_sum),currency_number2)+commerce_currency2;
}else{
option_price_text=commerce_currency1+jQuery.number((parseFloat(jQuery("#product_sale_price").val())+option_price_sum),currency_number1);
}
jQuery("#mb_commerce_product_order_list").append('<tr><td class="mb-td-item1">'+select_text+'<input type="hidden" name="product_required_options[]" value="'+select_text.split('"').join("&quot;")+"||"+option_price_sum+'" /></td><td class="mb-td-item2"><div><a onclick="setOrderCountInput(\'minus\',\''+input_id+'\');return false;" title="minus"><span class="mb-btn-minus mb-minus-style1"></a><input type="text" class="mc-order-count-input" id="'+input_id+'" maxlength="3" onkeydown="return inputOnlyNumber(event)" onkeyup="setCommerceProductOptionPrice();" name="product_required_options_count[]" value="1" style="vertical-align: top !important;"/><a onclick="setOrderCountInput(\'plus\',\''+input_id+'\');return false;" title="plus"><span class="mb-btn-plus mb-plus-style1"></span></a></div></td><td class="mb-td-item3" style="text-align:right;padding-left:0px !important;"><span class="mc-required-option-price">+ '+option_price_text+'</span></td><td class="mb-td-item4" style="text-align:center;"><a onclick="deleteCommerceProductOption(this)" title="delete" role="button"><img  src="'+mb_urls["commerce_base"]+'images/icon_close.gif"/></a></td></tr>');
product_required_options_index++;
}
setCommerceProductOptionPrice();
}
function setOrderCountInput(type, id){
if(typeof(type)==='undefined') type="";
var target=jQuery("#"+id);
var count=target.val().replace(/[^0-9]/g,"");
if(count==""||count=="0") count=1;
count=parseInt(count);
if(type=="plus"){
target.val(count+1);
}else if(type=="minus"){
if(count>1){
target.val(count-1);
}}else{
target.val(count);
}
setCommerceProductOptionPrice();
}
function setOrderCountInput2(type, name, obj){
if(typeof(type)==='undefined') type="";
var target=jQuery("input[name='"+name+"']");
var count=target.val().replace(/[^0-9]/g,"");
if(count==""||count=="0") count=1;
count=parseInt(count);
if(type=="plus"){
target.val(count+1);
}else if(type=="minus"){
if(count>1){
target.val(count-1);
}}else{
if(typeof(obj)!=='undefined'){
count=jQuery(obj).val().replace(/[^0-9]/g,"");
if(count==""||count=="0") count="1";
target.val(count);
}}
}
function setOrderCountInputM(type, id){
if(typeof(type)==='undefined') type="";
var target=jQuery("#"+id);
var count=target.val().replace(/[^0-9]/g,"");
if(count==""||count=="0") count=1;
count=parseInt(count);
if(type=="plus"){
target.val(count+1);
}else if(type=="minus"){
if(count>1){
target.val(count-1);
}}else{
target.val(count);
}
setCommerceProductOptionPriceM();
}
function getCommercePriceFormat(price,type){
var price_text="";
if(commerce_price_type==2){
if(price>0){
price_text=" (+"+jQuery.number(price,currency_number2)+commerce_currency2+")";
}else{
price_text=" ("+jQuery.number(price,currency_number2)+commerce_currency2+")";
}}else{
if(price>0){
price_text=" (+"+commerce_currency1+jQuery.number(price,currency_number1)+")";
}else{
price_text=" ("+commerce_currency1+jQuery.number(price,currency_number1)+")";
}}
return price_text;
}
function changeCommerceProductRequiredOption(obj, idx){
var option_values=jQuery("#order_option_values1").val();
var option_prices=jQuery("#order_option_prices1").val();
var value_array=new Array();
var price_array=new Array(0);
var option_value=new Array();
var option_price=new Array(0);
if(option_values==undefined||option_values=="") return;
value_array=option_values.split("||");
price_array=option_prices.split("||");
var index=jQuery(obj).prop('selectedIndex')-1;
var i=0;
if(typeof(value_array[index])!=='undefined') option_value=value_array[index].split(",");
else option_value=value_array[value_array.length-1].split(",");
if(typeof(price_array[index])!=='undefined') option_price=price_array[index].split(",");
var value="";
var price=0;
var price_text="";
var select_option='<option value="">'+jQuery("select[name='product_required_options_select[]']").eq(idx+1).find("option").eq(0).html()+'</option>';
for(i;i<option_value.length;i++){
if(typeof(option_value[i])!=='undefined') value=option_value[i];
if(typeof(option_price[i])!=='undefined'&&option_price[i]!=""&&option_price[i]!="0"){
price=parseFloat(option_price[i]);
price_text=getCommercePriceFormat(price,'option');
}else{
price=0;
price_text="";
}
select_option		+='<option value="'+value.split('"').join("&quot;")+"||"+price+'">'+value+price_text+'</option>';
}
jQuery("select[name='product_required_options_select[]']").eq(idx+1).html(select_option);
}
function selectCommerceProductAddOption(obj){
var option_text=new Array();
var option_value=new Array();
var option_price_sum=0;
if(jQuery(obj).val()=="") return;
option_value=jQuery(obj).val().split("||");
if(option_value[0]) option_text.push(option_value[0]);
if(option_value[1]) option_price_sum=option_price_sum+parseFloat(option_value[1]);
var select_text=option_text.join(" / ");
var is_exist=false;
jQuery("input[name='product_add_options[]']").each(function(index){
if(jQuery(this).val()==select_text+"||"+option_price_sum){
var count=parseInt(jQuery("input[name='product_add_options_count[]']").eq(index).val());
is_exist=true;
jQuery("input[name='product_add_options_count[]']").eq(index).val(count+1);
}});
if(!is_exist){
var input_id="product_add_options"+product_add_options_index;
var option_price_text="";
if(commerce_price_type==2){
option_price_text=jQuery.number(option_price_sum,currency_number2)+commerce_currency2;
}else{
option_price_text=commerce_currency1+jQuery.number(option_price_sum,currency_number1);
}
jQuery("#mb_commerce_product_order_list").append('<tr><td class="mb-td-item1">'+select_text+'<input type="hidden" name="product_add_options[]" value="'+select_text+"||"+option_price_sum+'" /></td><td class="mb-td-item2"><div><a onclick="setOrderCountInput(\'minus\',\''+input_id+'\');return false;" title="minus"><span class="mb-btn-minus mb-minus-style1"></a><input type="text" class="mc-order-count-input" id="'+input_id+'" maxlength="3" onkeydown="return inputOnlyNumber(event)" onkeyup="setCommerceProductOptionPrice();" name="product_add_options_count[]" value="1" style="vertical-align: top !important;"/><a onclick="setOrderCountInput(\'plus\',\''+input_id+'\');return false;" title="plus"><span class="mb-btn-plus mb-plus-style1"></span></a></div></td><td class="mb-td-item3" style="text-align:right;"><span class="mc-add-option-price">+ '+option_price_text+'</span></td><td class="mb-td-item4" style="text-align:center;"><a onclick="deleteCommerceProductOption(this)" title="delete" role="button"><img  src="'+mb_urls["commerce_base"]+'images/icon_close.gif"/></a></td></tr>');
product_add_options_index++;
}
setCommerceProductOptionPrice();
}
function changeCommerceProductRequiredOption2(obj, idx){
var selectedIndex=0;
var oData=mb_commerce_op2;
var checkSelect=true;
var select_option='<option value="">'+jQuery("select[name='product_required_options_select[]']").eq(idx+1).find("option").eq(0).html()+'</option>';
jQuery("select[name='product_required_options_select[]']").each(function(index){
if(idx>=index){
selectedIndex=jQuery(this).prop('selectedIndex');
if(selectedIndex==0){
checkSelect=false;
return false;
}
if(oData[selectedIndex-1]["children"]!==undefined){
oData=oData[selectedIndex-1]["children"]
}else{
oData=[];
}}else{
var option_text2=jQuery(this).find('option').first().text();
if(option_text2=="") option_text2="선택해 주세요(필수)";
jQuery(this).html('<option value="">'+option_text2+'</option>');
}});
if(!checkSelect) return false;
var value="";
var count=0;
var price=0;
var price_text="";
if(oData.length!=0){
for (var item in oData){
if(oData[item]["option_name"]!==undefined) value=oData[item]["option_name"];
if(oData[item]["option_add_price"]!==undefined&&oData[item]["option_add_price"]!="0"){
price=parseFloat(oData[item]["option_add_price"]);
price_text=getCommercePriceFormat(price,'option');
}else{
price=0;
price_text="";
}
if(oData[item]["id"]!==undefined) option_id=oData[item]["id"];
else option_id="";
if(oData[item]["option_is_use"]===undefined||oData[item]["option_is_use"]!="OFF"){
if(oData[item]["option_count"]!==undefined) count=parseInt(oData[item]["option_count"]);
else count=0;
if(count==0){
select_option		+='<option disabled value="'+value.split('"').join("&quot;")+"||"+price+"||"+option_id+'">'+value+price_text+' [품절]</option>';
}else{
select_option		+='<option value="'+value.split('"').join("&quot;")+"||"+price+"||"+option_id+'">'+value+price_text+'</option>';
}}
}
jQuery("select[name='product_required_options_select[]']").eq(idx+1).show();
jQuery("select[name='product_required_options_select[]']").eq(idx+1).html(select_option);
}else{
jQuery("select[name='product_required_options_select[]']").slice(idx+1).hide();
var option_text=new Array();
var option_value=new Array();
var option_id="";
var option_price_sum=0;
var check_option=true;
jQuery("select[name='product_required_options_select[]']").each(function(index){
option_value=jQuery(this).val().split("||");
if(option_value[0]) option_text.push(option_value[0]);
if(option_value[1]) option_price_sum=option_price_sum+parseFloat(option_value[1]);
if(option_value[2]) option_id=option_value[2];
});
if(!check_option) return;
var select_text=option_text.join(" / ");
var is_exist=false;
jQuery("input[name='product_required_options[]']").each(function(index){
if(jQuery(this).val()==select_text+"||"+option_price_sum+"||"+option_id){
var count=parseInt(jQuery("input[name='product_required_options_count[]']").eq(index).val());
is_exist=true;
jQuery("input[name='product_required_options_count[]']").eq(index).val(count+1);
}});
if(!is_exist){
var input_id="product_required_options"+product_required_options_index;
var option_price_text="";
if(commerce_price_type==2){
option_price_text=jQuery.number((parseFloat(jQuery("#product_sale_price").val())+option_price_sum),currency_number2)+commerce_currency2;
}else{
option_price_text=commerce_currency1+jQuery.number((parseFloat(jQuery("#product_sale_price").val())+option_price_sum),currency_number1);
}
jQuery("#mb_commerce_product_order_list").append('<tr><td class="mb-td-item1">'+select_text+'<input type="hidden" name="product_required_options[]" value="'+select_text.split('"').join("&quot;")+"||"+option_price_sum+"||"+option_id+'" /></td><td class="mb-td-item2"><div><a onclick="setOrderCountInput(\'minus\',\''+input_id+'\');return false;" title="minus"><span class="mb-btn-minus mb-minus-style1"></a><input type="text" class="mc-order-count-input" id="'+input_id+'" maxlength="3" onkeydown="return inputOnlyNumber(event)" onkeyup="setCommerceProductOptionPrice();" name="product_required_options_count[]" value="1" style="vertical-align: top !important;"/><a onclick="setOrderCountInput(\'plus\',\''+input_id+'\');return false;" title="plus"><span class="mb-btn-plus mb-plus-style1"></span></a></div></td><td class="mb-td-item3" style="text-align:right;padding-left:0px !important;"><span class="mc-required-option-price">+ '+option_price_text+'</span></td><td class="mb-td-item4" style="text-align:center;"><a onclick="deleteCommerceProductOption(this)" title="delete" role="button"><img  src="'+mb_urls["commerce_base"]+'images/icon_close.gif"/></a></td></tr>');
product_required_options_index++;
}
setCommerceProductOptionPrice();
}}
function changeCommerceProductRequiredOptionM2(obj, idx){
var selectedIndex=0;
var oData=mb_commerce_op2;
var checkSelect=true;
var select_option='<option value="">'+jQuery("select[name='product_required_options_select2[]']").eq(idx+1).find("option").eq(0).html()+'</option>';
jQuery("select[name='product_required_options_select2[]']").each(function(index){
if(idx>=index){
selectedIndex=jQuery(this).prop('selectedIndex');
if(selectedIndex==0){
checkSelect=false;
return false;
}
if(oData[selectedIndex-1]["children"]!==undefined){
oData=oData[selectedIndex-1]["children"]
}else{
oData=[];
}}else{
var option_text2=jQuery(this).find('option').first().text();
if(option_text2=="") option_text2="선택해 주세요(필수)";
jQuery(this).html('<option value="">'+option_text2+'</option>');
}});
if(!checkSelect) return false;
var value="";
var count=0;
var price=0;
var price_text="";
if(oData.length!=0){
for (var item in oData){
if(oData[item]["option_name"]!==undefined) value=oData[item]["option_name"];
if(oData[item]["option_add_price"]!==undefined&&oData[item]["option_add_price"]!="0"){
price=parseFloat(oData[item]["option_add_price"]);
price_text=getCommercePriceFormat(price,'option');
}else{
price=0;
price_text="";
}
if(oData[item]["id"]!==undefined) option_id=oData[item]["id"];
else option_id="";
if(oData[item]["option_is_use"]===undefined||oData[item]["option_is_use"]!="OFF"){
if(oData[item]["option_count"]!==undefined) count=parseInt(oData[item]["option_count"]);
else count=0;
if(count==0){
select_option		+='<option disabled value="'+value.split('"').join("&quot;")+"||"+price+"||"+option_id+'">'+value+price_text+' [품절]</option>';
}else{
select_option		+='<option value="'+value.split('"').join("&quot;")+"||"+price+"||"+option_id+'">'+value+price_text+'</option>';
}}
}
jQuery("select[name='product_required_options_select2[]']").eq(idx+1).show();
jQuery("select[name='product_required_options_select2[]']").eq(idx+1).html(select_option);
}else{
jQuery("select[name='product_required_options_select2[]']").slice(idx+1).hide();
var option_text=new Array();
var option_value=new Array();
var option_id="";
var option_price_sum=0;
var check_option=true;
jQuery("select[name='product_required_options_select2[]']").each(function(index){
option_value=jQuery(this).val().split("||");
if(option_value[0]) option_text.push(option_value[0]);
if(option_value[1]) option_price_sum=option_price_sum+parseFloat(option_value[1]);
if(option_value[2]) option_id=option_value[2];
});
if(!check_option) return;
var select_text=option_text.join(" / ");
var is_exist=false;
jQuery("input[name='product_required_options2[]']").each(function(index){
if(jQuery(this).val()==select_text+"||"+option_price_sum+"||"+option_id){
var count=parseInt(jQuery("input[name='product_required_options_count2[]']").eq(index).val());
is_exist=true;
jQuery("input[name='product_required_options_count2[]']").eq(index).val(count+1);
}});
if(!is_exist){
var input_id="product_required_options2"+product_required_options_index;
var option_price_text="";
if(commerce_price_type==2){
option_price_text=jQuery.number((parseFloat(jQuery("#product_sale_price").val())+option_price_sum),currency_number2)+commerce_currency2;
}else{
option_price_text=commerce_currency1+jQuery.number((parseFloat(jQuery("#product_sale_price").val())+option_price_sum),currency_number1);
}
jQuery("#mb_commerce_product_order_list2").append('<tr><td class="mb-td-item1">'+select_text+'<input type="hidden" name="product_required_options2[]" value="'+select_text.split('"').join("&quot;")+"||"+option_price_sum+"||"+option_id+'" /></td><td class="mb-td-item2"><div><a onclick="setOrderCountInputM(\'minus\',\''+input_id+'\');return false;" title="minus"><span class="mb-btn-minus mb-minus-style1"></a><input type="text" class="mc-order-count-input" id="'+input_id+'" maxlength="3" onkeydown="return inputOnlyNumber(event)" onkeyup="setCommerceProductOptionPriceM();" name="product_required_options_count2[]" value="1" style="vertical-align: top !important;"/><a onclick="setOrderCountInputM(\'plus\',\''+input_id+'\');return false;" title="plus"><span class="mb-btn-plus mb-plus-style1"></span></a></div></td><td class="mb-td-item3" style="text-align:right;padding-left:0px !important;"><span class="mc-required-option-price">+ '+option_price_text+'</span></td><td class="mb-td-item4" style="text-align:center;"><a onclick="deleteCommerceProductOption(this)" title="delete" role="button"><img  src="'+mb_urls["commerce_base"]+'images/icon_close.gif"/></a></td></tr>');
jQuery(".mc-mobile-fix-option-view").show();
jQuery(".mc-mobile-fix-option-price").show();
product_required_options_index++;
}
setCommerceProductOptionPriceM();
}}
function setCommerceProductOptionPrice(){
var option_text=new Array();
var option_value=new Array();
var option_price_sum=0;
var option_count_sum=0;
var option_price=0;
var option_count=0;
var count=0;
var price=0;
var option_sign="";
jQuery("input[name='product_required_options[]']").each(function(index){
option_value=jQuery(this).val().split("||");
count=parseInt(jQuery("input[name='product_required_options_count[]']").eq(index).val());
option_count_sum=option_count_sum+count;
if(option_value[1]) option_price=parseFloat(option_value[1]);
else option_price=0;
option_price_sum=option_price_sum+(option_price*count);
price=(parseFloat(jQuery("#product_sale_price").val())*count)+(option_price*count);
if(price>=0) option_sign="+";
else option_sign="";
if(commerce_price_type==2){
jQuery(".mc-required-option-price").eq(index).html(option_sign+jQuery.number(price,currency_number2)+commerce_currency2);
}else{
jQuery(".mc-required-option-price").eq(index).html(option_sign+" "+commerce_currency1+jQuery.number(price,currency_number1));
}});
if(option_count_sum==0) option_count_sum=1;
option_price_sum=option_price_sum+(parseFloat(jQuery("#product_sale_price").val())*option_count_sum);
jQuery("input[name='product_add_options[]']").each(function(index){
option_value=jQuery(this).val().split("||");
count=parseInt(jQuery("input[name='product_add_options_count[]']").eq(index).val());
option_count_sum=option_count_sum+count;
if(option_value[1]) option_price=parseFloat(option_value[1]);
else option_price=0;
option_price_sum=option_price_sum+(option_price*count);
price=(option_price*count);
if(price>=0) option_sign="+";
else option_sign="";
if(commerce_price_type==2){
jQuery(".mc-add-option-price").eq(index).html(option_sign+jQuery.number(price,currency_number2)+commerce_currency2);
}else{
jQuery(".mc-add-option-price").eq(index).html(option_sign+" "+commerce_currency1+jQuery.number(price,currency_number1));
}});
jQuery("#mb_commerce_product_order_price>tbody>tr").remove();
if(option_count_sum>0){
var option_price_text="";
if(commerce_price_type==2){
option_price_text=jQuery.number(option_price_sum,currency_number2)+commerce_currency2;
}else{
option_price_text=commerce_currency1+jQuery.number(option_price_sum,currency_number1);
}
jQuery("#mb_commerce_product_order_price>tbody").append('<tr><td class="bold">합계</td><td><input type="hidden" name="order_count" value="'+option_count_sum+'" style="width:60px;"/></td><td style="text-align:right;padding-left:0px !important" class="mc-order-price">'+option_price_text+'</td><td></td></tr>');
}}
function useCoupon(pid){
if(confirm("쿠폰을 사용하시겠습니까?")){
commerce_action="use_coupon";
sendCommerceData(commerce_action,pid);
}}
function deleteCommerceProductOption(obj){
jQuery(obj).parents("tr").remove();
setCommerceProductOptionPrice();
setCommerceProductOptionPriceM();
}
function checkGivePoint(type){
var check_count=jQuery("input[name='check_array[]']").filter(":checked").length;
var give_point=parseFloat(jQuery("input[name='give_point']").val());
var give_type=jQuery("select[name='give_type'] option").filter(":selected").val();
if(check_count==0){
showAlertPopup({"code":"1000","message":"회원을 선택해 주세요"});
}else if(give_point==0){
showAlertPopup({"code":"1000","message":"지급할 포인트를 입력해 주세요"});
}else{
if(give_type=="coupon"){
showConfirmPopup(check_count+"명의 회원에게 "+give_point+" 포인트 쿠폰을 <br>지급 하시겠습니까?", {"board_action":type}, sendCommerceListData);
}else if(give_type=="point"){
showConfirmPopup(check_count+"명의 회원에게 "+give_point+" 포인트를 <br>지급 하시겠습니까?", {"board_action":type}, sendCommerceListData);
}}
}
function checkUserRandCoupon(type){
commerce_action=type;
var coupon_id=jQuery("input[name='coupon_id']").val();
if(coupon_id.length<=10){
showAlertPopup({"code":"1000","message":"10글자 이상의 쿠폰 ID를 입력해 주세요"});
}else{
var data="mode=commerce&board_action="+type+"&board_name="+mb_options["board_name"]+"&coupon_id="+coupon_id;
sendDataRequest(mb_urls["commerce_api"], data, sendBoardListDataHandler);
}}
function checkCreateRandCoupon(type){
commerce_action=type;
var count=jQuery("select[name='coupon_count'] option").filter(":selected").val();
var give_point=parseFloat(jQuery("input[name='give_point']").val());
if(give_point==0){
showAlertPopup({"code":"1000","message":"쿠폰 ID 입력시 지급할 포인트를 입력해 주세요"});
}else{
showConfirmPopup(count+"개의 쿠폰 ID를 생성 하시겠습니까?", {"board_action":type}, sendCommerceListData);
}}
function sendCommerceListData(args){
if(args.board_action=="multi_modify_order"){
jQuery('#'+mb_options["board_name"]+'_form_board_list input[name=board_pid]').val(args.board_pid);
}
jQuery('#'+mb_options["board_name"]+'_form_board_list input[name=board_action]').val(args.board_action);
sendFormDataRequest(jQuery('#'+mb_options["board_name"]+'_form_board_list'), mb_urls["commerce_api"], sendBoardListDataHandler);
}
function sendCommerceFormData(name){
sendFormDataRequest(jQuery('#'+name), mb_urls["commerce_api"], sendCommerceFormDataHandler);
}
function sendCommerceFormDataHandler(response, state){
if(response&&response.state=="success"){
if(typeof(response.message)!=='undefined'&&response.message!="")
alert(response.message);
moveURL("reload");
}else{
showAlertPopup(response);
}}
function sendCommerceMail(message,args){
showConfirmPopup(message, {"board_action":args.board_action,"board_pid":args.board_pid}, sendCommerceParamData);
}
function sendCommerceSMS(message,args){
showConfirmPopup(message, {"board_action":args.board_action,"board_pid":args.board_pid,"user_phone":args.user_phone,"sms_title":args.sms_title,"sms_content":args.sms_content}, sendCommerceParamData);
}
function sendOrderNotifyMail(message,args){
showConfirmPopup(message, {"board_action":args.board_action,"board_pid":args.board_pid,"billing_id":args.billing_id}, sendCommerceParamData);
}
function sendCommerceMessageTemplate(message,args){
showConfirmPopup(message, args, sendCommerceParamData);
}
function sendCommerceParamData(args){
var data="mode=list&board_name="+mb_options["board_name"];
if(args){
for (var key in args){
data	+="&"+key+"="+encodeURIComponent(args[key]);
}}
sendDataRequest(mb_urls["commerce_api"], data, sendBoardListDataHandler);
}
function checkCommerceSendMail(action){
jQuery('#'+mb_options["board_name"]+'_form_board_list input[name=board_action]').val("write");
jQuery('#'+mb_options["board_name"]+'_form_board_list input[name=mode]').val("write");
jQuery('#'+mb_options["board_name"]+'_form_board_list input[name=board_name]').val("commerce_email");
jQuery('#'+mb_options["board_name"]+'_form_board_list input[name=page]').val("mbw_commerce_email");
var form=jQuery('#'+mb_options["board_name"]+'_form_board_list');
form.attr("method", "POST");
form.attr("action", action);
form.submit();
}
function changeCommerceProductRequiredOptionM(obj, idx){
var value_array=new Array();
var price_array=new Array(0);
var option_value=new Array();
var option_price=new Array(0);
var option_values=jQuery("#order_option_values2").val();
var option_prices=jQuery("#order_option_prices2").val();
if(option_values==undefined||option_values=="") return;
value_array=option_values.split("||");
price_array=option_prices.split("||");
var index=jQuery(obj).prop('selectedIndex')-1;
var i=0;
if(typeof(value_array[index])!=='undefined') option_value=value_array[index].split(",");
else option_value=value_array[value_array.length-1].split(",");
if(typeof(price_array[index])!=='undefined') option_price=price_array[index].split(",");
var value="";
var price=0;
var price_text="";
var select_option='<option value="">'+jQuery("select[name='product_required_options_select2[]']").eq(idx+1).find("option").eq(0).html()+'</option>';
for(i;i<option_value.length;i++){
if(typeof(option_value[i])!=='undefined') value=option_value[i];
if(typeof(option_price[i])!=='undefined'&&option_price[i]!=""&&option_price[i]!="0"){
price=parseFloat(option_price[i]);
price_text=getCommercePriceFormat(price,'option');
}else{
price=0;
price_text="";
}
select_option		+='<option value="'+value.split('"').join("&quot;")+"||"+price+'">'+value+price_text+'</option>';
}
jQuery("select[name='product_required_options_select2[]']").eq(idx+1).html(select_option);
}
function selectCommerceProductRequiredOptionM(){
var option_text=new Array();
var option_value=new Array();
var option_price_sum=0;
var check_option=true;
jQuery("select[name='product_required_options_select2[]']").each(function(index){
if(jQuery(this).val()==""){ check_option=false;return false;	}
option_value=jQuery(this).val().split("||");
if(option_value[0]) option_text.push(option_value[0]);
if(option_value[1]) option_price_sum=option_price_sum+parseFloat(option_value[1]);
});
if(!check_option) return;
var select_text=option_text.join(" / ");
var is_exist=false;
jQuery("input[name='product_required_options2[]']").each(function(index){
if(jQuery(this).val()==select_text+"||"+option_price_sum){
var count=parseInt(jQuery("input[name='product_required_options_count2[]']").eq(index).val());
is_exist=true;
jQuery("input[name='product_required_options_count2[]']").eq(index).val(count+1);
}});
if(!is_exist){
var input_id="product_required_options2"+product_required_options_index;
var option_price_text="";
if(commerce_price_type==2){
option_price_text=jQuery.number((parseFloat(jQuery("#product_sale_price").val())+option_price_sum),currency_number2)+commerce_currency2;
}else{
option_price_text=commerce_currency1+jQuery.number((parseFloat(jQuery("#product_sale_price").val())+option_price_sum),currency_number1);
}
jQuery("#mb_commerce_product_order_list2").append('<tr><td class="mb-td-item1">'+select_text+'<input type="hidden" name="product_required_options2[]" value="'+select_text.split('"').join("&quot;")+"||"+option_price_sum+'" /></td><td class="mb-td-item2"><div><a onclick="setOrderCountInputM(\'minus\',\''+input_id+'\');return false;" title="minus"><span class="mb-btn-minus mb-minus-style1"></a><input type="text" class="mc-order-count-input" id="'+input_id+'" maxlength="3" onkeydown="return inputOnlyNumber(event)" onkeyup="setCommerceProductOptionPriceM();" name="product_required_options_count2[]" value="1" style="vertical-align: top !important;"/><a onclick="setOrderCountInputM(\'plus\',\''+input_id+'\');return false;" title="plus"><span class="mb-btn-plus mb-plus-style1"></span></a></div></td><td class="mb-td-item3" style="text-align:right;padding-left:0px !important;"><span class="mc-required-option-price">+ '+option_price_text+'</span></td><td class="mb-td-item4" style="text-align:center;"><a onclick="deleteCommerceProductOption(this)" title="delete" role="button"><img  src="'+mb_urls["commerce_base"]+'images/icon_close.gif"/></a></td></tr>');
jQuery(".mc-mobile-fix-option-view").show();
jQuery(".mc-mobile-fix-option-price").show();
product_required_options_index++;
}
setCommerceProductOptionPriceM();
}
function selectCommerceProductAddOptionM(obj){
var option_text=new Array();
var option_value=new Array();
var option_price_sum=0;
if(jQuery(obj).val()=="") return;
option_value=jQuery(obj).val().split("||");
if(option_value[0]) option_text.push(option_value[0]);
if(option_value[1]) option_price_sum=option_price_sum+parseFloat(option_value[1]);
var select_text=option_text.join(" / ");
var is_exist=false;
jQuery("input[name='product_add_options2[]']").each(function(index){
if(jQuery(this).val()==select_text+"||"+option_price_sum){
var count=parseInt(jQuery("input[name='product_add_options_count2[]']").eq(index).val());
is_exist=true;
jQuery("input[name='product_add_options_count2[]']").eq(index).val(count+1);
}});
if(!is_exist){
var input_id="product_add_options2"+product_add_options_index;
var option_price_text="";
if(commerce_price_type==2){
option_price_text=jQuery.number(option_price_sum,currency_number2)+commerce_currency2;
}else{
option_price_text=commerce_currency1+jQuery.number(option_price_sum,currency_number1);
}
jQuery("#mb_commerce_product_order_list2").append('<tr><td class="mb-td-item1">'+select_text+'<input type="hidden" name="product_add_options2[]" value="'+select_text+"||"+option_price_sum+'" /></td><td class="mb-td-item2"><div><a onclick="setOrderCountInputM(\'minus\',\''+input_id+'\');return false;" title="minus"><span class="mb-btn-minus mb-minus-style1"></a><input type="text" class="mc-order-count-input" id="'+input_id+'" maxlength="3" onkeydown="return inputOnlyNumber(event)" onkeyup="setCommerceProductOptionPriceM();" name="product_add_options_count2[]" value="1" style="vertical-align: top !important;"/><a onclick="setOrderCountInputM(\'plus\',\''+input_id+'\');return false;" title="plus"><span class="mb-btn-plus mb-plus-style1"></span></a></div></td><td class="mb-td-item3" style="text-align:right;"><span class="mc-add-option-price">+ '+option_price_text+'</span></td><td class="mb-td-item4" style="text-align:center;"><a onclick="deleteCommerceProductOption(this)" title="delete" role="button"><img  src="'+mb_urls["commerce_base"]+'images/icon_close.gif"/></a></td></tr>');
jQuery(".mc-mobile-fix-option-view").show();
jQuery(".mc-mobile-fix-option-price").show();
product_add_options_index++;
}
setCommerceProductOptionPriceM();
}
function setCommerceProductOptionPriceM(){
var option_text=new Array();
var option_value=new Array();
var option_price_sum=0;
var option_count_sum=0;
var option_price=0;
var option_count=0;
var count=0;
var price=0;
var option_sign="";
jQuery("input[name='product_required_options2[]']").each(function(index){
option_value=jQuery(this).val().split("||");
count=parseInt(jQuery("input[name='product_required_options_count2[]']").eq(index).val());
option_count_sum=option_count_sum+count;
if(option_value[1]) option_price=parseFloat(option_value[1]);
else option_price=0;
option_price_sum=option_price_sum+(option_price*count);
price=(parseFloat(jQuery("#product_sale_price").val())*count)+(option_price*count);
if(price>=0) option_sign="+";
else option_sign="";
if(commerce_price_type==2){
jQuery(".mc-required-option-price").eq(index).html(option_sign+jQuery.number(price,currency_number2)+commerce_currency2);
}else{
jQuery(".mc-required-option-price").eq(index).html(option_sign+" "+commerce_currency1+jQuery.number(price,currency_number1));
}});
if(option_count_sum==0) option_count_sum=1;
option_price_sum=option_price_sum+(parseFloat(jQuery("#product_sale_price").val())*option_count_sum);
jQuery("input[name='product_add_options2[]']").each(function(index){
option_value=jQuery(this).val().split("||");
count=parseInt(jQuery("input[name='product_add_options_count2[]']").eq(index).val());
option_count_sum=option_count_sum+count;
if(option_value[1]) option_price=parseFloat(option_value[1]);
else option_price=0;
option_price_sum=option_price_sum+(option_price*count);
price=(option_price*count);
if(price>=0) option_sign="+";
else option_sign="";
if(commerce_price_type==2){
jQuery(".mc-add-option-price").eq(index).html(option_sign+jQuery.number(price,currency_number2)+commerce_currency2);
}else{
jQuery(".mc-add-option-price").eq(index).html(option_sign+" "+commerce_currency1+jQuery.number(price,currency_number1));
}});
jQuery("#mb_commerce_product_order_price2>tbody>tr").remove();
if(option_count_sum>0){
var option_price_text="";
if(commerce_price_type==2){
option_price_text=jQuery.number(option_price_sum,currency_number2)+commerce_currency2;
}else{
option_price_text=commerce_currency1+jQuery.number(option_price_sum,currency_number1);
}
jQuery("#mb_commerce_product_order_price2>tbody").append('<tr><td class="bold">합계</td><td><input type="hidden" name="order_count" value="'+option_count_sum+'" style="width:60px;"/></td><td style="text-align:right;padding-left:0px !important" class="mc-order-price">'+option_price_text+'</td><td></td></tr>');
}}
var order_view_action='';
function sendModifyOrderViewData(action,type,param){
var msg="상태를 변경하시겠습니까?";
if(action=="order_modify_cash_receipt"){
if(type=="none"){
msg="선택하신 주문에 대한 현금영수증 신청을 마감하시겠습니까?";
}}
if(confirm(msg)){
order_view_action=action+'_'+type;
var data="mode=view&board_action="+action+"&modify_type="+type+"&board_name="+mb_options["board_name"]+"&board_pid="+mb_options["pid"];
if(typeof(param)!=='undefined'&&param!="") data=data+"&"+param;
sendDataRequest(mb_urls["commerce_api"], data, sendModifyOrderViewDataHandler);
}}
function sendModifyOrderViewDataHandler(response, state){
if(response&&response.state=="success"){
if(order_view_action=="order_modify_cash_receipt_none"){
alert('선택하신 주문에 대한 현금영수증 신청이 마감되었습니다');
}else{
alert('정상적으로 수정되었습니다');
}
moveURL("reload");
}else{
showAlertPopup(response);
}}
function sendCommerceUserOrderData(value,order_id){
sendDataRequest2(mb_urls["template_api"], "mode=plugin&board_action=save_user_order_data&order_data="+encodeURIComponent(value)+"&order_id="+encodeURIComponent(order_id));
}
function getBillingPostcode(type,id){
if(typeof(mb_hybrid_app)==='undefined'||mb_hybrid_app==""){
new kakao.Postcode({
oncomplete: function(data){
var fullAddr="";
var extraAddr="";
if(data.userSelectedType==="R"){
fullAddr=data.roadAddress;
}else{
fullAddr=data.jibunAddress;
}
if(data.userSelectedType==="R"){
if(data.bname!==""){extraAddr +=data.bname;}
if(data.buildingName!==""){extraAddr +=(extraAddr!=="" ? ", " + data.buildingName:data.buildingName);}
fullAddr +=(extraAddr!=="" ? " ("+ extraAddr +")":"");
}
document.getElementById(type+"_postcode").value=data.zonecode;
document.getElementById(type+"_address1").value=fullAddr;
if(type.indexOf('shipping')==0) checkAddressAddShippingCost(type);
jQuery("#"+type+"_address2").focus();
}}).open();
}else{
openWindow(mb_urls["home"]+"/?mb_app=postcode&type="+type);
}}
function getBillingPostcodeIframe(type,id){
if(typeof(id)==='undefined'||id=='') id='mb_kakao_postcode1';
var element_wrap=document.getElementById(id);
var currentScroll=Math.max(document.body.scrollTop, document.documentElement.scrollTop);
new kakao.Postcode({
oncomplete: function(data){
var fullAddr="";
var extraAddr="";
if(data.userSelectedType==="R"){
fullAddr=data.roadAddress;
}else{
fullAddr=data.jibunAddress;
}
if(data.userSelectedType==="R"){
if(data.bname!==""){extraAddr +=data.bname;}
if(data.buildingName!==""){extraAddr +=(extraAddr!=="" ? ", " + data.buildingName:data.buildingName);}
fullAddr +=(extraAddr!=="" ? " ("+ extraAddr +")":"");
}
document.getElementById(type+"_postcode").value=data.zonecode;
document.getElementById(type+"_address1").value=fullAddr;
if(type.indexOf('shipping')==0) checkAddressAddShippingCost(type);
jQuery("#"+type+"_address2").focus();
element_wrap.style.display='none';
jQuery("html, body").scrollTop(currentScroll);
},
onresize:function(size){
element_wrap.style.height=(size.height+30)+'px';
},
width:'100%',
height:'100%'
}).embed(element_wrap);
element_wrap.style.display='block';
}
function checkAddressAddShippingCost(type){
if(typeof(type)==='undefined'||type=='') type='shipping';
if(jQuery("#"+type+"_postcode").length>0&&jQuery("input[name='is_add_shipping']").length>0){
var postcode=jQuery("#"+type+"_postcode").val();
var address1=jQuery("#"+type+"_address1").val();
var check_address=',제주,인천,부산,충남,경북,경남,전북,전남,충청,경상,전라,';
var state=address1.substr(0,2);
var addShippingCost=0;
var addShippingText='';
if(postcode!=''){
if(check_address.indexOf(state)!=-1){
postcode=parseInt(postcode);
var add_shipping_cost=[
{"code1":"22386","code2":"22388","address":"인천 중구 섬","price":6000},
{"code1":"23004","code2":"23010","address":"인천 강화 섬","price":4500},
{"code1":"23100","code2":"23116","address":"인천 옹진 섬1","price":6000},
{"code1":"23124","code2":"23136","address":"인천 옹진 섬2","price":6000},
{"code1":"31708","code2":"31708","address":"충남 당진 섬","price":4000},
{"code1":"32133","code2":"32133","address":"충남 태안 섬","price":5000},
{"code1":"33411","code2":"33411","address":"충남 보령 섬","price":5000},
{"code1":"40200","code2":"40240","address":"경북 울릉도","price":4000},
{"code1":"46768","code2":"46771","address":"부산 강서구","price":4000},
{"code1":"52570","code2":"52571","address":"경남 사천 섬","price":4000},
{"code1":"53031","code2":"53033","address":"경남 통영 섬1","price":4000},
{"code1":"53089","code2":"53104","address":"경남 통영 섬2","price":4000},
{"code1":"54000","code2":"54000","address":"경남 통영 섬3","price":4000},
{"code1":"56347","code2":"56349","address":"전북 부안 섬","price":5000},
{"code1":"57068","code2":"57069","address":"전남 영광 섬","price":4000},
{"code1":"58760","code2":"58762","address":"전남 목포 섬","price":6000},
{"code1":"58800","code2":"58810","address":"전남 신안 섬1","price":7000},
{"code1":"58816","code2":"58818","address":"전남 신안 섬2","price":7000},
{"code1":"58826","code2":"58826","address":"전남 신안 섬3","price":7000},
{"code1":"58828","code2":"58866","address":"전남 신안 섬4","price":7000},
{"code1":"58953","code2":"58958","address":"전남 진도 섬","price":7000},
{"code1":"59102","code2":"59103","address":"전남 완도 섬1","price":5000},
{"code1":"59106","code2":"59106","address":"전남 완도 섬2","price":5000},
{"code1":"59127","code2":"59127","address":"전남 완도 섬3","price":5000},
{"code1":"59129","code2":"59129","address":"전남 완도 섬4","price":5000},
{"code1":"59137","code2":"59166","address":"전남 완도 섬5","price":5000},
{"code1":"59421","code2":"59421","address":"전남 보성 섬","price":4000},
{"code1":"59531","code2":"59531","address":"전남 고흥 섬1","price":5000},
{"code1":"59551","code2":"59551","address":"전남 고흥 섬2","price":5000},
{"code1":"59563","code2":"59563","address":"전남 고흥 섬3","price":5000},
{"code1":"59568","code2":"59568","address":"전남 고흥 섬4","price":5000},
{"code1":"59650","code2":"59650","address":"전남 여수 섬1","price":8000},
{"code1":"59766","code2":"59766","address":"전남 여수 섬1","price":8000},
{"code1":"59781","code2":"59790","address":"전남 여수 섬3","price":8000},
{"code1":"63000","code2":"63644","address":"제주도","price":3000}];
jQuery.each(add_shipping_cost, function(key, val){
if(postcode>=parseInt(val['code1'])&&postcode<=parseInt(val['code2'])){
addShippingCost=parseInt(val['price']);
return false;
}});
}
if(commerce_price_type==2){
addShippingText=jQuery.number(addShippingCost,currency_number2)+commerce_currency2;
}else{
addShippingText=commerce_currency1+jQuery.number(addShippingCost,currency_number1);
}
var tempShippingCost=jQuery("#add_shipping_cost").val();
jQuery("#add_shipping_cost").val(addShippingCost);
jQuery("#billing_add_shipping_cost").text(addShippingText);
jQuery("#shipping_cost").val(parseFloat(jQuery("#shipping_cost2").val())+parseFloat(jQuery("#add_shipping_cost").val()));
checkBillingPrice('shipping');
if(addShippingCost>0){
jQuery("input[name='is_add_shipping']").prop("checked", true);
if(typeof(tempShippingCost)!=='undefined'&&tempShippingCost!=String(addShippingCost)){
alert("추가배송비가 발생하는 배송지역입니다 (추가배송비:"+addShippingText+")");
}}else{
jQuery("input[name='is_add_shipping']").prop("checked", false);
}}else{
if(commerce_price_type==2){
addShippingText='0'+commerce_currency2;
}else{
addShippingText=commerce_currency1+'0';
}
jQuery("#add_shipping_cost").val(addShippingCost);
jQuery("#billing_add_shipping_cost").text(addShippingText);
jQuery("#shipping_cost").val(parseFloat(jQuery("#shipping_cost2").val()));
checkBillingPrice('shipping');
}}
}
function sendMultiOrderState(){
if(jQuery('#mb_multi_order_state').length>0){
var order_state=jQuery('#mb_multi_order_state').val();
if(order_state==''){
alert('주문상태를 선택해 주세요');
}else{
var check_count=jQuery("input[name='check_array[]']").filter(":checked").length;
if(check_count==0){
alert('수정할 주문을 선택해 주세요');
}else{
var s_target;
jQuery("input[name='check_array[]']").filter(":checked").each(function(){
s_target=jQuery(this).closest('tr').find("td.mb-order-state select");
if(s_target.find('option[value='+order_state+']').length>0){
s_target.val(order_state);
}});
sendCommerceListData({'mode':'list','board_action':'multi_modify_order'});
}}
}};