var ToothPromos={animSpeed:250,autoDelay:5000,auto:true,animating:false,currentPromo:null,currentPromoIndex:null,hero:null,promos:null,promoButtons:null,prevPromoButton:null,nextPromoButton:null,label:null,promoAnim:[],labelAnim:null,init:function(c){var a=this;this.hero=$("hero");this.promos=c;this.promoButtons=this.hero.getElements(".bubblenav ol a");this.prevPromoButton=this.hero.getElement(".bubblenav .prev");this.nextPromoButton=this.hero.getElement(".bubblenav .next");this.label=this.hero.getElement(".undertab h4");if(this.hero&&this.promos&&this.promoButtons&&this.label){this.promos.each(function(e,d){a.promoAnim.push(new Fx.Style(e,"opacity",{duration:a.animSpeed,wait:false}).set(0))});this.labelAnim=new Fx.Style(this.label,"opacity",{duration:this.animSpeed,wait:false});function b(){$clear(a.auto)}this.promoButtons.each(function(e,d){$(e).addEvent("click",function(f){new Event(f).stop();b();a.select(d)})});this.prevPromoButton.addEvent("click",function(d){new Event(d).stop();b();a.prev()});this.nextPromoButton.addEvent("click",function(d){new Event(d).stop();b();a.next()});this.auto=this.next.periodical(this.autoDelay,this);this.select(0,true)}},select:function(c,b){var a=this;var b=typeof b=="boolean"?b:false;if(this.animating){return}if(this.currentPromoIndex!=c){var d=this.promoButtons[c].getText();if(b){this.promoAnim[c].element.setStyle("display","block");this.promoAnim[c].set(1);a.label.setText(d)}else{this.animating=true;this.promoAnim[this.currentPromoIndex].start(0).chain(function(){a.promoAnim[c].element.setStyle("display","block");a.promoAnim[c].start(1).chain(function(){a.animating=false})});this.labelAnim.start(0).chain(function(){a.label.setText(d);this.start(1)})}this.promoButtons.getParent().removeClass("on");this.promoButtons[c].getParent().addClass("on");this.currentPromoIndex=c}},prev:function(){this.select(this.currentPromoIndex>0?this.currentPromoIndex-1:this.promos.length-1)},next:function(){this.select(this.currentPromoIndex<(this.promos.length-1)?this.currentPromoIndex+1:0)}};var ToothHeroTabs={hashed:false,heroHashes:[],heroFrames:null,heroTabs:null,currentFrame:null,heroAnim:[],init:function(d,f,c){var a=this;var c=typeof c=="undefined"?0:c;this.heroFrames=d;this.heroTabs=f;var b=[];a.heroFrames.each(function(g){var h=$(g).getProperty("id");if(h){b.push("#"+h)}if(Modernizr.csstransitions){$(g).setStyle("opacity",0)}else{a.heroAnim.push(new Fx.Style(g,"opacity",{duration:250,wait:false}).set(0))}});this.heroTabs.each(function(j,h){var g=j.getProperty("href");if(b.indexOf(g)>=0){a.heroHashes[h]=g}j.addEvent("click",function(k){new Event(k).stop();a.setHero(h)})});var e=document.location.hash;if(e&&this.heroHashes.indexOf(e)>=0){c=this.heroHashes.indexOf(e);this.hashed=true}if(typeof c=="number"){this.setHero(c,true)}},setHero:function(l,m){var o=this;m=typeof m=="boolean"?m:false;var c=f();var e=(typeof this.currentFrame=="number"&&this.heroFrames[this.currentFrame]);var d=(typeof l=="number"&&this.heroFrames[l]);this.heroTabs.removeClass("on");if(d){this.heroTabs[l].addClass("on")}if(this.currentFrame!=l){ToothPlayer.hidePlaylists();if(d){this.heroFrames[l].setStyle("display","block")}if(m&&d){if(Modernizr.csstransitions){this.heroFrames[l].setStyle("opacity",1)}else{this.heroAnim[l].set(1)}}else{if(Modernizr.csstransitions){var b={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd",msTransition:"msTransitionEnd",transition:"transitionEnd"};var j=b[Modernizr.prefixed("transition")];if(e){var g=this.heroFrames[this.currentFrame];function n(){g.setStyles({display:"none",opacity:0});g.removeEventListener(j,n,false)}g.addEventListener(j,n,false);g.style.opacity=0;if(g.getElements("iframe")){g.getElements("iframe").setStyle("display","none")}}if(d){var k=this.heroFrames[l];var h=k.getElements("iframe");if(h){function a(){h.setStyle("display","block");k.removeEventListener(j,a,false)}k.addEventListener(j,a,false)}k.setStyles({display:"block",opacity:1})}}else{if(e){if(c!=8){this.heroAnim[this.currentFrame].start(0).chain(function(){o.heroFrames[o.currentFrame].setStyle("display","none");if(d){o.heroAnim[l].start(1)}})}else{this.heroFrames[this.currentFrame].setStyle("visibility","hidden");this.heroFrames[this.currentFrame].setStyle("display","none");if(d){this.heroFrames[l].setStyle("visibility","visible");this.heroFrames[l].setStyle("display","block")}}}else{if(d){o.heroAnim[l].start(1)}}}}this.currentFrame=l}if(ToothHeroPhotos.heroPhotosInited){ToothHeroPhotos.centerThumbsImgs();ToothHeroPhotos.setMegaImgSizes();ToothHeroPhotos.paginatePhotos()}function f(){var r=-1;if(navigator.appName=="Microsoft Internet Explorer"){var p=navigator.userAgent;var q=new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})");if(q.exec(p)!=null){r=parseFloat(RegExp.$1)}}return r}}};var ToothHeroPhotos={heroThumbs:null,heroMega:null,heroMegaInner:null,heroNav:null,heroNavThumbs:null,heroNavMega:null,heroThumbThumbs:null,heroThumbImgs:null,heroMegaImgs:null,heroMegaImgSizes:[],heroMegaImgAnim:[],heroPhotoCurrent:0,heroPhotoTotal:0,heroSlideshowControls:{},heroSlideshow:false,heroIsMega:false,heroPhotosInited:false,heroPaginatedPhotos:false,heroSliderObj:null,heroSliderPane:0,heroThumbAnim:[],heroMegaAnim:null,init:function(){var a=this;this.heroThumbs=$$(".photos-hero-thumbs");this.heroMega=$$(".photos-hero-mega");this.heroMegaInner=$$(".photos-hero-mega ul");this.heroMegaInnerWidth=923;this.heroMegaMargin=3;this.heroNav=$$(".photos-hero-nav");this.heroNavThumbs=$$(".photos-hero-nav-thumbs");this.heroNavMega=$$(".photos-hero-nav-mega");this.heroThumbThumbs=$$(".photos-hero-thumbs .hero-right a");this.heroThumbImgs=$$(".photos-hero-thumbs .hero-left li");this.heroMegaImgs=$$(".photos-hero-mega li");this.heroPhotoTotal=this.heroThumbThumbs.length-1;this.heroPhotoPanes=Math.round(this.heroPhotoTotal/15);this.heroSlideshowControls.wrapper=$$(".photos-hero-slideshow-nav");this.heroSlideshowControls.prev=$$(".photos-hero-slideshow-nav .prev");this.heroSlideshowControls.next=$$(".photos-hero-slideshow-nav .next");this.heroSlideshowControls.play=$$(".photos-hero-slideshow-nav .play");this.heroSlideshowControls.pause=$$(".photos-hero-slideshow-nav .pause");this.heroThumbImgs.each(function(c,b){a.heroThumbAnim.push(new Fx.Style(c,"opacity",{duration:450,wait:false}).set(0))});this.heroMegaInner.each(function(c,b){a.heroMegaAnim=new Fx.Style(c,"left",{duration:500,wait:false}).set(0)});this.heroMegaImgs.each(function(c,b){a.heroMegaImgAnim.push(new Fx.Style(c,"opacity",{duration:300,wait:false}).set(0))});this.heroThumbThumbs.each(function(c,b){c.addEvent("click",function(d){new Event(d).stop();a.setThumbsPhoto(b);a.setMegaPhoto(b)})});this.heroMegaImgs.each(function(c,b){c.addEvent("click",function(d){new Event(d).stop();a.setThumbsPhoto(b);a.setMegaPhoto(b)})});this.heroSlideshowControls.prev.addEvent("click",function(b){new Event(b).stop();a.prevThumbPhoto();a.heroSlideshow?a.startSlideshow(false):""});this.heroSlideshowControls.next.addEvent("click",function(b){new Event(b).stop();a.nextThumbPhoto();a.heroSlideshow?a.startSlideshow(false):""});this.heroSlideshowControls.play.addEvent("click",function(b){new Event(b).stop();a.startSlideshow()});this.heroSlideshowControls.pause.addEvent("click",function(b){new Event(b).stop();a.stopSlideshow()});if(this.heroPhotoTotal>-1){this.heroPhotosInited=true;a.heroNavThumbs.addEvent("click",function(b){new Event(b).stop();a.setPhotoNavToThumbs()});a.heroNavMega.addEvent("click",function(b){new Event(b).stop();a.setPhotoNavToMega()});a.centerThumbsImgs();a.setMegaImgSizes();a.setPhotoNavToThumbs();a.paginatePhotos();this.heroSlideshowControls.pause.setStyle("display","none");this.heroMegaInner.setStyle("left",this.heroMegaInnerWidth+"px");this.setThumbsPhoto(0)}},setPhotoNavToThumbs:function(){this.heroThumbs.setStyle("display","block");this.heroMega.setStyle("display","none");this.heroNavThumbs.addClass("on");this.heroNavMega.removeClass("on");this.heroSlideshowControls.wrapper.removeClass("mega-nav");this.heroIsMega=false},setPhotoNavToMega:function(){this.heroThumbs.setStyle("display","none");this.heroMega.setStyle("display","block");this.heroNavThumbs.removeClass("on");this.heroNavMega.addClass("on");this.heroSlideshowControls.wrapper.addClass("mega-nav");this.heroIsMega=true;this.setMegaPhoto(this.heroPhotoCurrent)},nextThumbPhoto:function(){var a=this.heroPhotoCurrent;if(this.heroPhotoCurrent>=this.heroPhotoTotal){a=0}else{a+=1}this.setThumbsPhoto(a);this.setMegaPhoto(a)},prevThumbPhoto:function(){var a=this.heroPhotoCurrent;if(this.heroPhotoCurrent==0){a=this.heroPhotoTotal}else{a-=1}this.setThumbsPhoto(a);this.setMegaPhoto(a)},setThumbsPhoto:function(b){var a=this;if(this.heroThumbThumbs[b]){this.heroThumbThumbs.removeClass("on");this.heroThumbThumbs[b].addClass("on");var c=Math.floor(b/15);if(this.heroSliderObj){this.heroSliderPane=c;this.heroSliderObj.shift(c)}this.heroThumbAnim[this.heroPhotoCurrent].start(0).chain(function(){a.heroThumbAnim[b].set(1)});this.heroPhotoCurrent=b}},setMegaPhoto:function(c){var b=this;this.heroPhotoCurrent=c;this.setMegaImgSizes();var d=0;for(i=0;i<=b.heroMegaImgSizes.length;i++){if(i<this.heroPhotoCurrent){d+=b.heroMegaImgSizes[i].size.x;d+=b.heroMegaMargin}else{continue}}var a=(this.heroMegaInnerWidth-this.heroMegaImgSizes[this.heroPhotoCurrent].size.x)/2;d=(-d)+a;b.heroMegaImgs.each(function(f,e){b.heroMegaImgAnim[e].start(0.5);f.addClass("inactive")});this.heroMegaAnim.start(d+"px").chain(function(){b.heroMegaImgAnim[b.heroPhotoCurrent].start(1)});b.heroMegaImgs[c].removeClass("inactive")},startSlideshow:function(b){var a=this;clearTimeout(this.heroSlideshow);if(b==true||b==undefined){this.nextThumbPhoto()}this.heroSlideshow=setTimeout(function(){a.startSlideshow()},4000);this.heroSlideshowControls.play.setStyle("display","none");this.heroSlideshowControls.pause.setStyle("display","block")},stopSlideshow:function(a){clearTimeout(this.heroSlideshow);this.heroSlideshow=false;this.heroSlideshowControls.pause.setStyle("display","none");this.heroSlideshowControls.play.setStyle("display","block")},setMegaImgSizes:function(){var a=this;this.heroMegaImgs.each(function(c,b){var d=c.getElement("img");a.heroMegaImgSizes[b]=d.getSize()})},centerThumbsImgs:function(){var a=this;this.heroThumbThumbs.each(function(d,c){maxThumbImgSize={w:95,h:95};maxLargeImgSize={w:360,h:328};var f=a.heroThumbThumbs[c].getElement("img");var e=a.heroThumbImgs[c].getElement("img");b(f,maxThumbImgSize);b(e,maxLargeImgSize);function b(g,j){var h=g.getSize();if(h.size.x>0){if(h.size.x>j.w&&h.size.x>h.size.y){h.size.y=(h.size.y*j.w)/h.size.x;h.size.x=j.w;g.setStyle("width",h.size.x+"px");g.setStyle("height",h.size.y+"px")}g.setStyle("margin-left",((j.w-h.size.x)/2)+"px")}if(h.size.y>0){if(h.size.y>j.h&&h.size.y>h.size.x){h.size.x=(h.size.x*j.h)/h.size.y;h.size.y=j.h;g.setStyle("height",h.size.y+"px");g.setStyle("width",h.size.x+"px")}g.setStyle("margin-top",((j.h-h.size.y)/2)+"px")}}})},paginatePhotos:function(){var a=this;if(!this.heroPaginatedPhotos){if(this.heroThumbs[0].getElement(".hero-right .inner").getSize().size.x>0){this.heroPaginatedPhotos=true;this.heroThumbs.each(function(c,b){a.heroSliderObj=new SlidePane(c.getElement(".hero-right"),{contentClass:"inner",itemClass:"photos-thumbs-list",indexButtons:c.getElements(".bubblenav a"),orientation:"horizontal",fxOptions:{wait:false,duration:750,transition:Fx.Transitions.Expo.easeInOut}})})}}}};window.ToothPromos=ToothPromos;window.ToothHeroTabs=ToothHeroTabs;window.ToothHeroPhotos=ToothHeroPhotos;var SlidePane=new Class({options:{initial:0,orientation:"horizontal",prevClass:"prev",nextClass:"next",indexButtons:null,contentClass:"content",itemClass:"content-item",fxOptions:{duration:500},onShiftStart:Class.empty,onShiftComplete:Class.empty},slideProperty:null,pane:null,contentWindow:null,contentItems:[],slideAnim:null,initialize:function(f,e){var d=this;this.setOptions(e);this.pane=$(f);this.contentWindow=this.pane.getElement("."+this.options.contentClass);var b=this.pane.getElements("."+this.options.prevClass);var a=this.pane.getElements("."+this.options.nextClass);if(b.length>0){b.each(function(h){h.addEvent("click",function(j){h.blur();this.previous(j)}.bind(this))},this)}if(a.length>0){a.each(function(h){h.addEvent("click",function(j){h.blur();this.next(j)}.bind(this))},this)}if(this.options.indexButtons){this.options.indexButtons.each(function(j,h){$(j).addEvent("click",function(k){new Event(k).stop();this.blur();d.shift(h)})})}var c=this.pane.getElements("."+this.options.itemClass);this.contentItems=[];var g=0;c.each(function(k){var j=k.getSize();var h={item:k,width:j.size.x,height:j.size.y};g=g+j.size.x;this.contentItems.push(h)},this);this.options.fxOptions.onStart=function(){this.fireEvent("onShiftStart",this.currentItem)}.bind(this);this.options.fxOptions.onComplete=function(){this.fireEvent("onShiftComplete",this.currentItem)}.bind(this);this.slideProperty=(this.options.orientation=="vertical")?"top":"left";this.contentWindow.setStyle(this.slideProperty,0);this.contentWindow.setStyles({position:"absolute",width:g});if(!Modernizr.csstransitions){this.slideAnim=new Fx.Style(this.contentWindow,this.slideProperty,this.options.fxOptions)}if(this.contentItems.length<this.options.initial){this.options.initial=0}this.shift(this.options.initial)},previous:function(a){a=new Event(a).stop();if((this.currentItem-1)>=0){this.shift((this.currentItem-1))}},next:function(a){a=new Event(a).stop();if((this.currentItem+1)<this.contentItems.length){this.shift((this.currentItem+1))}},shift:function(c){this.currentItem=c;var b=0;if(c>0){for(var a=0;a<c;a++){if(this.options.orientation=="vertical"){b=b+this.contentItems[a].height}else{b=b+this.contentItems[a].width}}}if(this.options.indexButtons){this.options.indexButtons.each(function(e,d){if(d==c){$(e).addClass("on")}else{$(e).removeClass("on")}})}b=b*-1;if(Modernizr.csstransitions){this.contentWindow.setStyle(Modernizr.prefixed("transition"),this.slideProperty+" "+this.options.fxOptions.duration+"ms ease-in-out");this.contentWindow.setStyle(this.slideProperty,b)}else{this.slideAnim.start(b)}}});SlidePane.implement(new Events,new Options);window.addEvent("domready",function(){ToothPromos.init($$(".hero-banner"));if($("latest-news")&&$("latest-blogs")){var b=new Fx.Style("latest-news","opacity",{duration:250});var a=new Fx.Style("latest-blogs","opacity",{duration:250}).hide();$("latest-blogs").setStyle("display","none");$("latest-news-btn").addEvent("click",function(c){c=new Event(c).stop();this.getParent().removeClass("off");this.getParent().removeClass("off-start");this.getParent().addClass("on");this.getParent().addClass("on-start");this.getParent().getNext().removeClass("m-off-on");this.getParent().getNext().addClass("m-on-off");$("latest-blogs-btn").getParent().removeClass("on");$("latest-blogs-btn").getParent().addClass("off");$("latest-blogs-btn").getParent().getNext().removeClass("m-on-none");$("latest-blogs-btn").getParent().getNext().addClass("m-off-none");a.start(0).chain(function(){$("latest-blogs").setStyle("display","none");$("latest-news").setStyle("display","block");b.start(1)})});$("latest-blogs-btn").addEvent("click",function(c){c=new Event(c).stop();this.getParent().removeClass("off");this.getParent().addClass("on");$("latest-news-btn").getParent().removeClass("on");$("latest-news-btn").getParent().removeClass("on-start");$("latest-news-btn").getParent().addClass("off");$("latest-news-btn").getParent().addClass("off-start");$("latest-news-btn").getParent().getNext().removeClass("m-on-off");$("latest-news-btn").getParent().getNext().addClass("m-off-on");$("latest-blogs-btn").getParent().getNext().removeClass("m-off-none");$("latest-blogs-btn").getParent().getNext().addClass("m-on-none");b.start(0).chain(function(){$("latest-news").setStyle("display","none");$("latest-blogs").setStyle("display","block");a.start(1)})})}if($("box-blog")){new SlidePane("box-blog",{contentClass:"box-content",itemClass:"box-read-blog",fxOptions:{duration:500,transition:Fx.Transitions.Quad.easeInOut}})}});
