/**
 * jquery.scrollable 0.13. Put your HTML scroll.
 * 
 * http://flowplayer.org/tools/scrollable.html
 *
 * Copyright (c) 2008 Tero Piirainen (support@flowplayer.org)
 *
 * Released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 * 
 * >> Basically you can do anything you want but leave this header as is <<
 *
 * Since  : 0.10 - 03/01/2008
 * Version: 0.13 - Wed Nov 05 2008 12:04:04 GMT-0000 (GMT+00:00)
 */
(function(b){function a(g,e){var d=this;if(!a.current){a.current=this;}var h={size:5,vertical:false,activeClass:"active",speed:300,onSeek:null,clickable:true,inactiveClassNext:"inactive_next",inactiveClassPrev:"inactive_prev",items:".items",prev:".prev",next:".next",navi:".navi",naviItem:"span",loop:false};this.opts=b.extend(h,e);this.opts.horizontal=!h.vertical;this.root=b(g);var c=this.root;var f=b(h.items,c);if(!f.length){f=c;}f.css({position:"relative",overflow:"hidden",visibility:"visible"});f.children().wrapAll('<div class="__scrollable" style="position:absolute"/>');this.wrap=f.find(":first");this.wrap.css(h.horizontal?"width":"height","200000em").after('<br clear="all" />');this.items=this.wrap.children(":visible");this.index=0;if(h.horizontal){}else{f.height(h.size*(this.items.eq(1).offset().top-this.items.eq(0).offset().top)-2);}if(b.isFunction(b.fn.mousewheel)){c.bind("mousewheel.scrollable",function(i,j){d.move(-j,50);return false;});}if(h.clickable){this.items.each(function(j,i){b(this).bind("click.scrollable",function(){d.click(j);});});}d.getStatus();this.activeIndex=0;b(h.prev,c).click(function(){d.prev();});b("#prev").click(function(i){if(window.hbv&&hbv.Gallery&&hbv.Gallery.atEnd()){d.end();}else{d.prev();}return false;});b(h.next,c).click(function(){d.next();});b("#next").click(function(i){if(window.hbv&&hbv.Gallery&&hbv.Gallery.atBegin()){d.begin();}else{d.next();}return false;});b(h.navi,c).each(function(){var n=b(this);var j=d.getStatus();if(n.is(":empty")){for(var l=0;l<j.pages;l++){var m=b("<"+h.naviItem+"/>").attr("page",l).click(function(o){var i=b(this);i.parent().children().removeClass(h.activeClass);i.addClass(h.activeClass);d.setPage(i.attr("page"));o.preventDefault();});if(l===0){m.addClass(h.activeClass);}n.append(m);}}else{var k=n.find("a");if(!k.length){k=n.children();}k.each(function(o){var p=b(this);p.attr("page",o);if(o===0){p.addClass(h.activeClass);}p.click(function(){n.find("."+h.activeClass).removeClass(h.activeClass);p.addClass(h.activeClass);d.setPage(p.attr("page"));});});}});}b.extend(a.prototype,{getVersion:function(){return"@VERSION";},click:function(d){var e=this.items.eq(d),c=this.opts.activeClass;if(document.getElementById("bauer_lecker_bildergalerie_bildansicht")&&window.hbv&&hbv.Gallery){hbv.Gallery.setCurrent(d);}if(!e.hasClass(c)&&(d>=0||d<this.items.size())){this.items.removeClass(c);e.addClass(c);var g=Math.floor(this.opts.size/2);var f=d-g;if(f!==this.activeIndex){this.seekTo(f);}}},setElements:function(){var c=this.items.length;this.items=this.wrap.children(":visible");if(c!=this.items.length){this.begin();var d=this.root;b(d).find(".prev").addClass(this.opts.inactiveClassPrev);return false;}else{return true;}},getStatus:function(){var c=this.items.size();var f=this.items.length;var d=this.opts.size;if(b("#carousel_items").children(".__scrollable").children().length==1){if(b("#carousel_items").children(".__scrollable").children(".__scrollable").length>0){f=b("#carousel_items").children(".__scrollable").children(".__scrollable").children().length;}}var e=this.root;if(f<=d){b(e).find(".next").addClass(this.opts.inactiveClassNext);}return{size:this.opts.size,total:c,index:this.index,pages:Math.ceil(c/this.opts.size),page:Math.ceil(this.index/this.opts.size)};},seekTo:function(h,d){if(h<0){h=0;}if(this.items.length/2!=0){h=Math.floor(h);}var l=Math.min(h,this.items.length-this.opts.size);if(h<=l){var n=this.items.eq(h);this.index=h;if(this.opts.horizontal){var e=this.wrap.offset().left-n.offset().left;this.wrap.animate({left:e},d||this.opts.speed);}else{var k=this.wrap.offset().top-n.offset().top;this.wrap.animate({top:k},d||this.opts.speed);}a.current=this;}var g=this.items.length;var f=this.opts.size;var c=this.root;if(h>=(g-f)||(l<=0)){b(c).find(".next").addClass(this.opts.inactiveClassNext);}if(g!=f){if((h+f)>f){if(g>0&&(g>f)){b(c).find(".prev").removeClass(this.opts.inactiveClassPrev);}}else{b(c).find(".prev").addClass(this.opts.inactiveClassPrev);if(g>0&&(g>f)){b(c).find(".next").removeClass(this.opts.inactiveClassNext);}}}if(b.isFunction(this.opts.onSeek)){this.opts.onSeek.call(this);}var m=b(this.opts.navi,this.root);if(m.length){var i=this.opts.activeClass;var j=Math.ceil(h/this.opts.size);j=Math.min(j,m.children().length-1);m.children().removeClass(i).eq(j).addClass(i);}this.activeIndex=h;return true;},move:function(d,c){var e=this.index+d;if(this.opts.loop&&e>this.items.length){e=0;}this.seekTo(e,c);},next:function(c){this.move(1,c);},prev:function(c){if(this.setElements()){this.move(-1,c);}},movePage:function(d,c){this.move(this.opts.size*d,c);},setPage:function(f,g){var d=this.opts.size;var c=d*f;var e=c+d>=this.items.size();if(e){c=this.items.size()-this.opts.size;}this.seekTo(c,g);},prevPage:function(c){this.setPage(this.getStatus().page-1,c);},nextPage:function(c){this.setPage(this.getStatus().page+1,c);},begin:function(c){this.seekTo(0,c);},end:function(c){this.seekTo(this.items.size()-this.opts.size,c);}});if(0){b(window).bind("keypress.scrollable",function(c){var d=a.current;if(!d){return;}if(d.opts.horizontal&&(c.keyCode==37||c.keyCode==39)){d.move(c.keyCode==37?-1:1);return c.preventDefault();}if(!d.opts.horizontal&&(c.keyCode==38||c.keyCode==40)){d.move(c.keyCode==38?-1:1);return c.preventDefault();}return true;});}jQuery.prototype.scrollable=function(g,e,d){if(!g||typeof g=="number"){var c=g||0;var f=b.data(this.get()[c],"scrollable");if(f){return f;}}this.each(function(){if(typeof g=="string"){var i=b.data(this,"scrollable");i[g].apply(i,[e,d]);}else{var h=new a(this,g);b.data(this,"scrollable",h);}});return this;};})(jQuery);

