(function(A){A.scrollFollow=function(G,E){var C=A(G).css("position");function D(M,O){A(M).dequeue();var L=A(document).scrollTop();var N=A(B).offset().top;var J=A(B).height();var K=A(M).offset().top;var P=M.offsetHeight;var I;if(F){I=Math.min((Math.max((N+O),(L+E.offset))-N),(J-P));if(E.animate=="yes"){A(M).animate({top:I},E.speed,E.easing)}else{if(typeof document.body.style.maxHeight!="undefined"){A(M).css({top:E.offset,position:"fixed"})}else{A(M).css({top:I})}}}}var F=true;if(A.cookie("scrollFollowSetting"+A(G).attr("id"))=="false"){var F=false;A("#"+E.killSwitch).text(E.offText).toggle(function(){F=true;A(this).text(E.onText);A.cookie("scrollFollowSetting"+A(G).attr("id"),true,{expires:365,path:"/"})},function(){F=false;A(this).text(E.offText);if(E.animate=="yes"){A(G).animate({top:H},E.speed,E.easing)}else{A(G).css({position:C,top:H})}A.cookie("scrollFollowSetting"+A(G).attr("id"),false,{expires:365,path:"/"})})}else{A("#"+E.killSwitch).text(E.onText).toggle(function(){F=false;A(this).text(E.offText);A(G).animate({top:H},0);A.cookie("scrollFollowSetting"+A(G).attr("id"),false,{expires:365,path:"/"})},function(){F=true;A(this).text(E.onText);A.cookie("scrollFollowSetting"+A(G).attr("id"),true,{expires:365,path:"/"})})}var B;if(E.container==""){B=A(G).parent()}else{B=document.getElementById(E.container)}var H=A(G).css("top");if(H=="auto"){H=0}else{H=parseInt(H.substr(0,H.indexOf("p")))}A(window).scroll(function(){D(G,H)})};A.fn.scrollFollow=function(B){B=B||{};B.speed=B.speed||500;B.offset=B.offset||0;B.easing=B.easing||"easeOutBack";B.container=B.container||this.parent().attr("id");B.killSwitch=B.killSwitch||"killSwitch";B.onText=B.onText||"Navigation fixieren";B.offText=B.offText||"Navigation lockern";B.animate=B.animate||"yes";this.each(function(){new A.scrollFollow(this,B)});return this}})(jQuery);