/*Copyright 2006-2009 Treefly, Inc. All rights reserved.*/var snipshot={DEBUG:false,IS_SAFARI:!!(navigator.userAgent.match(/Konqueror|Safari|KHTML/gi)),MIN_LEFT:8,MIN_TOP:8,MIN_WIDTH:1,MIN_HEIGHT:1,CACHE_THRESHOLD:50,START_LOAD_TIME:500,URL_RENDER:null,FILE:null,PIXIE:null,OP_DELAY:10,BUTTON_DESELECT_DELAY:50,HISTORY:[],HISTORY_INDEX:-1,FLOATING_INFO:"floatingInfo",IMAGE_BOX:"imageBox",IMAGE_FADED_BOX:"imageFadedBox",IMAGE_FADED:"imageFaded",IMAGE:"image",NOTIFY_MESSAGE:"notifyMessage",NOTIFY_BG:"notifyBg",NOTIFY_FADE_DELAY:500,NOTIFY_FADE_SPEED:75,PROGRESS_BAR:"progressBar",PROGRESS_BOX:"progressBox"};snipshot.adjust={};snipshot.adjust.scales={tilt:{units:"°"},brightness:{units:"%"},contrast:{units:"%"},sharpness:{units:""},hue:{units:"°"},saturation:{units:"%"},exposure:{units:"%"}};snipshot.adjust.init=function(){snipshot.adjust.slider.init();snipshot.adjust.constrain.init();snipshot.adjust.hueDrag.init();};snipshot.adjust.slider={_move:null,_down:null,init:function(){var z=getElementsByTagAndClassName("DIV","slider","paletteAdjust");forEach(z,function(b){connect(b,"onmousedown",snipshot.adjust.slider.start);connect(b.parentNode,"onmousedown",snipshot.adjust.slider.jump);var j=getElementsByTagAndClassName("DIV","leftIcon",b.parentNode.parentNode)[0];var x=getElementsByTagAndClassName("DIV","rightIcon",b.parentNode.parentNode)[0];connect(j,"onmousedown",function(){snipshot.adjust.slider._setSlider(b,0);snipshot.load.loadImage();});connect(x,"onmousedown",function(){var J=parseInt(getStyle(b.parentNode,"width"));snipshot.adjust.slider._setSlider(b,J);snipshot.load.loadImage();});});connect("reset","onmousedown",function(){snipshot.adjust.slider.resetSliders();addElementClass("reset","buttonBoxActive");});connect("reset","onmouseup",function(){removeElementClass("reset","buttonBoxActive");});},resetSliders:function(){var z=snipshot.adjust.slider;var x=getElementsByTagAndClassName("DIV","sliderBox");var j=false;forEach(x,function(J){m.state.blur.setValue(0);if(J.className.indexOf("hueSliderBox")!=-1){if(snipshot.adjust.hueDrag.resetHue()){j=true;}}else{var r=getElementsByTagAndClassName("DIV","slider",J)[0];var b=getStyle(J,"width");if(b){var b=parseInt(b);if(parseInt(r.style.left)!=b/2){z._setSlider(r,b/2);j=true;}}}});if(j==true){snipshot.load.loadImage();}},start:function(x){var z=snipshot.adjust.slider;x.stop();if(x.target().className.indexOf("sliderBox")!=-1){z._target=getElementsByTagAndClassName("DIV","slider",x.target())[0];}else{z._target=x.target();}addElementClass(z._target,"down");z._sliderBoxPositionX=getElementPosition(z._target.parentNode).x;z._sliderBoxWidth=parseInt(getStyle(z._target.parentNode,"width"));z._sliderWidth=getElementDimensions(z._target).w;z._offsetX=x.mouse().page.x-getElementPosition(z._target).x;z._offsetX-=z._sliderWidth/2;z._move=connect(document,"onmousemove",z._drag);z._down=connect(document,"onmouseup",z._stop);},_drag:function(b){var x=snipshot.adjust.slider;b.stop();var z=b.mouse().page.x-x._sliderBoxPositionX;var J=z-x._offsetX;if(J<0){x._setSlider(x._target,0);}else{if(J>x._sliderBoxWidth){x._setSlider(x._target,x._sliderBoxWidth);}else{var j=z-x._offsetX;x._setSlider(x._target,j);}}},_stop:function(x){var z=snipshot.adjust.slider;disconnect(z._move);disconnect(z._down);removeElementClass(z._target,"down");snipshot.load.loadImage();},jump:function(x){var z=snipshot.adjust.slider;x.stop();z._target=x.src();z._offsetX=x.mouse().page.x-getElementPosition(z._target).x;z._slider=getElementsByTagAndClassName("DIV","slider",z._target)[0];z._sliderBoxWidth=parseInt(getStyle(z._target,"width"),10);if(z._offsetX>z._sliderBoxWidth){z._offsetX=z._sliderBoxWidth;}else{if(z._offsetX<0){z._offsetX=0;}}z._setSlider(z._slider,z._offsetX);z.start(x);},_setSlider:function(J,r){var x=snipshot.adjust.slider;setElementPosition(J,{x:r});var z=parseInt(getStyle(J.parentNode,"width"));var b=r/z;var j=J.parentNode.parentNode.id;x._slideValue(b,j);},slideFractionToValue:function(b,j){var x=snipshot.adjust.slider;var J=snipshot.adjust.scales[j];var z=b*J.scale+J.shift;if(typeof (J.precision)!="undefined"){z=Math.round(z/J.precision)*J.precision;}return z;},_slideValue:function(j,x){var z=snipshot.adjust.slider;param=z.getParam(x);slideValue=j*(param.max-param.min)+param.min;if(x=="sharpness"){if(slideValue<0){param.value=0;param=m.state.blur.getFirstParam();slideValue=Math.abs(slideValue);}if(slideValue>0){m.state.blur.setValue(0);}}param.value=slideValue;z._updateTitle(x,slideValue);return slideValue;},_updateTitle:function(j,b){var x=snipshot.adjust.slider;var J=snipshot.adjust.scales[j];var z=getElement(j).title.split(":")[0];if(j=="tilt"){b=Math.pow(b,2);}updateNodeAttributes(j,{"title":z+": "+Math.round(b)+J.units});},getParam:function(z){if(z=="brightness"||z=="contrast"||z=="saturation"){return m.state.color.params[z];}else{return m.state[z].getFirstParam();}},setAll:function(Z){var x=snipshot.adjust.slider;for(name in Z){var r=getElement(name);param=x.getParam(name);if(name=="sharpness"){if(m.state.blur.getValue()>0){param.value=0;Z[name]=m.state.blur.getValue()*-1;}if(Z[name]>0){m.state.blur.setValue(0);}}x._updateTitle(name,Z[name]);var j=(Z[name]-param.min)/(param.max-param.min);if(j>1){j=1;}if(j<0){j=0;}var b=getElementsByTagAndClassName("DIV","sliderBox",r)[0];var z=parseInt(getStyle(b,"width"));var I=j*z;if(name=="hue"){snipshot.adjust.hueDrag._setHueBackgroundPosition(I);snipshot.adjust.hueDrag.hueBarPosition=I;}else{var J=getElementsByTagAndClassName("DIV","slider",b)[0];setElementPosition(J,{x:I});}}}};snipshot.adjust.constrain={_widthHandler:null,_heightHandler:null,init:function(){connect("constrain","onclick",snipshot.adjust.constrain.toggleConstrain);snipshot.adjust.constrain.toggleConstrain();},toggleConstrain:function(){var x=snipshot.adjust.constrain;toggleElementClass("buttonBoxActive","constrain");var j=getElement("adjustWidth");var z=getElement("adjustHeight");if(x._widthHandler!=null&&x._heightHandler!=null){disconnect(x._heightHandler);disconnect(x._widthHandler);}if(hasElementClass("constrain","buttonBoxActive")){x._widthHandler=connect(j,"onchange",function(b){x._constrain(b,z,snipshot.image.ratio);});x._heightHandler=connect(z,"onchange",function(b){x._constrain(b,j,1/snipshot.image.ratio);});}else{x._widthHandler=connect(j,"onchange",function(){x._updateImage();});x._heightHandler=connect(z,"onchange",function(){x._updateImage();});}},_updateImage:function(j){var z=new Dimensions(parseInt(getElement("adjustWidth").value),parseInt(getElement("adjustHeight").value));if(snipshot.tool.current()=="resize"){var x=new Coordinates(snipshot.image.cropPos.x+snipshot.image.pos.x,snipshot.image.cropPos.y+snipshot.image.pos.y);snipshot.image.setImageBox(x,z);snipshot.load.loadImage();}else{if(snipshot.tool.current()=="crop"){if(j){snipshot.image.setCropBox(null,z,z.w/z.h);}else{snipshot.image.setCropBox(null,z);}}}getElement("adjustWidth").value=snipshot.image.cropSize.w;getElement("adjustHeight").value=snipshot.image.cropSize.h;},_constrain:function(j,b,x){j.stop();var z=snipshot.adjust.constrain;z._input=j.src();z._input.value=z._input.value.replace(/[^0-9.]/g,"");z._input.value=Math.round(z._input.value);b.value=Math.round(z._input.value/x);z._updateImage(true);}};snipshot.adjust.hueDrag={_timer:null,_shiftHandler:null,init:function(){var z=snipshot.adjust.hueDrag;disconnectAll("hueInputBar");z.hueBar=getElement("hueInputBar");z.hueBarWidth=getElementDimensions(z.hueBar).w;if(!z.hueBarPosition){z.hueBarPosition=z.hueBarWidth/2;}connect("hueInputBar","onmousedown",z.start);hueLeftArrowHandler=connect("hueLeftArrow","onmousedown",z.startShift);hueRightArrowHandler=connect("hueRightArrow","onmousedown",z.startShift);},resetHue:function(){var z=snipshot.adjust.hueDrag;if(z.hueBarPosition!=z.hueBarWidth/2){z.hueBarPosition=z.hueBarWidth/2;z._setHue(z.hueBarPosition);return true;}else{return false;}},start:function(x){var z=snipshot.adjust.hueDrag;x.stop();z._mouseStart=x.mouse().page.x;z._lastPosition=z.hueBarPosition;z._moveHandler=connect(document,"onmousemove",z._move);z._upHandler=connect(document,"onmouseup",z._stop);},_move:function(j,x){var z=snipshot.adjust.hueDrag;j.stop();z.hueBarPosition=j.mouse().page.x-z._mouseStart+z._lastPosition;z._setHue(z.hueBarPosition);},_stop:function(x){var z=snipshot.adjust.hueDrag;x.stop();disconnect(z._moveHandler);disconnect(z._upHandler);snipshot.load.loadImage();},startShift:function(x){var z=snipshot.adjust.hueDrag;x.stop();elem=x.src();z._shift(elem,1);if(z._timer==null){z._timer=setInterval(function(){z._shift(elem,2);},100);}z._shiftHandler=connect(document,"onmouseup",z.stopShift);},_shift:function(x,j){var z=snipshot.adjust.hueDrag;if(x.id=="hueLeftArrow"){z.hueBarPosition-=j;addElementClass(x,"hueLeftArrowDown");}else{if(x.id=="hueRightArrow"){z.hueBarPosition+=j;addElementClass(x,"hueRightArrowDown");}}z._setHue(z.hueBarPosition);},stopShift:function(x){var z=snipshot.adjust.hueDrag;x.stop();clearInterval(z._timer);z._timer=null;removeElementClass("hueLeftArrow","hueLeftArrowDown");removeElementClass("hueRightArrow","hueRightArrowDown");disconnect(z._shiftHandler);snipshot.load.loadImage();},_setHueBackgroundPosition:function(x){var z=snipshot.adjust.hueDrag;setStyle("hueInputBar",{"backgroundPosition":x+"px 0px"});},_setHue:function(b){var x=snipshot.adjust.hueDrag;x._setHueBackgroundPosition(b);var z=x.hueBarWidth;slideFraction=(b%z)/z;slideFraction=Math.abs(slideFraction);var j=x.hueBar.parentNode.id;snipshot.adjust.slider._slideValue(slideFraction,j);}};snipshot.box={aspectRatio:null,startPos:null,startSize:null,lastPos:null,lastSize:null,newPos:null,newSize:null,handle:null,mode:null,bounds:null,mode:null,init:function(j){var z=snipshot.box;j.stop();var x=snipshot.image.cropSize;z.aspectRatio=x.w/x.h;snipshot.control.showAll();z.startPos=snipshot.image.getImageBoxPos();z.startSize=snipshot.image.cropSize;z.handle=j.target().id;z.mode=snipshot.tool.current();if(z.mode=="resize"){z.bounds=new Coordinates(snipshot.MIN_LEFT,snipshot.MIN_TOP);}else{if(z.mode=="crop"){z.bounds=snipshot.image.pos;}}snipshot.info.show();snipshot.info.refresh(z.mode,true);connect(document,"onmousemove",z.drag);connect(document,"onmouseup",z.up);},drag:function(b){var Z=snipshot.box;b.stop();var x=b.mouse().page;var D=b.mouse().page;var j=getElement("canvas");j.pos=getElementPosition(j);x.x-=j.pos.x;x.y-=j.pos.y;if(x.x<Z.bounds.x){x.x=Z.bounds.x;}if(x.y<Z.bounds.y){x.y=Z.bounds.y;}Z.lastPos=snipshot.image.getImageBoxPos();Z.lastSize=snipshot.image.cropSize;var J=Z.lastPos;if(Z.handle=="seHandle"){Z.newSize=new Dimensions(x.x-Z.lastPos.x,x.y-Z.lastPos.y);}else{if(Z.handle=="sHandle"){Z.newSize=new Dimensions(Z.lastSize.w,x.y-Z.lastPos.y);}else{if(Z.handle=="eHandle"){Z.newSize=new Dimensions(x.x-Z.lastPos.x,Z.lastSize.h);}else{if(Z.handle=="nwHandle"){Z.newSize=new Dimensions(Z.lastSize.w-x.x+Z.lastPos.x,Z.lastSize.h-x.y+Z.lastPos.y);J=x;}else{if(Z.handle=="nHandle"){Z.newSize=new Dimensions(Z.lastSize.w,Z.lastSize.h-x.y+Z.lastPos.y);J=new Coordinates(Z.lastPos.x,x.y);}else{if(Z.handle=="wHandle"){Z.newSize=new Dimensions(Z.lastSize.w-x.x+Z.lastPos.x,Z.lastSize.h);J=new Coordinates(x.x,Z.lastPos.y);}else{if(Z.handle=="neHandle"){Z.newSize=new Dimensions(x.x-Z.lastPos.x,Z.lastSize.h-x.y+Z.lastPos.y);J=new Coordinates(Z.lastPos.x,x.y);}else{if(Z.handle=="swHandle"){Z.newSize=new Dimensions(Z.lastSize.w-x.x+Z.lastPos.x,x.y-Z.lastPos.y);J=new Coordinates(x.x,Z.lastPos.y);}}}}}}}}var r=b.modifier().shift;if(Z.handle=="swHandle"||Z.handle=="nwHandle"||Z.handle=="seHandle"||Z.handle=="neHandle"){r=!r;}if(r){if(Z.handle=="swHandle"||Z.handle=="wHandle"||Z.handle=="eHandle"){Z.newSize.h=Math.round(Z.newSize.w/Z.aspectRatio);}else{if(Z.handle!="nwHandle"){Z.newSize.w=Math.round(Z.newSize.h*Z.aspectRatio);}else{Z.newSize.w=Math.round(Z.newSize.h*Z.aspectRatio);J=new Coordinates(Z.lastPos.x+Z.lastSize.w-Z.newSize.w,x.y);}}var z=Z.lastPos.x;var I=Z.lastPos.y;if(Z.handle=="sHandle"||Z.handle=="nHandle"){z=Math.round(Z.startPos.x+(Z.startSize.w-Z.newSize.w)/2);if(Z.handle=="nHandle"){I=x.y;}J=new Coordinates(z,I);}else{if(Z.handle=="wHandle"||Z.handle=="eHandle"){I=Math.round(Z.startPos.y+(Z.startSize.h-Z.newSize.h)/2);if(Z.handle=="wHandle"){z=x.x;}J=new Coordinates(z,I);}}}if(Z.mode=="crop"){if(r){snipshot.image.setCropBox(J,Z.newSize,Z.aspectRatio);}else{snipshot.image.setCropBox(J,Z.newSize);}}else{if(Z.mode=="resize"){snipshot.image.setImageBox(J,Z.newSize);}}snipshot.info.refresh(Z.mode,true);},up:function(x){var z=snipshot.box;x.stop();snipshot.info.hide();disconnect(document,"onmousemove",z.drag);disconnect(document,"onmouseup",z.up);snipshot.palette.update("adjust");if(z.mode=="crop"){m.save();}else{if(z.mode=="resize"){snipshot.load.loadImage();}}snipshot.control.fadeAll();}};snipshot.control={handles:["nwHandle","nHandle","neHandle","eHandle","seHandle","sHandle","swHandle","wHandle"],showAll:function(z){forEach(snipshot.control.handles,function(x){setOpacity(x,1);});},fadeAll:function(x){if(!x){x=25;}var j=1;var z=window.setInterval(function(){j-=0.1;if(j<=0.5){window.clearInterval(z);}else{forEach(snipshot.control.handles,function(b){setOpacity(b,j);});}},x);}};snipshot.drag={offsetX:null,offsetY:null,elem:null,bounds:null,init:function(b){if(b.target().nodeName=="A"||b.target().nodeName=="INPUT"||b.target().nodeName=="LABEL"){return ;}var z=snipshot.drag;z.elem=b.src();var j=b.mouse().page;var x=getElementPosition(z.elem,"canvas");z.offsetX=j.x-x.x;z.offsetY=j.y-x.y;z.size=getElementDimensions(z.elem);z.bounds=new Coordinates(getElementDimensions("canvas").w-z.size.w,getElementDimensions("canvas").h-z.size.h);connect(document,"onmousemove",z.drag);connect(document,"onmouseup",z.up);},_setInsideBounds:function(z,x){if(z.x<=0){z.x=0;}if(z.y<=0){z.y=0;}if(z.x>=x.x){z.x=x.x;}return z;},drag:function(b){b.stop();var z=snipshot.drag;var j=b.mouse().page;var x=new Coordinates(j.x-z.offsetX,j.y-z.offsetY);z._setInsideBounds(x,z.bounds);setElementPosition(z.elem,x);},up:function(j){j.stop();var z=snipshot.drag;disconnect(document,"onmousemove",z.drag);disconnect(document,"onmouseup",z.up);var x=getElementPosition(snipshot.drag.elem,"canvas");if(x.x>0&&x.y>0){writeCookie(z.elem.id,serializeJSON(x));}else{writeCookie(z.elem.id,"",-1);}}};snipshot.effect={list:null,toggleFromEvent:function(z){z.stop();snipshot.effect.toggle(z.src().id);},selectAllFromState:function(){forEach(snipshot.effect.list,function(z){if(m.state[z.id].getValue()){addElementClass(z,"selected");}else{removeElementClass(z,"selected");}});},toggle:function(x){toggleElementClass("selected",x);if(m.state[x].getValue()){for(var z in m.state[x].params){m.state[x][z].set(false);}}else{for(var z in m.state[x].params){m.state[x][z].set(true);}}snipshot.load.loadImage();}};snipshot.image={size:null,cropPos:null,cropSize:null,canvasGuidePos:null,canvasGuideSize:null,src:null,ratio:null,faceCounter:0,__update:function(){var z=snipshot.image;setElementPosition(snipshot.IMAGE,{x:-z.cropPos.x,y:-z.cropPos.y});setElementDimensions(snipshot.IMAGE,z.size);setElementPosition(snipshot.IMAGE_FADED,z.pos);setElementDimensions(snipshot.IMAGE_FADED,z.size);setElementPosition(snipshot.IMAGE_FADED_BOX,z.pos);setElementDimensions(snipshot.IMAGE_FADED_BOX,z.size);setElementPosition(snipshot.IMAGE_BOX,z.getImageBoxPos());setElementDimensions(snipshot.IMAGE_BOX,z.cropSize);z.ratio=z.cropSize.w/z.cropSize.h;snipshot.init.setStateFromImageProperties();},update:function(){var z=snipshot.image;if(z.pos.x<snipshot.MIN_LEFT){z.pos.x=snipshot.MIN_LEFT;}if(z.pos.y<snipshot.MIN_TOP){z.pos.y=snipshot.MIN_TOP;}z.__update();},setCropBox:function(j,J,b){var z=snipshot.image;if(j){if(j.x<snipshot.MIN_LEFT){j.x=snipshot.MIN_LEFT;}if(j.y<snipshot.MIN_TOP){j.y=snipshot.MIN_TOP;}if(j.x<z.pos.x){j.x=z.pos.x;}if(j.y<z.pos.y){j.y=z.pos.y;}if(!J){if((z.pos.x+z.size.w)<(j.x+z.cropSize.w)){j.x=z.pos.x+z.size.w-z.cropSize.w;}if((z.pos.y+z.size.h)<(j.y+z.cropSize.h)){j.y=z.pos.y+z.size.h-z.cropSize.h;}}var x=new Coordinates((j.x-z.pos.x),(j.y-z.pos.y));}if(J){if(x){if((z.size.w-x.x)<J.w){J.w=(z.size.w-x.x);if(typeof (b)!="undefined"){J.h=Math.round(J.w/b);}}if((z.size.h-x.y)<J.h){J.h=(z.size.h-x.y);if(typeof (b)!="undefined"){J.w=Math.round(J.h*b);}}}else{if((z.size.w-z.cropPos.x)<J.w){J.w=(z.size.w-z.cropPos.x);if(typeof (b)!="undefined"){J.h=Math.round(J.w/b);}}if((z.size.h-z.cropPos.y)<J.h){J.h=(z.size.h-z.cropPos.y);if(typeof (b)!="undefined"){J.w=Math.round(J.h*b);}}}if(J.w<snipshot.MIN_WIDTH){J.w=snipshot.MIN_WIDTH;x.x=z.cropPos.x+z.cropSize.w-snipshot.MIN_WIDTH;}if(J.h<snipshot.MIN_HEIGHT){J.h=snipshot.MIN_HEIGHT;x.y=z.cropPos.y+z.cropSize.h-snipshot.MIN_HEIGHT;}}if(x){z.cropPos=x;}if(J){z.cropSize=J;}z.__update();},setGuideSection:function(J){var z=snipshot.image;var b=getElement("canvasGuide");if(J=="inner"){var j=new Dimensions(Math.min(z.canvasGuidePos.x+z.canvasGuideSize.w,z.pos.x+z.cropPos.x+z.cropSize.w)-Math.max(z.canvasGuidePos.x,z.pos.x+z.cropPos.x),Math.min(z.canvasGuidePos.y+z.canvasGuideSize.h,z.pos.y+z.cropPos.y+z.cropSize.h)-Math.max(z.canvasGuidePos.y,z.pos.y+z.cropPos.y));var x=new Coordinates(Math.max(z.canvasGuidePos.x,z.pos.x+z.cropPos.x),Math.max(z.canvasGuidePos.y,z.pos.y+z.cropPos.y));}if(J=="outer"){var j=new Dimensions(Math.max(z.canvasGuidePos.x+z.canvasGuideSize.w,z.pos.x+z.cropPos.x+z.cropSize.w)-Math.min(z.canvasGuidePos.x,z.pos.x+z.cropPos.x),Math.max(z.canvasGuidePos.y+z.canvasGuideSize.h,z.pos.y+z.cropPos.y+z.cropSize.h)-Math.min(z.canvasGuidePos.y,z.pos.y+z.cropPos.y));var x=new Coordinates(Math.min(z.canvasGuidePos.x,z.pos.x+z.cropPos.x),Math.min(z.canvasGuidePos.y,z.pos.y+z.cropPos.y));}if(!hasElementClass(b,"topbottom")){x.y=z.cropPos.y+z.pos.y;j.h=z.cropSize.h;}if(!hasElementClass(b,"leftright")){x.x=z.cropPos.x+z.pos.x;j.w=z.cropSize.w;}z.setCropBox(x,j);},setImageBox:function(b,j){var x=snipshot.image;if(b){if(b.x<snipshot.MIN_LEFT){b.x=snipshot.MIN_LEFT;}if(b.y<snipshot.MIN_TOP){b.y=snipshot.MIN_TOP;}if(j){if(j.w<snipshot.MIN_WIDTH){j.w=snipshot.MIN_WIDTH;}if(j.h<snipshot.MIN_HEIGHT){j.h=snipshot.MIN_HEIGHT;}x.cropPos=new Coordinates(Math.round(j.w/x.cropSize.w*(x.cropPos.x)),Math.round(j.h/x.cropSize.h*(x.cropPos.y)));}var b=new Coordinates(b.x-x.cropPos.x,b.y-x.cropPos.y);}if(j){if(j.w<=snipshot.MIN_WIDTH){j.w=snipshot.MIN_WIDTH;b.x=x.pos.x+x.cropSize.w-snipshot.MIN_WIDTH;}if(j.h<=snipshot.MIN_HEIGHT){j.h=snipshot.MIN_HEIGHT;b.y=x.pos.y+x.cropSize.h-snipshot.MIN_HEIGHT;}var z=new Dimensions(Math.round(j.w/x.cropSize.w*x.size.w),Math.round(j.h/x.cropSize.h*x.size.h));}if(b){x.pos=b;}if(j){x.cropSize=j;x.size=z;}else{}x.__update();},rotate:function(Z,j){var x=snipshot.image;var r=new Dimensions(x.cropSize.h,x.cropSize.w);var z=new Dimensions(x.size.h,x.size.w);if(j){var J=new Coordinates(x.cropPos.y,x.size.w-x.cropSize.w-x.cropPos.x);}else{var J=new Coordinates(z.w-r.w-x.cropPos.y,x.cropPos.x);}var b=new Coordinates((J.x+x.pos.x),(J.y+x.pos.y));if(b.x<snipshot.MIN_LEFT){x.pos.x=snipshot.MIN_LEFT;}if(b.y<snipshot.MIN_TOP){x.pos.y=snipshot.MIN_TOP;}x.cropPos=J;x.cropSize=r;x.size=z;x.__update();},getImageBoxPos:function(){var z=snipshot.image;return new Coordinates(z.pos.x+z.cropPos.x,z.pos.y+z.cropPos.y);},cropToNextFace:function(){if(m.state.rotate.getValue()!==0){return ;}var z=snipshot.image;var J=m.faces[z.faceCounter];if(m.faces[z.faceCounter+1]){z.faceCounter++;}else{z.faceCounter=0;}var x=m.state.size.width.value/m.originalSize.width;var b=m.state.size.height.value/m.originalSize.height;var j=new Coordinates(snipshot.image.pos.x+Math.round((J.x-J.w/4)*x),snipshot.image.pos.y+Math.round((J.y-J.h/3)*b));var r=new Dimensions(Math.round((J.w*6/4)*x),Math.round((J.h*5/3)*b));snipshot.image.setCropBox(j,r);snipshot.tool.select("crop");snipshot.tool.setInfobar("infoFaces");m.save();}};snipshot.info={startSize:null,refresh:function(J,b){var z=null;if(J=="resize"){var j="";z=new Coordinates(snipshot.image.pos.x+snipshot.image.cropPos.x,snipshot.image.pos.y+snipshot.image.cropPos.y);}else{z=snipshot.image.cropPos;var j="x: "+z.x+"px, y: "+z.y+"px<br />";}if(b){j+="w: "+snipshot.image.cropSize.w+"px, h: "+snipshot.image.cropSize.h+"px "+" ("+Math.round((snipshot.image.cropSize.w/snipshot.info.startSize.w)*100)+"% x "+Math.round((snipshot.image.cropSize.h/snipshot.info.startSize.h)*100)+"%)";}var x=new Coordinates(snipshot.image.pos.x+snipshot.image.cropPos.x,snipshot.image.pos.y+snipshot.image.cropPos.y+snipshot.image.cropSize.h+8);setElementPosition(snipshot.FLOATING_INFO,x);getElement(snipshot.FLOATING_INFO).innerHTML=j;},show:function(){snipshot.info.startSize=snipshot.image.cropSize;removeElementClass(snipshot.FLOATING_INFO,"disabled");},hide:function(){snipshot.info.startSize=null;addElementClass(snipshot.FLOATING_INFO,"disabled");}};snipshot.init={init:function(){if(m.services.input_options&&m.services.input_options.reapply){var j=evalJSON(readCookie("metaImage"));if(j&&j.id!=m.id){m.state=new State(j.stateDef);}}snipshot.init.setImagePropertiesFromState();try{var b=m.services.output_options;if(b.size.max&&!some(values(b.size.max),isUndefinedOrNull)){snipshot.init.hasMax=true;}if(b.size.min&&!some(values(b.size.min),isUndefinedOrNull)){snipshot.init.hasMin=true;}}catch(x){}snipshot.init.centerImageAndGuide();connect(window,"onresize",snipshot.init.centerImageAndGuide);snipshot.effect.list=getElementsByTagAndClassName("div","onoff");snipshot.effect.selectAllFromState();snipshot.init.wireButtons();snipshot.adjust.init();snipshot.init.setAllSlidersFromState();snipshot.palette.init();snipshot.load.loadImage();var z=connect(m.image,"onload",function(){snipshot.tool.select("resize");disconnect(z);});snipshot.tool.wireHandles();snipshot.control.fadeAll(75);},setImagePropertiesFromState:function(){snipshot.image.size=new Dimensions(m.state.size.width.value,m.state.size.height.value);snipshot.image.cropPos=new Coordinates(m.state.crop.x.value,m.state.crop.y.value);snipshot.image.cropSize=new Dimensions(m.state.crop.width.value,m.state.crop.height.value);},setStateFromImageProperties:function(){m.state.size.width.set(snipshot.image.size.w);m.state.size.height.set(snipshot.image.size.h);m.state.crop.x.value=snipshot.image.cropPos.x;m.state.crop.y.value=snipshot.image.cropPos.y;m.state.crop.width.value=snipshot.image.cropSize.w;m.state.crop.height.value=snipshot.image.cropSize.h;},setAllSlidersFromState:function(){var z={};for(key in snipshot.adjust.scales){param=snipshot.adjust.slider.getParam(key);z[key]=param.value;}snipshot.adjust.slider.setAll(z);},centerImageAndGuide:function(){var x=getElement("canvas");if(x.parentNode.tagName!="BODY"){var b=getElementDimensions(x.parentNode);}else{var b=getViewportDimensions();if(!snipshot.IS_SAFARI){connect(window,"onresize",snipshot.tool.markToolbarOverflow);snipshot.tool.markToolbarOverflow();}}x.pos=getElementPosition(x);if(!x.pos){var D=b.w-0;var r=b.h-78;}else{var D=b.w-x.pos.x;var r=b.h-x.pos.y;}if(m.history.length==1){var j=snipshot.image.size.w/snipshot.image.size.h;var w=D/r;var h=snipshot.MIN_LEFT*10;var c=snipshot.MIN_TOP*10;if(j<w){if((r-c)<snipshot.image.size.h){snipshot.image.size.h=r-c;snipshot.image.size.w=Math.round(snipshot.image.size.h*j);}}else{if((D-h)<snipshot.image.size.w){snipshot.image.size.w=D-h;snipshot.image.size.h=Math.round(snipshot.image.size.w/j);}}snipshot.image.cropSize=snipshot.image.size;}var I=new Coordinates(Math.round((D/2)-(snipshot.image.cropSize.w/2)),Math.round((r/2)-(snipshot.image.cropSize.h/2)));snipshot.image.pos=I;snipshot.image.setImageBox(I,snipshot.image.cropSize);if(snipshot.init.hasMax){var J=getElement("canvasGuide");var E=getElement("canvasGuideBorder");removeElementClass(J,"disabled");addElementClass(J,"leftright");addElementClass(E,"leftright");addElementClass(J,"topbottom");addElementClass(E,"topbottom");var z=m.services.output_options;if(isUndefinedOrNull(z.size.max.width)){z.size.max.width=Math.round(snipshot.image.size.w*(z.size.max.height/snipshot.image.size.h));}if(isUndefinedOrNull(z.size.max.height)){z.size.max.height=Math.round(snipshot.image.size.h*(z.size.max.width/snipshot.image.size.w));}snipshot.image.canvasGuideSize=new Dimensions(z.size.max.width,z.size.max.height);setElementDimensions(J,snipshot.image.canvasGuideSize);setElementDimensions(E,snipshot.image.canvasGuideSize);var Z=new Coordinates(Math.round((D/2)-(snipshot.image.canvasGuideSize.w/2)),Math.round((r/2)-(snipshot.image.canvasGuideSize.h/2)));setElementPosition(J,Z);snipshot.image.canvasGuidePos=new Coordinates(parseInt(getStyle(J,"left")),parseInt(getStyle(J,"top")));if(getStyle("canvasGuide","z-index")==103){connect("canvasGuide","onmousedown",function(y){var t={};forEach(snipshot.control.handles,function(F){t[F]=connect(F,"onmouseover",function(C){snipshot.box.init(C);setStyle("canvasGuide",{"z-index":103});forEach(snipshot.control.handles,function(W){disconnect(t[W]);});});});setStyle("canvasGuide",{"z-index":100});});}}},wireButtons:function(){connect("crop","onclick",snipshot.tool.selectFromEvent);connect("resize","onclick",snipshot.tool.selectFromEvent);connect("rotate","onmousedown",snipshot.tool.selectFromEvent);connect("undo","onmousedown",snipshot.tool.selectFromEvent);connect(document,"onkeydown",function(z){if(z.modifier().ctrl||z.modifier().meta){if(z.key().code==90){z.stop();snipshot.tool.button("undo",false);window.setTimeout(function(){removeElementClass("undo","selected");},snipshot.BUTTON_DESELECT_DELAY);}else{if(z.key().code==89){z.stop();snipshot.tool.button("undo",true);window.setTimeout(function(){removeElementClass("undo","selected");},snipshot.BUTTON_DESELECT_DELAY);}}}});if(isEmpty(m.faces)){hideElement("faces");}else{connect("faces","onmousedown",function(){addElementClass("faces","selected");snipshot.image.cropToNextFace();});connect("faces","onmouseup",function(){removeElementClass("faces","selected");});}forEach(["adjustHeight","adjustWidth"],function(z){connect(z,"onfocus",function(){disconnectAll(document,"onkeydown",snipshot.tool.applyCrop);});connect(z,"onblur",function(){connect(document,"onkeydown",snipshot.tool.applyCrop);});});forEach(snipshot.effect.list,function(z){var x=getFirstElementByTagAndClassName("DIV","proMsg",z);if(!x){connect(z,"onclick",snipshot.effect.toggleFromEvent);}else{if(m.isPro&&x){connect(z,"onclick",snipshot.effect.toggleFromEvent);addElementClass(x,"disabled");}else{connect(z,"onclick",function(){window.location="http://snipshot.com/pro/";});}}});forEach(["adjust","save","effects"],function(x){connect(x,"onclick",snipshot.palette.toggleFromEvent);var z="palette"+x.charAt(0).toUpperCase()+x.substr(1).toLowerCase();connect(z+"Close","onmousedown",function(){snipshot.palette.toggle(x);});connect(z,"onmousedown",snipshot.drag.init);});connect("continue","onclick",function(){addElementClass("continue","selected");});if(snipshot.init.hasMax||snipshot.init.hasMin){connect("save","onclick",snipshot.init.cropToGuide);connect("continue","onclick",function(z){z.stop();d=snipshot.init.cropToGuide();if(d===false){window.location=getNodeAttribute("continue","href");}else{d.addCallback(function(){window.location=getNodeAttribute("continue","href");});}});}connect("hires","onclick",function(z){if(z.src().checked){snipshot.palette.toggleLinks("localSave");}else{snipshot.palette.toggleLinks("localSave");}});},setLocale:function(x){if(x&&x.innerText){for(id in x.innerText){var z=[getElement(id)];if(!z[0]){continue;}while(z.length){elem=z.shift();if(elem.nodeType==3&&/\S/.test(elem.nodeValue)){elem.nodeValue=x.innerText[id];break;}else{extend(z,elem.childNodes);}}}}if(x&&x.titleText){for(id in x.titleText){var z=[getElement(id)];if(!z[0]){continue;}while(z.length){elem=z.shift();if(elem.title){elem.title=x.titleText[id];break;}else{extend(z,elem.childNodes);}}}}},cropToGuide:function(){if(snipshot.init.hasMax){snipshot.image.setGuideSection("inner");}if(snipshot.init.hasMin){snipshot.image.setGuideSection("outer");}return m.save();}};snipshot.load={opTimeout:null,loadImage:function(){if(snipshot.load.opTimeout!==null){window.clearTimeout(snipshot.load.opTimeout);}snipshot.load.opTimeout=window.setTimeout(snipshot.load.fireOp,snipshot.OP_DELAY);},fireOp:function(z){connect(snipshot.IMAGE,"onload",snipshot.load.imageLoaded);m.loadImage();snipshot.progress.start(snipshot.progress.lastLoadTime);snipshot.progress.startLoadTime=(new Date).getTime();},imageLoaded:function(x){disconnect(snipshot.IMAGE,"onload",snipshot.load.imageLoaded);snipshot.progress.done();var z=(new Date).getTime()-snipshot.progress.startLoadTime;if(snipshot.CACHE_THRESHOLD<z){snipshot.progress.lastLoadTime=z;}if(snipshot.tool.current()=="crop"){getElement(snipshot.IMAGE_FADED).src=m.image.src;}snipshot.load.effectsPreview();m.save();},effectsPreview:function(){if(snipshot.palette.effects()){var z=document.domain.substring(document.domain.indexOf("snipshot"),document.domain.length);var j=m._buildURL(m.domain,m.pathToScratch,m.inputImageType,m.outputImageType);j=j.replace(/snipshot\.jpg/,"preview.jpg");j=j.replace(/\/size[^\/]*/,"");j=j.replace(/\/crop[^\/]*/,"");var x=getElementsByTagAndClassName("DIV","effectTile");forEach(x,function(b){updateNodeAttributes(b,{"style":{"background-image":"url("+j+")"}});});}},justLoadTheImage:function(){m.loadImage();if(snipshot.tool.current()=="crop"){getElement(snipshot.IMAGE_FADED).src=m.image.src;}snipshot.load.effectsPreview();}};snipshot.move={offsetX:null,offsetY:null,mode:null,init:function(b){var z=snipshot.move;b.stop();snipshot.control.showAll();var j=b.mouse().page;var x=snipshot.image.getImageBoxPos();z.mode=snipshot.tool.current();z.offsetX=j.x-x.x;z.offsetY=j.y-x.y;if(z.mode=="crop"){snipshot.info.show();snipshot.info.refresh(z.mode,false);}connect(document,"onmousemove",z.drag);connect(document,"onmouseup",z.up);},drag:function(J){var x=snipshot.move;J.stop();var b=J.mouse().page;var j=new Coordinates(b.x-x.offsetX,b.y-x.offsetY);var z=null;if(x.mode=="crop"){snipshot.image.setCropBox(j);z=snipshot.image.cropPos;snipshot.info.refresh(x.mode,false);}else{if(x.mode=="resize"){snipshot.image.setImageBox(j);z=new Coordinates(snipshot.image.pos.x+snipshot.image.cropPos.x,snipshot.image.pos.y+snipshot.image.cropPos.y);}}},up:function(x){var z=snipshot.move;snipshot.info.hide();disconnect(document,"onmousemove",z.drag);disconnect(document,"onmouseup",z.up);if(z.mode=="crop"){m.save();}snipshot.control.fadeAll();}};snipshot.notify={delay:null,fader:null,centerElement:function(j){var x=getViewportDimensions();var b=elementDimensions(j);var z=new Coordinates(Math.round(x.w/2-b.w/2),Math.round(x.h/2-b.h/2));setElementPosition(j,z);},message:function(z){if(snipshot.notify.delay!==null||snipshot.notify.fader!==null){window.clearTimeout(snipshot.notify.delay);window.clearInterval(snipshot.notify.fader);}removeElementClass(snipshot.NOTIFY_MESSAGE,"disabled");removeElementClass(snipshot.NOTIFY_BG,"disabled");replaceChildNodes(snipshot.NOTIFY_MESSAGE,z);setOpacity(snipshot.NOTIFY_BG,0.5);setOpacity(snipshot.NOTIFY_MESSAGE,1);snipshot.notify.centerElement(snipshot.NOTIFY_MESSAGE);snipshot.notify.centerElement(snipshot.NOTIFY_BG);snipshot.notify.delay=window.setTimeout(function(){snipshot.notify.fade();},snipshot.NOTIFY_FADE_DELAY);},fade:function(){var x=1;var z=0.5;snipshot.notify.fader=window.setInterval(function(){x-=0.2;z-=0.1;if(x<=0.1){addElementClass(snipshot.NOTIFY_MESSAGE,"disabled");addElementClass(snipshot.NOTIFY_BG,"disabled");window.clearInterval(snipshot.notify.fader);snipshot.notify.delay=null;snipshot.notify.fader=null;}else{setOpacity(snipshot.NOTIFY_BG,z);setOpacity(snipshot.NOTIFY_MESSAGE,x);}},snipshot.NOTIFY_FADE_SPEED);}};snipshot.palette={init:function(){var z=snipshot.palette;if(!snipshot.IS_SAFARI){z._setInitialPos("adjust");z._setInitialPos("save");z._setInitialPos("effects");}z.update("adjust");},_setInitialPos:function(j){var Z=camelize("palette-"+j);var r=readCookie(Z);var x=evalJSON(readCookie(Z));if(x){var z=getElementDimensions("canvas");var J=getElementDimensions(Z);var b=new Coordinates(z.w-J.w,z.h-J.h);x=snipshot.drag._setInsideBounds(x,b);setElementPosition(Z,x);snipshot.palette.toggle(j);}},toggleFromEvent:function(z){z.stop();snipshot.palette.toggle(z.target().id);},toggle:function(z){var x=camelize("palette-"+z);toggleElementClass("selected",z);toggleElementClass("hidden",x);if(z=="effects"){snipshot.load.effectsPreview();}},update:function(z){if(z=="adjust"){getElement("adjustWidth").value=m.state.crop.width.value;getElement("adjustHeight").value=m.state.crop.height.value;}},adjust:function(){return hasElementClass("adjust","selected");},save:function(){return hasElementClass("save","selected");},effects:function(){return hasElementClass("effects","selected");},toggleLinks:function(x){var z=getElementsByTagAndClassName("a",null,x);forEach(z,function(b){var J=b.href.split("/");var j=J[J.length-1].split(".");if(j[0].indexOf("_hi_")!=-1){j[0]=j[0].replace("_hi_","");}else{j[0]=j[0]+"_hi_";}b.href=J.slice(0,J.length-1).join("/")+"/"+j.join(".");});}};snipshot.progress={bar:snipshot.PROGRESS_BAR,box:snipshot.PROGRESS_BOX,startLoadTime:0,completed:0,interval:null,lastLoadTime:snipshot.START_LOAD_TIME,_setBarWidth:function(z){updateNodeAttributes(snipshot.progress.bar,{"style":{"width":z+"%"}});},increment:function(){if(100<=snipshot.progress.completed){snipshot.progress._setBarWidth(100);snipshot.progress.completed=0;window.clearInterval(snipshot.progress.interval);snipshot.progress.interval=null;}else{snipshot.progress.completed+=1;snipshot.progress._setBarWidth(snipshot.progress.completed);}},start:function(z){updateNodeAttributes(snipshot.progress.box,{"style":{"display":"block"}});setOpacity(snipshot.progress.box,0.5);if(snipshot.progress.interval!==null){snipshot.progress.completed=0;snipshot.progress._setBarWidth(0);window.clearInterval(snipshot.progress.interval);}snipshot.progress.interval=window.setInterval(function(){snipshot.progress.increment();},z/100);},done:function(){snipshot.progress._setBarWidth(100);if(snipshot.progress.interval!==null){window.clearInterval(snipshot.progress.interval);}var x=0.5;var z=window.setInterval(function(){x-=0.1;if(x<=0.1){snipshot.progress.completed=0;snipshot.progress._setBarWidth(0);updateNodeAttributes(snipshot.progress.box,{"style":{"display":"none"}});window.clearInterval(z);}else{setOpacity(snipshot.progress.box,x);}},25);}};snipshot.state={restore:function(z){var x=snipshot.state;snipshot.init.setImagePropertiesFromState();snipshot.init.setAllSlidersFromState();snipshot.effect.selectAllFromState();snipshot.load.justLoadTheImage();snipshot.image.update();snipshot.palette.update("adjust");},undo:function(){if(m.restoreHistory(m.historyIndex-1)){snipshot.state.restore();}else{snipshot.notify.message(getElement("undoMessage").innerHTML);}},redo:function(){if(m.restoreHistory(m.historyIndex+1)){snipshot.state.restore();}else{snipshot.notify.message(getElement("redoMessage").innerHTML);}}};snipshot.tool={current:function(){if(hasElementClass("crop","selected")){return "crop";}else{if(hasElementClass("resize","selected")){return "resize";}}},applyCrop:function(z){if(z.type()=="keydown"&&z.key().string=="KEY_ENTER"){snipshot.tool.select("resize");}else{if(z.type()=="dblclick"){snipshot.tool.select("resize");}}},selectFromEvent:function(z){z.stop();if(snipshot.tool.current()==z.target().id&&snipshot.tool.current()=="crop"){snipshot.tool.select("resize");}else{if(z.target().id=="rotate"||z.target().id=="undo"){snipshot.tool.button(z.target().id,(z.modifier().shift||z.modifier().alt));}else{snipshot.tool.select(z.target().id);}}},deselectRotate:function(z){disconnect("rotate","onmouseup",snipshot.tool.deselectRotate);disconnect("rotate","onmouseout",snipshot.tool.deselectRotate);window.setTimeout(function(){removeElementClass("rotate","selected");},snipshot.BUTTON_DESELECT_DELAY);},deselectUndo:function(z){disconnect("undo","onmouseup",snipshot.tool.deselectUndo);disconnect("undo","onmouseout",snipshot.tool.deselectUndo);window.setTimeout(function(){removeElementClass("undo","selected");},snipshot.BUTTON_DESELECT_DELAY);},button:function(x,z){if(x=="rotate"){addElementClass("rotate","selected");connect("rotate","onmouseup",snipshot.tool.deselectRotate);connect("rotate","onmouseout",snipshot.tool.deselectRotate);if(z){m.state.rotate.degrees.value-=90;if(m.state.rotate.degrees.value<0){m.state.rotate.degrees.value=360+m.state.rotate.degrees.value;}}else{m.state.rotate.degrees.value+=90;if(270<m.state.rotate.degrees.value){m.state.rotate.degrees.value=0;}}snipshot.image.rotate(m.state.rotate.degrees.value,z);getElement(snipshot.IMAGE).src=snipshot.PIXIE;if(snipshot.tool.current()=="crop"){getElement(snipshot.IMAGE_FADED).src=snipshot.PIXIE;}snipshot.load.loadImage();}else{if(x=="undo"){addElementClass("undo","selected");connect("undo","onmouseup",snipshot.tool.deselectUndo);connect("undo","onmouseout",snipshot.tool.deselectUndo);if(z){snipshot.state.redo();}else{snipshot.state.undo();}}}},setInfobar:function(z){infos=getElementsByTagAndClassName("DIV",null,"infobar");forEach(infos,function(x){addElementClass(x,"disabled");});removeElementClass(z,"disabled");},select:function(z){removeElementClass("resize","selected");removeElementClass("crop","selected");snipshot.tool.setInfobar("infoResize");addElementClass(z,"selected");if(z=="resize"){if(snipshot.IS_SAFARI){getElement(snipshot.IMAGE_BOX).ondblclick=null;}else{disconnectAll(snipshot.IMAGE_BOX,"ondblclick");connect(snipshot.IMAGE_BOX,"ondblclick",function(){snipshot.tool.select("crop");});}disconnect(document,"onkeydown",snipshot.tool.applyCrop);disconnect(snipshot.IMAGE_FADED,"onmousedown",function(J){J.stop();});hideElement(snipshot.IMAGE_FADED);hideElement(snipshot.IMAGE_FADED_BOX);}else{if(z=="crop"){snipshot.tool.setInfobar("infoCrop");if(snipshot.IS_SAFARI){getElement(snipshot.IMAGE_BOX).ondblclick=function(){snipshot.tool.select("resize");};}else{disconnectAll(snipshot.IMAGE_BOX,"ondblclick");connect(snipshot.IMAGE_BOX,"ondblclick",snipshot.tool.applyCrop);}connect(document,"onkeydown",snipshot.tool.applyCrop);if(snipshot.image.cropPos.x==0&&snipshot.image.cropPos.y==0&&snipshot.image.size.w==snipshot.image.cropSize.w&&snipshot.image.size.h==snipshot.image.cropSize.h){var j=new Coordinates(snipshot.image.pos.x+Math.round(snipshot.image.size.w*0.1),snipshot.image.pos.y+Math.round(snipshot.image.size.h*0.1));var b=new Dimensions(Math.round(snipshot.image.size.w*0.8),Math.round(snipshot.image.size.h*0.8));snipshot.image.setCropBox(j,b,snipshot.image.size.w/snipshot.image.size.h);m.save();}var x={"top":snipshot.image.pos.y+"px","left":snipshot.image.pos.x+"px","width":snipshot.image.size.w+"px","height":snipshot.image.size.h+"px"};updateNodeAttributes(snipshot.IMAGE_FADED,{"src":m.image.src,"style":x});updateNodeAttributes(snipshot.IMAGE_FADED_BOX,{"src":m.image.src,"style":x});showElement(snipshot.IMAGE_FADED_BOX);showElement(snipshot.IMAGE_FADED);connect(snipshot.IMAGE_FADED,"onmousedown",function(J){J.stop();});}}},wireHandles:function(){forEach(snipshot.control.handles,function(z){connect(z,"onmousedown",snipshot.box.init);});connect(snipshot.IMAGE_BOX,"onmousedown",snipshot.move.init);},markToolbarOverflow:function(){var x=getElement("toolbar");x.dim=elementDimensions(x);var j=getElement("leftGroup");j.dim=elementDimensions(j);var z=getElement("overflowMarker");if(j.dim.h>=x.dim.h){showElement(z);connect(z,"onclick",function(){window.moveTo(0,0);window.resizeTo(screen.width,screen.height);hideElement(z);j.style.display="block";});}else{hideElement(z);disconnectAll(z);}}};