var Gallery=function(){this.initialize.apply(this,arguments)};Gallery.Page=function(){this.initialize.apply(this,arguments)};Gallery.Item=function(){this.initialize.apply(this,arguments)};Gallery.Launcher=function(){this.initialize.apply(this,arguments)};Gallery.CATEGORY_URL='/prints-on-demand/category.html';Gallery.redirectToCategories=function(){window.location.href=this.CATEGORY_URL};Gallery.compareURLs=function(b,c,d){b=this.parseURL(b.replace(/^https?:\/\/[^\/]*/ig,''));c=this.parseURL(c.replace(/^https?:\/\/[^\/]*/ig,''));if(b.protocol!=c.protocol)return false;if(b.domain!=c.domain)return false;if(b.path!=c.path)return false;if(d&&d.ignore)d.ignore.forEach(function(a){delete b.params[a];delete c.params[a]});for(var e in b.params){if(b.params[e]!=c.params[e])return false}for(var e in c.params){if(b.params[e]!=c.params[e])return false}return true};Gallery.parseURL=function(b){var c,domain,path,params={},i,n,bit;b=b.replace(/^\w+:\/+/,function(a){c=a;return''}).replace(/^[^\/]+/,function(a){domain=a;return''}).replace(/^[^\?]+/,function(a){path=a;return''});if(b.charAt(0)=='?'){b=b.slice(1).split('&');for(i=0,n=b.length;i<n;i++){bit=b[i].split('=').map(decodeURIComponent).map(YAHOO.lang.trim);params[bit[0]]=bit[1]}}return{protocol:c,domain:domain,path:path,params:params}};Gallery.prototype={config:{itemTag:'div',itemClass:'item',thumbSize:75,zoomFactor:1.8,scrollDirection:'vertical',fullSizeWidth:600},Y:YAHOO.util,setStyle:YAHOO.util.Dom.setStyle,getRegion:YAHOO.util.Dom.getRegion,initialize:function(a,b){this.elementID=String(a);b=b||{};for(var c in b)this.config[c]=b[c]},getInitialState:function(){return{page:1,popupVisible:0,popup:0}},changeState:function(a){if(a.page)this.focusPage(a.page)},setup:function(){this.element=document.getElementById(this.elementID);if(!this.element)return;this.setupItems();this.paginate();this.setupControls();this.state=this.getInitialState();this.focusPage(this.state.page);this.galleryMode='browse';return this},setupItems:function(){if(!this.element||this.items)return;this.items=[];var a=this.Y.Dom.getElementsByClassName(this.config.itemClass,this.config.itemTag,this.element);for(var i=0,n=a.length;i<n;i++)this.items.push(new Gallery.Item(this,a[i]))},findItemByURL:function(a){if(!this.items)return null;for(var i=0,n=this.items.length,item;i<n;i++){item=this.items[i];if(Gallery.compareURLs(item.getURL(),a,{ignore:['ajaxLayout']}))return item}return null},openItemByURL:function(a){if(!a)return;var b=this.findItemByURL(a);if(b)this.openItem(b)},paginate:function(){if(!this.element||!this.items||!this.items.length)return;var a=this.items[0].getElementRegion();this.itemWidth=a.right-a.left;this.itemHeight=a.bottom-a.top;this.createContainers();a=this.getContainerRegion();this.pageWidth=a.right-a.left;this.pageHeight=a.bottom-a.top;var x=Math.floor(this.pageWidth/this.itemWidth);var y=Math.floor(this.pageHeight/this.itemHeight);this.itemsPerPage=x*y;var n=Math.ceil(this.items.length/this.itemsPerPage);this.pages=[];for(var i=0;i<n;i++)this.pages.push(new Gallery.Page(this,i+1));switch(this.config.scrollDirection){case'horizontal':this.setStyle(this.slider,'width',(n*this.pageWidth+1000)+'px');this.setStyle(this.slider,'height',this.pageHeight+'px');break;case'vertical':this.setStyle(this.slider,'width',this.pageWidth+'px');this.setStyle(this.slider,'height',(n*this.pageHeight+1000)+'px');break}},createContainers:function(){if(!this.element)return;this.container=document.createElement('div');Gallery.setStyle(this.container,{width:'100%',height:'100%',overflow:'hidden',position:'relative'});this.slider=document.createElement('div');this.setStyle(this.slider,'position','absolute');this.container.appendChild(this.slider);this.element.innerHTML='';this.element.appendChild(this.container);var a=this.getContainerRegion();this.setStyle(this.container,'width',(a.right-a.left)+'px');this.setStyle(this.container,'height',(a.bottom-a.top)+'px')},getContainerRegion:function(){return this.getRegion(this.container)},setupControls:function(){this.controlContainer=document.createElement('div');this.controlContainer.className='scrollbar';this.scrollbarThumb=document.createElement('div');this.scrollbarThumb.className='scrollbar-thumb';this.scrollbarThumb.innerHTML='<img src="'+IMAGE_CONFIG.SCROLLBAR_THUMB+'" />';this.controlContainer.appendChild(this.scrollbarThumb);this.element.parentNode.insertBefore(this.controlContainer,this.element.nextSibling);var c=this.getRegion(this.controlContainer);var d=this.getRegion(this.scrollbarThumb);this.scrollRange=(c.bottom-c.top)-(d.bottom-d.top);this.sliderControl=YAHOO.widget.Slider.getVertSlider(this.controlContainer,this.scrollbarThumb,0,this.scrollRange);var e=this;this.sliderControl.getPage=function(){var n=e.pages.length;return Math.ceil(n*this.getValue()/e.scrollRange)||1};this.sliderControl.subscribe('change',function(a){var b=e.sliderControl.getPage();if(b!=e.state.page)e.changeState({page:b})});this.prevControl=document.createElement('div');this.prevControl.className='prevControl';this.prevControl.innerHTML='Previous';this.Y.Event.addListener(this.prevControl,'click',function(){if(e.state.page>1)e.changeState({page:e.state.page-1});if(e.sliderControl){var a=(e.state.page-1)*e.scrollRange/(e.pages.length-1);e.sliderControl.setValue(a,false)}});this.nextControl=document.createElement('div');this.nextControl.className='nextControl';this.nextControl.innerHTML='Next';this.Y.Event.addListener(this.nextControl,'click',function(){if(e.state.page<e.pages.length)e.changeState({page:e.state.page+1});if(e.sliderControl){var a=(e.state.page-1)*e.scrollRange/(e.pages.length-1);e.sliderControl.setValue(a,false)}});this.element.appendChild(this.prevControl);this.element.appendChild(this.nextControl)},focusPage:function(a){if(a<1||a>this.pages.length)return;this.state.page=a;var b=(this.config.scrollDirection=='horizontal')?{left:{to:-(this.state.page-1)*this.pageWidth}}:{top:{to:-(this.state.page-1)*this.pageHeight}};var c=new this.Y.Anim(this.slider,b,0.6,this.Y.Easing.easeBoth);c.animate()},openItem:function(a){this.galleryMode='item';this.populateImageViewer(a.url)},getImageViewer:function(){var a=document.getElementById('pod-gallery-image-viewer');if(!a)this.createImageViewer();else this.imageViewer=a;this.imageViewerVisible=!!this.imageViewerVisible},createImageViewer:function(){if(this.imageViewer)return;this.imageViewer=document.createElement('div');this.imageViewer.id='pod-gallery-image-viewer';Gallery.setStyle(this.imageViewer,{position:'absolute',display:'none',width:'678px',height:'396px',padding:'16px',background:'#eee','z-index':10020,opacity:0.01,overflow:'hidden'});document.body.appendChild(this.imageViewer);this.imageViewerVisible=false},populateImageViewer:function(b){this.getImageViewer();if(!/ajaxLayout=true/.test(b))b=b+(/\?/.test(b)?'&':'?')+'ajaxLayout=true';YAHOO.util.Connect.asyncRequest('GET',b,{scope:this,success:function(a){this.imageViewer.innerHTML=a.responseText;setTimeout(function(){this.imageSources=(new Function('return '+document.getElementById('pod-image-sources').innerHTML.replace(/\s+/g,' ')))()}.bind(this),10);this.setupImageViewer()}})},getViewerRegion:function(){return this.getRegion(_$('.galleryPanel').el[0])},positionImageViewer:function(){this.getImageViewer();Gallery.setStyle(this.imageViewer,{display:''});var a=this.getViewerRegion();var b={x:(a.right+a.left)/2,y:(a.bottom+a.top)/2};var c=this.getRegion(this.imageViewer);var d={width:c.right-c.left,height:c.bottom-c.top};Gallery.setStyle(this.imageViewer,{left:(b.x-d.width/2-(YAHOO.env.ua.ie?2:0))+'px',top:(b.y-d.height/2)+'px'})},displayImageViewer:function(){if(this.imageViewerVisible)return;var a=this;Gallery.setStyle(this.imageViewer,{display:''});var b=new this.Y.Anim(this.imageViewer,{opacity:{to:1}},0.5,this.Y.Easing.easeIn);b.onComplete.subscribe(function(){a.imageViewerVisible=true;if(a.imageViewer.style.filter)a.imageViewer.style.filter=''});b.animate();var a=this;setTimeout(function(){a.showImageViewerCloseButton()},500)},closeImageViewer:function(){Gallery.FrameInformation.hideAll();if(!this.imageViewerVisible)return;var a=this;var b=new this.Y.Anim(this.imageViewer,{opacity:{to:0.01}},0.5,this.Y.Easing.easeIn);b.onComplete.subscribe(function(){a.imageViewerVisible=false;a.imageViewer.style.display='none';a.galleryMode='browse'});Gallery.setStyle(this.imageViewerCloseButton,{display:'none'});b.animate();this.selectedFrameType=null},fixButtonLabels:function(a,b){var c=document.getElementById(b).getElementsByTagName('label');for(var i=0,n=a.getButtons().length;i<n;i++){if(c[i]){var d=a.getButtons()[i]._button.innerHTML=c[i].innerHTML.replace(/^FC?\d\S*/,'').replace(/\s*-+\s*/,'<br />').replace(/\s*frame/ig,'').capitalizeFirst()}}YAHOO.util.Dom.setStyle(c[0].parentNode,'display','none')},setupImageViewer:function(){this.positionImageViewer();this.displayImageViewer();setTimeout(function(){this.purchaseForm=document.getElementById('othercommerce/PurchaseImage');this.Y.Event.addListener(this.purchaseForm,'submit',function(e){this.Y.Event.preventDefault(e);this.mediumButtons.getButtons().forEach(function(a){a.createHiddenFields()});this.frameButtons.getButtons().forEach(function(a){a.createHiddenFields()});YAHOO.util.Connect.setForm(this.purchaseForm);var b=this.purchaseForm.method||'POST';var c=this.purchaseForm.action;YAHOO.util.Connect.asyncRequest(b,c,{success:function(a){this.imageViewer.innerHTML=a.responseText;if(this.imageViewerCloseButton){this.imageViewerCloseButton.parentNode.removeChild(this.imageViewerCloseButton);this.imageViewerCloseButton=null}Gallery.FrameInformation.hideAll();this.Y.Event.on(_$('#choose-image').el[0],'click',function(e){this.Y.Event.preventDefault(e);this.launcher.changeState({item:null})}.bind(this));this.Y.Event.on(_$('#choose-gallery').el[0],'click',function(e){this.Y.Event.preventDefault(e);Gallery.redirectToCategories()}.bind(this))}.bind(this)});YAHOO.util.Connect.resetFormState()}.bind(this));var d=this.getViewerRegion(),headingRegion=this.getRegion(_$('#'+this.imageViewer.id+' h4').el[0]),infoRegion=this.getRegion(_$('#'+this.imageViewer.id+' .credits').el[0]);var f=(d.bottom-infoRegion.top)-(headingRegion.bottom-d.top);this.originalPositioning={marginTop:parseInt(_$('.imageContainer').el[0].style.marginTop)-f,marginLeft:parseInt(_$('.imageContainer').el[0].style.marginLeft),width:parseInt(_$('.imageContainer img').el[0].width),height:parseInt(_$('.imageContainer img').el[0].height)};this.imageFrameHolder=this.Y.Dom.getElementsByClassName('imageContainer','div',this.imageViewer)[0];this.imageHolderClass=this.imageFrameHolder.className;this.mediumButtons=new YAHOO.widget.ButtonGroup('printOptionMedium');this.fixButtonLabels(this.mediumButtons,'printOptionMedium');this.mediumButtons.getButtons()[0].set('checked',true);this.updateFramingOptions();for(var i=0,n=this.mediumButtons.getButtons().length;i<n;i++)(function(a){a.addListener('click',this.updateFramingOptions.bind(this));a.addListener('click',this.setImageSource.bind(this,a));a.addListener('click',this.setImageSize.bind(this,a));var b=a._button.innerHTML;a._button.innerHTML=b.replace(/^\s*\d+\%\s*/,'');a.relativeSize=parseInt(b.match(/^\s*(\d+)\%/)[1])/100}.bind(this))(this.mediumButtons.getButtons()[i]);this.setImageSource(this.mediumButtons.getButtons()[0]);this.setImageSize(this.mediumButtons.getButtons()[0]);this.frameButtons=new YAHOO.widget.ButtonGroup('printOptionFrame');this.fixButtonLabels(this.frameButtons,'printOptionFrame')}.bind(this),10)},setImageSource:function(a){var b=a._button.innerHTML.match(/(paper|canvas)/i)[1].toLowerCase();var c=_$('.imageContainer img').el[0];c.src=this.imageSources[b].source;var d=this.imageSources[b].width,height=this.imageSources[b].height,pos=this.originalPositioning;pos.marginLeft=pos.marginLeft+(pos.width-d)/2;pos.marginTop=pos.marginTop+(pos.height-height)/2;pos.width=d;pos.height=height},setImageSize:function(a){var b=0.5+0.5*a.relativeSize||1.0,pos=this.originalPositioning;if(b>1)b=1;b=1;var c=pos.width*b;var d=pos.height*b;var e=_$('.imageContainer').el[0];var f=_$('.imageContainer img').el[0];f.width=c;f.height=d;Gallery.setStyle(e,{marginLeft:(pos.marginLeft-(c-pos.width)/2)+'px',marginTop:(pos.marginTop-(d-pos.height)/2)+'px'})},updateFramingOptions:function(){var k='/ajax/request.html?template=/site/templates/ajax/frame-field.vm&action=com.othermedia.nhm.actions.BasketActions.doRetrieveSkuFrames&Psku='+this.mediumButtons.get('value');YAHOO.util.Connect.asyncRequest('GET',k,{scope:this,success:function(h){var j=YAHOO.util.Dom.getElementsByClassName('fieldcontrol','span','printOptionFrame')[0];j.innerHTML=h.responseText;Gallery.FrameInformation.hideAll();this.imageFrameHolder.className=this.imageHolderClass+' noframe';setTimeout(function(){var g=_$('#printOptionFrame input[type=radio]').el,label,checked=false;for(var i=0,n=g.length;i<n;i++){label=_$('label[for='+g[i].id+']').el[0];if(this.selectedFrameType&&label.innerHTML.match(new RegExp(this.selectedFrameType,'ig'))){checked=i}}if(checked!==false&&!this.frameButtons)g[checked].checked=true;if(this.selectedFrameType)this.imageFrameHolder.className=this.imageHolderClass+' '+this.selectedFrameType;if(this.frameButtons){while(this.frameButtons.getButtons()[0])this.frameButtons.removeButton(0)}this.frameButtons=new YAHOO.widget.ButtonGroup('printOptionFrame');this.fixButtonLabels(this.frameButtons,'printOptionFrame');if(checked===false)this.frameButtons.getButtons()[0].set('checked',true);else this.frameButtons.check(checked);for(var i=0,n=this.frameButtons.getButtons().length;i<n;i++)(function(b){var c=b._button.innerHTML.match(/white|black|maple|gold|brown/i);b._button.innerHTML=b._button.innerHTML.replace(/\d[0-9mx\s]+/g,'');b.addListener('click',this.updatePrice.bind(this));b.addListener('click',function(e){var a=c?c[0].toLowerCase():'noframe';this.selectedFrameType=a;this.imageFrameHolder.className=this.imageHolderClass+' '+a}.bind(this));if(!c)return;var d=Gallery.FrameInformation.create(c[0].toLowerCase());var f=this.getRegion(b._button);Gallery.setStyle(d.thumb,{left:(f.right+4)+'px',top:(f.top+4)+'px'});d.show()}.bind(this))(this.frameButtons.getButtons()[i]);this.fixBuggyYUIButtonGroups();setTimeout(this.updatePrice.bind(this),10)}.bind(this),100)}})},fixBuggyYUIButtonGroups:function(){for(var i=0,n=this.mediumButtons.getButtons().length;i<n;i++)this.mediumButtons.getButtons()[i]._addListenersToForm()},updatePrice:function(){var d='/ajax/request.html?template=/site/templates/ajax/image-price.vm&action=com.othermedia.nhm.actions.BasketActions.doRetrieveSkuFramePrice';var e=this.mediumButtons.get('value')||'';var f=this.frameButtons.get('value')||'';YAHOO.util.Connect.asyncRequest('GET',d+'&Psku='+e+'&Pframe='+f,{scope:this,success:function(a){var b=a.responseText.split(/\s*\|+\s*/);var c=b[1].match(/^([a-z0-9\s]*)/)[1];_$('.imagePurchaseForm .price').el[0].innerHTML='Price not including delivery <span>&pound;'+b[0]+'</span>';_$('#pod-selection-info').el[0].innerHTML=b[1].capitalizeFirst()}})},showImageViewerCloseButton:function(){if(!this.imageViewerCloseButton)this.createImageViewerCloseButton();var a=this.getRegion(this.imageViewer);Gallery.setStyle(this.imageViewerCloseButton,{display:'',left:(a.left+16)+'px',top:(a.bottom-24)+'px'})},createImageViewerCloseButton:function(){if(this.imageViewerCloseButton)return;this.imageViewerCloseButton=document.createElement('div');this.imageViewerCloseButton.innerHTML='Select a different image';Gallery.setStyle(this.imageViewerCloseButton,{display:'none','z-index':10030});this.imageViewerCloseButton.className='image-viewer-close';document.body.appendChild(this.imageViewerCloseButton);this.Y.Event.addListener(this.imageViewerCloseButton,'click',function(e){this.launcher.changeState({item:null})},this,true)},setupImageZoom:function(){if(!this.zoomIamge)this.createZoomImage();var b=_$('.imageContainer img').el[0];this.zoomImage.src=b.src;this.Y.Event.addListener(b,'mouseover',function(){var a=this.getRegion(b),w=a.right-a.left,h=a.bottom-a.top;var f=1.8;Gallery.setStyle(this.zoomImage,{display:'',width:(f*w)+'px',height:(f*h)+'px',left:(a.left-(f-1)*w/2)+'px',top:(a.top-(f-1)*h/2)+'px'})}.bind(this))},createZoomImage:function(){if(this.zoomImage)return;this.zoomImage=document.createElement('img');Gallery.setStyle(this.zoomImage,{position:'absolute',display:'none','z-index':10070});document.body.appendChild(this.zoomImage);this.Y.Event.addListener(this.zoomImage,'mouseout',function(){Gallery.setStyle(this.zoomImage,{display:'none'})}.bind(this))}};Gallery.Page.prototype={Y:YAHOO.util,setStyle:YAHOO.util.Dom.setStyle,getRegion:YAHOO.util.Dom.getRegion,initialize:function(c,d){this.gallery=c;this.page=Number(d);var a=(this.page-1)*this.gallery.itemsPerPage;var b=a+this.gallery.itemsPerPage;this.items=this.gallery.items.slice(a,b);this.createElement()},createElement:function(){this.element=document.createElement('div');var a=this.gallery.getContainerRegion();this.setStyle(this.element,'width',(a.right-a.left)+'px');this.setStyle(this.element,'height',(a.bottom-a.top)+'px');if(this.gallery.config.scrollDirection=='horizontal'){this.setStyle(this.element,'display','inline');this.setStyle(this.element,'float','left')}var b;for(var i=0,n=this.items.length;i<n;i++){b=this.items[i];this.element.appendChild(b.element);if(b.element.innerHTML)continue;b.element.appendChild(b.link);b.link.appendChild(b.image)}this.gallery.slider.appendChild(this.element)}};Gallery.Item.prototype={Y:YAHOO.util,setStyle:YAHOO.util.Dom.setStyle,getRegion:YAHOO.util.Dom.getRegion,initialize:function(a,b){this.gallery=a;this.thumbSize=this.gallery.config.thumbSize;this.element=b;this.link=this.element.getElementsByTagName('a')[0];this.image=this.element.getElementsByTagName('img')[0];this.url=String(this.link.href).replace(/^https?:\/\/[^\/]*/ig,'');var c=this.image.alt.split(/\|+/);this.altText='<strong>'+c[0].capitalizeFirst()+'</strong>'+(c[1]?'<br />'+c[1]:'');this.configureElement();this.configureImage();this.disableLink();this.setupAnimationImage();this.setupZoom()},getURL:function(){return this.url.replace(/^https?:\/\/[^\/]*/ig,'')},getElementRegion:function(){return this.getRegion(this.element)},getImageRegion:function(){return this.getRegion(this.image)},getZoomImageRegion:function(){var a=this.getImageRegion(),f=this.gallery.config.zoomFactor;var w=a.right-a.left;var h=a.bottom-a.top;return new YAHOO.util.Region(a.top-(f-1)*h/2,a.right+(f-1)*w/2,a.bottom+(f-1)*h/2,a.left-(f-1)*w/2)},configureElement:function(){Gallery.setStyle(this.element,{width:this.gallery.config.thumbSize+'px',height:this.gallery.config.thumbSize+'px',marginTop:0,marginRight:0,marginBottom:0,marginLeft:0,display:'inline','float':'left'})},configureImage:function(){var w=Number(this.image.width),h=Number(this.image.height),r=w/h;this.imageDimensions=(w>h)?{width:this.thumbSize,height:this.thumbSize/r}:{width:r*this.thumbSize,height:this.thumbSize};this.image.width=this.imageDimensions.width;this.image.height=this.imageDimensions.height;this.setStyle(this.element,'position','relative');this.setStyle(this.image,'position','absolute');var a=this.getElementRegion(),ireg=this.getImageRegion();this.setStyle(this.image,'left',((a.right-a.left)-(ireg.right-ireg.left))/2+'px');this.setStyle(this.image,'top',((a.bottom-a.top)-(ireg.bottom-ireg.top))/2+'px')},disableLink:function(){var a=this.image;while(a.tagName.toLowerCase()!='a'&&a!==this.element)a=a.parentNode;if(a.tagName.toLowerCase()!='a')return;YAHOO.util.Event.addListener(this.link,'click',YAHOO.util.Event.preventDefault)},setupAnimationImage:function(){if(this.animationImage)return;this.imageSrc=String(this.image.src);this.animationImage=document.createElement('img');this.animationImage.src=this.imageSrc;Gallery.setStyle(this.animationImage,{display:'none',position:'absolute',cursor:'pointer','z-index':10018,border:'1px solid #cacaca'});document.body.appendChild(this.animationImage)},setupZoom:function(){var c=this;this.Y.Event.addListener(this.image,'mouseover',function(e){if(c.gallery.galleryMode=='browse')c.showZoom()});MouseTracker.subscribe(function(a){var b=c.getRegion(c.animationImage);if(c.gallery.galleryMode=='browse'&&(a.x<b.left||a.x>b.right||a.y<b.top||a.y>b.bottom))c.hideZoom()});this.Y.Event.addListener(this.animationImage,'click',function(e){Gallery.setStyle(c.animationImage,{display:'none'});Gallery.setStyle(c.tooltip,{display:'none'});c.gallery.galleryMode='item';c.gallery.launcher.changeState({item:c.getURL()})})},showZoom:function(){if(this.gallery.currentZoomItem)this.gallery.currentZoomItem.hideZoom();this.gallery.currentZoomItem=this;var a=this.animationImage,region=this.getImageRegion();var b=this.getZoomImageRegion();Gallery.setStyle(a,{width:(b.right-b.left)+'px',height:(b.bottom-b.top)+'px',left:b.left+'px',top:b.top+'px',display:''});if(!this.tooltip)this.createTooltip();this.tooltip.innerHTML='<div>'+this.altText+'</div>';Gallery.setStyle(this.tooltip,{width:(b.right-b.left+2)+'px',left:b.left+'px',top:b.bottom+'px',display:''})},hideZoom:function(){this.gallery.currentZoomItem=null;Gallery.setStyle(this.animationImage,{display:'none',opacity:1});Gallery.setStyle(this.tooltip,{display:'none'})},createTooltip:function(){this.tooltip=document.createElement('div');this.tooltip.className='tooltip';Gallery.setStyle(this.tooltip,{display:'none',position:'absolute','z-index':10040});document.body.appendChild(this.tooltip)},blowupImage:function(){if(this.gallery.currentBlowupItem)this.gallery.currentBlowupItem.collapse();this.gallery.currentBlowupItem=this;var a=this.getAnimationParameters();this.setStyle(this.animationImage,'display','');var b=new this.Y.Anim(this.animationImage,{left:{from:a.left.lo,to:a.left.hi},top:{from:a.top.lo,to:a.top.hi},width:{from:a.width.lo,to:a.width.hi},height:{from:a.height.lo,to:a.height.hi},opacity:{from:a.opacity.lo,to:a.opacity.hi}},0.5,this.Y.Easing.easeOut);b.animate()},collapse:function(){this.gallery.currentBlowupItem=null;var a=this.getAnimationParameters();var b=new this.Y.Anim(this.animationImage,{left:{from:a.left.hi,to:a.left.lo},top:{from:a.top.hi,to:a.top.lo},width:{from:a.width.hi,to:a.width.lo},height:{from:a.height.hi,to:a.height.lo},opacity:{from:a.opacity.hi,to:a.opacity.lo}},0.5,this.Y.Easing.easeOut);var c=this;b.onComplete.subscribe(function(){c.setStyle(c.animationImage,'display','')});b.animate()},getAnimationParameters:function(){var a=this.getZoomImageRegion();var b=Gallery.getViewportDimensions();var c=Gallery.getScrollOffsets();var d=this.gallery.config.fullSizeWidth;var e=(a.right-a.left)/(a.bottom-a.top);var f={left:{lo:a.left,hi:(b.width-d)/2+c.left},top:{lo:a.top,hi:(b.height-d/e)/2+c.top},width:{lo:a.right-a.left,hi:d},height:{lo:a.bottom-a.top,hi:d/e},opacity:{lo:0.01,hi:1}};return f}};Gallery.FrameInformation={Panel:function(){this.initialize.apply(this,arguments)},create:function(a){if(this[a])return this[a];return new Gallery.FrameInformation.Panel(a)},hideAll:function(){for(var a in this){if(!/^Panel|create|hideAll$/.test(a))this[a].hide()}}};Gallery.FrameInformation.Panel.prototype={initialize:function(a){if(Gallery.FrameInformation[a])return;Gallery.FrameInformation[a]=this;this.frameType=a;this.createThumb();this.createPanel()},createThumb:function(){this.thumb=document.createElement('div');this.thumb.className='frame-thumb';this.thumb.innerHTML='<img src="'+IMAGE_CONFIG.FRAME_DIR+this.frameType+'-info.png" />';MouseTracker.on('entering',this.thumb,this.showPanel.bind(this));MouseTracker.on('leaving',this.thumb,this.hidePanel.bind(this));Gallery.setStyle(this.thumb,{position:'absolute',left:0,top:0,'z-index':10040});this.hide();document.body.appendChild(this.thumb)},hide:function(){Gallery.setStyle(this.thumb,{display:'none'});this.hidePanel()},show:function(){Gallery.setStyle(this.thumb,{display:''})},createPanel:function(){this.panel=document.createElement('div');this.panel.className='frame-panel';this.panel.innerHTML='<img src="'+IMAGE_CONFIG.FRAME_DIR+this.frameType+'-frame.jpg" />'+'<img src="'+IMAGE_CONFIG.FRAME_DIR+this.frameType+'-diagram.jpg" />';Gallery.setStyle(this.panel,{display:'none',position:'absolute','z-index':10050});document.body.appendChild(this.panel)},showPanel:function(){if(!this.panel)return;Gallery.setStyle(this.panel,{display:''});var a=YAHOO.util.Dom.getRegion(this.thumb),panelRegion=YAHOO.util.Dom.getRegion(this.panel);Gallery.setStyle(this.panel,{left:(a.left-(panelRegion.right-panelRegion.left)+8)+'px',top:((a.top+a.bottom)/2-(panelRegion.bottom-panelRegion.top)/2)+'px'})},hidePanel:function(){if(!this.panel)return;Gallery.setStyle(this.panel,{display:'none'})}};Gallery.Launcher.prototype={Y:YAHOO.util,setStyle:YAHOO.util.Dom.setStyle,getRegion:YAHOO.util.Dom.getRegion,initialize:function(a,b,c){this.className=String(a);this.galleryID=String(b);this.state=this.getInitialState();this.galleryOptions=c||{}},setup:function(){this.triggers=this.Y.Dom.getElementsByClassName(this.className);for(var i=0,n=this.triggers.length;i<n;i++)(function(a,b){var c=b.href||'/';if(!/ajaxLayout=true/.test(c))c=c+(/\?/.test(c)?'&':'?')+'ajaxLayout=true&podAjax=true';c=c.replace(/^http:\/\/[^\/]+/,'');a.Y.Event.addListener(b,'click',function(e){YAHOO.util.Event.preventDefault(e);a.changeState({visible:true,url:c})});if(/view products/i.test(b.innerHTML))b.innerHTML='<em>View images</em>'})(this,this.triggers[i]);var d=document.getElementById('pod-product-open-overlay');if(d)Gallery.setStyle(d,{display:'block'})},getInitialState:function(){return{visible:false,url:'',item:null}},changeState:function(a){var b=this;var c=String(a.url).replace(/&amp;/g,'&');switch(a.visible){case true:setTimeout(function(){b.displayGallery(c)},50);break;case false:this.hideGallery();break}if(a.item!==undefined){this.state.item=String(a.item).replace(/&amp;/g,'&');setTimeout(function(){if(this.gallery&&this.state.visible){a.item?this.gallery.openItemByURL(this.state.item):this.gallery.closeImageViewer()}}.bind(this),100)}},displayGallery:function(a){if(this.state.visible)return;if(!this.overlay)this.createOverlays();var b=Gallery.getDocumentDimensions();Gallery.setStyle(this.overlay,{width:b.width+'px',height:b.height+'px',display:'',opacity:0.7});this.state.visible=true;this.populateGallery(a,true)},hideGallery:function(){if(!this.state.visible)return;this.gallery.closeImageViewer();this.state.visible=false;new this.Y.Anim(this.contentOverlay,{opacity:{to:0}},0.5,this.Y.Easing.easeIn).animate();new this.Y.Anim(this.overlay,{opacity:{to:0}},0.5,this.Y.Easing.easeIn).animate();var a=new this.Y.Anim(this.closeButton,{opacity:{to:0}},0.5,this.Y.Easing.easeIn);var b=this;a.onComplete.subscribe(function(){b.setStyle(b.overlay,'display','none');b.setStyle(b.contentOverlay,'display','none');b.setStyle(b.closeButton,'display','none');if(b.gallery.currentBlowupItem)b.gallery.currentBlowupItem.collapse();else if(b.gallery.currentZoomItem)b.gallery.currentZoomItem.hideZoom()});a.animate()},populateGallery:function(c,d){Gallery.Spinner.show();c=c||this.url;YAHOO.util.Connect.asyncRequest('GET',c,{scope:this,success:function(a){Gallery.Spinner.hide();this.contentOverlay.innerHTML=a.responseText;var b=this;setTimeout(function(){b.gallery=new Gallery(b.galleryID,b.galleryOptions).setup();b.gallery.launcher=b;b.gallery.openItemByURL(b.state.item)},400);this.centerContent();if(!d)return this.setStyle(this.contentOverlay,'opacity',1);Gallery.setStyle(this.contentOverlay,{opacity:1});Gallery.setStyle(this.closeButton,{opacity:1})}})},centerContent:function(){Gallery.setStyle(this.contentOverlay,{display:'',left:0,top:0});var a=Gallery.getViewportDimensions(),scrolls=Gallery.getScrollOffsets();var b=this.getRegion(this.contentOverlay);var w=b.right-b.left,h=b.bottom-b.top;Gallery.setStyle(this.contentOverlay,{left:(scrolls.left+(a.width-w)/2)+'px',top:(scrolls.top+(a.height-h)/2)+'px'});this.positionCloseButton()},positionCloseButton:function(){if(!this.closeButton)this.createCloseButton();this.setStyle(this.closeButton,'display','');var a=this.getRegion(this.contentOverlay);this.setStyle(this.closeButton,'left',(a.right-76)+'px');this.setStyle(this.closeButton,'top',(a.top-2)+'px')},createCloseButton:function(){if(this.closeButton)return;this.closeButton=document.createElement('div');this.closeButton.innerHTML='Close';this.closeButton.className='gallery-close';Gallery.setStyle(this.closeButton,{display:'none',cursor:'pointer',position:'absolute',left:0,top:0,'z-index':10010,opacity:0.01});document.body.appendChild(this.closeButton);YAHOO.util.Event.addListener(this.closeButton,'click',function(e){YAHOO.util.Event.preventDefault(e);this.changeState({visible:false,url:null,item:null})},this,true)},createOverlays:function(){if(this.overlay)return;this.overlay=document.createElement('div');Gallery.setStyle(this.overlay,{position:'absolute',left:0,top:0,display:'none','background-color':'#000',opacity:0.01,'z-index':10000});this.contentOverlay=document.createElement('div');Gallery.setStyle(this.contentOverlay,{position:'absolute',display:'none',opacity:0.01,'z-index':10010});document.body.appendChild(this.overlay);document.body.appendChild(this.contentOverlay)}};Gallery.Spinner={setStyle:YAHOO.util.Dom.setStyle,count:0,createImage:function(){this.width=200;this.height=100;if(!this.source)return false;if(this.container)return true;this.container=document.createElement('div');this.setStyle(this.container,'width',this.width+'px');this.setStyle(this.container,'height',this.height+'px');this.setStyle(this.container,'text-align','center');var a=document.createElement('img');a.src=this.source;var p=document.createElement('p');p.innerHTML='Loading...';this.setStyle(p,'color','#ffffff');this.setStyle(p,'font','normal 14px Arial, sans-serif');this.setStyle(p,'margin','12px 0');this.container.appendChild(a);this.container.appendChild(p);this.container.style.display='none';document.body.appendChild(this.container);this.image=a;this.p=p;return true},positionImage:function(){var a=Gallery.getViewportDimensions(),scrolls=Gallery.getScrollOffsets();this.setStyle(this.container,'position','absolute');this.setStyle(this.container,'left',(scrolls.left+a.width/2-this.width/2)+'px');this.setStyle(this.container,'top',(scrolls.top+a.height/2-this.height/2)+'px');this.setStyle(this.container,'z-index','20000')},show:function(){if(!this.createImage())return;this.count++;this.positionImage();this.container.style.display='';this.image.style.display='';this.p.style.display=''},hide:function(){if(!this.createImage())return;if(this.count==0)return;this.count--;if(this.count!=0)return;this.container.style.display='none';this.image.style.display='none';this.p.style.display='none'}};Gallery.getViewportDimensions=function(){return{width:YAHOO.util.Dom.getViewportWidth(),height:YAHOO.util.Dom.getViewportHeight()}};Gallery.getDocumentDimensions=function(){return{width:YAHOO.util.Dom.getDocumentWidth(),height:YAHOO.util.Dom.getDocumentHeight()}};Gallery.getScrollOffsets=function(){return{left:YAHOO.util.Dom.getDocumentScrollLeft(),top:YAHOO.util.Dom.getDocumentScrollTop()}};Gallery.setStyle=function(a,b){for(var c in b)YAHOO.util.Dom.setStyle(a,c,b[c])};Gallery.History={manage:function(d,e){if(!YAHOO||!YAHOO.util.History)throw new ReferenceError('YAHOO.util.History is not defined');if(!d||!d.getInitialState||!d.changeState)throw new TypeError('object must implement getInitialState() and changeState()');var f=String(e);var g=d.changeState.functionize();var h={};var j=YAHOO.util.History;var k={'?':'--Qq--','=':'--Ee--','&':'--Aa--','_':'--Uu--','/':'--Ss--'};var l=function(a){var b=encodeURIComponent(m(a));for(var c in k)b=b.replace(c,k[c]);return b};var m=function(a){a=decodeURIComponent(String(a));for(var b in k)a=a.replace(k[b],b);return a};var o=function(a){if(typeof a!='string')return a;if((/^\-?\d+(?:\.\d+)?$/.test(a)))a=Number(a);var b={'true':true,'false':false,'undefined':undefined,'null':null};for(var c in b){if(a==c)a=b[c]}return a};var p=function(a){if(!a)return'';var b=[];for(var c in a)b.push(l(c)+'_'+l(a[c]));return b.join('/')};var q=function(a){a=String(a).replace(/^\s*(.*?)\s*$/,'$1');if(!a)return{};var b=a.split('/'),part,state={},value;for(var i=0,n=b.length;i<n;i++){part=b[i].split('_');value=o(m(part[1]));state[m(part[0])]=value}return state};d.getInitialState=d.getInitialState.wrap(function(a){h=j.getBookmarkedState(f);if(h)h=q(h);else h=a();return h});d.changeState=function(a){a=a||{};for(var b in a)h[b]=a[b];a=p(h);j.navigate(f,a)};var r=p(d.getInitialState());j.register(f,r,function(a){a=q(a);g(d,a)});j.onLoadEvent.subscribe(function(){var a=j.getCurrentState(f);a=q(a);g(d,a)})},initialize:function(){YAHOO.util.History.initialize()}};Array.from=function(a){if(!a)return[];if(a.toArray)return a.toArray();var b=a.length,results=new Array(b);while(b--)results[b]=a[b];return results};Function.prototype.bind=function(){if(arguments.length<2&&arguments[0]===undefined)return this;var a=this,args=Array.from(arguments),object=args.shift();return function(){return a.apply(object,args.concat(Array.from(arguments)))}};Function.prototype.wrap=function(a){var b=this;return function(){return a.apply(this,[b.bind(this)].concat(Array.from(arguments)))}};Function.prototype.functionize=function(){if(this._functionized)return this._functionized;var b=this;return this._functionized=function(){var a=Array.from(arguments);return b.apply(a.shift(),a)}};String.prototype.capitalizeFirst=function(){return this.toLowerCase().replace(/^([^a-z]*?)([a-z])/ig,function(a,b,c){return b+c.toUpperCase()})};YAHOO.widget.Button.prototype.RADIO_CHECKED_TITLE='Selected option';YAHOO.widget.Button.prototype.RADIO_DEFAULT_TITLE='Click to select';var MouseTracker={responders:[],pointerX:null,pointerY:null,fireResponders:function(e){var a=YAHOO.util.Event.getXY(e);MouseTracker.pointerX=a[0];MouseTracker.pointerY=a[1];for(var i=0,n=MouseTracker.responders.length;i<n;i++)MouseTracker.responders[i]({x:a[0],y:a[1]})},subscribe:function(a,b){if(a instanceof Function)this.responders.push(b?a.bind(b):a)},on:function(d,e,f,g){if(!/^(?:entering|leaving)$/.test(d))throw new TypeError('Movement is not recognised');var h=(e instanceof YAHOO.util.Region);var i=h?e:null;var e=h?null:e;var j=false;this.subscribe(function(a){var b=i||YAHOO.util.Dom.getRegion(e);var c=this.isInside(b);if(d=='entering'&&!j&&c)f.call(g||null,this.position);if(d=='leaving'&&j&&!c)f.call(g||null,this.position);j=c},this)},isInside:function(a){if(!a)return undefined;var b={left:this.pointerX,top:this.pointerY};return b.left>=a.left&&b.left<=a.right&&b.top>=a.top&&b.top<=a.bottom}};YAHOO.util.Event.addListener(document,'mousemove',MouseTracker.fireResponders);
