if(typeof(FOH)=="undefined"){FOH={}}FOH.SwapItem=Class.create({initVariables:function(){this.triggers=[];
this.title=null;this.video={url:null,poster:null,end:null};this.content=null;this.gallery=null;
this.itunes=null;this.docTitle=document.title},initialize:function(b){this.initVariables();
b=$(b);this.triggers=[b];this.title=b.down("a").innerHTML.stripTags().strip();this.category="";
if(b.up(".category").down("h4")){if(b.up(".category").down("h4")){this.category+=b.up(".category").down("h4").innerHTML.stripTags().strip()+" - "
}}else{this.category+=b.up(".category").previous("h4").innerHTML.stripTags().strip()+" - ";
if(b.up(".category").down("h5")){this.category+=b.up(".category").down("h5").innerHTML.stripTags().strip()+" - "
}}this.id=b.identify();var a=b.down("a")||b;if(a.href.match(/\.mov/)){this.video={url:b.down("a").href,end:(b.down(".endstate"))?b.down(".endstate").innerHTML:""}
}if(b.down(".gallery")){this.gallery=b.down(".gallery").innerHTML.strip()}if(b.down(".itunes")){this.itunes=b.down(".itunes").href
}if(b.down(".content")){this.content=b.down(".content").innerHTML.strip()}if(b.up("div.tabswap")){this.tab=b.up("div.tabswap")
}a.href="#";if(this.tab){a.href+="tab="+this.tab.identify()+"&"}a.href+="tutorial="+this.id+"&";
a.href=a.href.substring(0,a.href.length-1);this.setHover(0);this.setClick(0)},setHover:function(b){var a=this.triggers[b];
Event.observe(a,"mouseover",function(){a.addClassName("hover")},false);Event.observe(a,"mouseout",function(){a.removeClassName("hover")
},false)},setClick:function(b){var a=this.triggers[b];Event.observe(a,"click",function(c){if(!AC.Detector.isOpera()){if(c){var d=c.findElement("a[href]");
if(d&&!d.href.match("#")){Event.stop(c)}}this.dispatchEvent("activate",this)}}.bind(this),false)
},addTrigger:function(a){this.triggers.push(a);this.setHover(this.triggers.length-1);
this.setClick(this.triggers.length-1)},activate:function(a){document.title=this.docTitle+" - "+this.category+this.title;
this.trackClick(a);this.visited();this.triggers.each(function(b){b.addClassName("active")
})},deactivate:function(){this.triggers.each(function(a){a.removeClassName("active")
})},visited:function(){this.triggers.each(function(a){if(!a.hasClassName("visited")){a.addClassName("visited")
}})},trackClick:function(f){var d={};var c=document.location.toString().replace(/#.*/,"");
if(f.toString().match(/gallery/i)){d.prop4=c+"#tutorial="+this.id+"&gallery"}else{if(this.video.url){d.prop4=this.video.url
}else{if(this.gallery&&this.id){d.prop4=c+"#tutorial="+this.id}}}if(this.tab){var g=document.title.toString().match(/Apple - Find Out How - ([^-]*)/i)[1].toLowerCase().strip();
var e=this.tab.identify().toLowerCase().strip();d.prop2="www.us.findouthow."+g+"."+e
}var b="";if(typeof(f)!="boolean"){b+=f+": "}else{if(this.video.url){b+="V@S: "
}else{if((this.content!=null)&&(typeof(f)=="boolean")){b+="Text: "}}}var a=this.category;
var h=a.split(/-/);if((h.length-1)>1){a=a.substring(a.indexOf("-")+2,a.length)}b+=AC.Tracking.pageName()+" - "+a+this.id;
b+=" (US)";d.pageName=b;d.prop13=b.replace(/Apple - |\(US\)/g,"");AC.Tracking.trackPage(d)
}});Object.extend(FOH.SwapItem.prototype,Event.Publisher);FOH.Swap=Class.create();
Object.extend(FOH.Swap.prototype,Event.Listener);Object.extend(FOH.Swap.prototype,{initVariables:function(){this.sections={};
this.initialized=false;this.currentSection=null;this.currentController=null;this.panels={wrapper:null,movie:null,controller:null,end:null,html:null};
this.cookies=new FOH.Cookies()},initialize:function(d,c,b,a){this.initVariables();
var c=this.setExtraTriggersInfo(c);this.setSections(d,c);this.tabs=b;for(panel in a){this.panels[panel]=$(a[panel])
}this.panels.video.gallery.back.observe("click",this.showCurrent.bind(this));this.panels.video.gallery.trigger.observe("click",this.showCurrentGallery.bind(this));
this.panels.video.end.replay.observe("click",this.replayCurrent.bind(this));Event.observe(window,"unload",function(){this.currentController=null;
this.currentMovie=null}.bind(this))},setExtraTriggersInfo:function(a){a.each(function(b,c){var d=b.down("a")||b;
d=d.href.replace(/.*#/,"");d=d.toQueryParams();d=d.tutorial;a[c].writeAttribute({compareId:d})
});return a},setSections:function(e,c){for(var b=0;b<e.length;b++){var d=new FOH.SwapItem(e[b]);
if(this.cookies.data.indexOf(d.id)>-1){d.visited()}for(var a=0;a<c.length;a++){if(d.id==c[a].readAttribute("compareId")){if(a==0){this.firstSection=d
}d.addTrigger(c[a])}}this.setListener(d);this.sections[d.id]=d}this.lastSection=this.firstSection;
this.currentSection=this.firstSection},setListener:function(a){this.listenForEvent(a,"activate",false,function(b){var c=b.event_data.data;
this.show(c,false)})},showVideo:function(b,a){this.panels.wrapper.className="movie";
if(this.currentController&&!this.currentController.movie){this.onMovieShow=setTimeout(this.showVideo.bind(this,b),100)
}if(this.currentController&&this.currentController.movie){if(this.currentUrl!=b.video.url){this.currentController.SetURL(b.video.url);
this.currentUrl=b.video.url}if(!this.currentController.isPlaying()){this.currentController.Play();
if(!this.onMovieShow){this.onMovieShow=setTimeout(this.showVideo.bind(this,b),100)
}}var c=function(d){this.currentController.options.onMovieFinished=this.showEndFrame.bind(this,d)
}.bind(this,b);this.onMovieFinished=setTimeout(c,1000)}this.showVideoGalleryLink(b);
this.showiTunesLink(b)},showiTunesLink:function(a){this.panels.video.itunes.trigger.href=a.itunes;
this.panels.video.itunes.trigger.style.display=a.itunes?"block":"none"},showVideoGalleryLink:function(a){if(a.gallery){this.panels.video.gallery.back.href="#tutorial="+a.id;
if(a.tab){this.panels.video.gallery.back.href=this.panels.video.gallery.back.href.replace("#","#tab="+a.tab.identify()+"&")
}this.panels.video.gallery.trigger.href="#tutorial="+a.id+"&gallery";if(a.tab){this.panels.video.gallery.trigger.href=this.panels.video.gallery.trigger.href.replace("#","#tab="+a.tab.identify()+"&")
}this.panels.video.gallery.trigger.style.display="block"}},showGallery:function(a){if(a.gallery){this.panels.wrapper.className="gallery";
this.hideVideo(true);this.hideGallery();this.hideText();this.panels.video.gallery.display.insert(a.gallery);
new FOH.Gallery(this.panels.video.gallery.display)}},showCurrentGallery:function(){this.showGallery(this.currentSection);
this.currentSection.trackClick("Gallery")},showEndFrame:function(a){this.panels.wrapper.className="endstate";
this.panels.video.end.display.insert(a.video.end);this.trackEndFrame(a)},trackEndFrame:function(d){var c={};
var a=d.category;var e=a.split(/-/);if((e.length-1)>1){a=a.substring(a.indexOf("-")+2,a.length)
}var b="V@E: ";b+=AC.Tracking.pageName()+" - "+a+d.id;AC.Tracking.trackClick({prop13:b},this,"o",b)
},showText:function(a){this.panels.wrapper.className="tips";this.panels.text.update(a.content);
if(a.gallery){new FOH.Gallery(this.panels.text)}},showCurrent:function(){this.show(this.currentSection,true)
},showById:function(b,a){var c=this.sections[b];if(c){if(a&&c.gallery){this.show(this.sections[b],"Gallery")
}else{this.show(this.sections[b],false)}}else{this.showFirst()}},showLast:function(){if(this.lastSection){this.show(this.lastSection,true)
}else{this.showCurrent()}},showFirst:function(){this.showVideoGalleryLink(this.firstSection);
this.showiTunesLink(this.firstSection);if(this.tabs&&this.firstSection.tab){this.tabs.showContent(this.firstSection.tab)
}var a=new AC.QuicktimeController();a.render(this.panels.video.controller);a=null;
this.panels.video.controller.down(".control").observe("click",this.show.bind(this,this.firstSection,false))
},show:function(b,a){if(!this.initialized||a||this.currentSection!=b){if((!this.initialized||!a)&&this.currentSection){this.hide(this.currentSection)
}b.activate(a);this.cookies.set(b.id);if(this.tabs&&b.tab){this.tabs.showContent(b.tab)
}this.showiTunesLink(b);if(a=="Gallery"){this.showVideoGalleryLink(b);this.showGallery(b)
}else{if(b.video.url!=null){if(!this.currentController){this.setUpMovieAndController(b)
}this.showVideo(b,b.video.url)}else{if(b.content!=null){this.showText(b)}}}if(!this.initialized){this.initialized=true
}}this.currentSection=b;if(b.video.url||b.gallery){this.lastSection=b}},replayCurrent:function(){this.show(this.currentSection,"V@R")
},hide:function(a){a.deactivate();this.hideVideo();this.hideGallery();this.hideText()
},hideVideo:function(a){if(this.onMovieFinished){this.onMovieFinished.clearTimeout
}if(this.onMovieShow){this.onMovieShow.clearTimeout}if(this.currentController){this.currentController.options.onMovieFinished=null;
this.currentController.Stop()}this.panels.video.end.display.update("")},hideGallery:function(){this.panels.video.gallery.display.update("");
this.panels.video.gallery.trigger.style.display=""},hideText:function(){this.panels.text.update("")
},setUpMovieAndController:function(b){var a=AC.Quicktime.packageMovie("frpm-object",b.video.url,{width:640,height:400,autoplay:true,controller:false,cache:true});
this.panels.video.display.appendChild(a);if(AC.Detector.isValidQTAvailable("7")){this.currentController=new AC.QuicktimeController();
this.panels.video.controller.update("");this.currentController.render(this.panels.video.controller);
this.currentController.attachToMovie(a,{onMoviePlayable:function(){this.monitorMovie()
}.bind(this.currentController)})}a=null}});
