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];}};Prozoom=function(selector,options){var settings={zoomType:'standard',zoomWidth:200,zoomHeight:200,xOffset:10,yOffset:0,position:'right',lens:true,lensReset:false,lensCursor:'crosshair',lensOpacity:0.5,imageOpacity:0.2,title:true,alwaysOn:false,showEffect:'fade',hideEffect:'fade',showSpeed:0.3,hideSpeed:0.3,preloadImages:true,showPreload:true,errorMsg:'Large image cannot be loaded',preloadText:'Loading zoom'};options=options||{};Object.extend(settings,options);return $$(selector).each(function(el){var a=el;var img=$(a).select('img')[0];var smallimage=new Smallimage(img);var smallimagedata={};var btop=0;var bleft=0;var loader=null;loader=new Loader();var informer=null;informer=new Informer();var ZoomTitle='';var ZoomTitleObj=new zoomTitle();var largeimage=[];largeimage[a.href]=new Largeimage(a.href);var lens=new Lens();var lensdata={};var largeimageloaded=[];var smallimageloaded=false;var scale={};var stage=[];var running=false;var mousepos={};var firstime=0;var preloadshow=false;smallimage.loadimage();$(a).observe('click',showLargeImage);$(a).hover(function(e){mousepos.x=e.pageX;mousepos.y=e.pageY;activate();},function(){deactivate();});$$('a.prozoom-small-image').each(function(el){Event.observe(el,'click',switchProductImage);});function activate()
{if(!running){smallimage.findborder();running=true;imageTitle=img.title;$(img).removeAttribute('title');aTitle=a.title;$(a).removeAttribute('title');ZoomTitle=(trim(aTitle).length>0)?aTitle:(trim(imageTitle).length>0)?imageTitle:null;ZoomTitleObj.updateTitle();if(!largeimage[a.href]){largeimage[a.href]=new Largeimage(a.href);}
if(!largeimageloaded[a.href]){largeimage[a.href].loadimage();return false;}
if(settings.zoomType!='innerzoom'){stage[a.href]=new Stage();stage[a.href].activate();}
lens.activate();$(a).blur();return false;}}
function deactivate()
{if(settings.zoomType=='reverse'&&!settings.alwaysOn){img.setOpacity(1);}
if(!settings.alwaysOn){running=false;$(lens.node).stopObserving('mousemove');lens.remove();if(settings.zoomType!='innerzoom'&&stage[a.href]){stage[a.href].remove();}
ZoomTitleObj.remove();img.writeAttribute('title',imageTitle);a.writeAttribute('title',aTitle);a.stopObserving('mousemove');firstime=0;if($$('.zoom_ieframe').length>0){$$('.zoom_ieframe').invoke('remove');}}else{if(settings.lensReset){switch(settings.zoomType){case'innerzoom':largeimage[a.href].setcenter();break;default:lens.center();break;}}}};function showLargeImage(e)
{e.stop();var link=e.element();while(link.tagName!='A'){link=link.up();}
if(!largeimageloaded[link.href]||$('largeimage')){return false;}
var largeimage=new Element('div',{'id':'largeimage'});document.body.appendChild(largeimage);var image=new Image();image.onload=function(){$(largeimage).setStyle({left:document.viewport.getWidth()/2-image.width/2+'px',top:document.viewport.getScrollOffsets().top+50+'px'});$(largeimage).setOpacity(0);new Effect.Fade($(largeimage),{duration:0.5,from:0,to:1});Event.observe($(largeimage),'click',$(largeimage).remove);}
image.src=link.href;largeimage.innerHTML='<img src="'+link.href+'" />';}
function switchProductImage(e)
{e.stop();loader.hide();informer.hide();var link=e.element();while(link.tagName!='A'){link=link.up();}
$('image').src=link.down('img.small-image').src;$$('.more-views-list li').invoke('removeClassName','active');link.up().addClassName('active');a.writeAttribute('href',link.href);a.writeAttribute('title',link.title);img.writeAttribute('title',link.down('img.small-image').title);if(settings.alwaysOn&&!largeimage[link.href]){largeimage[link.href]=new Largeimage(link.href);largeimage[link.href].loadimage();}
if(settings.zoomType=='innerzoom'&&settings.alwaysOn){function activateLens(){if(!largeimageloaded[link.href]){setTimeout(activateLens,150);}else{lens.activate();}}
activateLens();}else if(settings.alwaysOn){lens.activate();if(stage[a.href]){stage[a.href].activate();}}}
function Smallimage(image){this.node=image;this.loadimage=function(){this.node.src=image.src;};this.findborder=function(){var bordertop='';bordertop=$(img).getStyle('border-top-width');btop='';var borderleft='';borderleft=$(img).getStyle('border-left-width');bleft='';if(Prototype.Browser.IE){var temp=bordertop.split(' ');bordertop=temp[1];var temp=borderleft.split(' ');borderleft=temp[1];}
if(bordertop){for(i=0;i<3;i++){var x=[];x=bordertop.substr(i,1);if(isNaN(x)==false){btop=btop+''+bordertop.substr(i,1);}
else{break;}}}
if(borderleft){for(i=0;i<3;i++){if(!isNaN(borderleft.substr(i,1))){bleft=bleft+borderleft.substr(i,1)}
else{break;}}}
btop=(btop.length>0)?eval(btop):0;bleft=(bleft.length>0)?eval(bleft):0;}
this.node.onload=function(){a.setStyle({'cursor':settings.lensCursor,'display':'block'});if(a.getStyle('position')!='absolute'&&a.up().getStyle('position')){a.setStyle({'cursor':settings.lensCursor,'position':'relative','display':'block'});}
if(a.up().getStyle('position')!='absolute'){a.up().setStyle({'position':'relative'});}
if(Prototype.Browser.Webkit||Prototype.Browser.Opera){$(img).setStyle({position:'absolute',top:'0px',left:'0px'});}
smallimagedata.w=$(this).getWidth();smallimagedata.h=$(this).getHeight();smallimagedata.pos=$(this).viewportOffset();smallimagedata.pos.l=$(this).viewportOffset().left;smallimagedata.pos.t=$(this).viewportOffset().top+document.viewport.getScrollOffsets().top;smallimagedata.pos.r=smallimagedata.w+smallimagedata.pos.l;smallimagedata.pos.b=smallimagedata.h+smallimagedata.pos.t;$(a).setStyle({'height':smallimagedata.h+'px','width':smallimagedata.w+'px'});smallimageloaded=true;if(settings.alwaysOn){activate();}
if(settings.preloadImages){largeimage[a.href].loadimage();}};return this;};function Lens(){this.node=new Element('div',{'class':'zoom-lens'});this.node.addClassName('zoom-lens');this.loadlens=function(){switch(settings.zoomType){case'reverse':this.image=new Image();this.image.src=smallimage.node.src;this.node.childElements().invoke('remove');this.node.appendChild(this.image);$(this.node).setOpacity(1);break;case'innerzoom':this.image=new Image();this.image.src=largeimage[a.href].node.src;this.node.childElements().invoke('remove');this.node.appendChild(this.image);$(this.node).setOpacity(1);break
default:$(this.node).setOpacity(settings.lensOpacity);break;}
switch(settings.zoomType){case'innerzoom':lensdata.w=smallimagedata.w;lensdata.h=smallimagedata.h;break;default:lensdata.w=(settings.zoomWidth)/scale.x;lensdata.h=(settings.zoomHeight)/scale.y;break;}
$(this.node).setStyle({'width':lensdata.w+'px','height':lensdata.h+'px','display':'none'});a.insert({'top':this.node});}
return this;};Lens.prototype.activate=function(){this.loadlens();switch(settings.zoomType){case'reverse':img.setOpacity(settings.imageOpacity);(settings.alwaysOn)?lens.center():lens.setposition(null);$(a).observe('mousemove',function(e){mousepos.x=e.pageX;mousepos.y=e.pageY;lens.setposition(e);});break;case'innerzoom':$(this.node).setStyle({top:0+'px',left:0+'px'}).show();if(settings.title){ZoomTitleObj.loadtitle();}
largeimage[a.href].setcenter();$(a).observe('mousemove',function(e){mousepos.x=e.pageX;mousepos.y=e.pageY;largeimage[a.href].setinner(e);});break;default:(settings.alwaysOn)?lens.center():lens.setposition(null);$(a).observe('mousemove',function(e){mousepos.x=e.pageX;mousepos.y=e.pageY;lens.setposition(e);});break;}
return this;};Lens.prototype.setposition=function(e){if(e){mousepos.x=e.pageX;mousepos.y=e.pageY;}
if(firstime==0){var lensleft=(smallimagedata.w)/2-(lensdata.w)/2;var lenstop=(smallimagedata.h)/2-(lensdata.h)/2;this.node.show();if(settings.lens){this.node.style.visibility='visible';}else{this.node.style.visibility='hidden';this.node.hide();}
firstime=1;}else{var lensleft=mousepos.x-smallimagedata.pos.l-(lensdata.w)/2;var lenstop=mousepos.y-smallimagedata.pos.t-(lensdata.h)/2;}
if(overleft()){lensleft=0+bleft;}else if(overright()){if(Prototype.Browser.IE){lensleft=smallimagedata.w-lensdata.w+bleft+1;}else{lensleft=smallimagedata.w-lensdata.w+bleft-1;}}
if(overtop()){lenstop=0+btop;}else if(overbottom()){if(Prototype.Browser.IE){lenstop=smallimagedata.h-lensdata.h+btop+1;}else{lenstop=smallimagedata.h-lensdata.h-1+btop;}}
lensleft=parseInt(lensleft);lenstop=parseInt(lenstop);this.node.setStyle({top:lenstop+'px',left:lensleft+'px'});if(settings.zoomType=='reverse'){this.image.style.position='absolute';this.image.style.left=-(lensleft-bleft+1)+'px';this.image.style.top=-(lenstop-btop+1)+'px';}
largeimage[a.href].setposition();function overleft(){return mousepos.x-(lensdata.w+2*1)/2-bleft<smallimagedata.pos.l;}
function overright(){return mousepos.x+(lensdata.w+2*1)/2>smallimagedata.pos.r+bleft;}
function overtop(){return mousepos.y-(lensdata.h+2*1)/2-btop<smallimagedata.pos.t;}
function overbottom(){return mousepos.y+(lensdata.h+2*1)/2>smallimagedata.pos.b+btop;}
return this;};Lens.prototype.center=function(){this.node.hide();var lensleft=(smallimagedata.w)/2-(lensdata.w)/2;var lenstop=(smallimagedata.h)/2-(lensdata.h)/2;this.node.setStyle({'top':lenstop+'px','left':lensleft+'px'});if(settings.zoomType=='reverse'){this.image.setStyle({'position':'absolute','top':-(lenstop-btop+1)+'px','left':-(lensleft-bleft+1)+'px'});}
largeimage[a.href].setposition();if(Prototype.Browser.IE){this.node.show();}else{this.node.setOpacity(0).show();Effect.Fade(this.node,{duration:0.2,from:0,to:(settings.zoomType=='reverse')?1:settings.lensOpacity});}};Lens.prototype.getoffset=function(){var o={};o.left=parseInt(this.node.style.left);o.top=parseInt(this.node.style.top);return o;};Lens.prototype.remove=function(){if(!this.node.parentNode){return false;}
if(settings.zoomType=='innerzoom'){Effect.Fade(this.node,{duration:0.2,from:1,to:0,afterFinish:function(){this.node.remove();}.bind(this)});}else{this.node.remove();}};function Largeimage(url){this.url=url;this.node=new Image();this.loadimage=function(){if(!this.node){this.node=new Image();}
this.node.style.position='absolute';this.node.style.display='none';this.node.style.left='-5000px';this.node.style.top='10px';if(!loader){loader=new Loader();}
if(settings.showPreload&&!preloadshow){loader.show();}
document.body.appendChild(this.node);this.node.src=this.url;}
this.node.onload=function(){this.style.display='block';var w=Math.round($(this).getWidth());var h=Math.round($(this).getHeight());this.style.display='none';scale.x=(w/smallimagedata.w);scale.y=(h/smallimagedata.h);if(settings.zoomType!='innerzoom'&&running&&!stage[a.href]){stage[a.href]=new Stage();stage[a.href].activate();}
if(running){lens.activate();}
loader.hide();largeimageloaded[a.href]=true;}
this.node.onerror=function(){loader.hide();informer.show();informer.node.update(settings.errorMsg);}
return this;}
Largeimage.prototype.setposition=function(){this.node.style.left=Math.ceil(-scale.x*parseInt(lens.getoffset().left)+bleft)+'px';this.node.style.top=Math.ceil(-scale.y*parseInt(lens.getoffset().top)+btop)+'px';};Largeimage.prototype.setinner=function(e){var left=Math.ceil(-scale.x*Math.abs(e.pageX-smallimagedata.pos.l));if(Math.abs(left)>(this.node.width-smallimagedata.w)){left=-(this.node.width-smallimagedata.w);}
var top=Math.ceil(-scale.y*Math.abs(e.pageY-smallimagedata.pos.t));if(Math.abs(top)>(this.node.height-smallimagedata.h)){top=-(this.node.height-smallimagedata.h);}
if(settings.zoomType=='innerzoom'){lens.node.down('img').setStyle({'position':'absolute','top':top+'px','left':left+'px'});}else{this.node.style.left=left+'px';this.node.style.top=top+'px';}};Largeimage.prototype.setcenter=function(){this.node.style.left=Math.ceil(-scale.x*Math.abs((smallimagedata.w)/2))+'px';this.node.style.top=Math.ceil(-scale.y*Math.abs((smallimagedata.h)/2))+'px';if(settings.zoomType=='innerzoom'){lens.node.down('img').setStyle({'position':'absolute','top':this.node.style.top,'left':this.node.style.left});}};function Stage(){var leftpos=smallimagedata.pos.l;var toppos=smallimagedata.pos.t;this.node=new Element('div',{'class':'zoom-window'});this.node.addClassName('zoom-window');$(this.node).setStyle({position:'absolute',width:Math.round(settings.zoomWidth)+'px',height:Math.round(settings.zoomHeight)+'px',display:'none',zIndex:10000,overflow:'hidden'});switch(settings.position){case"right":leftpos=(smallimagedata.pos.r+Math.abs(settings.xOffset)+settings.zoomWidth<screen.width)?(smallimagedata.pos.l+smallimagedata.w+Math.abs(settings.xOffset)):(smallimagedata.pos.l-settings.zoomWidth-Math.abs(settings.xOffset));topwindow=smallimagedata.pos.t+settings.yOffset+settings.zoomHeight;toppos=(topwindow<screen.height&&topwindow>0)?smallimagedata.pos.t+settings.yOffset:smallimagedata.pos.t;break;case"left":leftpos=(smallimagedata.pos.l-Math.abs(settings.xOffset)-settings.zoomWidth>0)?(smallimagedata.pos.l-Math.abs(settings.xOffset)-settings.zoomWidth):(smallimagedata.pos.l+smallimagedata.w+Math.abs(settings.xOffset));topwindow=smallimagedata.pos.t+settings.yOffset+settings.zoomHeight;toppos=(topwindow<screen.height&&topwindow>0)?smallimagedata.pos.t+settings.yOffset:smallimagedata.pos.t;break;case"top":toppos=(smallimagedata.pos.t-Math.abs(settings.yOffset)-settings.zoomHeight>0)?(smallimagedata.pos.t-Math.abs(settings.yOffset)-settings.zoomHeight):(smallimagedata.pos.t+smallimagedata.h+Math.abs(settings.yOffset));leftwindow=smallimagedata.pos.l+settings.xOffset+settings.zoomWidth;leftpos=(leftwindow<screen.width&&leftwindow>0)?smallimagedata.pos.l+settings.xOffset:smallimagedata.pos.l;break;case"bottom":toppos=(smallimagedata.pos.b+Math.abs(settings.yOffset)+settings.zoomHeight<(document.viewport.getHeight()+document.viewport.getScrollOffsets().top))?(smallimagedata.pos.b+Math.abs(settings.yOffset)):(smallimagedata.pos.t-settings.zoomHeight-Math.abs(settings.yOffset));leftwindow=smallimagedata.pos.l+settings.xOffset+settings.zoomWidth;leftpos=(leftwindow<screen.width&&leftwindow>0)?smallimagedata.pos.l+settings.xOffset:smallimagedata.pos.l;break;default:leftpos=(smallimagedata.pos.l+smallimagedata.w+settings.xOffset+settings.zoomWidth<screen.width)?(smallimagedata.pos.l+smallimagedata.w+Math.abs(settings.xOffset)):(smallimagedata.pos.l-settings.zoomWidth-Math.abs(settings.xOffset));toppos=(smallimagedata.pos.b+Math.abs(settings.yOffset)+settings.zoomHeight<screen.height)?(smallimagedata.pos.b+Math.abs(settings.yOffset)):(smallimagedata.pos.t-settings.zoomHeight-Math.abs(settings.yOffset));break;}
this.node.style.left=leftpos+'px';this.node.style.top=toppos+'px';return this;}
Stage.prototype.activate=function(){$$('.zoom-window').invoke('hide');if(!this.node.parentNode){if(!this.node.firstChild){this.node.appendChild(largeimage[a.href].node);}
if(settings.title){ZoomTitleObj.loadtitle();}
document.body.appendChild(this.node);}
switch(settings.showEffect){case'none':$(this.node).show();break;case'fade':$(this.node).setOpacity(0).show();Effect.Fade($(this.node),{from:0,to:1,duration:settings.showSpeed});break;default:$(this.node).show();break;}
if(Prototype.Browser.IE&&parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE")+5))==6){this.ieframe=new Element('iframe',{'class':'zoom_ieframe','frameborder':'0','src':'#'});$(this.ieframe).setStyle({position:'absolute',left:this.node.style.left,top:this.node.style.top,zIndex:99,width:settings.zoomWidth,height:settings.zoomHeight});$(this.node).insert({'before':this.ieframe});};if(settings.alwaysOn&&lens.image){lens.center();}
largeimage[a.href].node.style.display='block';}
Stage.prototype.remove=function(){switch(settings.hideEffect){case'none':this.node.remove();break;case'fade':$(this.node).setOpacity(1);Effect.Fade($(this.node),{from:1,to:0,duration:settings.hideSpeed,afterFinish:function(){this.node.remove();}.bind(this)});break;default:this.node.remove();break;}}
function zoomTitle(){this.node=new Element('div',{'class':'zoom-title'}).update(ZoomTitle);this.node.addClassName('zoom-title');this.loadtitle=function(){if(!ZoomTitle||!ZoomTitle.length){return false;}
if(settings.zoomType=='innerzoom'){$(this.node).setStyle({position:'absolute',top:smallimagedata.pos.b+3,left:(smallimagedata.pos.l+1),width:smallimagedata.w});lens.node.insert({'bottom':this.node});}else{stage[a.href].node.insert({'bottom':this.node});}};this.updateTitle=function(){this.node.update(ZoomTitle);}}
zoomTitle.prototype.remove=function(){if(this.node.parentNode){this.node.remove();}}
function Loader(){this.node=new Element('div',{'class':'spinner'}).setStyle({'visibility':'hidden'}).update(settings.preloadText);this.node.addClassName('spinner');document.body.appendChild(this.node);this.show=function(){preloadshow=true;loadertop=smallimagedata.pos.t+(smallimagedata.h-$(this.node).getHeight())/2;loaderleft=smallimagedata.pos.l+(smallimagedata.w-$(this.node).getWidth())/2;$(this.node).setStyle({top:loadertop+'px',left:loaderleft+'px',position:'absolute',visibility:'visible'});}
this.hide=function(){preloadshow=false;this.node.setStyle({'visibility':'hidden'});}
return this;}
function Informer(){this.node=new Element('div',{'class':'informer'}).setStyle({'visibility':'hidden'});this.node.addClassName('informer');document.body.appendChild(this.node);this.show=function(){informertop=smallimagedata.pos.t+(smallimagedata.h-$(this.node).getHeight())/2;informerleft=smallimagedata.pos.l+(smallimagedata.w-$(this.node).getWidth())/2;$(this.node).setStyle({top:informertop+'px',left:informerleft+'px',position:'absolute',visibility:'visible'});}
this.hide=function(){this.node.setStyle({'visibility':'hidden'});}
return this;}});};function trim(stringa){while(stringa.substring(0,1)==' '){stringa=stringa.substring(1,stringa.length);}
while(stringa.substring(stringa.length-1,stringa.length)==' '){stringa=stringa.substring(0,stringa.length-1);}
return stringa;}
(function(){var withinElement=function(evt,el){var parent=evt.relatedTarget;while(parent&&parent!=el){try{parent=parent.parentNode;}
catch(error){parent=el;}}
return parent==el;};Object.extend(Event,{mouseEnter:function(element,f,options){element=$(element);var fc=(options&&options.enterDelay)?(function(){window.setTimeout(f,options.enterDelay);}):(f);if(Prototype.Browser.IE){element.observe('mouseenter',fc);}
else{element.hovered=false;element.observe('mouseover',function(evt){if(!element.hovered){element.hovered=true;fc(evt);}});}},mouseLeave:function(element,f,options){element=$(element);var fc=(options&&options.leaveDelay)?(function(){window.setTimeout(f,options.leaveDelay);}):(f);if(Prototype.Browser.IE){element.observe('mouseleave',fc);}
else{element.observe('mouseout',function(evt){var target=Event.element(evt);if(!withinElement(evt,element)){fc(evt);element.hovered=false;}});}}});Element.addMethods({'hover':function(element,mouseEnterFunc,mouseLeaveFunc,options){options=Object.extend({},options)||{};Event.mouseEnter(element,mouseEnterFunc,options);Event.mouseLeave(element,mouseLeaveFunc,options);}});})();