
var doAddSelectToMap=false;var xmlEndPos=0;var highlightedOne="";var map2;var env2;var twomaps;var decimalChar=((("theChar is"+(10/100)).indexOf("."))==-1)?",":".";function parseRecordString(theReply,startpos){var inData="";var pos=theReply.indexOf("<FIELDS ",startpos);if(pos!=-1){startpos=pos+8;xmlEndPos=theReply.indexOf('" />',startpos);inData=theReply.substring(startpos,xmlEndPos);}
return inData;}
function getIdValue(fieldNameArray,fieldValueArray){var theValue=0;for(var f=0;f<fieldNameArray.length;f++){if(fieldNameArray[f]=="#ID#"){theValue=fieldValueArray[f];}}
return theValue;}
function getInitialMap(){goTheme(1);}
function getServiceInfo(){var axl='<?xml version="1.0" encoding="UTF-8"?><ARCXML version="1.1">\n<REQUEST>\n<GET_SERVICE_INFO renderer="false" extensions="false" fields="false" />\n</REQUEST>\n</ARCXML>\n';http=getHTTPObject();if((http!=null)){http.open("POST",url,true);http.onreadystatechange=parseLayers;isWorking=true;showLayer('loading');http.send(axl);}}
function parseLayers(){if(http.readyState==4){if(http.status==200){var result=http.responseText;getLayers(result);getInitialMap();}else alert("Error retreiving data\n"+result);}}
function pan(ix,iy){var dx=(maxx-minx)/mwidth;var mx=dx*ix;var my=dx*iy;minx+=mx;maxx+=mx;miny+=my;maxy+=my;checkFullExtent();var env='<ENVELOPE minx="'+minx+'" miny="'+miny+'" maxx="'+maxx+'" maxy="'+maxy+'" />';env2=env;getMap(env);}
function panDirection(dir){shift(dir);checkFullExtent();get2mapsWithCurrentExtent();}
function shift(dir){var dx=maxx-minx;var dy=maxy-miny;switch(dir){case"north":miny+=0.25*dy;maxy+=0.25*dy;break;case"south":miny-=0.25*dy;maxy-=0.25*dy;break;case"east":minx+=0.25*dx;maxx+=0.25*dx;break;case"west":minx-=0.25*dx;maxx-=0.25*dx;break;case"ne":miny+=0.25*dy;maxy+=0.25*dy;minx+=0.25*dx;maxx+=0.25*dx;break;case"nw":miny+=0.25*dy;maxy+=0.25*dy;minx-=0.25*dx;maxx-=0.25*dx;break;case"se":miny-=0.25*dy;maxy-=0.25*dy;minx+=0.25*dx;maxx+=0.25*dx;break;case"sw":miny-=0.25*dy;maxy-=0.25*dy;minx-=0.25*dx;maxx-=0.25*dx;break}}
function get2mapsWithCurrentExtent(){checkFullExtent();twomaps=true;var env='<ENVELOPE minx="'+minx+'" miny="'+miny+'" maxx="'+maxx+'" maxy="'+maxy+'" />';env2=env;getMap(env);}
function getMapWithCurrentExtent(){checkFullExtent();twomaps=false;var env='<ENVELOPE minx="'+minx+'" miny="'+miny+'" maxx="'+maxx+'" maxy="'+maxy+'" />';env2=env;getMap(env);}
var samemap;function getMap(envelope){http=getHTTPObject();if((http!=null)){var axl=getMapRequest(envelope);if(samemap){if(!twomaps){if(map2)document.getElementById('theImage2').src=document.getElementById('theImage1').src;else document.getElementById('theImage1').src=document.getElementById('theImage2').src;putsamemap();return;}
twomaps=false;}
http.open("POST",url,true);http.onreadystatechange=printResponse;showLayer('loading');http.send(axl);}}
function putsamemap(){document.getElementById('theImage2').src=document.getElementById('theImage1').src;}
function getMapRequest(envelope){var axl='<?xml version="1.0" encoding="UTF-8"?>';axl+='<ARCXML version="1.1">';axl+=' <REQUEST>';axl+='    <GET_IMAGE>';axl+='     <PROPERTIES>';axl+=envelope;axl+='<IMAGESIZE height="'+mheight+'" width="'+mwidth+'" />';axl+='<LAYERLIST >\n';samemap=true;for(var i=0;i<layerCount;i++)
{if((LayerVisible2[i]!=LayerVisible[i])&&(i!=0)){samemap=false}
if(map2)
{if(LayerVisible2[i]==1){axl+='<LAYERDEF id="'+LayerID[i]+'" visible="true" />\n';}else{axl+='<LAYERDEF id="'+LayerID[i]+'" visible="false" />\n';}}
else
{if(LayerVisible[i]==1){axl+='<LAYERDEF id="'+LayerID[i]+'" visible="true" />\n';}else{axl+='<LAYERDEF id="'+LayerID[i]+'" visible="false" />\n';}}}
axl+='</LAYERLIST>\n';axl+=' </PROPERTIES>';if(doAddSelectToMap)
{axl+="\n"+addSelectToMap();}
var coordsDelimiter=" ";var pairsDelimiter=";";if(drawBottomBar){axl+='<LAYER type="acetate" name="theBottomBar">\n';axl+='<OBJECT units="pixel">\n<POLYGON ';axl+='coords="0'+coordsDelimiter+'0'+pairsDelimiter;axl+='0'+coordsDelimiter+bottomBarHeight+pairsDelimiter;axl+=(iWidth)+coordsDelimiter+bottomBarHeight+pairsDelimiter;axl+=(iWidth)+coordsDelimiter+'0'+pairsDelimiter;axl+='0'+coordsDelimiter+'0">\n';axl+='<SIMPLEPOLYGONSYMBOL fillcolor="'+bottomBarColor+'" filltransparency="'+bottombartransparency+'" boundary="false" overlap="false" />\n';axl+='</POLYGON>\n</OBJECT>\n';axl+='</LAYER>\n';}
if(drawScaleBar){axl+='<LAYER type="acetate" name="theScaleBar">\n';axl+='<OBJECT units="pixel">\n';axl+='<SCALEBAR ';axl+='screenlength="'+parseInt(iWidth*(1/7))+'" coords="'+ScaleBarCoords+'" ';if(ScaleBarFont!="")axl+='font="'+ScaleBarFont+'" ';axl+='fontcolor="'+ScaleBarFontColor+'" fontstyle="'+ScaleBarStyle+'" barcolor="'+ScaleBarColor+'" ';axl+='scaleunits="'+ScaleBarUnits.toLowerCase()+'" antialiasing="false" ';axl+='mapunits="meters" ';axl+='precision="'+ScaleBarPrecision+'" ';axl+='fontsize="'+ScaleBarSize+'" barwidth="'+ScaleBarWidth+'" overlap="False"  ';axl+='/>\n</OBJECT>\n';axl+='</LAYER>\n';}
if(drawCopyright)
{axl+='<LAYER type="acetate" name="theCopyright">\n';axl+='<OBJECT units="pixel">\n<TEXT coords="'+CopyrightCoords+'" label="'+CopyrightText+'">\n';axl+='<TEXTMARKERSYMBOL fontstyle="'+CopyrightStyle+'" fontsize="'+CopyrightSize+'" ';axl+='font="'+CopyrightFont+'" fontcolor="'+CopyrightColor+'" antialiasing="false" ';if(CopyrightBackground.toUpperCase()=="TRUE")axl+='blockout="'+CopyrightBGColor+'" ';axl+=' overlap="false" ';if(CopyrightGlow.toUpperCase()=="TRUE")axl+=' glowing="'+CopyrightGlowColor+'" ';axl+='/>\n</TEXT>\n</OBJECT>\n';axl+='</LAYER>\n';}
axl+='    </GET_IMAGE> ';axl+='   </REQUEST></ARCXML>';return axl;}
if(!isIE){Document.prototype.loadXML=function(s){var doc2=(new DOMParser()).parseFromString(s,"text/xml");while(this.hasChildNodes())
this.removeChild(this.lastChild);for(var i=0;i<doc2.childNodes.length;i++){this.appendChild(this.importNode(doc2.childNodes[i],true));}};}
function printResponse(){if(http.readyState==4){if(http.status==200){isWorking=false;var result=http.responseText;var xmlDoc;var theURL;if(navigator.userAgent.indexOf("MSIE")!=-1){var IE=navigator.userAgent;var IEind=IE.indexOf("MSIE");var IEversion=IE.substring((IEind+5),(IEind+6));if(window.ActiveXObject&&(IEversion>5))
{xmlDoc=new ActiveXObject("Microsoft.XMLDOM");xmlDoc.async="false";xmlDoc.loadXML(result);theURL=xmlDoc.getElementsByTagName("OUTPUT").item(0).getAttribute("url");var env=xmlDoc.getElementsByTagName("ENVELOPE").item(0);minx=parseFloat(env.getAttribute("minx"));miny=parseFloat(env.getAttribute("miny"));maxx=parseFloat(env.getAttribute("maxx"));maxy=parseFloat(env.getAttribute("maxy"));}
else if(window.ActiveXObject&&(IEversion<=5))
{parseEnvelope(result,0);theURL=getURL(result);hideLayer('loading');}}else if(document.implementation&&document.implementation.createDocument){parseEnvelope(result,0);theURL=getURL(result);hideLayer('loading');}
if(twomaps)
{if(map2){document.getElementById('theImage2').src=theURL;map2=false;afterMap();return;}
else{document.getElementById('theImage1').src=theURL;map2=true;getMap(env2);}}
else
{if(map2){document.getElementById('theImage2').src=theURL;map2=false;afterMap()}
else{document.getElementById('theImage1').src=theURL;afterMap()}}}else alert("Error retreiving data");}}
function afterMap(){hideLayer('loading');putExtentOnOVMap();teleUpdateScale();calcscale();showScale();if(samemap){putsamemap();}}
function getURL(theReply){var theURL="";var startpos=0;var endpos=0;var pos=theReply.indexOf("OUTPUT");var pos1=theReply.indexOf("url",pos);pos1+=5;var pos2=theReply.indexOf("\"",pos1);theURL=theReply.substring(pos1,pos2);return theURL;}
function parseEnvelope(theString,startpos){theString=theString.toUpperCase();var tempString="";var dQuote="\"";var pos=theString.indexOf("ENVELOPE",startpos);if(pos!=-1){pos=pos+8;startpos=theString.indexOf("MINX=",pos);startpos+=6;var endpos=theString.indexOf(dQuote,startpos);tempString=theString.substring(startpos,endpos);minx=parseFloat(tempString);startpos=theString.indexOf("MINY=",pos);startpos+=6;endpos=theString.indexOf(dQuote,startpos);tempString=theString.substring(startpos,endpos);miny=parseFloat(tempString);startpos=theString.indexOf("MAXX=",pos);startpos+=6;endpos=theString.indexOf(dQuote,startpos);tempString=theString.substring(startpos,endpos);maxx=parseFloat(tempString);startpos=theString.indexOf("MAXY=",pos);startpos+=6;endpos=theString.indexOf(dQuote,startpos);tempString=theString.substring(startpos,endpos);maxy=parseFloat(tempString);}}
function getEnvelopeXYs(theString,startpos){var dQuote='"';var theEnvelope=new Array();theString=theString.toUpperCase();var tempString="";var pos=theString.indexOf("ENVELOPE",startpos);if(pos!=-1){pos=pos+8;startpos=theString.indexOf("MINX=",pos);startpos+=6;var endpos=theString.indexOf(dQuote,startpos);tempString=theString.substring(startpos,endpos);theEnvelope[0]=parseFloat(setDecimalString(tempString));startpos=theString.indexOf("MINY=",pos);startpos+=6;endpos=theString.indexOf(dQuote,startpos);tempString=theString.substring(startpos,endpos);theEnvelope[1]=parseFloat(setDecimalString(tempString));startpos=theString.indexOf("MAXX=",pos);startpos+=6;endpos=theString.indexOf(dQuote,startpos);tempString=theString.substring(startpos,endpos);theEnvelope[2]=parseFloat(setDecimalString(tempString));startpos=theString.indexOf("MAXY=",pos);startpos+=6;endpos=theString.indexOf(dQuote,startpos);tempString=theString.substring(startpos,endpos);theEnvelope[3]=parseFloat(setDecimalString(tempString));xmlEndPos=endpos;}
return theEnvelope;}
function setDecimalString(numberString){if(decimalChar=="."){numberString=numberString.replace(/,/g,".");}else{}
return numberString;}
function forceComma(theNumber){var comma=",";var dot=".";var charOut=comma;var charIn=dot;var numberString=new String(theNumber);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;}
function forceOVComma(theNumber){var comma=",";var dot=".";var charOut=comma;var charIn=dot;var numberString=new String(theNumber);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;}
function addSelectToMap(){var selString="";if(highlightedOne!="")
{}
return selString;}
function getScaleBarDistance(){var mUnits=MapUnits;var mUnits=MapUnits;var mDistance=maxx-minx;var sbDistance=0
if(mUnits!=ScaleBarUnits){theDist=mDistance
mDistance=convertUnits(theDist,mUnits,ScaleBarUnits);}
sbDistance=mDistance/5;var num1=0;var num2=sbDistance;if(sbDistance>10000000){num1=parseInt(sbDistance/5000000);num2=num1*5000000;}else if(sbDistance>1000000){num1=parseInt(sbDistance/500000);num2=num1*500000;}else if(sbDistance>100000){num1=parseInt(sbDistance/50000);num2=num1*50000;}else if(sbDistance>10000){num1=parseInt(sbDistance/5000);num2=num1*5000;}else if(sbDistance>1000){num1=parseInt(sbDistance/500);num2=num1*500;}else if(sbDistance>100){num1=parseInt(sbDistance/50);num2=num1*50;}else if(sbDistance>10){num1=parseInt(sbDistance/5);num2=num1*5;}else if(sbDistance>1){num1=parseInt(sbDistance/(25/100));num2=num1*(25/100);}else if(sbDistance>0.1){num1=parseInt(sbDistance/(25/1000));num2=num1*(25/1000);}
sbDistance=num2;if(sbDistance>2){ScaleBarPrecision="0";}else if(sbDistance>1){ScaleBarPrecision="1";}else if(sbDistance>1/10){ScaleBarPrecision="2";}else if(sbDistance>1/100){ScaleBarPrecision="3";}else{ScaleBarPrecision="4";}
return sbDistance;}
function convertUnits(theDist1,mUnits,sUnits){var theDist=parseFloat(theDist1);var mDistance=theDist;if(mUnits=="FEET"){if(sUnits=="MILES"){mDistance=theDist/5280;}else if(sUnits=="METERS"){mDistance=theDist*(3048/10000);}else if(sUnits=="KILOMETERS"){mDistance=theDist*(3048/10000000);}}else{if(sUnits=="MILES"){mDistance=theDist*(621311922/10000000000000);}else if(sUnits=="FEET"){mDistance=theDist*(3280839895/1000000000);}else if(sUnits=="KILOMETERS"){mDistance=theDist/1000;}}
var u=Math.pow(10,numDecimals);if(!isNav)mDistance=parseInt(mDistance*u+(5/10))/u
return mDistance;}
function checkFullExtent(){var landscape;if((fullHeight/fullWidth)<0.6){var landscape=true}
if(enforceFullExtent){var xDistance1=Math.abs(maxx-minx);var yDistance1=Math.abs(maxy-miny);if(xDistance1>fullWidth){xDistance1=fullWidth;}
if(yDistance1>fullHeight){yDistance1=fullHeight;}
hideMinButton=false;hideGoWest=false;hideGoEast=false;hideGoNorth=false;hideGoSouth=false;if(landscape&&(maxy>=limitTop)&&(miny<=limitBottom)){hideMinButton=true;hideGoSouth=true;hideGoNorth=true;miny=limitBottom;maxy=limitTop;xDistance1=(3*yDistance1)/2;if(minx<=limitLeft){minx=limitLeft;maxx=minx+xDistance1;hideGoWest=true;}else if(maxx>=limitRight){maxx=limitRight;minx=maxx-xDistance1;hideGoEast=true;}}
else
{if((minx<=limitLeft)&&(maxy>=limitTop)&&(maxx>=limitRight)&&(miny<=limitBottom)){hideMinButton=true;}
if((maxx>=limitRight)&&(miny<=limitBottom)){hideGoSouth=true;hideGoEast=true;maxx=limitRight;miny=limitBottom;}else{if(minx<=limitLeft){minx=limitLeft;maxx=minx+xDistance1;hideGoWest=true;}else if(maxx>=limitRight){maxx=limitRight;minx=maxx-xDistance1;hideGoEast=true;}}
if((minx<=limitLeft)&&(maxy>=limitTop)){hideGoWest=true;hideGoNorth=true;minx=limitLeft;maxy=limitTop}else{if(maxy>=limitTop){maxy=limitTop;miny=maxy-yDistance1;hideGoNorth=true;}else if(miny<=limitBottom){miny=limitBottom;maxy=miny+yDistance1;hideGoSouth=true;}}}}}
