if(!window.StyleSoft){window.StyleSoft={}}(function(){var a=Math;var c;var b;StyleSoft.carousel={debug:false,defaults:function(){return{radius:150,minRadius:100,duration:600,angleX:30*a.PI/180,steps:c.calcSteps(600),perspective:600,minOpacity:0.6,filteredOpacity:0.2,centerImage:null,offsetTop:0,modelsHeight:110,items:[]}},create:function(d,f){var g=c.defaults();var e=b.apply({},g);b.apply(e,f);b.toNumbers(e,g,["radius","minRadius","duration","angleX","steps","perspective","minOpacity","filteredOpacity","offsetTop"]);e.container=$(d);return new c.Simple(e)},Simple:function(e){var g=this;e=b.apply(c.defaults(),e);e.container=$(e.container);if(e.angleX>a.PI/2){e.angleX=e.angleX*a.PI/180}g.cfg=e;var d=$('
').appendTo(g.cfg.container);var f=$('
').appendTo(g.cfg.container);g.space=$('
').appendTo(g.cfg.container);if(c.debug){g.logPanel=$('
');g.logPanel.appendTo(g.cfg.container)}g.containerHalfWidth=a.round(g.cfg.container.width()/2);g.containerHalfHeight=a.round(g.cfg.container.height()/2);if(e.designMode){d.css("borderRight","1px solid #cccccc");f.css("borderBottom","1px solid #cccccc")}g.space.css({perspective:g.cfg.perspective+"px"});g.nodes=[];g.setItems=function(s){if(!s||s.length<2){throw"Insufficient number of items"}if(g.fx&&g.fx.timer){g.stopFx()}g.cfg.items=s;var j,m;var l=2*a.PI/g.cfg.items.length;g.angle={base:0,scroll:0,step:l,fixedStep:l};g.fx={timer:null,step:0,direction:0,interval:a.round(g.cfg.duration/g.cfg.steps),easing:b.easing};var q,o,t,r;g.space.find(".ssc-category").remove();g.nodes=[];for(var n=0;n',j.id);if(j.models){for(var h=0;h{4}',r.name,r.id,j.id,encodeURI(t),r.shortName||r.name)}}var k=encodeURI(j.pathLarge||"/img/no-image-47x26.png");o+="";q=b.format('
{1}
{2}
',k,j.html,o,j.id);m=$(q).appendTo(g.space);g.addReflection(m,m.children()[0],k,"#feed01");m.css(g.calcNodeStyles(m,n));m.data("index",n);m.data("category",j.id);m.data("id",j.id);g.setCategorySwipe(m);g.nodes.push(m)}g.space.find(".ssc-category").on("click",g.onClickCategory);g.space.find(".ssc-model").on("click",g.onClickModel);g.selectItem()};g.setCategorySwipe=function(h){h.mousecapture({down:function(j,i){if(j.which==1){b.pauseEvent(j);i.tracking=false;i.x=j.pageX;i.dx=0;var k=/matrix\(/.test(h.css("transform"))?0:Number(/matrix3d\((?:-?\d+,\s){14}(-?\d+)/.exec(h.css("transform"))[1]);i.inverse=k<-g.cfg.radius*a.cos(g.cfg.angleX)?-1:1}},move:function(m,l){if(m.which==1){b.pauseEvent(m);l.dx=m.pageX-l.x;l.lastDx=l.dx;if(l.tracking){var j=g.angle.base-l.inverse*l.dx/g.cfg.radius;var k=g.getNearestIndex(j);g.rotate(j)}else{if(a.abs(l.dx)>5){l.tracking=true;arguments.callee(m,l)}}}},up:function(k,j){if(j.tracking){b.pauseEvent(k);j.tracking=false;j.dx=k.pageX-j.x;g.angle.base-=j.inverse*j.dx/g.cfg.radius;var i=g.getNearestIndex(g.angle.base,j.inverse*(j.lastDx-j.dx));g.scrollTo(i);h.data("clickDisabled",true);setTimeout(function(){h.removeData("clickDisabled")},10)}}})};g.setCenterControls=function(i){if(!g.centerControls){var h=['
','','
"].join("");g.centerControls={};g.centerControls.html=$(h);g.centerControls.logo=g.centerControls.html.find("img.ssc-logo");g.centerControls.reflection=g.centerControls.html.find("canvas.ssc-logo");g.centerControls.msgContainer=g.centerControls.html.find(".ssc-center-controls");g.centerControls.filter=g.centerControls.msgContainer.find(".ssc-center-filter");g.centerControls.filterText=g.centerControls.filter.find("span");g.centerControls.confirm=g.centerControls.msgContainer.find(".ssc-center-confirm");g.centerControls.confirmText=g.centerControls.confirm.find("span");g.centerControls.html.prependTo(g.cfg.container);g.centerControls.msgContainer.hide();g.centerControls.filter.find("input[name=close]").click(function(){g.centerControls.filter.hide();g.centerControls.msgContainer.hide();g.filter(null)})}g.centerControls.html.css({transform:"translateY("+(-g.cfg.offsetTop||0)+"px) "+g.space.css("transform")});if(i.logo){g.centerControls.logo.attr({src:encodeURI(i.logo)});g.addReflection($(g.centerControls.logo[0]),g.centerControls.reflection[0],i.logo)}};g.filterConfirm=function(h){if(h!=null&&g.isFiltered()){return}g.centerControls.msgContainer.toggle(h!=null);g.centerControls.filter.hide();g.filter(null);g.centerControls.confirm.toggle(h!=null);if(!h){return}g.centerControls.html.find('.ssc-center-confirm [name="yes"]').click(function(){g.centerControls.confirm.hide();g.filter(h)});g.centerControls.html.find('.ssc-center-confirm [name="no"]').click(function(){g.centerControls.confirm.hide();g.centerControls.msgContainer.hide()});g.centerControls.confirmText.html(h.message);g.centerControls.confirm.show()};g.filter=function(j){g.stopFx();var i=j?j.modelIds:null;var h={};g.centerControls.filterText.html(j?j.modelName:"");g.centerControls.filter.toggle(j!=null);if(!j){g.space.find(".ssc-category-models").each(function(k,l){$(l).removeClass("filter-show")});g.space.find(".ssc-model").each(function(l,k){$(k).removeClass("filter-hide")})}else{g.space.find(".ssc-model").each(function(l,k){k=$(k);var m=i.indexOf(k.data("id"))==-1;k.toggleClass("filter-hide",m);if(!m){h[k.data("category")]=1}});g.space.find(".ssc-category-models").each(function(k,l){l=$(l);l.toggleClass("filter-show",l.data("id") in h)})}$.each(g.nodes,function(k,l){l.data("opacity",!j||(l.data("category") in h)?1:g.cfg.filteredOpacity)});g.rotate(g.angle.base)};g.isFiltered=function(){return $.css(g.centerControls.filter[0],"display")!=="none"&&$.css(g.centerControls.msgContainer[0],"display")!=="none"};g.addReflection=function(i,k,h,j){$(b.format('',encodeURI(h))).load(function(){var n=this;var o=k.getContext("2d");var p=i.width(),m=i.height(),l=m/2;if(j){$(k).css({top:m+"px"})}else{}try{$(k).attr({width:p,height:l});o.save();o.translate(0,m-1);o.scale(1,-1);o.drawImage(n,0,0,p,m);o.restore();o.globalCompositeOperation="destination-out";var r=o.createLinearGradient(0,0,0,l);r.addColorStop(0,"rgba(255, 255, 255, 0.5)");r.addColorStop(1,"rgba(255, 255, 255, 1)");o.fillStyle=r;o.rect(0,0,p,l);o.fill()}catch(q){}})};g.gotoCategory=function(j,h){var i=g.space.find(".ssc-category[data-catid="+j+"]").data("index");g.scrollTo(i,h)};g.onClickCategory=function(){if(!$(this).data("clickDisabled")){g.gotoCategory($(this).data("catid"),false)}};g.gotoModel=function(i){var h=g.space.find(".ssc-model[data-id="+i+"]").first();g.gotoCategory(h.closest(".ssc-category").data("catid"),true);g.selectModel(h)};g.onClickModel=function(h){g.gotoCategory($(this).closest(".ssc-category").data("catid"),false);g.selectModel($(this))};g.selectModel=function(h){if(!h){h=$(this)}if(!h.closest(".ssc-category").first().data("clickDisabled")){g.deselectAnyModel();h.addClass("ssc-model-selected")}};g.deselectAnyModel=function(){g.space.find(".ssc-category .ssc-model-selected").removeClass("ssc-model-selected")};g.scrollTo=function(k,j){g.stopFx();var i=g.angle.base-k*g.angle.fixedStep;var h=a.abs(i)%(2*a.PI);var l=a.min(h,2*a.PI-h);if(l<0.001){return}g.angle.step=l;g.scroll((i>0)==(h0){g.angle.step=g.angle.fixedStep-a.abs(g.angle.base)%g.angle.fixedStep}else{g.angle.step=a.abs(g.angle.base)%g.angle.fixedStep}}}g.scroll(i)};g.scroll=function(i,h){g.space.children(".ssc-category-selected").removeClass("ssc-category-selected").each(function(){var j=$(this);j.attr("title",j.data("title"));j.find(".ssc-model").each(function(){var k=$(this);k.data("title",k.attr("title"));k.removeAttr("title")})});if(h){g.fx.direction=i;g.angle.base+=g.fx.direction*g.angle.step;g.stopFx();g.rotate(g.angle.base);g.selectItem()}else{g.fx.step=1;g.fx.direction=i;g.fx.timer=setInterval(function(){g.angle.scroll=g.fx.easing(g.fx.step/g.cfg.steps)*g.angle.step;g.rotate(g.angle.base+g.fx.direction*g.angle.scroll);if(g.fx.step>=g.cfg.steps){g.stopFx();g.angle.step=2*a.PI/g.cfg.items.length;g.angle.scroll=0;g.angle.base%=2*a.PI;if(a.abs(g.angle.base)0){return a.ceil(i/g.angle.fixedStep)%g.cfg.items.length}else{return a.floor(i/g.angle.fixedStep)%g.cfg.items.length}}};g.selectItem=function(){var h=g.getNearestIndex(g.angle.base);var i=g.nodes[h];i.addClass("ssc-category-selected").each(function(){var j=$(this);j.data("title",j.attr("title"));j.removeAttr("title");j.find(".ssc-model").each(function(){var k=$(this);k.attr("title",k.data("title"));k.removeData("title")})});if(!g.isFiltered()){}};g.setConfig=function(h){g.stopFx();b.apply(g.cfg,h);if(h.minRadius&&g.cfg.radius0?g.nodes[0].width():200;var k=g.nodes.length>0?g.nodes[0].height():150;var v=g.cfg.minRadius;var j=a.round(g.cfg.perspective/a.cos(g.cfg.angleX));var t=(s-w)/2;var h=c.carouselRadius(t,j,w/2);if(hr = "+h);g.cfg.radius=h;var l=c.carouselWidth(h,j,w/2);var n=sscale = "+n.toFixed(3));var q=c.carouselHeight(h,g.cfg.perspective,k/2,g.cfg.angleX);var y=q+m;var o=c.carouselTopToCenter(h,g.cfg.perspective,k/2,g.cfg.angleX);g.containerHalfWidth=a.round(s/2);g.containerHalfHeight=a.round(y/2);g.cfg.offsetTop=a.round(o*n);g.addLog("
containerHalfHeight = "+g.containerHalfHeight);g.addLog("
offsetTop = "+g.cfg.offsetTop);var u=b.format;g.space.css({transform:u("translate3d({0}px, {1}px, 0) scale3d({2}, {2}, 1)",g.containerHalfWidth,g.cfg.offsetTop,n)});g.cfg.container.height(a.round(n*y));var i=a.round(n*o);g.centerControls.html.css({transformOrigin:""+a.round(g.centerControls.html.width()/2)+"px 0 0",transform:"translateY("+i+"px) "+b.format("scale3d({0}, {0}, 1)",n)});if(g.cfg.items&&g.cfg.items.length>0){g.rotate(g.angle.base+g.fx.direction*g.angle.scroll)}};g.calcNodeStyles=function(i,o,t){var p=g.cfg.radius;var n=g.angle.fixedStep;var v=g.cfg.angleX;t=t||0;var j=typeof i.width=="function"?i.width():i.width;var w=typeof i.height=="function"?i.height():i.height;var l=Math;var h=l.PI/2-o*n+t;var k=p*l.sin(h);var s=l.round(p*l.cos(h)-j/2);var r=l.round(k*l.sin(v)-w/2);var q=l.round((k-p)*l.cos(v));var u=i.data("opacity")||1;return{transform:["translate3d(",s,"px, ",r,"px, ",q,"px)"].join(""),opacity:(((l.sin(h)+1)/2)*(1-g.cfg.minOpacity)+g.cfg.minOpacity)*u}};g.clearLog=function(){if(c.debug){g.logPanel.html("")}};g.addLog=function(h){if(c.debug){g.logPanel.html(g.logPanel.html()+h)}};if(g.cfg.centerImage){g.setCenterControls({logo:g.cfg.centerImage})}if(g.cfg.items&&g.cfg.items.length>0){g.setItems(g.cfg.items)}},calcSteps:function(e,d){return Math.max(Math.round((d||30)*e/1000),1)},carouselRadius:function(d,g,e){var f=a.atan((e+d)/g);return a.round(d*a.tan(a.PI/4+f/2))},carouselWidth:function(e,i,d){var g=a.atan(d/(e+i));var f=a.asin(e/(a.sqrt(d*d+a.pow(e+i,2))));return a.round(i*a.tan(g+f)*2)},carouselHeight:function(f,i,e,g){var d=f*a.sin(g)+e;return a.round(i*d/(i+2*f*a.cos(g))+d)},carouselTopToCenter:function(f,i,e,g){var d=f*a.sin(g)+e;return a.round(i*d/(i+2*f*a.cos(g)))}};c=StyleSoft.carousel;b=StyleSoft.util})();