// 전역 변수 var errmsg = ""; var errfld = null; // 필드 검사 function check_field(fld, msg) { if ((fld.value = trim(fld.value)) == "") error_field(fld, msg); else clear_field(fld); return; } // 필드 오류 표시 function error_field(fld, msg) { if (msg != "") errmsg += msg + "\n"; if (!errfld) errfld = fld; fld.style.background = "#BDDEF7"; } // 필드를 깨끗하게 function clear_field(fld) { fld.style.background = "#FFFFFF"; } function trim(s) { var t = ""; var from_pos = to_pos = 0; for (i=0; i=0; i--) { if (s.charAt(i-1) == ' ') continue; else { to_pos = i; break; } } t = s.substring(from_pos, to_pos); // alert(from_pos + ',' + to_pos + ',' + t+'.'); return t; } // 자바스크립트로 PHP의 number_format 흉내를 냄 // 숫자에 , 를 출력 function number_format(data) { var tmp = ''; var number = ''; var cutlen = 3; var comma = ','; var i; var sign = data.match(/^[\+\-]/); if(sign) { data = data.replace(/^[\+\-]/, ""); } len = data.length; mod = (len % cutlen); k = cutlen - mod; for (i=0; i 0) document.getElementById(id).rows -= row; } function textarea_original(id, row) { document.getElementById(id).rows = row; } function textarea_increase(id, row) { document.getElementById(id).rows += row; } // 글숫자 검사 function check_byte(content, target) { var i = 0; var cnt = 0; var ch = ''; var cont = document.getElementById(content).value; for (i=0; i 4) { cnt += 2; } else { cnt += 1; } } // 숫자를 출력 document.getElementById(target).innerHTML = cnt; return cnt; } // 브라우저에서 오브젝트의 왼쪽 좌표 function get_left_pos(obj) { var parentObj = null; var clientObj = obj; //var left = obj.offsetLeft + document.body.clientLeft; var left = obj.offsetLeft; while((parentObj=clientObj.offsetParent) != null) { left = left + parentObj.offsetLeft; clientObj = parentObj; } return left; } // 브라우저에서 오브젝트의 상단 좌표 function get_top_pos(obj) { var parentObj = null; var clientObj = obj; //var top = obj.offsetTop + document.body.clientTop; var top = obj.offsetTop; while((parentObj=clientObj.offsetParent) != null) { top = top + parentObj.offsetTop; clientObj = parentObj; } return top; } function flash_movie(src, ids, width, height, wmode) { var wh = ""; if (parseInt(width) && parseInt(height)) wh = " width='"+width+"' height='"+height+"' "; return ""; } function obj_movie(src, ids, width, height, autostart) { var wh = ""; if (parseInt(width) && parseInt(height)) wh = " width='"+width+"' height='"+height+"' "; if (!autostart) autostart = false; return ""; } function doc_write(cont) { document.write(cont); } var win_password_lost = function(href) { window.open(href, "win_password_lost", "left=50, top=50, width=617, height=330, scrollbars=1"); } $(document).ready(function(){ $("#login_password_lost, #ol_password_lost").click(function(){ win_password_lost(this.href); return false; }); }); /** * 포인트 창 **/ var win_point = function(href) { var new_win = window.open(href, 'win_point', 'left=100,top=100,width=600, height=600, scrollbars=1'); new_win.focus(); } /** * 쪽지 창 **/ var win_memo = function(href) { var new_win = window.open(href, 'win_memo', 'left=100,top=100,width=620,height=500,scrollbars=1'); new_win.focus(); } /** * 메일 창 **/ var win_email = function(href) { var new_win = window.open(href, 'win_email', 'left=100,top=100,width=600,height=580,scrollbars=0'); new_win.focus(); } /** * 자기소개 창 **/ var win_profile = function(href) { var new_win = window.open(href, 'win_profile', 'left=100,top=100,width=620,height=510,scrollbars=1'); new_win.focus(); } /** * 스크랩 창 **/ var win_scrap = function(href) { var new_win = window.open(href, 'win_scrap', 'left=100,top=100,width=600,height=600,scrollbars=1'); new_win.focus(); } /** * 홈페이지 창 **/ var win_homepage = function(href) { var new_win = window.open(href, 'win_homepage', ''); new_win.focus(); } /** * 우편번호 창 **/ var win_zip = function(frm_name, frm_zip1, frm_zip2, frm_addr1, frm_addr2, frm_addr3, frm_jibeon) { if(typeof daum === 'undefined'){ alert("다음 juso.js 파일이 로드되지 않았습니다."); return false; } new daum.Postcode({ oncomplete: function(data) { // 팝업에서 검색결과 항목을 클릭했을때 실행할 코드를 작성하는 부분. // 우편번호와 주소 정보를 해당 필드에 넣고, 커서를 상세주소 필드로 이동한다. var of = document[frm_name]; of[frm_zip1].value = data.postcode1; of[frm_zip2].value = data.postcode2; of[frm_addr1].value = data.address1; of[frm_addr2].value = ""; of[frm_addr3].value = ""; if( data.addressType == "R" ){ //도로명이면 of[frm_addr3].value = data.address2; } if(of[frm_jibeon] !== undefined){ of[frm_jibeon].value = data.addressType; } of[frm_addr2].focus(); } }).open(); } /** * sms5 창 **/ var win_sms5 = function(href) { var new_win = window.open(href, 'win_sms5', 'width=474, height=560, scrollbars=1'); new_win.focus(); } /** * 새로운 비밀번호 분실 창 : 101123 **/ win_password_lost = function(href) { var new_win = window.open(href, 'win_password_lost', 'width=617, height=330, scrollbars=1'); new_win.focus(); } /** * 설문조사 결과 **/ var win_poll = function(href) { var new_win = window.open(href, 'win_poll', 'width=616, height=500, scrollbars=1'); new_win.focus(); } /** * 스크린리더 미사용자를 위한 스크립트 - 지운아빠 2013-04-22 * alt 값만 갖는 그래픽 링크에 마우스오버 시 title 값 부여, 마우스아웃 시 title 값 제거 **/ $(function() { $('a img').mouseover(function() { $a_img_title = $(this).attr('alt'); $(this).attr('title', $a_img_title); }).mouseout(function() { $(this).attr('title', ''); }); }); /** * 텍스트 리사이즈 **/ function font_resize(id, rmv_class, add_class) { var $el = $("#"+id); $el.removeClass(rmv_class).addClass(add_class); set_cookie("ck_font_resize_rmv_class", rmv_class, 1, g5_cookie_domain); set_cookie("ck_font_resize_add_class", add_class, 1, g5_cookie_domain); } $(function(){ $(".win_point").click(function() { win_point(this.href); return false; }); $(".win_memo").click(function() { win_memo(this.href); return false; }); $(".win_email").click(function() { win_email(this.href); return false; }); $(".win_scrap").click(function() { win_scrap(this.href); return false; }); $(".win_profile").click(function() { win_profile(this.href); return false; }); $(".win_homepage").click(function() { win_homepage(this.href); return false; }); $(".win_password_lost").click(function() { win_password_lost(this.href); return false; }); $(".win_sms5").click(function() { win_sms5(this.href); return false; }); /* $(".win_poll").click(function() { win_poll(this.href); return false; }); */ // 사이드뷰 var sv_hide = false; $(".sv_member, .sv_guest").click(function() { $(".sv").removeClass("sv_on"); $(this).closest(".sv_wrap").find(".sv").addClass("sv_on"); }); $(".sv, .sv_wrap").hover( function() { sv_hide = false; }, function() { sv_hide = true; } ); $(".sv_member, .sv_guest").focusin(function() { sv_hide = false; $(".sv").removeClass("sv_on"); $(this).closest(".sv_wrap").find(".sv").addClass("sv_on"); }); $(".sv a").focusin(function() { sv_hide = false; }); $(".sv a").focusout(function() { sv_hide = true; }); // 셀렉트 ul var sel_hide = false; $('.sel_btn').click(function() { $('.sel_ul').removeClass('sel_on'); $(this).siblings('.sel_ul').addClass('sel_on'); }); $(".sel_wrap").hover( function() { sel_hide = false; }, function() { sel_hide = true; } ); $('.sel_a').focusin(function() { sel_hide = false; }); $('.sel_a').focusout(function() { sel_hide = true; }); $(document).click(function() { if(sv_hide) { // 사이드뷰 해제 $(".sv").removeClass("sv_on"); } if (sel_hide) { // 셀렉트 ul 해제 $('.sel_ul').removeClass('sel_on'); } }); $(document).focusin(function() { if(sv_hide) { // 사이드뷰 해제 $(".sv").removeClass("sv_on"); } if (sel_hide) { // 셀렉트 ul 해제 $('.sel_ul').removeClass('sel_on'); } }); $("#dealdate").datepicker({ showOn: "button", buttonImage: "./img/calendar.png", buttonImageOnly: true, buttonText: "Select date", dateFormat: "yy-mm-dd", changeMonth: true, changeYear: true, monthNames: ['1월','2월','3월','4월','5월','6월','7월','8월','9월','10월','11월','12월'], monthNamesShort: ['1월','2월','3월','4월','5월','6월','7월','8월','9월','10월','11월','12월'], dayNames: ['일','월','화','수','목','금','토'], dayNamesShort: ['일','월','화','수','목','금','토'], dayNamesMin: ['일','월','화','수','목','금','토'], showMonthAfterYear: true, yearSuffix: '년' }); $("#sdate").datepicker({ showOn: "button", buttonImage: "./img/calendar.png", buttonImageOnly: true, buttonText: "Select date", dateFormat: "yy-mm-dd", changeMonth: true, changeYear: true, monthNames: ['1월','2월','3월','4월','5월','6월','7월','8월','9월','10월','11월','12월'], monthNamesShort: ['1월','2월','3월','4월','5월','6월','7월','8월','9월','10월','11월','12월'], dayNames: ['일','월','화','수','목','금','토'], dayNamesShort: ['일','월','화','수','목','금','토'], dayNamesMin: ['일','월','화','수','목','금','토'], showMonthAfterYear: true, yearSuffix: '년' }); $("#edate").datepicker({ showOn: "button", buttonImage: "./img/calendar.png", buttonImageOnly: true, buttonText: "Select date", dateFormat: "yy-mm-dd", changeMonth: true, changeYear: true, monthNames: ['1월','2월','3월','4월','5월','6월','7월','8월','9월','10월','11월','12월'], monthNamesShort: ['1월','2월','3월','4월','5월','6월','7월','8월','9월','10월','11월','12월'], dayNames: ['일','월','화','수','목','금','토'], dayNamesShort: ['일','월','화','수','목','금','토'], dayNamesMin: ['일','월','화','수','목','금','토'], showMonthAfterYear: true, yearSuffix: '년' }); $(document).on("change",".comp_sn_class_office, .comp_sn_class, .telno_class, .number_class, .int_class",function(){ // 번호등 - 처리 var v = $(this).val(); if($(this).hasClass("comp_sn_class")==true){ preg_replace2("sn",v,$(this)); } else if($(this).hasClass("comp_sn_class_office")==true){ preg_replace2("sn_office",v,$(this)); } else if($(this).hasClass("telno_class")==true){ preg_replace2("hp",v,$(this)); } else if($(this).hasClass("number_class")==true){ preg_replace2("number",v,$(this)); } else if($(this).hasClass("int_class")==true){ $(this).val(integer_ch(v)); } }); $(".paging_sel_class").change(function(){ // 라인수 변경시 var vp = $(".paging_sel_class option:selected").val(); vv = qstr_rmv(qstr,"page_sel"); setsave("page_line", vp, 31); document.location.reload(); }); $(document).on("focus",".input_readonly",function(){ $(this).attr("readonly",true); }) $(".select_bg_ch").change(function(){ if($(this).val()=='0' || $(this).val()==''){ $(this).css("background","#DEB3B3").css("color","white"); } else { $(this).css("background","").css("color",""); } }) $(".select_bg_ch").each(function(){ $v = $(this).find("option:selected").val(); if($v=='0' || $v==''){ $(this).css("background","#DEB3B3").css("color","white"); } }); $(".list_cart_class").click(function(){ // 리스트에서 일반상품 바로 담기 기능 $form_obj = $(this).closest("form"); list_prod_cart_process($form_obj); }); $(".list_wish_class").click(function(){ // 리스트에서 위시리스트 담기 처리 $form_obj = $(this).closest("form"); list_prod_wish_process($form_obj); }); $(".list_option_class").click(function(){ // 리스트에서 옵션상품 새창띄우기 기능 if($("#modal_member_box_opt").attr("id")===undefined){ $("body").append(""); } $box_obj = $(this).closest(".opt_div"); $code = $box_obj.find("input[name='code']").val(); if($("#is_mobile").val()=='Y'){ $dialog_height = "500"; $dialog_width = "98%"; } else { $dialog_height = "600"; $dialog_width = "520"; } $ev_code = parseInt($box_obj.find("input[name='p_ev_code']").val()); if($ev_code>0){ $add_param = "&ev_code="+$ev_code; } else { $add_param = ""; } $.get("cart_option.inc.php?od_ids=&code="+$code+$add_param,function(rtn){ $("#modal_member_box_opt").html(rtn).dialog({ resizable: true, height:$dialog_height, width:$dialog_width, modal: true, title:"상품옵션 [선택]", buttons: { 장바구니담기: function() { prod_cart_save('list'); }, 닫기: function() { $( this ).dialog( "close" ); }, 찜하기: function() { prod_wish_save(); }, } }); }); }); $(document).on("change",".list_opt_sel_class",function(){ // 리스트에서 옵션상품 선택시 처리 기능 var select_name = $(this).children("option:selected").text(); $(this).siblings("label").text(select_name); code = $(this).val(); if($(this).attr("id")=='opt'){ mode = 'opt'; } else { mode = 'addopt'; } add_list_opt_info_get(code,mode); }); /*$(document).on("click",".list_opt_del_class",function(){ // 리스트에서 옵션 삭제 기능 $parent_obj = $(this).closest(".sit_sel_option_class"); if($parent_obj.find("input[name='opt_mode[]']").val()!=''){ $parent_obj.remove(); //sum_opt_price(); } });*/ $(document).on("click",".opt_del_class",function(){ // 옵션 삭제 (item.php에서 동일모듈이라 이전됨) $parent_obj = $(this).closest("#sit_sel_option"); if($parent_obj.find("input[name='opt_mode[]']").val()!=''){ $parent_obj.remove(); sum_opt_price(); } }); $(document).on("click",".minus_qty_class",function(){ // - 버튼시 동작 (item.php에서 동일모듈이라 이전됨) $parent_obj = $(this).closest("#sit_sel_option"); $min_qty = parseInt($parent_obj.find("input[name='p_min_buy[]']").val()); $pack_qty = parseInt($parent_obj.find("input[name='p_pack_buy[]']").val()); $cur_qty = parseInt($parent_obj.find("input[name='qty[]']").val()); if($cur_qty==$min_qty){ alert('해당 상품의 최소구매수량은 '+$min_qty+'개 입니다.'); } else if($min_qty==0 && $cur_qty==1){ } else { if($pack_qty>1){ $parent_obj.find("input[name='qty[]']").val($cur_qty-$pack_qty); } else { $parent_obj.find("input[name='qty[]']").val($cur_qty-1); } sum_opt_price(); } }); $(document).on("click",".add_qty_class",function(){ // + 버튼시 동작 (item.php에서 동일모듈이라 이전됨) $parent_obj = $(this).closest("#sit_sel_option"); $max_qty = parseInt($parent_obj.find("input[name='p_max_buy[]']").val()); $pack_qty = parseInt($parent_obj.find("input[name='p_pack_buy[]']").val()); $cur_qty = parseInt($parent_obj.find("input[name='qty[]']").val()); $jego = parseInt($parent_obj.find("input[name='jego[]']").val()); if($max_qty>0 && $cur_qty==$max_qty){ alert('해당 상품의 최대구매수량은 '+$max_qty+'개 입니다.'); } else if($jego<=$cur_qty){ alert('해당 상품의 재고는 '+$jego+'개 입니다.'); } else { if($pack_qty>1){ if($cur_qty+$pack_qty>$jego){ alert('해당 상품의 재고는 '+$jego+'개 입니다.'); return; } $parent_obj.find("input[name='qty[]']").val($cur_qty+$pack_qty); } else { $parent_obj.find("input[name='qty[]']").val($cur_qty+1); } sum_opt_price(); } }); $(document).on("change","input[name='qty[]']",function(){ // 수량 직접 수정시 동작 (item.php에서 동일모듈이라 이전됨) preg_replace2("number",$(this).val(),$(this)); $parent_obj = $(this).closest("#sit_sel_option"); $min_qty = parseInt($parent_obj.find("input[name='p_min_buy[]']").val()); $max_qty = parseInt($parent_obj.find("input[name='p_max_buy[]']").val()); $pack_qty = parseInt($parent_obj.find("input[name='p_pack_buy[]']").val()); $cur_qty = parseInt($parent_obj.find("input[name='qty[]']").val()); $jego = parseInt($parent_obj.find("input[name='jego[]']").val()); if($min_qty>0 && $min_qty>$cur_qty){ alert('해당 상품의 최소구매수량은 '+$min_qty+'개 입니다.'); $parent_obj.find("input[name='qty[]']").val($parent_obj.find("input[name='qty_default[]']").val()); } else if($max_qty<$cur_qty && $max_qty>0){ alert('해당 상품의 최대구매수량은 '+$max_qty+'개 입니다.'); $parent_obj.find("input[name='qty[]']").val($parent_obj.find("input[name='qty_default[]']").val()); } else if($jego<=$cur_qty){ alert('해당 상품의 재고는 '+$jego+'개 입니다.'); if($pack_qty>1){ $parent_obj.find("input[name='qty[]']").val($parent_obj.find("input[name='qty_default[]']").val()); } else { $parent_obj.find("input[name='qty[]']").val($jego); } } else if($pack_qty>1){ $vv = ($cur_qty-$min_qty)%$pack_qty; if($vv!=0){ alert('해당 상품의 구매 묶음단위는 '+$pack_qty+'입니다.'); $parent_obj.find("input[name='qty[]']").val($parent_obj.find("input[name='qty_default[]']").val()); } } sum_opt_price(); }); $(".qty_minus_class2").click(function(){ // 상품리스트에서 수량 마이너스 버튼 클릭 $tr_obj = $(this).closest("form"); $ct_qty = $tr_obj.find("input[name='qty[]']").val(); $min_qty = $tr_obj.find("input[name='p_min_buy[]']").val(); $pack_qty = parseInt($tr_obj.find("input[name='p_pack_buy[]']").val()); if($ct_qty==$min_qty){ alert('최소 구매수량은 '+$min_qty+'개 입니다.'); } else if($ct_qty>'1'){ if($pack_qty>1){ $tr_obj.find("input[name='qty[]']").val(parseInt($ct_qty)-$pack_qty); } else { $tr_obj.find("input[name='qty[]']").val(parseInt($ct_qty)-1); } } }); $(".qty_plus_class2").click(function(){ // 상품리스트에서 수량 플러스 버튼 클릭 $tr_obj = $(this).closest("form"); $ct_qty = $tr_obj.find("input[name='qty[]']").val(); $jego = $tr_obj.find("input[name='jego[]']").val(); $max_qty = $tr_obj.find("input[name='p_max_buy[]']").val(); $pack_qty = parseInt($tr_obj.find("input[name='p_pack_buy[]']").val()); if(Number($jego)<=Number($ct_qty)){ alert('재고가 '+$jego+'개 입니다.'); } else if(Number($max_qty)<=Number($ct_qty) && Number($max_qty)>0){ alert('최대 구매수량은 '+$max_qty+'개 입니다.'); } else { if($pack_qty>1){ if(parseInt($ct_qty)+$pack_qty>Number($jego)){ alert('해당 상품의 재고는 '+$jego+'개 입니다.'); return; } $tr_obj.find("input[name='qty[]']").val(parseInt($ct_qty)+$pack_qty); } else { $tr_obj.find("input[name='qty[]']").val(parseInt($ct_qty)+1); } } }); $("#cart_list_form .qty_minus_class").click(function(){ // 장바구니 수량 마이너스 버튼 클릭 $tr_obj = $(this).closest("tr"); if($tr_obj.length==0){ // 모바일시 $tr_obj = $(this).closest("section"); } $ct_qty = $tr_obj.find("input[name='ct_qty[]']").val(); $min_qty = $tr_obj.find("input[name='p_min_buy[]']").val(); $pack_qty = parseInt($tr_obj.find("input[name='p_pack_buy[]']").val()); if($ct_qty==$min_qty){ alert('최소 구매수량은 '+$min_qty+'개 입니다.'); } else if($ct_qty>'1'){ if($pack_qty>1){ $tr_obj.find("input[name='ct_qty[]']").val(parseInt($ct_qty)-$pack_qty); } else { $tr_obj.find("input[name='ct_qty[]']").val(parseInt($ct_qty)-1); } } }); $("#cart_list_form .qty_plus_class").click(function(){ // 장바구니 수량 플러스 버튼 클릭 $tr_obj = $(this).closest("tr"); if($tr_obj.length==0){ // 모바일시 $tr_obj = $(this).closest("section"); } $ct_qty = $tr_obj.find("input[name='ct_qty[]']").val(); $jego = $tr_obj.find("input[name='jego[]']").val(); $max_qty = $tr_obj.find("input[name='p_max_buy[]']").val(); $pack_qty = parseInt($tr_obj.find("input[name='p_pack_buy[]']").val()); if(Number($jego)<=Number($ct_qty)){ alert('재고가 '+$jego+'개 입니다.'); } else if(Number($max_qty)<=Number($ct_qty) && Number($max_qty)>0){ alert('최대 구매수량은 '+$max_qty+'개 입니다.'); } else { if($pack_qty>1){ if(parseInt($ct_qty)+$pack_qty>Number($jego)){ alert('해당 상품의 재고는 '+$jego+'개 입니다.'); return; } $tr_obj.find("input[name='ct_qty[]']").val(parseInt($ct_qty)+$pack_qty); } else { $tr_obj.find("input[name='ct_qty[]']").val(parseInt($ct_qty)+1); } } }); $("#cart_list_form input[name='ct_qty[]']").change(function(){ // 장바구니 수량 직접 수정시 동작 preg_replace2("number",$(this).val(),$(this)); $parent_obj = $(this).closest("tr"); if($parent_obj.length==0){ // 모바일시 $parent_obj = $(this).closest("section"); } $min_qty = parseInt($parent_obj.find("input[name='p_min_buy[]']").val()); $max_qty = parseInt($parent_obj.find("input[name='p_max_buy[]']").val()); $pack_qty = parseInt($parent_obj.find("input[name='p_pack_buy[]']").val()); $cur_qty = parseInt($parent_obj.find("input[name='ct_qty[]']").val()); $jego = parseInt($parent_obj.find("input[name='jego[]']").val()); if($min_qty>0 && $min_qty>$cur_qty){ alert('해당 상품의 최소구매수량은 '+$min_qty+'개 입니다.'); $parent_obj.find("input[name='ct_qty[]']").val($min_qty); } else if($max_qty<$cur_qty && $max_qty>0){ alert('해당 상품의 최대구매수량은 '+$max_qty+'개 입니다.'); $parent_obj.find("input[name='ct_qty[]']").val($min_qty); } else if($jego<=$cur_qty){ alert('해당 상품의 재고는 '+$jego+'개 입니다.'); if($pack_qty>1){ $parent_obj.find("input[name='ct_qty[]']").val($min_qty); } else { $parent_obj.find("input[name='ct_qty[]']").val($jego); } } else if($pack_qty>1){ $vv = ($cur_qty-$min_qty)%$pack_qty; if($vv!=0){ alert('해당 상품의 구매 묶음단위는 '+$pack_qty+'입니다.'); $parent_obj.find("input[name='ct_qty[]']").val($min_qty); } } //sum_opt_price(); }); }); function prod_add_cnt($form_obj){ // 선택된 상품수를 리턴 $sel_cnt = 0; $form_obj.find(".sit_sel_option_class").each(function(){ $this = $(this); if($this.find("input[name='opt_code[]']").val()!=''){ // 전체 상품수 $sel_cnt++; } }); return $sel_cnt; } function prod_cart_save($mode){ // 옵션 상품 장바구니 변경 처리 if('옵션정보를 변경하시겠습니까?'){ if($mode=='list'){ $form_obj = $("#modal_member_box_opt #item_cart_form"); } else { $form_obj = $("#item_cart_form"); } form_data = $form_obj.serialize(); $.ajax({type:"post", url:"ajax.prod_cart_process.php", data:form_data, async:false, dataType : "xml", success:function(xml){ var v_mode = $(xml).find("mode").text(); var v_mode_ok = $(xml).find("mode_ok").text(); var v_msg = $(xml).find("msg").text(); if(v_mode_ok!='Y'){ alert(v_msg); } else { if($mode=='list'){ $("#modal_member_box_opt").dialog("close"); right_cart_get(); if($app_id!='csfd2019'){ alert('장바구니에 담았습니다.'); } } else { document.location.reload(); } } }, error:function(rtn,status,error){ alert(error); } }); } } function list_prod_cart_process($form_obj){ // 리스트에서 장바구니 담기시 처리 form_data = $form_obj.serialize(); $.ajax({type:"post", url:"../shop/ajax.prod_cart_process.php", data:form_data, async:false, dataType : "xml", success:function(xml){ var v_mode = $(xml).find("mode").text(); var v_mode_ok = $(xml).find("mode_ok").text(); var v_msg = $(xml).find("msg").text(); var v_dmode = $(xml).find("dmode").text(); if(v_mode_ok=='L'){ alert(v_msg); document.location.href='login.php'; } else if(v_mode_ok!='Y'){ alert(v_msg); } else { if(v_dmode=='direct'){ // 바로구매모드일 경우 document.location.href='orderform.php?dmode=direct'; } else { $("#modal_member_box_opt").dialog("close"); right_cart_get(); if($app_id!='csfd2019'){ alert('장바구니에 담았습니다.'); } } } }, error:function(rtn,status,error){ alert(error); } }); } function list_prod_wish_process($form_obj){ // 리스트에서 위시리스트 담기시 처리 form_data = $form_obj.serialize(); if($("#id_ccode").val()==''){ alert('즐겨찾기는 회원만 가능합니다.'); document.location.href='login.php'; return; } $v = prod_add_cnt($form_obj); if($v=='0'){ alert('상품을 선택하시기 바랍니다. 참고로 품절상품은 추가가 안됩니다.'); return; } form_data = $form_obj.serialize(); $.ajax({type:"post", url:"../shop/ajax.prod_wish_process.php", data:form_data, async:false, dataType : "xml", success:function(xml){ var v_mode = $(xml).find("mode").text(); var v_mode_ok = $(xml).find("mode_ok").text(); var v_msg = $(xml).find("msg").text(); if(v_mode_ok!='Y'){ alert(v_msg); } else { alert('위시리스트에 저장되었습니다.'); $(".wish_ico_off").addClass("wish_ico_on").removeClass("wish_ico_off"); } }, error:function(rtn,status,error){ alert(error); } }); } function prod_wish_save(){ // 상품리스트 옵션에서 위시리스트 기능 $form_obj = $form_obj = $("#modal_member_box_opt #item_cart_form"); list_prod_wish_process($form_obj); } function add_list_opt_info_get(code,mode){ // 리스트에서 상품옵션 선택 $box_obj = $("#modal_member_box_opt"); if(code==''){ return; } $.get("../shop/ajax.opt_sel_get.php?code="+code+"&mode="+mode,function(rtn){ console.log(rtn); $v = rtn.split("§§§"); $pcode = $v[0]; $rtn = $v[1]; if($pcode==0){ if($rtn!=''){ alert($rtn); } return; } // 품절 상품일 경우 처리 $dflag = 0; $("#modal_member_box_opt .opt_list_div").find("input[name='opt_code[]']").each(function(){ // 기존 옵션 중복 체크 if($pcode==$(this).val()){ $dflag = 1; } }); if($dflag==0){ $("#modal_member_box_opt .opt_list_div").append($rtn); //sum_opt_price(); } }); } function qstr_rmv(qstr,v){ // 쿼리스트링에서 현재 지정된 필드만 제거 vv = qstr.split("&"); v_str = ""; for(i=0;i inputMaxLength){ alert('20자리까지만 입력 가능합니다.'); //$(eventInput).val(inputText.substr(0, count)); } } function inputLengthCheckByte(eventInput){ // 한글도 2바이트 처리 var inputText = $(eventInput).val(); var inputMaxLength = $(eventInput).prop("maxlength"); var j = 0; var count = 0; for(var i = 0;i < inputText.length;i++) { val = escape(inputText.charAt(i)).length; if(val == 6){ j++; } j++; if(j <= inputMaxLength){ count++; } } if(j > inputMaxLength){ $(eventInput).val(inputText.substr(0, count)); alert('20바이트까지만 입력 가능합니다.'); } } function setsave(name, value, expiredays){ value = encodeURI(value); // 한글깨짐문제 처리 var today = new Date(); today.setDate( today.getDate() + expiredays ); document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + today.toGMTString() + ";" } function section_list_left_align($tag,$mode){ // 메인 섹션의 상품 리스트를 크기를 맞춰 처리한다. function do_left_space($tag){ $obj = $($tag); $st_width = $obj.width(); // ul의 부모창 크기 구한다. $li_width = $obj.find("ul li").outerWidth(true); // 마진을 포함한 넓이를 구한다. $col_cnt = Math.floor($st_width/$li_width); // 부모창에서 li크기를 통한 한줄 가능한 갯수 구한다. $left_space = Math.round(($st_width-($li_width*$col_cnt))/2); // 적정한 왼쪽마진을 구한다. $ul_width = ($li_width*$col_cnt); //alert($st_width+" " +$li_width+" "+$col_cnt+" "+$left_space); if($mode=='wh' || $mode=='w'){ //$obj.find("ul").css("padding-left",$left_space); // ul크기와 li크기에 맞춰서 왼쪽 마진을 처리한다. $obj.find("ul").css("width",$ul_width+"px"); // ul width크기를 주면 알아서 가운데 들어간다.ul에 .float_c{margin:0 auto} 있어야 가운데됨 } $li_height = $obj.find("ul li").outerHeight(true); // 마진을 포함한 크기를 구한다. $li_cnt = $obj.find("ul li").size(); // 총 li 갯수를 구한다. $row_cnt = Math.ceil($li_cnt/$col_cnt); // 총li와 한줄 li를 통한 몇줄 표시되는지를 구한다. $ul_height = $li_height*$row_cnt; // li크기와 몇줄을 곱한다. if($mode=='wh' || $mode=='h'){ $obj.find("ul").css("height",$ul_height+"px"); // 맞춰서 ul의 높이를 재 산정한다. } //alert($li_height+" "+$li_cnt+" "+$row_cnt); } $(window).resize(function(){ do_left_space($tag); }); do_left_space($tag); } function section_obj_left_align($tag,$align_obj){ // 특정 오브젝트를 크기 맞춰 중앙정렬한다. function do_left_space($tag,$align_obj){ $obj = $($tag); $aobj = $obj.find($align_obj); $st_width = $obj.innerWidth(); // ul의 부모창 크기 구한다. $aobj_width = 0; $aobj.each(function(){ $v = parseInt($(this).outerWidth(true)); $aobj_width = $aobj_width + $v; }); $vv = Math.round(($st_width-$aobj_width)/2); $obj.css("padding-left",$vv+"px"); } $(window).resize(function(){ do_left_space($tag,$align_obj); }); do_left_space($tag,$align_obj); } function bookmark(url,title){ // 즐겨찾기 var str = navigator.userAgent.toLowerCase(); //접속한 브라우저의 코드네임 소문자로 저장 if ( -1 != str.indexOf('msie') ) { // msie 라는 문자열이 있으면 window.external.AddFavorite(url,title); } else { alert("Ctrl+D키를 누르시면 즐겨찾기에 추가하실 수 있습니다."); } } function li_max_height_align($tag,$mode){ $max_height = 0; $($tag).each(function(){ $v = $(this).height(); //console.log($v); if($max_height<$v){ $max_height = $v; } }); $($tag).height($max_height); if($mode=='ul'){ $ul_obj = $($tag).closest("ul"); $oh = $ul_obj.outerHeight(); $ul_obj.height($oh); } if($mode=='li'){ $ul_obj = $($tag).closest("ul"); $ul_obj.height($max_height); } } function right_cart_get(){ if($("#right_cart_id").attr("id")==undefined){ return; } $.get("../shop/ajax.right_cart_get.php",function(rtn){ $("#right_cart_id").html(rtn); $ct_tot_amt = 0; $("#right_cart_id input[name='ct_tot_amt[]']").each(function(){ $ct_tot_amt = $ct_tot_amt + parseInt($(this).val()); }); $ct_tot_amt = $ct_tot_amt+""; $ct_tot_amt = number_format($ct_tot_amt); $(".right_tot_amt").html($ct_tot_amt); right_height_sync(); }); } function right_height_sync(){ function resize_do(){ $v = $(".right_cart_list").outerHeight(); $v2 = $(".right_cart_footer").outerHeight(); $v3 = parseInt($v)-parseInt($v2)-180; //alert($v+" "+$v2+" "+$v3); $("#right_wrap .right_cart_list ul").css("max-height",$v3+"px"); } $(window).resize(function(){ resize_do(); }); resize_do(); }