if(!ndpov){var ndpov={}}ndpov.WISVIEWER_VERSION="1.0.0.4";ndpov.WSIViewer=function(J,B,F){if(!J){return }if(!B){J.innerHTML="Invalid itemID.";return }this.element=J;this.itemID=B;this.width=this.element.offsetWidth;this.height=this.element.offsetHeight;this.element.innerHTML="";if(this.element.style.position.toLowerCase()!="absolute"&&this.element.style.position.toLowerCase()!="relative"){this.element.style.position="relative"}this.element.style.width=this.width+"px";this.element.style.height=this.height+"px";ndpov.PreLoader(["divider.png","tBack.png","tBackPressed.png","tBackHot.png","tForward.png","tForwardPressed.png","tForwardHot.png","tMap.png","tMapPressed.png","tMapHot.png","tLensBlank.png","tLensPressed.png","tLensHot.png","tAnnotate.png","tAnnotatePressed.png","tAnnotateHot.png","tExport.png","tExportPressed.png","tExportHot.png","tSettings.png","tSettingsPressed.png","tSettingsHot.png","tStatus.png","tStatusPressed.png","tStatusHot.png","tHelp.png","tHelpPressed.png","tHelpHot.png","tViewingMode.png","tViewingModePressed.png","tViewingModeHot.png","tAnalysisDropDown.png","tAnalysisDropDownPressed.png","tAnalysisDropDownHot.png","tCustomDropDown.png","tCustomDropDownPressed.png","tCustomDropDownHot.png","Zm.png","ZmPressed.png","ZmHot.png","Zp.png","ZpPressed.png","ZpHot.png","Z0.png","Z0Pressed.png","Z0Hot.png","mZm.png","mZmf.png","mZp.png","mZpf.png","mZ0.png","mZ0f.png"]);var I=this;var P="position:absolute; top:0px; z-index:10; background-color:white; border:0px solid black;";var E=0;this.element.style.textAlign="left";var O=function(R,T,U){var V=document.createElement("div");V.style.cssText=P+"left:"+E+"px";var S=new sjsl.Button(V,"",R,T,U);J.appendChild(V);return S};var Q=O(ndpov.IMAGE_BASE+"tBack.png",ndpov.IMAGE_BASE+"tBackPressed.png",ndpov.IMAGE_BASE+"tBackHot.png");Q.onclick=sjsl.bind(this,function(){if(this.viewer){this.viewer.back()}});Q.setToolTip("Go back");E+=38;var M=O(ndpov.IMAGE_BASE+"tForward.png",ndpov.IMAGE_BASE+"tForwardPressed.png",ndpov.IMAGE_BASE+"tForwardHot.png");M.onclick=sjsl.bind(this,function(){if(this.viewer){this.viewer.forward()}});M.setToolTip("Go forward");E+=38;var H=document.createElement("img");H.style.cssText=P+"left:"+E+"px";H.src=ndpov.IMAGE_BASE+"divider.png";this.element.appendChild(H);E+=4;var D=O(ndpov.IMAGE_BASE+"tMap.png",ndpov.IMAGE_BASE+"tMapPressed.png",ndpov.IMAGE_BASE+"tMapHot.png");D.onclick=sjsl.bind(this,function(){if(this.viewer){this.viewer.setPosLensMap()}});D.setToolTip("Return to overview map");E+=38;var G=O(ndpov.IMAGE_BASE+"tLensBlank.png",ndpov.IMAGE_BASE+"tLensPressed.png",ndpov.IMAGE_BASE+"tLensHot.png");G.onclick=sjsl.bind(this,function(){if(!this.viewer||!this.viewer.isValid()){return }var R=new sjsl.Selecter(this.element,this.viewer.LENS_MENU,parseInt(G.element.style.left),parseInt(G.element.style.top)+G.element.offsetHeight);R.onselected=sjsl.bind(this.viewer,this.viewer.onLensMenuSelected)});G.onchange=function(R,U,T,S){if(S<10){S=Math.round(S*100)/100}else{S=Math.round(S*10)/10}this.setHTML("<nobr><table cellpadding='0px' cellspacing='0px' style='margin:0px 0px 0px 20px;padding:0px;'><tr><td width='80px'><div style='font-size:16px;font-family:Tahoma,sans-serif;text-align:center;font-weight:bold;'>"+S+"x</div></td></tr></table></nobr>")};G.setToolTip("Change lens");G.onchange(0,0,0,1);E+=100;var N=O(ndpov.IMAGE_BASE+"Z0.png",ndpov.IMAGE_BASE+"Z0Pressed.png",ndpov.IMAGE_BASE+"Z0Hot.png");N.onchange=function(R,U,T,S){if(T<0){this.imgSrc(ndpov.IMAGE_BASE+"Zm.png",ndpov.IMAGE_BASE+"ZmPressed.png",ndpov.IMAGE_BASE+"ZmHot.png")}else{if(T>0){this.imgSrc(ndpov.IMAGE_BASE+"Zp.png",ndpov.IMAGE_BASE+"ZpPressed.png",ndpov.IMAGE_BASE+"ZpHot.png")}else{this.imgSrc(ndpov.IMAGE_BASE+"Z0.png",ndpov.IMAGE_BASE+"Z0Pressed.png",ndpov.IMAGE_BASE+"Z0Hot.png")}}this.setHTML("<nobr><table cellpadding='0px' cellspacing='0px' style='margin:0px 0px 0px 20px;padding:0px;'><tr><td width='80px'><div style='font-size:16px;font-family:Tahoma,sans-serif;text-align:center;font-weight:bold;'><nobr>"+(T/1000)+"<span style='font-size:10px;'> μm</span></nobr></div></td></tr></table></nobr>")};N.setToolTip("Change focul plane");N.onchange(0,0,0);E+=100;var H=document.createElement("img");H.style.cssText=P+"left:"+E+"px";H.src=ndpov.IMAGE_BASE+"divider.png";this.element.appendChild(H);E+=4;var C=O(ndpov.IMAGE_BASE+"tAnnotate.png",ndpov.IMAGE_BASE+"tAnnotatePressed.png",ndpov.IMAGE_BASE+"tAnnotateHot.png");C.onclick=function(){if(!I.viewer||!I.viewer.isValid()){return }var R=new sjsl.Selecter(I.element,I.viewer.ANNOTATION_MENU,parseInt(C.element.style.left),parseInt(C.element.style.top)+C.element.offsetHeight);R.onselected=sjsl.bind(I.viewer,I.viewer.onAnnotationMenuSelected)};C.setToolTip("Annotate image");E+=46;var H=document.createElement("img");H.style.cssText=P+"left:"+E+"px";H.src=ndpov.IMAGE_BASE+"divider.png";this.element.appendChild(H);E+=4;this.exportButton=O(ndpov.IMAGE_BASE+"tExport.png",ndpov.IMAGE_BASE+"tExportPressed.png",ndpov.IMAGE_BASE+"tExportHot.png");this.exportButton.onclick=sjsl.bind(this,function(){if(this.viewer){this.viewer.exportImage()}});this.exportButton.setToolTip("Export the current image to file");E+=38;var H=document.createElement("img");H.style.cssText=P+"left:"+E+"px";H.src=ndpov.IMAGE_BASE+"divider.png";this.element.appendChild(H);E+=4;modeButton=O();modeButton.onclick=function(){if(!I.viewer||!I.viewer.isValid()){return }var R=new sjsl.Selecter(I.element,I.viewer.DISPLAY_MODE_MENU,parseInt(this.element.style.left),parseInt(this.element.style.top)+this.element.offsetHeight);R.onselected=sjsl.bind(I.viewer,I.viewer.onDisplayModeMenuSelected)};modeButton.onchange=function(R){switch(R){case ndpov.VIEW_MODE[1]:this.imgSrc(ndpov.IMAGE_BASE+"tAnalysisDropDown.png",ndpov.IMAGE_BASE+"tAnalysisDropDownPressed.png",ndpov.IMAGE_BASE+"tAnalysisDropDownHot.png");break;case ndpov.VIEW_MODE[2]:this.imgSrc(ndpov.IMAGE_BASE+"tCustomDropDown.png",ndpov.IMAGE_BASE+"tCustomDropDownPressed.png",ndpov.IMAGE_BASE+"tCustomDropDownHot.png");break;default:this.imgSrc(ndpov.IMAGE_BASE+"tViewingMode.png",ndpov.IMAGE_BASE+"tViewingModePressed.png",ndpov.IMAGE_BASE+"tViewingModeHot.png");break}};modeButton.setToolTip("Change display mode");modeButton.onchange(ndpov.VIEW_MODE[0]);E+=46;var L=O(ndpov.IMAGE_BASE+"tSettings.png",ndpov.IMAGE_BASE+"tSettingsPressed.png",ndpov.IMAGE_BASE+"tSettingsHot.png");L.onclick=sjsl.bind(this,function(){if(this.viewer){this.viewer.showSettingsDialog()}});L.setToolTip("Show/hide settings window");E+=38;var H=document.createElement("img");H.style.cssText=P+"left:"+E+"px";H.src=ndpov.IMAGE_BASE+"divider.png";this.element.appendChild(H);E+=4;this.statusButton=O(ndpov.IMAGE_BASE+"tStatus.png",ndpov.IMAGE_BASE+"tStatusPressed.png",ndpov.IMAGE_BASE+"tStatusHot.png");this.statusButton.onclick=function(){I.viewer.showStatus()};this.statusButton.setToolTip("Show/hide status screen");E+=38;this.helpButton=O(ndpov.IMAGE_BASE+"tHelp.png",ndpov.IMAGE_BASE+"tHelpPressed.png",ndpov.IMAGE_BASE+"tHelpHot.png");this.helpButton.onclick=function(){I.viewer.showHelp()};this.helpButton.setToolTip("Show/hide help screen");E+=38;var K=document.createElement("div");K.id=this.element.id+"_ndpov";K.style.position="absolute";K.style.left="0px";K.style.top="44px";K.style.width=this.width+"px";K.style.height=(this.height-44)+"px";this.element.appendChild(K);if(!F){var A=location.pathname.substring(0,location.pathname.lastIndexOf("/")+1);F=location.protocol+"//"+location.host+A+"NDPServe.dll"}this.viewer=new ndpov.NDPov(K,F,B,function(){sjsl.eventObserver(this);var T=document.createElement("div");T.style.zIndex=10;T.style.position="absolute";T.style.left=(K.offsetWidth*3/4-10)+"px";T.style.top=(K.offsetHeight*3/4-10)+"px";T.style.width=(K.offsetWidth/4)+"px";T.style.height=(K.offsetHeight/4)+"px";K.appendChild(T);I.mapWnd=new ndpov.MapWnd(T,B,this);var R=document.createElement("div");R.style.zIndex=10;R.style.position="absolute";R.style.left="0px";R.style.top=(K.offsetHeight-40)+"px";K.appendChild(R);I.scaleBar=new ndpov.ScaleBarWnd(R,this,0);var S=sjsl.getCookie("wsiviewer")||"";if(S.match(/mapWnd=([01])/)&&RegExp.$1==0){T.style.visibility="hidden"}if(S.match(/scaleBar=([012])/)){if(RegExp.$1==1){I.scaleBar.type=0;I.scaleBar.resize()}else{if(RegExp.$1==2){I.scaleBar.type=1;I.scaleBar.resize()}else{R.style.visibility="hidden"}}}this.addEventObserver("change",sjsl.bind(G,G.onchange));this.addEventObserver("change",sjsl.bind(N,N.onchange));this.addEventObserver("changeviewmode",sjsl.bind(modeButton,modeButton.onchange));if(this.zstep!=0&&this.zmin!=this.zmax){N.onclick=function(){var U=new Array();for(var X=I.viewer.zmin,V=0;X<=I.viewer.zmax;X+=I.viewer.zstep,++V){if(X<0){U[V]={img:ndpov.IMAGE_BASE+"mZm.png",img_f:ndpov.IMAGE_BASE+"mZmf.png",mess:(X/1000)+" μm"}}else{if(X>0){U[V]={img:ndpov.IMAGE_BASE+"mZp.png",img_f:ndpov.IMAGE_BASE+"mZpf.png",mess:(X/1000)+" μm"}}else{U[V]={img:ndpov.IMAGE_BASE+"mZ0.png",img_f:ndpov.IMAGE_BASE+"mZ0f.png",mess:(X/1000)+" μm"}}}}var W=new sjsl.Selecter(I.element,U,parseInt(N.element.style.left),parseInt(N.element.style.top)+N.element.offsetHeight);W.onselected=function(Y){I.viewer.setPosition(I.viewer.getPosX(),I.viewer.getPosY(),I.viewer.zmin+Y*I.viewer.zstep)}}}sjsl.eventObserver(document);document.addEventObserver("keydown",sjsl.bind(I,I.onkeydown));this.setPosLensMap();this.setViewMode(this.viewMode)})};ndpov.WSIViewer.prototype={resize:function(){this.width=this.element.offsetWidth;this.height=this.element.offsetHeight;if(this.viewer){this.viewer.element.style.width=this.width+"px";this.viewer.element.style.height=(this.height-44)+"px";this.viewer.resize()}if(this.mapWnd){this.mapWnd.element.style.left=(this.viewer.element.offsetWidth*3/4-10)+"px";this.mapWnd.element.style.top=(this.viewer.element.offsetHeight*3/4-10)+"px";this.mapWnd.element.style.width=(this.viewer.element.offsetWidth/4)+"px";this.mapWnd.element.style.height=(this.viewer.element.offsetHeight/4)+"px";this.mapWnd.resize()}if(this.scaleBar){this.scaleBar.element.style.top=(this.viewer.element.offsetHeight-40)+"px";this.scaleBar.resize()}},onkeydown:function(B){if(!this.viewer.isValid()||this.viewer.queryModal){return }switch(sjsl.getKeyCode(B)){case 66:if(this.scaleBar.element.style.visibility=="hidden"){this.scaleBar.element.style.visibility="visible";this.scaleBar.type=0;this.scaleBar.resize()}else{if(this.scaleBar.type==0){this.scaleBar.type=1;this.scaleBar.resize()}else{this.scaleBar.element.style.visibility="hidden"}}break;case 67:case 69:this.exportButton.onclick();break;case 83:this.statusButton.onclick();break;case 77:if(this.mapWnd.element.style.visibility=="hidden"){this.mapWnd.element.style.visibility="visible"}else{this.mapWnd.element.style.visibility="hidden"}break;case 72:this.helpButton.onclick();break}var A=sjsl.getCookie("wsiviewer")||"mapWnd=1,scaleBar=1";A=A.replace(/mapWnd=[01]/,"mapWnd="+((this.mapWnd.element.style.visibility=="hidden")?0:1));A=A.replace(/scaleBar=[012]/,"scaleBar="+((this.scaleBar.element.style.visibility=="hidden")?0:(1+this.scaleBar.type)));sjsl.setCookie("wsiviewer",A)}};ndpov.MapWnd=function(B,C,D){this.element=B;this.itemID=C;this.viewer=D;this.baseWidth=this.element.offsetWidth;this.baseHeight=this.element.offsetHeight;this.element.style.backgroundColor="gray";this.element.style.overflow="hidden";sjsl.eventObserver(this.element);this.element.addEventObserver("click",sjsl.bind(this,this.onclick));var A=this;this.element.addEventObserver("mousemove",function(E){if(!A.rubberBand){sjsl.cancelBubble(E);return false}});this.element.addEventObserver("contextmenu",function(E){sjsl.cancelBubble(E);return false});this.element.addEventObserver("mousedown",sjsl.bind(this,this.onmousedown));this.element.addEventObserver("mouseup",sjsl.bind(this,this.onmouseup));this.img=document.createElement("img");this.img.style.position="absolute";this.img.style.left="1px";this.img.style.top="1px";this.element.appendChild(this.img);this.frameW=document.createElement("div");this.frameW.style.border="1px solid gray";this.frameW.style.position="absolute";this.frameW.style.fontSize="0px";this.element.appendChild(this.frameW);this.frame=document.createElement("div");this.frame.style.border="1px solid black";this.frame.style.position="absolute";this.frame.style.fontSize="0px";this.element.appendChild(this.frame);this.viewer.addEventObserver("change",sjsl.bind(this,this.onchange));this.viewer.addEventObserver("refresh",sjsl.bind(this,this.onrefresh));this.rotation=-1;this.resize()};ndpov.MapWnd.prototype={onrefresh:function(){this.img.count=0;this.img.onerror=function(C){if(++this.count<5){this.src=this.src}};var B=this.viewer.getPhysicalPos();var A=this.viewer.getPixelSize();this.img.src=this.viewer.getImageURI(B.x,B.y,0,this.width*this.viewer.sourcelens/A.width,this.width,this.height)},resize:function(){this.width=this.baseWidth-2;this.height=this.baseHeight-2;var A=this.viewer.getPixelSize();if(this.width/A.width<this.height/A.height){this.height=Math.floor(this.width*A.height/A.width)}else{this.width=Math.floor(this.height*A.width/A.height)}this.onrefresh();this.element.style.left=(this.viewer.element.offsetWidth-this.width-10)+"px";this.element.style.top=(this.viewer.element.offsetHeight-this.height-10)+"px";this.element.style.width=(this.width+2)+"px";this.element.style.height=(this.height+2)+"px";this.recalcFrame()},recalcFrame:function(){var C=this.viewer.getPhysicalPos();var E=this.viewer.getPhysicalSize();var B=this.viewer.getPixelSize();var A=this.width*(this.viewer.element.offsetWidth*this.viewer.sourcelens/this.viewer.currentLens)/B.width;var D=this.height*(this.viewer.element.offsetHeight*this.viewer.sourcelens/this.viewer.currentLens)/B.height;var G=(this.viewer.getPosX()-C.x)*this.width/E.width+this.width/2-A/2;var F=(this.viewer.getPosY()-C.y)*this.height/E.height+this.height/2-D/2;this.frame.style.left=Math.floor(G+1-1)+"px";this.frame.style.top=Math.floor(F+1-1)+"px";this.frame.style.width=Math.floor(A+2)+"px";this.frame.style.height=Math.floor(D+2)+"px";this.frameW.style.left=Math.floor(G+1-1+1)+"px";this.frameW.style.top=Math.floor(F+1-1+1)+"px";this.frameW.style.width=Math.floor(A+2)+"px";this.frameW.style.height=Math.floor(D+2)+"px"},onchange:function(A,D,C,B){if(this.rotation!=this.viewer.rotation){this.rotation=this.viewer.rotation;this.resize()}else{this.recalcFrame()}},onclick:function(E){var D=sjsl.getSrcElement(E);var A=sjsl.getMouseXonSrcElement(E);var F=sjsl.getMouseYonSrcElement(E);while(D!=this.element){if(!D){return }A+=parseInt(D.style.left);F+=parseInt(D.style.top);D=D.parentNode}var B=this.viewer.getPhysicalPos();var C=this.viewer.getPhysicalSize();A=(A-1-this.width/2)*C.width/this.width+B.x;F=(F-1-this.height/2)*C.height/this.height+B.y;this.viewer.setPosition(A,F,this.viewer.getPosZ())},onmousedown:function(C){if(sjsl.getMouseButton(C)==2){var B=sjsl.getSrcElement(C);var D=sjsl.getMouseXonSrcElement(C);var A=sjsl.getMouseYonSrcElement(C);while(B!=this.element){if(!B){return }D+=parseInt(B.style.left);A+=parseInt(B.style.top);B=B.parentNode}this.rubberBand=new sjsl.RectTracker(sjsl.getMouseX(C),sjsl.getMouseY(C));this.rubberBand.onfinished=sjsl.bind(this,function(F,E,P,N){var K=Math.min(F,P)-(F-D);var J=Math.min(E,N)-(E-A);var L=Math.abs(P-F);var G=Math.abs(N-E);var I=this.viewer.getPhysicalPos();var Q=this.viewer.getPhysicalSize();K=(K-this.width/2+L/2)*Q.width/this.width+I.x;J=(J-this.height/2+G/2)*Q.height/this.height+I.y;var H=this.viewer.getPixelSize();var O=this.viewer.sourcelens*this.viewer.element.offsetWidth/(H.width*L/this.width);var M=this.viewer.sourcelens*this.viewer.element.offsetHeight/(H.height*G/this.height);this.viewer.setPosLens(K,J,this.viewer.getPosZ(),O<M?O:M)})}sjsl.cancelBubble(C);return false},onmouseup:function(A){if(this.rubberBand){this.rubberBand=null}}};ndpov.ScaleBarWnd=function(A,C,B){this.element=A;this.viewer=C;this.viewer.addEventObserver("change",sjsl.bind(this,this.onchange));this.type=B;this.resize()};ndpov.ScaleBarWnd.prototype={resize:function(){var H,C;if(this.type==0){H="#FFFFFF";C="#000000"}else{H="#000000";C="#FFFFFF"}var K=this.viewer.pixelToNanoX(this.viewer.element.offsetWidth/2,this.viewer.currentLens);var M=1;while(K>=10){K/=10;M*=10}K=parseInt(K);if(K==7){K=6}var G=([0,4,4,3,4,5,3,0,4,3])[K];var A;var J;if(M>=1000000){J="mm";A=M/1000000}else{if(M>=1000){J="μm";A=M/1000}else{uint="nm";A=M}}var D=this.viewer.nanoToPixelX(K*M,this.viewer.currentLens);this.element.innerHTML="";var L=document.createElement("div");L.style.position="absolute";L.style.left="9px";L.style.top="1px";L.style.width=D+"px";L.style.height="3px";L.style.fontSize="0px";L.style.backgroundColor=C;L.style.zIndex=0;this.element.appendChild(L);for(var B=0;B<G+1;++B){var L=document.createElement("div");L.style.position="absolute";L.style.left=(9+D/G*B)+"px";L.style.top="1px";L.style.width="3px";L.style.height="12px";L.style.fontSize="0px";L.style.backgroundColor=C;L.style.zIndex=0;this.element.appendChild(L);var I=document.createElement("div");I.style.position="absolute";I.style.left=(11+D/G*B-30)+"px";I.style.top="13px";I.style.width="60px";I.style.height="20px";I.style.fontSize="20px";I.style.color=C;I.style.zIndex=1;I.style.textAlign="center";I.appendChild(document.createTextNode(K*A/G*B));this.element.appendChild(I)}var I=document.createElement("div");I.style.position="absolute";I.style.left=(11+D+5)+"px";I.style.top="13px";I.style.width="60px";I.style.height="20px";I.style.fontSize="20px";I.style.color=C;I.style.zIndex=1;I.style.textAlign="center";I.appendChild(document.createTextNode(J));this.element.appendChild(I);var E=document.createElement("div");E.style.position="absolute";E.style.left="8px";E.style.top="0px";E.style.width=D+"px";E.style.height="3px";E.style.fontSize="0px";E.style.backgroundColor=H;E.style.zIndex=1;this.element.appendChild(E);for(var B=0;B<G+1;++B){var E=document.createElement("div");E.style.position="absolute";E.style.left=(8+D/G*B)+"px";E.style.top="0px";E.style.width="3px";E.style.height="12px";E.style.fontSize="0px";E.style.backgroundColor=H;E.style.zIndex=1;this.element.appendChild(E);var F=document.createElement("div");F.style.position="absolute";F.style.left=(10+D/G*B-30)+"px";F.style.top="12px";F.style.width="60px";F.style.height="20px";F.style.fontSize="20px";F.style.color=H;F.style.zIndex=1;F.style.textAlign="center";F.appendChild(document.createTextNode(K*A/G*B));this.element.appendChild(F)}var F=document.createElement("div");F.style.position="absolute";F.style.left=(10+D+5)+"px";F.style.top="12px";F.style.width="60px";F.style.height="20px";F.style.fontSize="20px";F.style.color=H;F.style.zIndex=1;F.style.textAlign="center";F.appendChild(document.createTextNode(J));this.element.appendChild(F)},onchange:function(A,D,C,B){this.resize()}};