function Film(a){this.viewport=$(a);this.navItems=this.viewport.find(".navigation li");this.reel=this.viewport.find(".reel");this.frames=this.reel.find(".frame");this.tween=null;this.selectedIndex=0;this.previous=this.viewport.find(".previous");this.previousCaption=this.previous.find(".caption span");this.next=this.viewport.find(".next");this.nextCaption=this.next.find(".caption span");this.logo=$("p#logo img");this.normalLogoSrc=this.logo.attr("src");this.funkyFrameIndex=9;this.funkyFrameLogo=new Image();this.funkyFrameLogo.src="/f/1/global/i/euroset-hr-logo-funky.gif";this.prepare()}Film.prototype={prepare:function(){var c=this;this.navItems.each(function(b){$(this).click(function(){this.blur();return c.activate(b)});$(this).keydown(function(a){this.blur();return a.keyCode!=13||c.activate(b)})});this.frames.each(function(a){$(this).find("p.further span").click(function(){this.blur();return c.activate(a+1)})});this.previous.click(function(){this.blur();return c.activate(c.selectedIndex-1)});this.previous.keydown(function(a){this.blur();return a.keyCode!=13||c.activate(c.selectedIndex-1)});this.next.click(function(){this.blur();return c.activate(c.selectedIndex+1)});this.next.keydown(function(a){this.blur();return a.keyCode!=13||c.activate(c.selectedIndex+1)});this.previous.css("display","none");this.nextCaption.text(this.navItems.eq(this.selectedIndex+1).find("span").text());return this},num:function(a,b){return parseInt($.css(a.jquery?a[0]:a,b),10)||0},activate:function(a){if(a>=0&&a<this.frames.length&&a!=this.selectedIndex){var b=this;this.navItems.eq(this.selectedIndex).removeClass("selected");this.navItems.eq(a).addClass("selected");this.previous.fadeOut("fast");this.next.fadeOut("fast");if(this.selectedIndex==this.funkyFrameIndex){this.deactivateFunkyFrame()}this.moveTo(a,function(){if(a>0){b.previousCaption.text(b.navItems.eq(a-1).find("span").text());b.previous.fadeIn("fast")}if(a<b.frames.length-1){b.nextCaption.text(b.navItems.eq(a+1).find("span").text());b.next.fadeIn("fast")}if(a==b.funkyFrameIndex){b.activateFunkyFrame()}});this.selectedIndex=a}return this},moveTo:function(a,b){if(this.tween){this.tween.stop()}var c=-100*a;this.tween=new Tween(this.reel,"left",EEQ.Quartic.easeInOut,this.num(this.reel,"left"),c,50,"%");this.tween.onMotionFinished=function(){b()};return this},activateFunkyFrame:function(){$(document.body).addClass("funky");this.logo.attr("src",this.funkyFrameLogo.src);return this},deactivateFunkyFrame:function(){$(document.body).removeClass("funky");this.logo.attr("src",this.normalLogoSrc);return this}};$(function(){$(".film").each(function(){new Film(this)})});