Carousel=Class.create(Abstract,{initialize:function(scroller,slides,controls,options){this.scrolling=false;this.scroller=$(scroller);this.slides=slides;this.controls=controls;this.options=Object.extend({duration:1,auto:false,frequency:3,visibleSlides:1,controlClassName:'carousel-control',jumperClassName:'carousel-jumper',disabledClassName:'carousel-disabled',selectedClassName:'carousel-selected',circular:false,wheel:true,effect:'scroll',transition:'sinoidal'},options||{});if(this.options.effect=='fade'){this.options.circular=true;}
this.slides.each(function(slide,index){slide._index=index;});if(this.controls){this.controls.invoke('observe','click',this.click.bind(this));}
if(this.options.wheel){this.scroller.observe('mousewheel',this.wheel.bindAsEventListener(this)).observe('DOMMouseScroll',this.wheel.bindAsEventListener(this));;}
if(this.options.auto){this.start();}
if(this.options.initial){var initialIndex=this.slides.indexOf($(this.options.initial));if(initialIndex>(this.options.visibleSlides-1)&&this.options.visibleSlides>1){if(initialIndex>this.slides.length-(this.options.visibleSlides+1)){initialIndex=this.slides.length-this.options.visibleSlides;}}
this.moveTo(this.slides[initialIndex]);}},click:function(event){this.stop();var element=event.findElement('a');if(!element.hasClassName(this.options.disabledClassName)){if(element.hasClassName(this.options.controlClassName)){eval("this."+element.rel+"()");}else if(element.hasClassName(this.options.jumperClassName)){this.moveTo(element.rel);if(this.options.selectedClassName){this.controls.invoke('removeClassName',this.options.selectedClassName);element.addClassName(this.options.selectedClassName);}}}
this.deactivateControls();event.stop();},moveTo:function(element){if(this.options.beforeMove&&(typeof this.options.beforeMove=='function')){this.options.beforeMove();}
this.previous=this.current?this.current:this.slides[0];this.current=$(element);var scrollerOffset=this.scroller.cumulativeOffset();var elementOffset=this.current.cumulativeOffset();if(this.scrolling){this.scrolling.cancel();}
switch(this.options.effect){case'fade':this.scrolling=new Effect.Opacity(this.scroller,{from:1.0,to:0,duration:this.options.duration,afterFinish:(function(){this.scroller.scrollLeft=elementOffset[0]-scrollerOffset[0];this.scroller.scrollTop=elementOffset[1]-scrollerOffset[1];new Effect.Opacity(this.scroller,{from:0,to:1.0,duration:this.options.duration,afterFinish:(function(){if(this.controls){this.activateControls();}
if(this.options.afterMove&&(typeof this.options.afterMove=='function')){this.options.afterMove();}}).bind(this)});}).bind(this)});break;case'scroll':default:var transition;switch(this.options.transition){case'spring':transition=Effect.Transitions.spring;break;case'sinoidal':default:transition=Effect.Transitions.sinoidal;break;}
this.scrolling=new Effect.SmoothScroll(this.scroller,{duration:this.options.duration,x:(elementOffset[0]-scrollerOffset[0]),y:(elementOffset[1]-scrollerOffset[1]),transition:transition,afterFinish:(function(){if(this.controls){this.activateControls();}
if(this.options.afterMove&&(typeof this.options.afterMove=='function')){this.options.afterMove();}
this.scrolling=false;}).bind(this)});break;}
return false;},prev:function(){if(this.current){var currentIndex=this.current._index;var prevIndex=(currentIndex==0)?(this.options.circular?this.slides.length-1:0):currentIndex-1;}else{var prevIndex=(this.options.circular?this.slides.length-1:0);}
if(prevIndex==(this.slides.length-1)&&this.options.circular&&this.options.effect!='fade'){this.scroller.scrollLeft=(this.slides.length-1)*this.slides.first().getWidth();this.scroller.scrollTop=(this.slides.length-1)*this.slides.first().getHeight();prevIndex=this.slides.length-2;}
this.moveTo(this.slides[prevIndex]);},next:function(){if(this.current){var currentIndex=this.current._index;var nextIndex=(this.slides.length-1==currentIndex)?(this.options.circular?0:currentIndex):currentIndex+1;}else{var nextIndex=1;}
if(nextIndex==0&&this.options.circular&&this.options.effect!='fade'){this.scroller.scrollLeft=0;this.scroller.scrollTop=0;nextIndex=1;}
if(nextIndex>this.slides.length-(this.options.visibleSlides+1)){nextIndex=this.slides.length-this.options.visibleSlides;}
this.moveTo(this.slides[nextIndex]);},first:function(){this.moveTo(this.slides[0]);},last:function(){this.moveTo(this.slides[this.slides.length-1]);},toggle:function(){if(this.previous){this.moveTo(this.slides[this.previous._index]);}else{return false;}},stop:function(){if(this.timer){clearTimeout(this.timer);}},start:function(){this.periodicallyUpdate();},pause:function(){this.stop();this.activateControls();},resume:function(event){if(event){var related=event.relatedTarget||event.toElement;if(!related||(!this.slides.include(related)&&!this.slides.any(function(slide){return related.descendantOf(slide);}))){this.start();}}else{this.start();}},periodicallyUpdate:function(){if(this.timer!=null){clearTimeout(this.timer);this.next();}
this.timer=setTimeout(this.periodicallyUpdate.bind(this),this.options.frequency*1000);},wheel:function(event){event.cancelBubble=true;event.stop();var delta=0;if(!event){event=window.event;}
if(event.wheelDelta){delta=event.wheelDelta/120;}else if(event.detail){delta=-event.detail/3;}
if(!this.scrolling){this.deactivateControls();if(delta>0){this.prev();}else{this.next();}}
return Math.round(delta);},deactivateControls:function(){this.controls.invoke('addClassName',this.options.disabledClassName);},activateControls:function(){this.controls.invoke('removeClassName',this.options.disabledClassName);}});Effect.SmoothScroll=Class.create();Object.extend(Object.extend(Effect.SmoothScroll.prototype,Effect.Base.prototype),{initialize:function(element){this.element=$(element);var options=Object.extend({x:0,y:0,mode:'absolute'},arguments[1]||{});this.start(options);},setup:function(){if(this.options.continuous&&!this.element._ext){this.element.cleanWhitespace();this.element._ext=true;this.element.appendChild(this.element.firstChild);}
this.originalLeft=this.element.scrollLeft;this.originalTop=this.element.scrollTop;if(this.options.mode=='absolute'){this.options.x-=this.originalLeft;this.options.y-=this.originalTop;}},update:function(position){this.element.scrollLeft=this.options.x*position+this.originalLeft;this.element.scrollTop=this.options.y*position+this.originalTop;}});;Event.observe(window,'load',function(){if($('color_box')&&$('product_name')){$$('select.product-custom-option').each(function(item){Event.observe(item,'change',changeColor);});$('color_box').observe('click',hideBox);}});function changeColor(event){var img_assets="http://72.47.202.40/store/modulr_assets/img/colors/";var productName=$('product_name').getValue();var colorPicBox=$('color_box');var colorPic=$('color_img');var colorGraphite="Case-Graphite.jpg";var colorBlack;var colorWhite;var colorSilver;var colorOrange;if(productName=="Slim Mount"){colorBlack="SlimMount-Black.jpg";colorWhite="SlimMount-White.jpg";colorSilver="SlimMount-Silver.jpg";colorOrange="SlimMount-Orange.jpg";}
if(productName=="Quick Stand"){colorBlack="QuickStand-Black.jpg";colorWhite="QuickStand-White.jpg";colorSilver="QuickStand-Silver.jpg";colorOrange="QuickStand-Orange.jpg";}
var mySelect=Event.element(event);var selectedColor=mySelect.options[mySelect.selectedIndex].text;switch(selectedColor){case"Graphite":colorPic.src=img_assets+colorGraphite;break;case"Classic Black":colorPic.src=img_assets+colorBlack;break;case"Mod Orange":colorPic.src=img_assets+colorOrange;break;case"Silver Pearl":colorPic.src=img_assets+colorSilver;break;case"Tech White":colorPic.src=img_assets+colorWhite;break;}
colorPicBox.appear({duration:0.3});}
function hideBox(){$('color_box').fade({duration:0.2});};;Event.observe(window,'load',function(){if($('btn_features')){$('btn_features').observe('click',togglePanel);}
if($('features_nav_1')){$('features_nav_1').observe('mouseover',showOne)};if($('features_nav_2')){$('features_nav_2').observe('mouseover',showTwo);}
if($('features_nav_3')){$('features_nav_3').observe('mouseover',showThree);}
if($('features_nav_4')){$('features_nav_4').observe('mouseover',showFour);}});var isVisible=false;function togglePanel(event){if(!isVisible){$('features_tab').hide();Effect.BlindDown('features_tab',{duration:0.4,afterFinish:function(){$('btn_features').setStyle({backgroundPosition:'0px -24px',})}});isVisible=true;}else{Effect.BlindUp('features_tab',{duration:0.4});$('btn_features').setStyle({backgroundPosition:'0px 0px',});isVisible=false;}}
function showOne(event){$$('.feat_slide_img').each(function(item){item.hide()});$('features_ss_1').show();}
function showTwo(event){$$('.feat_slide_img').each(function(item){item.hide()});$('features_ss_2').show();}
function showThree(event){$$('.feat_slide_img').each(function(item){item.hide()});$('features_ss_3').show();}
function showFour(event){$$('.feat_slide_img').each(function(item){item.hide()});$('features_ss_4').show();};var TINY={};function T$(i){return document.getElementById(i)}
TINY.box=function(){var p,m,b,fn,ic,iu,iw,ih,ia,f=0;return{show:function(c,u,w,h,a,t){if(!f){p=document.createElement('div');p.id='tinybox';m=document.createElement('div');m.id='tinymask';b=document.createElement('div');b.id='tinycontent';document.body.appendChild(m);document.body.appendChild(p);p.appendChild(b);m.onclick=TINY.box.hide;window.onresize=TINY.box.resize;f=1}
if(!a&&!u){p.style.width=w?w+'px':'auto';p.style.height=h?h+'px':'auto';p.style.backgroundImage='none';b.innerHTML=c}else{b.style.display='none';p.style.width=p.style.height='100px'}
this.mask();ic=c;iu=u;iw=w;ih=h;ia=a;this.alpha(m,1,80,3);if(t){setTimeout(function(){TINY.box.hide()},1000*t)}},fill:function(c,u,w,h,a){if(u){p.style.backgroundImage='';var x=window.XMLHttpRequest?new XMLHttpRequest():new ActiveXObject('Microsoft.XMLHTTP');x.onreadystatechange=function(){if(x.readyState==4&&x.status==200){TINY.box.psh(x.responseText,w,h,a)}};x.open('GET',c,1);x.send(null)}else{this.psh(c,w,h,a)}},psh:function(c,w,h,a){if(a){if(!w||!h){var x=p.style.width,y=p.style.height;b.innerHTML=c;p.style.width=w?w+'px':'';p.style.height=h?h+'px':'';b.style.display='';w=parseInt(b.offsetWidth);h=parseInt(b.offsetHeight);b.style.display='none';p.style.width=x;p.style.height=y;}else{b.innerHTML=c}
this.size(p,w,h)}else{p.style.backgroundImage='none'}},hide:function(){TINY.box.alpha(p,-1,0,3)},resize:function(){TINY.box.pos();TINY.box.mask()},mask:function(){m.style.height=TINY.page.total(1)+'px';m.style.width='';m.style.width=TINY.page.total(0)+'px'},pos:function(){var t=(TINY.page.height()/2)-(p.offsetHeight/2);t=t<10?10:t;p.style.top=(t+TINY.page.top())+'px';p.style.left=(TINY.page.width()/2)-(p.offsetWidth/2)+'px'},alpha:function(e,d,a){clearInterval(e.ai);if(d==1){e.style.opacity=0;e.style.filter='alpha(opacity=0)';e.style.display='block';this.pos()}
e.ai=setInterval(function(){TINY.box.ta(e,a,d)},20)},ta:function(e,a,d){var o=Math.round(e.style.opacity*100);if(o==a){clearInterval(e.ai);if(d==-1){e.style.display='none';e==p?TINY.box.alpha(m,-1,0,2):b.innerHTML=p.style.backgroundImage=''}else{e==m?this.alpha(p,1,100):TINY.box.fill(ic,iu,iw,ih,ia)}}else{var n=Math.ceil((o+((a-o)*.5)));n=n==1?0:n;e.style.opacity=n/100;e.style.filter='alpha(opacity='+n+')'}},size:function(e,w,h){e=typeof e=='object'?e:T$(e);clearInterval(e.si);var ow=e.offsetWidth,oh=e.offsetHeight,wo=ow-parseInt(e.style.width),ho=oh-parseInt(e.style.height);var wd=ow-wo>w?0:1,hd=(oh-ho>h)?0:1;e.si=setInterval(function(){TINY.box.ts(e,w,wo,wd,h,ho,hd)},20)},ts:function(e,w,wo,wd,h,ho,hd){var ow=e.offsetWidth-wo,oh=e.offsetHeight-ho;if(ow==w&&oh==h){clearInterval(e.si);p.style.backgroundImage='none';b.style.display='block'}else{if(ow!=w){var n=ow+((w-ow)*.5);e.style.width=wd?Math.ceil(n)+'px':Math.floor(n)+'px'}
if(oh!=h){var n=oh+((h-oh)*.5);e.style.height=hd?Math.ceil(n)+'px':Math.floor(n)+'px'}
this.pos()}}}}();TINY.page=function(){return{top:function(){return document.documentElement.scrollTop||document.body.scrollTop},width:function(){return self.innerWidth||document.documentElement.clientWidth||document.body.clientWidth},height:function(){return self.innerHeight||document.documentElement.clientHeight||document.body.clientHeight},total:function(d){var b=document.body,e=document.documentElement;return d?Math.max(Math.max(b.scrollHeight,e.scrollHeight),Math.max(b.clientHeight,e.clientHeight)):Math.max(Math.max(b.scrollWidth,e.scrollWidth),Math.max(b.clientWidth,e.clientWidth))}}}();
