if(typeof os==="undefined"){var os={}}if(os.Plug&&os.MediaControl){os.Carousel=function(selector,config){var defaults={name:"os.Carousel",slideWindowClass:os.$c.SLIDE_WINDOW,slideClass:os.$c.SLIDE,slidePanelClass:os.$c.SLIDE_PANEL,slideShowClass:os.$c.SLIDE_SHOW,controlsClass:os.$c.CONTROLS,controlItemClass:os.$c.CONTROL_TRIGGER,enableClass:os.$c.ENABLED,disabledClass:os.$c.DISABLED,isPaused:false,LAZY_LOAD_TIMEOUT:1500};os.Carousel._super.constructor.apply(this,arguments);this.applySettings(defaults,config)};os.Plug.extend(os.Carousel,os.Plug.Core,{initialize:function(){this._this.isCarousel=true;var _this=this;this.addClass(this.enableClass);this.slideWindow=jQuery("<div></div>").addClass(this.slideWindowClass);this.slides=this.element.find("."+this.slideClass);this.slidePanel=this.element.find("."+this.slidePanelClass)},getDataTarget:function(itemId){return null},checkIndex:function(index){index=parseInt(index)||0;return(index>this.slides.length-1)?0:index},setSlideDisplay:function(){this.slideWindow.insertBefore(this.slidePanel).append(this.slidePanel)},setControls:function(){var _this=this;this.bind("mediacontrolclick",function(e){_this.handleControlClick(e)})},handleControlClick:function(e){},changePanelByIndex:function(index){var _this=this,selectedIndex=this.checkIndex(index),currPos=this.getCurrentIndex();if(currPos===selectedIndex){return }this.loadImagesForSlide(this.slides[selectedIndex],function(){_this.showPanel(_this.slides[selectedIndex]);_this.hidePanel(_this.slides[currPos]);_this.setCurrentIndex(selectedIndex);_this.updateInterface(selectedIndex)})},showPanel:function(node){jQuery(node).fadeIn(this.slideEffectSpeed)},hidePanel:function(node,effectSpeed){jQuery(node).fadeOut(this.slideEffectSpeed)},doPlay:function(){if(this.AUTO_ID){return }this.startAutoRun(true)},doPause:function(){if(this.resumeId){clearTimeout(this.resumeId);this.resumeId=null}this.isPaused=true;this.doStop()},doResume:function(){var _this=this;this.resumeId=setTimeout(function(){_this.isPaused=false;_this.doPlay()},2000)},doStop:function(){if(this.AUTO_ID){clearInterval(this.AUTO_ID)}this.AUTO_ID=null},updateInterface:function(index){index=index||this.getCurrentIndex();this.controls.toggleSelect(index+1)},startAutoRun:function(bypassFirstInterval){var _this=this;if(bypassFirstInterval){_this.changePanelByIndex(_this.getCurrentIndex()+1)}this.AUTO_ID=setInterval(function(){_this.changePanelByIndex(_this.getCurrentIndex()+1)},this.slideInterval)},getCurrentIndex:function(){return this.currentIndex},setCurrentIndex:function(index){this.currentIndex=parseInt(index)},lazyLoadImages:function(node,callback,opt){callback=callback||function(){};opt=opt||{};var dataSrc=os.Plug.config.SlideShow.DATA_SRC,_this=this,slideTimeoutId=null,exitProcess=false;var imgs=jQuery(node).find("["+dataSrc+"]");if(imgs.size()>0){slideTimeoutId=setTimeout(function(){exitProcess=true;if(opt.after&&opt.after instanceof Function){opt.after()}callback()},this.LAZY_LOAD_TIMEOUT);if(opt.before&&opt.before instanceof Function){opt.before()}var loadCount=0;imgs.each(function(){var $this=jQuery(this);if($this.attr(dataSrc)){var $img=jQuery("<img></img>").css({opacity:0}).bind("load",function(e){jQuery(e.target).animate({opacity:100},800);loadCount++;if(loadCount===imgs.size()&&!exitProcess){if(slideTimeoutId){clearTimeout(slideTimeoutId)}if(opt.after&&opt.after instanceof Function){opt.after()}callback()}}).attr({src:$this.attr(dataSrc),alt:$this.text()});$this.empty().append($img).removeAttr(dataSrc)}})}else{callback()}}});os.SlideShow=function(selector,config){config=config||{};var type=config.type||null;return jQuery(selector).each(function(){if(this&&this.isCarousel){return }var o=null;switch(type){case"slider":o=new os.Slider(this,config);break;default:o=new os.Pager(this,config)}o.setContext(this)._create()})};os.Pager=function(selector,config){var defaults={name:"os.SlideShow",slideEffectSpeed:os.Plug.config.SlideShow.SLIDE_EFFECT_SPEED,slideInterval:os.Plug.config.SlideShow.SLIDE_INTERVAL,currentIndex:0,slideWindow:null,slidePanel:null,triggerNodes:{},triggers:null,controls:null,auto:true,toggleClass:os.$c.TOGGLE,itemClass:"item"};os.Pager._super.constructor.apply(this,arguments);this.applySettings(defaults,config)};os.Plug.extend(os.Pager,os.Carousel,{initialize:function(){os.Pager._super.initialize.apply(this);var _this=this,firstSlide=null;this.addClass(this.toggleClass);this.setSlideDisplay();this.setControls();firstSlide=this.slides[this.getCurrentIndex()];this.loadImagesForSlide(firstSlide,function(){_this.showPanel(firstSlide)});this.bind("slide-change",function(e){_this.handlePanelChange(e)});this.slideWindow.hover(function(){_this.doPause()},function(){_this.doResume()});if(this.auto){this.startAutoRun()}},setControls:function(){os.Pager._super.setControls.apply(this);var _this=this;this.controls=new os.MediaControl();var v=this.slides.length;this.slides.each(function(i){var content={};content.img=this.getAttribute("data-control-img")||null;content.lbl=this.getAttribute("data-label")||i+1;_this.controls.addControlItem(content.lbl,content,{"data-index":i});if(i+1===v){_this.controls.hide().appendTo(_this.slideWindow).fadeIn(_this.slideEffectSpeed);_this.updateInterface()}})},handlePanelChange:function(e){switch(e.type){case"slide-change":this.changePanelByIndex(e.indexId);break}},handleControlClick:function(e){var target=e.controlTarget,indexId=null;while(target.nodeName.toLowerCase()!=="a"&&target.parentNode){if(target===this._this){return }target=target.parentNode}indexId=target.getAttribute("data-index");if(indexId){e.preventDefault();this.doStop();this.trigger({trigger:target,type:"slide-change",indexId:indexId,request:{url:this.getDataTarget(indexId)}})}},loadImagesForSlide:function(slide,callback){this.lazyLoadImages(slide,callback)}});os.Slider=function(selector,config){defaults={currentIndex:0,maxIndex:null,itemsRemainder:null,minColumnWidth:null};os.Slider._super.constructor.apply(this,arguments);this.applySettings(defaults,config)};os.Plug.extend(os.Slider,os.Carousel,{initialize:function(){os.Slider._super.initialize.apply(this);var _this=this;this.setSlideDisplay();this.setControls();this.adaptProductLayout();jQuery(window).resize(function(){_this.adaptProductLayout()});this.bind("slide-change",function(e){_this.handleSlideChange(e)});jQuery(document).bind("update-tab-interface",function(){_this.adaptProductLayout()})},setControls:function(){os.Slider._super.setControls.apply(this);this.controls=new os.MediaControl();this.controls.addControlItem("previous",'<i class="icon"></i>Previous',{className:"left"});this.controls.addControlItem("next",'<i class="icon"></i>Next',{className:"right"});this.controls.hide().insertBefore(this.slideWindow).fadeIn(this.slideEffectSpeed);this.updateInterface()},setSlideDisplay:function(){os.Slider._super.setSlideDisplay.apply(this)},setPanelWidth:function(v){var l=this.slides.length;var vi=(l/v);var pw=100*vi;var sw=((pw/vi)/l);this.itemsRemainder=(l%v);this.numItemsInView=Math.round(l/vi);this.slides.css({width:sw+"%"});this.slidePanel.css({width:pw+"%"});this.setMaxIndex(vi);if(this.currentIndex>this.maxIndex){var index=this.maxIndex;this.setCurrentIndex(index);this.changeSlide(index)}this.updateInterface()},handleControlClick:function(e){var target=e.controlTarget,indexId=null;while(target.nodeName.toLowerCase()!=="a"&&target.parentNode){if(target===this._this){return }target=target.parentNode}if(jQuery(target).hasClass("disabled")){return }action=target.getAttribute("data-action");if(action){e.preventDefault();this.trigger({trigger:target,type:"slide-change",action:action})}},handleSlideChange:function(e){switch(e.action){case"next":this.nextSlide();break;case"previous":this.previousSlide();break}},changeSlide:function(index){var _this=this;if(index>this.maxIndex||index<0){return }if(!this.itemsRemainder&&index>this.maxIndex){return }this.slidePanel.animate({marginLeft:-(index*100)+"%"},"swing",function(){_this.updateInterface()})},nextSlide:function(){var _this=this;var index=this.currentIndex+1;this.setCurrentIndex(index);this.loadImagesForSlide(index,{onComplete:function(){_this.changeSlide(index)}})},previousSlide:function(){var _this=this;var index=this.currentIndex-1;this.setCurrentIndex(index);this.loadImagesForSlide(index,{onComplete:function(){_this.changeSlide(index)}})},loadImagesForSlide:function(){var arg=arguments,_this=this,toIndex=null,opt=null,items=[],callback=null,options={};if(this.getObjectClass(arg[0])==="Number"){toIndex=arg[0];opt=arg[1]}else{if(this.getObjectClass(arg[0])==="Object"){toIndex=this.currentIndex;opt=arg[0]}else{toIndex=this.currentIndex;opt={}}}opt.interfaceEnabled=opt.interfaceEnabled||false;callback=opt.onComplete;if(!opt.interfaceEnabled){options={before:function(){_this.toggleInterface(false)},after:function(){_this.toggleInterface(true)}}}for(var i=0,len=this.numItemsInView;i<len;i++){var index=parseInt(this.returnWithinRange((this.currentIndex*len)+((toIndex>=this.currentIndex)?+i:-i),0,_this.slides.length));if(!(this.slides[index]===items[items.length])){items.push(this.slides[index])}}this.lazyLoadImages(items,callback,options)},toggleInterface:function(enable){var action=(enable)?"enable":"disable",showLoading=true,control=this.controls.controlItems;if(enable){this.slidePanel.fadeTo(200,1);if(showLoading){this.slideWindow.removeClass("loading").find(".loading-overlay").remove()}}else{this.slidePanel.fadeTo(0,0.5);if(showLoading){this.slideWindow.addClass("loading").append('<div class="loading-overlay"></div>')}}control.next[action]();control.previous[action]()},setCurrentIndex:function(index){if(index<0){index=0}if(index>=this.maxIndex){index=this.maxIndex}if(!this.itemsRemainder&&index>=this.maxIndex){index=this.maxIndex}this.currentIndex=index},setMaxIndex:function(index){index=(this.itemsRemainder)?index:index-1;this.maxIndex=Math.floor(index)},updateInterface:function(){var control=this.controls.controlItems;(this.currentIndex===0)?control.previous.disable():control.previous.enable();(this.currentIndex>=this.maxIndex||(!this.itemsRemainder&&this.currentIndex>=this.maxIndex))?control.next.disable():control.next.enable()},adaptProductLayout:function(){var sw=this.slideWindow.width();var b=this.columnBase||300;var t=this.minColumnWidth||150;var c=0;while(b<3600){c++;if(sw<b+t&&sw>b){this.setPanelWidth(c);break}b+=t}this.loadImagesForSlide({interfaceEnabled:true})}})}else{os.Carousel=function(){};os.SlideShow=function(){}};
