function setStepAttributes(e,t,n){var r=yit_woocommerce.woocommerce_ship_to_billing?t:n;e.attr("data-next",r)}(function(e,t,n){t.yit_checkout=function(e,n){this.element=t(n);this._init(e)};t.yit_checkout.defaults={steps:5,elements:{steps:t("#multistep_steps .multistep_step"),sections:t("#multistep_resume a"),progress_bar:t("#multistep_progress .bar"),ship_to_billing:{billing:t("#shiptobilling_bill-checkbox"),shipping:t("#shiptobilling-checkbox")}}};t.yit_checkout.prototype={_init:function(e){this.options=t.extend(true,{},t.yit_checkout.defaults,e);this.current_step=this.options.elements.steps.filter(".current");this.user_logged_in=this.options.elements.steps.filter(".user_logged_in").length>0;this._initEvents();this._initLabels();this._updateBar(this.current_step.data("step"))},_initLabels:function(){var e=this.element.find("input[data-alternativelabel]");e.each(function(){t(this).data({billing:t(this).val(),shipping:t(this).data("alternativelabel")})})},_initEvents:function(){var e=this.options.elements;var n=this;var r=t(this).data("step");var i=e.ship_to_billing.billing.prop("checked");if(!i){e.ship_to_billing.shipping.attr("checked","checked")}e.sections.on("click",function(e){e.preventDefault();r=t(this).data("step");var i=n.current_step.data("step");if(n._validateChangeStep(i,r)){n._gotoStep(r)}});e.steps.on("click.yit",".next, .prev",function(e){e.preventDefault();var r=t(this).attr("data-next");var i=n.current_step.data("step");if(n._validateChangeStep(i,r)){n._gotoStep(r)}});e.ship_to_billing.billing.on("click",function(r){var i=t(this).prop("checked");e.ship_to_billing.shipping.prop("checked",i).click();i=yit_woocommerce.woocommerce_ship_to_billing?i:!i;n._updateBillingShippingLabels(i)});e.ship_to_billing.shipping.on("click",function(r){var i=t(this).prop("checked");e.ship_to_billing.billing.prop("checked",!i);i=yit_woocommerce.woocommerce_ship_to_billing?!i:i;n._updateBillingShippingLabels(i)});this.element.on("slide_change.yit",function(e,n){if(n.step==4){var r=t(this).find("input[name=payment_method]:checked");t(this).find("div.payment_box."+t(r).attr("ID")).slideDown(250)}});this.element.on("click",".payment_methods input.input-radio",function(){if(t(".payment_methods input.input-radio").length>1){t("div.payment_box").filter(":visible").slideUp(250);if(t(this).is(":checked")){t("div.payment_box."+t(this).attr("ID")).slideDown(250)}}else{t("div.payment_box").show()}})},_updateBillingShippingLabels:function(e){var t=this.options.elements.steps.filter("[data-step=2]").find("input.next");var n=this.options.elements.steps.filter("[data-step=4]").find("input.prev");if(e){t.val(t.data("billing"));setStepAttributes(t,"4","3");n.val(n.data("billing"));setStepAttributes(n,"2","3")}else{t.val(t.data("shipping"));setStepAttributes(t,"3","4");n.val(n.data("shipping"));setStepAttributes(n,"3","2")}},_validateChangeStep:function(e,t){steps=this.options.steps;if(e<t&&t<=steps){return this._validateStep(t)}else if(this.user_logged_in&&t>1&&t<e){return this._validateStep(t)}else if(!this.user_logged_in&&t>0&&t<e){return this._validateStep(t)}else{return false}},_validateStep:function(e){return true},_gotoStep:function(e){var n=this.element;var r=this.options.elements.steps.filter("[data-step="+e+"]");this.current_step.fadeOut("slow",function(){r.fadeIn("slow").addClass("current");t(this).removeClass("current");n.trigger("slide_change.yit",{step:e})});this._updateSection(e);this._updateBar(e);this.current_step=r},_updateSection:function(e){var n=this.options.elements.sections;n.removeClass("current").removeClass("passed").filter("[data-step="+e+"]").addClass("current");n.filter(function(){return parseInt(t(this).data("step"))<parseInt(e)}).addClass("passed")},_updateBar:function(e){var t=(parseInt(e)+1)*100/(this.options.steps+1);this.options.elements.progress_bar.css("width",t+"%")}};t.fn.yit_checkout=function(e){if(typeof e==="string"){var n=Array.prototype.slice.call(arguments,1);this.each(function(){var r=t.data(this,"yit_checkout");if(!r){console.error("cannot call methods on yit_checkout prior to initialization; "+"attempted to call method '"+e+"'");return}if(!t.isFunction(r[e])||e.charAt(0)==="_"){console.error("no such method '"+e+"' for yit_checkout instance");return}r[e].apply(r,n)})}else{this.each(function(){var n=t.data(this,"yit_checkout");if(!n){t.data(this,"yit_checkout",new t.yit_checkout(e,this))}})}return this}})(window,jQuery)