////////////////////////////////////////////////////////////////////////////////////////////////
//			PLUGIN:		ARMY KNIFE
//			VERSION:	1.4
//			AUTHOR:		ROMAN D. PACHECO
////////////////////////////////////////////////////////////////////////////////////////////////
(function(a){var b="armyKnife",c={cssProps:{active:{marginLeft:"0%"},above:{zIndex:100},below:{zIndex:10},hiddenR:{marginLeft:"100%"},hiddenL:{marginLeft:"-100%"},fadeOut:{opacity:0},fadeIn:{opacity:1}},regex:{transition:{fadeIn:new RegExp("fade(,|$|In)","i"),fadeOut:new RegExp("fade(,|$|Out)","i"),slideIn:new RegExp("slide(,|$|In)","i"),slideOut:new RegExp("slide(,|$|Out)","i"),none:new RegExp("none(,|$)","i")}}},d={button:a("<a />",{href:"#"})},e={speed:300,sections:"> *",startingSection:0,easing:"swing",transition:"none",autoResize:false,resizeSpeed:200,autoRotate:false,autoRotateDelay:5e3,generateNav:false,navType:"empty",navItemSource:function(a){return"&nbsp;"},navItemCode:function(a){var b=d.button.clone();b.html(a);return b},navID:false,navClass:b+"-Nav",itemsPerNav:0,activeNavItemClass:"active",showSectionButtons:false,sectionButtonClass:b+"-Btn",sectionButtonCodeNext:d.button.clone(),sectionButtonCodePrev:d.button.clone(),sectionOnEnter:false,sectionOnExit:false,sectionBeforeEnter:false,sectionBeforeExit:false},f={init:function(d,g){return this.each(function(){var h=a(this),i=h.data(b);if(!i){var j=a.extend(true,{},e);j=d?a.extend(true,j,d):j;a.extend(true,j,{sectionList:[],navItems:[],currentSection:j.startingSection,targetSection:false});h.data(b,j);i=h.data(b);var k=h.find(i.sections);if(i.generateNav){f.generateNav.call(h,k)}a.each(k,function(b,d){if(b==i.startingSection){a(d).css(c.cssProps.active)}else{a(d).css(c.cssProps.hiddenR)}if(i.showSectionButtons){if(b>0){var e=i.sectionButtonCodePrev.clone();e.html()==""&&e.html("Prev");e.addClass(i.sectionButtonClass).bind("click",function(){f.prev.call(h);return false}).appendTo(a(d))}if(b<k.length-1){var g=i.sectionButtonCodeNext.clone();g.html()==""&&g.html("Next");g.addClass(i.sectionButtonClass).bind("click",function(){f.next.call(h);return false}).appendTo(a(d))}}i.sectionList.push(a(d))})}if(i.autoRotate){f.setAutoRotate.call(h)}if(i.autoResize){i.targetSection=i.currentSection;f.resizeView.call(h,g)}else{if(typeof g=="function"){g()}}if(typeof i.sectionBeforeEnter=="function"){i.sectionBeforeEnter.call(i.sectionList[i.currentSection],i.currentSection,i.currentSection,i.sectionList)}if(typeof i.sectionOnEnter=="function"){i.sectionOnEnter.call(i.sectionList[i.currentSection],i.currentSection,i.currentSection,i.sectionList)}})},generateNav:function(c){var e=this,g=e.data(b);if(g){g.nav=a("<div />");var h=g.itemsPerNav,i=a("<ul />",{"class":g.navClass}),j=c;if(g.itemsPerNav==0){h=c.length}var k=0;while(j.length){var l=i.clone();c=j;a.each(c,function(b,i){if(b>=h){return false}var m=a("<li />"),n=d.button.clone(),i=c[b];switch(g.navType){case"numeric":n.html(parseFloat(b+1));break;case"text":var o=g.navItemSource(a(i))||g.navItemSource;n.html(o);break;case"custom":var o=g.navItemSource(a(i))||g.navItemSource,p=g.navItemCode(o)||g.navItemCode;n=p;break;default:n.html("&nbsp;")}l.append(m);m.append(n);n.bind("click",{i:k},function(a){f["goto"].call(e,a.data.i);return false});if(b==g.startingSection){m.addClass(g.activeNavItemClass)}g.navItems.push(m);j=j.filter(function(a){return j[a]!=i});k++});g.nav.append(l)}if(g.nav.children().length==1){g.nav=a(g.nav.children()[0])}if(g.navID){if(a("#"+g.navID).length){a("#"+g.navID).replaceWith(g.nav)}else{e.after(g.nav)}g.nav.attr("id",g.navID)}else{e.after(g.nav)}}},setAutoRotate:function(){return this.each(function(){var c=a(this),d=c.data(b);if(d){clearTimeout(d.autoRotateInterval);d.autoRotateInterval=setTimeout(function(){if(typeof d.isAnimating=="undefined"||d.isAnimating.isResolved()){f.next.call(c)}else{if(!d.isAnimating.isResolved()){a.when(d.isAnimating).then(function(){f.next.call(c)})}}},d.autoRotateDelay)}})},resizeView:function(c){return this.each(function(){var d=a(this),e=d.data(b);if(e){var f=d.height(),g=e.sectionList[e.targetSection].outerHeight();if(f!=g){d.animate({height:g},e.resizeSpeed,function(){if(typeof c=="function"){c()}})}else{if(typeof c=="function"){c()}}}})},"goto":function(c){return this.each(function(){var d=a(this),e=d.data(b);if(e&&c!=e.currentSection&&(typeof e.isAnimating=="undefined"||e.isAnimating.isResolved())){e.isAnimating=new a.Deferred;if(e.autoRotate){f.setAutoRotate.call(d)}e.targetSection=c;var g=c<e.currentSection?"right":"left";if(e.autoResize){f.resizeView.call(d,function(){f.animate.call(d,g)})}else{f.animate.call(d,g)}}})},next:function(){return this.each(function(){var c=a(this),d=c.data(b);if(d&&d.sectionList[d.currentSection]&&(typeof d.isAnimating=="undefined"||d.isAnimating.isResolved())){d.isAnimating=new a.Deferred;if(d.autoRotate){f.setAutoRotate.call(c)}d.targetSection=d.sectionList[d.currentSection+1]?d.currentSection+1:0;if(d.autoResize){f.resizeView.call(c,function(){f.animate.call(c)})}else{f.animate.call(c)}}})},prev:function(){return this.each(function(){var c=a(this),d=c.data(b);if(d&&d.sectionList[d.currentSection]&&(typeof d.isAnimating=="undefined"||d.isAnimating.isResolved())){d.isAnimating=new a.Deferred;if(d.autoRotate){f.setAutoRotate.call(c)}d.targetSection=d.sectionList[d.currentSection-1]?d.currentSection-1:d.sectionList.length-1;if(d.autoResize){f.resizeView.call(c,function(){f.animate.call(c,"right")})}else{f.animate.call(c,"right")}}})},animate:function(d,e){e=!!e?e:function(){};return this.each(function(){var f=a(this),g=f.data(b);d=!!d?d:"left";if(g&&g.sectionList[g.currentSection]&&g.sectionList[g.targetSection]){if(typeof g.sectionBeforeExit=="function"){g.sectionBeforeExit.call(g.sectionList[g.currentSection],g.currentSection,g.targetSection,g.sectionList)}if(typeof g.sectionBeforeEnter=="function"){g.sectionBeforeEnter.call(g.sectionList[g.targetSection],g.targetSection,g.currentSection,g.sectionList)}g.sectionList[g.currentSection].css(c.cssProps.below);var h=c.cssProps.active;if(g.transition.match(c.regex.transition.slideOut)||g.transition.match(c.regex.transition.none)){h=d=="left"?c.cssProps.hiddenL:c.cssProps.hiddenR}var i=a.extend(true,{},h);!!g.transition.match(c.regex.transition.fadeOut)&&a.extend(true,i,c.cssProps.fadeOut);if(g.transition.match(c.regex.transition.none)){g.sectionList[g.currentSection].css(i);e()}else{g.sectionList[g.currentSection].animate(i,g.speed,g.easing,e)}if(g.transition.match(c.regex.transition.fadeIn)){g.sectionList[g.targetSection].css(c.cssProps.fadeOut)}else{g.sectionList[g.targetSection].css(c.cssProps.fadeIn)}g.sectionList[g.targetSection].css(c.cssProps.above);var j=c.cssProps.active;if(g.transition.match(c.regex.transition.slideIn)||g.transition.match(c.regex.transition.none)){j=d=="left"?c.cssProps.hiddenR:c.cssProps.hiddenL}g.sectionList[g.targetSection].css(j);var k=a.extend(true,{},c.cssProps.active);!!g.transition.match(c.regex.transition.fadeIn)&&a.extend(true,k,c.cssProps.fadeIn);if(g.transition.match(c.regex.transition.none)){g.sectionList[g.targetSection].css(k);g.isAnimating.resolve();e();if(typeof g.sectionOnExit=="function"){g.sectionOnExit.call(g.sectionList[g.currentSection],g.currentSection,g.targetSection,g.sectionList)}if(typeof g.sectionOnEnter=="function"){g.sectionOnEnter.call(g.sectionList[g.targetSection],g.targetSection,g.currentSection,g.sectionList)}}else{g.sectionList[g.targetSection].animate(k,g.speed,g.easing,function(){g.isAnimating.resolve();e();if(typeof g.sectionOnExit=="function"){g.sectionOnExit.call(g.sectionList[g.currentSection],g.currentSection,g.targetSection,g.sectionList)}if(typeof g.sectionOnEnter=="function"){g.sectionOnEnter.call(g.sectionList[g.targetSection],g.targetSection,g.currentSection,g.sectionList)}})}if(g.nav){g.nav.find("."+g.activeNavItemClass).removeClass(g.activeClass);g.navItems[g.targetSection].addClass(g.activeNavItemClass)}g.currentSection=g.targetSection}})}};a.fn[b]=function(b){if(f[b]){return f[b].apply(this,Array.prototype.slice.call(arguments,1))}else if(!b||typeof b=="object"){return f.init.apply(this,arguments)}else{a.error(c.pluginName+": Invalid method passed")}}})(jQuery);

