/*--------------------------------------------------------------------------*
 * 
 * Copyright (C) 2008 Brand Labs LLC
 * 
 * Product Detail Zoom (Whitney)
 * 
 * Version 1.1.1
 * 
 *--------------------------------------------------------------------------*/
var WhitneyZoom={MAIN_PHOTO_ID:'product_photo',ZOOM_RATIO:3.0,VIEW_PORT_WIDTH:300,VIEW_PORT_HEIGHT:300,USE_QUICK_PREVIEW:false,ALTERNATE_PHOTO_ID_TEMPLATE:new Template('alternate_product_photo_#{photoIndex}'),NO_PHOTO_FILE_NAME:'nophoto.gif',MAIN_PHOTO_ANCHOR:'product_photo_zoom_url',OVERLAY_OPACITY:0.5,body:null,mainPhotoElement:null,mainPhotoWidth:null,mainPhotoHeight:null,mainPhotoLeft:null,mainPhotoRight:null,overlayElement:null,viewPortElement:null,viewPortElementImage:null,zoomedPhotoElement:null,zoomedPhotoElementImage:null,zoomedPhotoIFrame:null,initialize:function(){var aa;if(!WhitneyZoom.isProductDetailPage()){return;}
try{WhitneyZoom.body=$$('body').first();WhitneyZoom.mainPhotoElement=$(WhitneyZoom.MAIN_PHOTO_ID);}
catch(e){return;}
if(WhitneyZoom.mainPhotoElement==null||WhitneyZoom.body==null){return;}
aa=WhitneyZoom.mainPhotoElement.src;if(aa==null||aa.indexOf(WhitneyZoom.NO_PHOTO_FILE_NAME)!=-1){return;}
if(WhitneyZoom.USE_QUICK_PREVIEW){WhitneyZoom.setupQuickPreview();}
Event.observe(WhitneyZoom.mainPhotoElement,'mouseover',WhitneyZoom.entered);},setupQuickPreview:function(){var ba=2;var ca=null;var da=new Array();var ea;var fa;var ga=true;if(!WhitneyZoom.USE_QUICK_PREVIEW){return;}
try{ca=$(WhitneyZoom.ALTERNATE_PHOTO_ID_TEMPLATE.evaluate({photoIndex:ba}));if(ca==null||!ca.getWidth||!ca.getHeight){return;}
ea=ca.getWidth();fa=ca.getHeight();while($(WhitneyZoom.ALTERNATE_PHOTO_ID_TEMPLATE.evaluate({photoIndex:ba}))!=null){ca=$(WhitneyZoom.ALTERNATE_PHOTO_ID_TEMPLATE.evaluate({photoIndex:ba}));da.push(ca);if(ca.getWidth()!=ea||ca.getHeight()!=fa){ga=false;}
ba++;}
for(var ha=0,len=da.length;ha<len;++ha){if(ga){new WhitneyMainImageQuickPreview((ha+2),da[ha],WhitneyZoom.mainPhotoElement);}
else{new WhitneyQuickPreview((ha+2),da[ha]);}}}
catch(e){}},isProductDetailPage:function(){return Try.these(function(){return global_Current_ProductCode!='';})||false;},move:function(ia){var x=Event.pointerX(ia);var y=Event.pointerY(ia);if(WhitneyZoom.mainPhotoElement==null){return;}
if(x<WhitneyZoom.mainPhotoLeft){WhitneyZoom.exited(ia);return;}
if(x>(WhitneyZoom.mainPhotoLeft+WhitneyZoom.mainPhotoWidth)){WhitneyZoom.exited(ia);return;}
if(y<WhitneyZoom.mainPhotoTop){WhitneyZoom.exited(ia);return;}
if(y>(WhitneyZoom.mainPhotoTop+WhitneyZoom.mainPhotoHeight)){WhitneyZoom.exited(ia);return;}
WhitneyZoom.moveViewPort(x,y);WhitneyZoom.moveZoomedPhoto(x,y);},moveViewPort:function(x,y){var ja=WhitneyZoom.viewPortElement;var ka=WhitneyZoom.viewPortElementImage;var la;var ma;var na;var oa;var pa;var qa;if(ja==null||ka==null){return;}
la=ja.getWidth();ma=ja.getHeight();na=la/2;oa=ma/2;pa=x;qa=y;if(WhitneyZoom.mainPhotoLeft>(x-na)){pa=WhitneyZoom.mainPhotoLeft+na;}
if((WhitneyZoom.mainPhotoLeft+WhitneyZoom.mainPhotoWidth)<(x+na)){pa=WhitneyZoom.mainPhotoLeft+WhitneyZoom.mainPhotoWidth-na;}
if(WhitneyZoom.mainPhotoTop>(y-oa)){qa=WhitneyZoom.mainPhotoTop+oa;}
if((WhitneyZoom.mainPhotoTop+WhitneyZoom.mainPhotoHeight)<(y+oa)){qa=WhitneyZoom.mainPhotoTop+WhitneyZoom.mainPhotoHeight-oa;}
ja.setStyle({left:pa-na+'px',top:qa-oa+'px'});ka.setStyle({marginLeft:-(pa-WhitneyZoom.mainPhotoLeft)+na-1+'px',marginTop:-(qa-WhitneyZoom.mainPhotoTop)+oa-1+'px'});},moveZoomedPhoto:function(x,y){var ra=WhitneyZoom.zoomedPhotoElement;var sa=WhitneyZoom.zoomedPhotoElementImage;var ta;var ua;var va;var wa;var xa;var ya;if(ra==null||sa==null){return;}
ta=ra.getWidth();ua=ra.getHeight();xa=ta/2;ya=ua/2;va=WhitneyZoom.mainPhotoWidth*WhitneyZoom.ZOOM_RATIO;wa=WhitneyZoom.mainPhotoHeight*WhitneyZoom.ZOOM_RATIO;var za=-((x-WhitneyZoom.mainPhotoLeft)*WhitneyZoom.ZOOM_RATIO)+xa;var Aa=-((y-WhitneyZoom.mainPhotoTop)*WhitneyZoom.ZOOM_RATIO)+ya;if(za>0){za=0;}
else if(za<(ta-va)){za=ta-va;}
if(Aa>0){Aa=0;}
else if(Aa<(ua-wa)){Aa=ua-wa;}
sa.setStyle({marginLeft:za+'px',marginTop:Aa+'px'});},entered:function(Ba){var Ca=null;var x;var y;try{x=Event.pointerX(Ba);y=Event.pointerY(Ba);if(WhitneyZoom.mainPhotoElement==null){return;}
Ca=WhitneyZoom.mainPhotoElement.positionedOffset();WhitneyZoom.mainPhotoLeft=Ca.left;WhitneyZoom.mainPhotoTop=Ca.top;WhitneyZoom.mainPhotoWidth=WhitneyZoom.mainPhotoElement.getWidth();WhitneyZoom.mainPhotoHeight=WhitneyZoom.mainPhotoElement.getHeight();WhitneyZoom.createOverlay();WhitneyZoom.createViewPort(x,y);WhitneyZoom.createZoomedPhoto(x,y);}
catch(e){return;}
Event.observe(WhitneyZoom.body,'mousemove',WhitneyZoom.move);Event.observe(WhitneyZoom.viewPortElement,'click',function(){var Da=$(WhitneyZoom.MAIN_PHOTO_ANCHOR);if(Da==null){return;}
window.location.href=Da.href;});},exited:function(Ea){var x=Event.pointerX(Ea);var y=Event.pointerY(Ea);WhitneyZoom.removeZoomedPhoto();WhitneyZoom.removeViewPort();WhitneyZoom.removeOverlay();Event.stopObserving(WhitneyZoom.body,'mousemove',WhitneyZoom.move);},createOverlay:function(){var Fa=null;Fa=$('whitney_overlay_id');if(Fa!=null){WhitneyZoom.overlayElement=Fa;return;}
Fa=new Element('div',{id:'whitney_overlay_id','style':'display: none;'});Fa.addClassName('whitney_overlay_class');WhitneyZoom.overlayElement=Fa;Fa.setStyle({position:'absolute',width:WhitneyZoom.mainPhotoWidth+'px',height:WhitneyZoom.mainPhotoHeight+'px',left:WhitneyZoom.mainPhotoLeft+'px',top:WhitneyZoom.mainPhotoTop+'px',overflow:'hidden',zIndex:100,opacity:WhitneyZoom.OVERLAY_OPACITY});WhitneyZoom.body.insert(Fa);Fa.show();},removeOverlay:function(){if(WhitneyZoom.overlayElement==null){return;}
WhitneyZoom.overlayElement.hide();WhitneyZoom.overlayElement.remove();WhitneyZoom.overlayElement=null;},createViewPort:function(x,y){var Ga=null;var Ha=null;var Ia;var Ja;Ga=$('whitney_view_port_id');Ha=$('whitney_view_port_image_id');if(Ga!=null){WhitneyZoom.viewPortElement=Ga;WhitneyZoom.viewPortElementImage=Ha;return;}
Ia=WhitneyZoom.VIEW_PORT_WIDTH/WhitneyZoom.ZOOM_RATIO;Ja=WhitneyZoom.VIEW_PORT_HEIGHT/WhitneyZoom.ZOOM_RATIO;Ga=new Element('div',{id:'whitney_view_port_id','style':'display: none;'});WhitneyZoom.viewPortElement=Ga;Ha=new Element('img',{id:'whitney_view_port_image_id',src:WhitneyZoom.mainPhotoElement.src,alt:WhitneyZoom.mainPhotoElement.alt,title:WhitneyZoom.mainPhotoElement.title});WhitneyZoom.viewPortElementImage=Ha;Ga.addClassName('whitney_view_port_class');Ga.setStyle({position:'absolute',width:Ia+'px',height:Ja+'px',overflow:'hidden',zIndex:101,backgroundColor:'transparent'});Ha.addClassName('whitney_view_port_image_class');Ga.update(Ha);WhitneyZoom.body.insert(Ga);WhitneyZoom.moveViewPort(x,y);Ga.show();},removeViewPort:function(){if(WhitneyZoom.viewPortElement==null){return;}
WhitneyZoom.viewPortElement.hide();WhitneyZoom.viewPortElement.remove();WhitneyZoom.viewPortElement=null;WhitneyZoom.viewPortElementImage=null;},createZoomedPhoto:function(x,y){var Ka=null;var La=null;var Ma=null;Ka=$('whitney_zoomed_photo_id');La=$('whitney_view_port_image_id');if(Prototype.Browser.IE){Ma=$('whitney_zoomed_photo_iframe_id');}
if(Ka!=null){WhitneyZoom.zoomedPhotoElement=Ka;WhitneyZoom.zoomedPhotoElementImage=La;if(Prototype.Browser.IE){WhitneyZoom.zoomedPhotoIFrame=Ma;}
return;}
Ka=new Element('div',{id:'whitney_zoomed_photo_id','style':'display: block;'});WhitneyZoom.zoomedPhotoElement=Ka;Ka.addClassName('whitney_zoomed_photo_class');La=new Element('img',{id:'whitney_zoomed_photo_image_id',src:WhitneyZoom.getLargePhotoFileName(),alt:WhitneyZoom.mainPhotoElement.alt,title:WhitneyZoom.mainPhotoElement.title,width:(WhitneyZoom.mainPhotoWidth*WhitneyZoom.ZOOM_RATIO)+'px',height:(WhitneyZoom.mainPhotoHeight*WhitneyZoom.ZOOM_RATIO)+'px'});La.addClassName('whitney_zoomed_photo_image_class');La.setStyle({width:(WhitneyZoom.mainPhotoWidth*WhitneyZoom.ZOOM_RATIO)+'px',height:(WhitneyZoom.mainPhotoHeight*WhitneyZoom.ZOOM_RATIO)+'px'});WhitneyZoom.zoomedPhotoElementImage=La;Ka.setStyle({position:'absolute',width:WhitneyZoom.VIEW_PORT_WIDTH+'px',height:WhitneyZoom.VIEW_PORT_WIDTH+'px',top:WhitneyZoom.mainPhotoTop+'px',left:(WhitneyZoom.mainPhotoLeft+WhitneyZoom.mainPhotoWidth)+'px',overflow:'hidden',zIndex:102,opacity:0.0});Ka.update(La);if(Prototype.Browser.IE){Ma=new Element('iframe',{id:'whitney_zoomed_photo_iframe_id','style':'display: none;',scrolling:'no',src:'javascript:\'<html><body></body></html>\';',frameborder:'0'});WhitneyZoom.zoomedPhotoIFrame=Ma;Ma.addClassName('whitney_zoomed_photo_class');Ma.setStyle({position:'absolute',width:WhitneyZoom.VIEW_PORT_WIDTH+'px',height:WhitneyZoom.VIEW_PORT_WIDTH+'px',top:WhitneyZoom.mainPhotoTop+'px',left:(WhitneyZoom.mainPhotoLeft+WhitneyZoom.mainPhotoWidth)+'px',marginWidth:'0px',marginHeight:'0px',paddingWidth:'0px',paddingHeight:'0px',overflow:'hidden',zIndex:101,display:'none','float':'left',filter:'alpha(opacity=0)'});WhitneyZoom.body.insert(Ma);Ma.show();}
WhitneyZoom.body.insert(Ka);WhitneyZoom.moveZoomedPhoto(x,y);Effect.Appear(Ka,{queue:'end',duration:0.4});},removeZoomedPhoto:function(){if(WhitneyZoom.zoomedPhotoElement==null){return;}
WhitneyZoom.zoomedPhotoElement.hide();WhitneyZoom.zoomedPhotoElement.remove();WhitneyZoom.zoomedPhotoElement=null;WhitneyZoom.zoomedPhotoElementImage=null;if(Prototype.Browser.IE){WhitneyZoom.zoomedPhotoIFrame.hide();WhitneyZoom.zoomedPhotoIFrame.remove();WhitneyZoom.zoomedPhotoIFrame=null;}},getLargePhotoFileName:function(){var Na;var Oa;if(previous_selected_photo==null||previous_selected_photo==''){Oa=2;}
else{Oa=previous_selected_photo;}
Na=WhitneyZoom.getPhotosPath()+"/"+WhitneyZoom.getProductCode()+"-"+Oa+'.jpg';return Na;},getProductCode:function(){return global_URL_Encode_Current_ProductCode;},getPhotosPath:function(){return global_Config_StoreFolderName+global_Config_ProductPhotosFolder;}};var WhitneyQuickPreview=Class.create({initialize:function(Pa,Qa){var Ra;var Sa;try{Ra=$$('body').first();}
catch(e){}
if(Ra==null){return;}
if(Qa==null){return;}
this.alternateElement=Qa;this.photoNumber=Pa;this.thumbnailElement=new Element('div',{id:'whitney_quick_preview_'+Pa});this.thumbnailElement.addClassName('whitney_quick_preview');this.thumbnailElement.setStyle({position:'absolute',display:'none',zIndex:102});Sa=new Element('img',{src:this.getThumbnailFileName(),alt:this.alternateElement.alt,title:this.alternateElement.title});this.thumbnailElement.update(Sa);Ra.insert(this.thumbnailElement);Event.observe(Qa,'mouseover',this.mouseOver.bindAsEventListener(this));Event.observe(Qa,'mouseout',this.mouseOut.bindAsEventListener(this));},mouseOver:function(){var Ta;if(this.alternateElement==null||this.thumbnailElement==null){return;}
Ta=this.alternateElement.positionedOffset();this.thumbnailElement.setStyle({top:Ta.top+'px',left:(Ta.left+this.alternateElement.getWidth())+'px'});this.showElement(this.thumbnailElement);},mouseOut:function(){if(this.thumbnailElement==null){return;}
this.hideElement(this.thumbnailElement);},getThumbnailFileName:function(){var Ua;Ua=WhitneyZoom.getPhotosPath()+"/"+WhitneyZoom.getProductCode()+"-"+this.photoNumber+'T'+'.jpg';return Ua;},showElement:function(Va){Va.show();},hideElement:function(Wa){Wa.hide();}});var WhitneyMainImageQuickPreview=Class.create(WhitneyQuickPreview,{initialize:function(Xa,Ya,Za){if(Za==null||Ya==null){return;}
this.photoNumber=Xa;this.mainElement=Za;this.originalFileName=Za.src;Event.observe(Ya,'mouseover',this.mouseOver.bindAsEventListener(this));Event.observe(Ya,'mouseout',this.mouseOut.bindAsEventListener(this));Event.observe(Ya,'click',this.click.bindAsEventListener(this));},mouseOver:function(){if(this.mainElement==null){return;}
this.originalFileName=this.mainElement.src;this.mainElement.src=this.getThumbnailFileName();},mouseOut:function(){if(this.mainElement==null){return;}
this.mainElement.src=this.originalFileName;},click:function(){this.originalFileName=this.getThumbnailFileName();}});if(location.pathname.toLowerCase()=='/productdetails.asp'||location.pathname.toLowerCase().indexOf('-p/')!=-1||location.pathname.toLowerCase().indexOf('_p/')!=-1){Event.observe(window,'load',WhitneyZoom.initialize);}