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