var __bt_Flag=false;var __bt_Busy=false;__bt_showhidePriceTD=function(){var __TD=$_('#__bt_totalPriceTD');if($_.ie){__TD.style.backgroundColor=$('__bt_Content').currentStyle.backgroundColor;if(__TD.style.backgroundColor=='transparent')__TD.style.backgroundColor='#FFFFFF';}
if(__boughtTogetherAnimation){__TD.mutate({opacity:1*(__bt_Flag?0:1)},{opacity:0},__bt_AnimSpeed,function(){__bt_calculatePrice();if(!__bt_Flag){__TD.style.display='';__TD.mutate({opacity:0},{opacity:1},__bt_AnimSpeed,function(){__bt_Busy=false;});}
else{__TD.style.display='none';__bt_Busy=false;}});}
else{__TD.style.display='none';__bt_calculatePrice();if(!__bt_Flag)__TD.style.display='';__bt_Busy=false;}};__bt_showhideTDs=function(TDObjs,show){for(var i=0;i<TDObjs.length;i++){var __TD=$_(TDObjs[i]);if(__TD){if(__boughtTogetherAnimation){if(show){__TD.mutate({opacity:0},{opacity:0},__bt_AnimSpeed,function(TD){return function(){TD.style.display='';TD.mutate({opacity:0},{opacity:1},__bt_AnimSpeed);}}
(__TD));}
else{__TD.mutate({opacity:1},{opacity:0},__bt_AnimSpeed,function(TD){return function(){TD.style.display='none';}}
(__TD));}}
else __TD.style.display=show?'':'none';}}};__bt_nearestTD=function(TDObj,show){var __nearestTD=TDObj;do __nearestTD=__nearestTD.nextSibling;while((__nearestTD)&&((__nearestTD.tagName!='TD')||((__nearestTD.style.display=='none')!=show)));if(__nearestTD){var __nearestTDnext=__nearestTD;do __nearestTDnext=__nearestTDnext.nextSibling;while((__nearestTDnext)&&((__nearestTDnext.tagName!='TD')||(__nearestTDnext.style.display=='none')));if(!__nearestTDnext)__nearestTD=null;}
if(!__nearestTD){__nearestTD=TDObj;do __nearestTD=__nearestTD.previousSibling;while((__nearestTD)&&((__nearestTD.tagName!='TD')||((__nearestTD.style.display=='none')!=show)));if(__nearestTD){__nearestTDnext=__nearestTD;do __nearestTDnext=__nearestTDnext.previousSibling;while((__nearestTDnext)&&((__nearestTDnext.tagName!='TD')||(__nearestTDnext.style.display=='none')));if(!__nearestTDnext)__nearestTD=null;}}
return __nearestTD;};__bt_calculatePrice=function(){var __price=0;var __showed=0;for(var i=0;i<bt_IDs.length;i++){var __cB=$('related-checkbox'+bt_IDs[i]);if((__cB)&&(__cB.checked)){__price+=bt_Prices[i];__showed++;}}
__bt_Flag=(__showed==0)?true:false;$('__bt_totalPrice').innerHTML=$('__bt_totalPrice').innerHTML.replace(/\d+([\s\.,]\d+)*/,__price.toFixed(2).toString());return __price;};bt_itemClick=function(productID){if(__bt_Busy)return false;__bt_Busy=true;var __show=$('related-checkbox'+productID).checked;var __TD=$('__bt_product_'+productID+'_TD');var __A=$('__bt_product_'+productID+'_Name');__bt_showhidePriceTD();__bt_showhideTDs([__TD,__bt_nearestTD(__TD,__show)],__show);if(__show)__A.style.color='';else __A.style.color='#BBBBBB';};bt_addToCart=function(){var checkboxes=$$('.related-checkbox');var values=[];for(var i=0;i<checkboxes.length;i++)if(checkboxes[i].checked)values.push(checkboxes[i].value);var primaryProductID=values.shift();var s=productAddToCartForm.form.action;s=s.substr(0,s.lastIndexOf('/')-1);productAddToCartForm.form.action=s.substr(0,s.lastIndexOf('/'))+'/'+primaryProductID+'/';productAddToCartForm.form.product.value=primaryProductID;if($('related-products-field'))$('related-products-field').value=values.join(',');productAddToCartForm.submit();};Product.OptionsPrice.prototype.formatPrice=function(price){bt_Prices[0]=price;__bt_calculatePrice();return formatCurrency(price,this.priceFormat);};var Lightbox=Class.create();Lightbox.prototype={imageArray:[],activeImage:undefined,options:{overlayOpacity:0.8,animate:true,resizeSpeed:7,borderSize:10,labelImage:"Image",labelOf:"of"},initialize:function(params){Object.extend(this.options,params||{});this.animating=false;this.keyboardAction=this.keyboardAction.bindAsEventListener(this);if(this.options.resizeSpeed>10)this.options.resizeSpeed=10;if(this.options.resizeSpeed<1)this.options.resizeSpeed=1;this.resizeDuration=this.options.animate?((11-this.options.resizeSpeed)*0.15):0;this.overlayDuration=this.options.animate?0.2:0;var size=(this.options.animate?250:1)+'px';this.pageScroll=document.viewport.getScrollOffsets();this.pageHeight=document.viewport.getHeight();var objBody=$$('body')[0];objBody.appendChild(Builder.node('div',{id:'overlay'}));objBody.appendChild(Builder.node('div',{id:'lightbox'},[Builder.node('div',{id:'outerImageContainer'},Builder.node('div',{id:'imageContainer',style:'padding: '+this.options.borderSize+'px'},[Builder.node('img',{id:'lightboxImage'}),Builder.node('div',{id:'hoverNav'},[Builder.node('a',{id:'prevLink',href:'#'}),Builder.node('a',{id:'nextLink',href:'#'})]),Builder.node('div',{id:'loading'},Builder.node('a',{id:'loadingLink',href:'#'},Builder.node('img',{src:this.options.fileLoadingImage})))])),Builder.node('div',{id:'imageDataContainer'},Builder.node('div',{id:'imageData'},[Builder.node('div',{id:'imageDetails'},[Builder.node('span',{id:'caption'}),Builder.node('span',{id:'numberDisplay'})]),Builder.node('div',{id:'bottomNav'},Builder.node('a',{id:'bottomNavClose',href:'#'},Builder.node('img',{src:this.options.fileBottomNavCloseImage})))]))]));$('overlay').hide().observe('click',(function(){this.end();}).bind(this));$('lightbox').hide().observe('click',(function(event){if(event.element().id=='lightbox')this.end();}).bind(this));$('outerImageContainer').setStyle({width:size,height:size});$('prevLink').observe('click',(function(event){event.stop();this.changeImage(this.activeImage-1);}).bindAsEventListener(this));$('nextLink').observe('click',(function(event){event.stop();this.changeImage(this.activeImage+1);}).bindAsEventListener(this));$('loadingLink').observe('click',(function(event){event.stop();this.end();}).bind(this));$('bottomNavClose').observe('click',(function(event){event.stop();this.end();}).bind(this));var th=this;var ids='overlay lightbox outerImageContainer imageContainer lightboxImage hoverNav prevLink nextLink loading loadingLink '+'imageDataContainer imageData imageDetails caption numberDisplay bottomNav bottomNavClose';$w(ids).each(function(id){th[id]=$(id);});this.updateImageList();},updateImageList:function(){this.updateImageList=Prototype.emptyFunction;document.observe('click',(function(event){var target=event.findElement('a[rel^=lightbox]')||event.findElement('area[rel^=lightbox]');if(target){event.stop();this.start(target);}}).bind(this));},start:function(imageLink){if(this.animating){return false;}
$$('select','object','embed').each(function(node){node.style.visibility='hidden'});var arrayPageSize=this.getPageSize();this.overlay.setStyle({width:arrayPageSize[0]+'px',height:arrayPageSize[1]+'px'});new Effect.Appear(this.overlay,{duration:this.overlayDuration,from:0.0,to:this.options.overlayOpacity});this.imageArray=[];var imageNum=0;if((imageLink.rel=='lightbox')){this.imageArray.push([imageLink.href,imageLink.title]);}else{this.imageArray=$$(imageLink.tagName+'[href][rel="'+imageLink.rel+'"]').collect(function(anchor){return[anchor.href,anchor.title];}).uniq();while(this.imageArray[imageNum][0]!=imageLink.href){imageNum++;}}
var lightboxTop=this.pageScroll[1]+(this.pageHeight/10);var lightboxLeft=this.pageScroll[0];this.lightbox.setStyle({top:lightboxTop+'px',left:lightboxLeft+'px'}).show();this.changeImage(imageNum);},changeImage:function(imageNum){this.activeImage=imageNum;if(this.options.animate)this.loading.show();this.lightboxImage.hide();this.hoverNav.hide();this.prevLink.hide();this.nextLink.hide();this.imageDataContainer.setStyle({opacity:.0001});this.numberDisplay.hide();var imgPreloader=new Image();imgPreloader.onload=(function(){this.lightboxImage.src=this.imageArray[this.activeImage][0];this.resizeImageContainer(imgPreloader.width,imgPreloader.height);}).bind(this);imgPreloader.src=this.imageArray[this.activeImage][0];},resizeImageContainer:function(imgWidth,imgHeight){var widthCurrent=this.outerImageContainer.getWidth()||(this.options.animate?250:1);var heightCurrent=this.outerImageContainer.getHeight()||(this.options.animate?250:1);var widthNew=(imgWidth+this.options.borderSize*2);var heightNew=(imgHeight+this.options.borderSize*2);var xScale=(widthNew/widthCurrent)*100;var yScale=(heightNew/heightCurrent)*100;var wDiff=widthCurrent-widthNew;var hDiff=heightCurrent-heightNew;if(hDiff!=0){this.animating=true;new Effect.Scale(this.outerImageContainer,yScale,{scaleX:false,duration:this.resizeDuration,queue:'front',afterFinish:function(){this.outerImageContainer.setStyle({height:heightNew+'px'});this.animating=false;}.bind(this)});}
if(wDiff!=0){this.animating=true;new Effect.Scale(this.outerImageContainer,xScale,{scaleY:false,duration:this.resizeDuration,delay:this.resizeDuration,afterFinish:function(){this.outerImageContainer.setStyle({width:widthNew+'px'});this.animating=false;}.bind(this)});}
var timeout=0;if((hDiff==0)&&(wDiff==0)){timeout=100;if(Prototype.Browser.IE)timeout=250;}
(function(){this.prevLink.setStyle({height:imgHeight+'px'});this.nextLink.setStyle({height:imgHeight+'px'});this.imageDataContainer.setStyle({width:widthNew+'px'});this.showImage();}).bind(this).delay(timeout/1000);},showImage:function(){this.loading.hide();new Effect.Appear(this.lightboxImage,{duration:this.resizeDuration,queue:'end',afterFinish:(function(){this.updateDetails();}).bind(this)});this.preloadNeighborImages();},updateDetails:function(){if(this.imageArray[this.activeImage][1]!=""){this.caption.update(this.imageArray[this.activeImage][1]).show();}
if(this.imageArray.length>1){this.numberDisplay.update(this.options.labelImage+' '+(this.activeImage+1)+' '+this.options.labelOf+'  '+this.imageArray.length).show();}
new Effect.Parallel([new Effect.SlideDown(this.imageDataContainer,{sync:true,duration:this.resizeDuration,from:0.0,to:1.0}),new Effect.Appear(this.imageDataContainer,{sync:true,duration:this.resizeDuration})],{duration:this.resizeDuration,afterFinish:(function(){var arrayPageSize=this.getPageSize();this.overlay.setStyle({height:arrayPageSize[1]+'px'});this.updateNav();}).bind(this)});},updateNav:function(){this.hoverNav.show();if(this.activeImage>0)this.prevLink.show();if(this.activeImage<(this.imageArray.length-1))this.nextLink.show();this.enableKeyboardNav();},enableKeyboardNav:function(){document.observe('keydown',this.keyboardAction);},disableKeyboardNav:function(){document.stopObserving('keydown',this.keyboardAction);},keyboardAction:function(event){var keycode=event.keyCode;var escapeKey;if(event.DOM_VK_ESCAPE){escapeKey=event.DOM_VK_ESCAPE;}else{escapeKey=27;}
var key=String.fromCharCode(keycode).toLowerCase();if(key.match(/x|o|c/)||(keycode==escapeKey)){this.end();}else if((key=='p')||(keycode==37)){if(this.activeImage!=0){this.disableKeyboardNav();this.changeImage(this.activeImage-1);}}else if((key=='n')||(keycode==39)){if(this.activeImage!=(this.imageArray.length-1)){this.disableKeyboardNav();this.changeImage(this.activeImage+1);}}},preloadNeighborImages:function(){var preloadNextImage,preloadPrevImage;if(this.imageArray.length>this.activeImage+1){preloadNextImage=new Image();preloadNextImage.src=this.imageArray[this.activeImage+1][0];}
if(this.activeImage>0){preloadPrevImage=new Image();preloadPrevImage.src=this.imageArray[this.activeImage-1][0];}},end:function(){this.disableKeyboardNav();this.lightbox.hide();new Effect.Fade(this.overlay,{duration:this.overlayDuration});$$('select','object','embed').each(function(node){node.style.visibility='visible'});},getPageSize:function(){var xScroll,yScroll;if(window.innerHeight&&window.scrollMaxY){xScroll=window.innerWidth+window.scrollMaxX;yScroll=window.innerHeight+window.scrollMaxY;}else if(document.body.scrollHeight>document.body.offsetHeight){xScroll=document.body.scrollWidth;yScroll=document.body.scrollHeight;}else{xScroll=document.body.offsetWidth;yScroll=document.body.offsetHeight;}
var windowWidth,windowHeight;if(self.innerHeight){if(document.documentElement.clientWidth){windowWidth=document.documentElement.clientWidth;}else{windowWidth=self.innerWidth;}
windowHeight=self.innerHeight;}else if(document.documentElement&&document.documentElement.clientHeight){windowWidth=document.documentElement.clientWidth;windowHeight=document.documentElement.clientHeight;}else if(document.body){windowWidth=document.body.clientWidth;windowHeight=document.body.clientHeight;}
if(yScroll<windowHeight){pageHeight=windowHeight;}else{pageHeight=yScroll;}
if(xScroll<windowWidth){pageWidth=xScroll;}else{pageWidth=windowWidth;}
return[pageWidth,pageHeight];}}
