(function($){$.modules.shoppingcart=function(opts){$(document).ready(function(){var $p=$('.cc-checkout-paymentoption');if($p.length){$p.find('input:first').attr('checked','checked');}
$('.cc-quantity-plus').click(function(){var input=$(this).parent().prev('input');updateCountInCart(input,upcountItem(input));return false;});$('.cc-quantity-minus').click(function(){var input=$(this).parent().prev('input');updateCountInCart(input,downcountItem(input));return false;});$('.cc-quantity').blur(function(){updateCountInCart($(this),parseInt($(this).val()));});$('.cc-quantity-delete').click(function(){removeFromCart($(this).attr('data-product'),$(this).attr('data-variant'),'all');return false;});if(!opts.reloaded){$('#cc-checkout-paymentmethod-form').submit(function(){if($(this).find('input[name="payment_method"]:checked').val()=='32'){$('.cc-checkout-paymentoption-paypalimage').click();return false;}});$('.cc-checkout-paymentoption-paypalimage').click(function(){var el=$(this);$('#cc-checkout-submit-1').val(opts.buttontext.wait).attr('disabled','disabled');$.post('/app/shop/checkout/doexpresscheckout',{totalPrice:$('#cc-checkout').attr('data-price'),currency:$('#cc-checkout').attr('data-currency')},function(r){if(r.status==='success'){window.location=opts.paypalUrl+'&token='+r.token;}else{$('#cc-checkout-paypal-error').show(500);$('#cc-checkout-submit-1').val(opts.buttontext.next).attr('disabled',false);}},'json');return false;});$('#cc-checkout-address-checkbox').click(function(){$('#cc-checkout-billing-address-form').toggle();$('#cc-checkout-billing-address-form-heading').toggle();$as=$('#cc-checkout-address-head-same');$ad=$('#cc-checkout-address-head-differs');if($(this).is(':checked')){$ad.show();$as.hide();}else{$as.show();$ad.hide();}});}
function updateCountInCart(input,newcount){if($('#cc-sidecart').children().length){$('#cc-sidecart').addClass('cc-cart-loading');}
if($('#cc-checkout').length){$('#cc-checkout').addClass('cc-cart-loading');}
$.post('/app/shop/shoppingcart/updatecount',{product_id:input.attr('data-product'),row:input.attr('data-variant'),newcount:newcount},function(r){if($('#cc-sidecart').children().length){$('#cc-sidecart').replaceWith(r.cart);}
if($('#cc-checkout').length){$('#cc-checkout').replaceWith(r.checkout);}
reloadScript();},'json');}
function removeFromCart(productId,row,mode){$('#cc-checkout').addClass('cc-cart-loading');$.post('/app/shop/shoppingcart/remove',{product_id:productId,row:row,mode:mode},function(r){$('#cc-checkout').replaceWith(r.checkout);reloadScript();},'json');}
function upcountItem(input){return parseInt(input.val())+1;}
function downcountItem(input){if(parseInt(input.val())!==0){return parseInt(input.val())-1;}
return 0;}
function reloadScript(){opts.reloaded=true;$(window).triggerHandler('register',['module','shoppingcart',opts]);}});};})(jimdoGen002);
