var SkyMaps=Class.create();SkyMaps.prototype={initialize:function(a,d,b){this.skyMapsId=a;$(this.skyMapsId).maps=$H();this.setOptions(b);$(this.skyMapsId).options=this.options;this.divWellClass="well";this.divActiveSurfaceClass="surface";this.divStatusDimensionsId="status_dimensions";this.statusDimensionsLabelId="status_label_id";tileWell=document.createElement("div");tileWell.setAttribute("class",this.divWellClass);$(this.skyMapsId).appendChild(tileWell);$(this.skyMapsId).tileWell=tileWell;activeSurface=document.createElement("div");activeSurface.setAttribute("class",this.divActiveSurfaceClass);activeSurface.setAttribute("id","surface-findoverlapping");$(this.skyMapsId).appendChild(activeSurface);$(this.skyMapsId).activeSurface=activeSurface;statusDimensions=document.createElement("div");statusDimensions.setAttribute("id",this.divStatusDimensionsId);$(this.skyMapsId).appendChild(statusDimensions);$(this.skyMapsId).statusDimensions=statusDimensions;statusLabel=document.createElement("label");statusLabel.setAttribute("id",this.statusDimensionsLabelId);$(this.skyMapsId).statusDimensions.appendChild(statusLabel);ArchiveMap.ArchivesArray.each(function(e){$(this.skyMapsId).maps[e.archiveId]=new ArchiveMap(e.archiveName,e.archiveUrl,e.archiveTip,e.tilesArray,e.imageSrc,e.archiveId,e.archiveColor,e.isArchive,e.showArchive)}.bind(this));this.setStyleSheet();zoomLevel=-1;fullSize=this.options.tileSize*Math.pow(2,zoomLevel);do{zoomLevel+=1;fullSize*=2}while(fullSize<Math.max(this.options.width,this.options.height));corner={x:((fullSize-this.options.width)/-2),y:((fullSize-this.options.height)/-2)};$(this.skyMapsId).variables={zoomLevel:zoomLevel,x:corner.x,y:corner.y,offsetWidth:$(this.skyMapsId).offsetWidth,offsetHeight:$(this.skyMapsId).offsetHeight};$(this.skyMapsId).start={x:0,y:0};$(this.skyMapsId).mouse={x:0,y:0};$(this.skyMapsId).pressed=false;$(this.skyMapsId).releaseViewer=this.releaseViewer.bind(this);$(this.skyMapsId).activeSurface.onmouseup=$(this.skyMapsId).releaseViewer;$(this.skyMapsId).mouseMove=this.mouseMove.bind(this);$(this.skyMapsId).activeSurface.onmousemove=$(this.skyMapsId).mouseMove;$(this.skyMapsId).updateSkyMaps=this.updateSkyMaps.bind(this);$(this.skyMapsId).updateSkyMapsVisibility=this.updateSkyMapsVisibility.bind(this);$(this.skyMapsId).updateStatusDimensions=this.updateStatusDimensions.bind(this);$(this.skyMapsId).localizeCoordinates=this.localizeCoordinates.bind(this);$(this.skyMapsId).cleanImagesFromSky=this.cleanImagesFromSky.bind(this);$(this.skyMapsId).zoom=new ZoomController(this.skyMapsId,"zoom-controller");$(this.skyMapsId).flags=new CollectionFlags(this.skyMapsId,"collection-flags");$(this.skyMapsId).dwfs=new CollectionDWFs(this.skyMapsId,"collection-dwfs");$(this.skyMapsId).objectfinder=new ObjectFinder(this.skyMapsId);$(this.skyMapsId).search=new ShowAndSearchByArchive(this.skyMapsId,"show-search-archive");this.defaultRules={"#surface-findoverlapping":function(e){e.ondblclick=function(f){$(this.skyMapsId).search.findOverlappingImages()}.bind(this)}.bind(this)};this.setRules(d);this.skymapStatusArray=new Array();this.preparePersistence();this.updateStatusDimensions();this.prepareTiles();$(this.skyMapsId).dwfs.updateDWFs();if(persistence){persistence.createArchivesNameList();if(persistence.thereIsPersistence()){$(this.skyMapsId).variables.x+=($(this.skyMapsId).mouse.x-$(this.skyMapsId).start.x);$(this.skyMapsId).variables.y+=($(this.skyMapsId).mouse.y-$(this.skyMapsId).start.y)}}document.onmousemove=this.onResizeSkyMaps.bind(this)},setOptions:function(a){this.options={parentDivId:"upper",skymapStatusDivId:"skymaps-status",zoomLevelDifferentProjection:7,width:1024,height:512,tileSize:256,imagesBase:"/images/skymap"};Object.extend(this.options,a||{})},setRules:function(a){this.rules=a||this.defaultRules;this.registerRules()},registerRules:function(){Behaviour.register(this.rules)},applyRules:function(){Behaviour.applyRulesOn(this.defaultRules)},setStyleSheet:function(){skyMapStyle=document.styleSheets[0];length=skyMapStyle.cssRules?skyMapStyle.cssRules.length:skyMapStyle.rules.length;declaration="."+this.skyMapsId+"{position: absolute;margin: 0px;padding: 0px;top: 0px;left: 0px;width: 100%;height: 100%;overflow: hidden;color: black;}";skyMapStyle.insertRule(declaration,length);length=skyMapStyle.cssRules?skyMapStyle.cssRules.length:skyMapStyle.rules.length;declaration="img."+this.skyMapsId+" {position: relative;background-color: transparent;overflow: hidden;z-index: 2;}";skyMapStyle.insertRule(declaration,length);length=skyMapStyle.cssRules?skyMapStyle.cssRules.length:skyMapStyle.rules.length;declaration="."+this.skyMapsId+" ."+this.divActiveSurfaceClass+"{background-color: transparent;background-image: url('"+this.options.imagesBase+"/others/center.gif');background-repeat: no-repeat;background-position: center center;z-index: 2;}";skyMapStyle.insertRule(declaration,length);length=skyMapStyle.cssRules?skyMapStyle.cssRules.length:skyMapStyle.rules.length;declaration="."+this.skyMapsId+" ."+this.divWellClass+"{background-color: gray;background-image: url('"+this.options.imagesBase+"/null/none.png');overflow: hidden;}";skyMapStyle.insertRule(declaration,length);length=skyMapStyle.cssRules?skyMapStyle.cssRules.length:skyMapStyle.rules.length;declaration="."+this.skyMapsId+" ."+this.divWellClass+", ."+this.skyMapsId+" ."+this.divActiveSurfaceClass+"{position: absolute;top: 0px;left: 0px;width: 100%;height: 100%;cursor: default;}";skyMapStyle.insertRule(declaration,length);length=skyMapStyle.cssRules?skyMapStyle.cssRules.length:skyMapStyle.rules.length;declaration="."+this.skyMapsId+" ."+this.divWellClass;archivesArray=[];$(this.skyMapsId).maps.values().each(function(a){archivesArray.push("."+a.getArchiveId())}.bind(this));declaration=declaration+" "+archivesArray.join(" ,")+"{margin: 0;padding: 0;position: absolute;top: 0px;left: 0px;display: block;}";skyMapStyle.insertRule(declaration,length);length=skyMapStyle.cssRules?skyMapStyle.cssRules.length:skyMapStyle.rules.length;declaration="."+this.skyMapsId+" #"+this.divStatusDimensionsId+"{background-color: white;position: absolute;top: 10px;left: 40px;font-size: 12px;}";skyMapStyle.insertRule(declaration,length)},preparePersistence:function(){if(!persistence){return}if(persistence.isFirstTime()){persistence.initializePersistence()}else{if(persistence.thereIsPersistence()){persistence.resetSkyMapsValues()}}},updateSkymapStatus:function(){if(this.skymapStatusArray.length>0){$(this.options.skymapStatusDivId).innerHTML=this.skymapStatusArray.join("<br>")}},onResizeSkyMaps:function(){skyMaps=$(this.skyMapsId);if(skyMaps.variables.offsetWidth!=skyMaps.offsetWidth&&skyMaps.variables.offsetHeight!=skyMaps.offsetHeight){skyMaps.search.updateRangeSearchValues();skyMaps.variables.offsetWidth=skyMaps.offsetWidth;skyMaps.variables.offsetHeight=skyMaps.offsetHeight;if(persistence.thereIsPersistence()){persistence.offsetWidth=skyMaps.offsetWidth;persistence.offsetHeight=skyMaps.offsetHeight}}},updateStatusDimensions:function(){skyMaps=$(this.skyMapsId);fullSize=skyMaps.options.tileSize*Math.pow(2,skyMaps.variables.zoomLevel);zoomLevel=skyMaps.variables.zoomLevel;px=skyMaps.mouse.x-skyMaps.variables.x;py=skyMaps.mouse.y+Math.abs(skyMaps.variables.y);lonlat=PxPyToLonLat(fullSize,zoomLevel,px,py);ra=(lonlat.lon)?(lonlat.lon+180).toFixed(2):"0.00";dec=(lonlat.lat)?(lonlat.lat).toFixed(2):"0.00";text="&nbsp;Zoom="+skyMaps.variables.zoomLevel+"&nbsp;<br>";text+="&nbsp;RA="+ra+",Dec="+dec+"&nbsp;";$(this.statusDimensionsLabelId).innerHTML=text},prepareTiles:function(){skyMaps=$(this.skyMapsId);rows=Math.ceil(this.options.height/this.options.tileSize)+1;cols=Math.ceil(this.options.width/this.options.tileSize)+1;archives=skyMaps.maps.values();for(var a=0;a<archives.length;a++){for(var d=0;d<cols;d+=1){tileCol=[];for(var b=0;b<rows;b+=1){tile={c:d,r:b,img:document.createElement("img")};tile.img.setAttribute("class",archives[a].getArchiveId());tile.img.style.width=skyMaps.options.tileSize+"px";tile.img.style.height=skyMaps.options.tileSize+"px";skyMaps.tileWell.appendChild(tile.img);tileCol.push(tile)}archives[a].pushTile(tileCol)}}this.updateSkyMaps();skyMaps.activeSurface.onmousedown=this.pressViewer.bind(this)},cleanImagesFromSky:function(){skyMaps=$(this.skyMapsId);archives=skyMaps.maps.values();for(var a=0;a<archives.length;a++){tilesArray=archives[a].getTiles();for(c=0;c<tilesArray.length;c+=1){for(r=0;r<tilesArray[c].length;r+=1){tilesArray[c][r].img.src=skyMaps.options.imagesBase+"/null/none.png"}}}},setArchivePositionTiles:function(a){skyMaps=$(this.skyMapsId);tileSize=skyMaps.options.tileSize;width=skyMaps.options.width;height=skyMaps.options.height;tilesArray=a.getTiles();tilesSrc=a.getTilesDir();visibility="visible";if(!a.isVisible()){visibility="hidden"}for(c=0;c<tilesArray.length;c+=1){for(r=0;r<tilesArray[c].length;r+=1){tile=tilesArray[c][r];wrappedAround=false;tile.x=(tile.c*tileSize)+skyMaps.variables.x+(skyMaps.mouse.x-skyMaps.start.x);tile.y=(tile.r*tileSize)+skyMaps.variables.y+(skyMaps.mouse.y-skyMaps.start.y);if(tile.x>width){do{tile.c-=tilesArray.length;tile.x=(tile.c*tileSize)+skyMaps.variables.x+(skyMaps.mouse.x-skyMaps.start.x)}while(tile.x>width);wrappedAround=true}else{while(tile.x<(-1*tileSize)){tile.c+=tilesArray.length;tile.x=(tile.c*tileSize)+skyMaps.variables.x+(skyMaps.mouse.x-skyMaps.start.x);wrappedAround=true}}if(tile.y>height){do{tile.r-=tilesArray[c].length;tile.y=(tile.r*tileSize)+skyMaps.variables.y+(skyMaps.mouse.y-skyMaps.start.y)}while(tile.y>height);wrappedAround=true}else{while(tile.y<(-1*tileSize)){tile.r+=tilesArray[c].length;tile.y=(tile.r*tileSize)+skyMaps.variables.y+(skyMaps.mouse.y-skyMaps.start.y);wrappedAround=true}}this.setSrcImage(tile,tilesSrc,wrappedAround);this.setSrcImage(tile,tilesSrc,false);tile.img.style.top=tile.y+"px";tile.img.style.left=tile.x+"px";tile.img.style.visibility=visibility}}},setPositionTiles:function(){skyMaps=$(this.skyMapsId);if(zoomLevel>=skyMaps.zoom.options.levelWMS){this.setArchivePositionTiles(skyMaps.maps.grid)}else{archives=skyMaps.maps.values();for(var a=0;a<archives.length;a++){this.setArchivePositionTiles(archives[a])}}},setSrcImage:function(b,d,a){skyMaps=$(this.skyMapsId);zoomLevel=skyMaps.variables.zoomLevel;src=skyMaps.options.imagesBase+"/"+d+"/tiles/tile-"+zoomLevel+"-"+b.c+"-"+b.r+".png";if(zoomLevel>=skyMaps.zoom.options.levelWMS){src=this.getWMSImageURL(zoomLevel,b.c,b.r)}left=b.c<0;high=b.r<0;right=b.c>=Math.pow(2,zoomLevel);low=b.r>=Math.pow(2,zoomLevel);outside=high||left||low||right;nullDir=skyMaps.options.imagesBase+"/null";if(a){src=nullDir+"/none.png"}else{if(high&&left){src=nullDir+"/top-left.png"}else{if(low&&left){src=nullDir+"/bottom-left.png"}else{if(high&&right){src=nullDir+"/top-right.png"}else{if(low&&right){src=nullDir+"/bottom-right.png"}else{if(high){src=nullDir+"/top.png"}else{if(right){src=nullDir+"/right.png"}else{if(low){src=nullDir+"/bottom.png"}else{if(left){src=nullDir+"/left.png"}}}}}}}}}b.img.src=src},getWMSImageURL:function(d,a,b){WMS_URL="http://nvogre.phyast.pitt.edu/cgi-bin/nvomapserv?";WMS_VERSION="1.0.0";WMS_LAYERS="sdssimgl0,sdssimgl1,sdssimgl2,sdssimgl3";WMS_STYLES="default";WMS_SRS="EPSG:4326";WMS_FORMAT="image/jpeg";WMS_TRANSPARENT="TRUE";TILE_SIZE="256";tiles=Math.pow(2,d);dRA=360/tiles;dDEC=360/tiles;min={lon:dRA*(a)-180,lat:180-dDEC*(b+1)};max={lon:dRA*(a+1)-180,lat:180-dDEC*(b)};BBOX=min.lon+","+min.lat+","+max.lon+","+max.lat;return WMS_URL+"VERSION="+WMS_VERSION+"&REQUEST=GetMap&LAYERS="+WMS_LAYERS+"&STYLES="+WMS_STYLES+"&SRS="+WMS_SRS+"&BBOX="+BBOX+"&WIDTH="+TILE_SIZE+"&HEIGHT="+TILE_SIZE+"&FORMAT="+WMS_FORMAT+"&TRANSPARENT="+WMS_TRANSPARENT+"&EXCEPTIONS=INIMAGE"},updateSkyMaps:function(){this.setPositionTiles();skyMaps=$(this.skyMapsId);skyMaps.zoom.setPositionBar(skyMaps.variables.zoomLevel);skyMaps.flags.setPositionFlags();skyMaps.dwfs.setDImagesPosition();skyMaps.objectfinder.setZoomOption();skyMaps.search.updateRangeSearchValues();if(persistence){persistence.update()}},updateSkyMapsVisibility:function(a){if(!a){a=$(this.skyMapsId).maps.keys()}a.each(function(b){archive=$(this.skyMapsId).maps[b];tilesArray=archive.getTiles();for(c=0;c<tilesArray.length;c+=1){for(r=0;r<tilesArray[c].length;r+=1){tile=tilesArray[c][r];if(archive.isVisible()){tile.img.style.visibility="visible"}else{tile.img.style.visibility="hidden"}}}}.bind(this));persistence.updateArchivesSelected()},getEvent:function(a){return a||window.event},localizeCoordinates:function(a){local={x:a.x,y:a.y};for(node=$(this.skyMapsId);node;node=node.offsetParent){local.x-=node.offsetLeft;local.y-=node.offsetTop}return local},releaseViewer:function(a){ev=this.getEvent(a);skyMaps=$(this.skyMapsId);skyMaps.mouse=this.localizeCoordinates({x:ev.clientX,y:ev.clientY});skyMaps.activeSurface.focus();skyMaps.activeSurface.blur();if(skyMaps.pressed){skyMaps.pressed=false;skyMaps.tileWell.style.cursor=skyMaps.activeSurface.style.cursor="default";skyMaps.variables.x+=(skyMaps.mouse.x-skyMaps.start.x);skyMaps.variables.y+=(skyMaps.mouse.y-skyMaps.start.y);skyMaps.search.updateRangeSearchValues()}},mouseMove:function(a){ev=this.getEvent(a);$(this.skyMapsId).mouse=this.localizeCoordinates({x:ev.clientX,y:ev.clientY});if($(this.skyMapsId).pressed){this.updateSkyMaps()}else{this.updateStatusDimensions()}},pressViewer:function(a){skyMaps=$(this.skyMapsId);skyMaps.pressed=true;skyMaps.tileWell.style.cursor=skyMaps.activeSurface.style.cursor="move";ev=this.getEvent(a);skyMaps.mouse=this.localizeCoordinates({x:ev.clientX,y:ev.clientY});skyMaps.start={x:skyMaps.mouse.x,y:skyMaps.mouse.y}}};var ZoomController=Class.create();ZoomController.prototype={initialize:function(e,d,b,a){this.parentId=e;this.zoomId=d;this.setOptions(a);this.mouse={x:0,y:0};this.mousePressed=false;this.factor=10;this.zoomMax=this.options.levelMax+1;this.zoomMin=0;this.scaleDimensions={left:10,top:25,width:15,height:this.zoomMax*this.factor};this.scaleBarDimensions={width:15,height:9};zoomDiv=document.createElement("div");zoomDiv.setAttribute("id",this.zoomId);zoomDiv.setAttribute("class",this.zoomId);$(this.parentId).appendChild(zoomDiv);link=document.createElement("a");link.setAttribute("id",this.options.zoomInId);link.setAttribute("href","javascript:void(0);");image=document.createElement("img");image.setAttribute("onmousedown","return false;");image.setAttribute("src",this.options.zoomImageSrc+"/"+this.options.zoomInImageName);image.setAttribute("title","Zoom In");image.style.left="10px";image.style.top="10px";link.appendChild(image);zoomDiv.appendChild(link);link=document.createElement("a");link.setAttribute("id",this.options.zoomScaleId);link.setAttribute("href","javascript:void(0);");image=document.createElement("img");image.setAttribute("onmousedown","return false;");image.setAttribute("id",this.options.zoomScaleImageId);image.setAttribute("src",this.options.zoomImageSrc+"/"+this.options.zoomScaleImageName);image.setAttribute("title","Click to set zoom level");image.style.left=this.scaleDimensions.left+"px";image.style.top=this.scaleDimensions.top+"px";link.appendChild(image);zoomDiv.appendChild(link);link=document.createElement("a");link.setAttribute("id",this.options.zoomBarId);link.setAttribute("href","javascript:void(0);");image=document.createElement("img");image.setAttribute("onmousedown","return false;");image.setAttribute("id",this.options.zoomBarImageId);image.setAttribute("src",this.options.zoomImageSrc+"/"+this.options.zoomBarImageName);image.setAttribute("title","Drag to zoom");image.style.left="10px";image.style.cursor="url('"+$(this.parentId).options.imagesBase+"/others/openhand.cur'),default";link.appendChild(image);zoomDiv.appendChild(link);link=document.createElement("a");link.setAttribute("id",this.options.zoomOutId);link.setAttribute("href","javascript:void(0);");image=document.createElement("img");image.setAttribute("onmousedown","return false;");image.setAttribute("src",this.options.zoomImageSrc+"/"+this.options.zoomOutImageName);image.setAttribute("title","Zoom Out");image.style.left="10px";image.style.top=(this.scaleDimensions.height+this.scaleDimensions.top)+"px";link.appendChild(image);zoomDiv.appendChild(link);this.defaultRules={"#zoom-in":function(f){f.onclick=function(g){this.zoomImageIn(1)}.bind(this)}.bind(this),"#zoom-out":function(f){f.onclick=function(g){this.zoomImageOut(-1)}.bind(this)}.bind(this),"#zoom-scale":function(f){f.onmousedown=function(g){this.zoomImageScale(g)}.bind(this)}.bind(this),"#zoom-bar":function(f){f.onmousedown=function(g){this.zoomImageDrag(g)}.bind(this)}.bind(this)};this.setRules(b);this.setStyleSheet()},setOptions:function(a){this.options={levelMax:11,levelWMS:10,zoomImageSrc:$(this.parentId).options.imagesBase+"/others",zoomInImageName:"zoomin.gif",zoomInId:"zoom-in",zoomScaleId:"zoom-scale",zoomScaleImageName:"scale.png",zoomScaleImageId:"zoom-scale-image",zoomBarId:"zoom-bar",zoomBarImageName:"scalebar.gif",zoomBarImageId:"zoom-bar-image",zoomOutImageName:"zoomout.gif",zoomOutId:"zoom-out"};Object.extend(this.options,a||{})},setRules:function(a){this.rules=a||this.defaultRules;this.registerRules()},registerRules:function(){Behaviour.register(this.rules)},setStyleSheet:function(){skyMapStyle=document.styleSheets[0];length=skyMapStyle.cssRules?skyMapStyle.cssRules.length:skyMapStyle.rules.length;declaration="."+this.parentId+" ."+this.zoomId+"{background-color: black;position: absolute;margin: 0;padding: 0 0 0 4px;left: 0px;}";skyMapStyle.insertRule(declaration,length);length=skyMapStyle.cssRules?skyMapStyle.cssRules.length:skyMapStyle.rules.length;declaration="."+this.parentId+" ."+this.zoomId+" img{border: 0;position: absolute;z-index: 3;}";skyMapStyle.insertRule(declaration,length)},zoomPixel:function(a){y0=this.scaleDimensions.top;length=this.scaleDimensions.height;return(y0+(length*(this.zoomMax-a))/(this.zoomMax))},setPositionBar:function(a){zp=this.zoomPixel(a);$(this.options.zoomBarImageId).style.top=(zp-4)+"px"},zoomImageIn:function(a){zoomLevel=$(this.parentId).variables.zoomLevel;if(zoomLevel+a<this.zoomMax){this.zoomImageDifferentProjection(a)}},zoomImageOut:function(a){zoomLevel=$(this.parentId).variables.zoomLevel;if(zoomLevel+a>this.zoomMin){this.zoomImageDifferentProjection(a)}},zoomImage:function(a){skyMaps=$(this.parentId);mouse={x:skyMaps.clientWidth/2,y:skyMaps.clientHeight/2};corner={x:skyMaps.variables.x,y:skyMaps.variables.y};tileSize=skyMaps.options.tileSize;pos={before:{x:0,y:0}};pos.before.x=(mouse.x-pos.before.x)-corner.x;pos.before.y=(mouse.y-pos.before.y)-corner.y;pos.before.width=pos.before.height=Math.pow(2,skyMaps.variables.zoomLevel)*tileSize;pos.after={width:(pos.before.width*Math.pow(2,a)),height:(pos.before.height*Math.pow(2,a))};pos.after.x=pos.before.x*Math.pow(2,a);pos.after.y=pos.before.y*Math.pow(2,a);pos.after.left=mouse.x-pos.after.x;pos.after.top=mouse.y-pos.after.y;skyMaps.variables.x=pos.after.left;skyMaps.variables.y=pos.after.top;skyMaps.variables.zoomLevel+=a;skyMaps.start=skyMaps.mouse=mouse;this.updateAfterZoomIsChanged()},zoomImageDifferentProjection:function(a){skyMaps=$(this.parentId);mouse={x:skyMaps.clientWidth/2,y:skyMaps.clientHeight/2};corner={x:skyMaps.variables.x,y:skyMaps.variables.y};tileSize=skyMaps.options.tileSize;zoomLevel=skyMaps.variables.zoomLevel;center={x:mouse.x-corner.x,y:mouse.y+Math.abs(corner.y)};fullSize=tileSize*Math.pow(2,zoomLevel);iscaled=inverseScalePosition(fullSize,center.x,center.y);radLonLat=XYToLonLat(iscaled.x,iscaled.y,zoomLevel);lonlat={lon:AstroMath.radiansToDegree(radLonLat.lon),lat:AstroMath.radiansToDegree(radLonLat.lat)};position=LonLatToXY(lonlat.lon,lonlat.lat,zoomLevel);if((iscaled.x.toPrecision(5)!=position.x.toPrecision(5))||(iscaled.y.toPrecision(5)!=position.y.toPrecision(5))){this.zoomImage(a);return}skyMaps.variables.zoomLevel+=a;zoomLevel=skyMaps.variables.zoomLevel;if(zoomLevel==skyMaps.options.zoomLevelDifferentProjection||zoomLevel==skyMaps.options.zoomLevelDifferentProjection-1){position=LonLatToXY(lonlat.lon,lonlat.lat,zoomLevel)}fullSize=tileSize*Math.pow(2,zoomLevel);skyMaps.variables.x=-position.x*fullSize/2+skyMaps.clientWidth/2-128*Math.pow(2,zoomLevel);skyMaps.variables.y=position.y*fullSize/4-fullSize/4+skyMaps.clientHeight/2-64*Math.pow(2,zoomLevel);skyMaps.start=skyMaps.mouse=mouse;this.updateAfterZoomIsChanged()},updateAfterZoomIsChanged:function(){skyMaps=$(this.parentId);skyMaps.search.updateRangeSearchValues();skyMaps.updateStatusDimensions();skyMaps.cleanImagesFromSky();skyMaps.updateSkyMaps();skyMaps.dwfs.updateDWFs()},zoomLevel:function(a){y0=this.scaleDimensions.top;length=this.scaleDimensions.height;zl=Math.ceil((((y0-a)*this.zoomMax)+(length*this.zoomMax))/length);if(zl<0){zl=0}return zl},zoomImageScale:function(a){skyMaps=$(this.parentId);zoomOld=skyMaps.variables.zoomLevel;this.mousePressed=true;this.mouse=skyMaps.localizeCoordinates({x:a.clientX,y:a.clientY});zoomNew=this.zoomLevel(this.mouse.y);direction=zoomNew-zoomOld;if(zoomNew>zoomOld){this.zoomImageIn(direction)}else{if(zoomNew<zoomOld){this.zoomImageOut(direction)}}this.mousePressed=false},zoomImageDrag:function(a){this.mousePressed=true;this.mouse=$(this.parentId).localizeCoordinates({x:a.clientX,y:a.clientY});$(this.options.zoomBarImageId).style.cursor=$(this.options.zoomScaleImageId).style.cursor=$(this.parentId).tileWell.style.cursor=$(this.parentId).activeSurface.style.cursor="move";$(this.zoomId).onmousemove=$(this.parentId).activeSurface.onmousemove=this.moveBar.bind(this);if(this.mousePressed){$(this.zoomId).onmouseup=$(this.parentId).activeSurface.onmouseup=this.releaseBar.bind(this);$(this.parentId).activeSurface.onmouseout=this.releaseBar.bind(this)}},moveBar:function(a){y0=this.scaleDimensions.top;length=this.scaleDimensions.height;this.mouse=$(this.parentId).localizeCoordinates({x:a.clientX,y:a.clientY});my=this.mouse.y;if(my>y0&&my<y0+length){zl=this.zoomLevel(my);if(zl<this.zoomMax){this.setPositionBar(this.zoomLevel(my))}}},releaseBar:function(a){if(this.mousePressed){this.mousePressed=false;$(this.zoomId).onmousemove=null;$(this.parentId).activeSurface.onmousemove=$(this.parentId).mouseMove;$(this.parentId).activeSurface.onmouseup=$(this.parentId).releaseViewer;$(this.parentId).activeSurface.onmouseout=null;$(this.options.zoomBarImageId).style.cursor="default";$(this.parentId).tileWell.style.cursor=$(this.parentId).activeSurface.style.cursor="default";$(this.options.zoomScaleImageId).style.cursor="pointer";$(this.options.zoomScaleImageId).style.cursor="hand";zoomOld=$(this.parentId).variables.zoomLevel;zoomNew=this.zoomLevel(this.mouse.y);direction=zoomNew-zoomOld;if(zoomNew>zoomOld){if(zoomNew>=this.zoomMax-1){direction=this.zoomMax-1-zoomOld}this.zoomImageIn(direction)}else{if(zoomNew<zoomOld){if(zoomNew<=this.zoomMin){direction=this.zoomMin+1-zoomOld}this.zoomImageOut(direction)}}}}};var Flag=Class.create();Flag.prototype={initialize:function(d,e,b,a){this.image=d;this.lon=e;this.lat=b;this.time=a}};var CollectionFlags=Class.create();CollectionFlags.prototype={initialize:function(e,b,d,a){this.parentId=e;this.flagsId=b;this.flagsLength=0;this.flags=$H();this.setOptions(a);this.defaultRules={"#upload_flag_coordinates":function(f){f.onclick=function(g){this.uploadFlagCoordinates()}.bind(this)}.bind(this),"#add_flags_to_sky":function(f){f.onclick=function(g){this.addFlagCollectionToSky()}.bind(this)}.bind(this),"#remove_flags_from_sky":function(f){f.onclick=function(g){this.removeFlagsFromSky()}.bind(this)}.bind(this),"#xmatch_flags":function(f){f.onclick=function(g){this.xmatchFlags()}.bind(this)}.bind(this)};this.setRules(d);flagsDiv=document.createElement("div");flagsDiv.setAttribute("id",this.flagsId);flagsDiv.setAttribute("class",this.flagsId);$(this.parentId).appendChild(flagsDiv);this.setStyleSheet()},setOptions:function(a){this.options={imageName:"flag.gif",flagId:"flagId_",flagClass:"flag",flagSrc:$(this.parentId).options.imagesBase+"/others",flagsList:"flags-list",width:32,height:32,uploadFormId:"upload_flag_coordinates_form",coordinateListId:"coordinate_list",xmatchUrl:"/data_grid/data_grid/list_resources",xmatchIndicator:"response_indicator_id",xmatchResultDestination:"response_wrapper_id"};Object.extend(this.options,{center:{x:this.options.width/4,y:this.options.height/4}});Object.extend(this.options,a||{})},setRules:function(a){this.rules=a||this.defaultRules;this.registerRules()},registerRules:function(){Behaviour.register(this.rules)},setStyleSheet:function(){skyMapStyle=document.styleSheets[0];length=skyMapStyle.cssRules?skyMapStyle.cssRules.length:skyMapStyle.rules.length;declaration="."+this.parentId+" ."+this.flagsId+" img{position: absolute;top: 0;left: 0;z-index: 1;}";skyMapStyle.insertRule(declaration,length)},isEmpty:function(){return(this.flags.keys().length<=0)?true:false},isFlag:function(d,b,a){flags=this.flags.values();for(i=0;i<flags.length;i++){if(flags[i].lon==d&&flags[i].lat==b&&flags[i].time==a){return true}}return false},createFlagImage:function(d,e,b,a){image=document.createElement("img");image.setAttribute("id",d);image.setAttribute("class",this.options.flagClass);image.setAttribute("src",this.options.flagSrc+"/"+this.options.imageName);title="("+e+", "+b;if(a){title=title+", "+a}title=title+")";image.setAttribute("title",title);$(this.flagsId).appendChild(image);new Effect.Pulsate($(this.flagsId));return image},uploadFlagCoordinates:function(){$(this.options.uploadFormId).onsubmit=AIM.submit($(this.options.uploadFormId),{onStart:function(a){}.bind(this),onComplete:function(a){remoteMessage=a.split("||");status=remoteMessage[0];message=remoteMessage[1];if(status=="OK"){$(this.options.coordinateListId).value=message}else{alert("Error trying to upload the file: "+message)}}.bind(this)});$(this.options.uploadFormId).submit()},addFlagCollectionToSky:function(){coordinate_list_txt=$(this.options.coordinateListId).value;var b=AstroCoordValidations.coordinateListSpec(coordinate_list_txt);var e=b.findAll(function(f){return !f.success});if(e.length>0){var a=e.pluck("explanation");var d=a[0];if(e.length>1){d=d+"\n\n...+ "+(e.length-1)+" more errors..."}alert(d)}else{b.each(function(f){this.addFlagToSky(f.results[0],f.results[1],f.results[2])}.bind(this))}},validateFlagCollectionInRightFormat:function(b){for(var a=0;a<b.length;a++){line=b[a];line.replace(/^\s*/,"").replace(/\s*$/,"");if(line){if(!line.match(/^[+]?\d+(\.\d+)?\s*,\s*[+-]?\d+(\.\d+)?(\s*,\s*\d\d\d\d-\d\d-\d\d)?$/)){return false}}}return true},validateFlagCollectionInRange:function(b){for(var a=0;a<b.length;a++){line=b[a];line.replace(/^\s*/,"").replace(/\s*$/,"");if(line){coords=line.split(/\s*,\s*/);ra=parseFloat(coords[0]);dec=parseFloat(coords[1]);if(!AstroMath.raInRange(ra)||!AstroMath.decInRange(dec)){return false}}}return true},addFlagToSky:function(d,b,a){lon=d-180;lat=b;time=a;if(this.isFlag(lon,lat,time)){message="The mark ("+d+","+b;if(a){message+=","+a}message+=") already exists.";return}flag_id=this.options.flagId+this.flagsLength;this.flags[flag_id]=new Flag(this.createFlagImage(flag_id,d,b,a),lon,lat,time);this.flagsLength+=1;this.createFlagOption(flag_id,d,b,a);persistence.updateFlags();this.setPositionFlags({x:0,y:0})},xmatchFlags:function(){skyMaps=$(this.parentId);if(skyMaps.search.isEmptyArchiveSelected()){alert("You must select at least one Archive.");return}selectedArchives=new Array();skyMaps.search.archiveSelected.values().each(function(a){selectedArchives.push(a)}.bind(this));selectedOptions=[];$A($(this.options.flagsList)).each(function(a){if(a.selected){option_text=a.text.replace(/\s*/,"");selectedOptions.push(option_text)}}.bind(this));if(selectedOptions.length==0){$A($(this.options.flagsList)).each(function(a){option_text=a.text.replace(/\s*/,"");selectedOptions.push(option_text)}.bind(this))}if(selectedOptions.length>0){new Ajax.Updater(this.options.xmatchResultDestination,this.options.xmatchUrl,{method:"post",parameters:$H({xmatch:selectedOptions.join("/"),archives:selectedArchives.join(","),clear_selected_rows:"true"}).toQueryString(),onLoading:function(a){$(this.options.xmatchIndicator).show();$(this.options.xmatchResultDestination).innerHTML=""}.bind(this),onComplete:function(a){$(this.options.xmatchIndicator).hide();grid.onStopRefreshGrid()}.bind(this)})}},createFlagOption:function(d,e,b,a){option=document.createElement("option");option.setAttribute("value",d);optionValue=e+", "+b;if(a){optionValue=optionValue+", "+a}optionValue=optionValue;option.appendChild(document.createTextNode(optionValue));$(this.options.flagsList).appendChild(option)},removeFlagsFromSky:function(){if(!this.isEmpty()){optionSelected=new Array();$A($(this.options.flagsList)).each(function(a){if(a.selected){optionSelected.push(a)}}.bind(this));if(optionSelected.length>0){optionSelected.each(function(a){$(this.flagsId).removeChild($(a.value));$(this.options.flagsList).removeChild(a);delete this.flags[a.value];persistence.updateFlags()}.bind(this))}else{alert("You must select some flag.")}}else{alert("List of Flags is empty.")}},setPositionFlags:function(a){if(!this.isEmpty()){skyMaps=$(this.parentId);mouse=skyMaps.mouse;start=skyMaps.start;tileSize=skyMaps.options.tileSize;zoomLevel=skyMaps.variables.zoomLevel;fullSize=(tileSize*Math.pow(2,zoomLevel));corner={x:skyMaps.variables.x,y:skyMaps.variables.y};this.flags.values().each(function(b){position=LonLatToXY(b.lon,b.lat,zoomLevel);scale=scalePosition(fullSize,position.x,position.y);if(!a){a={x:(mouse.x-start.x),y:(mouse.y-start.y)}}px=Math.ceil(scale.px+corner.x+a.x-this.options.center.x);py=Math.ceil(scale.py+corner.y+a.y-this.options.center.y);b.image.style.left=px+"px";b.image.style.top=py+"px"}.bind(this))}}};var DImage=Class.create();DImage.prototype={initialize:function(b,a,d){this.image=b;this.rac=a;this.decc=d}};var CollectionDWFs=Class.create();CollectionDWFs.prototype={initialize:function(e,b,d,a){this.parentId=e;this.dwfsId=b;this.dImages=$H();this.setOptions(a);this.defaultRules={".show-dwf":function(f){f.onchange=function(g){this.showDWFs(f.checked);persistence.updateDWFs()}.bind(this)}.bind(this)};this.setRules(d);this.setStyleSheet();dwfsDiv=document.createElement("div");dwfsDiv.setAttribute("id",this.dwfsId);dwfsDiv.setAttribute("class",this.dwfsId);$(this.parentId).appendChild(dwfsDiv)},setOptions:function(a){this.options={DWFName:"Cart",DWFTip:"Show the items added to Cart",DWFVisible:true,dImagePrefixId:"dImageId_",findImagesUrl:"/discovery/skymap/find_images",DWFMarkSrc:$(this.parentId).options.imagesBase+"/others/pushpin.gif",DWFMarkHeight:24,DWFMarkWidth:24};Object.extend(this.options,{DWFMarkNail:{x:this.options.DWFMarkWidth-(this.options.DWFMarkWidth*46)/(66*2),y:this.options.DWFMarkHeight}});Object.extend(this.options,a||{})},setRules:function(a){this.rules=a||this.defaultRules;this.registerRules()},registerRules:function(){Behaviour.register(this.rules)},setStyleSheet:function(){skyMapStyle=document.styleSheets[0];length=skyMapStyle.cssRules?skyMapStyle.cssRules.length:skyMapStyle.rules.length;declaration="."+this.parentId+" ."+this.dwfsId+" img{position: absolute;top: 0;left: 0;overflow: hidden;z-index: 0;}";skyMapStyle.insertRule(declaration,length)},isEmpty:function(){if(this.dImages.keys().length<=0){return true}return false},setVisible:function(a){this.options.DWFVisible=a},isVisible:function(){return this.options.DWFVisible},isDImage:function(a){if(this.dImages[a]){return true}return false},showDWFs:function(a){this.setVisible(a);this.updateDWFs()},removeAllDImageFromSky:function(){if(!this.isEmpty()){this.dImages.keys().each(function(a){$(this.dwfsId).removeChild($(this.options.dImagePrefixId+a))}.bind(this));this.dImages=$H()}},removeDImageFromSky:function(a){if(!this.isEmpty()&&this.isDImage(a)){$(this.dwfsId).removeChild($(this.options.dImagePrefixId+a));delete this.dImages[a]}},updateDWFs:function(){this.removeAllDImageFromSky();if(this.isVisible()){new Ajax.Request(this.options.findImagesUrl,{asynchronous:true,evalScripts:true,onComplete:function(a){this.processItemsReturned(a);this.setDImagesPosition({x:0,y:0})}.bind(this)})}},processItemsReturned:function(a){items_values=a.responseText.split("|");if(items_values!=""){items_values.each(function(b){values=b.split(",");id=values[0];rac=values[1];decc=values[2];image=document.createElement("img");image.setAttribute("id",this.options.dImagePrefixId+id);image.setAttribute("src",this.options.DWFMarkSrc);image.setAttribute("alt","mark_"+id);image.setAttribute("height",this.options.DWFMarkHeight);image.setAttribute("width",this.options.DWFMarkWidth);$(this.dwfsId).appendChild(image);this.dImages[id]=new DImage(image,rac,decc)}.bind(this))}},setDImagesPosition:function(a){if(!this.isEmpty()&&this.isVisible()){skyMaps=$(this.parentId);mouse=skyMaps.mouse;start=skyMaps.start;tileSize=skyMaps.options.tileSize;zoomLevel=skyMaps.variables.zoomLevel;fullSize=(tileSize*Math.pow(2,zoomLevel));corner={x:skyMaps.variables.x,y:skyMaps.variables.y};this.dImages.values().each(function(b){position=LonLatToXY(b.rac-180,b.decc,zoomLevel);scale=scalePosition(fullSize,position.x,position.y);if(!a){a={x:(mouse.x-start.x),y:(mouse.y-start.y)}}px=Math.ceil(scale.px+corner.x-this.options.DWFMarkNail.x+a.x);py=Math.ceil(scale.py+corner.y-this.options.DWFMarkNail.y+a.y);b.image.style.left=px+"px";b.image.style.top=py+"px"}.bind(this))}}};var ObjectFinder=Class.create();ObjectFinder.prototype={initialize:function(d,b,a){this.parentId=d;this.setOptions(a);this.defaultRules={"#resolver_object":function(e){e.onclick=function(f){this.resolveObject()}.bind(this)}.bind(this),"#find_object":function(e){e.onclick=function(g){var l=$(this.options.objectRAId).value;var m=$(this.options.objectDecId).value;var k=false;var h=false;var j=l+", "+m;var f=AstroCoordValidations.coordinateSpec(j);if(f.success){this.panViewerTo(l,m)}else{alert(f.explanation);return}}.bind(this)}.bind(this)};this.setRules(b);skyMaps=$(this.parentId);zoomLevel=skyMaps.variables.zoomLevel;selectElem=$(this.options.selectElemId);for(i=1;i<=skyMaps.zoom.options.levelMax;i++){zoomOption=document.createElement("option");zoomOption.setAttribute("value",i);if(i==zoomLevel){zoomOption.setAttribute("selected","true")}zoomOption.appendChild(document.createTextNode(i));selectElem.appendChild(zoomOption)}},setOptions:function(a){this.options={selectElemId:"objectfinder-zoom",objectNameId:"objectfinder-objectname",siapResolveUrl:"/discovery/siap/resolve",resolveObjectIndicatorId:"objectfinder-indicator",objectRAId:"objectfinder-ra",objectDecId:"objectfinder-dec",objectZoomId:"objectfinder-zoom"};Object.extend(this.options,a||{})},setRules:function(a){this.rules=a||this.defaultRules;this.registerRules()},registerRules:function(){Behaviour.register(this.rules)},resolveObject:function(){name=AstroString.trim($(this.options.objectNameId).value);if(name!=""){new Ajax.Request(this.options.siapResolveUrl,{asynchronous:true,evalScripts:true,parameters:"object="+name,onLoading:function(a){Element.show(this.options.resolveObjectIndicatorId)}.bind(this),onFailure:function(a){Element.hide(this.options.resolveObjectIndicatorId);alert("Error trying to resolver the object: "+name+". Please email us: vohelp@noao.edu")}.bind(this),onSuccess:function(a){Element.hide(this.options.resolveObjectIndicatorId);this.setObjectPosition(a)}.bind(this)})}else{alert("You must enter an object.")}},setObjectPosition:function(a){var d=a.responseText;var b=d.split(/\s*,\s*/);if(AstroMath.isPosition(b[0])&&AstroMath.isPosition(b[1])){$(this.options.objectRAId).value=AstroMath.raToDegrees(b[0]).toFixed(2);$(this.options.objectDecId).value=AstroMath.decToDegrees(b[1]).toFixed(2)}else{alert("The object wasn't found.")}},setZoomOption:function(){$(this.options.selectElemId).selectedIndex=$(this.parentId).variables.zoomLevel-1},panViewerTo:function(a,b){if(!AstroMath.isPosition(a)){alert("RA must be decimal degree or sexagesimal value (HH:MM:SS)");return}if(!AstroMath.isPosition(b)){alert("Dec must be decimal degree or sexagesimal value (DD:MM:SS)");return}if(AstroMath.isSexagesimal(a)){a=AstroMath.raToDegrees(a)}if(AstroMath.isSexagesimal(b)){b=AstroMath.decToDegrees(b)}skyMaps=$(this.parentId);tileSize=skyMaps.options.tileSize;skyMaps.variables.zoomLevel=parseInt($(this.options.objectZoomId).value);position=LonLatToXY(a-180,b,skyMaps.variables.zoomLevel);fullSize=tileSize*Math.pow(2,skyMaps.variables.zoomLevel);skyMaps.variables.x=-position.x*fullSize/2+skyMaps.clientWidth/2-128*Math.pow(2,skyMaps.variables.zoomLevel);skyMaps.variables.y=position.y*fullSize/4-fullSize/4+skyMaps.clientHeight/2-64*Math.pow(2,skyMaps.variables.zoomLevel);skyMaps.start=skyMaps.mouse;skyMaps.updateStatusDimensions();skyMaps.updateSkyMaps()}};var ShowAndSearchByArchive=Class.create();ShowAndSearchByArchive.prototype={initialize:function(f,d,e,a){this.parentId=f;this.showSearchId=d;this.archiveSelected=$H();this.checkArchives=$H();this.showProjectionMessage=true;this.setOptions(a);this.defaultRules={".showsearch-showarchive":function(g){g.onchange=function(h){this.showArchive(g)}.bind(this)}.bind(this),"#showsearch-searchbyarchive":function(g){g.onclick=function(h){this.searchByArchive()}.bind(this)}.bind(this)};this.setRules(e);table=document.createElement("table");table.setAttribute("width","100%");table.setAttribute("border","0");tbody=document.createElement("tbody");skyMaps=$(this.parentId);tr=document.createElement("tr");tr.setAttribute("align","center");tdCheck=document.createElement("td");tdCheck.setAttribute("align","right");check=document.createElement("input");check.setAttribute("id","checkbox_"+skyMaps.dwfs.dwfsId);check.setAttribute("class",".show-dwf");check.setAttribute("type","checkbox");if(skyMaps.dwfs.options.DWFVisible){check.setAttribute("checked","checked")}tdCheck.appendChild(check);tr.appendChild(tdCheck);tdName=document.createElement("td");tdName.setAttribute("align","left");label=document.createElement("label");label.setAttribute("title",skyMaps.dwfs.options.DWFTip);label.innerHTML=skyMaps.dwfs.options.DWFName;tdName.appendChild(label);image=document.createElement("img");image.setAttribute("src",skyMaps.dwfs.options.DWFMarkSrc);image.setAttribute("width","24");image.setAttribute("height","24");tdName.appendChild(image);tr.appendChild(tdName);tbody.appendChild(tr);archives=skyMaps.maps.values();for(var b=0;b<archives.length;b++){if(archives[b].isArchive()){this.pushArchiveSelected(archives[b].getArchiveId());tr=document.createElement("tr");tr.setAttribute("align","center");tdCheck=document.createElement("td");tdCheck.setAttribute("align","right");check=document.createElement("input");check.setAttribute("class","showsearch-showarchive");check.setAttribute("type","checkbox");check.setAttribute("name",archives[b].getArchiveName());check.setAttribute("value",archives[b].getArchiveId());if(archives[b].isVisible()){check.setAttribute("checked","checked")}tdCheck.appendChild(check);this.checkArchives[archives[b].getArchiveId()]=check;tr.appendChild(tdCheck);tdName=document.createElement("td");tdName.setAttribute("align","left");text=document.createTextNode(archives[b].getArchiveName());if(AstroString.trim(archives[b].getArchiveUrl())!=""){link=document.createElement("a");link.setAttribute("href",archives[b].getArchiveUrl());link.setAttribute("target","_blank");link.setAttribute("title",archives[b].getArchiveTip());link.style.color=archives[b].getArchiveColor();link.style.textDecoration="none";link.setAttribute("onmouseout","this.style.textDecoration = 'none';");link.setAttribute("onmouseover","this.style.textDecoration = 'underline';");link.appendChild(text);tdName.appendChild(link)}else{tdName.appendChild(text)}tr.appendChild(tdName);tbody.appendChild(tr)}}table.appendChild(tbody);$(this.showSearchId).appendChild(table)},setOptions:function(a){this.options={queryUrl:"/data_grid/data_grid/list_resources",gridId:"response_wrapper_id",rangeSearchValuesLabelId:"showsearch-range_label_id",throbberIndicatorId:"response_indicator_id"};Object.extend(this.options,a||{})},setRules:function(a){this.rules=a||this.defaultRules;this.registerRules()},registerRules:function(){Behaviour.register(this.rules)},updateRangeSearchValues:function(){skyMaps=$(this.parentId);corners=getCorners(skyMaps.options.tileSize,skyMaps.variables.zoomLevel,skyMaps.offsetWidth,skyMaps.offsetHeight,{x:skyMaps.variables.x,y:skyMaps.variables.y});ra_min=(corners.corner1.lon+180).toFixed(2);ra_max=(corners.corner2.lon+180).toFixed(2);dec_min=(corners.corner3.lat).toFixed(2);dec_max=(corners.corner1.lat).toFixed(2);$(this.options.rangeSearchValuesLabelId).innerHTML="Search Region on the Sky:  <br>"+ra_min+"&ensp;&lt;&ensp;RA&ensp;&lt;&ensp;"+ra_max+"<br>"+dec_min+"&ensp;&lt;&ensp;DEC&ensp;&lt;&ensp;"+dec_max},updateValues:function(a,b){$(this.parentId).maps[a].setVisible(b);if(b){this.checkArchives[a].setAttribute("checked","checked");this.pushArchiveSelected(a)}else{this.checkArchives[a].removeAttribute("checked");this.removeArchiveSelected(a)}},showArchive:function(a){this.updateValues(a.value,a.checked);$(this.parentId).updateSkyMapsVisibility(new Array(a.value))},pushArchiveSelected:function(a){archive=$(this.parentId).maps[a];if(archive.isArchive()&&archive.isVisible()){if(this.archiveSelected[archive.getArchiveId()]==null){this.archiveSelected[archive.getArchiveId()]=archive.getArchiveName()}}},removeArchiveSelected:function(a){if(this.archiveSelected[a]!=null){delete this.archiveSelected[a]}},isEmptyArchiveSelected:function(){if(this.archiveSelected.keys().length<=0){return true}return false},createProjectionAlert:function(){message="<label>Due to the AITOFF projection, your search results may find data outside of the viewing window.</label><br><input id='showsearch-showprojectionmessage' type='checkbox'><label>&ensp;Do not show again this message.</label></input>";Dialog.alert(message,{windowParameters:{width:300,height:200},okLabel:"Okay",ok:function(a){this.showProjectionMessage=!$("showsearch-showprojectionmessage").checked}.bind(this)})},searchByArchive:function(){if(this.isEmptyArchiveSelected()){alert("You must select at least one Archive.");return}zoomLevel=$(this.parentId).variables.zoomLevel;if(zoomLevel<5){alert("Zoom level must be greater than 5.");return}if(this.showProjectionMessage&&(zoomLevel>=5&&zoomLevel<=6)){this.createProjectionAlert()}skyMaps=$(this.parentId);corners=getCorners(skyMaps.options.tileSize,skyMaps.variables.zoomLevel,skyMaps.offsetWidth,skyMaps.offsetHeight,{x:skyMaps.variables.x,y:skyMaps.variables.y});ra_min=(corners.corner1.lon+180).toFixed(2);ra_max=(corners.corner2.lon+180).toFixed(2);dec_min=(corners.corner3.lat).toFixed(2);dec_max=(corners.corner1.lat).toFixed(2);archives=new Array();this.archiveSelected.values().each(function(a){archives.push(a)}.bind(this));new Ajax.Updater(this.options.gridId,this.options.queryUrl,{method:"post",evalScripts:true,parameters:$H({in_space:ra_min+","+dec_min+"/"+ra_max+","+dec_max,archives:archives.join(","),clear_selected_rows:"true"}).toQueryString(),onLoading:function(a){$(this.options.throbberIndicatorId).show();$(this.options.gridId).innerHTML=""}.bind(this),onComplete:function(a){$(this.options.throbberIndicatorId).hide()}.bind(this)})},findOverlappingImages:function(){if(this.isEmptyArchiveSelected()){alert("You must select at least one Archive.");return}skyMaps=$(this.parentId);corners=getCorners(skyMaps.options.tileSize,skyMaps.variables.zoomLevel,skyMaps.offsetWidth,skyMaps.offsetHeight,{x:skyMaps.variables.x,y:skyMaps.variables.y});nedec=corners.corner2.lat;nwdec=corners.corner4.lat;nera=corners.corner2.lon+180;sera=corners.corner3.lon+180;width=Math.abs((nedec-nwdec)/skyMaps.offsetWidth);height=Math.abs((nera-sera)/skyMaps.offsetHeight);if(width<0.033){width=0.033}if(height<0.033){height=0.033}px=skyMaps.mouse.x+Math.abs(skyMaps.variables.x);py=skyMaps.mouse.y+Math.abs(skyMaps.variables.y);fullSize=skyMaps.options.tileSize*Math.pow(2,skyMaps.variables.zoomLevel);iscaled=inverseScalePosition(fullSize,px,py);radLonLat=XYToLonLat(iscaled.x,iscaled.y,skyMaps.variables.zoomLevel);lonlat={lon:AstroMath.radiansToDegree(radLonLat.lon),lat:AstroMath.radiansToDegree(radLonLat.lat)};center_ra=lonlat.lon+180;center_dec=lonlat.lat;if(center_ra>=179.95&&center_ra<=180.05&&center_dec>=-0.05&&center_dec<=0.05){width=0.1;height=0.1}factor=5;if($(this.parentId).variables.zoomLevel>=7){factor=3}necorner_ra=center_ra+factor*(width/2);necorner_dec=center_dec+factor*(height/2);swcorner_ra=center_ra-factor*(width/2);swcorner_dec=center_dec-factor*(height/2);archives=new Array();this.archiveSelected.values().each(function(a){archives.push(a)}.bind(this));new Ajax.Updater(this.options.gridId,this.options.queryUrl,{method:"post",evalScripts:true,parameters:$H({overlapping:necorner_ra+","+necorner_dec+"/"+swcorner_ra+","+swcorner_dec,archives:archives.join(","),clear_selected_rows:"true"}).toQueryString(),onLoading:function(a){$(this.options.throbberIndicatorId).show();$(this.options.gridId).innerHTML=""}.bind(this),onComplete:function(a){$(this.options.throbberIndicatorId).hide()}.bind(this)})}};