(function(b){if(!b){alert("The Promo Rotator requires jQuery.  Aborting rotation.");return}if(typeof b.fn.PromoRotator=="function"){return}function c(f,e){var g=f.data("PromoRotator"),h=f.attr("id");this.jq_promo_ref=e;this.jq_promo_ref.css("position","absolute").css("left","0").css("top","0");this.triggerLink=false;if(promoNav){var d=g.promos.length;this.triggerLink=b('<a href="'+(this.jq_promo_ref.attr("href")&&this.jq_promo_ref.attr("href").length>0?this.jq_promo_ref.attr("href"):"javascript:void(0)")+'" onmouseover="$(\'#'+h+"').PromoRotator('show', "+d+')" onmouseout="$(\'#'+h+"').PromoRotator('out')\"><span>"+(d+1)+"</span></a>");if(promoNav.get(0).tagName.toLowerCase()=="ul"){promoNav.append(b("<li></li>").append(this.triggerLink))}else{promoNav.append(this.triggerLink)}}}var a={init:function(d){return this.each(function(){var l=b(this),h=this.id;if(!l.data("PromoRotator")){l.data("PromoRotator",{})}var j=l.data("PromoRotator");var k=b.extend({},{delay:"8",fade:true,animate_time:"2",dynamic_nav:true,causata_promos:false,causata_decision_url:"",causata_decision_timeout:2,show_campaign_by_id:false,show_campaign_callback:false,begin_with_stored_data:false,single_promo_callback:false,zero_promo_callback:false},d);l.css("overflow","visible");if(k.begin_with_stored_data){j.began_with_stored_data=true;k.delay=j.delay;k.fade=j.fade;k.animate_time=j.animate_time;k.dynamic_nav=j.dynamic_nav;k.single_promo_callback=j.single_promo_callback;k.zero_promo_callback=j.zero_promo_callback}j.show_default_content_timeout=false;if(k.causata_promos&&k.causata_decision_url&&k.causata_decision_timeout>0){window.mboxDecision=function(r){var q=r.mbox;if(!q){return}var p=b("#"+q),u=p.data("PromoRotator");if(u.began_with_stored_data){return}var t="profile.decision-"+q;var s=r[t];if(r[t]!==undefined){if(u.show_default_content_timeout){clearTimeout(u.show_default_content_timeout);u.show_default_content_timeout=false}b("#"+q).PromoRotator({show_campaign_by_id:r[t]})}else{p.PromoRotator("show_default_content")}};j.delay=k.delay;j.fade=k.fade;j.animate_time=k.animate_time;j.dynamic_nav=k.dynamic_nav;j.single_promo_callback=k.single_promo_callback;j.zero_promo_callback=k.zero_promo_callback;j.show_default_content_timeout=setTimeout("$('#"+this.id+"').PromoRotator('show_default_content')",k.causata_decision_timeout*1000);var g=k.causata_decision_url+"?mbox="+this.id;var n=document.createElement("script");n.src=g;document.getElementsByTagName("head")[0].appendChild(n);return}if(k.show_campaign_by_id!==false){var m="campaign_"+k.show_campaign_by_id;var e=j[m];if(e){if(typeof j.rotateTimerID!="undefined"&&j.rotateTimerID){window.clearTimeout(j.rotateTimerID)}b("a",this).hide();l.append(e);j.showingCampaignByID=true;if(typeof j.single_promo_callback=="function"){j.single_promo_callback()}if(typeof window.jsHub=="object"&&typeof window.diSiteData=="object"){jsHub.configure("causata-transport.account",diSiteData.fiId);jsHub.configure("causata-transport.server",diSiteData.causataServer);jsHub.trigger("impression",{"custom-event":true,slot:this.id,offer:k.show_campaign_by_id})}}else{if(!j.showingCampaignByID){a.show_default_content.apply(l)}}return}else{if(j.showingCampaignByID){return}}promoNav=false;if(k.dynamic_nav){promoNav=b("#"+this.id+"_promoNav");var i=b("ul",promoNav);promoNav=(i.length>0)?i:promoNav;if(promoNav.length==0){promoNav=false}}j.fade=k.fade=(k.fade&&k.fade!="false"&&k.fade!="0")?true:false;j.delay=k.delay=isNaN(parseFloat(k.delay))?8:parseFloat(k.delay);j.animate_time=k.animate_time=isNaN(parseFloat(k.animate_time))?2:parseFloat(k.animate_time);j.promos=new Array();var o=b("."+this.id+"_promo",l);o.each(function(){b(this).show();j.promos.push(new c(l,b(this),this.id))});if(o.length==1&&typeof k.single_promo_callback=="function"){k.single_promo_callback()}if(o.length==0){if(typeof k.zero_promo_callback=="function"){k.zero_promo_callback()}return}j.rotateTimerID=0;j.firstSwap=true;var f=Math.floor(Math.random()*j.promos.length);a.updateNextIndex.apply(l,[f]);a.swap.apply(l)})},swap:function(d){return this.each(function(){var g=b(this),f=g.data("PromoRotator");if(f.rotateTimerID){window.clearTimeout(f.rotateTimerID)}if(f.firstSwap||!f.fade||d){if(f.rotateTimerID){clearTimeout(f.rotateTimerID)}if(f.currentIndex!=f.nextIndex){b("#"+this.id+" ."+this.id+"_promo").stop().not(f.promos[f.nextIndex].jq_promo_ref).fadeTo(0,0).css("z-index",9).hide();f.promos[f.nextIndex].jq_promo_ref.stop().fadeTo(0,1).css("z-index",10).show();a.updateIndexes.apply(g);if(f.promos[f.nextIndex].triggerLink){b("a",promoNav).removeClass("on");f.promos[f.currentIndex].triggerLink.addClass("on")}}f.firstSwap=false}else{var e=f.animate_time;if(f.currentIndex!=f.nextIndex){f.promos[f.currentIndex].jq_promo_ref.fadeTo(f.animate_time*1000,0,function(){b(this).css("z-index",9).fadeTo(0,0).hide()});f.promos[f.nextIndex].jq_promo_ref.fadeTo(0,1).fadeTo(f.animate_time*1000,1,function(){b(this).css("z-index",10)});f.rotateTimerID=setTimeout(function(){a.updateIndexes.apply(g);if(f.promos[f.currentIndex].triggerLink){b("a",promoNav).removeClass("on");f.promos[f.currentIndex].triggerLink.addClass("on")}f.rotateTimerID=0},(f.animate_time*1000)/2)}}if(!f.isOver){a.nextSwap.apply(g)}})},updateNextIndex:function(d){return this.each(function(){var f=b(this),e=f.data("PromoRotator");e.nextIndex=(d<0)?(d+e.promos.length):(Math.abs(d)%e.promos.length)})},updateIndexes:function(){return this.each(function(){var e=b(this),d=e.data("PromoRotator");d.currentIndex=d.nextIndex})},nextSwap:function(){return this.each(function(){var e=b(this),d=e.data("PromoRotator");if(d.delay>0&&d.promos.length>1&&!d.isOver){a.updateNextIndex.apply(e,[d.currentIndex>-1?d.currentIndex+1:d.nextIndex+1]);d.rotateTimerID=setTimeout(function(){a.swap.apply(e,[false])},d.delay*1000);return true}else{return false}})},skipForward:function(){return this.each(function(){var e=b(this),d=e.data("PromoRotator");a.updateNextIndex.apply(e,[d.currentIndex+1]);a.swap.apply(e,[true]);return false})},skipBack:function(){return this.each(function(){var e=b(this),d=e.data("PromoRotator");a.updateNextIndex.apply(e,[d.currentIndex-1]);a.swap.apply(e,[true]);return false})},show:function(d){return this.each(function(){var f=b(this),e=f.data("PromoRotator");a.updateNextIndex.apply(f,[d]);e.isOver=true;a.swap.apply(f,[true])})},go:function(){return this.each(function(){var e=b(this),d=e.data("PromoRotator");document.location.href=d.promos[d.currentIndex].jq_promo_ref.attr("href")})},out:function(){return this.each(function(){var e=b(this),d=e.data("PromoRotator");d.isOver=false;a.nextSwap.apply(e)})},over:function(){return this.each(function(){var e=b(this),d=e.data("PromoRotator");d.isOver=true;if(d.rotateTimerID){window.clearTimeout(d.rotateTimerID)}})},show_default_content:function(){return this.each(function(){var e=b(this),d=e.data("PromoRotator");if(d.show_default_content_timeout){clearTimeout(d.show_default_content_timeout);d.show_default_content_timeout=false}if(typeof window.jsHub=="object"&&typeof window.diSiteData=="object"){jsHub.configure("causata-transport.account",diSiteData.fiId);jsHub.configure("causata-transport.server",diSiteData.causataServer);jsHub.trigger("default-impression",{"custom-event":true,slot:this.id})}b("#"+this.id).PromoRotator({begin_with_stored_data:true})})}};b.fn.PromoRotator=function(d){if(a[d]){return a[d].apply(this,Array.prototype.slice.call(arguments,1))}else{if(typeof d==="object"||!d){return a.init.apply(this,arguments)}else{b.error("Method "+d+" does not exist on jQuery.tooltip")}}}})(jQuery);
