var SWFTitle=function(){var d=false;swfobject.addDomLoadEvent(a);function a(){d=true}function b(g,f,e){if(swfobject.hasFlashPlayerVersion("9.0.0")){if(d){document.getElementyById(g).style.visibility="hidden"}else{swfobject.createCSS("#"+g,"visibility:hidden")}swfobject.addDomLoadEvent(function(){c(g,f,e)})}}function c(j,h,f){var g=document.getElementById(j);g.style.visibility="visible";var e=g.innerText!=undefined?g.innerText:g.textContent;f=f!=undefined?(""+f):"55";swfobject.embedSWF(h,j,"100%",f,"9.0.0",null,{t:escape(e)},{wmode:"transparent",menu:"false"})}return{register:b}}();var BoxSwitcher=new Class({initialize:function(a){var b=$(a);var c=b.getElement("ul");if(b&&c){this.items=c.getElements("li");if(this.items.length>0){this.items.each(function(f,d){var e=f.getElements("div.smldesc a");if(e.length>0){e.each(function(g){g.addEvent("click",function(h){h=new Event(h).stop();this.toggle(d)}.bind(this))},this)}},this)}}},toggle:function(a){this.items.each(function(c,b){if(b==a){c.removeClass("collapsed");c.addClass("expanded")}else{c.removeClass("expanded");c.addClass("collapsed")}});return true}});var SearchForm=new Class({initialize:function(a){var d=$(a);var e=d.getElements("input[type=text]");var c=/Enter (Keywords|Zip Code)/;e.each(function(f){f.defaultText=(c.test(f.defaultValue))?f.defaultValue:"";f.addEvents({focus:function(){if(this.value==this.defaultText){this.value=""}else{this.select()}},blur:function(){if(this.value==""){this.value=this.defaultText}}})});var b=d.getElement(".submit");if(b){b.addEvent("click",function(f){f=new Event(f).stop();d.submit()})}}});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);var SlidePane2=new Class({options:{initial:0,indexButtons:null,previousButtons:null,nextButtons:null,buttonOnClass:null,fx:{duration:750,transition:Fx.Transitions.Expo.easeInOut}},current:null,wrapper:null,items:[],scroller:null,initialize:function(f,a,d,e){var c=this;this.setOptions(e);this.wrapper=$(f);this.items=d;var b=0;this.items.each(function(j,g){var h=$(j).getSize();b+=parseInt(h.size[c.options.orientation=="vertical"?"y":"x"])});a.setStyle("width",b+"px");if(this.options.previousButtons){this.options.previousButtons.addEvent("click",function(g){new Event(g).stop();c.previous()})}if(this.options.nextButtons){this.options.nextButtons.addEvent("click",function(g){new Event(g).stop();c.next()})}if(this.options.indexButtons){this.options.indexButtons.each(function(h,g){$(h).addEvent("click",function(j){new Event(j).stop();c.shift(g)})})}this.scroller=new Fx.Scroll(this.wrapper,this.options.fx);this.shift(this.options.initial)},previous:function(){if(this.current>0){return this.shift(this.current-1)}return false},next:function(){if((this.current+1)<this.items.length){return this.shift(this.current+1)}return false},shift:function(a){if(this.current!=a){this.scroller.toElement(this.items[a]);if(this.options.indexButtons&&this.options.indexButtons.length&&this.options.buttonOnClass){this.options.indexButtons.removeClass(this.options.buttonOnClass);this.options.indexButtons[a].addClass(this.options.buttonOnClass)}this.current=a}}});SlidePane2.implement(new Options);var ReleaseBrowser=function(a){this.init(a)};ReleaseBrowser.prototype={currentRelease:null,slidepane:null,release:null,releaseButtons:null,releaseAnim:null,init:function(b){var a=this;this.release=b.getElement(".hero-release");this.releaseButtons=b.getElements(".release-list a");this.releaseAnim=new Fx.Style(this.release,"opacity",{duration:250,wait:false});this.releaseButtons.addEvent("click",function(c){new Event(c).stop();var d=$(this).getProperty("data-title-id");if(d!=a.currentRelease){a.releaseButtons.removeClass("on");$(this).addClass("on");a.load(d,$(this).getProperty("href"))}});this.slidepane=new SlidePane2(b.getElement(".hero-releases-list .crop"),b.getElement(".hero-releases-list .inner"),b.getElements(".release-list"),{indexButtons:b.getElements(".bubblenav a"),buttonOnClass:"on"})},load:function(c,b){var a=this;this.releaseAnim.start(0).chain(function(){new Ajax(b,{method:"get",update:a.release,onSuccess:function(){a.currentRelease=c;a.release.setProperty("data-title-id",c);a.releaseAnim.start(1);var d=a.release.getElements("a.track");if(d){ToothPlayer.prepareTracks(d)}}}).request()})}};window.addEvent("domready",function(){var a=$$(".releases-hero");if(a){a.each(function(c,b){new ReleaseBrowser(c)})}});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 VideoBrowser={currentVideo:null,video:null,videoIframe:null,videoButtons:null,videoAnim:null,init:function(b){var a=this;this.video=b.getElement(".video");this.videoIframe=this.video.getElement("iframe");this.videoButtons=b.getElements(".videos-list a");this.videoAnim=new Fx.Style(this.video,"opacity",{duration:250,wait:false});this.videoButtons.addEvent("click",function(h){var j=$(this).getProperty("data-video-id");var f=$(this).getProperty("data-video-youtube-key");if($(this).getProperty("target")!="_blank"){new Event(h).stop();if(j!=a.currentVideo){a.videoButtons.removeClass("on");$(this).addClass("on");a.load(j,f)}}var d="/track/play/video/"+j+"/";var g=new Ajax(d,{method:"get"}).request()});var c=this.video.getProperty("data-video-id");if(c){this.currentVideo=c}},load:function(c,b){var a=this;this.video.setProperty("data-video-id",c);this.videoIframe.setProperty("src","http://www.youtube.com/embed/"+b)}};window.addEvent("domready",function(){var d=$$(".hero-frame");var c=$$(".undertab a");var e=c.shift();function a(){ToothHeroTabs.setHero(null);e.addClass("on")}ToothHeroTabs.init(d,c);e.addEvent("click",function(f){new Event(f).stop();a()});c.addEvent("click",function(f){new Event(f).stop();e.removeClass("on")});if(!ToothHeroTabs.hashed){a()}ToothHeroPhotos.init();if($("videos")){VideoBrowser.init($("videos"));var b=new SearchForm("videos-search")}});
