var serviceType=new Array();
var serviceHelpPage=new Array();
var serviceInfoPage=new Array();
aimsMultiService=true;
var baseMapServiceURL=imsURL;
var maxNumberMapServices=10;
var mapService=new Array();
var mapServiceList=new Array();
var mapServiceName=new Array();
var mapServiceVisible=new Array();
var mapServiceLayers=new Array();
var mapServiceLayersVisible=new Array();
mapServiceList[0]=imsURL;mapServiceName[0]='';
mapServiceVisible[0]=1; 
var applicationId=new Array();
var imgList=new Array();
var reqList=new Array();
var previousActiveService='';
var mapServiceCount=mapServiceList.length;
var activeMapService=mapServiceList[0];activeMapServiceIndex=0;
var availableHostsList="";
var availableHosts=new Array();
var overlayIndex=0;
var canManageMapServices=false;
imsURL=mapServiceList[0];
imsQueryURL=imsURL+"&CustomService=Query";
imsGeocodeURL=imsURL+"&CustomService=Geocode";
var serviceCount=0;
var ServiceName=new Array();
var serviceImageType=new Array();
var newServiceName="";
var serviceHost=hostName;
selectFields="#ALL#";
canLoad=true;
var updateMaps=false;
var tempcVersion="";
function sendMapXML()
{
showRetrieveMap();
updateMaps=false;
overlayIndex=0;
parent.MapFrame.document.theImage.src='images/map.gif';
hideLayer("theMap");
var mapwidth=getMapWidth();
var mapheight=getMapHeight();
var layersVisible="";
var servicesVisible="";
for(i=0;i<mapService.length;i++)
{ 
if(i==0)
{ 
layersVisible=mapServiceLayersVisible[i];
servicesVisible=mapServiceVisible[i];
}else{
layersVisible=layersVisible+"-"+mapServiceLayersVisible[i];
servicesVisible=servicesVisible+"-"+mapServiceVisible[i];
}
} 
var visibleWms="";
for(i=0;i<changeWmsScales.length;i++){
if(i==0)
{
if(changeWmsScales[i]==true){ 
wmsVisible[i]=true;
visibleWms="1";
}else{
wmsVisible[i]=false;
visibleWms="0";
}
}else{
if(changeWmsScales[i]==true){ 
wmsVisible[i]=true;
visibleWms=visibleWms+"|1";
}else{
wmsVisible[i]=false;
visibleWms=visibleWms+"|0";
}
}
}
if(layersVisible!=""&&servicesVisible!="")
{
var scaleDist=getScaleBarDistance();
if((selectCount>0)&&(showSelectedFeatures)){
var processForm=parent.ProcessFrame.document.mapProcessForm;
processForm.servicesVisible.value=servicesVisible;
processForm.layersVisible.value=layersVisible;
processForm.wmsVisible.value=wmsVisible;
processForm.scaleDist.value=scaleDist;
processForm.queryString.value=setQueryString;
processForm.selectType.value=selectType;
processForm.activeLayer.value=LayerID[ActiveLayerIndex];
processForm.extent.value=eLeft+"|"+eBottom+"|"+eRight+"|"+eTop;
processForm.action=appDir+'ProcessMapRequests.jsp';
processForm.target="HiddenFrame";
processForm.submit();
}else{ 
var processForm=parent.ProcessFrame.document.mapProcessForm;
processForm.servicesVisible.value=servicesVisible;
processForm.layersVisible.value=layersVisible;
processForm.wmsVisible.value=wmsVisible;
processForm.scaleDist.value=scaleDist;
processForm.queryString.value='';
processForm.selectType.value='';
processForm.activeLayer.value='';
processForm.extent.value=eLeft+"|"+eBottom+"|"+eRight+"|"+eTop;
processForm.action=appDir+'ProcessMapRequests.jsp';
processForm.target="HiddenFrame";
processForm.submit();
}
}else{
alert("Unable to retrieve map service layers.");
}
}
function sendMultiToServer(theURL,XMLRequest,theFunction,theType)
{
var theForm=parent.PostFrame.document.forms[0];
theForm.JavaScriptFunction.value=theFunction;
sendToServer(theURL,XMLRequest,theType)
}
function processMulti(theReplyIn)
{
theReplyIn=replacePlus(theReplyIn);
var theReply=unescape(theReplyIn);
okToSend=true;
if(debugOn>2)alert(msgList[13]+theReply);
var theError=getXMLErrorMessage(theReply);
switch(XMLMode)
{
case 5001:
updateMultiOverlay(theReply,theError);
break;
case 5002:
processStartMapServiceLayers(theReply);
break;
case 5003:
processSwitchActiveMapService(theReply);
break;
case 5004:
processAddMapServiceLayers(theReply);
break;
case 5005:
processTopMap(theReply);
break;
default:
customProcessMulti(XMLMode,theReply);
break;
}
}
function getStartExtent(){
if(iHeight!=""&&iWidth!="")
parent.HiddenFrame.document.location=appDir+"SetParameters.jsp?height="+iHeight+"&width="+iWidth;
}
function getStartExtent2(){
if(parent.PostFrame.document.forms[0]!=null){
var theString='<ARCXML version="1.1">\n<REQUEST>\n<GET_SERVICE_INFO renderer="false" extensions="false" fields="false" />\n';
theString=theString+'</REQUEST>\n</ARCXML>';
var theReply="";
if(hasOVMap){
theString='<ARCXML version="1.1">\n<REQUEST>\n<GET_IMAGE><PROPERTIES>\n';
theString+='<IMAGESIZE height="'+i2Height+'" width="'+i2Width+'" />\n';
if(mapBackColor!=""){
theString+='<BACKGROUND color="'+mapBackColor+'" />\n';
}
theString+='</PROPERTIES>\n';
theString+='</GET_IMAGE>\n</REQUEST>\n</ARCXML>';
sendToServer(imsOVURL,theString,902);
}else{
sendToServer(imsURL,theString,3);
}
}else{
alert(msgList[2]);
}
}
function getLayerIDs(theReply){
var theReplyUC=theReply.toUpperCase();
var startpos=0;
var endpos=0;
var pos=-1;
var lpos=1;
var epos=1;
var zpos=1;
var zpos2=1;
var tempString="";
var visString="";
var theString="";
var theCount=0;
var tempArray=new Array();
lpos=theReplyUC.indexOf("<LAYERINFO",zpos);
while(lpos>-1){
if(lpos!=-1){
zpos=theReplyUC.indexOf("</LAYERINFO",lpos);
if(zpos!=-1){
pos=theReplyUC.indexOf("NAME=",lpos);
if(pos!=-1){
startpos=pos+6;
endpos=theReply.indexOf(dQuote,startpos);
tempString=theReply.substring(startpos,endpos);
startpos=theReplyUC.indexOf("ID=",lpos);
if((startpos!=-1)&&(startpos<zpos)){
startpos=startpos+4;
endpos=theReply.indexOf(dQuote,startpos);
tempArray[theCount]=theReply.substring(startpos,endpos);
}else{
tempArray[theCount]=tempString;
}
theCount++;
endpos=zpos;
}
lpos=theReplyUC.indexOf("<LAYERINFO",zpos);
}else{
lpos=-1;
}
}
}
tempArray.reverse();
theString=tempArray.join("|");
theReplyUC="";
tempArray=null;
return theString;
}
function getLayerVisibles(theReply){
var theReplyUC=theReply.toUpperCase();
var startpos=0;
var endpos=0;
var pos=-1;
var lpos=1;
var epos=1;
var zpos=1;
var zpos2=1;
var tempString="";
var visString="";
var theString="";
var theCount=0;
var tempArray=new Array();
lpos=theReplyUC.indexOf("<LAYERINFO",zpos);
while(lpos>-1){
if(lpos!=-1){
zpos=theReplyUC.indexOf("</LAYERINFO",lpos);
if(zpos!=-1){
pos=theReplyUC.indexOf("NAME=",lpos);
if(pos!=-1){
startpos=theReplyUC.indexOf("VISIBLE=",lpos);
if(startpos!=-1){
startpos=startpos+9;
endpos=startpos+4;
visString=theReply.substring(startpos,endpos);
}
if(visString=="true"){tempArray[theCount]=1}else{tempArray[theCount]=0};
theCount++;
endpos=zpos;
}
lpos=theReplyUC.indexOf("<LAYERINFO",zpos);
}else{
lpos=-1;
}
}
}
tempArray.reverse();
theString=tempArray.join("|");
theReplyUC="";
tempArray=null;
return theString;
}
function processStartMapServiceLayers(theReply)
{
mapServiceLayers[overlayIndex]=getLayerIDs(theReply);
mapServiceLayersVisible[overlayIndex]=getLayerVisibles(theReply);
overlayIndex++;
if(overlayIndex<mapServiceCount)
{
var theString='<ARCXML version="1.1">\n<REQUEST>\n<GET_SERVICE_INFO renderer="false" extensions="false" fields="false" />\n</REQUEST>\n</ARCXML>\n';
sendMultiToServer(mapServiceList[overlayIndex],theString,"parent.MapFrame.processMulti",5002);
}else{
if(parent.ServiceFrame!=null)parent.ServiceFrame.document.location=appDir+"MapServices.jsp";
overlayIndex=0;
getStartExtent2();
}
}
function processSwitchActiveMapService(theReply){
if(parent.ServiceFrame!=null){
parent.ServiceFrame.document.location=appDir+"MapServices.jsp";
}
theIndex=parseInt(activeMapServiceIndex);
if(aimsLayersPresent){
getLayers(theReply);
if(setLayerVisible.length>0)setupLayerVisible();
LayerVisible.length=0;
if(mapServiceLayersVisible[theIndex].indexOf(",")!=-1){
LayerVisible=mapServiceLayersVisible[theIndex].split(",");
}else{
LayerVisible[0]=mapServiceLayersVisible[theIndex];
}
mapServiceLayers[theIndex]=getLayerIDs(theReply);
}
if(aimsQueryPresent){
if(useStoredQuery)checkStoredQueries(theReply);
}else{
useStoredQuery=false;
}
if(aimsLayersPresent){
if((hasTOC)&&(showTOC)){
parent.TOCFrame.document.location=appDir+"toc.htm";
}
}
if(aimsGeocodePresent){
if(GCLayerCount==0){
if((useGeocode)||(useReverseGeocode)){
useGeocode=false;
useReverseGeocode=false;
}
}
}else{
useGeocode=false;
useReverseGeocode=false;
}
if(parent.ToolFrame!=null){
parent.ToolFrame.document.location=appDir+"toolbar.htm";
}else if(hasToolBarOnLayer){
var content=getLayerListContent();
if(isNav){
replaceLayerContent("theToolBar",content);
}else{
content=swapStuff(content,"\\'",sQuote);
document.all.theToolBar.innerHTML=content;
}
}
hideRetrieveData();
if(updateMaps)
sendMapXML()
}
function switchActiveMapService(indexIn,redrawMaps,mode)
{
if(mode==null)
mode=5003;
var index=parseInt(indexIn);
activeMapServiceIndex=index;
activeMapService=mapServiceList[index];
showRetrieveData();
updateMaps=redrawMaps;
LayerName.length=0;
LayerType.length=0;
LayerVisible.length=0;
LayerExtent.length=0;
LayerIsFeature.length=0;
LayerID.length=0;
LayerIDField.length=0;
LayerShapeField.length=0;
LayerMinScale.length=0;
LayerMaxScale.length=0;
LayerFieldTypeList.length=0;
LayerFieldList.length=0;
LayerRenderString.length=0;
LayerFieldSizeList.length=0;
LayerFieldPrecisionList.length=0;
layerCount=0;
var theString='<ARCXML version="1.1">\n<REQUEST>\n<GET_SERVICE_INFO  renderer="false" extensions="true" fields="true" />\n</REQUEST>\n</ARCXML>';
sendMultiToServer(mapServiceList[index],theString,"parent.MapFrame.processMulti",mode);
imsURL=mapServiceList[index];
imsQueryURL=imsURL+"&CustomService=Query";
imsGeocodeURL=imsURL+"&CustomService=Geocode";
}
function writeXML()
{
if(mapServiceLayers[overlayIndex].indexOf(",")!=-1)
{
var idArray=mapServiceLayers[overlayIndex].split(",");
var visArray=new Array();
if(mapServiceLayersVisible[overlayIndex]!=null)
visArray=mapServiceLayersVisible[overlayIndex].split(",");
}
else
{
var idArray=new Array();
var visArray=new Array();
idArray[0]=mapServiceLayers[overlayIndex];
visArray[0]=mapServiceLayersVisible[overlayIndex];
}
var theString='<ARCXML version="1.1">\n<REQUEST>\n<GET_IMAGE>\n<PROPERTIES>\n<ENVELOPE minx="'+forceComma(eLeft)+'" miny="'+forceComma(eBottom)+'" maxx="'+forceComma(eRight)+'" maxy="'+forceComma(eTop)+'" />\n';
theString+='<IMAGESIZE height="'+iHeight+'" width="'+iWidth+'" />\n';
var visString="";
if(aimsLayersPresent)
{
if(toggleVisible){
theString+='<LAYERLIST >\n';
for(var i=0;i<idArray.length;i++)
{
if(visArray[i]==1)
{
theString+='<LAYERDEF id="'+idArray[i]+'" visible="true" />\n';
}
else
{
theString+='<LAYERDEF id="'+idArray[i]+'" visible="false" />\n';
}
}
theString+='</LAYERLIST>\n';
}
}
if((mapTransparent)&&(overlayIndex!=0)){
theString+='<BACKGROUND color="'+transColor+'" transcolor="'+transColor+'" />\n';
}else{
if(mapBackColor!=""){
theString+='<BACKGROUND color="'+mapBackColor+'" />\n\n';
}
}
if(overlayIndex==parseInt(activeMapServiceIndex)){
if(aimsLegendPresent){
if(legendVisible)theString+=addLegendToMap();
}
}
theString+='</PROPERTIES>\n';
if(overlayIndex==parseInt(activeMapServiceIndex)){
if(aimsBufferPresent){
if(showBuffer)theString+=addBufferToMap();
}
if(aimsSelectPresent){
theString+=addSelectToMap();
}
}
theString+='</GET_IMAGE>\n</REQUEST>\n</ARCXML>';
idArray=null;
visArray=null;
return theString;
}
function writeTopXML(){
var theString='<ARCXML version="1.1">\n<REQUEST>\n<GET_IMAGE>\n<PROPERTIES>\n<ENVELOPE minx="'+forceCommaInOverlay(eLeft)+'" miny="'+forceCommaInOverlay(eBottom)+'" maxx="'+forceCommaInOverlay(eRight)+'" maxy="'+forceCommaInOverlay(eTop)+'" />\n';
theString+='<IMAGESIZE height="'+iHeight+'" width="'+iWidth+'" />\n';
if((drawCopyright)||(drawBottomBar)||(drawScaleBar)||(drawScaleBar2)||(drawNorthArrow)||(aimsClickPresent)){
theString+='<LAYERLIST order="true">\n';
if(drawCopyright)theString+='<LAYERDEF id="theCopyright" visible="true"/>\n';
if(drawBottomBar)theString+='<LAYERDEF id="theBottomBar" visible="true"/>\n';
if(drawNorthArrow)theString+='<LAYERDEF id="theNorthArrow" visible="true"/>\n';
if(drawScaleBar)theString+='<LAYERDEF id="theScaleBar" visible="true"/>\n';
if(drawScaleBar2)theString+='<LAYERDEF id="theScaleBar2" visible="true"/>\n';
if(aimsClickPresent)theString+='<LAYERDEF id="allTheClicks" visible="true"/>\n';
theString+='</LAYERLIST>\n';
}
theString+='<BACKGROUND color="'+transColor+'" transcolor="'+transColor+'" />\n';
theString+='</PROPERTIES>\n';
if(drawBottomBar){
theString+='<LAYER type="acetate" name="theBottomBar">\n';
theString+='<OBJECT units="pixel">\n<POLYGON ';
theString+='coords="0'+coordsDelimiter+'1'+pairsDelimiter;
theString+='1'+coordsDelimiter+bottomBarHeight+pairsDelimiter;
theString+=(iWidth-1)+coordsDelimiter+bottomBarHeight+pairsDelimiter;
theString+=(iWidth-1)+coordsDelimiter+'1'+pairsDelimiter;
theString+='0'+coordsDelimiter+'1">\n';
theString+='<SIMPLEPOLYGONSYMBOL fillcolor="'+bottomBarColor+'" boundary="true" boundarycolor="'+bottomBarOutline+'" overlap="false" />\n';
theString+='</POLYGON>\n</OBJECT>\n';
theString+='</LAYER>\n';
}
if(drawCopyright){
theString+='<LAYER type="acetate" name="theCopyright" id="theCopyright">\n';
theString+='<OBJECT units="pixel">\n<TEXT coords="'+CopyrightCoords+'" label="'+CopyrightText+'">\n';
theString+='<TEXTMARKERSYMBOL fontstyle="'+CopyrightStyle+'" fontsize="'+CopyrightSize+'" ';
if(CopyrightFont!="")theString+='font="'+CopyrightFont+'" ';
theString+='fontcolor="'+CopyrightColor+'" antialiasing="True" ';
if(CopyrightBackground.toUpperCase()=="TRUE")theString+='blockout="'+CopyrightBGColor+'" ';
if(CopyrightShadow.toUpperCase()=="TRUE")theString+='shadow="'+CopyrightShadowColor+'" ';
theString+='overlap="false" ';
if(CopyrightGlow.toUpperCase()=="TRUE")theString+=' glowing="'+CopyrightGlowColor+'" ';
theString+='/>\n</TEXT>\n</OBJECT>\n';
theString+='</LAYER>\n';
}
if(drawNorthArrow){
theString+='<LAYER type="acetate" name="theNorthArrow" id="theNorthArrow">\n';
theString+='<OBJECT units="pixel">\n<NORTHARROW type="'+NorthArrowType+'" size="'+NorthArrowSize+'" coords="'+NorthArrowCoords+'" shadow="32,32,32" ';
theString+='angle="'+NorthArrowAngle+'" antialiasing="True" overlap="False" />\n</OBJECT>\n';
theString+='</LAYER>\n';
}
if(drawScaleBar){
theString+='<LAYER type="acetate" name="theScaleBar">\n';
xDistance=eRight-eLeft;
theString+='<OBJECT units="pixel">\n';
theString+='<SCALEBAR ';
if(drawScaleBar2){
theString+='screenlength="'+parseInt(iWidth*(1/10))+'" coords="'+(iWidth-((parseInt(iWidth*(4/10)))+20))+coordsDelimiter+'3" ';
}else{
theString+='screenlength="'+parseInt(iWidth*(2/10))+'" coords="'+parseInt(iWidth*(6/10))+coordsDelimiter+'3" ';
}
if(MapUnits=="DEGREES")theString+='mode="geodesic" ';
if(ScaleBarFont!="")theString+='font="'+ScaleBarFont+'" ';
theString+='fontcolor="'+ScaleBarFontColor+'" style="'+ScaleBarStyle+'" barcolor="'+ScaleBarColor+'" ';
if(MapUnits!="DEGREES"){
theString+='mapunits="'+MapUnits.toLowerCase()+'" ';
}
theString+='scaleunits="'+ScaleBarUnits.toLowerCase()+'" antialiasing="True" ';
var sDistance=getScaleBarDistance();
if(MapUnits=="DEGREES"){
if(xDistance<1/10){
theString+='precision="'+ScaleBarPrecision+'" ';
}
}else if(sDistance<5){
theString+='precision="'+ScaleBarPrecision+'" ';
}
theString+='fontsize="'+ScaleBarSize+'" barwidth="'+ScaleBarWidth+'" overlap="False"  ';
theString+='/>\n</OBJECT>\n';
theString+='</LAYER>\n';
}
if(drawScaleBar2){
theString+='<LAYER type="acetate" name="theScaleBar2">\n';
xDistance=eRight-eLeft;
theString+='<OBJECT units="pixel">\n';
theString+='<SCALEBAR ';
if(drawScaleBar){
theString+='screenlength="'+parseInt(iWidth*(1/10))+'" coords="'+(iWidth-((parseInt(iWidth*(2/10)))+10))+coordsDelimiter+'3" ';
}else{
theString+='screenlength="'+parseInt(iWidth*(2/10))+'" coords="'+parseInt(iWidth*(6/10))+coordsDelimiter+'3" ';
}
if(MapUnits=="DEGREES")theString+='mode="geodesic" ';
if(ScaleBar2Font!="")theString+='font="'+ScaleBar2Font+'" ';
theString+='fontcolor="'+ScaleBar2FontColor+'" style="'+ScaleBar2Style+'" barcolor="'+ScaleBar2Color+'" ';
if(MapUnits!="DEGREES"){
theString+='mapunits="'+MapUnits.toLowerCase()+'" ';
}
theString+='scaleunits="'+ScaleBar2Units.toLowerCase()+'" antialiasing="True" ';
var sDistance=getScaleBarDistance();
if(MapUnits=="DEGREES"){
if(xDistance<1/10){
theString+='precision="'+ScaleBar2Precision+'" ';
}
}else if(sDistance<5){
theString+='precision="'+ScaleBar2Precision+'" ';
}
theString+='fontsize="'+ScaleBar2Size+'" barwidth="'+ScaleBar2Width+'" overlap="False"  ';
theString+='/>\n</OBJECT>\n';
theString+='</LAYER>\n';
}
if(drawModeOnMap){
theString+='<LAYER type="acetate" name="theMode">\n';
theString+='<OBJECT units="pixel">\n<TEXT coord="5'+coordsDelimiter+(iHeight-10)+'" label="'+modeBlurb+'">\n';
theString+='<TEXTMARKERSYMBOL fontstyle="BOLD" fontsize="12" font="ARIAL" fontcolor="'+modeMapColor+'" ';
theString+='threed="TRUE" glowing="'+modeMapGlow+'" />\n</TEXT>\n</OBJECT>';
}
if(showGeocode){
theString+='<LAYER type="acetate" name="GeoCode1">\n';
theString+='<OBJECT units="database">\n<POINT coords="'+forceComma(geocodeX)+coordsDelimiter+forceComma(geocodeY)+'">\n';
theString+='<SIMPLEMARKERSYMBOL  type="circle"  color="'+geocodePointColor+'" width="'+geocodePointSize+'" />\n</POINT></OBJECT>\n';
if(geocodeLabel!=""){
theString+='<OBJECT units="database">\n<TEXT coords="'+forceComma(geocodeX)+coordsDelimiter+forceComma(geocodeY)+'" label="'+geocodeLabel+'">\n';
theString+='<TEXTMARKERSYMBOL fontcolor="'+geocodePointColor+'" fontsize="12" shadow="64,64,64" glowing="255,255,0" halignment="right" valignment="top" /></TEXT></OBJECT>\n';
}
theString+='</LAYER>\n';
}
if(aimsClickPresent){
if(clickCount>0){
var clickColor=selectColor;
if(clickType==1)clickColor=clickMarkerColor;
theString+='<LAYER type="acetate" name="allTheClicks" id="allTheClicks">\n';
if(clickCount>1){
theString+='<OBJECT units="database">\n<LINE coords="'+forceComma(clickPointX[0])+coordsDelimiter+forceComma(clickPointY[0]);
for(var i=1;i<clickCount;i++){
theString+=pairsDelimiter+forceComma(clickPointX[i])+coordsDelimiter+forceComma(clickPointY[i]);
}
theString+='" >\n';
theString+='<SIMPLELINESYMBOL type="solid" color="'+clickMarkerColor;
theString+='" width="3" />\n</LINE>\n</OBJECT>\n';
theString+='<OBJECT units="database">\n<LINE coords="'+forceComma(clickPointX[0])+coordsDelimiter+forceComma(clickPointY[0]);
for(var i=1;i<clickCount;i++){
theString+=pairsDelimiter+forceComma(clickPointX[i])+coordsDelimiter+forceComma(clickPointY[i]);
}
theString+='" >\n';
theString+='<SIMPLELINESYMBOL type="solid" color="'+clickMarkerColor+'" width="1" />\n</LINE>\n</OBJECT>\n';
}
for(var i=0;i<clickCount;i++){
theString+='<OBJECT units="database">\n<POINT coords="'+forceComma(clickPointX[i])+coordsDelimiter+forceComma(clickPointY[i])+'">\n';
theString+='<SIMPLEMARKERSYMBOL  type="'+clickMarkerType+'"';
theString+=' color="'+clickMarkerColor+'" width="'+clickMarkerSize+'" />\n</POINT>\n</OBJECT>\n';
}
theString+='</LAYER>\n';
}
}
if(aimsCustomPresent)theString+=addCustomToMap1();
theString+='</GET_IMAGE>\n</REQUEST>\n</ARCXML>';
return theString;
}
function getLegend(){
legendVisible=true;
drawLegendOnly=true;
overlayIndex=parseInt(activeMapServiceIndex);
legTitle=mapServiceName[overlayIndex];
var theString=writeXML();
sendToServer(imsURL,theString,98);
}
function serviceVisibility(index,isVisible){
var lyrName="theMap";
if(index>0)lyrName="theMap"+index;
parent.MapFrame.focus();
if(isVisible){
showLayer(lyrName);
mapServiceVisible[index]=1;
}else{
hideLayer(lyrName);
mapServiceVisible[index]=0;
}
}
function panMouse(){
var xMove=x2-x1;
var yMove=y2-y1;
var cLeft=-xMove;
var cTop=-yMove;
var cRight=iWidth;
var cBottom=iHeight;
if(xMove>0){
cLeft=0;
cRight=iWidth-xMove;
}
if(yMove>0){
cTop=0;
cBottom=iHeight-yMove;
}
clipLayer2("theMap",cLeft,cTop,cRight,cBottom);
moveLayer("theMap",xMove+hspc,yMove+vspc);
if(hasLayer("theMapClicks")){
clipLayer2("theMapClicks",cLeft,cTop,cRight,cBottom);
moveLayer("theMapClicks",xMove+hspc,yMove+vspc);
}
}
function moveServiceUp(){
var k=parseInt(activeMapServiceIndex);
if(k<mapServiceList.length-1){
var m=k+1;
activeMapServiceIndex=m;
moveMapService(k,m)
}
}
function moveServiceDown(){
var k=parseInt(activeMapServiceIndex);
if(k>0){
var m=k-1;
activeMapServiceIndex=m;
moveMapService(k,m)
}
}
function moveMapService(fromPosition,toPosition){
var fp=parseInt(fromPosition);
var tp=parseInt(toPosition);
var temp1=mapServiceList[fp];
var temp2=mapServiceList[tp];
mapServiceList[fp]=temp2;
mapServiceList[tp]=temp1;
temp1=mapServiceName[fp];
temp2=mapServiceName[tp];
mapServiceName[fp]=temp2;
mapServiceName[tp]=temp1;
temp1=mapServiceLayers[fp];
temp2=mapServiceLayers[tp];
mapServiceLayers[fp]=temp2;
mapServiceLayers[tp]=temp1;
temp1=mapServiceLayersVisible[fp];
temp2=mapServiceLayersVisible[tp];
mapServiceLayersVisible[fp]=new String(temp2);
mapServiceLayersVisible[tp]=new String(temp1);
var temp3=mapServiceVisible[fp];
var temp4=mapServiceVisible[tp];
mapServiceVisible[fp]=temp4;
mapServiceVisible[tp]=temp3;
temp3=forceCommaInRequest[fp];
temp4=forceCommaInRequest[tp];
forceCommaInRequest[fp]=temp4;
forceCommaInRequest[tp]=temp3;
if(parent.TOCFrame!=null){
parent.TOCFrame.updateLayers2();
}else{
sendMapXML();
}
}
function deleteMapService(){
var k=parseInt(activeMapServiceIndex);
var m=mapServiceList.length-1;
if(k==m){
activeMapServiceIndex=k-1;
}else{
for(var i=k;i<m;i++){
mapServiceList[i]=mapServiceList[i+1];
mapServiceName[i]=mapServiceName[i+1];
mapServiceLayers[i]=mapServiceLayers[i+1];
mapServiceLayersVisible[i]=mapServiceLayersVisible[i+1];
mapServiceVisible[i]=mapServiceVisible[i+1];
forceCommaInRequest[i]=forceCommaInRequest[i+1];
}
}
mapServiceList.length=m;
mapServiceName.length=m;
mapServiceLayers.length=m;
mapServiceLayersVisible.length=m;
mapServiceVisible.length=m;
forceCommaInRequest.length=m;
mapServiceCount=mapServiceList.length;
lyrName="theMap"+m;
hideLayer(lyrName);
switchActiveMapService(activeMapServiceIndex,true);
}
function processCatalog(theReply){
var theReplyUC=theReply.toUpperCase();
var startpos=0;
var endpos=0;
ServiceName.length=0;
serviceCount=0;
var pos=-1;
var spos=9;
var lpos=9;
var i=0;
var tempString=""
var visString=""
var testString="";
pos=theReply.indexOf("ERROR",endpos);
if(pos==-1){
while(lpos>-1){
lpos=theReplyUC.indexOf("<SERVICE ",endpos);
if(lpos!=-1){
startpos=theReplyUC.indexOf("NAME=",lpos+8);
startpos=startpos+6
endpos=theReply.indexOf(dQuote,startpos);
tempString=theReply.substring(startpos,endpos);
startpos=theReplyUC.indexOf("TYPE=",lpos);
startpos=startpos+6;
endpos=startpos+5;
if(theReply.substring(startpos,endpos)=="Image"){
startpos=theReplyUC.indexOf("STATUS=",lpos);
startpos=startpos+8;
endpos=startpos+7;
if(theReplyUC.substring(startpos,endpos)=="ENABLED"){
ServiceName[i]=tempString;
startpos=theReplyUC.indexOf("<IMAGE",lpos);
if(startpos!=-1){
endpos=startpos+7;
startpos=theReplyUC.indexOf("TYPE=",endpos);
startpos=startpos+6;
endpos=theReply.indexOf(dQuote,startpos);
serviceImageType[i]=theReplyUC.substring(startpos,endpos);
}else{
serviceImageType[i]="Unknown";
}
i=i+1;
serviceCount=serviceCount+1;
}
}
}
}
loadServiceForm();
}else{
alert("Error compiling MapService List");
}
hideRetrieveData();
}
function startAddService(){
var tempcVersion=cVersion;
cVersion="";
var catologURL="http://"+serviceHost+"/servlet/com.esri.esrimap.Esrimap?ServiceName=catalog";
var theText="<GETCLIENTSERVICES/>";
sendToServer(catologURL,theText,5);
cVersion=tempcVersion;
}
function loadServiceForm(){
if(useTextFrame){
parent.TextFrame.document.location=appDir+"addService.htm";
}else{
var Win1=open(appDir+"addService.htm","AddServiceWindow","width=575,height=150,scrollbars=yes,resizable=yes");
}
}
function addMapService(theServiceURL,addServiceName,serviceIndex){
var theType=serviceImageType[serviceIndex];
var okayToLoad=true;
if((theType=="JPG")||(theType=="PNG24")||(theType=="Unknown")){
if(!confirm(noTransMessage,true))okayToLoad=false;
}
if(okayToLoad){
mapServiceName[mapServiceCount]=addServiceName;
mapServiceList[mapServiceCount]=theServiceURL;
mapServiceVisible[mapServiceCount]=1;
var theString='<ARCXML version="1.1">\n<REQUEST>\n<GET_SERVICE_INFO renderer="false" extensions="false" fields="false" />\n</REQUEST>\n</ARCXML>\n';
sendMultiToServer(theServiceURL,theString,"parent.MapFrame.processMulti",5004);
}
}
function processAddMapServiceLayers(theReply)
{
mapServiceLayers[mapServiceCount]=getLayerIDs(theReply);
mapServiceLayersVisible[mapServiceCount]=getLayerVisibles(theReply);
if(parent.ServiceFrame!=null)
parent.ServiceFrame.document.location=appDir+"MapServices.jsp";
mapServiceCount++;
overlayIndex=0;
sendMapXML();
}
function forceCommaInOverlay(theNumber)
{
var comma=",";
var dot=".";
var charOut=comma;
var charIn=dot;
var numberString=new String(theNumber);
if(commaUsedInTopLayer){
charOut=dot;
charIn=comma;
}
var pos=numberString.indexOf(charOut);
if(pos!=-1){
var begin=numberString.substring(0,pos);
var ending=numberString.substring(pos+1,numberString.length);
numberString=begin+charIn+ending;
}
return numberString;
}
