(function(a){var b={teaserList:null,animationInterval:7,waitingTimeBeforeStart:0,mainContainerHeight:333,animationType:"fading",animationSpeed:"normal",progressbar:true,selectorAnimationGroupContainer:".animationGroupContainer",selectorAnimationGroup:".animationGroup",callFunctionAfterSuccess:function(){},debug:false,debugOuputMessagePrefix:"Autoteaser : "};var c={init:function(d){var e=a(this).eq(0);if(e.length>0){var d=a.extend({},b,d);if(d.debug){c.debugOutput({error:e})}if(d.mainContainerHeight){if(d.debug){c.debugOutput({error:"custom height: "+d.mainContainerHeight})}e.height(d.mainContainerHeight);a(".teaser, .teaser .slotFlashBackground, .teaser .slotImageBackgroundHT",e).height(d.mainContainerHeight);a(d.selectorAnimationGroupContainer+" .teaser:first",e).addClass("firstItem");a(d.selectorAnimationGroupContainer+" .teaser:last",e).addClass("lastItem")}var d=a.extend({mainContainerWidth:a("div#TeaserAnimation").width()},d);var f=a(d.selectorAnimationGroup,e);var g=a("div.teaser",e);var h=a("div.teaser:first",e);if(d.animationType=="fading"){g.hide().removeClass("visibleNo");h.fadeIn(b.animationSpeed,function(){a(this).addClass("active prepareAnimation")})}else{h.removeClass("visibleNo").addClass("active")}if(g.length>1){var i="div.teaserAnimationNavigator span#teaserAnimationNavigatorDynamicMenue";var j="div.teaserAnimationNavigator span#teaserAnimationNavigatorAutomaticNavigation";var k='<a class="teaserAnimationNavigatorMenuePrev" href="javascript:void(0);"></a><a class="hiddenMenueForAutoNavigationPrev" href="javascript:void(0);"></a>';k+='<a class="teaserAnimationNavigatorMenueNext" href="javascript:void(0);"></a><a class="hiddenMenueForAutoNavigationNext" href="javascript:void(0);"></a>';k+='<div class="teaserAnimationNavigator">';k+='<div class="teaserAnimationNavigatorContent">';k+='<span id="teaserAnimationNavigatorDynamicMenue">';k+='<a class="flashGroupPlayButton" href="javascript:void(0);"><span></span></a>';k+="</span>";k+='<span id="teaserAnimationNavigatorAutomaticNavigation"></span>';k+="</div>";k+="</div>";e.append(k);a(d.selectorAnimationGroupContainer).append("<div id='progressbar'></div>");var l=0;g.each(function(b){l++;var c=a(this);c.attr({animationgroupindex:l});a(i,e).append('<a class="flashGroupMenueItem" animationgroupindex="'+l+'" href="javascript:void(0);"><span>'+l+"</span></a>");a(j,e).append('<a class="hiddenMenueForAutoNavigation" animationgroupindex="'+l+'" href="javascript:void(0);"></a>')});function m(a){if(typeof a=="undefined"||typeof a!="boolean"){var a=false}var b=e.find(i+" a.flashGroupMenueItem.active, "+j+" a.active").attr("animationgroupindex");var c=e.find("div.teaserAnimationNavigator a.teaserAnimationNavigatorMenuePrev, div.teaserAnimationNavigator a.hiddenMenueForAutoNavigationPrev");var f=e.find("div.teaserAnimationNavigator a.teaserAnimationNavigatorMenueNext, div.teaserAnimationNavigator a.hiddenMenueForAutoNavigationNext");if(b>1){c.addClass("active")}else{c.removeClass("active")}if(b==l){f.removeClass("active")}else{f.addClass("active")}if(a){o({animationInterval:d.animationInterval,clearCustomInterval:a})}}function n(){var b=a(j+" a").length;var c=parseInt(a(j+" a.active",e).attr("animationgroupindex"));if(c==b){a(j+" a:first",e).click()}else{a("a.hiddenMenueForAutoNavigationNext",e).click()}}function o(b){var b=a.extend({playButton:a(i+" a.flashGroupPlayButton",e),animationInterval:null,clearCustomInterval:false},b||{});b.animationInterval=Math.abs(b.animationInterval*1e3);if(b.animationInterval<1e3){b.animationInterval=Math.abs(b.animationInterval*5e3)}if(b.clearCustomInterval){window.clearInterval(startAutoNavigation);startAutoNavigation=window.setInterval(n,b.animationInterval);if(b.playButton.hasClass("start")){b.playButton.addClass("stop").removeClass("start")}}else{if(b.playButton.hasClass("stop")){if(d.progressbar==true){t()}window.clearInterval(startAutoNavigation);b.playButton.removeClass("stop").addClass("start")}else if(b.playButton.hasClass("start")){startAutoNavigation=window.setInterval(n,b.animationInterval);b.playButton.removeClass("start").addClass("stop");if(d.progressbar==true){t();s(d.animationInterval)}}else{startAutoNavigation=window.setInterval(n,b.animationInterval);if(d.progressbar==true){s(d.animationInterval)}b.playButton.addClass("stop")}}}setTimeout(function(){o({animationInterval:d.animationInterval})},Math.abs(d.waitingTimeBeforeStart*1e3));a(i+" a.flashGroupPlayButton").click(function(){o({playButton:a(this),animationInterval:d.animationInterval})});e.find(i+" a.flashGroupMenueItem:first, "+j+" a:first").addClass("active");e.find("a.teaserAnimationNavigatorMenueNext, a.hiddenMenueForAutoNavigationNext").addClass("active");e.find(i+" a.flashGroupMenueItem, "+j+" a").unbind("click").click(function(c){if(d.progressbar==true){t()}if(!a(this).hasClass("active")){e.find(i+" a.flashGroupMenueItem, "+j+" a").removeClass("active");a(this).addClass("active");var g=a(this).attr("animationgroupindex")-1;var h=a("div.teaser",f).get(g);if(d.animationType=="fading"){a(".teaser.prepareAnimation",f).fadeOut(b.animationSpeed,function(){a(this).removeClass("active prepareAnimation");a(h).addClass("active prepareAnimation")});a(h).fadeIn(b.animationSpeed)}else{a("div.teaser",f).removeClass("active").addClass("visibleNo");a(h).removeClass("visibleNo").addClass("active")}var k=e.find(i+" a.flashGroupMenueItem, "+j+" a").get(g);a(k).addClass("active");p({clearInterval:a(this).hasClass("flashGroupMenueItem")});if(a(this).hasClass("hiddenMenueForAutoNavigation")){if(d.progressbar==true){s(d.animationInterval)}}}else{if(a(i+" a.flashGroupPlayButton").hasClass("stop")){o({animationInterval:d.animationInterval,clearCustomInterval:true})}}});e.find("a.teaserAnimationNavigatorMenuePrev, a.hiddenMenueForAutoNavigationPrev").unbind("click").click(function(){if(d.progressbar==true){t()}if(q()=="first"){r({type:"jumptolast",getCurrentSelectedGroupTeaser:a("div.teaser:last",f),getCurrentSelectedMenueDynamic:a(i+" a.flashGroupMenueItem:last",e),getCurrentSelectedAutomaticNavigation:a(j+" a:last",e),clearInterval:true,animationType:d.animationType})}else{r({type:"prev",getCurrentSelectedGroupTeaser:a("div.teaser.active:not(':first')",f),getCurrentSelectedMenueDynamic:a(i+" a.flashGroupMenueItem.active",e).not(a(i+" a.flashGroupMenueItem:first",e)),getCurrentSelectedAutomaticNavigation:a(j+" a.active",e).not(a(j+" a:first",e)),clearInterval:a(this).hasClass("teaserAnimationNavigatorMenuePrev"),animationType:d.animationType})}if(a(this).hasClass("hiddenMenueForAutoNavigationPrev")){if(d.progressbar==true){s(d.animationInterval)}}});e.find("a.teaserAnimationNavigatorMenueNext, a.hiddenMenueForAutoNavigationNext").unbind("click").click(function(b){if(d.progressbar==true){t()}if(q()=="last"){r({type:"jumptofirst",getCurrentSelectedGroupTeaser:a("div.teaser:first",f),getCurrentSelectedMenueDynamic:a(i+" a.flashGroupMenueItem:first",e),getCurrentSelectedAutomaticNavigation:a(j+" a:first",e),clearInterval:false,animationType:d.animationType})}else{r({type:"next",getCurrentSelectedGroupTeaser:a("div.teaser.active:not(':last')",f),getCurrentSelectedMenueDynamic:a(i+" a.flashGroupMenueItem.active",e).not(a(i+" a.flashGroupMenueItem:last",e)),getCurrentSelectedAutomaticNavigation:a(j+" a.active",e).not(a(j+" a:last",e)),clearInterval:a(this).hasClass("teaserAnimationNavigatorMenueNext"),animationType:d.animationType})}if(a(this).hasClass("hiddenMenueForAutoNavigationNext")){if(d.progressbar==true){s(d.animationInterval)}}});function p(b){var b=a.extend({clearInterval:false},b||{});m(b.clearInterval)}function q(){var b=a("div.teaser.prepareAnimation",f).attr("animationgroupindex");var c="";if(b==l){c="last"}else if(b==1){c="first"}else{}return c}function r(c){var c=a.extend({type:null,getCurrentSelectedGroupTeaser:null,getCurrentSelectedMenueDynamic:null,getCurrentSelectedAutomaticNavigation:null,clearInterval:null,animationType:null},c||{});if(c.type&&c.getCurrentSelectedGroupTeaser&&c.getCurrentSelectedMenueDynamic&&c.getCurrentSelectedAutomaticNavigation){if(c.animationType=="fading"){if(c.type=="next"||c.type=="prev"){c.getCurrentSelectedGroupTeaser.removeClass("active");c.getCurrentSelectedMenueDynamic.removeClass("active");c.getCurrentSelectedAutomaticNavigation.removeClass("active")}else{a(i+" a.flashGroupMenueItem.active",e).removeClass("active");a(j+" a.active",e).removeClass("active")}if(c.type=="next"){var d=c.getCurrentSelectedGroupTeaser.next("div.teaser");var f=c.getCurrentSelectedMenueDynamic.next("a");var g=c.getCurrentSelectedAutomaticNavigation.next("a");f.addClass("active");d.fadeIn(b.animationSpeed,function(){c.getCurrentSelectedGroupTeaser.fadeOut(b.animationSpeed,function(){a(this).removeClass("active prepareAnimation");d.addClass("active prepareAnimation");g.addClass("active")})})}else if(c.type=="prev"){var d=c.getCurrentSelectedGroupTeaser.prev("div.teaser");var f=c.getCurrentSelectedMenueDynamic.prev("a");var g=c.getCurrentSelectedAutomaticNavigation.prev("a");f.addClass("active");d.fadeIn(b.animationSpeed);c.getCurrentSelectedGroupTeaser.fadeOut(b.animationSpeed,function(){a(this).removeClass("active prepareAnimation");d.addClass("active prepareAnimation");g.addClass("active")})}else if(c.type=="jumptolast"||c.type=="jumptofirst"){var d=c.getCurrentSelectedGroupTeaser;var f=c.getCurrentSelectedMenueDynamic;var g=c.getCurrentSelectedAutomaticNavigation;f.addClass("active");a("div.teaser.active.prepareAnimation").fadeOut(b.animationSpeed,function(){a(this).removeClass("active prepareAnimation")});d.fadeIn(b.animationSpeed,function(){a(this).addClass("active prepareAnimation");g.addClass("active")})}else{}}else{c.getCurrentSelectedGroupTeaser.removeClass("active").addClass("visibleNo");c.getCurrentSelectedMenueDynamic.removeClass("active");c.getCurrentSelectedAutomaticNavigation.removeClass("active");if(c.type=="next"){c.getCurrentSelectedGroupTeaser.next("div.teaser").removeClass("visibleNo").addClass("active");c.getCurrentSelectedMenueDynamic.next("a").addClass("active");c.getCurrentSelectedAutomaticNavigation.next("a").addClass("active")}else{c.getCurrentSelectedGroupTeaser.prev("div.teaser").removeClass("visibleNo").addClass("active");c.getCurrentSelectedMenueDynamic.prev("a").addClass("active");c.getCurrentSelectedAutomaticNavigation.prev("a").addClass("active")}}p({clearInterval:c.clearInterval})}}if(d.progressbar==true){function s(b){a("#progressbar").animate({width:d.mainContainerWidth+"px"},b*1e3)}function t(){a("#progressbar").stop();a("#progressbar").css("width","0px")}}}else{var u=g}d.callFunctionAfterSuccess()}else{if(d.debug){c.debugOutput({error:"no animation container found!"})}}},debugOutput:function(c){function d(){var a=typeof c.error=="object"?c.error:c.debugOuputMessagePrefix+c.error;console.log(a)}var c=a.extend({error:null,debugOuputMessagePrefix:""},c||{});c=a.extend({},b,c);if(c.error&&"console"in window&&"firebug"in console){d()}}};a.fn.autoteaser=function(b){if(c[b]){return c[b].apply(this,Array.prototype.slice.call(arguments,1))}else if(typeof b==="object"||!b){return c.init.apply(this,arguments)}else{a.error("Method "+b+" does not exist on $.autoteaser")}}})($)
