// jQuery Sonic Zoom Plugin
//
// Version 1.00
//
// JavaScript Library: jQuery
// 
// Copyright (c) 2009 John Resig, http://jquery.com/
// 
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
// 
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(function($){$.soniczoom={setupCallback:function(data){var zoomer=$.data($(data.id).get(0),"zoomer");if(zoomer==null)return;zoomer.setupCallback(data)},changeImageCallback:function(data){var zoomer=$.data($(data.id).get(0),"zoomer");if(zoomer==null)return;zoomer.changeImageCallback(data)}};$.fn.soniczoom=function(options){var settings={maxZoomLevels:4,zoomPerLevel:2,zIndex:0,grid:100,animationSpeed:320,control:{mousewheel:"fz",contextmenu:"reset",shiftclick:"zoomout",ctrlclick:"swnavi"},requestOption:"",imageDirectory:"images",navigationDisplay:"off",navigationSize:"0.25",navigationImage:"thumbNail",navigationCss:null,dragviewCss:null,startPosition:null,jsonpgis:""};options=options||{};$.extend(settings,options);return this.each(function(){var zoomer=new Zoomer(this,settings)})};$.fn.szZoomin=function(){return this.each(function(){var zoomer=$.data(this,"zoomer");if(zoomer==null)return;zoomer.zoomin()})};$.fn.szZoomout=function(){return this.each(function(){var zoomer=$.data(this,"zoomer");if(zoomer==null)return;zoomer.zoomout()})};$.fn.szReset=function(){return this.each(function(){var zoomer=$.data(this,"zoomer");if(zoomer==null)return;zoomer.reset()})};$.fn.szMoving=function(shiftX,shiftY){return this.each(function(){var zoomer=$.data(this,"zoomer");if(zoomer==null)return;zoomer.moving(shiftX,shiftY)})};$.fn.szMoved=function(){return this.each(function(){var zoomer=$.data(this,"zoomer");if(zoomer==null)return;zoomer.moved()})};$.fn.szMoveToPosition=function(position){return this.each(function(){var zoomer=$.data(this,"zoomer");if(zoomer==null)return;zoomer.moveToPosition(position)})};$.fn.szSwitchNavigation=function(){return this.each(function(){var zoomer=$.data(this,"zoomer");if(zoomer==null)return;zoomer.switchNavigation()})};$.fn.szVisibleNavigation=function(){return this.each(function(){var zoomer=$.data(this,"zoomer");if(zoomer==null)return;zoomer.visibleNavigation()})};$.fn.szHiddenNavigation=function(){return this.each(function(){var zoomer=$.data(this,"zoomer");if(zoomer==null)return;zoomer.hiddenNavigation()})};$.fn.szChangeImage=function(path,action,args){return this.each(function(){var zoomer=$.data(this,"zoomer");if(zoomer==null)return;zoomer.changeImage(path,action,args)})};$.fn.szChangeSize=function(size){return this.each(function(){var zoomer=$.data(this,"zoomer");if(zoomer==null)return;zoomer.changeSize(size)})};$.fn.szAppendOverlap=function(content){return this.each(function(){var zoomer=$.data(this,"zoomer");if(zoomer==null)return;zoomer.appendOverlap(content)})};$.fn.szRemoveOverlap=function(){return this.each(function(){var zoomer=$.data(this,"zoomer");if(zoomer==null)return;zoomer.removeOverlap()})};Zoomer.PREFIX="sz_";Zoomer.MAX_ANIMATION_FRAME=8;Zoomer.UPDATE_FADEIN="normal";Zoomer.MAX_ZOOM_WAIT=1e4;Zoomer.MAX_LOAD_WAIT=1e4;Zoomer.UPDATE_CHECK_TIME=100;Zoomer.EVENT_IMAGE_INFO="sz_image_info";Zoomer.EVENT_MAX_ZOOM_LEVELS="sz_max_zoom_levels";Zoomer.EVENT_UPDATE_ZOOM="sz_update_zoom";Zoomer.EVENT_ZOOMIN="sz_zoomin";Zoomer.EVENT_ZOOMOUT="sz_zoomout";Zoomer.EVENT_RESET="sz_reset";Zoomer.EVENT_MOVING="sz_moving";Zoomer.EVENT_MOVED="sz_moved";Zoomer.EVENT_NAVIGATION_ZOOMIN="sz_navigation_zoomin";Zoomer.EVENT_NAVIGATION_MOVING="sz_navigation_moving";Zoomer.EVENT_NAVIGATION_MOVED="sz_navigation_moved";Zoomer.counter=0;function Zoomer(fullZoomImage,settings){var src=$(fullZoomImage).attr("src"),index=src.indexOf("?");if(index==-1)return;var image=src.substring(0,index),params=src.substring(index+1);index=params.indexOf("is=");if(index==-1)return;var isParams=params.substring(index+3).split(",");if(isParams.length!=3)return;index=image.toLowerCase().lastIndexOf("/mgen");this.mrl=image.substring(0,index+6);this.path=image.substring(index+6);this.zoomImage=image;this.zoomWidth=eval(isParams[0]);this.zoomHeight=eval(isParams[1]);this.padColor=isParams[2];this.maxZoomLevels=settings.maxZoomLevels;this.zoomPerLevel=settings.zoomPerLevel;this.zIndex=settings.zIndex;this.grid=settings.grid;this.animationUpdataTime=Math.floor(settings.animationSpeed/Zoomer.MAX_ANIMATION_FRAME);this.control=settings.control;this.requestOption=settings.requestOption;this.imageDirectory=settings.imageDirectory;this.navigationDisplay=settings.navigationDisplay;this.navigationSize=settings.navigationSize;this.navigationImage=settings.navigationImage;this.navigationCss=settings.navigationCss;this.dragviewCss=settings.dragviewCss;this.startPosition=settings.startPosition;this.jsonpgis=settings.jsonpgis;var id=$(fullZoomImage).attr("id");if(id==null||id==""){id=$(fullZoomImage).attr("class");if(id==null||id=="")id=Zoomer.PREFIX+id+"_"+Zoomer.counter++;else id=Zoomer.PREFIX+id+"_"+$.inArray(fullZoomImage,$("."+id));$(fullZoomImage).attr("id",id)}this.id="#"+id;if(this.requestOption!="")this.requestOption="&"+this.requestOption;this.currentPreviewPosition={};this.currentPreviewPosition.x=0;this.currentPreviewPosition.y=0;this.currentPreviewPosition.zoomLevel=0;this.newPosition={};this.newPosition.x=0;this.newPosition.y=0;this.newPosition.zoomLevel=0;this.changePosition={};this.changePosition.x=0;this.changePosition.y=0;this.changePosition.zoomLevel=0;this.image={};this.image.width=-1;this.image.height=-1;this.image.scale=1;this.image.adjWidth=0;this.image.adjHeight=0;this.image.padWidth=0;this.image.padHeight=0;this.trueZoomAdjuster={};this.trueZoomAdjuster.x=0;this.trueZoomAdjuster.y=0;this.trueZoomPadding={};this.trueZoomPadding.left=0;this.trueZoomPadding.top=0;this.trueZoomPadding.right=0;this.trueZoomPadding.bottom=0;var container=document.createElement("div");$(container).css({margin:"0",padding:"0",overflow:"visible",left:"0",top:"0",zIndex:this.zIndex,borderStyle:"none",position:"relative"});$(container).width(this.zoomWidth).height(this.zoomHeight);var frame=document.createElement("div");$(frame).css({margin:"0",padding:"0",overflow:"hidden",left:"0",top:"0",zIndex:this.zIndex,borderStyle:"none",position:"absolute"});$(frame).width(this.zoomWidth).height(this.zoomHeight);$(frame).css("cursor","crosshair");var previewZoom=document.createElement("div");$(previewZoom).css({margin:"0",padding:"0",overflow:"hidden",left:"0",top:"0",zIndex:this.zIndex,borderStyle:"none",position:"absolute"});$(previewZoom).width(this.zoomWidth).height(this.zoomHeight);$(fullZoomImage).css({margin:"0",padding:"0",borderStyle:"none"});$(fullZoomImage).wrap(container);$(fullZoomImage).wrap(frame);$(fullZoomImage).wrap(previewZoom);this.fullZoomImage=fullZoomImage;this.previewZoom=fullZoomImage.parentNode;this.frame=this.previewZoom.parentNode;this.container=this.frame.parentNode;this.trueZoomWidth=this.zoomWidth;this.trueZoomHeight=this.zoomHeight;this.trueZoom=null;$(previewZoom).css("visibility","visible");var loader=document.createElement("div");$(loader).append($("<img>").attr("src",this.imageDirectory+"/loader.gif"));$(loader).addClass("soniczoom-loader");$(loader).css("z-index",this.zIndex);$(loader).css("border-style","none");$(loader).css("visibility","hidden");$(this.container).append(loader);this.loader=loader;this.loadImage={};this.loadImage.action="switch";this.loadImage.actionArgs=null;this.loadImage.disableLoadAction=false;this.loadImage.fullZoomImage=null;this.loadImage.thumbNail=null;this.loadImage.ready={fullZoomImage:false,thumbNail:false};this.updateZoomTimerId=null;this.overlap={};this.overlap.elem=null;this.overlap.left=0;this.overlap.top=0;this.currentFrame=0;this.disableZoomAction=true;if(typeof this.control=="function")Zoomer.prototype.setupControl=this.control;$.data(this.fullZoomImage,"zoomer",this);this.setup(this.mrl,this.path)}Zoomer.prototype.setup=function(mrl,path){this.preparation=false;if(this.jsonpgis==""){var zoomer=this;this.ajaxParams={type:"GET",url:null,data:null,success:null,dataType:"text"};this.ajaxParams.url=mrl+"?gis="+path;this.ajaxParams.success=function(data){var size=data.split(",");$.soniczoom.setupCallback({id:zoomer.id,width:eval(size[0]),height:eval(size[1])})}}else{this.ajaxParams={type:"GET",url:null,data:null,success:null,dataType:"jsonp"};this.ajaxParams.url=mrl+this.jsonpgis+"?args='"+path+"','$.soniczoom.setupCallback','"+encodeURIComponent(this.id)+"'"}$.ajax(this.ajaxParams)};Zoomer.prototype.setupCallback=function(data){this.setSourceImageSize(data);this.setupNavigation();this.hasStartPosition()==true&&this.setPosition(this.startPosition);this.setupControl(this);this.disableZoomAction=false;this.preparation=true;$(this.fullZoomImage).triggerHandler(Zoomer.EVENT_IMAGE_INFO,[this,data])};Zoomer.prototype.setSourceImageSize=function(size){this.image.width=size.width;this.image.height=size.height;var scaleX=this.image.width/this.zoomWidth,scaleY=this.image.height/this.zoomHeight;if(scaleX>scaleY){this.image.scale=scaleX;this.image.adjWidth=this.image.width;this.image.adjHeight=Math.floor(this.zoomHeight*this.image.scale);this.image.padWidth=0;this.image.padHeight=Math.floor((this.image.adjHeight-this.image.height)/2)}else{this.image.scale=scaleY;this.image.adjWidth=Math.floor(this.zoomWidth*this.image.scale);this.image.adjHeight=this.image.height;this.image.padWidth=Math.floor((this.image.adjWidth-this.image.width)/2);this.image.padHeight=0}};Zoomer.prototype.setupNavigation=function(){if(this.navigationDisplay=="none"){this.navigationView={};this.navigationView.mainLayer=null;this.navigationView.dragView=null;this.navigationView.updateZoomBox=function(){};this.updateNavigationBox=function(){};this.navigationZoomin=function(){};this.navigationMoving=function(){};this.navigationMoved=function(){};this.switchNavigation=function(){};this.visibleNavigation=function(){};this.hiddenNavigation=function(){}}else{this.setupNavigationSize();var thumbNailImg=null;if(this.navigationImage=="thumbNail"){var thumbNailMRL=this.createThumbNailMRL(this.zoomImage,this.navWidth,this.navHeight,this.padColor,this.requestOption);thumbNailImg=$("<img>").attr("src",thumbNailMRL).css({margin:"0",padding:"0",borderStyle:"none"})}this.navigationView=new NavigationView(this.navWidth,this.navHeight,thumbNailImg,this.imageDirectory,this.navigationCss,this.dragviewCss);$(this.navigationView.mainLayer).css("z-index",this.zIndex);$(this.navigationView.dragView).css("z-index",this.zIndex);if(this.navigationDisplay=="on")$(this.navigationView.mainLayer).css("visibility","visible");else $(this.navigationView.mainLayer).css("visibility","hidden");$(this.container).append(this.navigationView.mainLayer)}};Zoomer.prototype.setupNavigationSize=function(){if(this.navigationSize.indexOf("width ")>-1){this.navWidth=eval($.trim(this.navigationSize.substring(this.navigationSize.indexOf("width ")+"width ".length)));this.thumbNailRatio=this.zoomWidth/this.navWidth;this.navHeight=Math.floor(this.zoomHeight/this.thumbNailRatio)}else if(this.navigationSize.indexOf("height ")>-1){this.navHeight=eval($.trim(this.navigationSize.substring(this.navigationSize.indexOf("height ")+"height ".length)));this.thumbNailRatio=this.zoomHeight/this.navHeight;this.navWidth=Math.floor(this.zoomWidth/this.thumbNailRatio)}else{this.thumbNailRatio=this.zoomWidth/(this.zoomWidth*eval(this.navigationSize));this.navWidth=Math.floor(this.zoomWidth/this.thumbNailRatio);this.navHeight=Math.floor(this.zoomHeight/this.thumbNailRatio)}};Zoomer.prototype.setupControl=function(){this.mouse=new Mouse;if(this.control.contextmenu!=undefined){var act=this.control.contextmenu;this.contextmenuDelegate="reset"==act?this.reset:"zoomout"==act?this.zoomout:"swnavi"==act?this.switchNavigation:null}if(this.control.shiftclick!=undefined){var act=this.control.shiftclick;this.shiftClickDelegate="reset"==act?this.reset:"zoomout"==act?this.zoomout:"swnavi"==act?this.switchNavigation:null}if(this.control.ctrlclick!=undefined){var act=this.control.ctrlclick;this.ctrlClickDelegate="reset"==act?this.reset:"zoomout"==act?this.zoomout:"swnavi"==act?this.switchNavigation:null}if(this.navigationDisplay=="none"){this.clickTrigger=this.previewZoom;this.dragTrigger=this.previewZoom}else{this.clickTrigger=[this.previewZoom,this.navigationView.mainLayer];this.dragTrigger=[this.previewZoom,this.navigationView.mainLayer,this.navigationView.dragView]}var zoomer=this;if(this.control.mousewheel!=undefined){function mousewheelEvent(e){var rollCount=zoomer.mouse.wheel(e);if(zoomer.control.mousewheel=="bz")rollCount*=-1;if(rollCount<0)if(this==zoomer.navigationView.mainLayer){zoomer.navigationZoomin(zoomer.getNavigationEventPosition(e));zoomer.mouse.preventEvent(e)}else zoomer.zoomin(zoomer.getEventPosition(e));else rollCount>0&&zoomer.zoomout()}if($.browser.mozilla){this.previewZoom.addEventListener("DOMMouseScroll",mousewheelEvent,false);this.navigationDisplay!="none"&&this.navigationView.mainLayer.addEventListener("DOMMouseScroll",mousewheelEvent,false)}else $(this.clickTrigger).bind("mousewheel",mousewheelEvent)}this.control.contextmenu!=undefined&&$(this.clickTrigger).bind("contextmenu",function(e){zoomer.mouse.preventEvent(e);zoomer.contextmenuDelegate()});if(this.control.shiftclick!=undefined&&this.control.ctrlclick!=undefined)$(this.clickTrigger).click(function(e){if(zoomer.mouse.preventClickEvent==true)zoomer.mouse.preventClickEvent=false;else if(e.shiftKey==true)zoomer.shiftClickDelegate();else if(e.ctrlKey==true)zoomer.ctrlClickDelegate();else if(this==zoomer.navigationView.mainLayer){zoomer.navigationZoomin(zoomer.getNavigationEventPosition(e));zoomer.mouse.preventEvent(e)}else zoomer.zoomin(zoomer.getEventPosition(e))});else if(this.control.shiftclick!=undefined)$(this.clickTrigger).click(function(e){if(zoomer.mouse.preventClickEvent==true)zoomer.mouse.preventClickEvent=false;else if(e.shiftKey==true)zoomer.shiftClickDelegate();else if(this==zoomer.navigationView.mainLayer){zoomer.navigationZoomin(zoomer.getNavigationEventPosition(e));zoomer.mouse.preventEvent(e)}else zoomer.zoomin(zoomer.getEventPosition(e))});else if(this.control.ctrlclick!=undefined)$(this.clickTrigger).click(function(e){if(zoomer.mouse.preventClickEvent==true)zoomer.mouse.preventClickEvent=false;else if(e.ctrlKey==true)zoomer.ctrlClickDelegate();else if(this==zoomer.navigationView.mainLayer){zoomer.navigationZoomin(zoomer.getNavigationEventPosition(e));zoomer.mouse.preventEvent(e)}else zoomer.zoomin(zoomer.getEventPosition(e))});else $(this.clickTrigger).click(function(e){if(zoomer.mouse.preventClickEvent==true)zoomer.mouse.preventClickEvent=false;else if(this==zoomer.navigationView.mainLayer){zoomer.navigationZoomin(zoomer.getNavigationEventPosition(e));zoomer.mouse.preventEvent(e)}else zoomer.zoomin(zoomer.getEventPosition(e))});$(this.dragTrigger).mousedown(function(e){if(this!=zoomer.navigationView.mainLayer)zoomer.mouse.start(e);else zoomer.mouse.preventEvent(e)});$(this.clickTrigger).mousemove(function(e){if(zoomer.mouse.move(e)==false)return;if(this==zoomer.navigationView.mainLayer||this==zoomer.navigationView.dragView)isMoved=zoomer.navigationMoving(zoomer.mouse.shiftX,zoomer.mouse.shiftY);else isMoved=zoomer.moving(zoomer.mouse.shiftX,zoomer.mouse.shiftY);if(isMoved==false)zoomer.mouse.cancelDrag();else zoomer.mouse.preventEvent(e)});$(this.clickTrigger).bind("mouseup mouseleave",function(e){if(zoomer.mouse.end(e)){zoomer.mouse.preventClickEvent=true;if(this==zoomer.navigationView.mainLayer||this==zoomer.navigationView.dragView)zoomer.navigationMoved();else zoomer.moved()}})};Zoomer.prototype.beginAnimation=function(newPosition){if(newPosition.zoomLevel>this.maxZoomLevels){$(this.fullZoomImage).triggerHandler(Zoomer.EVENT_MAX_ZOOM_LEVELS,[this]);return}this.newPosition=newPosition;this.currentFrame=1;this.constrainZoom();this.loadNewZoom();var oldCenterPoint=this.getCenterPoint(this.currentPreviewPosition),newCenterPoint=this.getCenterPoint(this.newPosition);this.changePosition.x=(newCenterPoint.x-oldCenterPoint.x)/Zoomer.MAX_ANIMATION_FRAME;this.changePosition.y=(newCenterPoint.y-oldCenterPoint.y)/Zoomer.MAX_ANIMATION_FRAME;this.changePosition.zoomLevel=(this.newPosition.zoomLevel-this.currentPreviewPosition.zoomLevel)/Zoomer.MAX_ANIMATION_FRAME;var zoomer=this;setTimeout(function(){zoomer.animateZoom()},this.animationUpdataTime)};Zoomer.prototype.getCenterPoint=function(position){var centerPoint={};centerPoint.x=position.x+this.zoomWidth/(2*this.calculateZoomLevel(position.zoomLevel));centerPoint.y=position.y+this.zoomHeight/(2*this.calculateZoomLevel(position.zoomLevel));return centerPoint};Zoomer.prototype.loadNewZoom=function(){if(this.newPosition.zoomLevel!=0){$(this.loader).css("visibility","visible");this.disableZoomAction=true;this.loadImageInBackground(Zoomer.MAX_LOAD_WAIT)}else{$(this.trueZoom).remove();this.disableZoomAction=true;this.trueZoom=null}};Zoomer.prototype.loadImageInBackground=function(waitTime){var zoomMRL=this.zoomMediaServerImage(this.newPosition),zoomImage=$("<img>").attr("src",zoomMRL).css({margin:"0",padding:"0",borderStyle:"none"});this.trueZoom!=null&&$(this.trueZoom).remove();var trueZoom=$("<div>").css({margin:"0",padding:"0",overflow:"hidden",left:"0",top:"0",zIndex:$(this.previewZoom).css("z-index"),borderStyle:"none",position:"absolute"});$(trueZoom).append(zoomImage);this.trueZoomImage=zoomImage.get(0);this.trueZoom=trueZoom.get(0)};Zoomer.prototype.constrainZoom=function(){if(this.newPosition.zoomLevel!=0){var maxHeight=this.zoomHeight-this.zoomHeight/this.calculateZoomLevel(this.newPosition.zoomLevel),maxWidth=this.zoomWidth-this.zoomWidth/this.calculateZoomLevel(this.newPosition.zoomLevel);if(this.newPosition.x<0)this.newPosition.x=0;else if(this.newPosition.x>maxWidth)this.newPosition.x=maxWidth;if(this.newPosition.y<0)this.newPosition.y=0;else if(this.newPosition.y>maxHeight)this.newPosition.y=maxHeight}};Zoomer.prototype.animateZoom=function(){this.zoomPreviewImage();this.currentFrame++;if(this.currentFrame>Zoomer.MAX_ANIMATION_FRAME){this.currentFrame=0;this.updateZoom(Zoomer.MAX_ZOOM_WAIT);return}else{var zoomer=this;setTimeout(function(){zoomer.animateZoom()},this.animationUpdataTime)}};Zoomer.prototype.updateZoom=function(waitTime){if(this.newPosition.zoomLevel==0){$(this.loader).css("visibility","hidden");this.disableZoomAction=false;$(this.fullZoomImage).triggerHandler(Zoomer.EVENT_UPDATE_ZOOM,[this]);return}var loaded=this.trueZoomImage!=null&&this.trueZoomImage.complete;if(waitTime>=0&&!loaded){var zoomer=this,nextWaitTime=waitTime-Zoomer.UPDATE_CHECK_TIME;this.updateZoomTimerId=setTimeout(function(){zoomer.updateZoom(nextWaitTime)},Zoomer.UPDATE_CHECK_TIME);return}else{$(this.loader).css("visibility","hidden");$(this.trueZoom).width(this.trueZoomWidth);$(this.trueZoom).height(this.trueZoomHeight);var zoomLevel=this.calculateZoomLevel(this.currentPreviewPosition.zoomLevel),x=this.currentPreviewPosition.x*zoomLevel-this.trueZoomAdjuster.x,y=this.currentPreviewPosition.y*zoomLevel-this.trueZoomAdjuster.y;$(this.trueZoom).css({left:x+"px",top:y+"px"});$(this.trueZoom).css("display","none");this.createTrueZoomPaddingLayer();if(this.overlap.elem==null)$(this.previewZoom).append(this.trueZoom);else $(this.overlap.elem).before(this.trueZoom);$(this.trueZoom).fadeIn(Zoomer.UPDATE_FADEIN);this.disableZoomAction=false;this.updateZoomTimerId=null;$(this.fullZoomImage).triggerHandler(Zoomer.EVENT_UPDATE_ZOOM,[this])}};Zoomer.prototype.createTrueZoomPaddingLayer=function(){if(this.image.padWidth>0){if(this.trueZoomPadding.left>0){var left=$("<div>").css({margin:"0",padding:"0",zIndex:$(this.previewZoom).css("z-index"),borderStyle:"none",position:"absolute",top:"0"});left.width(this.trueZoomPadding.left).height(this.trueZoomHeight);left.css("left","0");left.css("background-color","#"+this.padColor.substring(2));$(this.trueZoom).append(left)}if(this.trueZoomPadding.right>0){var right=$("<div>").css({margin:"0",padding:"0",zIndex:$(this.previewZoom).css("z-index"),borderStyle:"none",position:"absolute",top:"0"});right.width(this.trueZoomPadding.right).height(this.trueZoomHeight);right.css("left",this.trueZoomWidth-this.trueZoomPadding.right+"px");right.css("background-color","#"+this.padColor.substring(2));$(this.trueZoom).append(right)}}else if(this.image.padHeight>0){if(this.trueZoomPadding.top>0){var top=$("<div>").css({margin:"0",padding:"0",zIndex:$(this.previewZoom).css("z-index"),borderStyle:"none",position:"absolute",left:"0"});top.width(this.trueZoomWidth).height(this.trueZoomPadding.top);top.css("top","0");top.css("background-color","#"+this.padColor.substring(2));$(this.trueZoom).append(top)}if(this.trueZoomPadding.bottom>0){var bottom=$("<div>").css({margin:"0",padding:"0",zIndex:$(this.previewZoom).css("z-index"),borderStyle:"none",position:"absolute",left:"0"});bottom.width(this.trueZoomWidth).height(this.trueZoomPadding.bottom);bottom.css("top",this.trueZoomHeight-this.trueZoomPadding.bottom+"px");bottom.css("background-color","#"+this.padColor.substring(2));$(this.trueZoom).append(bottom)}}};Zoomer.prototype.calculateZoomLevel=function(zoomLevel){return Math.pow(this.zoomPerLevel,zoomLevel)};Zoomer.prototype.zoomPreviewImage=function(){var newCenter=this.getCenterPoint(this.currentPreviewPosition);newCenter.x+=this.changePosition.x;newCenter.y+=this.changePosition.y;this.currentPreviewPosition.zoomLevel+=this.changePosition.zoomLevel;var zoomLevel=this.calculateZoomLevel(this.currentPreviewPosition.zoomLevel);newCenter.x-=this.zoomWidth/(2*zoomLevel);newCenter.y-=this.zoomHeight/(2*zoomLevel);this.currentPreviewPosition.x=newCenter.x;this.currentPreviewPosition.y=newCenter.y;if(this.currentPreviewPosition.zoomLevel<.1){this.currentPreviewPosition.zoomLevel=0;this.currentPreviewPosition.x=0;this.currentPreviewPosition.y=0}var zoomLevel=this.calculateZoomLevel(this.currentPreviewPosition.zoomLevel),newWidth=this.zoomWidth*zoomLevel,newHeight=this.zoomHeight*zoomLevel,layerXOffset=-this.currentPreviewPosition.x*zoomLevel,layerYOffset=-this.currentPreviewPosition.y*zoomLevel;$(this.previewZoom).width(newWidth).height(newHeight);$(this.fullZoomImage).width(newWidth).height(newHeight);$(this.previewZoom).css({left:layerXOffset+"px",top:layerYOffset+"px"});this.updateNavigationBox();this.updateOverlapPosition()};Zoomer.prototype.updateNavigationBox=function(){var zbX=this.currentPreviewPosition.x/this.thumbNailRatio,zbY=this.currentPreviewPosition.y/this.thumbNailRatio,zoomLevel=this.calculateZoomLevel(this.currentPreviewPosition.zoomLevel),zbW=this.zoomWidth/this.thumbNailRatio/zoomLevel,zbH=this.zoomHeight/this.thumbNailRatio/zoomLevel;this.navigationView.updateZoomBox(this.currentPreviewPosition.zoomLevel,zbX,zbY,zbW,zbH)};Zoomer.prototype.zoomMediaServerImage=function(newPosition){var zoomLevel=this.calculateZoomLevel(newPosition.zoomLevel),nextWidth=this.zoomWidth*zoomLevel,nextHeight=this.zoomHeight*zoomLevel,x,y,w,h;if(this.zoomWidth+this.grid>nextWidth&&this.zoomHeight+this.grid>nextHeight){this.trueZoomWidth=nextWidth;this.trueZoomHeight=nextHeight;x=y=0;w=this.image.adjWidth;h=this.image.adjHeight}else{this.trueZoomWidth=this.zoomWidth+this.grid;this.trueZoomHeight=this.zoomHeight+this.grid;var gridZoomLevel=this.grid/zoomLevel;if(gridZoomLevel<1)gridZoomLevel=1;x=Math.floor(newPosition.x/gridZoomLevel)*gridZoomLevel;y=Math.floor(newPosition.y/gridZoomLevel)*gridZoomLevel;w=this.image.adjWidth/zoomLevel+gridZoomLevel*this.image.scale;h=this.image.adjHeight/zoomLevel+gridZoomLevel*this.image.scale}var crLeft=x*this.image.scale-this.image.padWidth,crTop=y*this.image.scale-this.image.padHeight,crRight=crLeft+w,crBottom=crTop+h;this.trueZoomAdjuster.x=(newPosition.x-x)*zoomLevel;this.trueZoomAdjuster.y=(newPosition.y-y)*zoomLevel;this.setTrueZoomPaddingProperties(crLeft,crTop,crRight,crBottom,zoomLevel);var zoomMRL=this.createZoomMRL(this.zoomImage,this.trueZoomWidth,this.trueZoomHeight,crLeft,crTop,crRight,crBottom,this.requestOption);return zoomMRL};Zoomer.prototype.setTrueZoomPaddingProperties=function(crLeft,crTop,crRight,crBottom,zoomLevel){this.trueZoomPadding.left=0;this.trueZoomPadding.top=0;this.trueZoomPadding.right=0;this.trueZoomPadding.bottom=0;if(this.image.padWidth>0){if(crLeft<0)this.trueZoomPadding.left=Math.ceil(crLeft/this.image.scale*zoomLevel*-1);if(crRight>this.image.width)this.trueZoomPadding.right=Math.ceil((crRight-this.image.width)/this.image.scale*zoomLevel)}else if(this.image.padHeight>0){if(crTop<0)this.trueZoomPadding.top=Math.ceil(crTop/this.image.scale*zoomLevel*-1);if(crBottom>this.image.height)this.trueZoomPadding.bottom=Math.ceil((crBottom-this.image.height)/this.image.scale*zoomLevel)}};Zoomer.prototype.createZoomMRL=function(zoomImage,width,height,crLeft,crTop,crRight,crBottom,option){var mrlParams="?is="+width+","+height+"&cr="+crLeft+","+crTop+","+crRight+","+crBottom+"&cvt=jpeg"+option;return this.zoomImage+mrlParams};Zoomer.prototype.createThumbNailMRL=function(zoomImage,width,height,background,option){var mrlParams="?is="+width+","+height+","+background+"&cvt=jpeg"+option;return zoomImage+mrlParams};Zoomer.prototype.getEventPosition=function(e){var offset=$(this.previewZoom).offset();return {x:e.pageX-offset.left,y:e.pageY-offset.top}};Zoomer.prototype.getNavigationEventPosition=function(e){var offset=$(this.navigationView.mainLayer).offset();return {x:e.pageX-offset.left,y:e.pageY-offset.top}};Zoomer.prototype.zoomin=function(position){var result=$(this.fullZoomImage).triggerHandler(Zoomer.EVENT_ZOOMIN,[this,position]);if(result=="end")return;if(this.disableZoomAction)return;var newPosition={};if(position==undefined){var zoomLevel=this.calculateZoomLevel(this.currentPreviewPosition.zoomLevel);newPosition.x=this.currentPreviewPosition.x+this.zoomWidth/(2*zoomLevel);newPosition.y=this.currentPreviewPosition.y+this.zoomHeight/(2*zoomLevel)}else{var zoomLevel=this.calculateZoomLevel(this.currentPreviewPosition.zoomLevel);newPosition.x=position.x/zoomLevel;newPosition.y=position.y/zoomLevel}newPosition.zoomLevel=this.currentPreviewPosition.zoomLevel+1;zoomLevel=this.calculateZoomLevel(newPosition.zoomLevel);newPosition.x-=this.zoomWidth/(2*zoomLevel);newPosition.y-=this.zoomHeight/(2*zoomLevel);this.beginAnimation(newPosition)};Zoomer.prototype.zoomout=function(){var result=$(this.fullZoomImage).triggerHandler(Zoomer.EVENT_ZOOMOUT,[this]);if(result=="end")return;if(this.disableZoomAction)return;var newPosition={};newPosition.x=this.currentPreviewPosition.x;newPosition.y=this.currentPreviewPosition.y;newPosition.zoomLevel=this.currentPreviewPosition.zoomLevel;if(newPosition.zoomLevel>=.2){newPosition.zoomLevel-=1;if(newPosition.zoomLevel<=.2){newPosition.zoomLevel=0;newPosition.x=0;newPosition.y=0}else{newPosition.x-=this.zoomWidth/(2*this.calculateZoomLevel(newPosition.zoomLevel+1));newPosition.y-=this.zoomHeight/(2*this.calculateZoomLevel(newPosition.zoomLevel+1))}this.beginAnimation(newPosition)}};Zoomer.prototype.reset=function(){var result=$(this.fullZoomImage).triggerHandler(Zoomer.EVENT_RESET,[this]);if(result=="end")return;if(this.hasStartPosition()==true)this.beginAnimation(this.startPosition);else if(this.currentPreviewPosition.zoomLevel>=.2){var newPosition={};newPosition.zoomLevel=0;newPosition.x=0;newPosition.y=0;this.beginAnimation(newPosition)}};Zoomer.prototype.moving=function(shiftX,shiftY){var result=$(this.fullZoomImage).triggerHandler(Zoomer.EVENT_MOVING,[this,shiftX,shiftY]);if(result=="end")return true;if(result=="cancel")return false;if(this.disableZoomAction)return false;if(this.currentPreviewPosition.zoomLevel<1)return false;$(this.frame).css("cursor","move");var position=$(this.previewZoom).position(),x=position.left+shiftX;if(x+$(this.previewZoom).width()<$(this.frame).width())x=$(this.frame).width()-$(this.previewZoom).width();else if(0<x)x=0;$(this.previewZoom).css("left",x+"px");var y=position.top+shiftY;if(y+$(this.previewZoom).height()<$(this.frame).height())y=$(this.frame).height()-$(this.previewZoom).height();else if(0<y)y=0;$(this.previewZoom).css("top",y+"px");var zoomLevel=this.calculateZoomLevel(this.currentPreviewPosition.zoomLevel),posX=-x/zoomLevel/this.thumbNailRatio,posY=-y/zoomLevel/this.thumbNailRatio;this.navigationView.updateZoomBox(this.currentPreviewPosition.zoomLevel,posX,posY);this.updateOverlapPosition();var position=$(this.previewZoom).position(),zoomLevel=this.calculateZoomLevel(this.currentPreviewPosition.zoomLevel);this.currentPreviewPosition.x=this.newPosition.x=-position.left/zoomLevel;this.currentPreviewPosition.y=this.newPosition.y=-position.top/zoomLevel;return true};Zoomer.prototype.moved=function(){var result=$(this.fullZoomImage).triggerHandler(Zoomer.EVENT_MOVED,[this]);if(result=="end")return;$(this.frame).css("cursor","crosshair");if(this.currentPreviewPosition.zoomLevel<1)return;var position=$(this.previewZoom).position(),zoomLevel=this.calculateZoomLevel(this.currentPreviewPosition.zoomLevel);this.currentPreviewPosition.x=this.newPosition.x=-position.left/zoomLevel;this.currentPreviewPosition.y=this.newPosition.y=-position.top/zoomLevel;this.update()};Zoomer.prototype.moveToPosition=function(position){if(this.disableZoomAction)return;this.beginAnimation(position)};Zoomer.prototype.update=function(){this.loadNewZoom();this.updateZoom(Zoomer.MAX_ZOOM_WAIT);this.updateNavigationBox();this.updateOverlapPosition()};Zoomer.prototype.navigationZoomin=function(position){var result=$(this.fullZoomImage).triggerHandler(Zoomer.EVENT_NAVIGATION_ZOOMIN,[this,position]);if(result=="end")return;if(this.disableZoomAction)return;var newPosition={},offset=$(this.navigationView.mainLayer).offset();newPosition.x=position.x*this.thumbNailRatio;newPosition.y=position.y*this.thumbNailRatio;newPosition.zoomLevel=this.currentPreviewPosition.zoomLevel+1;var zoomLevel=this.calculateZoomLevel(newPosition.zoomLevel);newPosition.x-=this.zoomWidth/(2*zoomLevel);newPosition.y-=this.zoomHeight/(2*zoomLevel);this.beginAnimation(newPosition)};Zoomer.prototype.navigationMoving=function(shiftX,shiftY){var result=$(this.fullZoomImage).triggerHandler(Zoomer.EVENT_NAVIGATION_MOVING,[this,shiftX,shiftY]);if(result=="end")return true;if(result=="cancel")return false;if(this.disableZoomAction)return false;$(this.navigationView.mainLayer).css("cursor","pointer");var position=$(this.navigationView.dragView).position(),x=position.left+shiftX,y=position.top+shiftY;if(x<0)x=0;else if(x+this.navigationView.zoomboxWidth>$(this.navigationView.mainLayer).width())x=$(this.navigationView.mainLayer).width()-this.navigationView.zoomboxWidth;if(y<0)y=0;else if(y+this.navigationView.zoomboxHeight>$(this.navigationView.mainLayer).height())y=$(this.navigationView.mainLayer).height()-this.navigationView.zoomboxHeight;this.navigationView.updateZoomBox(this.currentPreviewPosition.zoomLevel,x,y);var zoomLevel=this.calculateZoomLevel(this.currentPreviewPosition.zoomLevel),layerXOffset=-x*zoomLevel*this.thumbNailRatio,layerYOffset=-y*zoomLevel*this.thumbNailRatio;$(this.previewZoom).css({left:layerXOffset+"px",top:layerYOffset+"px"});this.updateOverlapPosition();var position=$(this.previewZoom).position(),zoomLevel=this.calculateZoomLevel(this.currentPreviewPosition.zoomLevel);this.currentPreviewPosition.x=this.newPosition.x=-position.left/zoomLevel;this.currentPreviewPosition.y=this.newPosition.y=-position.top/zoomLevel;return true};Zoomer.prototype.navigationMoved=function(){var result=$(this.fullZoomImage).triggerHandler(Zoomer.EVENT_NAVIGATION_MOVED,[this]);if(result=="end")return;$(this.navigationView.mainLayer).css("cursor","crosshair");if(this.currentPreviewPosition.zoomLevel<1)return;var position=$(this.navigationView.dragView).position();this.currentPreviewPosition.x=this.newPosition.x=position.left*this.thumbNailRatio;this.currentPreviewPosition.y=this.newPosition.y=position.top*this.thumbNailRatio;this.loadNewZoom();this.updateZoom(Zoomer.MAX_ZOOM_WAIT)};Zoomer.prototype.switchNavigation=function(){if($(this.navigationView.mainLayer).css("visibility")=="visible"){$(this.navigationView.mainLayer).css("visibility","hidden");$(this.navigationView.dragView).css("visibility","hidden")}else{$(this.navigationView.mainLayer).css("visibility","visible");this.currentPreviewPosition.zoomLevel>.2&&$(this.navigationView.dragView).css("visibility","visible")}};Zoomer.prototype.visibleNavigation=function(){if($(this.navigationView.mainLayer).css("visibility")=="hidden"){$(this.navigationView.mainLayer).css("visibility","visible");this.currentPreviewPosition.zoomLevel>.2&&$(this.navigationView.dragView).css("visibility","visible")}};Zoomer.prototype.hiddenNavigation=function(){if($(this.navigationView.mainLayer).css("visibility")=="visible"){$(this.navigationView.mainLayer).css("visibility","hidden");$(this.navigationView.dragView).css("visibility","hidden")}};Zoomer.prototype.changeImage=function(path,action,args){if(this.loadImage.disableLoadAction)return;this.loadImage.disableLoadAction=true;if(this.disableZoomAction){clearTimeout(this.updateZoomTimerId);this.updateZoomTimerId=null}this.disableZoomAction=true;this.path=path;this.zoomImage=this.mrl+this.path;if(action==undefined){this.loadImage.action="switch";this.loadImage.actionArgs=null}else{this.loadImage.action=action;this.loadImage.actionArgs=args}if(this.jsonpgis==""){var zoomer=this;this.ajaxParams.url=this.mrl+"?gis="+this.path;this.ajaxParams.success=function(data){var size=data.split(",");$.soniczoom.changeImageCallback({id:zoomer.id,width:eval(size[0]),height:eval(size[1])})}}else this.ajaxParams.url=this.mrl+this.jsonpgis+"?args='"+path+"','$.soniczoom.changeImageCallback','"+encodeURIComponent(this.id)+"'";$.ajax(this.ajaxParams)};Zoomer.prototype.changeImageCallback=function(data){if(this.preparation==false)return;this.setSourceImageSize(data);$(this.fullZoomImage).triggerHandler(Zoomer.EVENT_IMAGE_INFO,[this,data]);var thumbNailMRL=this.createThumbNailMRL(this.zoomImage,this.zoomWidth,this.zoomHeight,this.padColor,this.requestOption);this.loadImage.fullZoomImage=$("<img>").attr("src",thumbNailMRL).css({margin:"0",padding:"0",borderStyle:"none"}).get(0);if(this.navigationDisplay!="none"&&this.navigationImage=="thumbNail"){thumbNailMRL=this.createThumbNailMRL(this.zoomImage,this.navWidth,this.navHeight,this.padColor,this.requestOption);this.loadImage.thumbNail=$("<img>").attr("src",thumbNailMRL).css({margin:"0",padding:"0",borderStyle:"none"}).get(0)}this.updateImage(Zoomer.MAX_LOAD_WAIT)};Zoomer.prototype.updateImage=function(waitTime){var loaded=this.loadImage.fullZoomImage.complete&&(this.navigationDisplay!="none"&&this.navigationImage=="thumbNail"?this.loadImage.thumbNail.complete:true);if(waitTime>=0&&!loaded){$(this.loader).css("visibility","visible");var zoomer=this,nextWaitTime=waitTime-Zoomer.UPDATE_CHECK_TIME;setTimeout(function(){zoomer.updateImage(nextWaitTime)},Zoomer.UPDATE_CHECK_TIME);return}else{$(this.loader).css("visibility","hidden");this.trueZoom!=null&&$(this.trueZoom).remove();$(this.navigationView.dragView).css("visibility","hidden");if(this.loadImage.action=="fadeIn"){$(this.loadImage.fullZoomImage).css({margin:"0",padding:"0",overflow:"hidden",left:"0",top:"0",zIndex:$(this.previewZoom).css("z-index"),borderStyle:"none",position:"absolute"});var position=$(this.previewZoom).position();$(this.loadImage.fullZoomImage).css("left",Math.abs(position.left)+"px");$(this.loadImage.fullZoomImage).css("top",Math.abs(position.top)+"px");$(this.loadImage.fullZoomImage).width(this.zoomWidth).height(this.zoomHeight);if(this.overlap.elem==null)$(this.previewZoom).append(this.loadImage.fullZoomImage);else $(this.overlap.elem).before(this.loadImage.fullZoomImage);$(this.loadImage.fullZoomImage).css("display","none");$(this.loadImage.fullZoomImage).fadeIn(Zoomer.UPDATE_FADEIN,function(){var zoomer=$.data(this.parentNode.firstChild,"zoomer");if(zoomer!=null){zoomer.setInitialPosition();zoomer.setLoadedImage()}});if(this.navigationDisplay!="none"&&this.navigationImage=="thumbNail"){$(this.loadImage.thumbNail).css({margin:"0",padding:"0",overflow:"hidden",left:"0",top:"0",zIndex:$(this.navigationView.mainLayer).css("z-index"),borderStyle:"none",position:"absolute"});$(this.loadImage.thumbNail).width(this.navWidth).height(this.navHeight);$(this.navigationView.mainLayer).append(this.loadImage.thumbNail);$(this.loadImage.thumbNail).css("display","none");$(this.loadImage.thumbNail).fadeIn(Zoomer.UPDATE_FADEIN)}}else if(this.loadImage.action=="keepPosition"){this.setLoadedImage();this.currentPreviewPosition.zoomLevel>0&&this.update()}else if(this.loadImage.action=="setPosition"){this.setInitialPosition();this.setLoadedImage();var position=this.loadImage.actionArgs;position.zoomLevel>0&&this.setPosition(position)}else{this.setInitialPosition();this.setLoadedImage()}}};Zoomer.prototype.setInitialPosition=function(){this.currentPreviewPosition.zoomLevel=0;this.currentPreviewPosition.x=0;this.currentPreviewPosition.y=0;$(this.previewZoom).width(this.zoomWidth).height(this.zoomHeight);$(this.fullZoomImage).width(this.zoomWidth).height(this.zoomHeight);$(this.previewZoom).css({left:"0",top:"0"});this.updateOverlapPosition()};Zoomer.prototype.setLoadedImage=function(){var zoomer=this;if(this.navigationDisplay!="none"&&this.navigationImage=="thumbNail"){this.loadImage.ready.thumbNail=false;$(this.navigationView.thumbNail).bind("load",function(e){zoomer.loadImage.ready.thumbNail=true;$(zoomer.navigationView.thumbNail).unbind("load");if(zoomer.loadImage.ready.fullZoomImage==true){$(zoomer.loadImage.fullZoomImage).remove();$(zoomer.loadImage.thumbNail).remove();zoomer.loadImage.fullZoomImage=null;zoomer.loadImage.thumbNail=null;zoomer.loadImage.ready.fullZoomImage=false;zoomer.loadImage.ready.thumbNail=false;zoomer.disableZoomAction=false;zoomer.loadImage.disableLoadAction=false}});$(this.navigationView.thumbNail).attr("src",$(this.loadImage.thumbNail).attr("src"))}this.loadImage.ready.fullZoomImage=false;$(this.fullZoomImage).bind("load",function(){$(zoomer.fullZoomImage).unbind("load");if(zoomer.navigationDisplay!="none"){zoomer.loadImage.ready.fullZoomImage=true;if(zoomer.loadImage.ready.thumbNail==true){$(zoomer.loadImage.fullZoomImage).remove();$(zoomer.loadImage.thumbNail).remove();zoomer.loadImage.fullZoomImage=null;zoomer.loadImage.thumbNail=null;zoomer.loadImage.ready.fullZoomImage=false;zoomer.loadImage.ready.thumbNail=false;zoomer.disableZoomAction=false;zoomer.loadImage.disableLoadAction=false}}else{$(zoomer.loadImage.fullZoomImage).remove();zoomer.loadImage.fullZoomImage=null;zoomer.disableZoomAction=false;zoomer.loadImage.disableLoadAction=false}});$(this.fullZoomImage).attr("src",$(this.loadImage.fullZoomImage).attr("src"))};Zoomer.prototype.changeSize=function(size){if(this.loadImage.disableLoadAction)return;this.loadImage.disableLoadAction=true;if(this.disableZoomAction){clearTimeout(this.updateZoomTimerId);this.updateZoomTimerId=null}this.disableZoomAction=true;this.zoomWidth=size.width;this.zoomHeight=size.height;$(this.previewZoom).width(this.zoomWidth).height(this.zoomHeight);$(this.frame).width(this.zoomWidth).height(this.zoomHeight);$(this.container).width(this.zoomWidth).height(this.zoomHeight);this.trueZoomWidth=this.zoomWidth;this.trueZoomHeight=this.zoomHeight;this.setSourceImageSize({width:this.image.width,height:this.image.height});var thumbNailMRL=this.createThumbNailMRL(this.zoomImage,this.zoomWidth,this.zoomHeight,this.padColor,this.requestOption);this.loadImage.fullZoomImage=$("<img>").attr("src",thumbNailMRL).css({margin:"0",padding:"0",borderStyle:"none"}).get(0);if(this.navigationDisplay!="none"){this.setupNavigationSize();this.navigationView.changeSize(this.navWidth,this.navHeight);if(this.navigationImage=="thumbNail"){thumbNailMRL=this.createThumbNailMRL(this.zoomImage,this.navWidth,this.navHeight,this.padColor,this.requestOption);this.loadImage.thumbNail=$("<img>").attr("src",thumbNailMRL).css({margin:"0",padding:"0",borderStyle:"none"}).get(0)}}this.updateImage(Zoomer.MAX_LOAD_WAIT)};Zoomer.prototype.appendOverlap=function(content){$(this.previewZoom).append(content);this.overlap.elem=this.previewZoom.lastChild;var position=$(this.overlap.elem).position();this.overlap.left=position.left;this.overlap.top=position.top};Zoomer.prototype.removeOverlap=function(){if(this.overlap.elem){$(this.overlap.elem).remove();this.overlap.elem=null;this.overlap.left=0;this.overlap.top=0}};Zoomer.prototype.updateOverlapPosition=function(){if(this.overlap.elem!=null){var position=$(this.previewZoom).position();$(this.overlap.elem).css("left",Math.abs(position.left)+this.overlap.left+"px");$(this.overlap.elem).css("top",Math.abs(position.top)+this.overlap.top+"px")}};Zoomer.prototype.hasStartPosition=function(){if(this.startPosition!=null&&this.startPosition.x!=undefined&&this.startPosition.y!=undefined&&this.startPosition.zoomLevel!=undefined)return true;return false};Zoomer.prototype.setPosition=function(newPosition){if(newPosition.zoomLevel>this.maxZoomLevels){$(this.fullZoomImage).triggerHandler(Zoomer.EVENT_MAX_ZOOM_LEVELS,[this]);return}this.newPosition=newPosition;this.constrainZoom();this.loadNewZoom();$(this.loader).css("visibility","hidden");var oldCenterPoint=this.getCenterPoint(this.currentPreviewPosition),newCenterPoint=this.getCenterPoint(this.newPosition);this.changePosition.x=newCenterPoint.x-oldCenterPoint.x;this.changePosition.y=newCenterPoint.y-oldCenterPoint.y;this.changePosition.zoomLevel=this.newPosition.zoomLevel-this.currentPreviewPosition.zoomLevel;this.zoomPreviewImage();this.updateZoom(Zoomer.MAX_ZOOM_WAIT);$(this.fullZoomImage).css("visibility","visible")};function NavigationView(width,height,image,imageDirectory,navigationCss,dragviewCss){if(image==null)image=$("<img>").attr("src",imageDirectory+"/transparent.gif").css({margin:"0",padding:"0",borderStyle:"none"});this.thumbNail=image;this.mainLayer=document.createElement("div");if(navigationCss!=null)$(this.mainLayer).css(navigationCss);else $(this.mainLayer).addClass("soniczoom-navigation");$(this.mainLayer).css({margin:"0",padding:"0",overflow:"hidden",position:"absolute",cursor:"crosshair"});$(this.mainLayer).width(width).height(height);$(this.mainLayer).append(image);this.zoomboxWidth=width;this.zoomboxHeight=height;this.dragViewImage=$("<img>").attr("src",imageDirectory+"/transparent.gif").css({margin:"0",padding:"0",borderStyle:"none"});$(this.dragViewImage).width(width-2).height(height-2);this.dragView=document.createElement("div");$(this.dragView).addClass("soniczoom-dragview");if(dragviewCss!=null)$(this.dragView).css(dragviewCss);else $(this.dragView).addClass("soniczoom-dragview");$(this.dragView).css({margin:"0",padding:"0",overflow:"hidden",left:"0",top:"0",position:"absolute"});$(this.dragView).width(width-2).height(height-2);$(this.dragView).css("visibility","hidden");$(this.dragView).append(this.dragViewImage);$(this.mainLayer).append(this.dragView)}NavigationView.prototype.updateZoomBox=function(zoomLevel,posX,posY,width,height){if(zoomLevel<=.2)$(this.dragView).css("visibility","hidden");else{if(width!=null)this.zoomboxWidth=width;if(height!=null)this.zoomboxHeight=height;$(this.dragViewImage).width(this.zoomboxWidth-2).height(this.zoomboxHeight-2);$(this.dragView).width(this.zoomboxWidth-2).height(this.zoomboxHeight-2);$(this.dragView).css({left:posX+"px",top:posY+"px"});$(this.mainLayer).css("visibility")=="visible"&&$(this.dragView).css("visibility","visible")}};NavigationView.prototype.changeSize=function(width,height){$(this.mainLayer).width(width).height(height);this.zoomboxWidth=width;this.zoomboxHeight=height;$(this.dragViewImage).width(width-2).height(height-2);$(this.dragView).width(width-2).height(height-2)};Mouse.ROLLCOUNT=2;function Mouse(){this.on=false;this.x=0;this.y=0;this.shiftX=0;this.shiftY=0;this.drag=false;this.rollCount=0;this.preventClickEvent=false}Mouse.prototype.start=function(e){if(this.on==true)return false;this.on=true;this.x=e.pageX;this.y=e.pageY;this.shiftX=0;this.shiftY=0;this.drag=false;this.preventEvent(e);return true};Mouse.prototype.move=function(e){if(this.on==false)return false;this.shiftX=e.pageX-this.x;this.shiftY=e.pageY-this.y;this.x=e.pageX;this.y=e.pageY;this.drag=true;this.preventEvent(e);return true};Mouse.prototype.wheel=function(e){var roll=0;if(e.wheelDelta)roll=e.wheelDelta/-120;else if(e.detail)roll=e.detail/3;if(this.rollCount>0&&roll<0||this.rollCount<0&&roll>0)this.rollCount=0;this.rollCount+=roll;this.preventEvent(e);if(this.rollCount<=-Mouse.ROLLCOUNT){this.rollCount=0;return -1}else if(this.rollCount>=Mouse.ROLLCOUNT){this.rollCount=0;return 1}return 0};Mouse.prototype.end=function(e){if(this.on==false)return false;var result=this.drag;this.on=false;this.x=0;this.y=0;this.shiftX=0;this.shiftY=0;this.drag=false;this.preventEvent(e);return result};Mouse.prototype.preventEvent=function(e){e.preventDefault();e.returnValue=false;e.stopPropagation();e.cancelBubble=false};Mouse.prototype.cancelDrag=function(e){this.on=false;this.x=0;this.y=0;this.shiftX=0;this.shiftY=0;this.drag=false}})(jQuery)