if(!ndpov){var ndpov={}}ndpov.VERSION="1.0.2.12";ndpov.VIEW_MODE=["view","raw","custom"];ndpov.OPERATION_MODE=["normal","point","freehand","circle","rectangle"];ndpov.CHIP_SIZE={x:256,y:256};ndpov.ANNO_MIN_SIZE=10;ndpov.IMAGE_BASE="./";ndpov.HELP_FILE_URL="./help.html";ndpov.isUsable=function(){if(!document.getElementById){return false}if(!sjsl.createXMLHttpRequest()){return false}return true};ndpov.isAnnotationValid=function(){if(ndpov.annotationValid==undefined){var B=document.createElement("div");B.style.position="absolute";B.style.left="-65536px";B.style.visibility="hidden";document.body.appendChild(B);var C=B.offsetLeft;document.body.removeChild(B);var A=document.createElement("div");var D=ndpov.createGraphic(A);ndpov.annotationValid=(C==-65536&&D!=null)}return ndpov.annotationValid};ndpov.loadSetting=function(C){var B=sjsl.getCookie(C.element.id||"ndpov")||"";var A=B.match(/([^,]+)/g);C.controls.show=0;C.controls.x=10;C.controls.y=10;C.gamma=1.8;C.brightness=0;C.contrast=1;C.red=1;C.green=1;C.blue=1;C.sharpenFilter=0;C.settings.show=0;C.settings.x=10;C.settings.y=10;C.settings.scrolling.animate=1;C.settings.scrolling.move=100;C.settings.zooming.mouseWheel=1;C.settings.zooming.moveToCursor=0;C.settings.rotation.rotation180=0;C.sharpenFilterForViewMode=0;C.viewMode=ndpov.VIEW_MODE[0];if(!A){return }if(A.length>0){C.controls.show=A[0]-0}if(A.length>1){C.controls.x=A[1]-0}if(A.length>2){C.controls.y=A[2]-0}if(A.length>3){C.gamma=A[3]-0}if(A.length>4){C.brightness=A[4]-0}if(A.length>5){C.contrast=A[5]-0}if(A.length>6){C.red=A[6]-0}if(A.length>7){C.green=A[7]-0}if(A.length>8){C.blue=A[8]-0}if(A.length>9){C.sharpenFilter=A[9]-0}if(A.length>10){C.settings.show=A[10]-0}if(A.length>11){C.settings.x=A[11]-0}if(A.length>12){C.settings.y=A[12]-0}if(A.length>13){C.settings.scrolling.animate=A[13]-0}if(A.length>14){C.settings.scrolling.move=A[14]-0}if(A.length>15){C.settings.zooming.mouseWheel=A[15]-0}if(A.length>16){C.settings.zooming.moveToCursor=A[16]-0}if(A.length>17){C.settings.rotation.rotation180=A[17]-0}if(A.length>18){C.sharpenFilterForViewMode=A[18]-0}if(A.length>19){C.viewMode=A[19]}};ndpov.saveSetting=function(B){var A=B.controls.show+","+B.controls.x+","+B.controls.y+","+B.gamma+","+B.brightness+","+B.contrast+","+B.red+","+B.green+","+B.blue+","+B.sharpenFilter+","+B.settings.show+","+B.settings.x+","+B.settings.y+","+B.settings.scrolling.animate+","+B.settings.scrolling.move+","+B.settings.zooming.mouseWheel+","+B.settings.zooming.moveToCursor+","+B.settings.rotation.rotation180+","+B.sharpenFilterForViewMode+","+B.viewMode;sjsl.setCookie(B.element.id||"ndpov",A)};ndpov.NDPov=function(B,A,C,D){this.LENS_MENU={icon:{image:ndpov.IMAGE_BASE+"ndpov.png",width:32,height:32},data:[{normalX:-64,normalY:-64,focusedX:-64,focusedY:-96,label:"1.25x"},{normalX:-96,normalY:-64,focusedX:-96,focusedY:-96,label:"2.5x"},{normalX:-128,normalY:-64,focusedX:-128,focusedY:-96,label:"5x"},{normalX:-160,normalY:-64,focusedX:-160,focusedY:-96,label:"10x"},{normalX:-192,normalY:-64,focusedX:-192,focusedY:-96,label:"20x"},{normalX:-224,normalY:-64,focusedX:-224,focusedY:-96,label:"40x"},{normalX:-256,normalY:-64,focusedX:-256,focusedY:-96,label:"63x"},{normalX:-288,normalY:-64,focusedX:-288,focusedY:-96,label:"100x"}]};this.COLOR_MENU={icon:{image:ndpov.IMAGE_BASE+"ndpov.png",width:32,height:32},line:{image:ndpov.IMAGE_BASE+"ndpov.png",x:0,y:-320,width:164,height:1},data:[{normalX:0,normalY:-192,focusedX:0,focusedY:-224,label:"Black"},{normalX:-32,normalY:-192,focusedX:-32,focusedY:-224,label:"White"},{normalX:-64,normalY:-192,focusedX:-64,focusedY:-224,label:"Red"},{normalX:-96,normalY:-192,focusedX:-96,focusedY:-224,label:"Green"},{normalX:-128,normalY:-192,focusedX:-128,focusedY:-224,label:"Blue"},{normalX:-160,normalY:-192,focusedX:-160,focusedY:-224,label:"Cyan"},{normalX:-192,normalY:-192,focusedX:-192,focusedY:-224,label:"Magenta"},{normalX:-224,normalY:-192,focusedX:-224,focusedY:-224,label:"Yellow"}]};this.ANNOTATION_MENU={icon:{image:ndpov.IMAGE_BASE+"ndpov.png",width:32,height:32},line:{image:ndpov.IMAGE_BASE+"ndpov.png",x:0,y:-320,width:164,height:1},data:[{normalX:-32,normalY:-128,focusedX:-32,focusedY:-160,label:"Hide Annotations"},{line:true},{normalX:-64,normalY:-128,focusedX:-64,focusedY:-160,label:"Pointer"},{normalX:-96,normalY:-128,focusedX:-96,focusedY:-160,label:"Freehand"},{normalX:-128,normalY:-128,focusedX:-128,focusedY:-160,label:"Circle"},{normalX:-160,normalY:-128,focusedX:-160,focusedY:-160,label:"Rectangle"},{line:true},{normalX:-192,normalY:-128,focusedX:-192,focusedY:-160,label:"Linear Measure"},{normalX:-224,normalY:-128,focusedX:-224,focusedY:-160,label:"Rectangle Area"},{normalX:-256,normalY:-128,focusedX:-256,focusedY:-160,label:"Freehand Area"},{normalX:-288,normalY:-128,focusedX:-288,focusedY:-160,label:"Freehand Perimeter"},{line:true},{normalX:0,normalY:-192,focusedX:0,focusedY:-224,label:"Choose color",subMenu:this.COLOR_MENU}]};this.DISPLAY_MODE_MENU={icon:{image:ndpov.IMAGE_BASE+"ndpov.png",width:32,height:32},line:{image:ndpov.IMAGE_BASE+"ndpov.png",x:0,y:-320,width:164,height:1},data:[{normalX:-192,normalY:0,focusedX:-192,focusedY:-32,label:"Standard (optimal for viewing)"},{normalX:-224,normalY:0,focusedX:-224,focusedY:-32,label:"Analysis (linear data)"},{normalX:-256,normalY:0,focusedX:-256,focusedY:-32,label:"Custom"},{line:true},{normalX:0,normalY:-128,focusedX:0,focusedY:-160,label:"Customise..."}]};this.element=B;if(this.element.style.position.toLowerCase()!="absolute"&&this.element.style.position.toLowerCase()!="relative"){this.element.style.position="relative"}this.NDPServe=A;this.itemID=C;this.callback=D;this.width=this.element.offsetWidth;this.height=this.element.offsetHeight;ndpov.PreLoader(["ndpov.png"],null,3);this.signIn(sjsl.bind(this,function(){if(this.initialize()&&this.callback){this.callback()}}))};ndpov.NDPov.prototype={initialize:function(){this.images;this.imagesCount={x:0,y:0};this.currentPos={x:0,y:0,z:0};this.currentLens;this.mapLens;this.mouse={x:0,y:0};this.offset={x:0,y:0};this.mode=ndpov.OPERATION_MODE[0];this.queryModal=false;this.controls={};this.settings={scrolling:{},zooming:{},rotation:{}};ndpov.loadSetting(this);this.rotation=this.settings.rotation.rotation180?180:0;this.draging=false;this.dragBeginPos={x:0,y:0};this.dragingPos={x:0,y:0};this.drawing=false;this.currentAnno=null;sjsl.eventObserver(document);this.element.style.backgroundColor="silver";this.element.style.border="1px solid gray";this.element.style.overflow="hidden";sjsl.eventObserver(this.element);this.container=document.createElement("div");this.container.style.position="absolute";this.container.style.zIndex=3;this.container.style.overflow="visible";this.container.style.left="0px";this.container.style.top="0px";this.container.style.width=this.width+"px";this.container.style.height=this.height+"px";this.element.appendChild(this.container);this.graphic=ndpov.createGraphic(this.container);if(!ndpov.isAnnotationValid()){this.graphic=null}this.annotations=new Array();this.history=new Array();this.currentHistoryPos=-1;this.setDefaultAnnoColor("#000000");this.showAnnotations(true);this.setShowMessage(true);this.currentLens=1;if(!this.getImageInfo()||!this.getAnnotations()){this.element.innerHTML="<img src='"+ndpov.IMAGE_BASE+"error.png' style='vertical-align:middle;margin:10px;' /><span style='font-size:20px;'>Item not found.</span>";return }this.getUserInfo();this.mapLens=this.getMapLens();this.element.addEventObserver("mousedown",sjsl.bind(this,this.onmousedown));this.element.addEventObserver("mouseout",sjsl.bind(this,this.onmouseout));document.addEventObserver("mouseup",sjsl.bind(this,this.onmouseup));document.addEventObserver("mousemove",sjsl.bind(this,this.onmousemove));this.element.addEventObserver("contextmenu",sjsl.bind(this,this.oncontextmenu));document.addEventObserver("keydown",sjsl.bind(this,this.onkeydown));this.element.addEventObserver("mousewheel",sjsl.bind(this,this.onmousewheel));if(window.addEventListener){window.addEventListener("DOMMouseScroll",sjsl.bind(this,this.onmousewheel),false)}var F=this.getPhysicalPos();this.currentPos.x=F.x;this.currentPos.y=F.y;this.currentLens=this.mapLens;this.initialized=true;this.resize();this.settingsDialog=null;this.imageControlWnd=null;if(this.controls.show){this.imageControlWnd=new ndpov.ImageController(this)}if(this.settings.show){this.settingsDialog=new ndpov.SettingsDialog(this)}if(!ndpov.isAnnotationValid()){var D=new sjsl.Window(this.element,"Warning",(this.width-400)/2,(this.height-110)/2,400,110);var C=document.createElement("table");C.style.padding="15px";var B=C.insertRow(-1);var E=B.insertCell(-1);var A=document.createElement("img");A.src=ndpov.IMAGE_BASE+"warning.png";E.appendChild(A);E=B.insertCell(-1);E.style.textAlign="center";E.appendChild(document.createTextNode("Annotation doesn't work on this browser."));D.client.appendChild(C);C.style.width="100%";C.style.height="100%";D.table.width="100%";D.table.height="100%"}return true},isValid:function(){if(this.initialized){return true}},exportImage:function(){if(!this.isValid()){return }if(this.queryModal){return }this.clearMessage();if(!this.permissions.exportImages){this.message("You do not have permission to export images retrieved from this server");return }location.href=this.getImageURI(this.getPosX(),this.getPosY(),this.getPosZ(),this.currentLens,this.element.offsetWidth,this.element.offsetHeight,"&Download=1")},showImageControls:function(){if(this.imageControlWnd&&this.imageControlWnd.isValid()){this.imageControlWnd.close()}else{this.imageControlWnd=new ndpov.ImageController(this)}},showSettingsDialog:function(){if(this.settingsDialog&&this.settingsDialog.isValid()){this.settingsDialog.close()}else{this.settingsDialog=new ndpov.SettingsDialog(this)}},showStatus:function(){if(!this.isValid()){return }if(this.queryModal){return }this.clearMessage();if(this.statusWnd&&this.statusWnd.isValid()){this.statusWnd.close()}else{this.statusWnd=new ndpov.StatusWnd(this)}},showHelp:function(){if(this.helpWnd&&this.helpWnd.isValid()){this.helpWnd.close()}else{this.helpWnd=new ndpov.HelpWnd(this)}},oncontextmenuselected:function(C,B,A){switch(C){case 0:this.exportImage();break;case 2:this.back();break;case 3:this.forward();break;case 5:this.setPosLensMap();break;case 6:this.onLensMenuSelected(B);break;case 8:this.onAnnotationMenuSelected(B,A);break;case 10:this.onDisplayModeMenuSelected(B);break;case 11:this.showSettingsDialog();break;case 13:this.showStatus();break;case 14:this.showHelp();break}},onLensMenuSelected:function(A){switch(A){case 0:this.setLens(1.25);break;case 1:this.setLens(2.5);break;case 2:this.setLens(5);break;case 3:this.setLens(10);break;case 4:this.setLens(20);break;case 5:this.setLens(40);break;case 6:this.setLens(63);break;case 7:this.setLens(100);break}},onAnnotationMenuSelected:function(B,A){switch(B){case 0:this.showAnnotations(!this.areAnnotationsShown());break;case 2:this.setMode("pointer");break;case 3:this.setMode("freehand");break;case 4:this.setMode("circle");break;case 5:this.setMode("rectangle");break;case 7:this.setMode("linearmeasure");break;case 8:this.setMode("rectanglearea");break;case 9:this.setMode("freehandarea");break;case 10:this.setMode("freehandperimeter");break;case 12:this.onColorMenuSelected(A);break}},onColorMenuSelected:function(A){switch(A){case 0:this.setDefaultAnnoColor("#000000");break;case 1:this.setDefaultAnnoColor("#FFFFFF");break;case 2:this.setDefaultAnnoColor("#FF0000");break;case 3:this.setDefaultAnnoColor("#00FF00");break;case 4:this.setDefaultAnnoColor("#0000FF");break;case 5:this.setDefaultAnnoColor("#00FFFF");break;case 6:this.setDefaultAnnoColor("#FF00FF");break;case 7:this.setDefaultAnnoColor("#FFFF00");break}},onDisplayModeMenuSelected:function(A){switch(A){case 0:case 1:case 2:this.setViewMode(ndpov.VIEW_MODE[A]);break;case 4:this.showImageControls();break}},oncontextmenu:function(A){return false},onmousedown:function(C){if(this.queryModal){return }this.clearMessage();this.cancelClickMovingTimer();this.mouseButton=sjsl.getMouseButton(C);var B=ndpov.rotate(this.pixelToNanoX(this.mouse.x+this.currentPos.x),this.pixelToNanoY(this.mouse.y+this.currentPos.y),360-this.rotation);var A=ndpov.rotate(this.pixelToNanoX(this.currentPos.x+this.width/2),this.pixelToNanoY(this.currentPos.y+this.height/2),360-this.rotation);switch(this.mode){case"normal":if(this.mouseButton==2){this.rubberBand=new sjsl.RectTracker(sjsl.getMouseX(C),sjsl.getMouseY(C));this.rubberBand.onfinished=sjsl.bind(this,function(E,D,L,K){var I=Math.min(E,L);var H=Math.min(D,K);var J=Math.abs(L-E);var F=Math.abs(K-D);I=this.nanoToPixelX(this.getPosX())-this.element.offsetWidth/2+I-this.offset.x+J/2;H=this.nanoToPixelY(this.getPosY())-this.element.offsetHeight/2+H-this.offset.y+F/2;var G=Math.min(this.currentLens*this.element.offsetWidth/J,this.currentLens*this.element.offsetHeight/F);this.setPosLens(this.pixelToNanoX(I),this.pixelToNanoY(H),this.getPosZ(),G)});return }this.dragBeginPos={x:this.mouse.x,y:this.mouse.y};this.dragingPos={x:this.mouse.x,y:this.mouse.y};this.draging=true;break;case"pointer":case"linearmeasure":if(this.drawing){this.saveCurrentAnnotation();this.drawing=false;this.setMode("normal")}else{this.drawing=true;if(this.mode=="pointer"){this.currentAnno=new ndpov.AnnotationPointer(this,-1,"","","",A.x,A.y,this.currentPos.z,this.currentLens,-5,-5,-5,-5,this.defaultAnnoColor)}else{if(this.mode=="linearmeasure"){this.currentAnno=new ndpov.AnnotationLinearMeasure(this,-1,"","","",A.x,A.y,this.currentPos.z,this.currentLens,-5,-5,-5,-5,this.defaultAnnoColor)}}this.annotations.push(this.currentAnno);this.currentAnno.x1=this.currentAnno.x2=B.x;this.currentAnno.y1=this.currentAnno.y2=B.y;this.updateAnnotations()}break;case"rectangle":case"rectanglearea":if(this.drawing){this.saveCurrentAnnotation();this.drawing=false;this.setMode("normal")}else{this.drawing=true;if(this.mode=="rectangle"){this.currentAnno=new ndpov.AnnotationFreeHand(this,-1,"","","",A.x,A.y,this.currentPos.z,this.currentLens,[{x:B.x,y:B.y}],this.defaultAnnoColor,0)}else{if(this.mode=="rectanglearea"){this.currentAnno=new ndpov.AnnotationFreeHand(this,-1,"","","",A.x,A.y,this.currentPos.z,this.currentLens,[{x:B.x,y:B.y}],this.defaultAnnoColor,2)}}this.annotations.push(this.currentAnno);this.updateAnnotations()}break;case"circle":if(this.drawing){this.saveCurrentAnnotation();this.drawing=false;this.setMode("normal")}else{this.drawing=true;this.currentAnno=new ndpov.AnnotationCircle(this,-1,"","","",A.x,A.y,this.currentPos.z,this.currentLens,-5,-5,0,this.defaultAnnoColor);this.annotations.push(this.currentAnno);this.currentAnno.x1=this.currentAnno.x2=B.x;this.currentAnno.y1=this.currentAnno.y2=B.y;this.updateAnnotations()}break;case"freehand":case"freehandarea":case"freehandperimeter":if(this.drawing){this.saveCurrentAnnotation();this.drawing=false;this.setMode("normal")}else{this.drawing=true;if(this.mode=="freehand"){this.currentAnno=new ndpov.AnnotationFreeHand(this,-1,"","","",A.x,A.y,this.currentPos.z,this.currentLens,[{x:B.x,y:B.y}],this.defaultAnnoColor,0)}else{if(this.mode=="freehandarea"){this.currentAnno=new ndpov.AnnotationFreeHand(this,-1,"","","",A.x,A.y,this.currentPos.z,this.currentLens,[{x:B.x,y:B.y}],this.defaultAnnoColor,2)}else{if(this.mode=="freehandperimeter"){this.currentAnno=new ndpov.AnnotationFreeHand(this,-1,"","","",A.x,A.y,this.currentPos.z,this.currentLens,[{x:B.x,y:B.y}],this.defaultAnnoColor,1)}}}this.annotations.push(this.currentAnno);this.updateAnnotations()}break}return false},onmouseup:function(B){if(this.queryModal){return }this.clearMessage();this.cancelClickMovingTimer();if(this.mouseButton==2){this.mouseButton=0;if(this.rubberBand){if(this.rubberBand.isRectValid()){this.rubberBand=null;return }this.rubberBand=null}var D=this.viewMode==ndpov.VIEW_MODE[1]?-224:this.viewMode==ndpov.VIEW_MODE[2]?-256:-192;var A={icon:{image:ndpov.IMAGE_BASE+"ndpov.png",width:32,height:32},line:{image:ndpov.IMAGE_BASE+"ndpov.png",x:0,y:-320,width:164,height:1},data:[{normalX:0,normalY:0,focusedX:0,focusedY:-32,label:"Export"},{line:true},{normalX:-32,normalY:0,focusedX:-32,focusedY:-32,label:"Back"},{normalX:-64,normalY:0,focusedX:-64,focusedY:-32,label:"Forward"},{line:true},{normalX:-96,normalY:0,focusedX:-96,focusedY:-32,label:"Map"},{normalX:-128,normalY:0,focusedX:-128,focusedY:-32,label:"lens",subMenu:this.LENS_MENU},{line:true},{normalX:-160,normalY:0,focusedX:-160,focusedY:-32,label:"Annotations",subMenu:this.ANNOTATION_MENU},{line:true},{normalX:D,normalY:0,focusedX:D,focusedY:-32,label:"Display Mode",subMenu:this.DISPLAY_MODE_MENU},{normalX:-288,normalY:0,focusedX:-288,focusedY:-32,label:"Settings"},{line:true},{normalX:0,normalY:-64,focusedX:0,focusedY:-96,label:"Status"},{normalX:-32,normalY:-64,focusedX:-32,focusedY:-96,label:"Help"}]};var C=new sjsl.Selecter(this.element,A,this.mouse.x,this.mouse.y);C.onselected=sjsl.bind(this,this.oncontextmenuselected)}else{this.mouseButton=0;switch(this.mode){case"normal":if(this.draging&&this.dragBeginPos.x-1<=this.mouse.x&&this.mouse.x<=this.dragBeginPos.x+1&&this.dragBeginPos.y-1<=this.mouse.y&&this.mouse.y<=this.dragBeginPos.y+1){this.moveTo(this.pixelToNanoX(this.currentPos.x+this.mouse.x),this.pixelToNanoY(this.currentPos.y+this.mouse.y))}else{if(this.draging){this.addHistory()}}this.draging=false;break}}},onmousemove:function(T){if(this.queryModal){return }if(this.offset.x==undefined||this.offset.y==undefined){var K=false;var G=sjsl.getSrcElement(T);var J=0,I=0;while(G){if(G==this.element){K=true;break}if(!G.style.left||!G.style.top){break}if(window.createPopup){J+=G.offsetLeft;I+=G.offsetTop}else{J+=parseInt(G.style.left);I+=parseInt(G.style.top)}G=G.parentNode}if(K){this.mouse.x=sjsl.getMouseXonSrcElement(T)+J;this.mouse.y=sjsl.getMouseYonSrcElement(T)+I;this.offset.x=sjsl.getMouseX(T)-this.mouse.x;this.offset.y=sjsl.getMouseY(T)-this.mouse.y}else{return }}else{this.mouse.x=sjsl.getMouseX(T)-this.offset.x;this.mouse.y=sjsl.getMouseY(T)-this.offset.y}var H=ndpov.rotate(this.pixelToNanoX(this.mouse.x+this.currentPos.x),this.pixelToNanoY(this.mouse.y+this.currentPos.y),360-this.rotation);switch(this.mode){case"normal":this.cancelAnnoTipTimer();if(this.draging){this.currentPos.x+=-(this.mouse.x-this.dragingPos.x);this.currentPos.y+=-(this.mouse.y-this.dragingPos.y);for(var R=0;R<this.imagesCount.y;++R){for(var Q=0;Q<this.imagesCount.x;++Q){this.images[R][Q].x+=this.mouse.x-this.dragingPos.x;this.images[R][Q].y+=this.mouse.y-this.dragingPos.y;var F=false;if(this.images[R][Q].x<-ndpov.CHIP_SIZE.x){this.images[R][Q].x+=this.imagesCount.x*ndpov.CHIP_SIZE.x;F=true}if(this.images[R][Q].y<-ndpov.CHIP_SIZE.y){this.images[R][Q].y+=this.imagesCount.y*ndpov.CHIP_SIZE.y;F=true}if(this.images[R][Q].x>=(this.imagesCount.x-1)*ndpov.CHIP_SIZE.x){this.images[R][Q].x-=this.imagesCount.x*ndpov.CHIP_SIZE.x;F=true}if(this.images[R][Q].y>=(this.imagesCount.y-1)*ndpov.CHIP_SIZE.y){this.images[R][Q].y-=this.imagesCount.y*ndpov.CHIP_SIZE.y;F=true}if(F){this.updateChip(Q,R)}this.images[R][Q].element.style.left=this.images[R][Q].x+"px";this.images[R][Q].element.style.top=this.images[R][Q].y+"px"}}this.updateAnnotations();this.dragingPos={x:this.mouse.x,y:this.mouse.y};if(this.onchange){this.onchange(this.getPosX(),this.getPosY(),this.getPosZ(),this.currentLens)}return false}else{if(this.mouse.x<0||this.mouse.y<0||this.mouse.x>=this.width||this.mouse.y>=this.height){break}if(this.container.style.visibility=="hidden"){break}var E=-1;var S=1000000;for(var R=0;R<this.annotations.length;++R){var A=this.annotations[R].getBoundingRect();if(A.left-this.currentPos.x<=this.mouse.x&&this.mouse.x<A.right-this.currentPos.x+3&&A.top-this.currentPos.y<=this.mouse.y&&this.mouse.y<A.bottom-this.currentPos.y+3){var D=((A.left+A.right)/2-this.currentPos.x-this.mouse.x)*((A.left+A.right)/2-this.currentPos.x-this.mouse.x)+((A.top+A.bottom)/2-this.currentPos.y-this.mouse.y)*((A.top+A.bottom)/2-this.currentPos.y-this.mouse.y);if(D<S){E=R;S=D}}}if(E>=0){this.element.style.cursor="pointer"}else{this.element.style.cursor="default"}var L=this;this.annoTipTimer=setTimeout(function(){if(!L.annoTip||!L.annoTip.hitTest(L.mouse.x,L.mouse.y)){if(E<0){if(L.annoTip){L.annoTip.close()}}else{if(!L.annoTip||L.annoTip.item!=E){L.showAnnoTip(E,L.mouse.x,L.mouse.y)}}}},1000)}break;case"pointer":case"linearmeasure":if(this.drawing){this.currentAnno.x2=H.x;this.currentAnno.y2=H.y;this.currentAnno.offset(0,0,this.currentLens,true);this.updateAnnotations()}return false;case"rectangle":case"rectanglearea":if(this.drawing){var B=ndpov.rotate(this.currentAnno.points[0].x,this.currentAnno.points[0].y,this.rotation);var P={x:this.pixelToNanoX(this.mouse.x+this.currentPos.x),y:this.pixelToNanoY(this.mouse.y+this.currentPos.y)};var C={x:P.x,y:B.y};var O={x:B.x,y:P.y};this.currentAnno.points[1]=ndpov.rotate(C.x,C.y,360-this.rotation);this.currentAnno.points[2]=ndpov.rotate(P.x,P.y,360-this.rotation);this.currentAnno.points[3]=ndpov.rotate(O.x,O.y,360-this.rotation);this.currentAnno.offset(0,0,this.currentLens,true);this.updateAnnotations()}break;case"circle":if(this.drawing){var J=this.nanoToPixelX(this.currentAnno.x1-H.x);var I=this.nanoToPixelY(this.currentAnno.y1-H.y);this.currentAnno.radius=this.pixelToNanoX(Math.sqrt(J*J+I*I));this.currentAnno.offset(0,0,this.currentLens,true);this.updateAnnotations()}return false;case"freehand":case"freehandarea":case"freehandperimeter":if(this.drawing){var N=this.nanoToPixelX(this.currentAnno.points[this.currentAnno.points.length-1].x-H.x);var M=this.nanoToPixelX(this.currentAnno.points[this.currentAnno.points.length-1].y-H.y);if(N*N+M*M>32){this.currentAnno.points.push({x:H.x,y:H.y});this.currentAnno.offset(0,0,this.currentLens);this.updateAnnotations()}}return false}},onmouseout:function(A){this.cancelAnnoTipTimer()},onmousewheel:function(A){var C=0;var B=false;if(document.all){C=event.wheelDelta/120;B=event.ctrlKey}else{if(A.detail){C=-A.detail/3;B=A.ctrlKey;A.stopPropagation()}}if(B||this.mouseButton==4){if(C>0){this.setPosition(this.getPosX(),this.getPosY(),Math.min(this.getPosZ()+this.zstep,this.zmax))}else{if(C<0){this.setPosition(this.getPosX(),this.getPosY(),Math.max(this.getPosZ()-this.zstep,this.zmin))}}}else{if(this.settings.zooming.mouseWheel){if(this.settings.zooming.moveToCursor){this.setPosition(this.pixelToNanoX(this.mouse.x+this.currentPos.x),this.pixelToNanoY(this.mouse.y+this.currentPos.y),this.getPosZ(),true)}if(C>0){this.zoomIn()}else{if(C<0){this.zoomOut()}}}else{if(C>0){this.setPosition(this.getPosX(),this.getPosY(),Math.min(this.getPosZ()+this.zstep,this.zmax))}else{if(C<0){this.setPosition(this.getPosX(),this.getPosY(),Math.max(this.getPosZ()-this.zstep,this.zmin))}}}}return false},onkeydown:function(C){if(this.queryModal){return }this.clearMessage();var B=false;var D=false;if(document.all){B=event.altKey;D=event.ctrlKey}else{B=C.altKey;D=C.ctrlKey}switch(sjsl.getKeyCode(C)){case 48:case 96:this.setLens(this.mapLens);return false;case 49:case 97:this.setLens(1.25);return false;case 50:case 98:this.setLens(2.5);return false;case 51:case 99:this.setLens(5);return false;case 52:case 100:this.setLens(10);return false;case 53:case 101:this.setLens(20);return false;case 54:case 102:this.setLens(40);return false;case 55:case 103:this.setLens(63);return false;case 56:case 104:this.setLens(100);return false;case 32:this.setPosLensMap();return false;case 33:this.setPosition(this.getPosX(),this.getPosY(),Math.min(this.getPosZ()+this.zstep,this.zmax));return false;case 34:this.setPosition(this.getPosX(),this.getPosY(),Math.max(this.getPosZ()-this.zstep,this.zmin));return false;case 107:case 187:this.zoomIn();return false;case 109:case 189:this.zoomOut();return false;case 37:if(B){this.back()}else{var A=this.pixelToNanoX(this.width)*this.settings.scrolling.move/100;this.moveTo(this.getPosX()-A,this.getPosY())}break;case 38:var A=this.pixelToNanoY(this.height)*this.settings.scrolling.move/100;this.moveTo(this.getPosX(),this.getPosY()-A);return false;case 39:if(B){this.forward()}else{var A=this.pixelToNanoX(this.width)*this.settings.scrolling.move/100;this.moveTo(this.getPosX()+A,this.getPosY())}return false;case 40:var A=this.pixelToNanoY(this.height)*this.settings.scrolling.move/100;this.moveTo(this.getPosX(),this.getPosY()+A);return false;case 8:this.back();return false;case 73:if(this.imageControlWnd&&this.imageControlWnd.isValid()){this.imageControlWnd.close()}else{this.imageControlWnd=new ndpov.ImageController(this)}return false;case 82:if(D||B){this.queryModal=true;new ndpov.RotationDialog(this,sjsl.bind(this,function(E){this.queryModal=false;if(E!=undefined){this.setAngle(E)}}))}else{this.setAngle(Math.floor((this.rotation+90)/90)*90)}return false}},setAngle:function(D){var C=(D-this.rotation+360)%360;if(C==0){return }for(var B=0;B<this.history.length;++B){var E=ndpov.rotate(this.history[B].x,this.history[B].y,C);this.history[B].x=E.x;this.history[B].y=E.y}this.rotation=(this.rotation+C)%360;var A=ndpov.rotate(this.getPosX(),this.getPosY(),C);this.setPosition(A.x,A.y,this.getPosZ(),true,true);this.previousAnnoCount=0;this.updateAnnotations();this.mapLens=this.getMapLens();if(this.onchange){this.onchange(this.getPosX(),this.getPosY(),this.getPosZ(),this.currentLens)}},setViewMode:function(A){if(this.queryModal){return }this.clearMessage();this.viewMode=A;ndpov.saveSetting(this);this.refresh();if(this.imageControlWnd&&this.controls.show){this.imageControlWnd.close();this.imageControlWnd=new ndpov.ImageController(this)}if(this.onchangeviewmode){this.onchangeviewmode(this.viewMode)}},controlImage:function(B,F,D,A,C,H,G){var E=false;if(!isNaN(B)){var I=(B-0)/10;if(this.gamma!=I){this.gamma=I;E=true}}if(!isNaN(F)){var I=(F-0)/100;if(this.brightness!=I){this.brightness=I;E=true}}if(!isNaN(D)){var I=(D-0+100)/100;if(this.contrast!=I){this.contrast=I;E=true}}if(!isNaN(A)){var I=(A-0+100)/100;if(this.red!=I){this.red=I;E=true}}if(!isNaN(C)){var I=(C-0+100)/100;if(this.green!=I){this.green=I;E=true}}if(!isNaN(H)){var I=(H-0+100)/100;if(this.blue!=I){this.blue=I;E=true}}if(typeof G!="undefined"){var I=G;if(this.sharpenFilter!=I){this.sharpenFilter=I-0;E=true}}if(E){this.setViewMode(ndpov.VIEW_MODE[2]);if(this.imageControlWnd){this.imageControlWnd.update(true)}else{this.refresh()}}},setMode:function(B){if(this.queryModal){return }this.clearMessage();if(!ndpov.isAnnotationValid()){B="normal";this.message("Annotation doesn't work on this browser.")}this.mode=B;if(this.currentAnno){for(var A=0;A<this.annotations.length;++A){if(this.annotations[A]==this.currentAnno){this.annotations.splice(A--,1)}}this.currentAnno.erase();this.currentAnno=null;this.updateAnnotations()}this.drawing=false;if(this.mode!="normal"){this.container.style.visibility="visible";this.updateAnnotations()}if(this.annoTip){this.annoTip.close()}this.cancelAnnoTipTimer()},showAnnotations:function(A){if(A){this.container.style.visibility="visible";this.updateAnnotations();this.ANNOTATION_MENU.data[0].label="Hide Annotations"}else{this.container.style.visibility="hidden";this.ANNOTATION_MENU.data[0].label="Show Annotations"}},areAnnotationsShown:function(){return this.container.style.visibility!="hidden"},setPosLensMap:function(A){if(!this.isValid()||this.queryModal){return }this.clearMessage();var B=this.getPhysicalPos();this.setPosLens(B.x,B.y,0,this.mapLens,A)},setPosLens:function(A,F,E,C,D){if(!this.isValid()||this.queryModal){return }this.clearMessage();var B=false;if(this.currentLens!=Math.min(C,100)){B=true}this.currentLens=Math.min(C,100);this.setPosition(A,F,E,D,B)},zoomIn:function(){if(!this.isValid()||this.queryModal){return }this.clearMessage();var A=this.currentLens;if(A<1.25){this.setLens(1.25)}else{if(A<2.5){this.setLens(2.5)}else{if(A<5){this.setLens(5)}else{if(A<10){this.setLens(10)}else{if(A<20){this.setLens(20)}else{if(A<40){this.setLens(40)}else{if(A<63){this.setLens(63)}else{if(A<100){this.setLens(100)}}}}}}}}},zoomOut:function(){if(!this.isValid()||this.queryModal){return }this.clearMessage();var A=this.currentLens;if(A>100){this.setLens(100)}else{if(A>63){this.setLens(63)}else{if(A>40){this.setLens(40)}else{if(A>20){this.setLens(20)}else{if(A>10){this.setLens(10)}else{if(A>5){this.setLens(5)}else{if(A>2.5){this.setLens(2.5)}else{if(A>1.25){this.setLens(1.25)}}}}}}}}},setPosition:function(N,K,I,L,M){if(!this.isValid()||this.queryModal){return }this.clearMessage();var A=Math.round(this.nanoToPixelX(N)-this.width/2);var O=Math.round(this.nanoToPixelY(K)-this.height/2);if(!M&&this.currentPos.z==I&&Math.abs(this.currentPos.x-A)<this.width&&Math.abs(this.currentPos.y-O)<this.height){var G=A-this.currentPos.x;var D=O-this.currentPos.y;this.currentPos.x=A;this.currentPos.y=O;for(var F=0;F<this.imagesCount.y;++F){for(var C=0;C<this.imagesCount.x;++C){this.images[F][C].x-=G;this.images[F][C].y-=D;var B=false;if(this.images[F][C].x<-ndpov.CHIP_SIZE.x){this.images[F][C].x+=this.imagesCount.x*ndpov.CHIP_SIZE.x;B=true}if(this.images[F][C].y<-ndpov.CHIP_SIZE.y){this.images[F][C].y+=this.imagesCount.y*ndpov.CHIP_SIZE.y;B=true}if(this.images[F][C].x>=(this.imagesCount.x-1)*ndpov.CHIP_SIZE.x){this.images[F][C].x-=this.imagesCount.x*ndpov.CHIP_SIZE.x;B=true}if(this.images[F][C].y>=(this.imagesCount.y-1)*ndpov.CHIP_SIZE.y){this.images[F][C].y-=this.imagesCount.y*ndpov.CHIP_SIZE.y;B=true}if(B){this.updateChip(C,F)}this.images[F][C].element.style.left=this.images[F][C].x+"px";this.images[F][C].element.style.top=this.images[F][C].y+"px"}}}else{this.currentPos.x=A;this.currentPos.y=O;this.currentPos.z=I;var H=this.currentPos.x%ndpov.CHIP_SIZE.x;var E=this.currentPos.y%ndpov.CHIP_SIZE.y;if(H<-ndpov.CHIP_SIZE.x/2){H+=ndpov.CHIP_SIZE.x}if(E<-ndpov.CHIP_SIZE.y/2){E+=ndpov.CHIP_SIZE.y}if(H>=ndpov.CHIP_SIZE.x/2){H-=ndpov.CHIP_SIZE.x}if(E>=ndpov.CHIP_SIZE.y/2){E-=ndpov.CHIP_SIZE.y}for(var F=0;F<this.imagesCount.y;++F){for(var C=0;C<this.imagesCount.x;++C){var J=this.getDefaultChipPos(C,F);this.images[F][C].x=J.x-H;this.images[F][C].y=J.y-E;this.images[F][C].element.style.left=this.images[F][C].x+"px";this.images[F][C].element.style.top=this.images[F][C].y+"px";this.updateChip(C,F)}}}if(this.annoTip){this.annoTip.close()}this.cancelAnnoTipTimer();this.cancelClickMovingTimer();if(this.onchange){this.onchange(this.getPosX(),this.getPosY(),this.getPosZ(),this.currentLens)}this.updateAnnotations();if(!L){this.addHistory()}this.draging=false},setLens:function(B,C){if(!this.isValid()||this.queryModal){return }this.clearMessage();var A=this.getPosX();var E=this.getPosY();var D=this.getPosZ();this.currentLens=Math.min(B,100);this.setPosition(A,E,D,C)},moveTo:function(F,E){if(!this.isValid()||this.queryModal){return }this.clearMessage();this.cancelAnnoTipTimer();this.cancelClickMovingTimer();if(!this.settings.scrolling.animate){this.setPosition(F,E,this.getPosZ());return }var C=this;var B=this.currentPos.x;var A=this.currentPos.y;var J=Math.round(this.nanoToPixelX(F)-this.width/2);var I=Math.round(this.nanoToPixelY(E)-this.height/2);var H=Math.round((J-B)/10);var G=Math.round((I-A)/10);var D=0;this.clickMovingTimerID=setInterval(function(){D++;var K,N;if(D>9){K=J-C.currentPos.x;N=I-C.currentPos.y;C.currentPos.x=J;C.currentPos.y=I;clearInterval(C.clickMovingTimerID);C.clickMovingTimerID=null;C.addHistory()}else{C.currentPos.x+=H;C.currentPos.y+=G}for(var M=0;M<C.imagesCount.y;++M){for(var L=0;L<C.imagesCount.x;++L){if(D>9){C.images[M][L].x-=K;C.images[M][L].y-=N}else{C.images[M][L].x-=H;C.images[M][L].y-=G}if(C.images[M][L].x<-ndpov.CHIP_SIZE.x){C.images[M][L].x+=C.imagesCount.x*ndpov.CHIP_SIZE.x;C.updateChip(L,M)}if(C.images[M][L].y<-ndpov.CHIP_SIZE.y){C.images[M][L].y+=C.imagesCount.y*ndpov.CHIP_SIZE.y;C.updateChip(L,M)}if(C.images[M][L].x>=(C.imagesCount.x-1)*ndpov.CHIP_SIZE.x){C.images[M][L].x-=C.imagesCount.x*ndpov.CHIP_SIZE.x;C.updateChip(L,M)}if(C.images[M][L].y>=(C.imagesCount.y-1)*ndpov.CHIP_SIZE.y){C.images[M][L].y-=C.imagesCount.y*ndpov.CHIP_SIZE.y;C.updateChip(L,M)}C.images[M][L].element.style.left=C.images[M][L].x+"px";C.images[M][L].element.style.top=C.images[M][L].y+"px"}}C.updateAnnotations();if(C.onchange){C.onchange(C.getPosX(),C.getPosY(),C.getPosZ(),C.currentLens)}},50)},setDefaultAnnoColor:function(B){this.defaultAnnoColor=B;var A;switch(this.defaultAnnoColor){case"#000000":A=0;break;case"#FFFFFF":A=-32;break;case"#FF0000":A=-64;break;case"#00FF00":A=-96;break;case"#0000FF":A=-128;break;case"#00FFFF":A=-160;break;case"#FF00FF":A=-192;break;case"#FFFF00":A=-224;break}this.ANNOTATION_MENU.data[12].normalX=A;this.ANNOTATION_MENU.data[12].focusedX=A},getPosX:function(){return this.pixelToNanoX(this.currentPos.x+this.width/2)},getPosY:function(){return this.pixelToNanoY(this.currentPos.y+this.height/2)},getPosZ:function(){return this.currentPos.z},getMapLens:function(){var A=this.getPixelSize();if(this.element.offsetWidth/A.width<this.element.offsetHeight/A.height){return this.sourcelens*this.element.offsetWidth/A.width}else{return this.sourcelens*this.element.offsetHeight/A.height}},getPhysicalPos:function(){return ndpov.rotate(this.physicalx,this.physicaly,this.rotation)},getPhysicalSize:function(){var B=ndpov.rotate(0,0,this.rotation);var D=ndpov.rotate(this.physicalwidth,0,this.rotation);var E=ndpov.rotate(0,this.physicalheight,this.rotation);var G=ndpov.rotate(this.physicalwidth,this.physicalheight,this.rotation);var C=Math.min(Math.min(B.x,D.x),Math.min(E.x,G.x));var H=Math.max(Math.max(B.x,D.x),Math.max(E.x,G.x));var A=Math.min(Math.min(B.y,D.y),Math.min(E.y,G.y));var F=Math.max(Math.max(B.y,D.y),Math.max(E.y,G.y));return{width:H-C,height:F-A}},getPixelSize:function(){var B=ndpov.rotate(0,0,this.rotation);var D=ndpov.rotate(this.pixelwidth,0,this.rotation);var E=ndpov.rotate(0,this.pixelheight,this.rotation);var G=ndpov.rotate(this.pixelwidth,this.pixelheight,this.rotation);var C=Math.min(Math.min(B.x,D.x),Math.min(E.x,G.x));var H=Math.max(Math.max(B.x,D.x),Math.max(E.x,G.x));var A=Math.min(Math.min(B.y,D.y),Math.min(E.y,G.y));var F=Math.max(Math.max(B.y,D.y),Math.max(E.y,G.y));return{width:H-C,height:F-A}},setShowMessage:function(A){this.showMessage=A},message:function(B){if(!this.showMessage){return }if(this.messageTimerID){clearTimeout(this.messageTimerID)}if(!this.messageArea){this.messageArea=document.createElement("div");this.element.appendChild(this.messageArea)}this.messageArea.style.position="absolute";this.messageArea.style.left="10px";this.messageArea.style.top="10px";this.messageArea.style.backgroundColor="white";this.messageArea.style.border="1px solid black";this.messageArea.style.fontSize="20px";this.messageArea.style.padding="10px";this.messageArea.innerHTML=B;var A=this;this.messageTimerID=setTimeout(function(){A.clearMessage();A.messageTimerID=null},3000)},clearMessage:function(){if(this.messageArea){this.element.removeChild(this.messageArea)}this.messageArea=null},getUserInfo:function(){this.permissions={exportImages:true};var A=sjsl.createXMLHttpRequest();if(A){var B=this.NDPServe+"?QueryPermission?ID=10";A.open("GET",B,false);A.setRequestHeader("If-Modified-Since","Thu, 01 Jun 1970 00:00:00 GMT");A.send("");if(A.readyState==4&&A.status==200){this.permissions.exportImages=A.responseText!="NO"}}},getImageInfo:function(){var A=sjsl.createXMLHttpRequest();if(A){var B=this.NDPServe+"?GetImageDetails";B+="?"+this.itemID;A.open("GET",B,false);A.setRequestHeader("If-Modified-Since","Thu, 01 Jun 1970 00:00:00 GMT");A.send("");if(A.readyState!=4||A.status!=200){return false}this.physicalx=0;if(A.responseXML.getElementsByTagName("physicalx").length>0&&A.responseXML.getElementsByTagName("physicalx")[0].childNodes.length>0){this.physicalx=parseInt(A.responseXML.getElementsByTagName("physicalx")[0].childNodes[0].nodeValue)}this.physicaly=0;if(A.responseXML.getElementsByTagName("physicaly").length>0&&A.responseXML.getElementsByTagName("physicaly")[0].childNodes.length>0){this.physicaly=parseInt(A.responseXML.getElementsByTagName("physicaly")[0].childNodes[0].nodeValue)}this.physicalwidth=0;if(A.responseXML.getElementsByTagName("physicalwidth").length>0&&A.responseXML.getElementsByTagName("physicalwidth")[0].childNodes.length>0){this.physicalwidth=parseInt(A.responseXML.getElementsByTagName("physicalwidth")[0].childNodes[0].nodeValue)}this.physicalheight=0;if(A.responseXML.getElementsByTagName("physicalheight").length>0&&A.responseXML.getElementsByTagName("physicalheight")[0].childNodes.length>0){this.physicalheight=parseInt(A.responseXML.getElementsByTagName("physicalheight")[0].childNodes[0].nodeValue)}this.pixelwidth=0;if(A.responseXML.getElementsByTagName("pixelwidth").length>0&&A.responseXML.getElementsByTagName("pixelwidth")[0].childNodes.length>0){this.pixelwidth=parseInt(A.responseXML.getElementsByTagName("pixelwidth")[0].childNodes[0].nodeValue)}this.pixelheight=0;if(A.responseXML.getElementsByTagName("pixelheight").length>0&&A.responseXML.getElementsByTagName("pixelheight")[0].childNodes.length>0){this.pixelheight=parseInt(A.responseXML.getElementsByTagName("pixelheight")[0].childNodes[0].nodeValue)}this.sourcelens=0;if(A.responseXML.getElementsByTagName("sourcelens").length>0&&A.responseXML.getElementsByTagName("sourcelens")[0].childNodes.length>0){this.sourcelens=A.responseXML.getElementsByTagName("sourcelens")[0].childNodes[0].nodeValue-0}this.name="";if(A.responseXML.getElementsByTagName("name").length>0&&A.responseXML.getElementsByTagName("name")[0].childNodes.length>0){this.name=A.responseXML.getElementsByTagName("name")[0].childNodes[0].nodeValue}this.filesize=0;if(A.responseXML.getElementsByTagName("filesize").length>0&&A.responseXML.getElementsByTagName("filesize")[0].childNodes.length>0){this.filesize=A.responseXML.getElementsByTagName("filesize")[0].childNodes[0].nodeValue-0}this.reference="";if(A.responseXML.getElementsByTagName("reference").length>0&&A.responseXML.getElementsByTagName("reference")[0].childNodes.length>0){this.reference=A.responseXML.getElementsByTagName("reference")[0].childNodes[0].nodeValue}this.uncompressedsize=0;if(A.responseXML.getElementsByTagName("uncompressedsize").length>0&&A.responseXML.getElementsByTagName("uncompressedsize")[0].childNodes.length>0){this.uncompressedsize=A.responseXML.getElementsByTagName("uncompressedsize")[0].childNodes[0].nodeValue-0}this.zmin=0;if(A.responseXML.getElementsByTagName("zmin").length>0&&A.responseXML.getElementsByTagName("zmin")[0].childNodes.length>0){this.zmin=A.responseXML.getElementsByTagName("zmin")[0].childNodes[0].nodeValue-0}this.zmax=0;if(A.responseXML.getElementsByTagName("zmax").length>0&&A.responseXML.getElementsByTagName("zmax")[0].childNodes.length>0){this.zmax=A.responseXML.getElementsByTagName("zmax")[0].childNodes[0].nodeValue-0}this.zstep=0;if(A.responseXML.getElementsByTagName("zstep").length>0&&A.responseXML.getElementsByTagName("zstep")[0].childNodes.length>0){this.zstep=A.responseXML.getElementsByTagName("zstep")[0].childNodes[0].nodeValue-0}this.rotation=0;if(A.responseXML.getElementsByTagName("viewingangle").length>0&&A.responseXML.getElementsByTagName("viewingangle")[0].childNodes.length>0){this.rotation=A.responseXML.getElementsByTagName("viewingangle")[0].childNodes[0].nodeValue-0}if(this.physicalwidth&&this.physicalheight&&this.pixelwidth&&this.pixelheight&&this.filesize&&this.uncompressedsize){return true}}},getImageURI:function(B,H,G,C,E,A,D){B=Math.round(B/10)*10;H=Math.round(H/10)*10;var F=this.NDPServe+"?Generate";F+="?"+this.itemID;F+="&FrameWidth="+E;F+="&FrameHeight="+A;F+="&XPos="+B;F+="&YPos="+H;F+="&ZPos="+G;F+="&Lens="+C;F+="&Quality=75";if(this.viewMode==ndpov.VIEW_MODE[1]){F+="&Gamma=1";F+="&Brightness=0";F+="&Contrast=1";F+="&Red=1";F+="&Green=1";F+="&Blue=1";F+="&SharpenFilter=0"}else{if(this.viewMode==ndpov.VIEW_MODE[2]){F+="&Gamma="+this.gamma;F+="&Brightness="+this.brightness;F+="&Contrast="+this.contrast;F+="&Red="+this.red;F+="&Green="+this.green;F+="&Blue="+this.blue;F+="&SharpenFilter="+this.sharpenFilter}else{F+="&Gamma=1.8";F+="&Brightness=0";F+="&Contrast=1";F+="&Red=1";F+="&Green=1";F+="&Blue=1";F+="&SharpenFilter="+this.sharpenFilterForViewMode}}F+="&Rotation="+this.rotation;if(D){F+=D}return F},getChipURI:function(A,B){return this.getImageURI(this.pixelToNanoX(this.currentPos.x+this.images[B][A].x+ndpov.CHIP_SIZE.x/2),this.pixelToNanoY(this.currentPos.y+this.images[B][A].y+ndpov.CHIP_SIZE.y/2),this.currentPos.z,this.currentLens,ndpov.CHIP_SIZE.x,ndpov.CHIP_SIZE.y)},getDefaultChipPos:function(A,B){return{x:A*ndpov.CHIP_SIZE.x-ndpov.CHIP_SIZE.x/2,y:B*ndpov.CHIP_SIZE.y-ndpov.CHIP_SIZE.y/2}},refreshAnnotations:function(){for(var A=0;A<this.annotations.length;A++){this.annotations[A].erase()}this.annotations=new Array();this.updateAnnotations();this.getAnnotations()},getAnnotations:function(){if(!this.graphic){return true}var B=sjsl.createXMLHttpRequest();if(B){var I=this.NDPServe+"?GetAnnotations";I+="?"+this.itemID;B.open("GET",I,false);B.setRequestHeader("If-Modified-Since","Thu, 01 Jun 1970 00:00:00 GMT");B.send("");if(B.readyState!=4||B.status!=200){return true}var L=B.responseXML.getElementsByTagName("ndpviewstate");for(var S=0;S<L.length;++S){var O=L[S].getAttributeNode("id").value;var A="";if(L[S].getAttributeNode("owner")){A=L[S].getAttributeNode("owner").value}var X="";if(L[S].getElementsByTagName("title").length>0&&L[S].getElementsByTagName("title")[0].childNodes.length>0){X=L[S].getElementsByTagName("title")[0].childNodes[0].nodeValue}var V="";if(L[S].getElementsByTagName("details").length>0&&L[S].getElementsByTagName("details")[0].childNodes.length>0){V=L[S].getElementsByTagName("details")[0].childNodes[0].nodeValue}var N=0;if(L[S].getElementsByTagName("x").length>0&&L[S].getElementsByTagName("x")[0].childNodes.length>0){N=L[S].getElementsByTagName("x")[0].childNodes[0].nodeValue}var K=0;if(L[S].getElementsByTagName("y").length>0&&L[S].getElementsByTagName("y")[0].childNodes.length>0){K=L[S].getElementsByTagName("y")[0].childNodes[0].nodeValue}var J=0;if(L[S].getElementsByTagName("z").length>0&&L[S].getElementsByTagName("z")[0].childNodes.length>0){J=L[S].getElementsByTagName("z")[0].childNodes[0].nodeValue}var W=0;if(L[S].getElementsByTagName("lens").length>0&&L[S].getElementsByTagName("lens")[0].childNodes.length>0){W=L[S].getElementsByTagName("lens")[0].childNodes[0].nodeValue}var H=L[S].getElementsByTagName("annotation")[0];var P=H.getAttributeNode("color").value;switch(H.getAttributeNode("type").value){case"pointer":var U=H.getElementsByTagName("x1")[0].childNodes[0].nodeValue;var E=H.getElementsByTagName("y1")[0].childNodes[0].nodeValue;var T=H.getElementsByTagName("x2")[0].childNodes[0].nodeValue;var C=H.getElementsByTagName("y2")[0].childNodes[0].nodeValue;this.annotations.push(new ndpov.AnnotationPointer(this,O,A,X,V,N,K,J,W,U,E,T,C,P));break;case"rectangle":var F=H.getElementsByTagName("measuretype")[0].childNodes[0].nodeValue;var U=H.getElementsByTagName("x1")[0].childNodes[0].nodeValue;var E=H.getElementsByTagName("y1")[0].childNodes[0].nodeValue;var T=H.getElementsByTagName("x2")[0].childNodes[0].nodeValue;var C=H.getElementsByTagName("y2")[0].childNodes[0].nodeValue;this.annotations.push(new ndpov.AnnotationRect(this,O,A,X,V,N,K,J,W,U,E,T,C,P,F));break;case"circle":var N=H.getElementsByTagName("x")[0].childNodes[0].nodeValue;var K=H.getElementsByTagName("y")[0].childNodes[0].nodeValue;var G=H.getElementsByTagName("radius")[0].childNodes[0].nodeValue;this.annotations.push(new ndpov.AnnotationCircle(this,O,A,X,V,N,K,J,W,N,K,G,P));break;case"freehand":var F=H.getElementsByTagName("measuretype")[0].childNodes[0].nodeValue;var M=H.getElementsByTagName("pointlist")[0];var R=new Array();var D=M.getElementsByTagName("point");for(var Q=0;Q<D.length;++Q){R[Q]={x:D[Q].getElementsByTagName("x")[0].childNodes[0].nodeValue,y:D[Q].getElementsByTagName("y")[0].childNodes[0].nodeValue}}this.annotations.push(new ndpov.AnnotationFreeHand(this,O,A,X,V,N,K,J,W,R,P,F));break;case"linearmeasure":var U=H.getElementsByTagName("x1")[0].childNodes[0].nodeValue;var E=H.getElementsByTagName("y1")[0].childNodes[0].nodeValue;var T=H.getElementsByTagName("x2")[0].childNodes[0].nodeValue;var C=H.getElementsByTagName("y2")[0].childNodes[0].nodeValue;this.annotations.push(new ndpov.AnnotationLinearMeasure(this,O,A,X,V,N,K,J,W,U,E,T,C,P));break}this.updateAnnotations()}return true}},saveCurrentAnnotation:function(){var A=this;this.queryModal=true;var B=new ndpov.AnnotationDialog(this.element,this.currentAnno);B.onok=function(K,C,H){A.currentAnno.title=K;A.currentAnno.details=C;A.currentAnno.color=H;A.currentAnno.offset(0,0,A.currentLens);A.updateAnnotations();var J=A.currentAnno.getXML();var E=sjsl.createXMLHttpRequest();if(E){var F=A.NDPServe+"?SaveAnnotation";E.open("POST",F,false);E.setRequestHeader("Content-Type","text/xml");E.send(J);if(E.readyState==4&&E.status==200){var G=E.responseText.indexOf("<itemid>");var I=E.responseText.indexOf("</itemid>");if(G>=0&&I>=0){var D=parseInt(E.responseText.substring(G+8,I));if(A.currentAnno.id<0){A.currentAnno.id=D}}A.currentAnno=null;A.queryModal=false;A.setMode("normal")}else{if(E.status==500){A.currentAnno=null;A.queryModal=false;A.setMode("normal");A.message(E.responseText)}else{if(A.currentAnno.id>=0){A.currentAnno=null}A.queryModal=false;A.setMode("normal")}}}else{if(A.currentAnno.id>=0){A.currentAnno=null}A.queryModal=false;A.setMode("normal")}};B.oncancel=function(){if(A.currentAnno.id>=0){A.currentAnno=null}A.queryModal=false;A.setMode("normal")}},updateChip:function(A,C,B){if(B||this.images[C][A].element.src!=this.getChipURI(A,C)){this.images[C][A].element.style.zIndex=-1;this.images[C][A].element.onload=function(D){this.style.zIndex=1};this.images[C][A].element.count=0;this.images[C][A].element.onerror=function(E){if(++this.count<10){var D=this;this.timerID=setTimeout(function(){D.src=D.src},100)}};clearTimeout(this.images[C][A].element.timerID);this.images[C][A].element.src=this.getChipURI(A,C)}},refresh:function(){for(var B=0;B<this.imagesCount.y;++B){for(var A=0;A<this.imagesCount.x;++A){this.updateChip(A,B,true)}}if(this.onrefresh){this.onrefresh()}},updateAnnotations:function(){if(this.container.style.visibility=="hidden"){return }if(!this.previousAnnoCount||!this.previousLens||this.previousLens!=this.currentLens){for(var A=0;A<this.annotations.length;++A){this.annotations[A].offset(0,0,this.currentLens)}}if(this.previousAnnoCount){for(var A=this.previousAnnoCount;A<this.annotations.length;++A){this.annotations[A].offset(0,0,this.currentLens)}}this.previousAnnoCount=this.annotations.length;this.previousLens=this.currentLens;this.container.style.left=(-this.currentPos.x)+"px";this.container.style.top=(-this.currentPos.y)+"px"},showAnnoTip:function(B,A,D){if(this.annoTip){this.annoTip.close()}var C=this;this.annoTip=new ndpov.AnnotationTip(this,B,A,D);this.annoTip.onclose=function(){C.annoTip=null}},cancelAnnoTipTimer:function(){if(this.annoTipTimer){clearTimeout(this.annoTipTimer)}this.annoTipTimer=null},cancelClickMovingTimer:function(){if(this.clickMovingTimerID){clearInterval(this.clickMovingTimerID)}this.clickMovingTimerID=null},addHistory:function(){if(!this.isValid()||this.queryModal){return }this.clearMessage();this.currentHistoryPos++;this.history.splice(this.currentHistoryPos,this.history.length-this.currentHistoryPos);this.history[this.currentHistoryPos]={x:this.getPosX(),y:this.getPosY(),z:this.getPosZ(),lens:this.currentLens}},forward:function(){if(!this.isValid()||this.queryModal){return }this.clearMessage();if(this.currentHistoryPos>=this.history.length-1){return }this.currentHistoryPos++;this.setPosLens(this.history[this.currentHistoryPos].x,this.history[this.currentHistoryPos].y,this.history[this.currentHistoryPos].z,this.history[this.currentHistoryPos].lens,true)},back:function(){if(!this.isValid()||this.queryModal){return }this.clearMessage();if(this.currentHistoryPos<1){return }this.currentHistoryPos--;this.setPosLens(this.history[this.currentHistoryPos].x,this.history[this.currentHistoryPos].y,this.history[this.currentHistoryPos].z,this.history[this.currentHistoryPos].lens,true)},signIn:function(A){this.queryModal=true;var B=new ndpov.SignInDialog(this.element,this.NDPServe,sjsl.bind(this,function(){this.queryModal=true;if(A){A()}}))},resize:function(){var G=this.getPosX();var D=this.getPosY();this.width=this.element.offsetWidth;this.height=this.element.offsetHeight;if(!this.isValid()){return }this.offset.x=undefined;this.offset.y=undefined;this.container.style.width=this.width+"px";this.container.style.height=this.height+"px";var A=Math.floor((this.width+ndpov.CHIP_SIZE.x)/ndpov.CHIP_SIZE.x)+1;var F=Math.floor((this.height+ndpov.CHIP_SIZE.y)/ndpov.CHIP_SIZE.y)+1;if(!this.mask){this.mask=document.createElement("div");this.mask.style.position="relative";this.mask.style.backgroundColor="gray";this.mask.style.zIndex=0;this.element.appendChild(this.mask)}this.mask.style.width=this.width+"px";this.mask.style.height=this.height+"px";if(A!=this.imagesCount.x||F!=this.imagesCount.y){for(var C=0;C<this.imagesCount.y;++C){for(var B=0;B<this.imagesCount.x;++B){this.element.removeChild(this.images[C][B].element)}}this.imagesCount.x=A;this.imagesCount.y=F;this.images=new Array(this.imagesCount.y);for(var C=0;C<this.imagesCount.y;++C){this.images[C]=new Array(this.imagesCount.x);for(var B=0;B<this.imagesCount.x;++B){var E=this.getDefaultChipPos(B,C);this.images[C][B]={element:new Image(ndpov.CHIP_SIZE.x,ndpov.CHIP_SIZE.y),x:E.x,y:E.y};this.images[C][B].element.galleryimg="false";this.images[C][B].element.style.position="absolute";this.images[C][B].element.style.left=this.images[C][B].x+"px";this.images[C][B].element.style.top=this.images[C][B].y+"px";this.element.appendChild(this.images[C][B].element)}}}this.mapLens=this.getMapLens();if(this.graphic){this.graphic.resize()}this.setPosition(G,D,this.currentPos.z,true,true)},pixelToNanoX:function(B,A){if(!A){A=this.currentLens}return Math.round(B*(this.sourcelens*(this.physicalwidth/this.pixelwidth))/A)},pixelToNanoY:function(B,A){if(!A){A=this.currentLens}return Math.round(B*(this.sourcelens*(this.physicalheight/this.pixelheight))/A)},nanoToPixelX:function(B,A){if(!A){A=this.currentLens}return B*A/(this.sourcelens*(this.physicalwidth/this.pixelwidth))},nanoToPixelY:function(B,A){if(!A){A=this.currentLens}return B*A/(this.sourcelens*(this.physicalheight/this.pixelheight))}};ndpov.Annotation=function(){};ndpov.Annotation.prototype={initialize:function(F,C,D,K,A,L,J,I,G,E,B,H){this.viewer=F;this.id=C;this.owner=D;this.title=K;this.details=A;this.x=L;this.y=J;this.z=I;this.lens=G;this.graphic=B||(this.viewer?this.viewer.graphic:null);this.color=E;this.bold=2;this.type=H;if(this.graphic){this.smallAnno=this.graphic.ellipse(0,0,0,1,1,this.color,this.bold)}},getType:function(){return this.type},erase:function(){this.graphic.erase(this.smallAnno)},adjustBoundingRect:function(C){if(C.right<C.left){var B=C.left;C.left=C.right;C.right=B}if(C.bottom<C.top){var B=C.top;C.top=C.bottom;C.bottom=B}if(C.right-C.left<ndpov.ANNO_MIN_SIZE){var A=(C.left+C.right)/2;C.left=A-ndpov.ANNO_MIN_SIZE/2;C.right=A+ndpov.ANNO_MIN_SIZE/2}if(C.bottom-C.top<ndpov.ANNO_MIN_SIZE){var D=(C.top+C.bottom)/2;C.top=D-ndpov.ANNO_MIN_SIZE/2;C.bottom=D+ndpov.ANNO_MIN_SIZE/2}return C},drawDotIfNecessary:function(A,G,B,D){if(!this.smallAnno){return false}var C=this.getBoundingRect(B);if(!D&&C.right-C.left<=ndpov.ANNO_MIN_SIZE&&C.bottom-C.top<=ndpov.ANNO_MIN_SIZE){var E=C.left+(C.right-C.left)/2-A;var F=C.top+(C.bottom-C.top)/2-G;if(isNaN(E)||isNaN(F)){return }this.smallAnno.set(E,F,ndpov.ANNO_MIN_SIZE/2,1,1,this.color,this.bold,this.color);return true}this.smallAnno.set(0,0,0,1,1,this.color,this.bold);return false},createLabel:function(){this.label=document.createElement("div");this.graphic.element.appendChild(this.label);this.label.style.position="absolute";this.label.style.color=this.color;this.label.style.fontSize="20px";this.label.style.fontWeight="bold"}};ndpov.AnnotationPointer=function(){this.initialize.apply(this,arguments)};ndpov.AnnotationPointer.prototype=new ndpov.Annotation();ndpov.AnnotationPointer.prototype.initialize=function(H,E,F,N,A,O,L,J,I,D,M,C,K,G,B){ndpov.Annotation.prototype.initialize.apply(this,[H,E,F,N,A,O,L,J,I,G,B,"pointer"]);this.x1=D;this.y1=M;this.x2=C;this.y2=K;this.element=this.graphic.line(0,0,0,0,this.color,this.bold);this.element1=this.graphic.line(0,0,0,0,this.color,this.bold);this.element2=this.graphic.line(0,0,0,0,this.color,this.bold)};ndpov.AnnotationPointer.prototype.offset=function(K,J,H,G){if(!this.element){return }if(this.drawDotIfNecessary(K,J,H,G)){this.element.set(0,0,0,0,this.color,this.bold);this.element1.set(0,0,0,0,this.color,this.bold);this.element2.set(0,0,0,0,this.color,this.bold);return }var I=ndpov.rotate(this.x1,this.y1,this.viewer.rotation);var E=this.viewer.nanoToPixelX(I.x,H)-K;var B=this.viewer.nanoToPixelY(I.y,H)-J;I=ndpov.rotate(this.x2,this.y2,this.viewer.rotation);var D=this.viewer.nanoToPixelX(I.x,H)-K;var A=this.viewer.nanoToPixelY(I.y,H)-J;if(isNaN(E)||isNaN(B)||isNaN(D)||isNaN(A)){return }this.element.set(E,B,D,A,this.color,this.bold);var F=Math.sqrt((D-E)*(D-E)+(A-B)*(A-B));var C=((D-E)*Math.cos(45*Math.PI/180)-(A-B)*Math.sin(45*Math.PI/180))/2+E;var L=((D-E)*Math.sin(45*Math.PI/180)+(A-B)*Math.cos(45*Math.PI/180))/2+B;this.element1.set(E,B,C,L,this.color,this.bold);C=((D-E)*Math.cos(-45*Math.PI/180)-(A-B)*Math.sin(-45*Math.PI/180))/2+E;L=((D-E)*Math.sin(-45*Math.PI/180)+(A-B)*Math.cos(-45*Math.PI/180))/2+B;this.element2.set(E,B,C,L,this.color,this.bold)};ndpov.AnnotationPointer.prototype.erase=function(){this.graphic.erase(this.element);this.graphic.erase(this.element1);this.graphic.erase(this.element2);ndpov.Annotation.prototype.erase.apply(this,[])};ndpov.AnnotationPointer.prototype.getBoundingRect=function(A){A=A||this.viewer.currentLens;var C=ndpov.rotate(this.x1,this.y1,this.viewer.rotation);var B=ndpov.rotate(this.x2,this.y2,this.viewer.rotation);var D={left:this.viewer.nanoToPixelX(Math.min(C.x,B.x),A),top:this.viewer.nanoToPixelY(Math.min(C.y,B.y),A),right:this.viewer.nanoToPixelX(Math.max(C.x,B.x),A),bottom:this.viewer.nanoToPixelY(Math.max(C.y,B.y),A)};return this.adjustBoundingRect(D)};ndpov.AnnotationPointer.prototype.getXML=function(){this.viewer.itemID.match(/ItemID=(.*)/i);var A=RegExp.$1;return'<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><ndpserverequest><param name="ItemID" type="text">'+A+'</param><param name="annotation" type="xml"><ndpviewstate'+(this.id>=0?' id="'+this.id+'"':"")+"><title>"+ndpov.textToSendingMessage(this.title)+"</title><details>"+ndpov.textToSendingMessage(this.details)+"</details><x>"+this.x+"</x><y>"+this.y+"</y><z>"+this.z+"</z><lens>"+this.lens+'</lens><annotation type="pointer" displayname="Pointer Annotation" color="'+this.color+'"><x1>'+this.x1+"</x1><y1>"+this.y1+"</y1><x2>"+this.x2+"</x2><y2>"+this.y2+"</y2></annotation></ndpviewstate></param></ndpserverequest>"};ndpov.AnnotationLinearMeasure=function(){this.initialize.apply(this,arguments)};ndpov.AnnotationLinearMeasure.prototype=new ndpov.Annotation();ndpov.AnnotationLinearMeasure.prototype.initialize=function(H,E,F,N,A,O,L,J,I,D,M,C,K,G,B){ndpov.Annotation.prototype.initialize.apply(this,[H,E,F,N,A,O,L,J,I,G,B,"linearmeasure"]);this.x1=D;this.y1=M;this.x2=C;this.y2=K;this.element=this.graphic.line(0,0,0,0,this.color,this.bold);this.element1=this.graphic.line(0,0,0,0,this.color,this.bold);this.element2=this.graphic.line(0,0,0,0,this.color,this.bold);this.createLabel()};ndpov.AnnotationLinearMeasure.prototype.offset=function(M,L,I,H){if(!this.element){return }if(this.drawDotIfNecessary(M,L,I,H)){this.element.set(0,0,0,0,this.color,this.bold);this.element1.set(0,0,0,0,this.color,this.bold);this.element2.set(0,0,0,0,this.color,this.bold);this.label.innerHTML="";return }var K=ndpov.rotate(this.x1,this.y1,this.viewer.rotation);var F=this.viewer.nanoToPixelX(K.x,I)-M;var C=this.viewer.nanoToPixelY(K.y,I)-L;K=ndpov.rotate(this.x2,this.y2,this.viewer.rotation);var E=this.viewer.nanoToPixelX(K.x,I)-M;var A=this.viewer.nanoToPixelY(K.y,I)-L;if(isNaN(F)||isNaN(C)||isNaN(E)||isNaN(A)){return }this.element.set(F,C,E,A,this.color,this.bold);var G=Math.sqrt((E-F)*(E-F)+(A-C)*(A-C));var D=((E-F)*Math.cos(90*Math.PI/180)-(A-C)*Math.sin(90*Math.PI/180))*15/G+F;var O=((E-F)*Math.sin(90*Math.PI/180)+(A-C)*Math.cos(90*Math.PI/180))*15/G+C;var B=((E-F)*Math.cos(-90*Math.PI/180)-(A-C)*Math.sin(-90*Math.PI/180))*15/G+F;var N=((E-F)*Math.sin(-90*Math.PI/180)+(A-C)*Math.cos(-90*Math.PI/180))*15/G+C;this.element1.set(B,N,D,O,this.color,this.bold);D=((E-F)*Math.cos(-90*Math.PI/180)-(A-C)*Math.sin(-90*Math.PI/180))*15/G+E;O=((E-F)*Math.sin(-90*Math.PI/180)+(A-C)*Math.cos(-90*Math.PI/180))*15/G+A;var B=((E-F)*Math.cos(90*Math.PI/180)-(A-C)*Math.sin(90*Math.PI/180))*15/G+E;var N=((E-F)*Math.sin(90*Math.PI/180)+(A-C)*Math.cos(90*Math.PI/180))*15/G+A;this.element2.set(B,N,D,O,this.color,this.bold);this.label.style.left=((F+E)/2)+"px";this.label.style.top=((C+A)/2)+"px";var J=this.viewer.pixelToNanoX(G,I);if(J<1000){if(J<10){J=Math.floor(J*100)/100}else{if(J<100){J=Math.floor(J*10)/10}else{J=Math.floor(J)}}this.label.innerHTML=J+"nm"}else{if(J<1000000){J/=1000;if(J<10){J=Math.floor(J*100)/100}else{if(J<100){J=Math.floor(J*10)/10}else{J=Math.floor(J)}}this.label.innerHTML=J+"μm"}else{J/=1000000;if(J<10){J=Math.floor(J*100)/100}else{if(J<100){J=Math.floor(J*10)/10}else{J=Math.floor(J)}}this.label.innerHTML=J+"mm"}}this.label.style.color=this.color};ndpov.AnnotationLinearMeasure.prototype.erase=function(){this.graphic.erase(this.element);this.graphic.erase(this.element1);this.graphic.erase(this.element2);this.graphic.element.removeChild(this.label);ndpov.Annotation.prototype.erase.apply(this,[])};ndpov.AnnotationLinearMeasure.prototype.getBoundingRect=function(A){A=A||this.viewer.currentLens;var C=ndpov.rotate(this.x1,this.y1,this.viewer.rotation);var B=ndpov.rotate(this.x2,this.y2,this.viewer.rotation);var D={left:this.viewer.nanoToPixelX(Math.min(C.x,B.x),A),top:this.viewer.nanoToPixelY(Math.min(C.y,B.y),A),right:this.viewer.nanoToPixelX(Math.max(C.x,B.x),A),bottom:this.viewer.nanoToPixelY(Math.max(C.y,B.y),A)};return this.adjustBoundingRect(D)};ndpov.AnnotationLinearMeasure.prototype.getXML=function(){this.viewer.itemID.match(/ItemID=(.*)/i);var A=RegExp.$1;return'<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><ndpserverequest><param name="ItemID" type="text">'+A+'</param><param name="annotation" type="xml"><ndpviewstate'+(this.id>=0?' id="'+this.id+'"':"")+"><title>"+ndpov.textToSendingMessage(this.title)+"</title><details>"+ndpov.textToSendingMessage(this.details)+"</details><x>"+this.x+"</x><y>"+this.y+"</y><z>"+this.z+"</z><lens>"+this.lens+'</lens><annotation type="linearmeasure" displayname="Linear Measurement" color="'+this.color+'"><x1>'+this.x1+"</x1><y1>"+this.y1+"</y1><x2>"+this.x2+"</x2><y2>"+this.y2+"</y2></annotation></ndpviewstate></param></ndpserverequest>"};ndpov.AnnotationRect=function(){this.initialize.apply(this,arguments)};ndpov.AnnotationRect.prototype=new ndpov.Annotation();ndpov.AnnotationRect.prototype.initialize=function(I,F,G,O,A,P,M,K,J,E,N,D,L,H,C,B){ndpov.Annotation.prototype.initialize.apply(this,[I,F,G,O,A,P,M,K,J,H,B,"rectangle"]);this.x1=E;this.y1=N;this.x2=D;this.y2=L;this.measure=C;if(this.measure==2){this.createLabel()}this.element=this.graphic.polygon([{x:0,y:0}],this.color,this.bold)};ndpov.AnnotationRect.prototype.offset=function(N,L,H,G){if(!this.element){return }if(this.drawDotIfNecessary(N,L,H,G)){this.element.set([{x:0,y:0}],this.color,this.bold);if(this.label){this.label.innerHTML=""}return }var J=new Array();var P=new Array();J[0]=ndpov.rotate(this.x1,this.y1,this.viewer.rotation);P[0]={x:this.viewer.nanoToPixelX(J[0].x,H)-N,y:this.viewer.nanoToPixelY(J[0].y,H)-L};J[1]=ndpov.rotate(this.x2,this.y1,this.viewer.rotation);P[1]={x:this.viewer.nanoToPixelX(J[1].x,H)-N,y:this.viewer.nanoToPixelY(J[1].y,H)-L};J[2]=ndpov.rotate(this.x2,this.y2,this.viewer.rotation);P[2]={x:this.viewer.nanoToPixelX(J[2].x,H)-N,y:this.viewer.nanoToPixelY(J[2].y,H)-L};J[3]=ndpov.rotate(this.x1,this.y2,this.viewer.rotation);P[3]={x:this.viewer.nanoToPixelX(J[3].x,H)-N,y:this.viewer.nanoToPixelY(J[3].y,H)-L};if(this.measure&&this.label){var B=0;var M=0;for(var E=0;E<J.length;++E){var F=E+1;if(F==J.length){F=0}B+=J[E].x*J[F].y-J[F].x*J[E].y;M+=Math.sqrt((J[F].x-J[E].x)*(J[F].x-J[E].x)+(J[F].y-J[E].y)*(J[F].y-J[E].y))}B/=2;B=Math.abs(B);if(this.measure==1){if(M<1000){if(M<10){M=Math.floor(M*100)/100}else{if(M<100){M=Math.floor(M*10)/10}else{M=Math.floor(M)}}this.label.innerHTML=M+"nm"}else{if(M<1000000){M/=1000;if(M<10){M=Math.floor(M*100)/100}else{if(M<100){M=Math.floor(M*10)/10}else{M=Math.floor(M)}}this.label.innerHTML=M+"μm"}else{M/=1000000;if(M<10){M=Math.floor(M*100)/100}else{if(M<100){M=Math.floor(M*10)/10}else{M=Math.floor(M)}}this.label.innerHTML=M+"mm"}}}else{if(this.measure==2){if(B<1000){if(B<10){B=Math.floor(B*100)/100}else{if(B<100){B=Math.floor(B*10)/10}else{B=Math.floor(B)}}this.label.innerHTML=B+"nm<sup>2</sup>"}else{if(B<1000000000){B/=1000000;if(B<1){B=Math.floor(B*1000)/1000}else{if(B<10){B=Math.floor(B*100)/100}else{if(B<100){B=Math.floor(B*10)/10}else{B=Math.floor(B)}}}this.label.innerHTML=B+"μm<sup>2</sup>"}else{B/=1000000000000;if(B<1){B=Math.floor(B*1000)/1000}else{if(B<10){B=Math.floor(B*100)/100}else{if(B<100){B=Math.floor(B*10)/10}else{B=Math.floor(B)}}}this.label.innerHTML=B+"mm<sup>2</sup>"}}}}var O=-10000;var A=-10000;for(var E=0;E<P.length;++E){if(O<P[E].x){O=P[E].x}if(A<P[E].y){A=P[E].y}}var D=100000;var C=0,K=0;for(var E=0;E<P.length;++E){var I=(P[E].x-O)*(P[E].x-O)+(P[E].y-A)*(P[E].y-A);if(I<D||E==0){D=I;C=P[E].x;K=P[E].y}}if(!isNaN(C)&&!isNaN(K)){this.label.style.left=C+"px";this.label.style.top=K+"px";this.label.style.color=this.color}}this.element.set(P,this.color,this.bold)};ndpov.AnnotationRect.prototype.erase=function(){this.graphic.erase(this.element);if(this.label){this.graphic.element.removeChild(this.label)}ndpov.Annotation.prototype.erase.apply(this,[])};ndpov.AnnotationRect.prototype.getBoundingRect=function(B){B=B||this.viewer.currentLens;var E={left:100000,top:100000,right:-100000,bottom:-100000};var D=[];D[0]=ndpov.rotate(this.x1,this.y1,this.viewer.rotation);D[1]=ndpov.rotate(this.x2,this.y1,this.viewer.rotation);D[2]=ndpov.rotate(this.x2,this.y2,this.viewer.rotation);D[3]=ndpov.rotate(this.x1,this.y2,this.viewer.rotation);for(var C=0;C<D.length;++C){var A=this.viewer.nanoToPixelX(D[C].x,B);var F=this.viewer.nanoToPixelY(D[C].y,B);if(E.left>A){E.left=A}if(E.right<A){E.right=A}if(E.top>F){E.top=F}if(E.bottom<F){E.bottom=F}}return this.adjustBoundingRect(E)};ndpov.AnnotationRect.prototype.getXML=function(){this.viewer.itemID.match(/ItemID=(.*)/i);var A=RegExp.$1;return'<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><ndpserverequest><param name="ItemID" type="text">'+A+'</param><param name="annotation" type="xml"><ndpviewstate'+(this.id>=0?' id="'+this.id+'"':"")+"><title>"+ndpov.textToSendingMessage(this.title)+"</title><details>"+ndpov.textToSendingMessage(this.details)+"</details><x>"+this.x+"</x><y>"+this.y+"</y><z>"+this.z+"</z><lens>"+this.lens+'</lens><annotation type="rectangle" displayname="Rectangular Annotation" color="'+this.color+'"><measuretype>'+this.measure+"</measuretype><x1>"+this.x1+"</x1><y1>"+this.y1+"</y1><x2>"+this.x2+"</x2><y2>"+this.y2+"</y2></annotation></ndpviewstate></param></ndpserverequest>"};ndpov.AnnotationCircle=function(){this.initialize.apply(this,arguments)};ndpov.AnnotationCircle.prototype=new ndpov.Annotation();ndpov.AnnotationCircle.prototype.initialize=function(G,D,E,M,A,N,K,J,H,C,L,I,F,B){ndpov.Annotation.prototype.initialize.apply(this,[G,D,E,M,A,N,K,J,H,F,B,"circle"]);this.x1=C;this.y1=L;this.radius=I;this.element=this.graphic.ellipse(0,0,1,1,1,this.color,this.bold)};ndpov.AnnotationCircle.prototype.offset=function(A,H,C,E){if(!this.element){return }if(this.drawDotIfNecessary(A,H,C,E)){this.element.set(0,0,0,1,1,this.color,this.bold);return }var B=ndpov.rotate(this.x1,this.y1,this.viewer.rotation);var F=this.viewer.nanoToPixelX(B.x,C)-A;var G=this.viewer.nanoToPixelY(B.y,C)-H;var D=this.viewer.nanoToPixelX(this.radius,C);if(isNaN(F)||isNaN(G)||isNaN(D)){return }this.element.set(F,G,D,1,1,this.color,this.bold)};ndpov.AnnotationCircle.prototype.getBoundingRect=function(A){A=A||this.viewer.currentLens;var B=ndpov.rotate(this.x1,this.y1,this.viewer.rotation);var D=this.viewer.nanoToPixelX(this.radius,A);var C={left:this.viewer.nanoToPixelX(B.x,A)-D,top:this.viewer.nanoToPixelY(B.y,A)-D,right:this.viewer.nanoToPixelX(B.x,A)+D,bottom:this.viewer.nanoToPixelY(B.y,A)+D};return this.adjustBoundingRect(C)};ndpov.AnnotationCircle.prototype.erase=function(){this.graphic.erase(this.element);ndpov.Annotation.prototype.erase.apply(this,[])};ndpov.AnnotationCircle.prototype.getXML=function(){this.viewer.itemID.match(/ItemID=(.*)/i);var A=RegExp.$1;return'<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><ndpserverequest><param name="ItemID" type="text">'+A+'</param><param name="annotation" type="xml"><ndpviewstate'+(this.id>=0?' id="'+this.id+'"':"")+"><title>"+ndpov.textToSendingMessage(this.title)+"</title><details>"+ndpov.textToSendingMessage(this.details)+"</details><x>"+this.x+"</x><y>"+this.y+"</y><z>"+this.z+"</z><lens>"+this.lens+'</lens><annotation type="circle" displayname="Circular Annotation" color="'+this.color+'"><x>'+this.x1+"</x><y>"+this.y1+"</y><radius>"+this.radius+"</radius></annotation></ndpviewstate></param></ndpserverequest>"};ndpov.AnnotationFreeHand=function(){this.initialize.apply(this,arguments)};ndpov.AnnotationFreeHand.prototype=new ndpov.Annotation();ndpov.AnnotationFreeHand.prototype.initialize=function(G,D,E,K,A,L,J,I,H,M,F,C,B){ndpov.Annotation.prototype.initialize.apply(this,[G,D,E,K,A,L,J,I,H,F,B,"freehand"]);this.points=M;this.measure=C;if(this.measure){this.createLabel()}this.element=this.graphic.polygon([{x:0,y:0}],this.color,this.bold)};ndpov.AnnotationFreeHand.prototype.offset=function(N,M,H,G){if(!this.element){return }if(this.drawDotIfNecessary(N,M,H,G)){this.element.set([{x:0,y:0}],this.color,this.bold);if(this.label){this.label.innerHTML=""}return }var P=new Array();for(var E=0;E<this.points.length;++E){var J=ndpov.rotate(this.points[E].x,this.points[E].y,this.viewer.rotation);P[E]={x:this.viewer.nanoToPixelX(J.x,H)-N,y:this.viewer.nanoToPixelY(J.y,H)-M}}if(this.measure&&this.label){var B=0;var L=0;for(var E=0;E<this.points.length;++E){var F=E+1;if(F==this.points.length){F=0}B+=this.points[E].x*this.points[F].y-this.points[F].x*this.points[E].y;L+=Math.sqrt((this.points[F].x-this.points[E].x)*(this.points[F].x-this.points[E].x)+(this.points[F].y-this.points[E].y)*(this.points[F].y-this.points[E].y))}B/=2;B=Math.abs(B);if(this.measure==1){if(L<1000){if(L<10){L=Math.floor(L*100)/100}else{if(L<100){L=Math.floor(L*10)/10}else{L=Math.floor(L)}}this.label.innerHTML=L+"nm"}else{if(L<1000000){L/=1000;if(L<10){L=Math.floor(L*100)/100}else{if(L<100){L=Math.floor(L*10)/10}else{L=Math.floor(L)}}this.label.innerHTML=L+"μm"}else{L/=1000000;if(L<10){L=Math.floor(L*100)/100}else{if(L<100){L=Math.floor(L*10)/10}else{L=Math.floor(L)}}this.label.innerHTML=L+"mm"}}}else{if(this.measure==2){if(B<1000){if(B<10){B=Math.floor(B*100)/100}else{if(B<100){B=Math.floor(B*10)/10}else{B=Math.floor(B)}}this.label.innerHTML=B+"nm<sup>2</sup>"}else{if(B<1000000000){B/=1000000;if(B<1){B=Math.floor(B*1000)/1000}else{if(B<10){B=Math.floor(B*100)/100}else{if(B<100){B=Math.floor(B*10)/10}else{B=Math.floor(B)}}}this.label.innerHTML=B+"μm<sup>2</sup>"}else{B/=1000000000000;if(B<1){B=Math.floor(B*1000)/1000}else{if(B<10){B=Math.floor(B*100)/100}else{if(B<100){B=Math.floor(B*10)/10}else{B=Math.floor(B)}}}this.label.innerHTML=B+"mm<sup>2</sup>"}}}}var O=-10000;var A=-10000;for(var E=0;E<this.points.length;++E){if(O<P[E].x){O=P[E].x}if(A<P[E].y){A=P[E].y}}var D=100000;var C=0,K=0;for(var E=0;E<this.points.length;++E){var I=(P[E].x-O)*(P[E].x-O)+(P[E].y-A)*(P[E].y-A);if(I<D||E==0){D=I;C=P[E].x;K=P[E].y}}if(!isNaN(C)&&!isNaN(K)){this.label.style.left=C+"px";this.label.style.top=K+"px";this.label.style.color=this.color}}this.element.set(P,this.color,this.bold)};ndpov.AnnotationFreeHand.prototype.getBoundingRect=function(B){B=B||this.viewer.currentLens;var D={left:100000,top:100000,right:-100000,bottom:-100000};for(var C=0;C<this.points.length;++C){var F=ndpov.rotate(this.points[C].x,this.points[C].y,this.viewer.rotation);var A=this.viewer.nanoToPixelX(F.x,B);var E=this.viewer.nanoToPixelY(F.y,B);if(D.left>A){D.left=A}if(D.right<A){D.right=A}if(D.top>E){D.top=E}if(D.bottom<E){D.bottom=E}}return this.adjustBoundingRect(D)};ndpov.AnnotationFreeHand.prototype.erase=function(){this.graphic.erase(this.element);if(this.label){this.graphic.element.removeChild(this.label)}ndpov.Annotation.prototype.erase.apply(this,[])};ndpov.AnnotationFreeHand.prototype.getXML=function(){this.viewer.itemID.match(/ItemID=(.*)/i);var C=RegExp.$1;var A='<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><ndpserverequest><param name="ItemID" type="text">'+C+'</param><param name="annotation" type="xml"><ndpviewstate'+(this.id>=0?' id="'+this.id+'"':"")+"><title>"+ndpov.textToSendingMessage(this.title)+"</title><details>"+ndpov.textToSendingMessage(this.details)+"</details><x>"+this.x+"</x><y>"+this.y+"</y><z>"+this.z+"</z><lens>"+this.lens+'</lens><annotation type="freehand" displayname="Freehand Annotation" color="'+this.color+'"><measuretype>'+this.measure+"</measuretype><closed>1</closed><pointlist>";for(var B=0;B<this.points.length;++B){A+="<point><x>"+this.points[B].x+"</x><y>"+this.points[B].y+"</y></point>"}A+="</pointlist></annotation></ndpviewstate></param></ndpserverequest>";return A};ndpov.AnnotationDialog=function(G,E){var F=this;this.element=G;this.dialog=document.createElement("div");var I=document.createElement("img");I.src=ndpov.IMAGE_BASE+"annodlg.png";I.width=500;I.height=116;this.dialog.appendChild(I);var K=document.createElement("div");K.innerHTML="Name";this.dialog.appendChild(K);this.titleEdit=document.createElement("input");this.titleEdit.type="text";this.titleEdit.style.width="500px";if(E){this.titleEdit.value=E.title}this.dialog.appendChild(this.titleEdit);var A=document.createElement("div");A.innerHTML="Details";this.dialog.appendChild(A);this.detailsEdit=document.createElement("textarea");this.detailsEdit.style.width="500px";this.detailsEdit.rows=5;if(E){this.detailsEdit.value=E.details}this.dialog.appendChild(this.detailsEdit);var F=this;var D=document.createElement("div");this.dialog.appendChild(D);D.align="center";D.style.margin="5px";this.colorTip=new Array();this.colorTip[0]=new Image(32,32);this.colorTip[0].src=ndpov.IMAGE_BASE+"black.png";this.colorTip[0].style.verticalAlign="middle";this.colorTip[0].style.margin="2px";this.colorTip[0].onclick=function(){F.setColor("#000000")};D.appendChild(this.colorTip[0]);this.colorTip[1]=new Image(32,32);this.colorTip[1].src=ndpov.IMAGE_BASE+"white.png";this.colorTip[1].style.verticalAlign="middle";this.colorTip[1].style.margin="2px";this.colorTip[1].onclick=function(){F.setColor("#FFFFFF")};D.appendChild(this.colorTip[1]);this.colorTip[2]=new Image(32,32);this.colorTip[2].src=ndpov.IMAGE_BASE+"red.png";this.colorTip[2].style.verticalAlign="middle";this.colorTip[2].style.margin="2px";this.colorTip[2].onclick=function(){F.setColor("#FF0000")};D.appendChild(this.colorTip[2]);this.colorTip[3]=new Image(32,32);this.colorTip[3].src=ndpov.IMAGE_BASE+"green.png";this.colorTip[3].style.verticalAlign="middle";this.colorTip[3].style.margin="2px";this.colorTip[3].onclick=function(){F.setColor("#00FF00")};D.appendChild(this.colorTip[3]);this.colorTip[4]=new Image(32,32);this.colorTip[4].src=ndpov.IMAGE_BASE+"blue.png";this.colorTip[4].style.verticalAlign="middle";this.colorTip[4].style.margin="2px";this.colorTip[4].onclick=function(){F.setColor("#0000FF")};D.appendChild(this.colorTip[4]);this.colorTip[5]=new Image(32,32);this.colorTip[5].src=ndpov.IMAGE_BASE+"cyan.png";this.colorTip[5].style.verticalAlign="middle";this.colorTip[5].style.margin="2px";this.colorTip[5].onclick=function(){F.setColor("#00FFFF")};D.appendChild(this.colorTip[5]);this.colorTip[6]=new Image(32,32);this.colorTip[6].src=ndpov.IMAGE_BASE+"magenta.png";this.colorTip[6].style.verticalAlign="middle";this.colorTip[6].style.margin="2px";this.colorTip[6].onclick=function(){F.setColor("#FF00FF")};D.appendChild(this.colorTip[6]);this.colorTip[7]=new Image(32,32);this.colorTip[7].src=ndpov.IMAGE_BASE+"yellow.png";this.colorTip[7].style.verticalAlign="middle";this.colorTip[7].style.margin="2px";this.colorTip[7].onclick=function(){F.setColor("#FFFF00")};D.appendChild(this.colorTip[7]);this.setColor(E.color);var H=document.createElement("center");this.dialog.appendChild(H);var M=document.createElement("table");var L=M.insertRow(0);var C=L.insertCell(0);var N=L.insertCell(1);H.appendChild(M);var J=document.createElement("button");J.style.width="100px";J.style.backgroundColor="white";C.appendChild(J);J.innerHTML="<center style='font-weight:bold;font-size:20px;'>OK</center>";J.onclick=function(){if(F.onok){F.onok(F.titleEdit.value,F.detailsEdit.value,F.color)}F.close()};var B=document.createElement("button");B.style.width="100px";B.style.backgroundColor="white";N.appendChild(B);B.innerHTML="<center style='font-weight:bold;font-size:20px;'>Cancel</center>";B.onclick=function(){if(F.oncancel){F.oncancel()}F.close()};this.dialog.style.position="absolute";this.dialog.style.zIndex=110;this.dialog.style.backgroundColor="white";this.dialog.style.border="1px solid black";this.dialog.style.padding="10px";this.dialog.style.fontSize="20px";G.appendChild(this.dialog);this.dialog.style.left=((G.offsetWidth-this.dialog.offsetWidth)/2)+"px";this.dialog.style.top=((G.offsetHeight-this.dialog.offsetHeight)/2)+"px"};ndpov.AnnotationDialog.prototype={close:function(){this.element.removeChild(this.dialog)},setColor:function(A){for(var B=0;B<this.colorTip.length;++B){this.colorTip[B].width=32;this.colorTip[B].height=32}switch(A){default:A="#000000";this.colorTip[0].width=40;this.colorTip[0].height=40;break;case"#FFFFFF":this.colorTip[1].width=40;this.colorTip[1].height=40;break;case"#FF0000":this.colorTip[2].width=40;this.colorTip[2].height=40;break;case"#00FF00":this.colorTip[3].width=40;this.colorTip[3].height=40;break;case"#0000FF":this.colorTip[4].width=40;this.colorTip[4].height=40;break;case"#00FFFF":this.colorTip[5].width=40;this.colorTip[5].height=40;break;case"#FF00FF":this.colorTip[6].width=40;this.colorTip[6].height=40;break;case"#FFFF00":this.colorTip[7].width=40;this.colorTip[7].height=40;break}this.color=A}};ndpov.AnnotationTip=function(B,V,G,F){this.viewer=B;this.item=V;var E=B.annotations[V];this.annoTip=document.createElement("div");this.annoTip.style.overflow="hidden";this.annoTip.style.position="absolute";if(G+300<B.element.offsetWidth){this.annoTip.style.left=G+"px"}else{this.annoTip.style.left=(G-330)+"px"}this.annoTip.style.width="330px";this.annoTip.style.zIndex=110;this.annoTip.style.border="1px solid black";this.annoTip.style.backgroundColor="white";this.annoTip.style.cursor="default";this.annoTip.style.visibility="hidden";B.element.appendChild(this.annoTip);sjsl.eventObserver(this.annoTip);var T=document.createElement("table");this.annoTip.appendChild(T);var d=T.insertRow(0);var Y=d.insertCell(0);var A=document.createElement("button");A.style.backgroundColor="white";A.innerHTML="<img src='"+ndpov.IMAGE_BASE+"annotation.png' width='32px' />";var M=this;A.onclick=function(){var f={icon:{image:ndpov.IMAGE_BASE+"ndpov.png",width:32,height:32},data:[{normalX:-32,normalY:-256,focusedX:-32,focusedY:-288,label:"Goto"},{normalX:-64,normalY:-256,focusedX:-64,focusedY:-288,label:"Edit"},{normalX:-96,normalY:-256,focusedX:-96,focusedY:-288,label:"Delete"}]};var g=new sjsl.Selecter(M.annoTip,f,A.offsetLeft,A.offsetTop+A.offsetHeight);g.onselected=function(h){M.close();switch(h){case 0:var l=ndpov.rotate(E.x,E.y,B.rotation);B.setPosLens(l.x,l.y,E.z,E.lens);break;case 1:B.currentAnno=B.annotations[V];B.saveCurrentAnnotation();break;case 2:if(B.annotations[V].id<0){B.annotations[V].erase();B.annotations.splice(V,1);B.updateAnnotations();break}var j=sjsl.createXMLHttpRequest();if(j){var k=B.NDPServe+"?DeleteAnnotation";k+="?AnnotationID="+B.annotations[V].id;j.open("GET",k,true);j.onreadystatechange=function(){if(j.readyState!=4){return }if(j.status==200){B.annotations[V].erase();B.annotations.splice(V,1);B.updateAnnotations()}if(j.status==500){B.message(j.responseText)}};j.send("")}break}}};Y.appendChild(A);Y.style.width=A.offsetWidth+"px";var X=d.insertCell(1);if(B.annotations[V].title){X.innerHTML="<b>"+E.title+"</b>"}else{X.innerHTML="<b>Annotation</b>"}X.style.width=(this.annoTip.offsetWidth-Y.offsetWidth)+"px";X.style.fontSize="20px";var b=T.insertRow(1);var C=b.insertCell(0);C.colSpan=2;C.style.fontSize="0px";C.innerHTML="<img src='"+ndpov.IMAGE_BASE+"line2.png' vspace=1 />";if(E.details){var Z=T.insertRow(2);var N=Z.insertCell(0);N.colSpan=2;N.style.textAlign="center";var J=document.createElement("img");J.src=ndpov.IMAGE_BASE+"line2.png";J.vspace=1;J.style.display="block";N.appendChild(J);var S=document.createElement("iframe");S.frameBorder="0";S.style.border="none";S.style.width=(this.annoTip.offsetWidth-10)+"px";N.appendChild(S);S.contentWindow.document.open();S.contentWindow.document.write("<body></body>");S.contentWindow.document.close();var K=S.contentWindow.document.createElement("div");S.contentWindow.document.body.appendChild(K);var I=E.details;I=I.replace(/\r\n/g,"<br>");I=I.replace(/\r/g,"<br>");I=I.replace(/\n/g,"<br>");K.innerHTML=I;K.style.position="absolute";K.style.overflow="scroll";K.style.left="0px";K.style.top="0px";K.style.width=S.offsetWidth+"px";K.style.height=Math.min(300,K.offsetHeight)+"px";S.style.height=(K.offsetHeight+5)+"px";K.style.overflow="auto"}if(E.owner){var W=T.insertRow(-1);var a=W.insertCell(0);a.colSpan=2;a.style.fontSize="0px";a.innerHTML="<img src='"+ndpov.IMAGE_BASE+"line2.png' vspace=1 />";var U=T.insertRow(-1);var D=U.insertCell(0);D.colSpan=2;D.style.fontSize="20px";D.innerHTML="<img src='"+ndpov.IMAGE_BASE+"annotationowner.png' hspace=5 style='vertical-align:middle;' />"+E.owner}var H=Math.min(330,C.offsetWidth);var P=Math.floor(H*B.element.offsetHeight/B.element.offsetWidth);C.style.height=P+"px";var c=E.lens*H/B.element.offsetWidth;var R=document.createElement("div");R.style.position="relative";var e=ndpov.rotate(E.x,E.y,B.rotation);var O=document.createElement("img");O.count=0;O.onerror=function(){if(++this.count<10){var f=this;this.timerID=setTimeout(function(){f.src=f.src},1000)}};clearTimeout(O.timerID);O.src=B.getImageURI(e.x,e.y,E.z,c,H,P);R.appendChild(O);C.appendChild(R);var L=document.createElement("div");L.style.position="absolute";L.style.left="0px";L.style.top="0px";L.style.width=H+"px";L.style.height=P+"px";L.style.zIndex=2;R.appendChild(L);this.graphic=ndpov.createGraphic(L);var Q=null;switch(E.getType()){case"pointer":Q=new ndpov.AnnotationPointer(B,V,"",E.title,E.details,E.x,E.y,E.z,E.lens,E.x1,E.y1,E.x2,E.y2,E.color,this.graphic);break;case"linearmeasure":Q=new ndpov.AnnotationLinearMeasure(B,V,"",E.title,E.details,E.x,E.y,E.z,E.lens,E.x1,E.y1,E.x2,E.y2,E.color,this.graphic);break;case"rectangle":Q=new ndpov.AnnotationRect(B,V,"",E.title,E.details,E.x,E.y,E.z,E.lens,E.x1,E.y1,E.x2,E.y2,E.color,E.measure,this.graphic);break;case"circle":Q=new ndpov.AnnotationCircle(B,V,"",E.title,E.details,E.x,E.y,E.z,E.lens,E.x1,E.y1,E.radius,E.color,this.graphic);break;case"freehand":Q=new ndpov.AnnotationFreeHand(B,V,"",E.title,E.details,E.x,E.y,E.z,E.lens,E.points,E.color,E.measure,this.graphic);break}if(Q){var e=ndpov.rotate(Q.x,Q.y,B.rotation);Q.offset(B.nanoToPixelX(e.x,c)-H/2,B.nanoToPixelY(e.y,c)-P/2,Q.lens*H/B.element.offsetWidth,true)}if(F+this.annoTip.offsetHeight<B.element.offsetHeight){if(F+this.annoTip.offsetHeight>B.element.offsetHeight){F=B.element.offsetHeight-this.annoTip.offsetHeight-1}}else{F-=this.annoTip.offsetHeight}if(F<0){F=0}this.annoTip.style.top=F+"px";this.annoTip.style.visibility="visible";this.onmousedownID=this.annoTip.addEventObserver("mousedown",sjsl.bind(this,this.onmousedown));this.onmousedownParentID=document.addEventObserver("mousedown",sjsl.bind(this,this.onmousedownParent));this.onmousemoveParentID=document.addEventObserver("mousemove",sjsl.bind(this,this.onmousemoveParent))};ndpov.AnnotationTip.prototype={close:function(){if(this.annoTip){this.annoTip.removeEventObserver(this.onmousedownID)}document.removeEventObserver(this.onmousedownParentID);document.removeEventObserver(this.onmousemoveParentID);if(this.viewer&&this.annoTip){this.viewer.element.removeChild(this.annoTip);this.annoTip=null;if(this.onclose){this.onclose()}}},onmousedown:function(A){sjsl.cancelBubble(A);return false},onmousemoveParent:function(C){var A=this.viewer.annotations[this.item].getBoundingRect();if(this.hitTest(this.viewer.mouse.x,this.viewer.mouse.y)||(A.left-this.viewer.currentPos.x<=this.viewer.mouse.x&&this.viewer.mouse.x<A.right-this.viewer.currentPos.x+3&&A.top-this.viewer.currentPos.y<=this.viewer.mouse.y&&this.viewer.mouse.y<A.bottom-this.viewer.currentPos.y+3)){if(this.timerID){clearTimeout(this.timerID)}this.timerID=null}else{var B=this;if(!this.timerID){this.timerID=setTimeout(function(){B.close()},500)}}},onmousedownParent:function(A){this.close()},hitTest:function(A,B){if(parseInt(this.annoTip.style.left)<=A&&A<parseInt(this.annoTip.style.left)+this.annoTip.offsetWidth&&parseInt(this.annoTip.style.top)<=B&&B<parseInt(this.annoTip.style.top)+this.annoTip.offsetHeight){return true}return false}};ndpov.SignInDialog=function(B,A,E){this.element=B;this.NDPServe=A;this.callback=E;if(this.querySignedIn()){if(this.callback){this.callback()}return }this.wrap=document.createElement("div");this.wrap.style.position="absolute";this.wrap.style.left="0px";this.wrap.style.top="0px";this.wrap.style.width=this.element.offsetWidth+"px";this.wrap.style.height=this.element.offsetHeight+"px";this.wrap.style.zIndex=20;this.wrap.style.backgroundColor="white";this.element.appendChild(this.wrap);this.dialog=document.createElement("div");this.dialog.align="center";this.dialog.style.position="absolute";this.dialog.style.fontSize="20px";this.dialog.style.backgroundColor="white";this.dialog.style.border="1px solid black";var S=new Image(322,137);S.src=ndpov.IMAGE_BASE+"ndp.png";S.style.display="block";this.dialog.appendChild(S);S=new Image(322,2);S.src=ndpov.IMAGE_BASE+"line2.png";S.style.display="block";this.dialog.appendChild(S);this.text=document.createElement("div");this.text.style.margin="10px";this.text.innerHTML="Please sign in.";this.dialog.appendChild(this.text);S=new Image(322,2);S.src=ndpov.IMAGE_BASE+"line2.png";S.style.display="block";this.dialog.appendChild(S);var L=document.createElement("table");L.style.margin="10px";this.dialog.appendChild(L);var R=L.insertRow(0);var N=R.insertCell(0);N.style.fontSize="20px";N.innerHTML="Username";var M=R.insertCell(1);this.userEdit=document.createElement("input");this.userEdit.type="text";this.userEdit.style.width="150px";M.appendChild(this.userEdit);var P=L.insertRow(1);var F=P.insertCell(0);F.style.fontSize="20px";F.innerHTML="Password";var D=P.insertCell(1);this.passwordEdit=document.createElement("input");this.passwordEdit.type="password";this.passwordEdit.style.width="150px";D.appendChild(this.passwordEdit);var O=L.insertRow(2);var K=O.insertCell(0);var J=O.insertCell(1);J.style.fontSize="20px";var I=document.createElement("button");I.align="center";I.style.fontSize="20px";I.style.backgroundColor="white";I.innerHTML="Sign in";J.appendChild(I);I.onclick=sjsl.bind(this,this.onsignin);var H=new Image(322,2);H.src=ndpov.IMAGE_BASE+"line2.png";H.style.display="block";this.dialog.appendChild(H);var Q=document.createElement("button");Q.align="center";Q.style.margin="10px";Q.style.fontSize="20px";Q.style.backgroundColor="white";Q.innerHTML="Sign in as Guest";this.dialog.appendChild(Q);Q.onclick=sjsl.bind(this,this.onsigninasguest);var G=new Image(322,2);G.src=ndpov.IMAGE_BASE+"line2.png";G.style.display="block";this.dialog.appendChild(G);var C=new Image(322,42);C.src=ndpov.IMAGE_BASE+"hamamatsu.png";C.style.display="block";this.dialog.appendChild(C);this.wrap.appendChild(this.dialog);this.dialog.style.left=((this.element.offsetWidth-this.dialog.offsetWidth)/2)+"px";this.dialog.style.top=((this.element.offsetHeight-this.dialog.offsetHeight)/2)+"px";this.dialog.onkeydown=sjsl.bind(this,this.onkeydown)};ndpov.SignInDialog.prototype={close:function(){this.element.removeChild(this.wrap)},onkeydown:function(A){if(sjsl.getKeyCode(A)==13){this.onsignin();return false}},onsignin:function(){var A=sjsl.createXMLHttpRequest();if(A){A.open("POST",this.NDPServe,false);A.setRequestHeader("Content-Type","application/x-www-form-urlencoded");A.send("Username="+this.userEdit.value+"&Password="+this.passwordEdit.value+"&SignIn=Sign+in");if(A.readyState!=4||A.status!=200||!this.querySignedIn()){this.text.innerHTML="Incorrect username or passward.<br>Try again...";return }this.close();if(this.callback){this.callback()}}},onsigninasguest:function(){var A=sjsl.createXMLHttpRequest();if(A){A.open("POST",this.NDPServe,false);A.setRequestHeader("Content-Type","application/x-www-form-urlencoded");A.send("Username=&Password=&SignIn=Sign+in+as+Guest");if(A.readyState!=4||A.status!=200||!this.querySignedIn()){this.text.innerHTML="Unable to sign in as Guest.";return }this.close();if(this.callback){this.callback()}}},querySignedIn:function(){var A=sjsl.createXMLHttpRequest();if(A){var B=this.NDPServe+"?GetCurrentUserName";A.open("Get",B,false);A.setRequestHeader("Content-Type","application/x-www-form-urlencoded");A.send("");if(A.readyState!=4||A.status!=200){return false}return true}return false}};ndpov.PreLoader=function(D,F,B){var C=D.length;var A=0;var E=function(){if(D.length<=0){return }var G=new Image();G.onload=function(){setTimeout(function(){E()},0);A++;if(F){F(Math.floor(A*100/C))}};G.src=ndpov.IMAGE_BASE+D.shift()};B=B||4;while(B-->0){E()}};ndpov.createGraphic=function(A){if(document.namespaces&&document.namespaces.add){return new ndpov.GraphicVML(A)}if(document.createElementNS&&(document.implementation.hasFeature("org.w3c.svg",null)||document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure","1.1"))){return new ndpov.GraphicSVG(A)}return null};ndpov.GraphicVML=function(A){this.element=A;if(this.element.ownerDocument.namespaces&&!this.element.ownerDocument.namespaces.v){this.element.ownerDocument.namespaces.add("v","urn:schemas-microsoft-com:vml","#default#VML")}};ndpov.GraphicVML.prototype={getType:function(){return"VML"},resize:function(){},erase:function(A){this.element.removeChild(A)},line:function(D,G,B,E,A,C){var F=this.element.ownerDocument.createElement("v:shape");F.set=function(K,R,J,Q,M,O){if(K==J&&R==Q){this.style.visibility="hidden";return }this.style.visibility="inherit";var T=[{x:K,y:R},{x:J,y:Q}];var L=100000;var P=100000;var S=-100000;var I=-100000;for(var N=0;N<T.length;++N){if(T[N].x<L){L=T[N].x}if(T[N].x>S){S=T[N].x}if(T[N].y<P){P=T[N].y}if(T[N].y>I){I=T[N].y}}if(L>S||P>I){return }var U="m "+Math.floor(T[0].x-L)+","+Math.floor(T[0].y-P)+" l ";for(var N=1;N<T.length;++N){if(N!=1){U+=", "}U+=Math.floor(T[N].x-L)+","+Math.floor(T[N].y-P)}U+=" e";this.style.marginLeft=L+"px";this.style.marginTop=P+"px";this.style.width=(S-L+1)+"px";this.style.height=(I-P+1)+"px";this.path=U;this.filled="f";this.strokecolor=M;this.strokeweight=O;this.coordsize=(S-L+1)+","+(I-P+1);this.coordorigin="0,0"};F.style.position="absolute";F.style.zIndex=1;F.set(D,G,B,E,A,C);var H=this.element.ownerDocument.createElement("v:shadow");F.appendChild(H);H.on="true";H.offset="1px,1px";H.color="gray";this.element.appendChild(F);return F},box:function(C,H,B,G,E,F,A){var D=this.element.ownerDocument.createElement("v:shape");D.set=function(L,S,K,R,N,P){if(L==K&&S==R){this.style.visibility="hidden";return }this.style.visibility="inherit";var U=[{x:L,y:S},{x:L,y:R},{x:K,y:R},{x:K,y:S}];var M=100000;var Q=100000;var T=-100000;var J=-100000;for(var O=0;O<U.length;++O){if(U[O].x<M){M=U[O].x}if(U[O].x>T){T=U[O].x}if(U[O].y<Q){Q=U[O].y}if(U[O].y>J){J=U[O].y}}if(M>T||Q>J){return }var V="m "+Math.floor(U[0].x-M)+","+Math.floor(U[0].y-Q)+" l ";for(var O=1;O<U.length;++O){if(O!=1){V+=", "}V+=Math.floor(U[O].x-M)+","+Math.floor(U[O].y-Q)}V+=" x e";this.style.marginLeft=M+"px";this.style.marginTop=Q+"px";this.style.width=(T-M+1)+"px";this.style.height=(J-Q+1)+"px";this.path=V;this.filled="f";this.strokecolor=N;this.strokeweight=P;this.coordsize=(T-M+1)+","+(J-Q+1);this.coordorigin="0,0"};D.style.position="absolute";D.style.zIndex=1;D.set(C,H,B,G,E,F);var I=this.element.ownerDocument.createElement("v:shadow");D.appendChild(I);I.on="true";I.offset="1px,1px";I.color="gray";this.element.appendChild(D);return D},ellipse:function(H,E,A,G,F,C,D,J){var B=this.element.ownerDocument.createElement("v:oval");B.set=function(L,R,P,M,K,N,O,Q){if(isNaN(L)||isNaN(R)||isNaN(P)){return }if(P<=0){this.style.visibility="hidden";return }this.style.visibility="inherit";this.style.marginLeft=(L-P)+"px";this.style.marginTop=(R-P)+"px";this.style.width=(P*2)+"px";this.style.height=(P*2)+"px";this.strokecolor=N;this.strokeweight=O;this.filled=Q==undefined?"f":"t";this.fillcolor=Q};B.style.position="absolute";B.style.zIndex=1;B.set(H,E,A,G,F,C,D,J);var I=this.element.ownerDocument.createElement("v:shadow");B.appendChild(I);I.on="true";I.offset="1px,1px";I.color="gray";this.element.appendChild(B);return B},polygon:function(C,A,B){var D=this.element.ownerDocument.createElement("v:shape");D.set=function(L,H,J){var G=100000;var K=100000;var M=-100000;var F=-100000;for(var I=0;I<L.length;++I){if(L[I].x<G){G=L[I].x}if(L[I].x>M){M=L[I].x}if(L[I].y<K){K=L[I].y}if(L[I].y>F){F=L[I].y}}if(G>M||K>F){return }var N="m "+Math.floor(L[0].x-G)+","+Math.floor(L[0].y-K)+" l ";for(var I=1;I<L.length;++I){if(I!=1){N+=", "}N+=Math.floor(L[I].x-G)+","+Math.floor(L[I].y-K)}N+=" x e";this.style.marginLeft=G+"px";this.style.marginTop=K+"px";this.style.width=(M-G+1)+"px";this.style.height=(F-K+1)+"px";this.path=N;this.filled="f";this.strokecolor=H;this.strokeweight=J;this.coordsize=(M-G+1)+","+(F-K+1);this.coordorigin="0,0"};D.style.position="absolute";D.style.zIndex=1;D.set(C,A,B);var E=this.element.ownerDocument.createElement("v:shadow");D.appendChild(E);E.on="true";E.offset="1px,1px";E.color="gray";this.element.appendChild(D);return D},image:function(A,F,B,C,E){var D=this.element.ownerDocument.createElement("v:image");D.style.position="absolute";D.style.marginLeft=A+"px";D.style.marginTop=F+"px";D.style.width=B+"px";D.style.height=C+"px";D.style.zIndex=0;if(E){D.src=E}this.element.appendChild(D);return D}};ndpov.GraphicSVG=function(A){this.element=A};ndpov.GraphicSVG.prototype={getType:function(){return"SVG"},resize:function(){},erase:function(A){this.element.removeChild(A.parentNode.parentNode)},line:function(D,G,B,E,A,C){var F=this.element.ownerDocument.createElementNS("http://www.w3.org/2000/svg","line");F.svg=this.element.ownerDocument.createElementNS("http://www.w3.org/2000/svg","svg");F.svg.style.position="absolute";F.svg.style.left="0px";F.svg.style.top="0px";F.container=this.element.ownerDocument.createElementNS("http://www.w3.org/1999/xhtml","div");F.container.style.position="absolute";F.container.style.zIndex=1;F.container.appendChild(F.svg);this.element.appendChild(F.container);F.set=function(K,M,I,L,H,J){if(K==I&&M==L){this.container.style.visibility="hidden";return }this.container.style.visibility="inherit";var O=Math.min(K,I);var N=Math.min(M,L);this.svg.setAttribute("width",(Math.abs(K-I)+1+J*2)+"px");this.svg.setAttribute("height",(Math.abs(M-L)+1+J*2)+"px");this.container.style.left=(O-J)+"px";this.container.style.top=(N-J)+"px";this.container.style.width=(Math.abs(K-I)+1+J*2)+"px";this.container.style.height=(Math.abs(M-L)+1+J*2)+"px";this.setAttribute("x1",K-O+J);this.setAttribute("y1",M-N+J);this.setAttribute("x2",I-O+J);this.setAttribute("y2",L-N+J);this.setAttribute("stroke",H);this.setAttribute("stroke-width",J)};F.set(D,G,B,E,A,C);F.svg.appendChild(F);return F},box:function(D,G,B,E,A,C,H){var F=this.element.ownerDocument.createElementNS("http://www.w3.org/2000/svg","rect");F.svg=this.element.ownerDocument.createElementNS("http://www.w3.org/2000/svg","svg");F.svg.style.position="absolute";F.svg.style.left="0px";F.svg.style.top="0px";F.container=this.element.ownerDocument.createElementNS("http://www.w3.org/1999/xhtml","div");F.container.style.position="absolute";F.container.style.zIndex=1;F.container.appendChild(F.svg);this.element.appendChild(F.container);F.set=function(M,O,K,N,J,L,P){if(M==K&&O==N){this.container.style.visibility="hidden";return }this.container.style.visibility="inherit";if(M>K){var I=M;M=K;K=I}if(O>N){var I=O;O=N;N=I}this.svg.setAttribute("width",(K-M+1+L*2)+"px");this.svg.setAttribute("height",(N-O+1+L*2)+"px");this.container.style.left=(M-L)+"px";this.container.style.top=(O-L)+"px";this.container.style.width=(K-M+1+L*2)+"px";this.container.style.height=(N-O+1+L*2)+"px";this.setAttribute("x",L);this.setAttribute("y",L);this.setAttribute("width",K-M);this.setAttribute("height",N-O);this.setAttribute("stroke",J);this.setAttribute("stroke-width",L);if(P){F.setAttribute("fill",P)}else{F.setAttribute("fill","none")}};F.set(D,G,B,E,A,C,H);F.svg.appendChild(F);return F},ellipse:function(H,E,A,G,F,C,D,I){var B=this.element.ownerDocument.createElementNS("http://www.w3.org/2000/svg","circle");B.svg=this.element.ownerDocument.createElementNS("http://www.w3.org/2000/svg","svg");B.svg.style.position="absolute";B.svg.style.left="0px";B.svg.style.top="0px";B.container=this.element.ownerDocument.createElementNS("http://www.w3.org/1999/xhtml","div");B.container.style.position="absolute";B.container.style.zIndex=1;B.container.appendChild(B.svg);this.element.appendChild(B.container);B.set=function(K,Q,O,L,J,M,N,P){if(O<=0){this.container.style.visibility="hidden";return }this.container.style.visibility="inherit";O=Math.floor(O);K=Math.floor(K);Q=Math.floor(Q);this.svg.setAttribute("width",(O*2+1+N*2)+"px");this.svg.setAttribute("height",(O*2+1+N*2)+"px");this.container.style.left=(K-O-N)+"px";this.container.style.top=(Q-O-N)+"px";this.container.style.width=(O*2+1+N*2)+"px";this.container.style.height=(O*2+1+N*2)+"px";this.setAttribute("cx",O+N);this.setAttribute("cy",O+N);this.setAttribute("r",O);this.setAttribute("stroke",M);this.setAttribute("stroke-width",N);this.setAttribute("fill",P==undefined?"none":P)};B.set(H,E,A,G,F,C,D);B.svg.appendChild(B);return B},polygon:function(C,A,B){var D=this.element.ownerDocument.createElementNS("http://www.w3.org/2000/svg","polygon");D.svg=this.element.ownerDocument.createElementNS("http://www.w3.org/2000/svg","svg");D.svg.style.position="absolute";D.svg.style.left="0px";D.svg.style.top="0px";D.container=this.element.ownerDocument.createElementNS("http://www.w3.org/1999/xhtml","div");D.container.style.position="absolute";D.container.style.zIndex=1;D.container.appendChild(D.svg);this.element.appendChild(D.container);D.set=function(K,G,I){var F=100000,J=100000,L=-100000,E=-100000;for(var H=0;H<K.length;++H){if(F>K[H].x){F=K[H].x}if(J>K[H].y){J=K[H].y}if(L<K[H].x){L=K[H].x}if(E<K[H].y){E=K[H].y}}this.svg.setAttribute("width",(L-F+1+I*2)+"px");this.svg.setAttribute("height",(E-J+1+I*2)+"px");this.container.style.left=(F-I)+"px";this.container.style.top=(J-I)+"px";this.container.style.width=(L-F+1+I*2)+"px";this.container.style.height=(E-J+1+I*2)+"px";var M="";for(var H=0;H<K.length;++H){if(H!=0){M+=" "}M+=(K[H].x-F+I)+","+(K[H].y-J+I)}this.setAttribute("points",M);this.setAttribute("stroke",G);this.setAttribute("stroke-width",I)};D.set(C,A,B);D.setAttribute("fill","none");D.svg.appendChild(D);return D}};ndpov.textToSendingMessage=function(D){D=D.replace(/&/g,"&amp;");D=D.replace(/</g,"&lt;");D=D.replace(/>/g,"&gt;");D=D.replace(/\"/g,"&quot;");D=D.replace(/\'/g,"&apos;");var C="";for(var A=0;A<D.length;++A){var B=D.charCodeAt(A);if(B<32){C+="&#x";C+=B.toString(16);C+=";"}else{C+=String.fromCharCode(B)}}return C};ndpov.ImageController=function(){this.initialize.apply(this,arguments)};sjsl.extend(ndpov.ImageController.prototype,sjsl.Window.prototype);sjsl.extend(ndpov.ImageController.prototype,{initialize:function(B){sjsl.Window.prototype.initialize.apply(this,[B.element,"Image Controls",0,0]);var A="font-size:20px;font-family:Tahoma,sans-serif;color:#606060;";this.viewer=B;this.viewer.controls.show=1;ndpov.saveSetting(this.viewer);this.wnd.style.left=this.viewer.controls.x+"px";this.wnd.style.top=this.viewer.controls.y+"px";this.client.style.padding="4px";var D=document.createElement("table");D.cellPadding=0;D.cellSpacing=2;D.border=0;D.style.width="100%";D.style.margin="2px";this.client.appendChild(D);var C=function(S,R,Q,L){var P=S.insertRow(-1);P.align="center";var O=P.insertCell(0);O.innerHTML="<div style='width:32px;height:32px;background:url("+ndpov.IMAGE_BASE+"ndpov.png) no-repeat "+R+"px "+Q+"px'></div>";O.style.paddingRight="10px";var N=P.insertCell(1);var M=P.insertCell(2);M.style.cssText=A;M.style.width="50px";var K=P.insertCell(3);button=document.createElement("button");button.innerHTML="Reset";button.style.cssText=A;button.style.width="100%";button.style.backgroundColor="white";K.appendChild(button);button.onclick=L;if(B.viewMode!=ndpov.VIEW_MODE[2]){button.disabled=true;button.style.color="#E0E0E0"}return{slider:N,value:M}};this.gamma=C(D,-128,-256,sjsl.bind(this,function(){this.viewer.gamma=1.8;this.gammaSlider.setValue(this.viewer.gamma*10);this.update()}));this.brightness=C(D,-128,-288,sjsl.bind(this,function(){this.viewer.brightness=0;this.brightnessSlider.setValue(this.viewer.brightness*100);this.update()}));this.contrast=C(D,-160,-256,sjsl.bind(this,function(){this.viewer.contrast=1;this.contrastSlider.setValue(this.viewer.contrast*100-100);this.update()}));this.red=C(D,-64,-192,sjsl.bind(this,function(){this.viewer.red=1;this.redSlider.setValue(this.viewer.red*100-100);this.update()}));this.green=C(D,-96,-192,sjsl.bind(this,function(){this.viewer.green=1;this.greenSlider.setValue(this.viewer.green*100-100);this.update()}));this.blue=C(D,-128,-192,sjsl.bind(this,function(){this.viewer.blue=1;this.blueSlider.setValue(this.viewer.blue*100-100);this.update()}));var H=D.insertRow(-1);H.align="center";var J=H.insertCell(0);J.style.paddingRight="10px";J.innerHTML="<div style='width:32px;height:32px;background:url("+ndpov.IMAGE_BASE+"ndpov.png) no-repeat -160px -288px'></div>";var I=H.insertCell(1);I.style.cssText=A;this.sharpenCheck=document.createElement("input");this.sharpenCheck.type="checkbox";this.sharpenCheck.id=B.element.id+"_imageControl_sharpenFilter";this.sharpenCheck.onclick=sjsl.bind(this,function(){if(B.viewMode==ndpov.VIEW_MODE[2]){this.viewer.sharpenFilter=this.sharpenCheck.checked?1:0}else{this.viewer.sharpenFilterForViewMode=this.sharpenCheck.checked?1:0}this.update()});I.appendChild(this.sharpenCheck);var E=document.createElement("label");E.htmlFor=this.sharpenCheck.id;E.appendChild(document.createTextNode("Enable Sharpen Filter"));I.appendChild(E);if(B.viewMode==ndpov.VIEW_MODE[1]){this.sharpenCheck.disabled=true;E.style.color="#E0E0E0"}var G=H.insertCell(2);var F=H.insertCell(3);button=document.createElement("button");button.innerHTML="Reset All";button.style.cssText=A;button.style.backgroundColor="white";F.appendChild(button);button.onclick=sjsl.bind(this,function(){this.viewer.gamma=1.8;this.viewer.brightness=0;this.viewer.contrast=1;this.viewer.red=1;this.viewer.green=1;this.viewer.blue=1;this.gammaSlider.setValue(this.viewer.gamma*10);this.brightnessSlider.setValue(this.viewer.brightness*100);this.contrastSlider.setValue(this.viewer.contrast*100-100);this.redSlider.setValue(this.viewer.red*100-100);this.greenSlider.setValue(this.viewer.green*100-100);this.blueSlider.setValue(this.viewer.blue*100-100)});if(B.viewMode!=ndpov.VIEW_MODE[2]){button.disabled=true;button.style.color="#E0E0E0"}this.sharpenCheck.checked=this.viewer.viewMode==ndpov.VIEW_MODE[1]?false:this.viewer.viewMode==ndpov.VIEW_MODE[2]?(this.viewer.sharpenFilter?true:false):(this.viewer.sharpenFilterForViewMode?true:false);this.gammaSlider=new sjsl.Slider(this.gamma.slider,5,35,7,(this.viewer.viewMode==ndpov.VIEW_MODE[1]?1:this.viewer.viewMode==ndpov.VIEW_MODE[2]?this.viewer.gamma:1.8)*10);this.brightnessSlider=new sjsl.Slider(this.brightness.slider,-100,100,11,(this.viewer.viewMode==ndpov.VIEW_MODE[2]?this.viewer.brightness:0)*100);this.contrastSlider=new sjsl.Slider(this.contrast.slider,-100,100,11,(this.viewer.viewMode==ndpov.VIEW_MODE[2]?this.viewer.contrast:1)*100-100);this.redSlider=new sjsl.Slider(this.red.slider,-100,100,11,(this.viewer.viewMode==ndpov.VIEW_MODE[2]?this.viewer.red:1)*100-100);this.greenSlider=new sjsl.Slider(this.green.slider,-100,100,11,(this.viewer.viewMode==ndpov.VIEW_MODE[2]?this.viewer.green:1)*100-100);this.blueSlider=new sjsl.Slider(this.blue.slider,-100,100,11,(this.viewer.viewMode==ndpov.VIEW_MODE[2]?this.viewer.blue:1)*100-100);this.gammaSlider.onchange=sjsl.bind(this,function(L,K){this.viewer.gamma=L/10;if(K){this.showValue()}else{this.update()}});this.brightnessSlider.onchange=sjsl.bind(this,function(L,K){this.viewer.brightness=L/100;if(K){this.showValue()}else{this.update()}});this.contrastSlider.onchange=sjsl.bind(this,function(L,K){this.viewer.contrast=(L+100)/100;if(K){this.showValue()}else{this.update()}});this.redSlider.onchange=sjsl.bind(this,function(L,K){this.viewer.red=(L+100)/100;if(K){this.showValue()}else{this.update()}});this.greenSlider.onchange=sjsl.bind(this,function(L,K){this.viewer.green=(L+100)/100;if(K){this.showValue()}else{this.update()}});this.blueSlider.onchange=sjsl.bind(this,function(L,K){this.viewer.blue=(L+100)/100;if(K){this.showValue()}else{this.update()}});if(this.viewer.viewMode!=ndpov.VIEW_MODE[2]){this.gammaSlider.disabled=true;this.gammaSlider.update();this.brightnessSlider.disabled=true;this.brightnessSlider.update();this.contrastSlider.disabled=true;this.contrastSlider.update();this.redSlider.disabled=true;this.redSlider.update();this.greenSlider.disabled=true;this.greenSlider.update();this.blueSlider.disabled=true;this.blueSlider.update()}this.showValue();this.width=this.wnd.offsetWidth;this.height=this.wnd.offsetHeight},update:function(A){if(A){this.gammaSlider.setValue(this.viewer.gamma*10);this.brightnessSlider.setValue(this.viewer.brightness*100);this.contrastSlider.setValue(this.viewer.contrast*100-100);this.redSlider.setValue(this.viewer.red*100-100);this.greenSlider.setValue(this.viewer.green*100-100);this.blueSlider.setValue(this.viewer.blue*100-100);this.sharpenCheck.checked=this.viewer.sharpenFilter?true:false}this.showValue();ndpov.saveSetting(this.viewer);this.viewer.refresh();if(this.viewer.onchange){this.viewer.onchange(this.viewer.getPosX(),this.viewer.getPosY(),this.viewer.getPosZ(),this.viewer.currentLens)}},showValue:function(){this.gamma.value.innerHTML=this.viewer.viewMode==ndpov.VIEW_MODE[1]?1:this.viewer.viewMode==ndpov.VIEW_MODE[2]?this.viewer.gamma:1.8;this.brightness.value.innerHTML=Math.round((this.viewer.viewMode==ndpov.VIEW_MODE[2]?this.viewer.brightness:0)*100);this.contrast.value.innerHTML=Math.round((this.viewer.viewMode==ndpov.VIEW_MODE[2]?this.viewer.contrast:1)*100-100);this.red.value.innerHTML=Math.round((this.viewer.viewMode==ndpov.VIEW_MODE[2]?this.viewer.red:1)*100-100);this.green.value.innerHTML=Math.round((this.viewer.viewMode==ndpov.VIEW_MODE[2]?this.viewer.green:1)*100-100);this.blue.value.innerHTML=Math.round((this.viewer.viewMode==ndpov.VIEW_MODE[2]?this.viewer.blue:1)*100-100);if(this.viewer.viewMode!=ndpov.VIEW_MODE[2]){this.gamma.value.style.color="#E0E0E0";this.brightness.value.style.color="#E0E0E0";this.contrast.value.style.color="#E0E0E0";this.red.value.style.color="#E0E0E0";this.green.value.style.color="#E0E0E0";this.blue.value.style.color="#E0E0E0"}},onmouseup:function(A){sjsl.Window.prototype.onmouseup.apply(this,arguments);this.gammaSlider.releaseButton();this.brightnessSlider.releaseButton();this.contrastSlider.releaseButton();this.redSlider.releaseButton();this.greenSlider.releaseButton();this.blueSlider.releaseButton()},onmousemove:function(A){sjsl.Window.prototype.onmousemove.apply(this,arguments);if(this.dragging){this.viewer.controls.x=parseInt(this.wnd.style.left);this.viewer.controls.y=parseInt(this.wnd.style.top);ndpov.saveSetting(this.viewer)}},close:function(){sjsl.Window.prototype.close.apply(this,arguments);this.viewer.controls.show=0;ndpov.saveSetting(this.viewer)}});ndpov.rotate=function(B,F,C){var A=C*Math.PI/180;var D=B*Math.cos(A)-F*Math.sin(A);var E=B*Math.sin(A)+F*Math.cos(A);return{x:D,y:E}};ndpov.RotationDialog=function(){this.initialize.apply(this,arguments)};sjsl.extend(ndpov.RotationDialog.prototype,sjsl.Window.prototype);sjsl.extend(ndpov.RotationDialog.prototype,{initialize:function(C,A){sjsl.Window.prototype.initialize.apply(this,[C.element,"Rotation",0,0]);this.viewer=C;this.callBack=A;this.client.appendChild(document.createTextNode("Enter a viewing angle(from 0 to 360)."));var E=document.createElement("div");E.style.textAlign="right";this.input=document.createElement("input");this.input.type="text";this.input.style.textAlign="right";this.input.style.margin="6px";this.input.value=this.viewer.rotation;E.appendChild(this.input);E.appendChild(document.createElement("br"));var D=document.createElement("button");D.style.cssText=this.defaultStyle;D.style.backgroundColor="white";D.innerHTML="OK";D.onclick=sjsl.bind(this,function(){this.submit()});E.appendChild(D);var B=document.createElement("button");B.style.cssText=this.defaultStyle;B.style.backgroundColor="white";B.innerHTML="Cancel";B.onclick=sjsl.bind(this,function(){this.close()});E.appendChild(B);this.client.appendChild(E);this.wnd.style.left=((this.viewer.element.offsetWidth-this.wnd.offsetWidth)/2)+"px";this.wnd.style.top=((this.viewer.element.offsetHeight-this.wnd.offsetHeight)/2)+"px";this.wnd.onkeydown=sjsl.bind(this,function(F){if(sjsl.getKeyCode(F)==13){this.submit();return false}});this.input.focus()},submit:function(){var A=this.input.value-0;if(isNaN(A)||A<0||360<A){return }this.value=A;this.close()},close:function(){sjsl.Window.prototype.close.apply(this,arguments);if(this.callBack){this.callBack(this.value)}}});ndpov.StatusWnd=function(){this.initialize.apply(this,arguments)};sjsl.extend(ndpov.StatusWnd.prototype,sjsl.Window.prototype);sjsl.extend(ndpov.StatusWnd.prototype,{initialize:function(G){sjsl.Window.prototype.initialize.apply(this,[G.element,"Status",0,0]);this.viewer=G;var B;if(this.viewer.zstep==0||this.viewer.zmin==this.viewer.zmax){B="No"}else{B=(this.viewer.zmin/1000)+" μm to "+(this.viewer.zmax/1000)+" μm in "+(this.viewer.zstep/1000)+" μm steps"}var D=this.viewer.currentLens;if(D<10){D=Math.round(D*100)/100}else{D=Math.round(D*10)/10}var C=this.arrange(this.viewer.filesize,1024,["B","kB","MB","GB"]);var E=this.arrange(this.viewer.uncompressedsize,1024,["B","kB","MB","GB"]);var A=this.arrange(this.viewer.pixelToNanoX(this.viewer.element.offsetWidth,this.viewer.currentLens),1000,["nm","μm","mm"]);var F=this.arrange(this.viewer.pixelToNanoY(this.viewer.element.offsetHeight,this.viewer.currentLens),1000,["nm","μm","mm"]);this.client.innerHTML="<table><tr><td><b>Current Lens</b></td><td>"+D+"x</td></tr><tr><td><b>Source Lens</b></td><td>"+this.viewer.sourcelens+"x</td></tr>"+((this.viewer.rotation==0)?"":"<tr><td><b>Viewing angle</b></td><td>"+this.viewer.rotation+"°</td></tr>")+"<tr><td><br></td></tr><tr><td><b>Focusing available</b></td><td>"+B+"</td></tr>"+((B=="No")?"":"<tr><td><b>Current focal plane</b></td><td>"+(this.viewer.getPosZ()/1000)+" μm</td></tr>")+"<tr><td><br></td></tr><tr><td><b>Source filename</b></td><td>"+this.viewer.name+" on "+document.domain+"</td></tr>"+(this.viewer.reference?"<tr><td><b>Reference</b></td><td>"+this.viewer.reference+"</td></tr>":"")+"<tr><td><b>Filesize</b></td><td>"+C+" (<B>uncompressed</b> "+E+")</td></tr><tr><td><br></td></tr><tr><td><b>Current screen width</b></td><td>"+A+"</td></tr><tr><td><b>Current screen height&nbsp;</b></td><td>"+F+"</td></tr></table><br><img src='"+this.viewer.NDPServe+"?GetMacroImage?"+this.viewer.itemID+"' onerror='this.parentNode.removeChild(this)' onload='var wnd = this.parentNode.parentNode.parentNode.parentNode;var defW = wnd.offsetWidth - wnd.parentNode.parentNode.offsetWidth + 4;var defH = wnd.offsetHeight - wnd.parentNode.parentNode.offsetHeight + 4;if (defW / this.width > defH / this.height && defW > 0)this.width = this.width - defW;if (defH / this.height > defW / this.width && defH > 0)this.height = this.height - defH;' /><br><div style='text-align:right;'>NDPov "+ndpov.VERSION+"</div>"},arrange:function(B,E,D){var A;for(var C=0;C<D.length-1;++C){if(B<E){if(B<10){return(parseInt(B*100)/100)+" "+D[C]}if(B<100){return(parseInt(B*10)/10)+" "+D[C]}return parseInt(B)+" "+D[C]}B/=E}if(B<10){return(parseInt(B*100)/100)+" "+D[D.length-1]}if(B<100){return(parseInt(B*10)/10)+" "+D[D.length-1]}return parseInt(B)+" "+D[D.length-1]}});ndpov.HelpWnd=function(){this.initialize.apply(this,arguments)};sjsl.extend(ndpov.HelpWnd.prototype,sjsl.Window.prototype);sjsl.extend(ndpov.HelpWnd.prototype,{initialize:function(A){sjsl.Window.prototype.initialize.apply(this,[A.element,"Help",0,0]);this.client.innerHTML="<iframe frameborder=0 src='"+ndpov.HELP_FILE_URL+"' width="+A.element.offsetWidth+" height="+A.element.offsetHeight+" onload='var wnd = this.parentNode.parentNode.parentNode.parentNode;var defW = wnd.offsetWidth - wnd.parentNode.parentNode.offsetWidth + 4;var defH = wnd.offsetHeight - wnd.parentNode.parentNode.offsetHeight + 4;if (defW > 0)this.width = this.width - defW;if (defH > 0)this.height = this.height - defH;'></iframe>"}});ndpov.SettingsDialog=function(){this.initialize.apply(this,arguments)};sjsl.extend(ndpov.SettingsDialog.prototype,sjsl.Window.prototype);sjsl.extend(ndpov.SettingsDialog.prototype,{initialize:function(F,B){sjsl.Window.prototype.initialize.apply(this,[F.element,"Settings",0,0]);this.viewer=F;this.callBack=B;this.viewer.settings.show=1;ndpov.saveSetting(this.viewer);this.wnd.style.left=this.viewer.settings.x+"px";this.wnd.style.top=this.viewer.settings.y+"px";this.client.style.lineHeight="32px";var D=function(O,K,R,Q,P){var N=document.createElement("div");N.style.width="32px";N.style.height="32px";N.style.background="url("+ndpov.IMAGE_BASE+"ndpov.png) no-repeat "+K+"px "+R+"px";N.style.verticalAlign="middle";N.style.margin="2px 2px -26px 2px";O.appendChild(N);var L=document.createElement("input");L.type="checkbox";L.id=F.id+"_settings_"+Q;L.onclick=P;L.style.marginLeft="40px";O.appendChild(L);var M=document.createElement("label");M.htmlFor=F.id+"_settings_"+Q;M.appendChild(document.createTextNode(" "+Q));O.appendChild(M);O.appendChild(document.createElement("br"));return L};this.client.appendChild(document.createTextNode("Scrolling"));var J=document.createElement("div");J.style.width="164px";J.style.height="1px";J.style.overflow="hidden";J.style.background="url("+ndpov.IMAGE_BASE+"ndpov.png) no-repeat 0px -320px";this.client.appendChild(J);this.scrollingAnimate=D(this.client,-192,-256,"Animate",sjsl.bind(this,function(){this.viewer.settings.scrolling.animate=this.scrollingAnimate.checked?1:0;ndpov.saveSetting(this.viewer)}));var I=document.createElement("table");I.cellPadding=0;I.cellSpacing=0;var G=I.insertRow(0);var E=G.insertCell(0);var H=document.createElement("div");H.style.width="32px";H.style.height="32px";H.style.background="url("+ndpov.IMAGE_BASE+"ndpov.png) no-repeat -192px -288px";E.appendChild(H);var C=G.insertCell(1);C.width=60;C.style.padding="5px";var A=G.insertCell(2);A.style.cssText=this.defaultStyle+"font-size:18px;";A.appendChild(document.createTextNode("Arrow Keys Move "));this.scrollingMoveValue=G.insertCell(3);this.scrollingMoveValue.style.cssText=this.defaultStyle+"font-size:18px;padding-left:10px;";this.scrollingMoveValue.innerHTML=this.viewer.settings.scrolling.move+"%";this.client.appendChild(I);this.scrollingMoveSlider=new sjsl.Slider(C,10,100,10,this.viewer.settings.scrolling.move);this.scrollingMoveSlider.onchange=sjsl.bind(this,function(L,K){this.viewer.settings.scrolling.move=L;ndpov.saveSetting(this.viewer);this.scrollingMoveValue.innerHTML=this.viewer.settings.scrolling.move+"%"});this.client.appendChild(document.createTextNode("Zooming"));J=document.createElement("div");J.style.width="164px";J.style.height="1px";J.style.overflow="hidden";J.style.background="url("+ndpov.IMAGE_BASE+"ndpov.png) no-repeat 0px -320px";this.client.appendChild(J);this.zoomingWheel=D(this.client,-224,-256,"Use Mouse Wheel to Zoom",sjsl.bind(this,this.updateZoomingMouseWheel));this.zoomingMoveToCursor=D(this.client,-224,-288,"Move to Cursor Position",sjsl.bind(this,function(){this.viewer.settings.zooming.moveToCursor=this.zoomingMoveToCursor.checked?1:0;ndpov.saveSetting(this.viewer)}));this.zoomingMoveToCursor.disabled=!this.viewer.settings.zooming.mouseWheel;this.client.appendChild(document.createTextNode("Rotation"));J=document.createElement("div");J.style.width="164px";J.style.height="1px";J.style.overflow="hidden";J.style.background="url("+ndpov.IMAGE_BASE+"ndpov.png) no-repeat 0px -320px";this.client.appendChild(J);this.rotation180=D(this.client,-256,-256,"180° Default Viewing Angle",sjsl.bind(this,function(){this.viewer.settings.rotation.rotation180=this.rotation180.checked?1:0;ndpov.saveSetting(this.viewer)}));this.scrollingAnimate.checked=this.viewer.settings.scrolling.animate;this.zoomingWheel.checked=this.viewer.settings.zooming.mouseWheel;this.zoomingMoveToCursor.checked=this.viewer.settings.zooming.moveToCursor;this.rotation180.checked=this.viewer.settings.rotation.rotation180},close:function(){sjsl.Window.prototype.close.apply(this,arguments);this.viewer.settings.show=0;ndpov.saveSetting(this.viewer)},updateZoomingMouseWheel:function(){this.viewer.settings.zooming.mouseWheel=this.zoomingWheel.checked?1:0;ndpov.saveSetting(this.viewer);this.zoomingMoveToCursor.disabled=!this.viewer.settings.zooming.mouseWheel},onmousemove:function(A){sjsl.Window.prototype.onmousemove.apply(this,arguments);if(this.dragging){this.viewer.settings.x=parseInt(this.wnd.style.left);this.viewer.settings.y=parseInt(this.wnd.style.top);ndpov.saveSetting(this.viewer)}},onmouseup:function(A){sjsl.Window.prototype.onmouseup.apply(this,arguments);this.scrollingMoveSlider.releaseButton()}});
