function log(){debugMode}var currentReel,reelWrapperObj,debugMode=!0,totalNavBarlength=0,leftNavMargin,rightNavMargin;$.reel.def.frame=36;leftNavMargin=84;rightNavMargin=42;reelWrapperObj={load:function(){reelWrapperObj.initiateReel();reelWrapperObj.preloader.initiate();reelWrapperObj.currentReel.bind("preloadedChange",function(n,t,i){var r=i/reelWrapperObj.currentReel.reel("images").length;log("Progress:"+r);reelWrapperObj.preloader.instance.animate(r);$(".tfm-section").css("background-color","rgba(0, 26, 34, "+(1-r)+")");r==1&&(reelWrapperObj.preloader.preloaderFinished(),reelWrapperObj.currentReel.unbind("preloadedChange"))})},annotations:annotationsFromServer,currentReel:{},initiateReel:function(){reelWrapperObj.currentReel=$("#360image").reel({frames:initialSpinnerObject.numberOfFrames,images:initialSpinnerObject.imagesFolderFullPath,responsive:!0,indicator:1,timeout:240,brake:.02,clickfree:!1,steppable:!1,throwable:!0,annotations:reelWrapperObj.annotations})},control:{playTillFrame:function(n){reelWrapperObj.currentReel.reel(":reach",n)},stopReel:function(){reelWrapperObj.currentReel.reel(":stop")},playNextFrame:function(n){reelWrapperObj.currentReel.reel(":step"+n)},setReelSpeedAndPlay:function(n){reelWrapperObj.currentReel.reel(":play",n)}},preloader:{instance:{},initiate:function(){var n=new ProgressBar.Circle("#progress-circle",{color:"#fff",strokeWidth:.5,trailWidth:.5,easing:"easeInOut",text:{autoStyleContainer:!1},from:{color:"#00ddde",width:.5},to:{color:"#00ddde",width:.5},step:function(n,t){t.path.setAttribute("stroke",n.color);t.path.setAttribute("stroke-width",n.width);var i=Math.round(t.value()*100);i===0?t.setText("ForceField Telematics"):t.setText("ForceField Telematics<br/>"+i+"%")}});n.text.style.fontFamily='"Raleway", Helvetica, sans-serif';n.text.style.fontSize="1rem";n.animate(0);reelWrapperObj.preloader.instance=n},preloaderFinished:function(){$("#progress-circle").hide();$(".car-div").fadeIn();$(".spinner-title").fadeIn();setTimeout(function(){$("#car-dome").fadeIn(500,function(){reelWrapperObj.control.setReelSpeedAndPlay(.7);setTimeout(function(){reelWrapperObj.control.playTillFrame(3);setTimeout(function(){$("#car-dome").fadeOut(500)},500)},1e3)})},1e3);$("#reel-left-right-btns").fadeIn();$("#bottom-controls").fadeIn();reelWrapperObj.currentReel.bind("frameChange",function(n,t,i){reelWrapperObj.hotSpot.hideHotSpots();log(i);reelWrapperObj.currentReel.currentFrame=i});reelWrapperObj.navBar.generateNavBar();reelWrapperObj.hotSpot.handleHotSpotsClick();var t=function(n){var t=$(n).attr("data-direction");t.toUpperCase()==="left".toUpperCase()?reelWrapperObj.control.playNextFrame("Left"):t.toUpperCase()=="right".toUpperCase()&&reelWrapperObj.control.playNextFrame("Right")},n=!0;$(".frame-button").mousedown(function(i){n=!1;t(this,i);var r=this,u=setInterval(function(){n?clearInterval(u):t(r,i)},100)});$("body").mouseup(function(){n=!0});reelWrapperObj.navBar.handleNavBarButtons();$("#360image").addClass("img-responsive")}},navBar:{generateNavBar:function(){var u=$("#nav-bar-template").html(),i={buttons:[]},n,t,r;for(n in reelWrapperObj.annotations)reelWrapperObj.annotations.hasOwnProperty(n)&&(t=reelWrapperObj.annotations[n],i.buttons.push({btnid:"btn"+n,annotationid:n,btntext:t.image.datatitle,defaultframe:t.image.datadefaultframe}));r=Mustache.render(u,i);$("#navbar").html(r);totalNavBarlength=this.calculateNavBarLength()},handleNavBarButtons:function(){$("#navbar a").click(function(n){var t;n.preventDefault();reelWrapperObj.control.playTillFrame($(this).attr("data-def-frame"));t=$(this).attr("data-id");reelWrapperObj.hotSpot.showHotSpotData(t,!0);reelWrapperObj.navBar.setNavBarActiveButton($(this));var i=$("#"+t),r=$(i).position().top,u=$(i).position().left,f=$(i).find(".hotspot")});$(".navBarMove").click(function(n){n.preventDefault();var t=$(this).attr("data-direction");reelWrapperObj.navBar.moveNavBar(t)})},setNavBarActiveButton:function(n){var t=0,u=$("#navbar li.active"),i=$(n).parent(),f=$("#navbar li").index(u),e=$("#navbar li").index(i),r;t=-i.position().left+$(".navbar-btns").width()/2-i.width()/2;r=-(totalNavBarlength-$(".navbar-btns").width()+rightNavMargin);t>leftNavMargin&&(t=leftNavMargin);t<r&&(t=r);$("ul#navbar").css("transform","translateX("+t+"px)");u.removeClass("active");i.addClass("active");$("#navbar  li.highlighted").removeClass("highlighted");i.addClass("highlighted")},moveNavBar:function(n){var r=$("#navbar  li.highlighted").index(),i=r,e=$("#navbar  li").length,f;if(r==-1)if(n=="right")i=1;else return;else n=="right"&&r!=e-1?i++:n=="left"&&r!=0&&i--;var t=0,u=$($("#navbar li a")[i]).parent(),o=i;t=-u.position().left+$(".navbar-btns").width()/2-u.width()/2;f=-(totalNavBarlength-$(".navbar-btns").width()+rightNavMargin);t>leftNavMargin&&(t=leftNavMargin);t<f&&(t=f);$("ul#navbar").css("transform","translateX("+t+"px)");$("#navbar  li.highlighted").removeClass("highlighted");u.addClass("highlighted")},calculateNavBarLength:function(){var n=0;return $("#navbar li").each(function(){n+=$(this).width()}),n}},hotSpot:{handleHotSpotsClick:function(){$(".reel-annotation").click(function(n){n.stopPropagation();log("working");reelWrapperObj.hotSpot.showHotSpotData($(this).attr("id"));var t="btn"+$(this).attr("id"),i=$("#"+t);reelWrapperObj.navBar.setNavBarActiveButton(i)});$(".reel-annotation").mouseup(function(n){n.stopPropagation()});$(".reel-annotation").mousedown(function(n){n.stopPropagation()});$(".modalwindow .close-btn").click(function(n){n.preventDefault();reelWrapperObj.hotSpot.hideHotSpots()})},showHotSpotWindow:function(n,t,i,r){var u=$("#modal");u.css("left",i-$("#modal").width()+13);u.css("top",r+18);$(".modalwindow #hs-title").html(n);$(".modalwindow #hs-content").html(t);u.fadeIn(500)},hideHotSpots:function(){$(".modalwindow").fadeOut(200)},showHotSpotData:function(n,t){var r=reelWrapperObj.annotations[n].image.datacontent,u;$("#mobile-hotspot-content").html(r);var f=reelWrapperObj.annotations[n].image.datatitle,i=$("#"+n).position(),e=reelWrapperObj.annotations[n].image.datadefaultframe;t?(u=function(){if(reelWrapperObj.currentReel.currentFrame!=e){setTimeout(u,100);return}i=$("#"+n).position();reelWrapperObj.hotSpot.showHotSpotWindow(f,r,i.left,i.top)},u()):this.showHotSpotWindow(f,r,i.left,i.top,t)}}};$(document).ready(function(){$=myJquery;reelWrapperObj.load()})