(function(a){function e(d,e,f,g,h){if(g=="next"){np="-="+e.outerWidth(true)}else{np="+="+e.outerWidth(true)}e.each(function(i){i++;var j=i+1;var k=i-1;if(b(a(this),a(this).closest(f))==0){if(g=="next"){f.animate({height:e.eq(c(e,f)).next(e).height()+"px"},200,function(){d.animate({left:np},200,function(){e.eq(c(e,f)).find("input:first").focus();a('[rel_form="'+f.attr("id")+'"][rel^="fstep_"]').removeClass(h);a('[rel_form="'+f.attr("id")+'"][rel="fstep_'+j+'"]').addClass(h)})})}else{f.animate({height:a(this).prev(e).height()+"px"},200,function(){d.animate({left:np},200,function(){e.eq(c(e,f)).find("input:first").focus();a('[rel_form="'+f.attr("id")+'"][rel^="fstep_"]').removeClass(h);a('[rel_form="'+f.attr("id")+'"][rel="fstep_'+k+'"]').addClass(h)})})}}})}function c(c,e){e.find(c).each(function(c){if(b(a(this),a(this).closest(e))==0){d=c}});return d}function b(a,b){var c=a.offset().left-b.offset().left;c=c-(b.outerWidth()-b.innerWidth())/2;return c}a.fn.StepizeForm=function(d){var f={Text_Next:"Next",Text_Prev:"Prev",Text_Submit:"Submit",Class_Prev:"myButton",Class_Next:"myButton",Class_Submit:"myButton",Class_Highlight:"step_highlight"};var d=a.extend(f,d);return this.each(function(){var f=d,g=a(this),h=g.find('[id*="fstep_"]');h.wrapAll('<div class="container_steps" style="position:relative" />').append('<div style="clear:both"></div>');g.wrap('<div class="container_form" />');var i=g.find(".container_steps"),j=g.closest(".container_form");j.append('<span type="button" class="fprev '+f.Class_Prev+'" style="display:none">'+f.Text_Prev+"</span>"+'<span type="button" class="fnext '+f.Class_Next+'">'+f.Text_Next+"</span>"+'<span type="submit" class="fsubmit '+f.Class_Submit+'" style="display:none">'+f.Text_Submit+"</span>");var k=j.find(".fnext"),l=j.find(".fprev"),m=j.find(".fsubmit");g.find("button:submit,input:submit").remove();g.css({height:g.find('[id^="fstep_"]:first').height()+"px",overflow:"hidden",width:g.outerWidth(true),border:"none",padding:"0px",margin:"0px"});h.css({width:g.outerWidth(true),overflow:"auto",border:"none",padding:"0px",margin:"0px","float":"left"});i.css({width:g.outerWidth(true)*h.length+"px",border:"none",padding:"0px",margin:"0px"});a('[rel_form="'+g.attr("id")+'"]:first').addClass(f.Class_Highlight);if(a().validate){g.validate()}k.click(function(){var d=h.eq(c(h,g));if(a().validate){g.valid()}if(d.find(".error:visible").length==0){if(a().validate)g.validate().resetForm();e(i,h,g,"next",f.Class_Highlight);l.fadeIn("slow");if(b(h.eq(h.length-2),h.eq(h.length-2).closest(g))==0){k.hide();m.fadeIn("slow")}}else{g.animate({height:d.height()+"px"},200)}});l.click(function(){if(a().validate)g.validate().resetForm();e(i,h,g,"prev",f.Class_Highlight);k.fadeIn("slow");m.hide();if(b(h.eq(1),h.eq(1).closest(g))==0){l.hide()}});h.find("input").live("keydown",function(a){if(a.which==13){if(b(h.eq(h.length-1),h.eq(h.length-1).closest(g))==0){m.click()}else{k.click()}}});a('[rel_form="'+g.attr("id")+'"]').click(function(d){if(a().validate){g.valid()}var e=h.eq(c(h,g));if(a("#"+a(this).attr("rel")).prevAll().find(".error:visible").length==0){if(a().validate)g.validate().resetForm();if(a(this).attr("rel_form")!="undefined"){h.not(e).find("label.error").remove();h.not(e).find(".error").removeClass("error");a('[rel_form="'+g.attr("id")+'"]').removeClass(f.Class_Highlight);a(this).addClass(f.Class_Highlight);d=a("#"+g.attr("id"));var j=g.find("#"+a(this).attr("rel")).prevAll().length*d.outerWidth(true);d.animate({height:a("#"+a(this).attr("rel")).height()+"px"},200,function(){i.animate({left:-j},100,function(){if(b(h.eq(0),h.eq(0).closest(g))==0){l.hide();m.hide();k.fadeIn("slow")}else if(b(h.eq(h.length-1),h.eq(h.length-1).closest(g))==0){k.hide();m.fadeIn("slow");l.fadeIn("slow")}else{k.fadeIn("slow");l.fadeIn("slow");m.hide()}h.eq(c(h,g)).find("input:first").focus()})})}}else{var n=h.find(".error:visible").closest(h).attr("id");a('[rel_form="'+g.attr("id")+'"][rel="'+n+'"]').click();if(a().validate){g.valid()}}});m.click(function(){if(a().validate){g.valid()}if(h.eq(c(h,g)).find(".error:visible").length==0){g.submit()}else{g.animate({height:h.eq(c(h,g)).height()+"px"},200)}})})}})(jQuery)
