/* カート用 */ ATcart = function(){ }; ATcart.loadFlag = 1; ATcart.price = new Array(); ATcart.carriage = new Array(); ATcart.free = new Array(); ATcart.list = new Array(); ATcart.nogoods = 1; ATcart.ajax = 0; ATcart.error = ""; ATcart.shop_mode = { "mode":"","gid":"","popup":"0","category":"0","direct":"0"}; ATcart.manual = '1'; //MakeForm2onDefault = function(){} ATcart.starter = function(){ if(typeof jQuery == "undefined"){ var script = document.createElement("script"); script.type= "text/javascript"; script.src = "http://www.14-seikatsu.com/netshop/atnetshop_img/jquery/jquery.js"; //document.body.appendChild(script); document.getElementsByTagName("head")[0].appendChild(script); _atcart_start = function(){ if( typeof jQuery != "undefined" ){ ATcart.setContent(); }else{ setTimeout( _atcart_start, 10 ); } }; setTimeout( _atcart_start, 10 ); }else{ ATcart.setContent(); } } ATcart.winLoad = function (func){ if (window.addEventListener) { //for W3C DOM if( window.onpageshow ){ window.addEventListener("pageshow", func, false); }else{ window.addEventListener("load", func, false); } }else if (window.attachEvent) { //for IE window.attachEvent("onload", func); }else { window.onload = func; } } ATcart.setContent = function(){ var Obj = document.getElementsByTagName('span'); for(i=0; i < Obj.length; i++){ var myObj = Obj[i]; var idName =myObj.id; if( idName.match(/atcart_p_(\d+)/g) ){ ATcart.setPrice(RegExp.$1,myObj); } if( idName.match(/atcart_r_(\d+)/g) ){ ATcart.setRest(RegExp.$1,myObj); } } $('span').each(function(){ if( typeof $(this).attr( "class" ) !== "undefined" ){ if( $(this).attr('class').match(/atcart_p_(\d+)/) ){ ATcart.setPriceJ(RegExp.$1,this); } if( $(this).attr('class').match(/atcart_r_(\d+)/) ){ ATcart.setRestJ(RegExp.$1,this); } } }); if( ATcart.shop_mode.direct > 0 ){ $("#toTop").hide(); } // 金額表示 ATcart.put(); } ATcart.setPrice = function(plan,obj){ ATcart.price.push(plan); var i = ATcart.price.length -1; var myName = "atcart_price_"+i; $('#'+obj.id).attr({"id":myName}); } ATcart.setRest = function(plan,obj){ ATcart.free.push(plan); var i = ATcart.free.length -1; var myName = "ATcart_free_"+i; $('#'+obj.id).attr({"id":myName}); } ATcart.setPriceJ = function(plan,obj){ ATcart.price.push(plan); var i = ATcart.price.length -1; var myName = "atcart_price_"+i; $(obj).attr({"id":myName}); } ATcart.setRestJ = function(plan,obj){ ATcart.free.push(plan); var i = ATcart.free.length -1; var myName = "ATcart_free_"+i; $(obj).attr({"id":myName}); } ATcart.put = function(){ var rnd = Math.random(); var url = "http://www.14-seikatsu.com/netshop/acc.cgi?callback=?"; var data = { "mode": "cart_in", "action": "get", "plan": '0', "shop_mode": ATcart.shop_mode.mode, "g_oclick": ATcart.shop_mode.gid, "cg" : ATcart.shop_mode.category, "manual" : ATcart.manual, "rnd": rnd }; callback = function(json){ if( json && json["total"] ){ ATcart.putPrice(json["total"]); } if( json && json["rest"] ){ ATcart.putRest(json["rest"]); } if( json && json['payment'] ){ $("#payment"+json['payment']).attr({'checked':'checked'}); } for(var i=1;i<=5;i++ ){ if( json['option'+i] ) $("#option"+i).attr({'checked':'checked'}); } ATcart.next(json["ok"]); if( ATcart.manual && typeof json["goods_info"] != "undefined" ){ ATcart.manual_put(json["goods_info"]); } } if( typeof ATcart.manual != "undefined" && ATcart.manual > 0 ){ var _mplans = ""; var _check = {}; $("[id^=button_]").each(function(){ if( $(this).attr('id').match(/^button_(\d+)_(.+)$/) ){ var _pid = RegExp.$1; if( typeof _check[_pid] == "undefined" ){ _mplans += _pid + '_'; } _check[_pid] = 'ok'; } }); if( _mplans != "" ){ data.mplans = _mplans; } } /*q = ""; $.each( data, function(i,o){ q += i +'='+ o + '&'; }); alert( url + q );*/ $.getJSON( url, data ); } ATcart.manual_put = function(json){ // 数量 $('select').each(function(){ if( typeof $(this).attr( "id" ) !== "undefined" ){ var _idname = $(this).attr('id'); if( typeof json[_idname] != "undefined" ){ $("#"+_idname + ' option').each(function(){ $(this).remove(); }); var v = json[_idname]; var _rest = new Array(); if( v["number_config"] == 0 ){ for(t=0; t 0 ){ if( _obj["stock"] > 0 ){ $(this).hide(); $("#button_"+_idname).attr({"disabled":false}); }else{ $(this).show(); document.getElementById( "button_"+_idname ).onclick=function(){return false;}; } }else{ $("#button_"+_idname).attr({"disabled":false}); $(this).hide(); } }else{ $(this).hide(); } } }); // 残り表示 $("[id^=goods_stock_disp_]").each(function(){ var _id = $(this).attr("id"); if( _id.match(/^goods_stock_disp_(.+)$/) ){ var _idname = RegExp.$1; if( typeof json[_idname] != "undefined" && json[_idname]["stock"]>0 ){ var _obj = json[_idname]; if( _obj["stock_config"] > 0 && _obj["stock_disp_config"] > 0 ){ $("#goods_stock_"+_idname).html(_obj["stock"]); $(this).show(); }else{ $(this).hide(); } }else{ $(this).hide(); } } }); } ATcart.cartIn = function (plan,goods,e,manual){ if( ATcart.ajax ){ setTimeout( ATcart.cartIn, 500, plan,goods,e, manual ); return; } ATcart.ajax = 1; var objname = manual > 0 ? plan + '_' + goods: goods; var n = document.getElementById(objname) ? document.getElementById(objname).value: 1; var rnd = Math.random(); //var action_mode = ATcart.shop_mode.mode == 'oneclick' ? 'oneclick_cartin': 'in'; var src = "http://www.14-seikatsu.com/netshop/acc.cgi"; var data = { "mode": "cart_in", "action" : "in", "id" : plan, "i" : goods, "n" : n, "rnd" : rnd, "shop_mode": ATcart.shop_mode.mode, "g_oclick" : ATcart.shop_mode.gid, "cg" : ATcart.shop_mode.category }; for(i=1;i<=5;i++ ){ var option_name = objname +'_option'+i; var option_prop = goods +'_option'+i; if( $( "#"+option_name ) != null ){ if( $( "#"+option_name ).val() != "" ){ data[option_prop] = $( "#"+option_name ).val(); } } } $("#cartin_message_"+objname).hide(); callback = function(json){ ATcart.ajax = 0; if( json["total"] ){ ATcart.putPrice(json["total"]); } if( json["rest"] ){ ATcart.putRest(json["rest"]); } if( typeof json['stocknumber'] != "undefined" ){ $("#"+objname + ' option').each(function(){ $(this).remove(); }); var select_box = document.getElementById(objname); if( json['stocknumber'] == 0 ){ select_box.options[0] = new Option( 0, 0 ); }else{ for(var i=0; i 0 ){ $('div').each(function(){ if( $(this).attr('id') ){ if( $(this).attr('id').match(/^cartin_message_/) ){ $(this).hide(); } } }); $("#cartin_message_"+objname).show(); }else{ if( ATcart.shop_mode.mode == 'oneclick' ){ var href = src +'?mode=cart_in&id='+ plan + '&ocs=' + ATcart.shop_mode.gid; if( ATcart.shop_mode.category > 0 ){ href += '&cg=1'; } if( ATcart.shop_mode.popup > 0 ) href += '&pu=1'; location.href = href; return; } location.href = src + '?mode=cart_in&id='+ plan; } if( json["cartin_config"] == 2 ){ e.disabled = true; } } $.getJSON( src + '?callback=?', data ); } ATcart.cartIn_manual = function (plan,goods,e){ ATcart.cartIn(plan,goods,e,1); } ATcart.putPrice = function(data){ var len = ATcart.price.length; for(var i=0;i 0 ){ for( i=0; i json['stock'] ? def: json['stock']; $("#"+ id + ' option' ).each( function(){ $(this).remove(); }); var select_box = document.getElementById(id); for( var i=0; i 0 && typeof json['stockover'] != "undefined" ){ $(this).show(); }else{ $(this).hide(); } } if( $(this).attr('id').match(re_nostock) ){ if( ! json['stock'] && typeof json['stockover'] != "undefined" ){ $(this).show(); }else{ $(this).hide(); } } } }); if( typeof json['stockover'] != "undefined" ){ $("span").each( function(){ var re_goods_stock = new RegExp("^goods_stock_" + json['gid'] ); if( $(this).attr('id') ){ if( $(this).attr('id').match(re_goods_stock) ){ $(this).html(json['stock']); } } }); } if( json["delete"] ){ $("#"+'tr_'+json["delete"]).hide(); if( json["goods"] <= 0 ){ $("#tr_cartgoods_non").show(); $("#tr_cartgoods_total").hide(); $("#carriage").hide(); $("#payments").hide(); $("#options").hide(); $("#total").hide(); } } /* 送料 */ ATcart.carriage_dom(json,plan); $("#error_message_autodel").hide(); $("#next").attr({'disabled':false}); }); } ATcart.del = function (plan,goods){ if( ATcart.ajax ){ //setTimeout( ATcart.del, 500, plan,goods ); return; } ATcart.ajax = 1; if( confirm('削除します。\nよろしいですか?') == false ) return; $("#next").attr({'disabled':true}); var rnd = Math.random(); var src = "http://www.14-seikatsu.com/netshop/acc.cgi"; var data = { "mode": "cart_in", "action" : "del", "id" : plan, "i" : goods, "rnd" : rnd, "shop_mode" : ATcart.shop_mode.mode, "cg" : ATcart.shop_mode.category, "g_oclick" : ATcart.shop_mode.gid }; $.getJSON( src, data, function(json){ if( json["total"] ){ ATcart.putPrice(json["total"]); } // 税金 ATcart.tax(json["change"]); if( json["change"] ){ ATcart.result(json["change"]); } if( json["delete"] ){ $("#"+'tr_'+json["delete"]).hide(); } if( json["rest"] ){ ATcart.putRest(json["rest"]); } if( typeof json['nostock'] != "undefined" ){ $("#error_message_nostock").show(); }else{ $("#error_message_nostock").hide(); } $("div").each( function(){ var re_err = new RegExp("^error_" + json['gid'] ); var re_stock = new RegExp("^stock_" + json['gid'] ); var re_nostock = new RegExp("^nostock_" + json['gid'] ); if( $(this).attr('id') ){ if( $(this).attr('id').match(re_err) ){ if( typeof json['stockover'] != "undefined" ){ $(this).show(); }else{ $(this).hide(); } } if( $(this).attr('id').match(re_stock) ){ if( json['stock'] > 0 && typeof json['stockover'] != "undefined" ){ $(this).show(); }else{ $(this).hide(); } } if( $(this).attr('id').match(re_nostock) ){ if( ! json['stock'] && typeof json['stockover'] != "undefined" ){ $(this).show(); }else{ $(this).hide(); } } } }); if( typeof json['stockover'] != "undefined" ){ $("span").each( function(){ var re_goods_stock = new RegExp("^goods_stock_" + json['gid'] ); if( $(this).attr('id') ){ if( $(this).attr('id').match(re_goods_stock) ){ $(this).html(json['stock']); } } }); } $("#error_message_sizeover").hide(); /* 送料 */ ATcart.carriage_dom(json,plan); if( json["goods"] <= 0 ){ $("#tr_cartgoods_non").show(); $("#tr_cartgoods_total").hide(); $("#carriage").hide(); $("#payments").hide(); $("#options").hide(); $("#total").hide(); } $("#error_message_autodel").hide(); $("#next").attr({'disabled':false}); ATcart.next(json["ok"]); ATcart.ajax = 0; }); } ATcart.tax = function(data){ if( data["goods_taxtotal"] > 0 ){ $("#goods_taxtotal_area").show(); }else{ $("#goods_taxtotal_area").hide(); } } ATcart.carriage = function(plan,e){ var rnd = Math.random(); var src = "http://www.14-seikatsu.com/netshop/acc.cgi"; var data = { "mode": "cart_in", "action" : "carriage", "id" : plan, "carriage": e.value, "rnd" : rnd, "shop_mode": ATcart.shop_mode.mode, "gid": ATcart.shop_mode.gid }; $.getJSON( src, data, function(json){ // 税金 ATcart.tax(json["change"]); if( json["change"] ){ ATcart.result(json["change"]); } ATcart.next(json["ok"]); }); } ATcart.carriage_dom = function(json,plan){ $("#tr_carriage_free").hide(); $("#tr_carriage_cost").hide(); $("#tr_carriage_goods").hide(); $("#tr_carriage_rest").hide(); $("#tr_carriage_after").hide(); $("#tr_carriage_total").hide(); if( json["carriage_area"] > 0 ){ $("#tr_carriage_after").show(); }else{ if( json["carriage_config"] == 0 ){ $("#tr_carriage_free").show(); } if( json["carriage_config"] == 1 ){ $("#tr_carriage_cost").show(); } if( json["carriage_goods_total"] > 0 ){ $("#tr_carriage_goods").show(); $("#tr_carriage_free").hide(); } $("#tr_carriage_total").show(); } if( json["rest"] ){ if( typeof json['rest'][plan] != "undefined" ){ if( json['rest'][plan] <= 0 ){ $("#tr_carriage_free").hide(); $("#tr_carriage_cost").hide(); $("#tr_carriage_goods").hide(); $("#tr_carriage_rest").show(); $("#tr_carriage_after").hide(); } } } } ATcart.carriage_rest = function(r,c){ if( r > 0 ){ if( c == 1 ){ $("#tr_carriage_cost").show(); $("#tr_carriage_area").hide(); } if( c == 2 ){ $("#tr_carriage_cost").hide(); $("#tr_carriage_area").show(); } $("#tr_carriage_rest").hide(); }else{ $("#tr_carriage_cost").hide(); $("#tr_carriage_area").hide(); $("#tr_carriage_rest").show(); } } ATcart.payment = function(plan,e){ $("#next").attr({'disabled':true}); var rnd = Math.random(); var src = "http://www.14-seikatsu.com/netshop/acc.cgi"; var data = { "mode": "cart_in", "action" : "payment", "id" : plan, "payment": e.value, "rnd" : rnd, "shop_mode": ATcart.shop_mode.mode, "g_oclick": ATcart.shop_mode.gid, "cg" : ATcart.shop_mode.category }; $.getJSON( src, data, function(json){ // 税金 ATcart.tax(json["change"]); if( json["change"] ){ ATcart.result(json["change"]); } $("#next").attr({'disabled':false}); ATcart.next(json["ok"]); }); } ATcart.option = function(plan,e){ if( ATcart.ajax ){ setTimeout( ATcart.option, 100, plan,e ); return; } ATcart.ajax = 1; $("#next").attr({'disabled':true}); var checked = e.checked ? 1: 0; var rnd = Math.random(); var src = "http://www.14-seikatsu.com/netshop/acc.cgi"; var data = { "mode": "cart_in", "action" : "option", "id" : plan, "option": e.name, "checked": checked, "rnd" : rnd, "shop_mode": ATcart.shop_mode.mode, "g_oclick": ATcart.shop_mode.gid, "cg" : ATcart.shop_mode.category }; $.getJSON( src, data, function(json){ // 税金 ATcart.tax(json["change"]); if( json["change"] ){ ATcart.result(json["change"]); } $("#next").attr({'disabled':false}); ATcart.ajax = 0; }); } ATcart.result = function(data){ $.each(data,function(o,v){ $("#"+o).html(ATcart.comma(v)); }); } ATcart.next = function(f){ if( f > 0 ){ $("#next").attr('disabled',false); }else{ $("#next").attr('disabled',true); } } ATcart.comma = function( str ){ var to = String( str ); var tmp = ""; while (to != (tmp = to.replace(/^([+-]?\d+)(\d\d\d)/,"$1,$2"))) { to = tmp; } return to; } ATWEB = {}; ATWEB.back = function(href,top_page){ if( ATcart.manual > 0 ){ var href = ''; location.href = href; } if( ATcart.shop_mode.mode == 'oneclick' && ATcart.shop_mode.direct <= 0 ){ href += '&ocl=1'; href += '&gid='+ ATcart.shop_mode.gid; if( ATcart.shop_mode.category > 0 ) href += '&cg=1'; if( ATcart.shop_mode.popup > 0 ) href += '&pu=1'; }else if( top_page != "" ){ href = top_page; } location.href = href; } ATWEB.confirm = function(s,m,href,ocs){ s.disabled = true; s.value = m; if( ocs != "" ) href += '&ocs='+ocs; if( ATcart.shop_mode.category > 0 ) href += '&cg=1'; if( ATcart.shop_mode.direct > 0 ) href += '&dt=1'; location.href = href; } ATcart.winLoad(ATcart.starter); window.onunload = function(){}; ATcart.debug = function(o){ q = ""; $.each( data, function(i,o){ q += i +'='+ o + '&'; }); alert( src +'?' + q ); }