$(function(){$("body").removeClass("coda-slider-no-js");$(".coda-slider").children(".panel").hide().end().prepend('<p class="loading">Loading...<br /><img src="images/ajax-loader.gif" alt="loading..." /></p>')});var sliderCount=1;var t=-1;$.fn.codaSlider=function(a){a=$.extend({autoHeight:true,autoHeightEaseDuration:1000,autoHeightEaseFunction:"easeInOutExpo",autoSlide:false,autoSlideInterval:7000,autoSlideStopWhenClicked:true,crossLinking:true,dynamicArrows:true,dynamicArrowLeftText:"&#171; left",dynamicArrowRightText:"right &#187;",dynamicTabs:true,dynamicTabsAlign:"center",dynamicTabsPosition:"top",externalTriggerSelector:"a.xtrig",firstPanelToLoad:1,panelTitleSelector:"h2.title",slideEaseDuration:1000,slideEaseFunction:"easeInOutExpo",direction:"ltr",navCount:4,transition:"auto"},a);return this.each(function(){var e=$(this);if(a.dynamicArrows){e.parent().addClass("arrows");e.before('<div class="coda-nav-left" id="coda-nav-left-'+sliderCount+'"><a href="#">'+a.dynamicArrowLeftText+"</a></div>");e.after('<div class="coda-nav-right" id="coda-nav-right-'+sliderCount+'"><a href="#">'+a.dynamicArrowRightText+"</a></div>")}var b=e.find(".panel").width();var k=b-34;var i=e.find(".panel").size();var j=b*i;var f=0;var l=i*(b/a.navCount);if(/Firefox/.test(navigator.userAgent)){k=b-38}$("#panelCount").html(i);$(".coda-nav").css({width:l});$(".coda-nav ul li a div").css({width:(k/a.navCount),height:66});$(".coda-nav-list").css({width:b-38});$(".panel",e).wrapAll('<div class="panel-container"></div>');$(".panel-container",e).css({width:j});$("#play").hide();$(".nav-buttons-panel").hide();if(a.crossLinking&&location.hash&&parseInt(location.hash.slice(1))<=i){var c=parseInt(location.hash.slice(1));var g=-(b*(c-1));if(a.direction=="ltr"){$(".panel-container",e).css({marginLeft:g})}else{$(".panel-container",e).css({marginRight:g})}}else{if(a.firstPanelToLoad!=1&&a.firstPanelToLoad<=i){var c=a.firstPanelToLoad;var g=-(b*(c-1));if(a.direction=="ltr"){$(".panel-container",e).css({marginLeft:g})}else{$(".panel-container",e).css({marginRight:g})}}else{var c=1}}$("#currentPanel").html(c);$("#coda-nav-left-"+sliderCount).click(function(){f++;if(c==1){g=-1*(b*(i-1));var m=-1*Math.floor((i-1)/a.navCount)*k;h(i-1);c=i;$(".coda-nav-Container").find("a.current").removeClass("current").parents("ul").find("li:last a").addClass("current")}else{c-=1;h(c-1);g=-(b*(c-1));var m=-1*(Math.floor((c-1)/a.navCount))*k;$(".coda-nav-Container").find("a.current").removeClass("current").parent().prev().find("a").addClass("current")}$("#currentPanel").html(c);if(a.direction=="rtl"){$(".coda-nav").animate({marginRight:m},a.slideEaseDuration/2);$(".panel-container",e).fadeOut("fast",function(){$(".panel-container",e).css({marginRight:g});$(".panel-container",e).fadeIn("fast")})}else{$(".coda-nav").animate({marginLeft:m},a.slideEaseDuration/2);$(".panel-container",e).fadeOut("fast",function(){$(".panel-container",e).css({marginLeft:g});$(".panel-container",e).fadeIn("fast")})}if(a.crossLinking){location.hash=c}return false});$("#coda-nav-right-"+sliderCount).click(function(){f++;if(c==i){g=0;var m=0;c=1;h(0);$(".coda-nav-Container").find("a.current").removeClass("current").parents("ul").find("a:eq(0)").addClass("current")}else{g=-1*(b*c);var m=-1*Math.floor(c/a.navCount)*k;h(c);c+=1;$(".coda-nav-Container").find("a.current").removeClass("current").parent().next().find("a").addClass("current")}$("#currentPanel").html(c);if(a.direction=="rtl"){$(".coda-nav").animate({marginRight:m},a.slideEaseDuration/2);$(".panel-container",e).fadeOut("fast",function(){$(".panel-container",e).css({marginRight:g});$(".panel-container",e).fadeIn("fast")})}else{$(".coda-nav").animate({marginLeft:m},a.slideEaseDuration/2);$(".panel-container",e).fadeOut("fast",function(){$(".panel-container",e).css({marginLeft:g});$(".panel-container",e).fadeIn("fast")})}if(a.crossLinking){location.hash=c}return false});$("#coda-nav-"+sliderCount+" a").each(function(m){$(this).bind("click",function(){f++;if((t!=-1)&&(t!=-2)){clearTimeout(t);t=setTimeout(d,a.autoSlideInterval)}$(this).addClass("current").parents("ul").find("a").not($(this)).removeClass("current");g=-1*(b*m);h(m);c=m+1;$("#currentPanel").html(c);if(a.direction=="rtl"){$(".panel-container",e).fadeOut("fast",function(){$(".panel-container",e).css({marginRight:g});$(".panel-container",e).fadeIn("fast")})}else{$(".panel-container",e).fadeOut("fast",function(){$(".panel-container",e).css({marginLeft:g});$(".panel-container",e).fadeIn("fast")})}if(!a.crossLinking){return false}})});$(a.externalTriggerSelector).each(function(){if(sliderCount==parseInt($(this).attr("rel").slice(12))){$(this).bind("click",function(){f++;targetPanel=parseInt($(this).attr("href").slice(1));g=-1*(b*(targetPanel-1));h(targetPanel-1);c=targetPanel;$("#currentPanel").html(c);$(".coda-nav-Container").find("a").removeClass("current").parents("ul").find("li:eq("+(targetPanel-1)+") a").addClass("current");if(a.direction=="ltr"){$(".panel-container",e).animate({marginLeft:g},a.slideEaseDuration,a.slideEaseFunction)}else{$(".panel-container",e).animate({marginRight:g},a.slideEaseDuration,a.slideEaseFunction)}if(!a.crossLinking){return false}})}});if(a.crossLinking&&location.hash&&parseInt(location.hash.slice(1))<=i){$("#coda-nav-"+sliderCount+" a:eq("+(location.hash.slice(1)-1)+")").addClass("current")}else{if(a.firstPanelToLoad!=1&&a.firstPanelToLoad<=i){$("#coda-nav-"+sliderCount+" a:eq("+(a.firstPanelToLoad-1)+")").addClass("current")}else{$("#coda-nav-"+sliderCount+" a:eq(0)").addClass("current")}}if(a.autoHeight){panelHeight=$(".panel:eq("+(c-1)+")",e).height();e.css({height:panelHeight})}if(a.autoSlide){e.ready(function(){t=setTimeout(d,a.autoSlideInterval)})}function h(m){if(a.autoHeight){panelHeight=$(".panel:eq("+m+")",e).height();e.animate({height:panelHeight},a.autoHeightEaseDuration,a.autoHeightEaseFunction)}}function d(){if(f==0||!a.autoSlideStopWhenClicked){if(c==i){var m=0;c=1;var n=0}else{var m=-1*(b*c);c+=1;var n=-1*Math.floor((c-1)/a.navCount)*k}$("#currentPanel").html(c);h(c-1);$(".coda-nav-Container").find("a").removeClass("current").parents("ul").find("li:eq("+(c-1)+") a").addClass("current");if(a.direction=="rtl"){$(".coda-nav").animate({marginRight:n},a.slideEaseDuration,a.slideEaseFunction);$(".panel-container",e).fadeOut("fast",function(){$(".panel-container",e).css({marginRight:m});$(".panel-container",e).fadeIn("fast")})}else{$(".coda-nav").animate({marginLeft:n},a.slideEaseDuration,a.slideEaseFunction);$(".panel-container",e).fadeOut("fast",function(){$(".panel-container",e).css({marginLeft:m});$(".panel-container",e).fadeIn("fast")})}t=setTimeout(d,a.autoSlideInterval)}}$(".panel",e).show().end().find("p.loading").remove();e.removeClass("preload");sliderCount++;$("#play").click(function(){e.ready(function(){if(t==-1){t=setTimeout(d,a.autoSlideInterval)}$("#pause").show();$("#play").hide()})});$("#pause").click(function(){e.ready(function(){if(t!=-1){clearTimeout(t);t=-1}$("#play").show();$("#pause").hide()})});$("#toggle").click(function(){e.ready(function(){if(t==-1){t=setTimeout(d,a.autoSlideInterval);$("this").addClass("play");$("this").removeClass("pause")}else{clearTimeout(t);t=-1;$("this").addClass("pause");$("this").removeClass("play")}})});$(".mouse-toggle").mouseenter(function(){e.ready(function(){if((t!=-1)&&(t!=-2)){clearTimeout(t);t=-2}})});$(".mouse-toggle").mouseleave(function(){e.ready(function(){if(t==-2){t=setTimeout(d,a.autoSlideInterval)}})});$("#nextSlidePage").click(function(){if((t!=-1)&&(t!=-2)){clearTimeout(t);t=setTimeout(d,a.autoSlideInterval)}e.ready(function(){if(Math.floor((c-1)/a.navCount)==Math.floor((i-1)/a.navCount)){var n=0;var m=1}else{var n=-1*(Math.floor((c-1)/a.navCount)+1)*k;var m=((Math.floor((c-1)/a.navCount)+1)*a.navCount)+1}if(a.direction=="ltr"){$(".coda-nav").animate({marginLeft:n},a.slideEaseDuration,function(){$(".coda-nav-Container").find("li:eq("+(m-1)+") a").click()})}else{$(".coda-nav").animate({marginRight:n},a.slideEaseDuration,function(){$(".coda-nav-Container").find("li:eq("+(m-1)+") a").click()})}})});$("#previousSlidePage").click(function(){e.ready(function(){if((t!=-1)&&(t!=-2)){clearTimeout(t);t=setTimeout(d,a.autoSlideInterval)}if(Math.floor((c-1)/a.navCount)==0){var n=-1*Math.floor((i-1)/a.navCount)*k;var m=(Math.floor((i-1)/a.navCount)*a.navCount)+1}else{var n=-1*(Math.floor((c-1)/a.navCount)-1)*k;var m=((Math.floor((c-1)/a.navCount)-1)*a.navCount)+1}if(a.direction=="rtl"){$(".coda-nav").animate({marginRight:n},a.slideEaseDuration,function(){$(".coda-nav-Container").find("li:eq("+(m-1)+") a").click()})}else{$(".coda-nav").animate({marginLeft:n},a.slideEaseDuration,function(){$(".coda-nav-Container").find("li:eq("+(m-1)+") a").click()})}})});$(".navVisible").mouseenter(function(){$(".nav-buttons-panel").slideDown("slow")});$(".navVisible").mouseleave(function(){$(".nav-buttons-panel").slideUp("slow")})})};
