/*
* DragZoomControl Class v1.2 
*  Copyright (c) 2005-2007, Andre Lewis, andre@earthcode.com
*
* Back Button functionality
*  Copyright (c)  2007, Richard Garland, papabear.newyork@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* 
*       http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* This class lets you add a control to the map which will let the user
*  zoom by dragging a rectangle.
*  More info on original GZoom at http://earthcode.com
*
* Back Button functionality provides the user with a one click means to return the map state 
*  to its state prior to the DragZoom.  Sequential DragZooms are backed out in reverse order.
*/
function DragZoomControl(B,C,F){this.globals={draggingOn:false,cornerTopDiv:null,cornerRightDiv:null,cornerBottomDiv:null,cornerLeftDiv:null,mapPosition:null,outlineDiv:null,mapWidth:0,mapHeight:0,mapRatio:0,startX:0,startY:0,borderCorrection:0};this.globals.style={opacity:0.2,fillColor:"#000",border:"2px solid blue"};var E=this.globals.style;for(var D in B){E[D]=B[D]}var A=E.border.split(" ");E.outlineWidth=parseInt(A[0].replace(/\D/g,""));E.outlineColor=A[2];E.alphaIE="alpha(opacity="+(E.opacity*100)+")";this.globals.backStack=[];this.globals.options={buttonHTML:"zoom ...",buttonStartingStyle:{width:"52px",border:"1px solid black",padding:"2px"},buttonStyle:{background:"#FFF"},backButtonHTML:"zoom back",backButtonStyle:{background:"#FFF",display:"none"},buttonZoomingHTML:"Drag a region on the map",buttonZoomingStyle:{background:"#FF0"},overlayRemoveTime:6000,backButtonEnabled:false,stickyZoomEnabled:false};for(var D in C){this.globals.options[D]=C[D]}if(F==null){F={}}this.globals.callbacks=F}DragZoomControl.prototype=new GControl();DragZoomControl.prototype.saveMapContext=function(A){if(this.globals.options.backButtonEnabled){this.saveBackContext_(A,true);this.globals.backButtonDiv.style.display="block"}};DragZoomControl.prototype.initiateZoom=function(){this.buttonclick_()};DragZoomControl.prototype.initiateZoomBack=function(){if(this.globals.options.backButtonEnabled){this.backbuttonclick_()}};DragZoomControl.prototype.initButton_=function(A){var B=this.globals;var C=document.createElement("div");C.innerHTML=B.options.buttonHTML;C.id="gzoom-control";DragZoomUtil.style([C],{cursor:"pointer",zIndex:200});DragZoomUtil.style([C],B.options.buttonStartingStyle);DragZoomUtil.style([C],B.options.buttonStyle);A.appendChild(C);return C};DragZoomControl.prototype.initBackButton_=function(A){var B=this.globals;var C=document.createElement("div");C.innerHTML=B.options.backButtonHTML;C.id="gzoom-back";DragZoomUtil.style([C],{cursor:"pointer",zIndex:200});DragZoomUtil.style([C],B.options.buttonStartingStyle);DragZoomUtil.style([C],B.options.backButtonStyle);A.appendChild(C);return C};DragZoomControl.prototype.setButtonMode_=function(B){var A=this.globals;if(B=="zooming"){A.buttonDiv.innerHTML=A.options.buttonZoomingHTML;DragZoomUtil.style([A.buttonDiv],A.options.buttonStartingStyle);DragZoomUtil.style([A.buttonDiv],A.options.buttonZoomingStyle)}else{A.buttonDiv.innerHTML=A.options.buttonHTML;DragZoomUtil.style([A.buttonDiv],A.options.buttonStartingStyle);DragZoomUtil.style([A.buttonDiv],A.options.buttonStyle)}};DragZoomControl.prototype.initialize=function(I){var C=this.globals;var F=this;var B=I.getContainer();var A=document.createElement("div");DragZoomUtil.style([A],{cursor:"pointer",zIndex:150});var E=this.initButton_(A);var D=this.initBackButton_(A);B.appendChild(A);var H=document.createElement("div");H.id="gzoom-map-cover";H.innerHTML='<div id="gzoom-outline" style="position:absolute;display:none;"></div><div id="gzoom-cornerTopDiv" style="position:absolute;display:none;"></div><div id="gzoom-cornerLeftDiv" style="position:absolute;display:none;"></div><div id="gzoom-cornerRightDiv" style="position:absolute;display:none;"></div><div id="gzoom-cornerBottomDiv" style="position:absolute;display:none;"></div>';DragZoomUtil.style([H],{position:"absolute",top:"0px",display:"none",overflow:"hidden",cursor:"crosshair",zIndex:101});B.appendChild(H);GEvent.addDomListener(E,"click",function(G){F.buttonclick_(G)});GEvent.addDomListener(D,"click",function(G){F.backbuttonclick_(G)});GEvent.addDomListener(H,"mousedown",function(G){F.coverMousedown_(G)});GEvent.addDomListener(document,"mousemove",function(G){F.drag_(G)});GEvent.addDomListener(document,"mouseup",function(G){F.mouseup_(G)});C.mapPosition=DragZoomUtil.getElementPosition(B);C.outlineDiv=DragZoomUtil.gE("gzoom-outline");C.buttonDiv=DragZoomUtil.gE("gzoom-control");C.backButtonDiv=DragZoomUtil.gE("gzoom-back");C.mapCover=DragZoomUtil.gE("gzoom-map-cover");C.cornerTopDiv=DragZoomUtil.gE("gzoom-cornerTopDiv");C.cornerRightDiv=DragZoomUtil.gE("gzoom-cornerRightDiv");C.cornerBottomDiv=DragZoomUtil.gE("gzoom-cornerBottomDiv");C.cornerLeftDiv=DragZoomUtil.gE("gzoom-cornerLeftDiv");C.map=I;C.borderCorrection=C.style.outlineWidth*2;this.setDimensions_();this.initStyles_();C.mapCover.onselectstart=function(){return false};return A};DragZoomControl.prototype.getDefaultPosition=function(){return new GControlPosition(G_ANCHOR_TOP_LEFT,new GSize(3,120))};DragZoomControl.prototype.coverMousedown_=function(B){var A=this.globals;var C=this.getRelPos_(B);A.startX=C.left;A.startY=C.top;DragZoomUtil.style([A.mapCover],{background:"transparent",opacity:1,filter:"alpha(opacity=100)"});DragZoomUtil.style([A.outlineDiv],{left:A.startX+"px",top:A.startY+"px",display:"block",width:"1px",height:"1px"});A.draggingOn=true;A.cornerTopDiv.style.top=(A.startY-A.mapHeight)+"px";A.cornerTopDiv.style.display="block";A.cornerLeftDiv.style.left=(A.startX-A.mapWidth)+"px";A.cornerLeftDiv.style.top=A.startY+"px";A.cornerLeftDiv.style.display="block";A.cornerRightDiv.style.left=A.startX+"px";A.cornerRightDiv.style.top=A.startY+"px";A.cornerRightDiv.style.display="block";A.cornerBottomDiv.style.left=A.startX+"px";A.cornerBottomDiv.style.top=A.startY+"px";A.cornerBottomDiv.style.width="0px";A.cornerBottomDiv.style.display="block";if(A.callbacks.dragstart!=null){A.callbacks.dragstart(A.startX,A.startY)}return false};DragZoomControl.prototype.drag_=function(B){var A=this.globals;if(A.draggingOn){var C=this.getRelPos_(B);rect=this.getRectangle_(A.startX,A.startY,C,A.mapRatio);if(rect.left){addX=-rect.width}else{addX=0}if(rect.top){addY=-rect.height}else{addY=0}DragZoomUtil.style([A.outlineDiv],{left:A.startX+addX+"px",top:A.startY+addY+"px",display:"block",width:"1px",height:"1px"});A.outlineDiv.style.width=rect.width+"px";A.outlineDiv.style.height=rect.height+"px";A.cornerTopDiv.style.height=((A.startY+addY)-(A.startY-A.mapHeight))+"px";A.cornerLeftDiv.style.top=(A.startY+addY)+"px";A.cornerLeftDiv.style.width=((A.startX+addX)-(A.startX-A.mapWidth))+"px";A.cornerRightDiv.style.top=A.cornerLeftDiv.style.top;A.cornerRightDiv.style.left=(A.startX+addX+rect.width+A.borderCorrection)+"px";A.cornerBottomDiv.style.top=(A.startY+addY+rect.height+A.borderCorrection)+"px";A.cornerBottomDiv.style.left=(A.startX-A.mapWidth+((A.startX+addX)-(A.startX-A.mapWidth)))+"px";A.cornerBottomDiv.style.width=(rect.width+A.borderCorrection)+"px";if(A.callbacks.dragging!=null){A.callbacks.dragging(A.startX,A.startY,rect.endX,rect.endY)}return false}};DragZoomControl.prototype.mouseup_=function(E){var M=this.globals;if(M.draggingOn){var H=this.getRelPos_(E);M.draggingOn=false;var I=this.getRectangle_(M.startX,M.startY,H,M.mapRatio);if(I.left){I.endX=I.startX-I.width}if(I.top){I.endY=I.startY-I.height}this.resetDragZoom_();var N=new GPoint(I.startX,I.startY);var A=new GPoint(I.endX,I.startY);var K=new GPoint(I.endX,I.endY);var F=new GPoint(I.startX,I.endY);var C=M.map.fromContainerPixelToLatLng(N);var B=M.map.fromContainerPixelToLatLng(A);var D=M.map.fromContainerPixelToLatLng(K);var L=M.map.fromContainerPixelToLatLng(F);var J=new GPolyline([C,B,D,L,C],M.style.outlineColor,M.style.outlineWidth+1,0.4);try{M.map.addOverlay(J);setTimeout(function(){M.map.removeOverlay(J)},M.options.overlayRemoveTime)}catch(E){}polyBounds=J.getBounds();var B=polyBounds.getNorthEast();var L=polyBounds.getSouthWest();var D=new GLatLng(L.lat(),B.lng());var C=new GLatLng(B.lat(),L.lng());zoomLevel=M.map.getBoundsZoomLevel(polyBounds);center=polyBounds.getCenter();M.map.setCenter(center,zoomLevel);if(M.callbacks.dragend!=null){M.callbacks.dragend(C,B,D,L,N,A,K,F)}if(M.options.stickyZoomEnabled){this.initCover_();if(M.options.backButtonEnabled){this.saveBackContext_(M.options.backButtonHTML,false)}M.backButtonDiv.style.display="none"}}};DragZoomControl.prototype.setDimensions_=function(){var A=this.globals;var B=A.map.getSize();A.mapWidth=B.width;A.mapHeight=B.height;A.mapRatio=A.mapHeight/A.mapWidth;DragZoomUtil.style([A.mapCover,A.cornerTopDiv,A.cornerRightDiv,A.cornerBottomDiv,A.cornerLeftDiv],{left:"0px",width:A.mapWidth+"px",height:A.mapHeight+"px"})};DragZoomControl.prototype.initStyles_=function(){var A=this.globals;DragZoomUtil.style([A.mapCover,A.cornerTopDiv,A.cornerRightDiv,A.cornerBottomDiv,A.cornerLeftDiv],{filter:A.style.alphaIE,opacity:A.style.opacity,background:A.style.fillColor});A.outlineDiv.style.border=A.style.border};DragZoomControl.prototype.buttonclick_=function(){var A=this.globals;A.backButtonDiv.style.display="none";if(A.mapCover.style.display=="block"){this.resetDragZoom_();if(A.options.backButtonEnabled){this.restoreBackContext_();if(A.backStack.length==0){A.backButtonDiv.style.display="none"}}}else{this.initCover_();if(A.options.backButtonEnabled){this.saveBackContext_(A.options.backButtonHTML,false)}}};DragZoomControl.prototype.backbuttonclick_=function(){var A=this.globals;if(A.options.backButtonEnabled&&A.backStack.length>0){this.restoreBackContext_();if(A.callbacks.backbuttonclick!=null){A.callbacks.backbuttonclick(A.methodCall)}}};DragZoomControl.prototype.saveBackContext_=function(D,A){var B=this.globals;var C={};C.center=B.map.getCenter();C.zoom=B.map.getZoom();C.maptype=B.map.getCurrentMapType();C.text=B.backButtonDiv.innerHTML;C.methodCall=A;B.backStack.push(C);B.backButtonDiv.innerHTML=D};DragZoomControl.prototype.restoreBackContext_=function(){var A=this.globals;var B=A.backStack.pop();A.map.setCenter(B.center,B.zoom,B.maptype);A.backButtonDiv.innerHTML=B.text;A.methodCall=B.methodCall;if(A.backStack.length==0){A.backButtonDiv.style.display="none"}};DragZoomControl.prototype.initCover_=function(){var A=this.globals;A.mapPosition=DragZoomUtil.getElementPosition(A.map.getContainer());this.setDimensions_();this.setButtonMode_("zooming");DragZoomUtil.style([A.mapCover],{display:"block",background:A.style.fillColor});DragZoomUtil.style([A.outlineDiv],{width:"0px",height:"0px"});if(A.callbacks.buttonclick!=null){A.callbacks.buttonclick()}};DragZoomControl.prototype.getRelPos_=function(B){var C=DragZoomUtil.getMousePosition(B);var A=this.globals;return{top:(C.top-A.mapPosition.top),left:(C.left-A.mapPosition.left)}};DragZoomControl.prototype.getRectangle_=function(D,B,H,E){var G=false;var F=false;var C=H.left-D;var A=H.top-B;if(C<0){C=C*-1;G=true}if(A<0){A=A*-1;F=true}delta=C>A?C:A;return{startX:D,startY:B,endX:D+delta,endY:B+parseInt(delta*E),width:delta,height:parseInt(delta*E),left:G,top:F}};DragZoomControl.prototype.resetDragZoom_=function(){var A=this.globals;DragZoomUtil.style([A.mapCover,A.cornerTopDiv,A.cornerRightDiv,A.cornerBottomDiv,A.cornerLeftDiv],{display:"none",opacity:A.style.opacity,filter:A.style.alphaIE});A.outlineDiv.style.display="none";this.setButtonMode_("normal");if(A.options.backButtonEnabled&&(A.backStack.length>0)){A.backButtonDiv.style.display="block"}};var DragZoomUtil={};DragZoomUtil.gE=function(A){return document.getElementById(A)};DragZoomUtil.getMousePosition=function(A){var C=0;var B=0;if(!A){var A=window.event}if(A.pageX||A.pageY){C=A.pageX;B=A.pageY}else{if(A.clientX||A.clientY){C=A.clientX+(document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft);B=A.clientY+(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop)}}return{left:C,top:B}};DragZoomUtil.getElementPosition=function(C){var B=C.offsetLeft;var A=C.offsetTop;var D=C.offsetParent;while(D!=null){B+=D.offsetLeft;A+=D.offsetTop;D=D.offsetParent}return{left:B,top:A}};DragZoomUtil.style=function(D,C){if(typeof (D)=="string"){D=DragZoomUtil.getManyElements(D)}for(var A=0;A<D.length;A++){for(var B in C){D[A].style[B]=C[B]}}};DragZoomUtil.getManyElements=function(D){var B=D.split(",");var C=[];for(var A=0;A<B.length;A++){C[C.length]=DragZoomUtil.gE(B[A])}return C};
/*
 * Google Maps Adapter to ArcGIS Server Cache
 * @Author Nianwei Liu 
 * @Date 2008-03-27
 */
function LCC(U){if(!U||U==null){U={}}this.name=U.name||"LCC";var D=(U.semi_major||6378137)/(U.unit||0.3048006096012192);var N=U.inverse_flattening||298.257222101;var H=(U.standard_parallel_1||34.33333333333334)*(Math.PI/180);var G=(U.standard_parallel_2||36.16666666666666)*(Math.PI/180);var A=(U.latitude_of_origin||33.75)*(Math.PI/180);var J=(U.central_meridian||-79)*(Math.PI/180);var V=U.false_easting||2000000.002616666;var P=U.false_northing||0;var Q=function(a,b){var Z=Math.sin(a);return Math.cos(a)/Math.sqrt(1-b*Z*Z)};var M=function(a,b){var Z=b*Math.sin(a);return Math.tan(Math.PI/4-a/2)/Math.pow((1-Z)/(1+Z),b/2)};var O=function(Z,c,b,d){return Z*c*Math.pow(b,d)};var E=function(Z,c,b){var a=c*Math.sin(b);return Math.PI/2-2*Math.atan(Z*Math.pow((1-a)/(1+a),c/2))};var T=function(b,d,f){var a=0;var c=f;var Z=E(b,d,c);while(Math.abs(Z-c)>1e-9&&a<10){a++;c=Z;Z=E(b,d,c)}return Z};var B=1/N;var F=2*B-B*B;var C=Math.sqrt(F);var L=Q(H,F);var K=Q(G,F);var I=M(A,C);var Y=M(H,C);var W=M(G,C);var X=Math.log(L/K)/Math.log(Y/W);var R=L/(X*Math.pow(Y,X));var S=O(D,R,I,X);this.forward=function(g){var d=g[1]*(Math.PI/180);var Z=g[0]*(Math.PI/180);var b=M(d,C);var c=O(D,R,b,X);var a=X*(Z-J);var e=V+c*Math.sin(a);var f=P+S-c*Math.cos(a);return[e,f]};this.inverse=function(f){var e=f[0];var g=f[1];var b=Math.atan((e-V)/(S-(g-P)));var a=(X>0?1:-1)*Math.sqrt((e-V)*(e-V)+(S-(g-P))*(S-(g-P)));var c=Math.pow((a/(D*R)),1/X);var d=T(c,C,0);var Z=b/X+J;return[Z*(180/Math.PI),d*(180/Math.PI)]};this.circum=function(){return Math.PI*2*D}}function GMapCacheProjection(A){if(!A||A==null){A={}}this.zoomOffset=A.zoomOffset||10;this.originX=A.originX||0;this.originY=A.originY||2000000;this.projection=A.projection||new LCC();this.resolutions=A.resolutions||[434.027777777778,217.013888888889,108.506944444444,55.5555555555556,27.7777777777778,13.8888888888889,6.94444444444444,3.47222222222222,1.73611111111111,1,0.5];this.bounds=A.bounds||null}GMapCacheProjection.prototype=new GProjection();GMapCacheProjection.prototype.fromLatLngToPixel=function(F,B){if(F==null){return null}var D=this.projection.forward([F.lng(),F.lat()]);var C=B-this.zoomOffset;var A=Math.round((D[0]-this.originX)/this.resolutions[C]);var E=Math.round((this.originY-D[1])/this.resolutions[C]);return new GPoint(A,E)};GMapCacheProjection.prototype.fromPixelToLatLng=function(B,C,E){if(B==null){return null}var D=C-this.zoomOffset;var A=B.x*this.resolutions[D]+this.originX;var G=this.originY-B.y*this.resolutions[D];var F=this.projection.inverse([A,G]);return new GLatLng(F[1],F[0])};GMapCacheProjection.prototype.tileCheckRange=function(G,I,F){var H=this.bounds;if(!H||H==null){return true}var E=I-this.zoomOffset;var D=G.x*F*this.resolutions[E]+this.originX;var C=this.originY-(G.y+1)*F*this.resolutions[E];var B=(G.x+1)*F*this.resolutions[E]+this.originX;var A=this.originY-G.y*F*this.resolutions[E];return !(H.minX>B||H.maxX<D||H.maxY<C||H.minY>A)};GMapCacheProjection.prototype.getWrapWidth=function(A){var B=A-this.zoomOffset;return this.projection.circum()/this.resolutions[B]};GMapCacheProjection.prototype.fromLatLngToCoords=function(B){var A=this.projection.forward([B.lng(),B.lat()]);return new GPoint(A[0],A[1])};GMapCacheProjection.prototype.fromCoordsToLatLng=function(A){var B=this.projection.inverse([A.x,A.y]);return new GLatLng(B[1],B[0])};function MapOverlay(A,B){this.url=A;this.bounds=B}MapOverlay.prototype=new GOverlay();MapOverlay.prototype.initialize=function(B){var A=document.createElement("img");A.style.position="absolute";B.getPane(G_MAP_MAP_PANE).appendChild(A);this.map_=B;this.img_=A};MapOverlay.prototype.remove=function(){this.img_.parentNode.removeChild(this.img_)};MapOverlay.prototype.copy=function(){return new MapOverlay(this.url)};MapOverlay.prototype.redraw=function(C){if(!C){return }var A=this.bounds.getSouthWest();var E=this.bounds.getNorthEast();var D=this.map_.fromLatLngToDivPixel(A);var B=this.map_.fromLatLngToDivPixel(E);this.img_.src=this.url;this.img_.style.left=D.x+"px";this.img_.style.top=B.y+"px";this.img_.style.width=Math.abs(B.x-D.x)+"px";this.img_.style.height=Math.abs(D.y-B.y)+"px"};var COC={};COC.getTileUrl=function(A,B,E,D){var C=document.location.host.indexOf("charmeck.org")==-1?"":"http://mt"+((E.x+E.y)%4)+".charmeck.org";return C+"/mapcache/"+A+"/Layers/_alllayers/L"+("00"+D.toString(10)).substring(("00"+D.toString(10)).length-2)+"/R"+("00000000"+E.y.toString(16)).substring(("00000000"+E.y.toString(16)).length-8)+"/C"+("00000000"+E.x.toString(16)).substring(("00000000"+E.x.toString(16)).length-8)+"."+B};var COC_COPYRIGHTS=new GCopyrightCollection("Data (c) 2008");COC_COPYRIGHTS.addCopyright(new GCopyright(1,new GLatLngBounds(new GLatLng(35,-81.7),new GLatLng(35.54,-80.5)),10,"City Of Charlotte, Mecklenburge County, NC"));var COC_PROJECTION=new GMapCacheProjection({bounds:{minX:1320000,minY:450000,maxX:1600000,maxY:660000}});var COC_ZONING_LAYER=new GTileLayer(COC_COPYRIGHTS,10,18);COC_ZONING_LAYER.getTileUrl=function(B,A){return COC.getTileUrl("PLAN_zoning","png",B,A-10)};var COC_AERIAL_LAYER=new GTileLayer(COC_COPYRIGHTS,10,20);COC_AERIAL_LAYER.getTileUrl=function(B,A){return COC.getTileUrl("GET_aerial","jpg",B,A-10)};var COC_BLEND_LAYER=new GTileLayer(COC_COPYRIGHTS,10,20,{isPng:true});COC_BLEND_LAYER.getTileUrl=function(B,A){return COC.getTileUrl("GET_Labels","png",B,A-10)};var COC_GRID_LAYER=new GTileLayer(COC_COPYRIGHTS,10,20,{tileUrlTemplate:"Images/grid512.png?x={X}&y={Y}&z={Z}}"});var COC_ZONING_MAP=new GMapType([COC_ZONING_LAYER],COC_PROJECTION,"Zoning",{errorMessage:"No data available",tileSize:512});var COC_AERIAL_MAP=new GMapType([COC_AERIAL_LAYER],COC_PROJECTION,"Aerial",{errorMessage:"No data available",tileSize:512});var COC_HYBRID_MAP=new GMapType([COC_AERIAL_LAYER,COC_BLEND_LAYER],COC_PROJECTION,"Hybrid",{errorMessage:"No data available",tileSize:512});var map=null;var loading=false;var querying=false;var tileServerBaseURL="/TileServer/MapTile.ashx";var mouseOnInfoWindow=false;var mapInfoTimeout=null;var clickTolerance=4;var mapMouseMoveLister=null;var tileOverlays=[];var markers=[];var sizebar_list_html="";var markerbounds=null;var ground=null;function windowSize(){if(self.innerHeight){return[self.innerWidth,self.innerHeight]}if(document.documentElement&&document.documentElement.clientHeight){return[document.documentElement.clientWidth,document.documentElement.clientHeight]}if(document.body){return[document.body.clientWidth,document.body.clientHeight]}return[0,0]}function handleResize(){var B=windowSize();var A=B[1]-document.getElementById("toolbar").offsetHeight-30;document.getElementById("map").style.height=A+"px";document.getElementById("sidebar").style.height=A+"px";var C=B[0]-document.getElementById("sidebar").offsetWidth-30;document.getElementById("map").style.width=C+"px";if(map!=null){map.checkResize()}}function load(){if(GBrowserIsCompatible()){handleResize();var B=document.getElementById("map");document.getElementById("map").style.backgroundColor="white";map=new GMap2(B);var A=new GKeyboardHandler(map);map.enableDoubleClickZoom();map.enableContinuousZoom();map.enableScrollWheelZoom();var C=parseFloat(document.getElementById("map").style.height);if(C>450){map.addControl(new GLargeMapControl())}else{map.addControl(new GSmallMapControl())}map.addControl(new GMapTypeControl());map.addControl(new DragZoomControl({opacity:0.2,border:"2px solid red"},{buttonHTML:"<img src='images/zoom-button.gif' />",buttonZoomingHTML:"<img src='images/zoom-button-activated.gif' />",buttonStartingStyle:{width:"24px",height:"24px"},overlayRemoveTime:2000}),new GControlPosition(G_ANCHOR_TOP_LEFT,new GSize(50,50)));map.setCenter(new GLatLng(35.249208,-80.843099),C>500?11:10);map.getMapTypes().length=0;map.addMapType(COC_ZONING_MAP);map.addMapType(COC_AERIAL_MAP);map.addMapType(COC_HYBRID_MAP);map.setMapType(COC_ZONING_MAP);GEvent.addListener(map,"click",function(E,D){v=E;if(E==null&&D!=null){setupMapInfo(D)}});GEvent.addListener(map,"dblclick",function(E,D){if(E==null&&D!=null){cancelMapInfo()}});GEvent.addListener(map,"mousemove",function(D){if(D!=null){var F="Z="+map.getZoom()+" LatLng:("+D.toUrlValue()+")";var E=map.getCurrentMapType().getProjection();if(E.fromLatLngToCoords){var G=E.fromLatLngToCoords(D);F=F+" Coords:("+parseInt(G.x)+", "+parseInt(G.y)+")"}window.status=F}});window.onresize=handleResize;setupAutoSuggest()}}function setupAutoSuggest(){var A=new AutoSuggestControl(document.getElementById("TXT_STNAME"),new RemoteSuggestions("Search.ashx?action=streetlist&TXT_STNAME="))}function log(A){}function RESET_ADDRESS_PARTS_onclick(){clearSearchResults();document.getElementById("NUM_STREET").value="";document.getElementById("TXT_STDIR").value=""}function optionValue(C){var B=C.selectedIndex;if(B<=0){return""}var A=C.options[B].value;if(A!=""){return A}else{return C.options[B].text}}function showHide(C,A){var B=document.getElementById(C);if(B!=null){B.style.visibility=A?"visible":"hidden"}}function showForm(C){var B=document.getElementById("frmDivsWrapper");if(B!=null){var A=B.childNodes;for(var D=0;D<A.length;D++){if(A[D].style){if(A[D].id==C){A[D].style.display="block"}else{A[D].style.display="none"}}}}}function searchByAddress(){var F="Search.ashx?action=address";var E=document.getElementById("NUM_STREET").value.replace(/&/g,"&amp;");var D=document.getElementById("TXT_STDIR")==null?"":optionValue(document.getElementById("TXT_STDIR")).replace(/&/g,"&amp;");var C=document.getElementById("TXT_STNAME").value.replace(/&/g,"&amp;");var A=document.getElementById("TXT_STSUFF")==null?"":optionValue(document.getElementById("TXT_STSUFF")).replace(/&/g,"&amp;");var B=document.getElementById("TXT_STYPE4")==null?"":optionValue(document.getElementById("TXT_STYPE4")).replace(/&/g,"&amp;");if(C==""){alert("Please type in Street Name");return false}var G=null;F=F+"&NUM_STREET="+E+"&TXT_STDIR="+D+"&TXT_STNAME="+C+"&TXT_STSUFF="+A+"&TXT_STYPE4="+B;log(F);var H=GXmlHttp.create();H.open("GET",F,true);H.onreadystatechange=function(){processSearchResults(H)};H.send(G)}function searchByParcel(){var B="Search.ashx?action=parcel";var A=document.getElementById("ID_PARCEL").value.replace(/&/g,"&amp;");if(A==""||A.length<7){alert("Please type in valid 8 digits Parcel Number");return false}var C=null;B=B+"&ID_PARCEL="+A;log(B);var D=GXmlHttp.create();D.open("GET",B,true);D.onreadystatechange=function(){processSearchResults(D)};D.send(C)}function processSearchResults(request){if(request.readyState==4){clearSearchResults();var json=request.responseText;if(json.length>0){var points=eval(json);sizebar_list_html="<table>";markerbounds=null;for(var i=0;i<points.length;i++){var latlng=new GLatLng(points[i].lat,points[i].lng);var header=points[i].full_address+"&nbsp;<br/>Parcel "+points[i].pid;var letter=String.fromCharCode("A".charCodeAt(0)+i);var img="http://www.google.com/mapfiles/marker"+letter+".png";sizebar_list_html+="<tr><td style='vertical-align:top'><img src='"+img+"' ></td><td><div id='header-"+i+"' class='fieldValue'><a href='javascript:getMapInfo("+points[i].lat+","+points[i].lng+", true)'>"+header+"</a></div></td></tr>";if(markerbounds==null){markerbounds=new GLatLngBounds(latlng,latlng)}else{markerbounds.extend(latlng)}}sizebar_list_html+="</table>";document.getElementById("sidebar-list").innerHTML=sizebar_list_html;if(points.length==0){alert("No Results Found, Please try again.")}else{showHide("btnClearResults",true);if(points.length==1){map.setCenter(new GLatLng(points[0].lat,points[0].lng),17);getMapInfo(points[0].lat,points[0].lng)}else{if(markerbounds!=null&&!markerbounds.isEmpty()){map.setCenter(markerbounds.getCenter(),map.getBoundsZoomLevel(markerbounds))}}}}else{alert("No Results Found, Please try again.")}}}function clearSearchResults(){map.closeInfoWindow();for(var A=0;A<markers.length;A++){map.removeOverlay(markers[A])}markers.length=0;markerbounds=null;document.getElementById("sidebar-list").innerHTML="";showHide("btnClearResults",false)}function setupMapInfo(A){log("setupMapInfo");mapInfoTimeout=window.setTimeout(function(){getMapInfo(A.lat(),A.lng(),false)},500);log("done setupMapInfo")}function cancelMapInfo(){if(mapInfoTimeout!=null){window.clearTimeout(mapInfoTimeout);mapInfoTimeout=null}}function getMapInfo(G,H,E){if(map.getZoom()<13){alert("Please zoom in to street level and click for zoning information");return }var I=new GLatLng(G,H);var F=1e-8;var A="Search.ashx?action=identify";var B=map.getCurrentMapType().getProjection();if(B.fromLatLngToCoords){var J=B.fromLatLngToCoords(new GLatLng(G-F,H-F));var C=B.fromLatLngToCoords(new GLatLng(G+F,H+F));A+="&minx="+J.x+"&miny="+J.y+"&maxx="+C.x+"&maxy="+C.y+"&rnd="+Math.random()}else{A+="&srid=4326&minx="+(H-F)+"&miny="+(G-F)+"&maxx="+(H+F)+"&maxy="+(G+F)+"&rnd="+Math.random()}var D=GXmlHttp.create();D.open("GET",A,true);D.onreadystatechange=function(){if(D.readyState==4){var K=D.responseText;if(E){map.setCenter(I,17)}map.openInfoWindowHtml(I,K,{maxWidth:300})}};D.send(null)}
/* 
* FROM http://www.webreference.com/programming/javascript/ncz/column3/ 
* @By Nicholas C. Zakas.
* @NL: Modified: check aSuggestions null
*/
function AutoSuggestControl(B,A){this.cur=-1;this.layer=null;this.provider=A;this.textbox=B;this.timer=null;this.init()}AutoSuggestControl.prototype.autosuggest=function(B,A){if(B!=null&&B.length>0){if(A){this.typeAhead(B[0])}this.showSuggestions(B)}else{this.hideSuggestions()}};AutoSuggestControl.prototype.createDropDown=function(){var A=this;this.layer=document.createElement("div");this.layer.className="suggestions";this.layer.style.visibility="hidden";this.layer.style.width=this.textbox.offsetWidth;this.layer.onmousedown=this.layer.onmouseup=this.layer.onmouseover=function(B){B=B||window.event;oTarget=B.target||B.srcElement;if(B.type=="mousedown"){var C=oTarget.firstChild;if(C.firstChild!=null){C=C.firstChild}A.textbox.value=C.nodeValue;A.hideSuggestions()}else{if(B.type=="mouseover"){A.highlightSuggestion(oTarget)}else{A.textbox.focus()}}};document.body.appendChild(this.layer)};AutoSuggestControl.prototype.getLeft=function(){var B=this.textbox;var A=0;while(B!=null&&B.tagName.toUpperCase()!="BODY"){A+=B.offsetLeft;B=B.offsetParent}return A};AutoSuggestControl.prototype.getTop=function(){var B=this.textbox;var A=0;while(B!=null&&B.tagName.toUpperCase()!="BODY"){A+=B.offsetTop;B=B.offsetParent}return A};AutoSuggestControl.prototype.handleKeyDown=function(A){switch(A.keyCode){case 38:this.previousSuggestion();break;case 40:this.nextSuggestion();break;case 13:this.hideSuggestions();break}};AutoSuggestControl.prototype.handleKeyUp=function(A){if(this.timer!=null){window.clearTimeout(this.timer)}var C=A.keyCode;var B=this;this.timer=window.setTimeout(function(){if(C==8||C==46){B.provider.requestSuggestions(B,false)}else{if(C<32||(C>=33&&C<46)||(C>=112&&C<=123)){}else{B.provider.requestSuggestions(B,true)}}},1000)};AutoSuggestControl.prototype.hideSuggestions=function(){this.layer.style.visibility="hidden"};AutoSuggestControl.prototype.highlightSuggestion=function(A){for(var B=0;B<this.layer.childNodes.length;B++){var C=this.layer.childNodes[B];if(C==A){C.className="current"}else{if(C.className=="current"){C.className=""}}}};AutoSuggestControl.prototype.init=function(){var A=this;this.textbox.onkeyup=function(B){if(!B){B=window.event}A.handleKeyUp(B)};this.textbox.onkeydown=function(B){if(!B){B=window.event}A.handleKeyDown(B)};this.textbox.onblur=function(){A.hideSuggestions()};this.createDropDown()};AutoSuggestControl.prototype.nextSuggestion=function(){var B=this.layer.childNodes;if(B.length>0&&this.cur<B.length-1){var A=B[++this.cur];this.highlightSuggestion(A);this.textbox.value=A.firstChild.nodeValue}};AutoSuggestControl.prototype.previousSuggestion=function(){var B=this.layer.childNodes;if(B.length>0&&this.cur>0){var A=B[--this.cur];this.highlightSuggestion(A);this.textbox.value=A.firstChild.nodeValue}};AutoSuggestControl.prototype.selectRange=function(A,B){if(this.textbox.createTextRange){var C=this.textbox.createTextRange();C.moveStart("character",A);C.moveEnd("character",B-this.textbox.value.length);C.select()}else{if(this.textbox.setSelectionRange){this.textbox.setSelectionRange(A,B)}}this.textbox.focus()};AutoSuggestControl.prototype.showSuggestions=function(C){var A=null;this.layer.innerHTML="";for(var B=0;B<C.length;B++){A=document.createElement("div");A.appendChild(document.createTextNode(C[B]));this.layer.appendChild(A)}this.layer.style.left=this.getLeft()+"px";this.layer.style.top=(this.getTop()+this.textbox.offsetHeight)+"px";this.layer.style.visibility="visible"};AutoSuggestControl.prototype.typeAhead=function(B){if(this.textbox.createTextRange||this.textbox.setSelectionRange){var A=this.textbox.value.length;this.textbox.value=B;this.selectRange(A,B.length)}};function RemoteSuggestions(A){this.base=A;if(typeof XMLHttpRequest!="undefined"){this.http=new XMLHttpRequest()}else{if(typeof ActiveXObject!="undefined"){this.http=new ActiveXObject("MSXML2.XmlHttp")}else{alert("No XMLHttpRequest object available. This functionality will not work.")}}}RemoteSuggestions.prototype.requestSuggestions=function(oAutoSuggestControl,bTypeAhead){var oHttp=this.http;if(oHttp.readyState!=0){oHttp.abort()}var sURL=this.base+encodeURIComponent(oAutoSuggestControl.textbox.value);oHttp.open("get",sURL,true);oHttp.onreadystatechange=function(){if(oHttp.readyState==4){var aSuggestions=eval(oHttp.responseText);oAutoSuggestControl.autosuggest(aSuggestions,bTypeAhead)}};oHttp.send(null)};