/* jQuery Carousel 0.9.2
Copyright 2008-2009 Thomas Lanciaux and Pierre Bertet.
This software is licensed under the CC-GNU LGPL <http://creativecommons.org/licenses/LGPL/2.1/>
*/
;(function(d){d.fn.carousel=function(e){var e=d.extend({direction:"horizontal",loop:false,dispItems:1,pagination:false,paginationPosition:"inside",nextBtn:'<a role="button">Next</a>',prevBtn:'<a role="button">Previous</a>',btnsPosition:"inside",nextBtnInsert:"appendTo",prevBtnInsert:"prependTo",nextBtnInsertFn:false,prevBtnInsertFn:false,autoSlide:false,autoSlideInterval:3000,delayAutoSlide:false,combinedClasses:false,effect:"slide",slideEasing:"swing",animSpeed:"normal",equalWidths:"true",verticalMargin:0,callback:function(){},useAddress:false,adressIdentifier:"carousel",minItemHeight:0,minItemWidth:0,tabLabel:function(a){return a}},e);if(e.btnsPosition=="outside"){e.prevBtnInsert="insertBefore";e.nextBtnInsert="insertAfter"}e.delayAutoSlide=e.delayAutoSlide||e.autoSlideInterval;return this.each(function(){var b={$elts:{},params:e,launchOnLoad:[]};b.$elts.carousel=d(this).addClass("js");b.$elts.content=d(this).children().css({position:"absolute","top":0});b.$elts.wrap=b.$elts.content.wrap('<div class="carousel-wrap"></div>').parent().css({overflow:"hidden",position:"relative"});b.steps={first:0,count:b.$elts.content.children().length};b.steps.last=b.steps.count-1;if(d.isFunction(b.params.prevBtnInsertFn)){b.$elts.prevBtn=b.params.prevBtnInsertFn(b.$elts)}else{b.$elts.prevBtn=d(e.prevBtn)[e.prevBtnInsert](b.$elts.carousel)}if(d.isFunction(b.params.nextBtnInsertFn)){b.$elts.nextBtn=b.params.nextBtnInsertFn(b.$elts)}else{b.$elts.nextBtn=d(e.nextBtn)[e.nextBtnInsert](b.$elts.carousel)}b.$elts.nextBtn.addClass("carousel-control next carousel-next");b.$elts.prevBtn.addClass("carousel-control previous carousel-previous");l(b);if(b.params.pagination){m(b)}n(b);d(function(){var f=b.$elts.content.children();var g=0;f.each(function(){$item=d(this);$itemHeight=$item.outerHeight();if(b.params.minItemHeight>$itemHeight){$itemHeight=b.params.minItemHeight}if($itemHeight>g){g=$itemHeight}});if(b.params.verticalMargin>0){g=g+b.params.verticalMargin}f.height(g);var o=b.$elts.content.children(":first");b.itemWidth=o.outerWidth();if(b.params.minItemWidth>b.itemWidth){b.itemWidth=b.params.minItemWidth}if(e.direction=="vertical"){b.contentWidth=b.itemWidth}else{if(e.equalWidths){b.contentWidth=b.itemWidth*b.steps.count}else{b.contentWidth=(function(){var a=0;b.$elts.content.children().each(function(){a+=d(this).outerWidth()});return a})()}}b.$elts.content.width(b.contentWidth);b.itemHeight=g;if(e.direction=="vertical"){b.$elts.content.css({height:b.itemHeight*b.steps.count+"px"});b.$elts.content.parent().css({height:b.itemHeight*b.params.dispItems+"px"})}else{b.$elts.content.parent().css({height:b.itemHeight+"px"})}j(b);d.each(b.launchOnLoad,function(a,c){c()});if(b.params.autoSlide){window.setTimeout(function(){b.autoSlideInterval=window.setInterval(function(){h(b,i(b,"next"))},b.params.autoSlideInterval)},b.params.delayAutoSlide)}})})};function l(c){c.$elts.nextBtn.add(c.$elts.prevBtn).bind("enable",function(){var a=d(this).unbind("click").bind("click",function(){h(c,i(c,(a.is(".next")?"next":"prev")));k(c)}).removeClass("disabled");if(c.params.combinedClasses){a.removeClass("next-disabled previous-disabled")}}).bind("disable",function(){var a=d(this).unbind("click").addClass("disabled");if(c.params.combinedClasses){if(a.is(".next")){a.addClass("next-disabled")}else if(a.is(".previous")){a.addClass("previous-disabled")}}}).hover(function(){d(this).toggleClass("hover")})};function m(c){c.$elts.pagination=d('<div class="center-wrap"><div class="carousel-pagination"><p></p></div></div>')[((c.params.paginationPosition=="outside")?"insertAfter":"appendTo")](c.$elts.carousel).find("p");c.$elts.paginationBtns=d([]);c.$elts.content.find("li").each(function(a){if(a%c.params.dispItems==0){c.$elts.paginationBtns=c.$elts.paginationBtns.add(d('<a role="button"><span>'+c.params.tabLabel(c.$elts.paginationBtns.length+1)+'</span></a>').data("firstStep",a))}});c.$elts.paginationBtns.each(function(){d(this).appendTo(c.$elts.pagination)});c.$elts.paginationBtns.slice(0,1).addClass("active");c.launchOnLoad.push(function(){c.$elts.paginationBtns.click(function(a){h(c,d(this).data("firstStep"));k(c)})})};function n(f){if(f.params.useAddress&&d.isFunction(d.fn.address)){d.address.init(function(a){var c=d.address.pathNames();if(c[0]===f.params.adressIdentifier&&!!c[1]){h(f,c[1]-1)}else{d.address.value('/'+f.params.adressIdentifier+'/1')}}).change(function(a){var c=d.address.pathNames();if(c[0]===f.params.adressIdentifier&&!!c[1]){h(f,c[1]-1)}})}else{f.params.useAddress=false}};function h(a,c){a.params.callback(c);p(a,c);a.steps.first=c;j(a);if(a.params.useAddress){d.address.value('/'+a.params.adressIdentifier+'/'+(c+1))}};function i(a,c){if(c=="prev"){if((a.steps.first-a.params.dispItems)>=0){return a.steps.first-a.params.dispItems}else{return((a.params.loop)?(a.steps.count-a.params.dispItems):false)}}else if(c=="next"){if((a.steps.first+a.params.dispItems)<a.steps.count){return a.steps.first+a.params.dispItems}else{return((a.params.loop)?0:false)}}};function p(a,c){switch(a.params.effect){case"no":if(a.params.direction=="vertical"){a.$elts.content.css("top",-(a.itemHeight*c)+"px")}else{a.$elts.content.css("left",-(a.itemWidth*c)+"px")}break;case"fade":if(a.params.direction=="vertical"){a.$elts.content.hide().css("top",-(a.itemHeight*c)+"px").fadeIn(a.params.animSpeed)}else{a.$elts.content.hide().css("left",-(a.itemWidth*c)+"px").fadeIn(a.params.animSpeed)}break;default:if(a.params.direction=="vertical"){a.$elts.content.stop().animate({top:-(a.itemHeight*c)+"px"},a.params.animSpeed,a.params.slideEasing)}else{a.$elts.content.stop().animate({left:-(a.itemWidth*c)+"px"},a.params.animSpeed,a.params.slideEasing)}break}};function j(a){if(i(a,"prev")!==false){a.$elts.prevBtn.trigger("enable")}else{a.$elts.prevBtn.trigger("disable")}if(i(a,"next")!==false){a.$elts.nextBtn.trigger("enable")}else{a.$elts.nextBtn.trigger("disable")}if(a.params.pagination){a.$elts.paginationBtns.removeClass("active").filter(function(){return(d(this).data("firstStep")==a.steps.first)}).addClass("active")}};function k(a){if(!!a.autoSlideInterval){window.clearInterval(a.autoSlideInterval)}}})(jQuery);

