if(typeof(AC)=="undefined"){AC={}}AC.ProductBrowser={productSlider:null,sliderVal:0,animationId:false,viewportWidth:946,contentWidth:946,categories:[{id:"pb-cat1",offset:0},{id:"pb-cat2",offset:0.32}],isIPhone:AC.Detector.isiPhone(),iPhoneCategories:[{id:"pb-cat1",offset:0},{id:"pb-cat2",offset:0.32}],arrowScrollAmount:0.24,iPhoneScrollAmount:0.22,iPhoneContainerWidth:834,isSliding:false,lastX:0.32,isMouseDown:false,dif:0,overlap:0,offsetImageWidth:127,sliderOffset:291,offsetContentWidth:-946,clicked:false,startIndex:0,isIpScroll:false,hasIpDragged:false,init:function(f){if(typeof(f.categories)!="undefined"){this.categories=f.categories
}if(typeof(f.imageOverlap)!="undefined"){this.overlap=f.imageOverlap}if(typeof(f.sliderCentering)!="undefined"){this.sliderOffset=f.sliderCentering
}if(typeof(f.initialCategory)!="undefined"){this.startIndex=f.initialCategory}if(typeof(f.arrowScrollAmount)!="undefined"){this.arrowScrollAmount=f.arrowScrollAmount
}if(typeof(f.iPhoneCategories)!="undefined"){this.iPhoneCategories=f.iPhoneCategories
}if(typeof(f.iPhoneScrollAmount)!="undefined"){this.iPhoneScrollAmount=f.iPhoneScrollAmount
}if(typeof(f.iPhoneContainerWidth)!="undefined"){this.iPhoneContainerWidth=f.iPhoneContainerWidth
}$("pb-productslidertrack").style.visibility="visible";$("pb-productbrowsercontainer").style.overflow="hidden";
this.viewportWidth=$("pb-productbrowsercontainer").getWidth();this.offsetImageWidth=$$("#pb-productslider .pb-productimage")[0].getWidth()-this.overlap;
this.contentWidth=this.offsetImageWidth*$$("#pb-productslider .pb-productimage").length;
this.offsetContentWidth=-1*(this.contentWidth-this.viewportWidth);this.productSlider=new Control.Slider("pb-productsliderhandle","pb-productslidertrack",{axis:"horizontal"});
if(AC.ProductBrowser.isIPhone){this.categories=this.iPhoneCategories;this.arrowScrollAmount=this.iPhoneScrollAmount;
$("pb-productslidertrack").style.visibility="none";$("pb-leftarrow").style.visibility="none";
$("pb-rightarrow").style.visibility="none";$("pb-productbrowsercontainer").style.width=this.iPhoneContainerWidth+"px";
var d=document.createElement("div");d.id="pb-iphone-leftarrow";var e=document.createElement("div");
e.id="pb-iphone-rightarrow";$("productbrowser").appendChild(d);$("productbrowser").appendChild(e);
Event.observe($(d),"click",function(){AC.ProductBrowser.left()});Event.observe($(e),"click",function(){AC.ProductBrowser.right()
})}AC.ProductBrowser.animateSlide(this.categories[this.startIndex].offset);this.productSlider.options.onChange=function(a){$("pb-productsliderhandleimage").style.left=$("pb-productsliderhandle").style.left;
if(AC.ProductBrowser.isThrow&&!AC.ProductBrowser.isSliding){AC.ProductBrowser.isSliding=true;
AC.ProductBrowser.isThrow=false;var b=a+AC.ProductBrowser.throwMod;if(b<0){b=0}if(b>1){b=1
}AC.ProductBrowser.animateSlide(b)}else{if(!AC.ProductBrowser.isSliding&&a){AC.ProductBrowser.isSliding=true;
AC.ProductBrowser.animateSlide(a)}}};this.productSlider.options.onSlide=function(a){$("pb-productsliderhandleimage").style.left=$("pb-productsliderhandle").style.left;
if(a&&!AC.ProductBrowser.isSliding){AC.ProductBrowser.isSliding=true;AC.ProductBrowser.isThrow=false;
if(AC.ProductBrowser.isMouseDown){AC.ProductBrowser.dif=a-AC.ProductBrowser.lastX;
AC.ProductBrowser.lastX=a;if(AC.ProductBrowser.dif>0.05){AC.ProductBrowser.isThrow=true;
AC.ProductBrowser.throwMod=0.2}else{if(AC.ProductBrowser.dif<-0.04){AC.ProductBrowser.isThrow=true;
AC.ProductBrowser.throwMod=-0.2}}}var b=AC.ProductBrowser.offsetContentWidth;$("pb-productslider").style.left=b*a+"px";
this.sliderVal=a;AC.ProductBrowser.lastX=a;AC.ProductBrowser.colorCats();AC.ProductBrowser.isSliding=false
}Element.setStyle($("pb-productbrowsercontainer"),{overflow:"hidden"})};Event.observe("pb-productslidertrack","mousedown",function(b){var a=b.offsetX||b.layerX;
if(Event.element(b).id=="pb-productslidertrack"&&a<100){AC.ProductBrowser.animateSlide(0)
}});Event.observe("pb-leftarrow","mousedown",function(){AC.ProductBrowser.left()
});Event.observe("pb-rightarrow","mousedown",function(){AC.ProductBrowser.right()
});Event.observe("pb-productsliderhandle","mousedown",function(){AC.ProductBrowser.isMouseDown=true;
$("pb-productsliderhandle").style.zIndex="5"});Event.observe("pb-productsliderhandle","mouseup",function(){AC.ProductBrowser.isMouseDown=false
});AC.ProductBrowser.categories.each(function(a){Event.observe($(a.id),"mouseup",function(b){AC.ProductBrowser.animateSlide(a.offset)
})})},animateSlide:function(g){if(g>1){g=1}if(g<0){g=0}AC.ProductBrowser.sliderVal=g;
window.clearInterval(AC.ProductBrowser.animationId);var f=AC.ProductBrowser.offsetContentWidth;
var h=f*g;var e=(Math.round(AC.ProductBrowser.viewportWidth-AC.ProductBrowser.sliderOffset)*g);
AC.ProductBrowser.isSliding=true;AC.ProductBrowser.animationId=window.setInterval(function(){var b=parseInt($("pb-productslider").getStyle("left"))||0;
var c=parseInt($("pb-productsliderhandle").getStyle("left"))||0;var d=AC.ProductBrowser.calculateDecel(b,h);
var a=AC.ProductBrowser.calculateDecel(c,e);$("pb-productslider").style.left=d+"px";
$("pb-productsliderhandle").style.left=a+"px";$("pb-productsliderhandleimage").style.left=a+"px";
AC.ProductBrowser.colorCats();if(d==h){window.clearInterval(AC.ProductBrowser.animationId);
AC.ProductBrowser.isSliding=false}},30)},colorCats:function(){var b=parseInt($("pb-productsliderhandle").getStyle("left"))+(($("pb-productsliderhandle").getWidth()-20)/2);
AC.ProductBrowser.categories.each(function(c){var f=parseInt($(c.id).getStyle("left"));
var a=Math.ceil((Math.min(b,f)/Math.max(b,f))*10);$(c.id).className="pb-catclass"+a
})},left:function(){AC.ProductBrowser.animateSlide(AC.ProductBrowser.sliderVal-AC.ProductBrowser.arrowScrollAmount)
},right:function(){AC.ProductBrowser.animateSlide(AC.ProductBrowser.sliderVal+AC.ProductBrowser.arrowScrollAmount)
},calculateDecel:function(f,d){var e=f-Math.floor((f-d)*0.4);if(Math.abs(f-d)<4){return d
}else{return e}}};
