var viewer;var slideshow;Event.onDOMReady(function(){var b=$$("a.herolink");viewer=new AC.ViewMaster.Viewer($$("div#herocontent div"),"herocontent","herolink",{silentTriggers:true}),galleryCount=2,activeId=1;
viewer.setDelegate({willShow:function(e,f,d){var h=d.id.match(/\d+/)[0];if(h<=galleryCount){var g=-parseInt($("heroimage"+h).getStyle("left"));
if(activeId<=galleryCount){if(AC.Detector._isWebKit){$("herogallery").style.webkitTransform="translate3d("+g+"px, 0, 0)";
if(c){c.translatePos=g}}else{new Effect.Move("herogallery",{x:g,duration:0.4,mode:"absolute"})
}}else{$("herogallery").setStyle({left:+g+"px"}).appear({duration:0.4})}}else{if(activeId<=galleryCount){$("herogallery").fade({duration:0.4})
}}activeId=h}});slideshow=new AC.ViewMaster.Slideshow(viewer,null,{autoplay:true,delay:6400});
b.each(function(d){d.observe("mousedown",function(f){slideshow.stop()})});if(AC.Detector.isiPad()||AC.Detector.isiPhone()){var c=new trackTouchMove($("herogallery"))
}$("main").removeClassName("loading");var a=new Image();a.src="http://images.apple.com/global/elements/quicktime/loading.gif"
});var trackTouchMove=Class.create({touchstart:{x:false,y:false},touchmove:{x:false,y:false},touchend:{x:false,y:false},translatePos:0,defaultCancelLimit:30,defaultCancelLimitLarge:100,rightLimit:5229,initialize:function(a){this.cancelLimit=this.defaultCancelLimit;
this.element=a;this.element.style.webkitTransform="translate3d(0, 0, 0)";this.element.observe("touchstart",this.onStart.bind(this));
this.element.observe("touchmove",this.onMove.bind(this));this.element.observe("touchend",this.onEnd.bind(this));
this.element.observe("touchcancel",this.onEnd.bind(this))},onStart:function(a){if(a.touches.length===1){this.startingPosition=this.translatePos;
this.touchstart.x=a.touches[0].clientX;this.touchstart.y=a.touches[0].clientY;this.element.addClassName("dragging")
}},onMove:function(d){if(d.touches.length===1&&!this.cancelX){var b=d.touches[0].clientX;
this.touchmove.x=(this.touchend.x!==false)?b-this.touchend.x:b-this.touchstart.x;
this.touchend.x=b;var a=d.touches[0].clientY;this.touchmove.y=(this.touchend.y!==false)?a-this.touchend.y:a-this.touchstart.y;
this.touchend.y=a;if(Math.abs(this.touchmove.y)<=4){d.stop()}else{if(Math.abs(this.touchmove.y)>(Math.abs(this.touchmove.x)+70)){this.cancelX=true
}}if(!this.slideshowStopped){slideshow.stop();this.slideshowStopped=true}var c=Math.abs(b-this.touchstart.x);
if(c>this.defaultCancelLimitLarge){this.cancelLimit=this.defaultCancelLimitLarge
}if(!isNaN(this.touchmove.x)){this.translatePos+=this.touchmove.x;if(this.translatePos<0&&this.translatePos>=-this.rightLimit){this.element.style.webkitTransform="translate3d("+this.translatePos+"px, 0, 0)"
}else{this.cancelEvent=true;this.translatePos=this.translatePos>=0?0:-this.rightLimit
}}}},onEnd:function(a){if(this.touchstart.x!==false&&this.touchend.x!==false){this.touchdiffx=this.touchend.x-this.touchstart.x;
this.element.removeClassName("dragging");if(Math.abs(this.touchdiffx)<=this.cancelLimit){a.stop();
this.translatePos=this.startingPosition;this.element.style.webkitTransform="translate3d("+this.startingPosition+"px, 0, 0)"
}else{if(!this.cancelEvent){if(this.touchdiffx>0){viewer.triggerClicked(a,$("hero-nav-prev"))
}else{viewer.triggerClicked(a,$("hero-nav-next"))}}else{this.translatePos=this.startingPosition;
this.element.style.webkitTransform="translate3d("+this.startingPosition+"px, 0, 0)"
}}}this.touchstart.x=false;this.touchmove.x=false;this.touchend.x=false;this.cancelEvent=false;
this.cancelX=false;this.cancelLimit=this.defaultCancelLimit}});
