/* jQuery zAccordion Plugin v2.1.0 Copyright (c) 2010 - 2012 Nate Armagost, http://www.armagost.com/zaccordion Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ (function(a){a.fn.zAccordion=function(e){var d={timeout:6000,width:null,slideWidth:null,tabWidth:null,height:null,startingSlide:0,slideClass:null,easing:null,speed:1200,auto:true,trigger:"click",pause:true,invert:false,animationStart:function(){},animationComplete:function(){},buildComplete:function(){},errors:false},c={displayError:function(g,f){if(window.console&&f){console.log("zAccordion: "+g+".")}},findChildElements:function(f){if(f.children().get(0)===undefined){return false}else{return true}},getNext:function(g,h){var f=h+1;if(f>=g){f=0}return f},fixHeight:function(f){if((f.height===null)&&(f.slideHeight!==undefined)){f.height=f.slideHeight;return true}else{if((f.height!==null)&&(f.slideHeight===undefined)){return true}else{if((f.height===null)&&(f.slideHeight===undefined)){return false}}}},getUnits:function(f){if(f!==null){if(f.toString().indexOf("%")>-1){return"%"}else{if(f.toString().indexOf("px")>-1){return"px"}else{return"px"}}}},toInteger:function(f){if(f!==null){return parseInt(f,10)}},sizeAccordion:function(f,g){if((g.width===undefined)&&(g.slideWidth===undefined)&&(g.tabWidth===undefined)){c.displayError("width must be defined",g.errors);return false}else{if((g.width!==undefined)&&(g.slideWidth===undefined)&&(g.tabWidth===undefined)){if((g.width>100)&&(g.widthUnits==="%")){c.displayError("width cannot be over 100%",g.errors);return false}else{g.slideWidthUnits=g.widthUnits;g.tabWidthUnits=g.widthUnits;if(g.widthUnits==="%"){g.tabWidth=100/(f.children().size()+1);g.slideWidth=100-((f.children().size()-1)*g.tabWidth)}else{g.tabWidth=g.width/(f.children().size()+1);g.slideWidth=g.width-((f.children().size()-1)*g.tabWidth)}return true}}else{if((g.width===undefined)&&(g.slideWidth!==undefined)&&(g.tabWidth===undefined)){c.displayError("width must be defined",g.errors);return false}else{if((g.width===undefined)&&(g.slideWidth===undefined)&&(g.tabWidth!==undefined)){c.displayError("width must be defined",g.errors);return false}else{if((g.width!==undefined)&&(g.slideWidth===undefined)&&(g.tabWidth!==undefined)){if(g.widthUnits!==g.tabWidthUnits){c.displayError("Units do not match",g.errors);return false}else{if((g.width>100)&&(g.widthUnits==="%")){c.displayError("width cannot be over 100%",g.errors);return false}else{if((((f.children().size()*g.tabWidth)>100)&&(g.widthUnits==="%"))||(((f.children().size()*g.tabWidth)>g.width)&&(g.widthUnits==="px"))){c.displayError("tabWidth too large for accordion",g.errors);return false}else{g.slideWidthUnits=g.widthUnits;if(g.widthUnits==="%"){g.slideWidth=100-((f.children().size()-1)*g.tabWidth)}else{g.slideWidth=g.width-((f.children().size()-1)*g.tabWidth)}return true}}}}else{if((g.width!==undefined)&&(g.slideWidth!==undefined)&&(g.tabWidth===undefined)){if(g.widthUnits!==g.slideWidthUnits){c.displayError("Units do not match",g.errors);return false}else{if((g.width>100)&&(g.widthUnits==="%")){c.displayError("width cannot be over 100%",g.errors);return false}else{if(g.slideWidth>=g.width){c.displayError("slideWidth cannot be greater than or equal to width",g.errors);return false}else{if((((f.children().size()*g.slideWidth)<100)&&(g.widthUnits==="%"))||(((f.children().size()*g.slideWidth)h.timeout){c.displayError("Speed cannot be greater than timeout",h.errors);return false}else{h.heightUnits=c.getUnits(h.height);h.height=c.toInteger(h.height);h.widthUnits=c.getUnits(h.width);h.width=c.toInteger(h.width);h.slideWidthUnits=c.getUnits(h.slideWidth);h.slideWidth=c.toInteger(h.slideWidth);h.tabWidthUnits=c.getUnits(h.tabWidth);h.tabWidth=c.toInteger(h.tabWidth);if(h.slideClass!==null){h.slideOpenClass=h.slideClass+"-open";h.slideClosedClass=h.slideClass+"-closed";h.slidePreviousClass=h.slideClass+"-previous"}if(!c.sizeAccordion(this,h)){return false}else{return this.each(function(){var q=h,p=a(this),j=[],k,f,n,l,m=-1;k=q.slideWidth-q.tabWidth;f=p.get(0).tagName;n=p.children().get(0).tagName;l=p.children().size();p.data(a.extend({},{auto:q.auto,interval:null,timeout:q.timeout,trigger:q.trigger,current:q.startingSlide,previous:m,next:c.getNext(l,q.startingSlide),slideClass:q.slideClass,inside:false,pause:q.pause}));if(q.heightUnits==="%"){q.height=(p.parent().get(0).tagName==="BODY")?q.height*0.01*a(window).height():q.height*0.01*p.parent().height();q.heightUnits="px"}p.children().each(function(s){var r,o,t;o=q.invert?o=((l-1)*q.tabWidth)-(s*q.tabWidth):s*q.tabWidth;j[s]=o;r=q.invert?((l-1)-s)*10:s*10;if(q.slideClass!==null){a(this).addClass(q.slideClass)}a(this).css({top:0,"z-index":r,margin:0,padding:0,"float":"left",display:"block",position:"absolute",overflow:"hidden",width:q.slideWidth+q.widthUnits,height:q.height+q.heightUnits});if(n==="LI"){a(this).css({"text-indent":0})}if(q.invert){a(this).css({right:o+q.widthUnits,"float":"right"})}else{a(this).css({left:o+q.widthUnits,"float":"left"})}if(s===(q.startingSlide)){a(this).css("cursor","default");if(q.slideClass!==null){a(this).addClass(q.slideOpenClass)}}else{a(this).css("cursor","pointer");if(q.slideClass!==null){a(this).addClass(q.slideClosedClass)}if((s>(q.startingSlide))&&(!q.invert)){t=s+1;p.children(n+":nth-child("+t+")").css({left:j[t-1]+k+q.widthUnits})}else{if((s<(q.startingSlide))&&(q.invert)){t=s+1;p.children(n+":nth-child("+t+")").css({right:j[t-1]+k+q.widthUnits})}}}});p.css({display:"block",height:q.height+q.heightUnits,width:q.width+q.widthUnits,padding:0,position:"relative",overflow:"hidden"});if((f==="UL")||(f==="OL")){p.css({"list-style":"none"})}p.hover(function(){p.data("inside",true);if(p.data("pause")){try{clearTimeout(p.data("interval"))}catch(o){}}},function(){p.data("inside",false);if(p.data("auto")&&p.data("pause")){c.timer(p)}});p.children().bind(q.trigger,function(){if(a(this).index()!==p.data("current")){var r,o,s,t;s=m+1;t=p.data("current")+1;if((s!==0)&&(q.slideClass!==null)){p.children(n+":nth-child("+s+")").removeClass(q.slidePreviousClass)}p.children(n+":nth-child("+t+")");if(q.slideClass!==null){p.children(n+":nth-child("+t+")").addClass(q.slidePreviousClass)}m=p.data("current");p.data("previous",p.data("current"));s=m;s+=1;p.data("current",a(this).index());t=p.data("current");t+=1;p.children().css("cursor","pointer");a(this).css("cursor","default");if(q.slideClass!==null){p.children().addClass(q.slideClosedClass).removeClass(q.slideOpenClass);a(this).addClass(q.slideOpenClass).removeClass(q.slideClosedClass)}p.data("next",c.getNext(l,a(this).index()));c.timer(p);q.animationStart();if(q.invert){p.children(n+":nth-child("+t+")").stop().animate({right:j[p.data("current")]+q.widthUnits},q.speed,q.easing,q.animationComplete)}else{p.children(n+":nth-child("+t+")").stop().animate({left:j[p.data("current")]+q.widthUnits},q.speed,q.easing,q.animationComplete)}for(r=0;rp.data("current")){if(q.invert){p.children(n+":nth-child("+o+")").stop().animate({right:(l-o)*q.tabWidth+q.widthUnits},q.speed,q.easing)}else{p.children(n+":nth-child("+o+")").stop().animate({left:j[r]+k+q.widthUnits},q.speed,q.easing)}}}return false}});if(p.data("auto")){c.timer(p)}q.buildComplete()})}}}}}},stop:function(){if(a(this).data("auto")){clearTimeout(a(this).data("interval"));a(this).data("auto",false)}},start:function(){if(!a(this).data("auto")){var f=a(this).data("next")+1;a(this).data("auto",true);a(this).children(a(this).children().get(0).tagName+":nth-child("+f+")").trigger(a(this).data("trigger"))}},trigger:function(f){if((f>=a(this).children().size())||(f<0)){f=0}f+=1;a(this).children(a(this).children().get(0).tagName+":nth-child("+f+")").trigger(a(this).data("trigger"))},destroy:function(i){var f,g,h=a(this).data("slideClass");if(i!==undefined){f=(i.removeStyleAttr!==undefined)?i.removeStyleAttr:true;g=(i.removeClasses!==undefined)?i.removeClasses:false}clearTimeout(a(this).data("interval"));a(this).children().stop().unbind(a(this).data("trigger"));a(this).unbind("mouseenter mouseleave mouseover mouseout");if(f){a(this).removeAttr("style");a(this).children().removeAttr("style")}if(g){a(this).children().removeClass(h);a(this).children().removeClass(h+"-open");a(this).children().removeClass(h+"-closed");a(this).children().removeClass(h+"-previous")}a(this).removeData();if(i!==undefined){if(i.destroyComplete!=="undefined"){if(typeof(i.destroyComplete.afterDestroy)!=="undefined"){i.destroyComplete.afterDestroy()}if(i.destroyComplete.rebuild){return b.init.apply(this,[i.destroyComplete.rebuild])}}}}};if(b[e]){return b[e].apply(this,Array.prototype.slice.call(arguments,1))}else{if(typeof e==="object"||!e){return b.init.apply(this,arguments)}else{a.error("zAccordion: "+e+" does not exist.")}}}}(jQuery));