nxTeaser=function(nxTeaserSelector,options){this.srFilm='.Film';this.srLens='.Lens';this.srMoveLeft='.MoveLeft';this.srMoveRight='.MoveRight';var that=this;if(nxTeaserSelector==null)nxTeaserSelector='#nxTeaser';this.nxTeaserSelector=nxTeaserSelector;this.duration=900;this.easing='swing';this.rewindSlowFactor=1.5;this.cycle=false;this.mousewheel=true;this.enableArrowCheck=false;this.floatfix=false;this.floatfixSelector='li';if(typeof(options)=='object'){if(options.duration!=null&&options.duration>0)this.duration=options.duration;if(options.easing!=null)this.easing=options.easing;if(options.rewindslow!=null)this.rewindSlowFactor=options.rewindslow;if(options.cycle===true)this.cycle=options.cycle;if(options.mousewheel===false)this.mousewheel=options.mousewheel;if(options.floatfix==true)this.floatfix=options.floatfix;if(options.floatfixSelector!=null)this.floatfixSelector=options.floatfixSelector;if(options.step!=null)this.step=options.step;if(this.cycle==false&&options.leftArrowInact!=null&&options.rightArrowInact!=null){this.enableArrowCheck=true;this.leftArrowInact=options.leftArrowInact;this.rightArrowInact=options.rightArrowInact;}if(this.cycle==false&&options.leftArrowAct!=null&&options.rightArrowAct!=null){this.enableArrowCheck=true;this.leftArrowAct=options.leftArrowAct;this.rightArrowAct=options.rightArrowAct;}}$(this.nxTeaserSelector+' '+this.srLens).css('overflow','hidden').css('position','relative');$(this.nxTeaserSelector+' '+this.srFilm).css('position','absolute');this.makeFloatFix();this.maxLeft=0;this.minLeft=-($(this.nxTeaserSelector+' '+this.srFilm).outerWidth()-$(this.nxTeaserSelector+' '+this.srLens).innerWidth());this.moveStepSizePx=$(this.nxTeaserSelector+' '+this.srLens).innerWidth();this.filmPosLeft=$(this.nxTeaserSelector+' '+this.srFilm).position().left;this.rewindInProgress=false;$(this.nxTeaserSelector+' img').load(function(){that.makeFloatFix()});$(window).resize(function(){that.reMeasureLeft();})
$(this.nxTeaserSelector+' '+this.srMoveLeft).click(function(e){e.preventDefault();that.moveToDirect('L')});$(this.nxTeaserSelector+' '+this.srMoveRight).click(function(e){e.preventDefault();that.moveToDirect('R')});if(this.mousewheel){$(this.nxTeaserSelector).bind('DOMMouseScroll mousewheel',function(e){e.preventDefault();that.moveByMouseWheel(e)});}if(this.step>0)this.moveStepSizePx=this.step;if(this.enableArrowCheck==true)this.checkArrow();}
nxTeaser.prototype.reMeasureLeft=function(){this.filmPosLeft=$(this.nxTeaserSelector+' '+this.srFilm).position().left;this.minLeft=-($(this.nxTeaserSelector+' '+this.srFilm).outerWidth()-$(this.nxTeaserSelector+' '+this.srLens).innerWidth());this.moveByStep(0);}
nxTeaser.prototype.makeFloatFix=function(){if(this.floatfix){var floatList=$(this.nxTeaserSelector+' '+this.floatfixSelector);var floatTotalCnt=floatList.length;var fullFilmLen=0;for(jj=0;jj<floatTotalCnt;jj++){fullFilmLen+=$(floatList[jj]).outerWidth(true);}$(this.nxTeaserSelector+' '+this.srFilm).css('width',fullFilmLen);this.reMeasureLeft();}}
nxTeaser.prototype.checkArrow=function(){var LeftArr=$(this.nxTeaserSelector+' '+this.srMoveLeft);var RightArr=$(this.nxTeaserSelector+' '+this.srMoveRight);if(this.leftArrowInact!=undefined){LeftArr.removeClass(this.leftArrowInact)}if(this.rightArrowInact!=undefined){RightArr.removeClass(this.rightArrowInact)}if(this.leftArrowAct!=undefined){LeftArr.removeClass(this.leftArrowAct)}if(this.rightArrowAct!=undefined){RightArr.removeClass(this.rightArrowAct)}if(this.filmPosLeft>=this.maxLeft){if(this.leftArrowInact!=undefined)LeftArr.addClass(this.leftArrowInact)}else{if(this.leftArrowAct!=undefined)LeftArr.addClass(this.leftArrowAct)};if(this.filmPosLeft<=this.minLeft){if(this.rightArrowInact!=undefined)RightArr.addClass(this.rightArrowInact)}else{if(this.rightArrowAct!=undefined)RightArr.addClass(this.rightArrowAct)}}
nxTeaser.prototype.moveByMouseWheel=function(e){var wheelDelta=0;if(e.originalEvent.wheelDelta){wheelDelta=e.originalEvent.wheelDelta/120;}else if(e.originalEvent.detail){wheelDelta=-e.originalEvent.detail/3;}if(wheelDelta>0){this.moveToDirect('L');}else if(wheelDelta<0){this.moveToDirect('R');}}
nxTeaser.prototype.moveToDirect=function(direct){if(direct=='L'){this.moveByStep(this.moveStepSizePx);}else{if(direct=='R')this.moveByStep(-this.moveStepSizePx);}}
nxTeaser.prototype.moveByStep=function(step_px){var filmPosLeft=this.filmPosLeft;var finalLeft=filmPosLeft+step_px;if(finalLeft>this.maxLeft){step_px=step_px-finalLeft;}if(finalLeft<this.minLeft){step_px=step_px-(finalLeft-this.minLeft);}finalLeft=filmPosLeft+step_px;if(this.cycle&&Math.abs(step_px)<=1){if(finalLeft==this.minLeft){finalLeft=this.maxLeft;this.rewindInProgress=true;}else if(finalLeft==this.maxLeft){finalLeft=this.minLeft;this.rewindInProgress=true;}}this.filmPosLeft=finalLeft;if(finalLeft<=this.maxLeft&&finalLeft>=this.minLeft){var curSpeed=this.duration;if(this.rewindInProgress==true){curSpeed=this.rewindSlowFactor*this.duration;this.rewindInProgress=false;}var that=this;$(this.nxTeaserSelector+' '+this.srFilm).animate({'left':finalLeft},{'queue':false,'duration':curSpeed,'easing':this.easing,'complete':function(){if(that.enableArrowCheck==true)that.checkArrow();}});}}