var DMP_AUTH_STATUS="VALID";var ReturnGeometryType={NONE:2,CENTRIOD:3,CENTROID:3,GEOMETRY:1,LATLON:4};function DMCException(b,a){this.msgCode=a;this.description=b;this.message=b;this.getMessage=c;this.toString=c;function c(){return b}}function DMCQueryControl(v,m){var b="http://parcelstream.com/Query.aspx";if(v!=null){b=v}var a="y_coord";var u="x_coord";var A=m;var t=null;var y=-1;var q=1;var k=0;var d="@@@@";var G=t;var C=200;var f=null;var p=null;var e=null;var o="json";var F=0;var r=false;var l=-1;var z=false;var h=20;var c=null;var j=null;var g=null;var s=null;var x=null;var B=0;var D=ReturnGeometryType.GEOMETRY;var w=null;var n=null;this.setKeyField=function(H){n=H};this.getKeyField=function(){return n};this.setLatitudeField=function(H){a=H};this.setLongitudeField=function(H){u=H};this.getSelectAttributeName=function(){return"attr"};this.getAttributeCondName=function(){return"attrConds"};this.setSelectAttributes=function(H){G=H};this.getSelectAttributes=function(){return G};this.setMaxOutputRecords=function(H){C=H};this.setOrderByAttribute=function(H){f=H};this.setWhereClause=function(I,H){p=I;e=H};this.setAPNFilter=function(I,H){j=I;g=H};this.setID=function(H){c=H};this.setGeometryFilter=function(H){s=H};this.setSpatialReference=function(H){x=H};this.setGeometryBufferDistance=function(H){B=H};this.setReturnGeometryType=function(H){D=H};this.setOutputType=function(H){o=H};this.setMinRecords=function(H){F=H};this.setNoSchema=function(H){r=H};this.setNoRecordsIfOverN=function(H){l=H};this.setIsTileOutSearch=function(H){z=H};this.setMaxRadius=function(H){h=H};this.getQueryServiceUrl=function(){return b};this.getResourceName=function(){return A};this.getDataSource=function(){return A};this.setDataSource=function(H){A=H};this.getQuery=function(){var I=b+"?";if(p!=null&&p.length>0){I+="attrConds=";if(typeof(p)=="string"){I+=this.encodeParameter(p)}else{for(var J=0;J<p.length;J++){var K=p[J];if(K==null||K==""){continue}I+=this.encodeParameter(K);if(J!=p.length-1){I+=d}}}}if(e!=null){I+="&andCond="+this.encodeParameter(e)}var H=G;if(D!=null&&D>=0){if(D==ReturnGeometryType.LATLON){H=H.toUpperCase();H=ReplaceString(H,"GEOMETRY",a+" AS _LATFIELD,"+u+" AS _LONFIELD")}else{I+="&returnGeoType="+D}}if(H!=null){I+="&attr="+this.encodeParameter(H)}if(C!=null){I+="&maxRecords="+C}if(A!=null&&A.length>0){I+="&DataSource="+this.encodeParameter(A)}if(f!=null){I+="&orderBy="+this.encodeParameter(f)}if(x!=null&&x.length>0){I+="&srs="+this.encodeParameter(x)}if(B!=null&&B>0){I+="&geoBufferDist="+B}if(s!=null){I+="&geoFilter="+this.encodeParameter(s)}if(c){I+="&ID="+this.encodeParameter(c)}else{if(j&&g){I+="&APN="+this.encodeParameter(j);I+="&FIPS="+this.encodeParameter(g)}}if(o!=null&&o.toLowerCase()!="json"){I+="&output="+this.encodeParameter(o)}if(F!=null&&F>0){I+="&minRecords="+this.encodeParameter(F)}if(r!=null&&r==true){I+="&noSchema=true"}if(l!=null&&l>1){I+="&noRecordsIfOverN="+this.encodeParameter(l)}if(z!=null&&z==true&&s!=null){I+="&isTileOutSearch=true";if(h!=null&&h>1){I+="&maxRadius="+this.encodeParameter(h)}if(a!=null){I+="&latField="+this.encodeParameter(a)}if(u!=null){I+="&lonField="+this.encodeParameter(u)}}return I};this.geocode=function(P,J,K,I,O,N,L,M,Q,H){if(w==null){w=new DMPGeocoder()}w.geocodeByAddress(P,J,K,O,N,L,M,Q,H)};var E=0;this.execute=function(I,H,M,K){var J=this.getQuery();try{var N=new _DMCQueryControlObserver(I,H,M,this.getResourceName(),n);if(K==null||typeof(K)=="undefined"){K="query"+K++}gLoadJSON(J,N,"onSuccess","onError",K)}catch(L){alert("Error DMCQueryCOntrol:"+L.description)}};this.encodeParameter=function(H){if(H!=null){return encodeURIComponent(H)}return""}}function _DMCQueryControlObserver(c,a,f,e,b){if(c==null){throw new DMCException("DMCQueryControlObserver: observer is undefined")}if(c[a]==null){throw new DMCException("DMCQueryControlObserver: observer must have a success method '"+a+"()' ")}if(c[f]==null){throw new DMCException("DMCQueryControlObserver: observer must have an error method '"+f+"()' ")}var d=this;this._observer=c;this._onSuccessMethod=a;this._onErrorMethod=f;this._dataSourceName=e;this.onSuccess=function(g,h,k){if(b==null&&typeof(c.getKeyField)!="undefined"){b=c.getKeyField()}var l=d._dataSourceName;if(c.getLayerName){l=c.getLayerName()}var j=JSON2RecordSet(g,b,l);c[a](j,e)};this.onError=function(h,j,g){c[f](h,j,g)};this.tryParse=function(h,g){if(h==null||g==null){return g}if(h=="int"){return parseInt(g)}else{if(h=="double"||h=="float"){return parseFloat(g)}else{if(h=="bool"){if(g=="1"||g=="true"){return true}else{return false}}else{return g}}}}}function DMPGeocoder(c){var d=1;var e="http://parcelstream.com/Geocode.aspx";if(c!=null){e=c}var a=["ID","DATASOURCE","ADDRESS","ZIP"];this.geocodeByAddress=function(p,g,h,o,m,j,k,q,f){if(f!=null&&f==true){f="true"}else{f=""}var r=e+"?";r+=b("address",o);r+=b("city",m);r+=b("state",j);r+=b("zip",k);r+=b("includeGeo",f);r+=b("minScore",q);try{var l=new _DMCQueryControlObserver(p,g,h,"",a);d=d++;gLoadJSON(r,l,"onSuccess","onError",d)}catch(n){alert("Error DMPGeocoder:"+n.description)}};function b(f,g){if(typeof(g)!="undefined"&&typeof(f)!="undefined"&&f!=null&&f!=""&&g!=""&&g!=null){return"&"+f+"="+encodeURIComponent(g)}return""}}function CPriority(){this.LOW=1000;this.MEDIUM=20;this.HIGH=2;this.HIGHEST=1}var Priority=new CPriority();if(typeof(Dmp)=="undefined"){Dmp=new Object()}Dmp.Event=function(b,a,c){this.eventType=b;this.consumed=false;this.source=a;this.data=(c?c:a);this.cancel=false;this.getSource=function(){return this.source};this.getStatus=function(){return this.eventType};this.getEventType=function(){return this.eventType};this.getData=function(){return this.data}};Dmp.EventManager=function(){this._event2PriorityArray=new Array();this._eventPassed=new Array();this.notify=function(d){if(d==null){throw new DMCException("Event object is NULL")}if(d.eventType==null){throw new DMCException("evtObj.eventType is NULL")}if(d.deadEvent){this.setDispatchedEvent(d.eventType,d)}var e=this._event2PriorityArray[d.eventType];if(e==null){return null}for(var f=0;f<e.length;f++){var b=e[f];var c=b.observer;var g=b.funcName;c[g](d);if(d.cancel==true){return}}};this.setDispatchedEvent=function(c,b){this._eventPassed[c]=b};this.addObserver=function(j,e,d,k,f){if(j==null||d==null){return}if(e==null){e="handleEvent"}if(k==null){k=20}if(j[e]==null){throw new DMCException("An observer must support "+e+" method.")}var h=this._eventPassed[d];if(h!=null&&typeof(f)!=undefined&&f!=true){j[e](h)}var b=this._event2PriorityArray[d];if(b==null){b=new Array();this._event2PriorityArray[d]=b}var g=this.indexOf(b,j);if(g<0){g=b.length;var c=new Object();c.observer=j;c.funcName=e;c.eventType=d;c.priority=k;b[g]=c}b.sort(a)};function a(c,d){if(c.priority==null){c.priority=20}if(d.priority==null){d.priority=20}if(c.priority<d.priority){return -1}else{if(c.priority>d.priority){return 1}else{return 0}}}this.indexOf=function(c,b){if(c==null||b==null){return -1}for(var d=0;d<c.length;d++){if(c[d].observer==b){return d}}return -1};this.remove=function(b,c){return this.removeObserver(b,c)};this.removeObserver=function(b,c){if(c==null){return}if(b==null){return removeAll(c)}var d=this._event2PriorityArray[c];if(d==null){return}var f=[];for(var e=0;e<d.length;e++){if(d[e].observer==b){continue}f.push(d[e])}this._event2PriorityArray[c]=f};this.removeAll=function(b){if(b==null){return}var c=this._event2PriorityArray[b];if(c==null){return}this._event2PriorityArray[b]=null}};function _gNotifyAsyncObs(_gid){try{var po=null;var eo=null;var str="po = window.PO"+_gid+"; window.PO"+_gid+" = null;";eval(str);eval("eo = window.EO"+_gid+"; window.PO"+_gid+" = null;");if(po==null){return}po._dmc_notifyEvent(eo.eventType,eo)}catch(ex){alert("_gNotifyAsyncObs: "+ex.description)}}function _dmc_notifyEvent(eventType,evtObj){if(eventType==null){eventType=evtObj.eventType}var funcName=this._dmcEventMethodNames[eventType];eval("this."+funcName+"(evtObj);")}if(typeof(Event)=="undefined"){Event=Dmp.Event}if(typeof(EventManager)=="undefined"){EventManager=Dmp.EventManager}function JSON2RecordSet(c,v,a){var w=false;if(v==null||v.length==0||(v.length==1&&v[0]=="")){v="_ridx";w=true}if(typeof(v)=="string"){v=[v]}var f=new Array();var m=[];if(c!=null){var g=null;try{g=c.Xml.Data.Row}catch(d){}if(g==null){g=new Array()}var r=null;if(c.Xml.Schema){r=c.Xml.Schema.ElementType.AttributeType}if(g&&g.length==null){g=[g]}if(r&&r.length==null){r=[r]}var n=[];if(r){for(var j=0;j<r.length;j++){var t=r[j].Datatype.type;m[r[j].name]=t;n[r[j].name]=r[j].basecolumn}}for(var j=0;j<g.length;j++){var e=g[j];var h=new Dmp.Record(v,a);if(w){h.setByName(v[0],(j+1)+"","string")}if(e._LATFIELD&&e._LONFIELD&&e.GEOMETRY==null){var l=tryParse("double",e._LATFIELD);var u=tryParse("double",e._LONFIELD);h.setByName("GEOMETRY",new DMCPoint(u,l),"geometry")}var p=0;for(property in e){if(property=="_LATFIELD"||property=="_LONFIELD"){continue}var o=n[property];if(o==null){o=property}var x=m[property];if(x==null){x="string"}var t=x=="wkt"?"geometry":x;h.setByName(o,tryParse(x,e[property]),t)}f.push(h)}}var s="QueryRecordset";if(a!=null&&a.length>0){s=a}var k=[];if(w){k.push(v[0])}for(var b in m){k.push(b)}var q=new Dmp.RecordSet(v,k);q.addRecordCollection(f);return(q)}function tryParse(b,a){if(b==null||a==null){return a}if(b=="int"){return parseInt(a)}else{if(b=="double"||b=="float"){return parseFloat(a)}else{if(b=="bool"){return(a=="1"||a=="true")}else{if(b=="wkt"){return WKT(a)}else{if(b=="date"){if(a==""){return null}a=a.replace(/00:00:00.0/,"");a=a.replace(/-/g,"/");a=new Date(a);if((a+"")=="NaN"){return null}return a}else{if(b=="string"){return a}else{return a}}}}}}}function deepCloneJSON(e){if(e==null){return e}var b=null;var c=getDataType(e);if(c=="associative array"){b=[];for(var d in e){b[d]=deepCloneJSON(e[d])}return b}else{if(c=="array"){b=[];for(var a=0;a<e.length;a++){b.push(deepCloneJSON(e[a]))}return b}else{return e}}}function getDataType(d){if(d==null){return null}var a=typeof(d);if(a.indexOf("object")<0){return a}try{for(var c in d){if(c!=null&&d[c]!=null){return"associative array"}break}}catch(b){}if(d.length>0){if(d[0]!=null){return"array"}}return a}function OrderedHashtable(){this._columnNames=[];this._columnNameIndices=[];this._fieldArray=[];this._dataTypes=[];this.setByName=function(a,c,b){if(a!=null){a=(""+a).toUpperCase()}this._fieldArray[a]=c;if(b&&this._dataTypes[a]==null){if(b=="wkt"){this._dataTypes[a]="geometry"}else{this._dataTypes[a]=b}}if(this._columnNameIndices[a]==null){this._columnNameIndices[a]=this._columnNames.length;this._columnNames.push(a)}};this.getByName=function(a){if(a!=null){a=(""+a).toUpperCase()}return this._fieldArray[a]};this.getDataTypeByName=function(a){return this._dataTypes[a]};this.clear=function(){this._fieldArray=[];this._columnNameIndices=[];this._columnNames=[]};this.getCount=function(){return this._columnNames.length};this.contains=function(a){if(a!=null){a=a.toUpperCase()}return this._columnNameIndices[a]!=null};this.remove=function(b){if(b!=null){b=(""+b).toUpperCase()}var a;if((a=this._columnNameIndices[b])==null){throw new DMCException("GridControl.remove: trying to remove an inexisting field : "+b)}delete this._fieldArray[b];delete this._columnNameIndices[b];this._columnNames.splice(a,1);for(var d=a;d<this._columnNames.length;d++){var c=this._columnNames[d];this._columnNameIndices[c]=d}};this.removeAll=function(c){var d=[];for(var b=0;b<c.length;b++){var f=c[b];if(f!=null){f=(""+f).toUpperCase()}var g;if((g=this._columnNameIndices[f])==null){d.push(f);continue}this._fieldArray[f]=null;this._columnNameIndices[f]=null;this._columnNames.splice(g,1)}for(var a=0;a<this._columnNames.length;a++){var h=this._columnNames[a];this._columnNameIndices[h]=a}if(d.length>0){var e="GridControl.removeAll: failed to remove "+d.join()+"\n\twhen removing: "+c.join();throw new DMCException(e)}};this.getByIndex=function(a){return this._fieldArray[this._columnNames[a]]};this.getNameByIndex=function(a){return this._columnNames[a]};this.getNames=function(){var a=[];var b;for(b in this._fieldArray){a.push(b)}return a}}Dmp.Record=function(a,b){this.base=OrderedHashtable;this.base();this.FIELD_DELIMITER="+*+";this._resourceName=b;this._keyArray=a;this._properties=[];this.setResourceName=function(c){this._resourceName=c};this.getKeyField=function(){return this._keyArray[0]};this.getResourceName=function(){return this._resourceName};this.getRowNumber=function(){return this.getProperty("RowNumber")};this.setKeyField=function(c){this._keyArray=[c]};this.setCompositeKeyField=function(c){this._keyArray=c};this.getCompositeKeyField=function(){return this._keyArray};this.getKey=function(){var c=this.getByName(this._keyArray[0]);for(var d=1;d<this._keyArray.length;d++){c+=this.FIELD_DELIMITER+this.getByName(this._keyArray[d])}return c};this.getCompositeKey=function(){var d=[];for(var e=0;e<this._keyArray.length;e++){var f=this._keyArray[e];var c=this.getByName(f);d[f]=c}return d};this.clone=function(){var c=new Dmp.Record(this._keyArray,this._resourceName);for(var f in this._columnNames){c._columnNames[f]=this._columnNames[f]}for(var e in this._columnNameIndices){c._columnNameIndices[e]=this._columnNameIndices[e]}for(var d in this._fieldArray){c._fieldArray[d]=this._fieldArray[d]}c._keyArray=this._keyArray;return c};this.isSameRecord=function(c){for(var f in this._columnNames){if(c._columnNames[f]!=this._columnNames[f]){return false}}for(var e in this._columnNameIndices){if(c._columnNameIndices[e]!=this._columnNameIndices[e]){return false}}for(var d in this._fieldArray){if(c._fieldArray[d]!=this._fieldArray[d]){return false}}if(c._keyArray!=this._keyArray){return false}return true};this.getProperty=function(c){return this._properties[c]};this.removeProperty=function(c){delete this._properties[c]};this.hasProperty=function(c){return this._properties[c]!=null};this.setProperty=function(d,c){this._properties[d]=c};this.getProperties=function(){return this._properties}};if(typeof(Record)=="undefined"){Record=Dmp.Record}Dmp.RecordSet=function(c,g,e){var h=this;this.className="RecordSet";this._records=new OrderedHashtable();this._keyArray=c;this.base=Dmp.EventManager;this.base();var a="Cannot add additional records to collection";var b=2000;if(typeof(e)!=undefined&&e!=null){b=e}this.setExceedMaxRecordsMessage=function(j){a=j+" Exceeded maximum allowable records: "+b};this._listOfColumnNames=g;this.getKeyFields=function(){return this._keyArray};this.clear=function(){this._records=new OrderedHashtable()};this.setCompositeKeyField=function(j){this._keyArray=j};this.getColumnNames=function(){return this._listOfColumnNames};this.newRecord=function(j){return new Dmp.Record(this._keyArray,j)};this.setRecord=function(j,o){if(h.getCount()>b){alert(a);return}var k=j.getKey();var m=this._records.contains(k);var n=null;if(m&&!o){n=this._records.getByName(k).clone()}this._records.setByName(k,j);if(!o){if(m){var l=new Dmp.Event("recordUpdated",this,j);l.oldRecord=n;l.newRecord=j;this.notify(l)}else{this.notify(new Dmp.Event("recordAdded",this,j))}}return j};this.getRecord=function(j){var k=this._records.getByName(j);if(!k){return null}else{return k}};this.removeRecord=function(k,l){var j=this._records.getByName(k);if(!j){return}this._records.remove(k);if(!l){this.notify(new Dmp.Event("recordRemoved",this,j))}return j};this.clone=function(){var j=new Dmp.RecordSet(this._keyArray,this.getColumnNames());for(var k=0;k<this._records.getCount();k++){j.setRecord(this._records.getByIndex(k).clone())}return j};this.addRecordCollection=function(l){var k=new Array();var n=new Array();var o=true;for(var p=0;p<l.length;p++){var m=this._records.contains(l[p].getKey());var j=this.setRecord(l[p],o);if(m){n.push(j)}else{if(h.getCount()>b){alert(a);break}k.push(j)}}if(k.length>0){this.notify(new Dmp.Event("recordCollectionAdded",this,k))}return n};this.toArray=function(){var j=[];for(var k=0;k<this._records.getCount();k++){j.push(this._records.getByIndex(k))}return j};this.removeRecordCollection=function(k){var l=true;var m=[];for(var n=0;n<k.length;n++){if(this.getRecord(k[n])){var j=this.removeRecord(k[n],l);m.push(j)}}this.notify(new Dmp.Event("recordCollectionRemoved",this,m));return m};this.clearRecords=function(l){var j=this.toArray();if(!l){var k=null;k=new Dmp.Event("beforeRecordsCleared",this,j);this.notify(k);if(k.cancel==true){return false}}this._records.clear();if(!l){this.notify(new Dmp.Event("recordsCleared",this,j))}return true};this.getKeys=function(){var j=[];var l;for(l in this._records._fieldArray){j.push(l)}return j};this.toRecordArray=function(){var l=[];var j=this.getByCount();for(var k=0;k<j;k++){l.push(this.getByIndex(k))}return l};this.importData=function(D,G){this.clearRecords();if(!D){return}var o=[];var n=true;try{var r=[];this._keyArray=[];var w=D.selectSingleNode("Xml/Schema");var s=w.getAttribute("keys");if(s){this._keyArray=s.split(",")}var L=D.selectNodes("Xml/Schema/ElementType/AttributeType");for(var y=0;y<L.length;y++){var K=L[y];var p=K.getAttribute("basecolumn");r[p]=K.selectSingleNode("Datatype").getAttribute("type");if(s==null&&K.getAttribute("keycolumn")=="true"){this._keyArray.push(p)}}var z=D.selectNodes("Xml/Data/Row");for(var C=0;C<z.length;C++){var x=z[C];var v=null;var m=G;if(!m){var m=x.getAttribute("__resName");if(m==null){m="_importedFromFile"}}v=new Dmp.Record(this._keyArray,m);if(this._keyArray.length>1){v.setCompositeKeyField(this._keyArray)}for(var E in r){var l=x.getAttribute(E);if(l!=null){var J=r[E];l=tryParse(J,l)}v.setByName(E,XMLAbstraction.decode(l),J)}o.push(v);this.setRecord(v,n)}var u=D.selectNodes("Xml/Properties/Properties");for(var C=0;C<u.length;C++){var H=u[C];var v=null;var B=H.getAttribute("__key");if(B==null){continue}var F=this.getRecord(B);if(F==null){continue}var q=H.attributes;for(var A=0;A<q.length;A++){var t=q[A].nodeName;if(t=="RowNumber"||t=="__key"){continue}F.setProperty(t,XMLAbstraction.decode(H.getAttribute(t)))}}}catch(I){throw new Exception("RecordSet.importData(): malformatted xmlDOM: "+D==null?null:D.xml)}this.notify(new Dmp.Event("recordCollectionAdded",this,o))};this.exportData=function(){if(this.getCount()<=0){return null}var w=gGetDomFromString("");var E=w.createElement("Xml");var s=w.createElement("Schema");var n=w.createElement("Data");var D=w.createElement("Properties");E.appendChild(s);E.appendChild(n);E.appendChild(D);var B=[];for(var t=0;t<this._keyArray.length;t++){B[this._keyArray[t]]=true}s.setAttribute("keys",this._keyArray.join(","));var p=this.getByIndex(0);var A=[];for(var u=0;u<this.getCount();u++){var p=this.getByIndex(u);for(var t=0;t<p.getCount();t++){var m=p.getNameByIndex(t);var q=p.getByIndex(t);if(A[m]){continue}else{A[m]=true}var x=w.createElement("ElementType");x.setAttribute("name","row");var F=w.createElement("AttributeType");x.appendChild(F);F.setAttribute("name",m);F.setAttribute("number",t+1);F.setAttribute("basecolumn",m);if(B[m]){F.setAttribute("keycolumn","true")}var l;if(typeof q=="number"){l="float"}else{if(q==null||typeof q=="string"){l="string"}else{if(typeof q=="boolean"){l="bool"}else{if(d(q)){l="date"}else{if(q.TYPE=="POLYGON"||q.TYPE.indexOf("LINE")>=0||q.TYPE=="POINT"){l="wkt"}else{throw new DMCException("RecordSet.exportData(): not supported value type : "+q)}}}}}var C=w.createElement("Datatype");C.setAttribute("type",l);F.appendChild(C);s.appendChild(x)}}for(var t=0;t<this.getCount();t++){var p=this.getByIndex(t);var o=w.createElement("Row");for(var u=0;u<p.getCount();u++){o.setAttribute(p.getNameByIndex(u),XMLAbstraction.encode(""+p.getByIndex(u)))}o.setAttribute("__resName",p.getResourceName());n.appendChild(o)}for(var t=0;t<this.getCount();t++){var p=this.getByIndex(t);var k=p.getProperties();var z=null;for(var y in k){if(y=="RowNumber"){continue}if(z==null){z=w.createElement("Properties")}z.setAttribute(y,XMLAbstraction.encode(k[y]))}if(z==null){continue}z.setAttribute("__key",p.getKey());D.appendChild(z)}return E};function f(k){var j=/^\s+$/;return((k==null)||(k.length==0)||j.test(k))}function d(j){var k=new Date(j);return !f(j)&&!isNaN(k)}this.getCount=function(){return this._records.getCount()};this.getByIndex=function(j){return this._records.getByIndex(j)};this.getEmptyRecordSet=function(){return new Dmp.RecordSet(this._keyArray,this._listOfColumnNames)}};if(typeof(RecordSet)=="undefined"){RecordSet=Dmp.RecordSet}if(typeof(Dmp.Utils)=="undefined"){Dmp.Utils=new Object()}Dmp.Utils.pause=function(a){var b=window.showModalDialog("../AJAX-Spring/Util/_dmcsleepWindow.html",a,"dialogLeft:2000px;dialogTop:2000px;dialogHeight:1px;dialogWidth:1px;")};if(typeof(pause)=="undefined"){pause=Dmp.Utils.pause}function gSleep(a){try{var b=new XMLHttpRequest();b.open("GET","someFakeDocument.xml",false);b.send("")}catch(c){}}function gLoadJSON(g,h,d,e,f){function c(){}var a=null;if(f){a=f}else{a=getGUID()}_gDMCObserverLounge[a]=h;var b=g;if(g.indexOf("?")>0){b+="&"}else{b+="?"}b+='obsId=_gDMCObserverLounge["'+a+'"]';b+="&obsSuccessMethod="+d;b+="&obsErrorMethod="+e;b+="&output=JSON";_gDmcLoadScript(b,c,f)}var _gDMCLOGIN_URL="http://maps.digitalmapcentral.com/production/init";function ProcessError(a){if(a.indexOf("User not found")>=0){document.location.href=_gDMCLOGIN_URL;return}alert(a)}var _gDMCObserverLounge=new Array();function _gDMCNotifyJSON(obsID){var observer=_gDMCObserverLounge[obsID];if(observer==null){observer=eval(obsID)}return observer}function _gDmcLoadScript(a,c,b){if(document.all){_gDmcLoadScriptIE(a,c,b)}else{_gDmcLoadScriptMOZILLA(a,c,b)}}function _gDmcLoadScriptMOZILLA(e,h,c){var a=document.getElementsByTagName("head").item(0);var g=document.createElement("script");g.setAttribute("language","JavaScript1.2");g.setAttribute("src",e);if(c){g.setAttribute("id",c)}var d=0;if(h){g.addEventListener("load",h,false)}else{function b(){d=100}g.addEventListener("load",b,false)}a.appendChild(g);if(!h){try{while(d<50){gSleep(200);d++}}catch(f){}}}function _gDmcLoadScriptIE(c,f,e){var a=document.getElementsByTagName("head").item(0);var d=document.createElement("script");d.setAttribute("src",c);if(e){d.setAttribute("id",e)}if(f==null){if(d.readyState!="loaded"){var b=0;d.onreadystatechange=function(){if(this.readyState=="loaded"){d.onreadystatechange=null;b=100}};while(b<50&&d.readyState!="loaded"&&d.readyState!="complete"){Dmp.Utils.pause(100);b++}}}else{if(d.readyState=="loaded"||d.readyState=="complete"){f()}else{if(d.readyState!="loaded"){d.onreadystatechange=function(){if(this.readyState=="loaded"){f();d.onreadystatechange=null}}}else{alert("Cannot load data url:"+c)}}}a.appendChild(d)}function _gDmcRemoveScriptTagById(c){var a=document.getElementsByTagName("head").item(0);var b=document.getElementById(c);if(b){a.removeChild(b);return}else{}return false}if(typeof(Dmp.Geometry)=="undefined"){Dmp.Geometry=new Object()}function DMCtoVEGeometry(g,f){if(!f){f=g}if(!f.TYPE){throw new DMCException("DMCtoVEGeometry: input is not a DMC javascript geometry")}try{var h=f.getPoints();var d=[];for(var c=0;c<h.length;c++){d.push(new VELatLong(h[c].getY(),h[c].getX()))}if(f.TYPE=="POLYGON"||f.TYPE=="BOUNDS"){return new VEShape(VEShapeType.Polygon,d)}else{if(f.TYPE=="CIRCLE"){var a=new VEShape(VEShapeType.Pushpin,d[0]);return a}else{if(f.TYPE=="LINESTRING"){return new VEShape(VEShapeType.Polyline,d)}else{if(f.TYPE=="POINT"){return new VEShape(VEShapeType.Pushpin,d)}}}}}catch(b){}throw new DMCException("DMCtoVEGeometry: input is an not a DMC javascript geometry")}function DMCPoint3D(a,b,c){this.x=a;this.y=b;this.z=c;this.dot=function(d){return this.x*d.x+this.y*d.y+this.z*d.z}}function DMCBounds(b){this.TYPE="BOUNDS";this.xMin;this.yMin;this.xMax;this.yMax;if(b&&b.length>0){this.xMin=this.xMax=b[0].x;this.yMin=this.yMax=b[0].y;for(var a=1;a<b.length;a++){if(b[a].x<this.xMin){this.xMin=b[a].x}else{if(b[a].x>this.xMax){this.xMax=b[a].x}}if(b[a].y<this.yMin){this.yMin=b[a].y}else{if(b[a].y>this.yMax){this.yMax=b[a].y}}}}this.setBounds=function(c,d,e,f){this.xMin=c;this.yMin=d;this.xMax=e;this.yMax=f};this.min=function(){return new DMCPoint(this.xMin,this.yMin)};this.getMin=this.min;this.max=function(){return new DMCPoint(this.xMax,this.yMax)};this.getMax=this.max;this.equals=function(c){return c.xMin==this.xMin&&c.xMax==this.xMax&&c.yMin==this.yMin&&c.yMax==this.yMax};this.contains=function(c){return c.x>=this.xMin&&c.x<=this.xMax&&c.y>=this.yMin&&c.y<=this.yMax};this.containsBounds=function(c){return c.xMin>=this.xMin&&c.xMax<=this.xMax&&c.yMin>=this.yMin&&c.yMax<=this.yMax};this.intersects=function(c){if((!((this.xMax<c.xMin)||(this.xMin>c.xMax)))&&(!((this.yMax<c.yMin)||(this.yMin>c.yMax)))){return true}return false};this.extend=function(c){if(c.x>this.xMax){this.xMax=c.x}else{if(c.x<this.xMin){this.xMin=c.x}}if(c.y>this.yMax){this.yMax=c.y}else{if(c.y<this.yMin){this.yMin=c.y}}};this.intersection=function(c){var d,e,f,g;var h=0;if(c.xMin>=this.xMin&&c.xMin<=this.xMax){d=c.xMin;++h}if(c.xMax>=this.xMin&&c.xMax<=this.xMax){f=c.xMax;++h}if(h<2){if(this.xMin>=c.xMin&&this.xMin<=c.xMax){d=this.xMin;++h}if(this.xMax>=c.xMin&&this.xMax<=c.xMax){f=this.xMax;++h}}if(h<2){return new DMCBounds([new DMCPoint(0,0),new DMCPoint(0,0)])}h=0;if(c.yMin>=this.yMin&&c.yMin<=this.yMax){e=c.yMin;++h}if(c.yMax>=this.yMin&&c.yMax<=this.yMax){g=c.yMax;++h}if(h<2){if(this.yMin>=c.yMin&&this.yMin<=c.yMax){e=this.yMin;++h}if(this.yMax>=c.yMin&&this.yMax<=c.yMax){g=this.yMax;++h}}if(h<2){return new DMCBounds([new DMCPoint(0,0),new DMCPoint(0,0)])}return new DMCBounds([new DMCPoint(d,e),new DMCPoint(f,g)])};this.getSouthEast=function(){return new DMCPoint(this.xMax,this.yMin)};this.getSouthWest=function(){return new DMCPoint(this.xMin,this.yMin)};this.getNorthEast=function(){return new DMCPoint(this.xMax,this.yMax)};this.getNorthWest=function(){return new DMCPoint(this.xMin,this.yMax)};this.toSpan=function(){return new DMCPoint(this.xMax-this.xMin,this.yMax-this.yMin)};this.isValidLat=function(){return this.yMin<=-90&&this.yMax>=90};this.isValidLng=function(){return this.max<=-180&&this.yMax>=180};this.isEmpty=function(){return this.xMin>=this.xMax||this.yMin>=this.yMax};this.getCenter=function(){return new DMCPoint((this.xMax+this.xMin)/2,(this.yMax+this.yMin)/2,true)};this.getPoints=function(){return[new DMCPoint(this.xMin,this.yMin),new DMCPoint(this.xMin,this.yMax),new DMCPoint(this.xMax,this.yMax),new DMCPoint(this.xMax,this.yMin),new DMCPoint(this.xMin,this.yMin)]};this.toString=function(){var c=new DMCPolygon(this.getPoints());return c.toString()}}function DMCPoint(a,b,c){this.TYPE="POINT";this.x=a;this.y=b;if(!c){this.y=Math.max(-90,this.y);this.y=Math.min(90,this.y);this.x=Math.max(-180,this.x);this.x=Math.min(180,this.x)}this.toString=function(){return"POINT("+this.x+" "+this.y+")"};this.getX=function(){return this.x};this.getY=function(){return this.y};this.setX=function(d){this.x=d};this.setY=function(d){this.y=d};this.getLat=function(){return this.y};this.getLng=function(){return this.x};this.getPoints=function(){return[this]};this.setPoints=function(d){var e=null;if(typeof(d.length)!="undefined"&&d.length>0){e=d[0]}else{e=d}if(e!=null){this.x=e.x;this.y=e.y}};this.getLatRadians=function(){return this.y*Math.PI/180};this.getLngRadians=function(){return this.x*Math.PI/180};this.equals=function(d){return this.y==d.y&&this.x==d.x};this.intersects=function(e){if(e==null){throw new DMCException("DMCPoint.intersects can not take a null parameter")}if(e.TYPE=="POINT"){return this.equals(e)}if(e.TYPE=="POLYGON"||e.TYPE=="CIRCLE"){var f=e.contains(this);return f}if(e.TYPE=="BOUNDS"){var f=e.contains(this);return f}if(e.TYPE=="LINESTRING"){var h=false;var d=Math.EPSILON;for(var g=0;g<e.getVertexCount()-1;g++){var h=pointCloseToSegment(e.getVertex(g),e.getVertex(g+1),this,d);if(h){break}}return h}throw new DMCException("Other geometry types no supported.")};this.getCentroid=function(){return new DMCPoint(this.x,this.y,c)};this.getCenter=function(){return new DMCPoint(this.x,this.y,c)};this.getHandles=function(){var d=[];var e={TYPE:"WHOLE",INDEX:0,GEOMETRY:this};d.push(e);return d};this.modifyByHandle=function(e,d){this.x=d.x;this.y=d.y};this.projectToPixels=function(d){return d.latLngToPixel(this)}}function _pointArray1DtoPointArray(a){var c=[];for(var b=0;b<a.length;b+=2){c.push(new DMCPoint(a[b],a[b+1]))}return c}function DMCPoly(a,b){this.points=a;if(!this.points){this.points=[]}this.TYPE=b;var c=this;this.getVertexCount=function(){return this.points.length};this.getVertex=function(d){return this.points[d]};this.getPoints=function(){return this.points};this.setPoints=function(d){this.points=d};this.getBounds=function(){return new DMCBounds(this.points)};this.getArea=function(){return 0};this.getLength=function(){return _getLength(this.points)};this.intersects=function(d){throw new DMCException("Intersects implemenation is not supported to DMCLineString")};this.getHandles=function(){var f=[];var d=this.points.length;for(var h=0;h<(d-1);h++){var j=this.points[h];var g=this.points[h+1];var e=new DMCPoint((j.x+g.x)/2,(j.y+g.y)/2,true);f.push({TYPE:"INSERT_VERTEX",PT_INDEX:h,INDEX:f.length-1,GEOMETRY:e})}for(var h=0;h<d;h++){var k=new DMCPoint(this.points[h].x,this.points[h].y);f.push({TYPE:"VERTEX",PT_INDEX:h,INDEX:f.length-1,GEOMETRY:k})}f.push({TYPE:"WHOLE",INDEX:f.length-1,GEOMETRY:this.getClone()});return f};this.modifyByHandle=function(h,l,f){var j=h.PT_INDEX;if(h.TYPE=="VERTEX"){var g=this.points[j];g.x=l.x;g.y=l.y;if(this.TYPE=="POLYGON"){if(j==0){var g=this.points[this.points.length-1];g.x=l.x;g.y=l.y}else{if(j==this.points.length-1){var g=this.points[0];g.x=l.x;g.y=l.y}}}}else{if(h.TYPE=="WHOLE"){var e=l.x-f.x;var k=l.y-f.y;for(var d=0;d<this.points.length;d++){this.points[d].x+=e;this.points[d].y+=k}}else{if(h.TYPE=="INSERT_VERTEX"){return c.insertVertex(h.GEOMETRY,j+1)}}}};this.insertVertex=function(f,h){var d=this.points.length;if(h<0||h>d){return false}var e=[];for(var g=0;g<d;g++){if(g==h){e.push(f)}e.push(this.points[g])}this.points=e;return true};this.projectToPixels=function(f){var d=[];for(var e=0;e<this.points.length;e++){d.push(f.latLngToPixel(this.points[e]))}return new DMCLineString(d)}}function DMCLineString(a){this.base=DMCPoly;this.base(a,"LINESTRING");this.toString=function(){var b=this.TYPE+"(";for(var c=0;c<this.points.length;c++){if(c!=0){b+=","}b+=this.points[c].x+" "+this.points[c].y}b+=")";return b};this.getCenter=function(){var b=a.length;var d;var c=0;var e=0;for(d in a){c+=a[d].getX();e+=a[d].getY()}if((a[0].getX()==a[b-1].getX())&&(a[0].getY()==a[b-1].getY())){b=b-1;c-=a[0].getX();e-=a[0].getY()}return new DMCPoint(c/b,e/b)};this.getClone=function(){var b=[];for(var c=0;c<this.points.length;c++){b.push(new DMCPoint(this.points[c].x,this.points[c].y))}return new DMCLineString(b)}}DMCLineString.prototype=new DMCPoly();function DMCPolygon(a){this.base=DMCPoly;this.base(a,"POLYGON");this.getClone=function(){var b=[];for(var c=0;c<this.points.length;c++){b.push(new DMCPoint(this.points[c].x,this.points[c].y))}return new DMCPolygon(b)};this.toString=function(){var b="POLYGON((";for(var c=0;c<this.points.length;c++){if(c!=0){b+=","}b+=this.points[c].x+" "+this.points[c].y}b+="))";return b};this.getArea=function(){var e=this.points;var b=e.length;var h=new Array();var c=new Array();var f=0;var g=Math.floor((e[0].getX()+180)/6)+1;for(var d=0;d<b;d++){LatLonToUTMXY(DegToRad(e[d].getY()),DegToRad(e[d].getX()),g,c);h[d]=new DMCPoint(c[0],c[1],true)}for(var d=0;d<b-1;d++){f+=h[d].getX()*h[d+1].getY()-h[d].getY()*h[d+1].getX()}delete h;delete c;return Math.abs(0.5*f)};this.getAreaForInput=function(c){if((typeof(c)=="undefined")||(c==null)){return 0}var d=c;var b=d.length;var e=0;for(var f=0;f<b-1;f++){e+=d[f].getX()*d[f+1].getY()-d[f].getY()*d[f+1].getX()}return Math.abs(0.5*e)};this.getCenter=function(){var c=this.getCentroid();if(c==null){return null}if(this.contains(c)){return c}var b=this.adjustCenter(this.points,c);return b};this.getAveragePosition=function(){if(this.points==null){return null}var b=this.points.length;if(b<2){return null}var c=0;var e=0;for(var d=0;d<b-1;d++){c+=this.points[d].getX();e+=this.points[d].getY()}return new DMCPoint(c/(b-1),e/(b-1),true)};this.getCentroid=function(){if(this.points==null){return null}if(this.points.length<2){return null}var c=1e-20;var k=this.getAreaForInput(this.points);if(k<c){var f=this.getAveragePosition();return f}var d=this.points.length-1;var o=this.points[0].getX();var n=this.points[0].getY();var r=this.points[0].getY();var h=this.points[0].getY();var t=this.points[0].getX();var j=this.points[0].getX();for(var b=0;b<=d;b++){if(this.points[b].getY()>r){r=this.points[b].getY()}else{if(this.points[b].getY()<h){h=this.points[b].getY()}}if(this.points[b].getX()>t){t=this.points[b].getX()}else{if(this.points[b].getX()<j){j=this.points[b].getX()}}this.points[b].setX(this.points[b].getX()-o);this.points[b].setY(this.points[b].getY()-n)}var s=0;var q=0;var e;for(var b=0;b<d;b++){e=(this.points[b].getX()*this.points[b+1].getY()-this.points[b+1].getX()*this.points[b].getY());s+=((this.points[b].getX()+this.points[b+1].getX())*e);q+=((this.points[b].getY()+this.points[b+1].getY())*e)}var p=(0.166666666666667)*(1/k);s*=p;q*=p;for(var b=0;b<=d;b++){this.points[b].setX(this.points[b].getX()+o);this.points[b].setY(this.points[b].getY()+n)}s+=o;q+=n;var g=new DMCPoint(s,q,true);if((s<j)||(s>t)||(q<h)||(q>r)){g=this.getAveragePosition()}return g};this.adjustCenter=function(v,c){if((typeof(c)=="undefined")||(c==null)){return null}if((typeof(v)=="undefined")||(v==null)){return new DMCPoint(c.getX(),c.getY(),true)}var q=1e-20;var E=v.length;if(E<4){return new DMCPoint(c.getX(),c.getY(),true)}var m=E-1;var A=-1e+20;var b=1e+20;for(var h=0;h<=m;h++){if(v[h].getY()>A){A=v[h].getY()}if(v[h].getY()<b){b=v[h].getY()}}var d=c.getX();var p=c.getY();var e=new Array();var n=new Array();var B=0;if((p>b+q)&&(p<A-q)){B=this.horizontalSegments(v,e,n,p,0)}else{return new DMCPoint(d,p,true)}var w=-1;var D=1e+20;var y=-1;for(var h=0;h<B;h++){var z=Math.abs(n[h]-d);if(z<D){D=z;y=n[h];w=h}}if(w>=0){var k=new DMCPoint(y,p,true);return k}var f=4;var r=new Array(f+f);var g=A-p;if(g<q){g=0}var C=b-p;if(C>-q){C=0}var o=g/f;var u=C/f;var s=o;var x=u;for(var h=0;h<f;h++){r[h+h]=p+x;r[h+h+1]=p+s;s+=o;x+=u}for(var h=0;h<f+f;h++){var B=0;if((r[h]>b+q)&&(r[h]<A-q)){B=this.horizontalSegments(v,e,n,r[h],0)}var w=-1;var D=1e+20;var y=-1;for(var t=0;t<B;t++){var z=Math.abs(n[t]-d);if(z<D){D=z;y=n[t];w=t}}if(w>=0){var k=new DMCPoint(y,r[h],true);return k}}return new DMCPoint(d,p,true)};this.getCenterForPlacement=function(F,I,b){if((typeof(F)=="undefined")||(F==null)){return null}if(I<0){I=0}if(b<0){b=0}var p=1e-20;var d=F.length;if(d<4){return null}var c=new DMCPolygon(F);var v=this.getAreaForInput(F);if(v<p){var C=c.getAveragePosition();return C}var B=d-1;var o=F[0].getY();var A=F[0].getY();var E=F[0].getX();var q=F[0].getX();for(var G=0;G<=B;G++){if(F[G].getY()>o){o=F[G].getY()}else{if(F[G].getY()<A){A=F[G].getY()}}if(F[G].getX()>E){E=F[G].getX()}else{if(F[G].getX()<q){q=F[G].getX()}}}var m=c.getCentroid();var r=m.getX();var L=m.getY();var w=1.5;var n=false;var s=new Array();var J=new Array();var M=0;if((L>A+b/2+p)&&(L<o-b/2-p)){M=this.horizontalSegments(F,s,J,L,b)}else{n=true}var O=false;var N=-1;var x=-1;for(var G=0;G<M;G++){if(s[G]>N){N=s[G];x=G}if(s[G]>w*I){r=J[G];n=true;break}}var y=-10000000000;var H=-10000000000;var D=L;if(x>=0){y=N;H=J[x]}var K=8;if(!n){if(N>w*I){r=J[x];O=true}else{var g=new Array(K+K);var e=o-L;if(e<p){e=0}var t=A-L;if(t>-p){t=0}var z=e/K;var u=t/K;var h=z;var P=u;for(var G=0;G<K;G++){g[G+G]=L+P;g[G+G+1]=L+h;h+=z;P+=u}for(var G=0;G<K+K;G++){var M=0;if((g[G]>A+b/2+p)&&(g[G]<o-b/2-p)){M=this.horizontalSegments(F,s,J,g[G],b)}var N=-1;var x=-1;for(var f=0;f<M;f++){if(s[f]>N){N=s[f];x=f}}if(N>w*I){r=J[x];L=g[G];O=true;break}if(N>y){y=N;H=J[x];D=g[G]}}if((!O)&&(y>I)){r=H;L=D}delete g}}else{O=true}delete s;delete J;var k=new DMCPoint(r,L,true);if((r<q)||(r>E)||(L<A)||(L>o)){k=c.getAveragePosition()}return k};this.horizontalSegments=function(n,d,l,b,c){var q=0;var t=n.length;if(t<2){return 0}var p=1e-08;var g=c;if(g<p){g=p}var k=new Array();var h=0;for(var j=0;j<t-1;j++){var f=n[j].getY();var m=n[j+1].getY();var e=false;if((Math.abs(f-b)<g)&&(Math.abs(m-b)<g)){delete k;return 0}if(f<(b+p)){if(m>b){e=true}}else{if(f>(b-p)){if(m<b){e=true}}}if(e==true){var r=n[j].getX();var s=n[j+1].getX();var o=r+((b-f)*(s-r)/(m-f));k[h]=o;h++}}if(h%2==1){alert("Odd number of intersections!!")}if(h>0){k.sort(sortNumber);q=0;for(var j=0;j<h-1;j=j+2){d[q]=k[j+1]-k[j];l[q]=(k[j+1]+k[j])/2;q++}}delete k;return q};this.intersects=function(b){if(b==null){throw new DMCException("DMCPolygon.intersects can not take a null parameter")}if(b.TYPE=="POINT"){return this.contains(b)}else{if(b.TYPE=="BOUNDS"){var c=this.getBounds();return b.intersects(c)}}throw new DMCException("Only Point in polygon is supported")};this.contains=function(h){if(h==null){throw new DMCException("DMCPolygon.intersects can not take a null parameter")}if(h.TYPE!="POINT"){throw new DMCException("DMCPolygon.intersects expects only point geometry")}var g=0;var f=0;var b=this.points.length;var e=b-1;for(f,e;f<b;e=f++){var d=h.getY();var c=h.getX();if((((this.points[f].getY()<=d)&&(d<this.points[e].getY()))||((this.points[e].getY()<=d)&&(d<this.points[f].getY())))&&(c<(this.points[e].getX()-this.points[f].getX())*(d-this.points[f].getY())/(this.points[e].getY()-this.points[f].getY())+this.points[f].getX())){g=!g}}return g};this.getVertexCount=function(){return this.points.length};this.getVertex=function(b){return this.points[b]};this.isClockWise=function(){if((this.points==null)||(this.points.length<4)){return false}var h=false;var b=this.points.length;var f=this.points[0].getY();var c=0;for(var g=1;g<b-1;g++){if(this.points[g].getY()<f){f=this.points[g].getY();c=g}}var e=this.points[(c+b-2)%(b-1)].getX();var d=this.points[(c+1)%(b-1)].getX();if(e>d){h=true}else{h=false}return h}}DMCPolygon.prototype=new DMCPoly();function DMCCircle(a,b){this.TYPE="CIRCLE";this.dmcMap=b;this.points=new Array();this.points[0]=new DMCPoint(a[0].getX(),a[0].getY(),true);this.points[1]=new DMCPoint(a[1].getX(),a[1].getY(),true);this.getVertexCount=function(){return this.points.length};this.getVertex=function(c){return this.points[c]};this.calculatePolygon=function(){if(this.points==null||this.points.length<1){return null}var r=false;if(this.points[0].getLat()<0){r=true}var q=Math.floor((this.points[0].getX()+180)/6)+1;var k=new Array();var m=null;if(this.dmcMap!=null){m=new Array();m[0]=new DMCPoint(this.points[0].getX(),this.points[0].getY(),true);m[1]=new DMCPoint(this.points[1].getX(),this.points[1].getY(),true);for(var n=0;n<2;n++){var t=new Array();LatLonToUTMXY(DegToRad(m[n].getY()),DegToRad(m[n].getX()),q,t);m[n].setX(t[0]);m[n].setY(t[1])}}else{m=this.points}var l=100;var e=(Math.PI*2)/l;var k=new Array(l+1);var g=m[1].x-m[0].x;var o=m[1].y-m[0].y;var s=Math.sqrt(g*g+o*o);var p=m[0];var j=(m[1].getY()-m[0].getY())/s;var d=(m[1].getX()-m[0].getX())/s;k[0]=new DMCPoint(s,0,true);k[l]=new DMCPoint(s,0,true);var u=0;for(var n=1;n<l;n++){u+=e;var v=s*Math.cos(u);var c=s*Math.sin(u);k[n]=new DMCPoint(v,c,true)}for(var n=0;n<=l;n++){var v=k[n].getX()*d-k[n].getY()*j;var c=k[n].getY()*d+k[n].getX()*j;k[n].setX(p.x+v);k[n].setY(p.y+c)}if(this.dmcMap!=null){for(var n=0;n<=l;n++){var h=new Array();UTMXYToLatLon(k[n].getX(),k[n].getY(),q,r,h);k[n].setX(RadToDeg(h[1]));k[n].setY(RadToDeg(h[0]))}}var f=new DMCPolygon(k);return f};this.polygon=this.calculatePolygon();this.getCenter=function(){return new DMCPoint(this.points[0].getX(),this.points[0].getY(),true)};this.intersects=function(c){if(c==null){throw new DMCException("DMCCircle.intersects can not take a null parameter")}if(c.TYPE=="POINT"){return this.contains(c)}else{if(c.TYPE=="BOUNDS"){var d=this.getBounds();return c.intersects(d)}}throw new DMCException("Only Point in circle is supported")};this.contains=function(j){if(j==null){throw new DMCException("DMCCircle.intersects can not take a null parameter")}if(j.TYPE!="POINT"){throw new DMCException("DMCPolygon.intersects expects only point geometry")}if(this.points==null||this.points.length<1){return false}var n=null;var e=j;if(this.dmcMap!=null){n=new Array();n[0]=new DMCPoint(this.points[0].getX(),this.points[0].getY(),true);n[1]=new DMCPoint(this.points[1].getX(),this.points[1].getY(),true);n[2]=new DMCPoint(j.getX(),j.getY(),true);for(var c=0;c<3;c++){var l=Math.floor((n[c].getX()+180)/6)+1;var m=new Array();LatLonToUTMXY(DegToRad(n[c].getY()),DegToRad(n[c].getX()),l,m);n[c].setX(m[0]);n[c].setY(m[1])}e=n[2]}else{n=this.points}var h=n[1].getX()-n[0].getX();var o=n[1].getY()-n[0].getY();var d=h*h+o*o;var k=e.getX()-n[0].getX();var f=e.getY()-n[0].getY();var g=k*k+f*f;if(g<=d){return true}else{return false}};this.getPoints=function(){return this.points};this.clearBoundPoly=function(){this.polygon=null};this.getBoundPoly=function(){if(this.polygon==null){this.polygon=this.calculatePolygon()}return this.polygon};this.getBounds=function(){if(this.points==null||this.points.length!=2){throw new DMCException("DMCCircle: do not get bounds of an empty circle!")}var e=false;if(this.points[0].getLat()<0){e=true}var k=Math.floor((this.points[0].getX()+180)/6)+1;var m=null;if(this.dmcMap!=null){m=new Array();m[0]=new DMCPoint(this.points[0].getX(),this.points[0].getY(),true);m[1]=new DMCPoint(this.points[1].getX(),this.points[1].getY(),true);for(var c=0;c<2;c++){var l=new Array();LatLonToUTMXY(DegToRad(m[c].getY()),DegToRad(m[c].getX()),k,l);m[c].setX(l[0]);m[c].setY(l[1])}}else{m=this.points}var h=m[1].x-m[0].x;var n=m[1].y-m[0].y;var j=Math.sqrt(h*h+n*n);var f=new Array();f[0]=new DMCPoint(m[0].x+j,m[0].y,true);f[1]=new DMCPoint(m[0].x,m[0].y+j,true);f[2]=new DMCPoint(m[0].x-j,m[0].y,true);f[3]=new DMCPoint(m[0].x,m[0].y-j,true);if(this.dmcMap!=null){for(var c=0;c<4;c++){var d=new Array();UTMXYToLatLon(f[c].getX(),f[c].getY(),k,e,d);f[c].setX(RadToDeg(d[1]));f[c].setY(RadToDeg(d[0]))}}var g=new DMCBounds(f);return g};this.getBoundsInPixel=function(){if(this.points==null||this.points.length!=2){throw new DMCException("DMCCircle: do not get bounds of an empty circle!")}var e=false;if(this.points[0].getLat()<0){e=true}var k=Math.floor((this.points[0].getX()+180)/6)+1;var m=null;if(this.dmcMap!=null){m=new Array();m[0]=new DMCPoint(this.points[0].getX(),this.points[0].getY(),true);m[1]=new DMCPoint(this.points[1].getX(),this.points[1].getY(),true);for(var c=0;c<2;c++){var l=new Array();LatLonToUTMXY(DegToRad(m[c].getY()),DegToRad(m[c].getX()),k,l);m[c].setX(l[0]);m[c].setY(l[1])}}else{m=this.points}var h=m[1].x-m[0].x;var n=m[1].y-m[0].y;var j=Math.sqrt(h*h+n*n);var f=new Array();f[0]=new DMCPoint(m[0].x+j,m[0].y,true);f[1]=new DMCPoint(m[0].x,m[0].y+j,true);f[2]=new DMCPoint(m[0].x-j,m[0].y,true);f[3]=new DMCPoint(m[0].x,m[0].y-j,true);if(this.dmcMap!=null){for(var c=0;c<4;c++){var d=new Array();UTMXYToLatLon(f[c].getX(),f[c].getY(),k,e,d);f[c].setX(RadToDeg(d[1]));f[c].setY(RadToDeg(d[0]))}this.dmcMap.latLngPointsToPixelPoints(f)}var g=new DMCBounds(f);return g};this.getArea=function(){if(this.points==null||this.points.length!=2){return 0}var l=this.points;var d=l.length;var k=new Array();var j=new Array();var e=0;var h=Math.floor((l[0].getX()+180)/6)+1;for(var c=0;c<d;c++){LatLonToUTMXY(DegToRad(l[c].getY()),DegToRad(l[c].getX()),h,j);k[c]=new DMCPoint(j[0],j[1],true)}var g=k[1].getX()-k[0].getX();var f=k[1].getY()-k[0].getY();var e=Math.PI*(g*g+f*f);delete k;delete j;return e};this.getLength=function(){if(this.points==null||this.points.length!=2){return 0}var m=this.points;var d=m.length;var l=new Array();var k=new Array();var e=0;var j=Math.floor((m[0].getX()+180)/6)+1;for(var c=0;c<d;c++){LatLonToUTMXY(DegToRad(m[c].getY()),DegToRad(m[c].getX()),j,k);l[c]=new DMCPoint(k[0],k[1],true)}var g=l[1].getX()-l[0].getX();var f=l[1].getY()-l[0].getY();var h=2*Math.PI*Math.sqrt(g*g+f*f);delete l;delete k;return h};this.getCentroid=function(){return new DMCPoint(this.points[0].getX(),this.points[0].getY())};this.toString=function(){if(this.points==null||this.points.length<2){return""}var c="CIRCLE(("+this.points[0].x+" "+this.points[0].y+","+this.points[1].x+" "+this.points[1].y+"))";return c}}function WKT(c){try{var h=new RegExp(/(?:\()([^)(]*)(?:\))/g);var a=h.exec(c);var f=null;if(a!=null&&a.length>0){f=a[0].substring(1,a[0].length-1)}h=new RegExp(/[^(]*/g);var j=h.exec(c);var g=null;if(j!=null&&j.length>0){g=j[0].replace(/ /,"")}if(f==null||f==""||g==null||g==""){return null}var b=__parseWKTPointsString(f);if(g=="POINT"){if(b.length!=2){throw null}return new DMCPoint(b[0],b[1])}else{if(g=="LINESTRING"){if(b.length<4){throw null}return new DMCLineString(_pointArray1DtoPointArray(b))}else{if(g=="POLYGON"||g=="MULTIPOLYGON"){if(b.length<4){throw null}return new DMCPolygon(_pointArray1DtoPointArray(b))}else{if(g=="CIRCLE"){if(b.length<2){throw null}return new DMCCircle(_pointArray1DtoPointArray(b))}else{return null}}}}}catch(d){return null}}function __parseWKTPointsString(d){var e=d.split(",");var a=[];for(var b=0;b<e.length;b++){var c=e[b].split(" ");c=__deleteBlankStringFromArray(c);if(c.length!=2){throw"unsupported/malformatted wkt format:"+d}a.push(parseFloat(c[0]));a.push(parseFloat(c[1]))}return a}function __deleteBlankStringFromArray(f){var e=[];for(var c=0;c<f.length;c++){var d=true;var b=f[c].split(" ");for(var a=0;a<b.length;a++){if(b[a].length!=0){d=false;break}}if(!d){e.push(_trim(f[c]))}}return e}function _lTrim(a){return a.replace(/^\s*/,"")}function _rTrim(a){return a.replace(/\s*$/,"")}function _trim(a){return _rTrim(_lTrim(a))}function _getLength(h){var f=0;var b=h.length;var d=new Array();var g=new Array();var e=Math.floor((h[0].getX()+180)/6)+1;for(var a=0;a<b;a++){LatLonToUTMXY(DegToRad(h[a].getY()),DegToRad(h[a].getX()),e,d);g[a]=new DMCPoint(d[0],d[1],true)}for(var a=0;a<b-1;a++){var c=Math.pow((g[a].getX()-g[a+1].getX()),2)+Math.pow((g[a].getY()-g[a+1].getY()),2);f=f+Math.sqrt(c)}return f}function createPolygonFromEnvelope(a,b,c,d){var e=[new DMCPoint(a,b),new DMCPoint(c,b),new DMCPoint(c,d),new DMCPoint(a,d),new DMCPoint(a,b)];var f=new DMCPolygon(e);return f}function distanceBetweenLatLongs(h,f){var g=6372795.477598;var a=b(h);var d=b(f);var c=a.dot(d);var e=Math.acos(c);return g*e;function b(p){var n=p.getLatRadians();var l=p.getLngRadians();var m=Math.sin(n);var o=Math.cos(n);var j=o*Math.cos(l);var k=o*Math.sin(l);return new DMCPoint3D(j,k,m)}}Dmp.Geometry.distance=function(d,b){var e=d.x-b.x;var c=d.y-b.y;var a=Math.sqrt(e*e+c*c);return a};if(typeof(distance)=="undefined"){distance=Dmp.Geometry.distance}function sortNumber(c,d){return(c-d)}function pointCloseToSegment(g,k,l,h){var c=k.getX()-g.getX();var f=k.getY()-g.getY();var d=Math.sqrt(c*c+f*f);var e=l.getX()-g.getX();var n=l.getY()-g.getY();var j=e*e+n*n;if(d<Math.EPSILON){if(j<h*h){return true}else{return false}}else{var m=(c*e+f*n)/d;var b=j-m*m;if((m>=-h)&&(m<=d+h)&&(b<h*h)){return true}else{return false}}}function DMCtoGoogGeometry(a,b,l,j,d,k){if(!a.TYPE){throw new DMCException("DMCtoGoogGeometry: input is not a DMC javascript geometry")}try{var h=a.getPoints();var f=[];for(var g=0;g<h.length;g++){f.push(new GLatLng(h[g].getY(),h[g].getX()))}if(a.TYPE=="POINT"){return f[0]}else{if(a.TYPE=="BOUNDS"||a.TYPE=="POLYGON"){return new GPolygon(f,b,l,j,d,k)}else{if(a.TYPE.indexOf("LINE")>=0){return new GPolyline(f,b,l,j)}}}}catch(c){}throw new DMCException("DMCtoGoogGeometry: input is an not a DMC javascript geometry ("+a.TYPE+")")}function FixForFirefox2(){var c=0;var b="Firefox/";var a=navigator.userAgent.indexOf(b);if(a!=-1){c=parseFloat(navigator.userAgent.substring(a+b.length))}if(c>=1.5){Msn.Drawing.Graphic.CreateGraphic=function(e,d){return new Msn.Drawing.SVGGraphic(e,d)}}}function SetDMPKey(a){_DMP_KEY=a}var _G_COUNTER=0;var _DMP_KEY="user";var _OUTPUT_TYPE="PNG";var _G_DMP_SERVER_NAME="http://parcelstream.com";var G_NUM_SERVERS=4;var _G_MULTIDOMAIN_SERVER_NAME=new Array();for(var i=0;i<G_NUM_SERVERS;i++){_G_MULTIDOMAIN_SERVER_NAME[i]="t"+i}var _gExpectedFilter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='";function _gOverrideAppendChildIE7(e,d,b,a){if(e.tagName!="IMG"){return this._dmcAppendChild(e,d,b,a)}if(e.src.indexOf(_G_DMP_SERVER_NAME)<0&&!containsDomainName(e.src)){return this._dmcAppendChild(e,d,b,a)}var f=e.style.filter;if(f==null||f==""){return this._dmcAppendChild(e,d,b,a)}f+="";var c="alpha(opacity=100);";if(f.indexOf(c)>=0){e.style.filter=""}return this._dmcAppendChild(e,d,b,a)}function _gOverrideAppendChildIE6(e,l,a,j){if(e.tagName=="DIV"&&e.innerHTML==""){var d=e.style.filter;if(d!=null){d+="";if(d!=""){if(d.indexOf(_gExpectedFilter+_G_DMP_SERVER_NAME)>=0||containsDomainName(d,_gExpectedFilter,_gExpectedFilter.length)){var m=d.indexOf("http://");var b=d.indexOf("',",m);var f=d.substring(m,b);var h=false;if(f!=null&&f.toLowerCase().indexOf("png")>-1){h=true}if(h){var c=", alpha(opacity=100)";var g=""+e.style.filter;var k=g.split(c);if(k.length==2){e.style.filter=k[0]+k[1]}}else{var n=document.createElement("IMG");n.src=f;n.style.left=e.style.left;n.style.top=e.style.top;n.style.width=e.style.width;n.style.height=e.style.height;n.style.border=e.style.border;n.style.zIndex=e.style.zIndex;n.style.position=e.style.position;e=n}}}}}this._dmcAppendChild(e,l,a,j)}var _b_dmc_hasInitCalled=false;function gInitializeDMPLayers(b){if(_b_dmc_hasInitCalled){return}_b_dmc_hasInitCalled=true;if(document.all){var a=document.getElementById(b.ID).firstChild;if(a==null){alert("Error in DMP API. Please contact Digital Map Products Inc. Support.");return}a._dmcAppendChild=a.appendChild;if(navigator.userAgent.indexOf("MSIE 7.0")>=0){a.appendChild=_gOverrideAppendChildIE7}else{a.appendChild=_gOverrideAppendChildIE6}}}function SetParcelLayerVisibility(c,a){if(c==null){alert("Please pass Virtual Earth map instance as a parameter to the ToggleDMPParcelLayer() function. ");return}var b=c.parcelLayer;if(b){b.setVisible(a)}}function AddDMPParcelLayer(c,b){if(c==null){alert("Please pass Virtual Earth map instance as a parameter to the AddDMPParcelLayer() function. ");return}else{if(typeof(c.parcelLayer)!="undefined"){alert("This map already has a parcel layer defined in it. ");return}}gInitializeDMPLayers(c);var a=new TiledLayer(c,["Parcels"]);a.setMinZoomLevel(16);a.setMaxZoomLevel(19);a.setFormat("image/png");if(b){a.setZIndex(b)}a.initialize();c.parcelLayer=a}function containsDomainName(c,a,d){var b,f;if(a==null){a="";d=0}else{if(d==null||d<0){d=0}}for(var e=0;e<G_NUM_SERVERS;e++){f=_G_DMP_SERVER_NAME.substr(0,7)+_G_MULTIDOMAIN_SERVER_NAME[e]+"."+_G_DMP_SERVER_NAME.substr(7);if(d<a.length){b=a.substr(0,d)+f+a.substr(d)}else{b=a+f}if(c.toLowerCase().indexOf(b.toLowerCase())!=-1){return true}}return false}function GoogleTiledLayer(n,r,e){var h="http://t%2.parcelstream.com/";if(!e){e=h+"VEParcelTileServer.aspx"}var g=n;var q=null;var v=true;var f=r;var m=17;var k=19;var u=1;var a=new GCopyrightCollection();var t=false;var o=null;var s=null;var d=[];var w="image/png";var b="Layer"+new Date().getTime()+"_"+(_G_COUNTER++);this.setFormat=function(y){w=y;if(t){if(g!=null){l();x()}}};this.getFormat=function(){return w};this.addCopyright=function(y){a.addCopyright(y)};this.getCopyrights=function(y,z){return a.getCopyrights(y,z)};this.getProperty=function(y){return d[y]};this.setProperty=function(y,z){if(y!=null&&y!=""){d[y]=z}};this.getVisible=function(){return v};this.setMinZoomLevel=function(y){m=y};this.setMaxZoomLevel=function(y){k=y};this.getMinZoomLevel=function(){return m};this.getMaxZoomLevel=function(){return k};this.setOpacity=function(y){if(y!=null&&y>=0&&y<=1){u=y}if(t){if(g!=null){l();x()}}};this.getOpacity=function(){return u};this.setStyleLayerDescriptorUrl=function(y){o=y};this.getStyleLayerDescriptorUrl=function(){return o};this.setStyleLayerDescriptorText=function(y){s=y};this.getStyleLayerDescriptorText=function(){return s};this.setVisible=function(y){try{v=y;if(v){l();x()}else{q.hide()}}catch(z){}};this.initialize=function(){if(t){return}x();t=true};function x(){var y=new GTileLayer(a,m,k);y.getTileUrl=c;y.isPng=function(){if(w=="image/png"){return true}else{return false}};y.getOpacity=function(){return u};q=new GTileLayerOverlay(y);g.addOverlay(q)}function l(){if(g!=null){g.removeOverlay(q)}}function c(A,y){if(!v||y<m||y>k){return""}var B=e.replace("%2",""+Math.floor(Math.random()*G_NUM_SERVERS));var C=B+"?tileid="+p(A.x,A.y,y);if(f!=null&&f!=""&&f.length>0){C+="&layers="+j(f.join(","))}if(o!=null){C+="&SLD="+j(o)}if(w!=null){C+="&format="+encodeURIComponent(w)}if(s!=null){C+="&SLD_BODY="+j(s)}C+="&IsEncoded=true&SRS=EPSG:4326&REQUEST=MAP";for(var z in d){var D=d[z];if(D!=null&&D!=""){if(typeof(D)!=="undefined"&&typeof(D)!=="function"){C+=("&"+z+"="+encodeURIComponent(D))}}}return C}function p(A,B,E){var y="";for(var D=E;D>0;D--){var C="0";var z=1<<(D-1);if((A&z)!=0){C++}if((B&z)!=0){C++;C++}y+=C}return y}function j(y){return encodeURIComponent(y).replace(/%/g,"._-")}}function GoogleWMSLayer(f,q,d){var j=d;if(!j){j=_G_DMP_SERVER_NAME+"/VEParcelTileServer.aspx"}var g=f;var p=null;var u=true;var e=q;var a=17;var h=19;var s=false;var o=null;var r=null;var t=[];var l="image/png";var m="Layer"+new Date().getTime()+"_"+(_G_COUNTER++);this.setFormat=function(v){l=v};this.getFormat=function(){return l};this.getProperty=function(v){return t[v]};this.setProperty=function(v,w){if(v!=null&&v!=""){t[v]=w}if(s){this.onviewchange()}};this.setStyleLayerDescriptorUrl=function(v){o=v;if(s){this.onviewchange()}};this.getStyleLayerDescriptorUrl=function(){return o};this.setStyleLayerDescriptorText=function(v){r=v;if(s){this.onviewchange()}};this.getStyleLayerDescriptorText=function(){return r};this.getVisible=function(){return u};this.setMinZoomLevel=function(v){a=v;if(s){this.onviewchange()}};this.setMaxZoomLevel=function(v){h=v;if(s){this.onviewchange()}};this.getMinZoomLevel=function(){return a};this.getMaxZoomLevel=function(){return h};this.setVisible=function(v){u=v;try{if(u){this.onviewchange()}else{p.hide()}}catch(w){}};this.onviewchange=function(B){if(p){g.removeOverlay(p)}if(!b.getVisible()){return}var D=g.getZoom();if(a>D||h<D){return}var v=g.getBounds();var A=g.getSize();var E=v.getSouthWest();var C=v.getNorthEast();var F="?bbox="+E.lng()+","+E.lat()+","+C.lng()+","+C.lat();var z="";z+=j+F;var w=encodeURIComponent;if((n>=5.5)&&(n<7)&&(document.body.filters)&&(typeof(d)=="undefined"||d==null)&&l!=null&&l.toLowerCase().indexOf("png")>-1){w=k;z+="&IsEncoded=true"}z+="&width="+A.width;z+="&height="+A.height;if(e!=null&&e!=""&&e.length>0){z+="&layers="+w(e.join(","))}if(o!=null){z+="&SLD="+w(o)}if(l!=null){z+="&format="+w(l)}if(r!=null){z+="&SLD_BODY="+w(r)}z+="&SRS=EPSG:4326&REQUEST=MAP";for(var x in t){var y=t[x];if(y!=null&&y!=""){if(typeof(y)!=="undefined"&&typeof(y)!=="function"){z+=("&"+x+"="+w(y))}}}p=new GGroundOverlay(z,v);g.addOverlay(p)};var c=navigator.appVersion.split("MSIE");var n=parseFloat(c[1]);var b=this;this.initialize=function(){if(s){return}GEvent.bind(g,"moveend",b,b.onviewchange);b.onviewchange();s=true};function k(v){return encodeURIComponent(v).replace(/%/g,"._-")}}function TiledLayer(d,c,a){var b=null;if(typeof(GMap2)!="undefined"&&d instanceof GMap2){b=new GoogleTiledLayer(d,c,a);this.addCopyright=function(e){b.addCopyright(e)};this.getCopyrights=function(e,f){return b.getCopyrights(e,f)}}else{if(typeof(VEMap)!="undefined"&&d instanceof VEMap){b=new VETiledLayer(d,c,a);this.setZIndex=function(e){b.setZIndex(e)};this.getZIndex=function(){return b.getZIndex()}}else{return null}}this.setFormat=function(e){b.setFormat(e)};this.getFormat=function(){return b.getFormat()};this.setProperty=function(e,f){b.setProperty(e,f)};this.getProperty=function(e){return b.getProperty(e)};this.setVisible=function(e){b.setVisible(e)};this.getVisible=function(){return b.getVisible()};this.setMinZoomLevel=function(e){b.setMinZoomLevel(e)};this.getMinZoomLevel=function(){return b.getMinZoomLevel()};this.setMaxZoomLevel=function(e){b.setMaxZoomLevel(e)};this.getMaxZoomLevel=function(){return b.getMaxZoomLevel()};this.setOpacity=function(e){b.setOpacity(e)};this.getOpacity=function(){return b.getOpacity()};this.setStyleLayerDescriptorUrl=function(e){b.setStyleLayerDescriptorUrl(e)};this.getStyleLayerDescriptorUrl=function(){return b.getStyleLayerDescriptorUrl()};this.setStyleLayerDescriptorText=function(e){b.setStyleLayerDescriptorText(e)};this.getStyleLayerDescriptorText=function(){return b.getStyleLayerDescriptorText()};this.initialize=function(){b.initialize()};this.draw=function(){}}function VETiledLayer(u,p,e){gInitializeDMPLayers(u);var g="http://t%2.parcelstream.com/";if(!e){e=g+"VEParcelTileServer.aspx"}var t=true;var f=p;var a=17;var h=19;var b=1;var r=false;var c=100;var n=null;var q=null;var s=[];var k="image/png";var l="Layer"+new Date().getTime()+"_"+(_G_COUNTER++);this.setFormat=function(w){k=w};this.getFormat=function(){return k};this.setZIndex=function(w){c=w};this.getZIndex=function(){return c};this.getProperty=function(w){return s[w]};this.setProperty=function(w,x){if(w!=null&&w!=""){s[w]=x}};this.getVisible=function(){return t};this.setMinZoomLevel=function(w){a=w;if(r){if(u!=null){d();v()}}};this.setMaxZoomLevel=function(w){h=w;if(r){if(u!=null){d();v()}}};this.getMinZoomLevel=function(){return a};this.getMaxZoomLevel=function(){return h};this.setOpacity=function(w){if(w!=null&&w>=0&&w<=1){b=w}if(r){if(u!=null){d();v()}}};this.getOpacity=function(){return b};this.setStyleLayerDescriptorUrl=function(w){n=w;if(r){if(u!=null){d();v()}}};this.getStyleLayerDescriptorUrl=function(){return n};this.setStyleLayerDescriptorText=function(w){q=w;if(r){if(u!=null){d();v()}}};this.getStyleLayerDescriptorText=function(){return q};this.setVisible=function(w){try{t=w;if(this.getVisible()){if(o(u.ShowTileLayer)){u.ShowTileLayer(l)}else{if(o(u.ShowLayer)){d();v()}}}else{if(o(u.HideTileLayer)){u.HideTileLayer(l)}else{if(o(u.HideLayer)){d()}}}}catch(x){}};_this=this;this.initialize=function(){if(r){return}v();r=true};function v(){var y=m();var x=new VETileSourceSpecification(l,y);x.NumServers=G_NUM_SERVERS;x.MinZoomLevel=a;x.MaxZoomLevel=h;x.Opacity=b;x.ZIndex=c;if(o(u.AddTileLayer)){if(u!=null){u.AddTileLayer(x,true)}}else{if(o(u.AddLayer)){u.AddTileSource(x);var w=new VELayerSpecification(VELayerType.VETileSource,l,l);w.ZIndex=c;w.Opacity=b;u.AddLayer(w)}}}function d(){if(u!=null){try{if(o(u.DeleteTileLayer)){u.DeleteTileLayer(l)}else{if(o(u.DeleteLayer)&&o(u.DeleteTileSource)){u.DeleteLayer(l);u.DeleteTileSource(l)}}}catch(w){}}}function o(w){return(typeof(w)!="undefined"&&w!=null)}function m(){var y=e+"?tileid=%4";if(f!=null&&f!=""&&f.length>0){y+="&layers="+j(f.join(","))}if(n!=null){y+="&SLD="+j(n)}if(k!=null){y+="&format="+encodeURIComponent(k)}if(q!=null){y+="&SLD_BODY="+j(q)}y+="&IsEncoded=true&SRS=EPSG:4326&REQUEST=MAP";for(var x in s){var w=s[x];if(w!=null&&w!=""){if(typeof(w)!=="undefined"&&typeof(w)!=="function"){y+=("&"+x+"="+encodeURIComponent(w))}}}y+="&OverrideMapStyle="+j("<OverrideMapStyle><FORCE>1</FORCE></OverrideMapStyle>");return y}function j(w){return encodeURIComponent(w).replace(/%/g,"._-")}}function VEWMSLayer(w,r,f){gInitializeDMPLayers(w);var k=f;if(!k){k=_G_DMP_SERVER_NAME+"/VEParcelTileServer.aspx"}var l=null;var v=true;var g=r;var a=17;var j=19;var b=1;var t=false;var p=null;var s=null;var u=[];var c=2;var m="image/png";var n="Layer"+new Date().getTime()+"_"+(_G_COUNTER++);this.setFormat=function(x){m=x};this.getFormat=function(){return m};this.setZIndex=function(x){c=x};this.getZIndex=function(){return c};this.getProperty=function(x){return u[x]};this.setProperty=function(x,y){if(x!=null&&x!=""){u[x]=y}};this.setStyleLayerDescriptorUrl=function(x){p=x};this.getStyleLayerDescriptorUrl=function(){return p};this.setStyleLayerDescriptorText=function(x){s=x};this.getStyleLayerDescriptorText=function(){return s};this.getVisible=function(){return v};this.setMinZoomLevel=function(x){a=x};this.setMaxZoomLevel=function(x){j=x};this.getMinZoomLevel=function(){return a};this.getMaxZoomLevel=function(){return j};this.setOpacity=function(x){if(x!=null&&x>=0&&x<=1){b=x}};this.getOpacity=function(){return b};this.setVisible=function(z){try{v=z;if(this.getVisible()){this.onviewchange(null)}else{var A=q();var x=A.firstChild;if(l!=null){x.removeChild(l);l=null}}}catch(y){}};this.onviewchange=function(L){if(!_this.getVisible()){return}var B=q();var I=B.firstChild;if(l!=null){I.removeChild(l);l=null}var C=w.GetZoomLevel();if(a>C||j<C){return}var K=w.GetWidth();var A=w.GetHeight();var P=0;var z=0;var R=P+w.GetWidth();var y=z+w.GetHeight();var G=w.PixelToLatLong(new VEPixel(P,y));var Q=w.PixelToLatLong(new VEPixel(R,z));var D=G.Longitude;var H=G.Latitude;var F=Q.Longitude;var J=Q.Latitude;var M="";M+=k;M+="?bbox="+D+","+H+","+F+","+J;var E=encodeURIComponent;if((o>=5.5)&&(o<7)&&(document.body.filters)&&(typeof(f)=="undefined"||f==null)&&m!=null&&m.toLowerCase().indexOf("png")>-1){E=h;M+="&IsEncoded=true"}M+="&width="+K;M+="&height="+A;if(g!=null&&g!=""&&g.length>0){M+="&layers="+E(g.join(","))}if(p!=null){M+="&SLD="+E(p)}if(m!=null){M+="&format="+E(m)}if(s!=null){M+="&SLD_BODY="+E(s)}M+="&SRS=EPSG:4326&REQUEST=MAP";for(var N in u){var x=u[N];if(x!=null&&x!=""){if(typeof(x)!=="undefined"&&typeof(x)!=="function"){M+=("&"+N+"="+E(x))}}}l=document.createElement("IMG");l.setAttribute("id","MDE"+n);l.id="MDE"+n;I.appendChild(l);var O=0-parseInt(I.style.top);var S=0-parseInt(I.style.left);l.style.left=S+"px";l.style.top=O+"px";l.style.position="absolute";l.style.width=K+"px";l.style.height=A+"px";l.style.opacity=b;l.style.filter="alpha(opacity="+(b*100)+")";l.style.zIndex=c;l.setAttribute("src",M);if(m!=null&&m.toLowerCase().indexOf("png")>-1){l=d(l)}};var e=navigator.appVersion.split("MSIE");var o=parseFloat(e[1]);function d(D){if((o>=5.5)&&(o<7)&&(document.body.filters)){var x=D.id;var z=(D.id)?"id='"+D.id+"' ":"";var B=(D.className)?"class='"+D.className+"' ":"";var y=(D.title)?"title='"+D.title+"' ":"title='"+D.alt+"' ";var A="display:inline-block;"+D.style.cssText;var C="<span "+z+B+y+' style="width:'+D.width+"px; height:"+D.height+"px;"+A+";filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+D.src+"', sizingMethod='scale');\"></span>";D.outerHTML=C;return document.getElementById(x)}return D}function q(){return document.getElementById(w.ID)}_this=this;this.initialize=function(){if(t){return}w.AttachEvent("onchangeview",this.onviewchange);this.onviewchange();t=true};function h(x){return encodeURIComponent(x).replace(/%/g,"._-")}}function WMSLayer(d,c,a){var b=null;if(typeof(GMap2)!="undefined"&&d instanceof GMap2){b=new GoogleWMSLayer(d,c,a)}else{if(typeof(VEMap)!="undefined"&&d instanceof VEMap){b=new VEWMSLayer(d,c,a);this.setZIndex=function(e){b.setZIndex(e)};this.getZIndex=function(){return b.getZIndex()};this.setOpacity=function(e){b.setOpacity(e)};this.getOpacity=function(){return b.getOpacity()}}else{return null}}this.setFormat=function(e){b.setFormat(e)};this.getFormat=function(){return b.getFormat()};this.setProperty=function(e,f){b.setProperty(e,f)};this.getProperty=function(e){return b.getProperty(e)};this.setVisible=function(e){b.setVisible(e)};this.getVisible=function(){return b.getVisible()};this.setMinZoomLevel=function(e){b.setMinZoomLevel(e)};this.getMinZoomLevel=function(){return b.getMinZoomLevel()};this.setMaxZoomLevel=function(e){b.setMaxZoomLevel(e)};this.getMaxZoomLevel=function(){return b.getMaxZoomLevel()};this.setStyleLayerDescriptorUrl=function(e){b.setStyleLayerDescriptorUrl(e)};this.getStyleLayerDescriptorUrl=function(){return b.getStyleLayerDescriptorUrl()};this.setStyleLayerDescriptorText=function(e){b.setStyleLayerDescriptorText(e)};this.getStyleLayerDescriptorText=function(){return b.getStyleLayerDescriptorText()};this.initialize=function(){b.initialize()};this.draw=function(){};this.onviewchange=b.onviewchange};function BingMap(S){var l=this;var Y=false;var u={container:"mapsearch-mainmap",fixedMap:false,mapView:VEMapStyle.Shaded,displayListingsOnLoad:true,displayOfficesOnLoad:true,poiEnabled:false,showParcelLines:true,fireOnChange:true,startingMidLat:0,startingMidLon:0,startingZoom:15,showBubble:true,showMinimap:false};var a=null;var R={};var L=null;var I=S.startingPolyType||"";var o=S.startingPolyValue||"";var Z=null;var E=0;var t=0;var V=0;var v=false;var T={};var X=null;var y={all:true};var G=[];var C=[];var f=false;var O=null;var k=null;var N=false;var c=[];function s(ae,ah,ai){var ag=new StringBuilder();var af;if(ai.substring(ai.length-1,1)=="y"){af=ai.substring(0,ai.length-2)+"ies"}else{af=ai+"s"}ag.append('<tr><td valign="top"><table cellspacing="0" cellpadding="0" border="0" class="txt_blk_graybg" width="100%">');ag.append('<tr><td colspan="3">Multiple '+af+" found here</td></tr>");ag.append('<tr><td align=left width="30%">');if(ah>0){ag.append('<a href="javascript:;" onclick="javascript:Search.togglePinBubble('+(ah-1)+","+ah+' )">&lt; Prev</a>')}ag.append("</td><td align=center width=40%>");ag.append("<b>"+(ah+1)+" of "+ae+"</b>");ag.append("</td><td align=right width=30%>");if(ah<ae-1){ag.append('<a href="javascript:;" onclick="javascript:Search.togglePinBubble('+(ah+1)+","+ah+')">Next &gt;</a>')}ag.append("</td></tr></table></td></tr>");return ag.toString()}function w(ax){var ap,am;var ak;var ay=30;var an=0;if(ax!=null){if(ax.gridSize){ay=ax.gridSize}an=ax.GetShapeCount()}if(an==0){return[]}if(T.Style=="o"||T.Style=="b"){ak=[];var aj=new VEClusterSpecification();aj.Shapes=[];for(ap=0;ap<an;ap++){aj.Shapes.push(ax.GetShapeByIndex(ap))}ak.push(aj)}else{var av=parseInt(Math.ceil(t/ay),10);var al=parseInt(Math.ceil(E/ay),10);ak=new Array(av*al);for(ap=0;ap<an;ap++){var ag=ax.GetShapeByIndex(ap);var ao=(ag.GetPoints())[0];var ae=a.LatLongToPixel(ao);var aw=ae.x;var aC=ae.y;if(t>=aw&&E>=aC&&aw>=0&&aC>=0){var ar=Math.floor(aw/ay);var at=Math.floor(aC/ay);var aA=ar+at*av;var af=ak[aA];if(af==null){af=new VEClusterSpecification();af.Shapes=[];ak[aA]=af}af.Shapes.push(ag)}}}var ah=[];for(ap=0,len=ak.length;ap<len;ap++){var ai=ak[ap];if(ai!=null&&ai.Shapes.length>0){var aq=ai.Shapes.length;var az=0;var au=0;for(am=0;am<aq;am++){var aB=ai.Shapes[am].GetPoints()[0];az+=aB.Latitude;au+=aB.Longitude}ai.LatLong=new VELatLong(az/aq,au/aq);ah.push(ai)}}return ah}function m(ap){for(var ae=0,ao=ap.length;ae<ao;++ae){var ar=ap[ae];var au=ar.GetClusterShape();var ah=ar.Shapes;var at=ah[0];var aj=BingMap.PinInfo[at.PinType];var an;if(aj){if(ah.length==1){an=aj.ImageOn}else{if(aj.PinType==BingMap.PinType.ListingSold){an=BingMap.PinInfo[BingMap.PinType.ListingSoldMultiple].ImageOn}else{if(aj.PinType==BingMap.PinType.ListingActive||aj.PinType==BingMap.PinType.ListingNew||aj.PinType==BingMap.PinType.ListingOpenHouse||aj.PinType==BingMap.PinType.ListingPending){an=BingMap.PinInfo[BingMap.PinType.ListingMultiple].ImageOn}else{an=aj.ImageOn}}}}else{an=at.PinType+".gif"}var ak=at.GetDescription();if(!ak||ak==""||ak=="{FROM_BIRDSEYE}"){var am=new StringBuilder();for(var af=0,al=ah.length;af<al;af++){if(af>0){am.append(",")}am.append(ah[af].PinID)}au.PinID=am.toString();au.SetDescription(ak)}else{if(ah.length>1){var aq=new StringBuilder();for(var ag=0,ai=ah.length;ag<ai;ag++){aq.append('<table width="100%" valign="top" cellspacing="1" cellpadding="1" class="txt_blk" ');if(ag>0){aq.append('style="display:none;"')}aq.append(' id="pin_'+ag+'">');aq.append(s(ai,ag,BingMap.PinInfo[ah[ag].PinType].DisplayName));aq.append("<tr><td>"+ah[ag].GetDescription()+"</td></tr>");aq.append("</table>")}au.SetDescription(aq.toString())}else{au.SetDescription(at.GetDescription())}}au.SetCustomIcon(POIImagePath+"POI/"+an);au.PinType=at.PinType}}function n(ag,ae,ai,aj){if(!R[ag]){var af=new VEShapeLayer();af.isPinLayer=ae;af.layerType=ag;if(typeof ai=="undefined"||ai==null){ai=true}if(ai){af.gridSize=aj||30;var ah=new VEClusteringOptions();ah.Callback=m;af.SetClusteringConfiguration(w,ah)}a.AddShapeLayer(af);R[ag]=af}return R[ag]}function U(ae){try{if(ae.indexOf(", USA")==-1&&ae.indexOf("mx")==-1){ae+=", USA"}if(ae!=""&&ae!="undefined"){a.Find(null,ae,VEFindType.Businesses,null,null,null,null,null,true,true,null)}}catch(af){}}function p(af){var ah;if(T.Zoom>=12){var ae="";for(var ai=5;ai<22;ai++){ah="poi-"+ai;if(y[ah]){if(ae.length>0){ae+=","}ae+=ai}else{if(af){n(ah,true).DeleteAllShapes()}}}if(ae.length===0){if(!f){$(L).trigger({type:"poichange",poiEnabled:true});f=true}}else{var ag=Utils.AppPath+"/Include/AJAX/MapSearch/GetPOI.aspx?neLat="+T.NELat+"&neLong="+T.NELon+"&swLat="+T.SWLat+"&swLong="+T.SWLon+"&types="+ae;$.ajax({mode:"abort",port:"poi",type:"GET",url:ag,cache:true,dataType:"json",success:function(an){for(var ak=0,ar=an.length;ak<ar;ak++){var ap=an[ak].PinType;var aq="poi-"+ap;l.startAddingPins(aq);for(var al=0,am=an[ak].POI.length;al<am;al++){var ao=an[ak].POI[al];l.addPin(aq,"poi-"+ap+"-"+al,ao.Latitude,ao.Longitude,ap,ao.DisplayName,ao.Html)}l.endAddingPins(aq)}if(!f){$(L).trigger({type:"poichange",poiEnabled:true});f=true}}})}}else{if(f){for(var aj=5;aj<22;aj++){ah="poi-"+aj;n(ah,true).DeleteAllShapes()}f=false;$(L).trigger({type:"poichange",poiEnabled:false})}}}function K(){if(a){try{var af=a.GetZoomLevel();var ae=a.GetMapStyle();if(af>=16&&ae!=VEMapStyle.Birdseye){if(V===0){if(typeof(a.parcelLayer)=="undefined"){AddDMPParcelLayer(a)}else{SetParcelLayerVisibility(a,true)}V=1}}else{V=0;SetParcelLayerVisibility(a,false)}if(af>=17||ae==VEMapStyle.Birdseye){$("#MSVE_navAction_ObliqueMapView").show()}else{$("#MSVE_navAction_ObliqueMapView").hide()}}catch(ag){}}}function g(){var ae;var af=a.GetBirdseyeScene();if(af!=null){var ag=af.PixelToLatLong(new VEPixel(0,0));var ah=af.PixelToLatLong(new VEPixel(af.GetWidth(),af.GetHeight()));switch(af.GetOrientation()){case VEOrientation.North:ae=new VELatLongRectangle(ag,ah,null,null);break;case VEOrientation.East:ae=new VELatLongRectangle(new VELatLong(ag.Latitude,ah.Longitude),new VELatLong(ah.Latitude,ag.Longitude),null,null);break;case VEOrientation.South:ae=new VELatLongRectangle(ah,ag,null,null);break;case VEOrientation.West:ae=new VELatLongRectangle(new VELatLong(ah.Latitude,ag.Longitude),new VELatLong(ag.Latitude,ah.Longitude),null,null);break}}else{ae=new VELatLongRectangle(new VELatLong(0,0),new VELatLong(0,0),null,null)}return ae}function J(){var ae;if(a.GetMapStyle()==VEMapStyle.Birdseye){ae=g()}else{var af=a.PixelToLatLong(new VEPixel(0,0));var ag=a.PixelToLatLong(new VEPixel(t,E));ae=new VELatLongRectangle(af,ag)}return ae}function P(ae){if(S.mapView=="o"||S.mapView=="b"){a.SetZoomLevel(19);K()}}function e(ae){if(!v&&(S.mapView=="o"||S.mapView=="b")){$(L).trigger("birdseyeavailable");v=true}}function F(ah){var af=X;X=null;if(af=="Resize"){return}var ae=a.GetMapStyle();if(ae!=T.Style){l.setView(ae);return}var ag=J();T={NELat:ag.TopLeftLatLong.Latitude,NELon:ag.BottomRightLatLong.Longitude,SWLat:ag.BottomRightLatLong.Latitude,SWLon:ag.TopLeftLatLong.Longitude,Zoom:a.GetZoomLevel(),PolyPoints:Z,PolygonType:I,Style:ae};Y=true;if(af!="SetMapView"){$(L).trigger("mapchange")}if(S.showParcelLines){K()}if(S.poiEnabled){p(true)}}function q(af){if(af!=null&&af.elementID!=null){var ae=a.GetShapeByID(af.elementID);a.ShowInfoBox(ae);return true}}function W(af){var ag=y.all&&y[af];var ae=typeof(G[af])!="undefined"?G[af]:false;if(ag&&!ae){n(af,true).Show()}else{if(!ag){n(af,true).Hide()}}G[af]=ag}function ad(ae){C[ae]=[];C[ae+"ids"]=[]}function b(ae){if(!C[ae]){C[ae]=[]}return C[ae]}function D(ah){var ag=ah.PinID;if(ag){var ai=ah.GetDescription();if(ai&&ai!="{FROM_BIRDSEYE}"){return true}if(ai=="{FROM_BIRDSEYE}"&&ag=="1_"){return false}var aj=new Date().getTime()+"_bubble";ah.SetDescription('<div id="'+aj+'" style="width:100%; text-align:center;"><span style="height:50px;"><br/><br/><img src="'+imageBase+'/search/Images/spinner.gif" border="0" /> Loading...</span></div>');var ae=Utils.AppPath+"/Include/AJAX/MapSearch/GetListingBubble.aspx?";if(ag.substring(0,1)=="3"){ae+="OfficeID="+ag.replace(/3_/g,"")}else{ae+="ListingID="+ag.replace(/1_/g,"")}if(ai=="{FROM_BIRDSEYE}"){ae+="&birdseye=true"}var af=new Querystring();if(af.contains("LayoutID")){ae+="&LayoutID="+af.get("LayoutID")+"&LayoutVersion="+af.get("LayoutVersion")}$.get(ae,null,function(ao){if(ao.indexOf("~~")>0){var al=new StringBuilder();var an=ao.split("~~");for(var am=0,ak=an.length;am<ak;am++){al.append('<table width="100%" valign="top" cellspacing="1" cellpadding="1" class="txt_blk" ');if(am>0){al.append('style="display:none;"')}al.append(' id="pin_'+am+'">');al.append(s(ak,am,BingMap.PinInfo[ah.PinType].DisplayName));al.append("<tr><td>"+an[am]+"</td></tr>");al.append("</table>")}ao=al.toString()}$("#"+aj).parent().html(ao);ah.SetDescription(ao)})}return true}function H(ae){if(S.showBubble&&ae.elementID){return !D(a.GetShapeByID(ae.elementID))}return true}function x(ae){var af=new VEShape(VEShapeType.Polygon,ae);af.SetFillColor(new VEColor(131,185,187,0.1));af.SetLineColor(new VEColor(186,0,255,1));af.SetLineWidth(2);af.HideIcon();return af}function h(ag,ae,aj){ae.DeleteAllShapes();var ai="";for(var af=0,ak=ag.length;af<ak;af++){var ah=ag[af];ai+=ah.GetPoints()+",";ae.AddShape(ag[af])}if(ai.length>0){ai=ai.substring(0,ai.length-1)}if(typeof aj=="function"){aj(ag,ai)}}function i(ai,af,ak){var ah=[];var ag=0;try{var am=ai.split(",");for(var ae=0,al=am.length;ae<al/2;ae++){ah[ae]=new VELatLong(parseFloat(am[ag]),parseFloat(am[ag+1]));ag+=2}h([x(ah)],af,ak)}catch(aj){Utils.Logger.warn("Error adding polygon from points: "+aj.message)}}function z(af,ae,ag){if(typeof af=="undefined"){return}$.ajax({type:"GET",url:Utils.AppPath+"/Include/AJAX/mapsearch/GetBoundary.aspx",data:af,dataType:"json",success:function(ap){var ao=[];try{for(var ah=0,aj=ap.length;ah<aj;ah++){var ak=[];var an=ap[ah];var ai=an.Points.length;if(ai>0){do{var al=an.Points[ai-1];ak.push(new VELatLong(parseFloat(al[1]),parseFloat(al[0])))}while(--ai)}ao.push(x(ak))}}catch(am){Utils.Logger.warn(am.message)}h(ao,ae,ag)}})}function ac(ah,ae){if(!I||I==""||I=="points"){i(o,ah,ae)}else{var ai="";var af=o;if(I=="city"){ai=defaultState;if(af.indexOf(",")>-1){var ag=af.split(",");af=ag[0].trim();ai=ag[1].trim()}}z({val:af,type:I,state:ai},ah,ae)}}function A(){var af=$("#minimap-toggle");var ae=$("#minimap-toggle img");if(af.is(".minimap-on")){a.HideMiniMap();af.css({bottom:0,left:0});af.removeClass("minimap-on");ae.attr("src","/Images/Common/Map/images/mapcontrol/minimap_show.gif");ae.attr("alt","Show Mini Map");ae.attr("title","Show Mini Map")}else{a.ShowMiniMap(0,E-150);$("#MSVE_minimap_resize").hide();af.addClass("minimap-on");af.css({bottom:127,left:129});ae.attr("src","/Images/Common/Map/images/mapcontrol/minimap_hide.gif");ae.attr("alt","Hide Mini Map");ae.attr("title","Hide Mini Map")}}this.load=function(){Y=false;S=$.extend({},u,S);y.listing=S.displayListingsOnLoad;y.office=S.displayOfficesOnLoad;y.address=true;L=document.getElementById(S.container);E=$(L).height();t=$(L).width();a=new VEMap(S.container);a.LoadMap(new VELatLong(S.startingMidLat,S.startingMidLong),S.startingZoom,S.mapView,S.fixedMap,VEMapMode.Mode2D,false);l.setView(S.mapView);a.SetMouseWheelZoomToCenter(false);a.AttachEvent("onchangemapstyle",P);a.AttachEvent("onobliqueenter",e);a.AttachEvent("onmouseover",H);a.AttachEvent("onclick",q);if(S.centerPin){l.startAddingPins("address");l.addPin("address","1",S.startingMidLat,S.startingMidLong,25,"","Center Pin");l.endAddingPins("address");$(L).pngFix()}if(S.fixedMap){$(L).css("cursor","default");if(S.showParcelLines){K()}Y=true}else{if(S.fireOnChange){a.AttachEvent("onchangeview",F)}if(S.showMinimap){$("<div style='position: absolute; bottom: 0; left: 0; z-index: 1000; cursor: pointer;' id='minimap-toggle'><img alt='Show Mini Map' title='Show Mini Map' src='/Images/Common/Map/images/mapcontrol/minimap_show.gif' border='0'/></div>").click(A).appendTo($(L))}if(o!=""){var ae=(S.startingMidLat!=S.defaultMidLat||S.startingMidLong!=S.defaultMidLong||S.startingZoom!=S.defaultZoom);l.gotoPoly(I,o,ae)}else{F()}}};this.setOptions=function(ae){if(ae){S=$.extend({},S,ae);if(S.displayListingsOnLoad){l.showPins("listing")}else{l.hidePins("listing")}if(S.displayOfficesOnLoad){l.showPins("office")}else{l.hidePins("office")}l.setView(S.mapView)}};this.isLoaded=function(){return Y};this.resize=function(af,ag){if(typeof ag=="undefined"){ag=E}if(af===0||ag===0){return}if(af!=t||ag!=E){t=af;E=ag;var ae=a.GetCenter();X="Resize";a.Resize(af,ag);a.PanToLatLong(ae);$(L).width(af);$(L).height(ag);if($("#minimap-toggle.minimap-on").length>0){a.ShowMiniMap(0,E-150);$("#MSVE_minimap_resize").hide()}}};this.dispose=function(){$.each(R,function(af,ae){ad(af);ae=null});C.length=0;if(a){a.Dispose();a=null}};this.setCenterAndZoom=function(ag,ae,af){a.SetCenterAndZoom(new VELatLong(ag,ae),af);X="SetCenter";setTimeout(function(){if(X=="SetCenter"){X=null;$(L).trigger("mapchange")}},500)};this.setView=function(ag){var ae,af;af=a.GetMapStyle();if(ag=="r"||ag=="s"){ae=VEMapStyle.Shaded}else{if(ag=="h"){ae=VEMapStyle.Hybrid}else{if(ag=="a"){ae=VEMapStyle.Aerial}else{if(ag=="b"||ag=="o"){ae=VEMapStyle.Birdseye}}}}if(ae!=af){a.SetMapStyle(ae);if(af==VEMapStyle.Birdseye){a.SetZoomLevel(17)}}if(ae==VEMapStyle.Birdseye){a.SetShapesAccuracy(VEShapeAccuracy.Pushpin)}else{a.SetShapesAccuracy(VEShapeAccuracy.None)}T.Style=ae};this.getMapState=function(){return T};this.showControls=function(){a.ShowInfoBox();a.ShowDashboard();a.ShowScalebar()};this.hideControls=function(){a.HideInfoBox();a.HideDashboard();a.HideScalebar()};this.showAllPins=function(){y.all=true;$.each(R,function(af,ae){if(ae.isPinLayer){W(af)}})};this.hideAllPins=function(){y.all=false;$.each(R,function(af,ae){if(ae.isPinLayer){W(af)}})};this.hidePins=function(ae){y[ae]=false;W(ae)};this.showPins=function(ae){y[ae]=true;W(ae)};this.hidePOI=function(af){var ae="poi-"+af;y[ae]=false;W(ae)};this.showPOI=function(af){var ae="poi-"+af;y[ae]=true;W(ae);if(n(ae,true).GetShapeCount()===0){p(false)}};this.hideAllPOI=function(){$.each(R,function(af,ae){if(ae.isPinLayer&&af.indexOf("poi-")==0){y[af]=false;W(af)}})};this.showAllPOI=function(){var ae=false;$.each(R,function(ag,af){if(af.isPinLayer&&ag.indexOf("poi-")==0){y[ag]=true;W(ag);if(af.GetShapeCount()===0){ae=true}}});if(ae){p(false)}};this.pinsAreVisible=function(af){var ae=y[af];return(typeof ae=="boolean")&&ae};this.deleteAllPins=function(ae){n(ae,true).DeleteAllShapes()};this.startAddingPins=function(ae,af){n(ae,true,af).DeleteAllShapes();ad(ae)};this.addPin=function(ak,af,ah,am,aj,an,al){var ag=new VEShape(VEShapeType.Pushpin,new VELatLong(parseFloat(ah),parseFloat(am)));if(an&&an.length>0){ag.SetTitle(an)}if(al&&al.length>0){ag.SetDescription(al)}var ai=BingMap.PinInfo[aj];var ae=typeof(ai)=="undefined"?aj+".gif":ai.ImageOn;ag.PinID=af;ag.PinType=aj;ag.SetCustomIcon(POIImagePath+"POI/"+ae);b(ak+"ids")[af]=ag;b(ak).push(ag)};this.endAddingPins=function(ag,af){var ae=b(ag);if(af){X="SetMapView";a.SetMapView(ae)}try{n(ag,true).AddShape(ae)}catch(ah){Utils.Logger.warn("Error adding "+ag+" pins to map: "+ah.message)}W(ag)};this.addAddressPin=function(ae){if(ae.indexOf(", USA")==-1&&ae.indexOf("mx")==-1){ae+=", USA"}a.Find(null,ae,null,null,1,null,true,null,null,null,function(aj,ah,af){var ai=af[0];var ag=ai.LatLong;l.startAddingPins("address");l.addPin("address","1",ag.Latitude,ag.Longitude,BingMap.PinType.Address,"",ai.Name);l.endAddingPins("address");$(L).pngFix()})};this.showListingBubble=function(af){var ae=b("listingids")[af];if(ae&&D(ae)){a.ShowInfoBox(ae)}};this.hideListingBubble=function(){a.HideInfoBox()};this.clearPolygons=function(ae){n("poly",false,false).DeleteAllShapes();Z=null;o=null;I=null;if(ae){F()}};this.gotoPoly=function(af,ae,ag){o=ae.toString();I=af;if(o.indexOf("(")>0){o=o.substring("(").trim()}ac(n("poly",false,false),function(ah,ai){Z=ai;if(!ag){X="GotoPoly";if(ah&&ah.length>0){a.SetMapView(ah)}else{U(o)}setTimeout(function(){if(X=="GotoPoly"){X=null;$(L).trigger("mapchange")}},500)}else{F()}})};function M(ag){var ae=new VEPixel(ag.mapX,ag.mapY);var af=a.PixelToLatLong(ae);af.Latitude*=10000;af.Latitude=Math.floor(af.Latitude)/10000;af.Longitude*=10000;af.Longitude=Math.floor(af.Longitude)/10000;return af}function B(ae){c.push(M(ae))}function aa(ag){var ae=0;var af=0;var ah=a.LatLongToPixel(a.GetMapView().BottomRightLatLong);if(ag.mapX<15||ag.mapX>ah.x-15){if(ag.mapX<15){ae=-2}else{ae=2}}if(ag.mapY<15||ag.mapY>ah.y-15){if(ag.mapY<15){af=-2}else{af=2}}if(ae!=0||af!=0){a.StartContinuousPan(ae,af);N=true}else{if(N){a.EndContinuousPan();N=false}}}function j(ae){if(N){a.EndContinuousPan();N=false}}function ab(af){if(c.length==0){return}var ae=n("poly",false,false);var ag=c.slice(0);ag.push(M(af));if(O){ae.DeleteShape(O)}if(ag.length<3){O=new VEShape(VEShapeType.Polyline,ag)}else{O=new VEShape(VEShapeType.Polygon,ag)}O.SetFillColor(new VEColor(153,153,153,0.4));O.SetLineColor(new VEColor(153,153,153,1));O.SetLineWidth(2);O.HideIcon();ae.AddShape(O);if(c.length==1){a.AttachEvent("onmouseout",aa);a.AttachEvent("onmouseover",j);$(L).trigger({type:"polypointchange",tipID:2})}if(c.length==3&&k==null){k=new VEShape(VEShapeType.Pushpin,c[0]);k.SetCustomIcon("<img src='/Images/Common/Map/Images/mapcontrol/bttn-drawpolygon-end2.gif' onclick='Search.endDrawing()' />");k.ShowDetailOnMouseOver=false;ae.AddShape(k);$(L).trigger({type:"polypointchange",tipID:3})}}this.startDrawing=function(){l.clearPolygons();n("listing",true,true).DeleteAllShapes();l.hideAllPins();c=[];$(L).css("cursor","crosshair");a.AttachEvent("onmouseup",B);a.AttachEvent("onmousemove",ab);a.DetachEvent("onchangeview",F);a.vemapcontrol.EnableGeoCommunity(true);$(L).trigger({type:"polypointchange",tipID:1})};this.endDrawing=function(af){a.DetachEvent("onclick",B);a.DetachEvent("onmousemove",ab);a.DetachEvent("onmouseout",aa);a.DetachEvent("onmouseover",j);if(S.fireOnChange&&!S.fixedMap){a.AttachEvent("onchangeview",F)}a.vemapcontrol.EnableGeoCommunity(false);var ae=n("poly",false,false);ae.DeleteAllShapes();if(N){a.EndContinuousPan();N=false}k=null;O=null;$(L).css("cursor","default");$(L).trigger({type:"polypointchange",tipID:0});if(!af&&c.length>=3){c.push(c[0]);i(c.toString(),ae,function(ag,ah){Z=ah;o="points";F()})}else{n("poly",false,false);F()}l.showAllPins()};this.plotComps=function(aj){var ai=aj.split(",");var ae=ai.length;var af,ah,ak;l.startAddingPins("comp",false);for(var ag=0;ag<ae;ag++){if(ai[ag]==""){continue}af=ai[ag].split(" ");ah=af[0];ak=af[1];if(ah!=""&&ak!=""&&ah!="undefined"&&ak!="undefined"){l.addPin("comp","comp_"+ag,ah,ak,"listing_"+(ag+1),"","")}}l.endAddingPins("comp",true);l.showPins("comp")};var Q;this.getDirections=function(ae){Q=ae;var af=new VERouteOptions();af.RouteCallback=r;af.ShowDisambiguation=true;af.DistanceUnit=VERouteDistanceUnit.Mile;a.GetDirections(ae,af)};function d(ai){if(!ai){return("")}if(ai>60){var af=ai%60;var ah=ai-af;ah=ah/60;if(ah>60){var ae=ah%60;var ag=ah-ae;ag=ag/60;return(ag+" hrs, "+ae+" mins, "+af+" secs")}else{return(ah+" mins, "+af+" secs")}}else{return(ai+" secs")}}function r(ah){var ao=new StringBuilder();var an=ah.RouteLegs;var am=0;var ak=$("#dd-route");ao.append('<table width="100%" border="0" cellspacing="2" cellpadding="2" class="dd_txt">');ao.append('<tr><td colspan="4" class="dd_tableHeader1">');ao.append("Total Distance: ");ao.append(ah.Distance.toFixed(1));ao.append(" miles");ao.append("<br/>Total Time: ");ao.append(d(ah.Time));ao.append("</td></tr>");for(var ae=0,al=an.length;ae<al;ae++){var aj=an[ae];var ap=null;var ag=ae+1;ao.append('<tr><td colspan="4" class="dd_tableHeader2" nowrap="nowrap"><b>From: </b>');ao.append(Q[ae]);ao.append("<br/><b>To: </b>");ao.append(Q[ae+1]);ao.append("<br/><b>Time: </b>");ao.append(d(aj.Time));ao.append("</td></tr>");$("#routeFrom").val(Q[ae]);$("#routeTo").val(Q[ae+1]);for(var af=0,ai=aj.Itinerary.Items.length;af<ai;af++){ap=aj.Itinerary.Items[af];ao.append("<tr>");if(ae==0&&af==0){ao.append('<td align="center"><img src="/images/common/map/images/DrivingDirection/pin_Start.gif"/></td>')}else{if(ae==al-1&&af==ai-1){ao.append('<td align="center"><img src="/images/common/map/images/DrivingDirection/pin_End.gif"/></td>')}else{ao.append('<td align="center"><div class="dd_number">');ao.append(am);ao.append("</div></td>")}}ao.append('<td class="hseparator">');ao.append(ap.Text);ao.append("</td>");ao.append("<td>");if(ap.Distance!=null){ao.append(ap.Distance.toFixed(1))}ao.append("</td></tr>");am++}}ao.append("</table>");ak.html(ao.toString())}}BingMap.PinType={ListingActive:1,ListingOther:2,Office:3,ListingMultiple:4,Childcare:5,Schools:6,Restaurants:7,Shopping:8,Grocery:9,Gas:10,Bank:11,Park:12,Hospital:13,Transport:14,Lodging:15,Worship:16,Police:17,Fire:18,Library:19,PostOffice:20,Cultural:21,Multiple:22,ListingOpenHouse:23,ListingSold:24,Address:25,ListingNew:26,ListingPending:27,ListingSoldMultiple:28};BingMap.PinInfo=[{},{PinType:BingMap.PinType.ListingActive,ShortName:"activelisting",DisplayName:"Listing",ImageOn:"listing_active.gif",ImageOff:"listing_active_off.gif",ImageDisabled:null},{PinType:BingMap.PinType.ListingOther,ShortName:"otherlisting",DisplayName:"Other Listing",ImageOn:"listing_other.gif",ImageOff:"listing_other_off.gif",ImageDisabled:null},{PinType:BingMap.PinType.Office,ShortName:"office",DisplayName:"Office",ImageOn:"office.gif",ImageOff:"office_off.gif",ImageDisabled:null},{PinType:BingMap.PinType.ListingMultiple,ShortName:"multiplelistings",DisplayName:"Multiple Listings",ImageOn:"listing_multiple.gif",ImageOff:"listing_multiple_off.gif",ImageDisabled:null},{PinType:BingMap.PinType.Childcare,ShortName:"childcare",DisplayName:"Child Care",ImageOn:"childcare_on.gif",ImageOff:"childcare_off.gif",ImageDisabled:"childcare_dis.gif"},{PinType:BingMap.PinType.Schools,ShortName:"schools",DisplayName:"School",ImageOn:"schools_on.gif",ImageOff:"schools_off.gif",ImageDisabled:"schools_dis.gif"},{PinType:BingMap.PinType.Restaurants,ShortName:"restaurants",DisplayName:"Restaurant",ImageOn:"restaurants_on.gif",ImageOff:"restaurants_off.gif",ImageDisabled:"restaurants_dis.gif"},{PinType:BingMap.PinType.Shopping,ShortName:"shopping",DisplayName:"Shopping",ImageOn:"shopping_on.gif",ImageOff:"shopping_off.gif",ImageDisabled:"shopping_dis.gif"},{PinType:BingMap.PinType.Grocery,ShortName:"grocery",DisplayName:"Grocery",ImageOn:"grocery_on.gif",ImageOff:"grocery_off.gif",ImageDisabled:"grocery_dis.gif"},{PinType:BingMap.PinType.Gas,ShortName:"gas",DisplayName:"Gas Station",ImageOn:"gas_on.gif",ImageOff:"gas_off.gif",ImageDisabled:"gas_dis.gif"},{PinType:BingMap.PinType.Bank,ShortName:"bank",DisplayName:"Bank",ImageOn:"bank_on.gif",ImageOff:"bank_off.gif",ImageDisabled:"bank_dis.gif"},{PinType:BingMap.PinType.Park,ShortName:"park",DisplayName:"Entertainment/Recreation",ImageOn:"park_on.gif",ImageOff:"park_off.gif",ImageDisabled:"park_dis.gif"},{PinType:BingMap.PinType.Hospital,ShortName:"hospital",DisplayName:"Hospital",ImageOn:"hospital_on.gif",ImageOff:"hospital_off.gif",ImageDisabled:"hospital_dis.gif"},{PinType:BingMap.PinType.Transport,ShortName:"transport",DisplayName:"Transportation",ImageOn:"transport_on.gif",ImageOff:"transport_off.gif",ImageDisabled:"transport_dis.gif"},{PinType:BingMap.PinType.Lodging,ShortName:"lodging",DisplayName:"Hotel",ImageOn:"lodging_on.gif",ImageOff:"lodging_off.gif",ImageDisabled:"lodging_dis.gif"},{PinType:BingMap.PinType.Worship,ShortName:"worship",DisplayName:"Worship",ImageOn:"worship_on.gif",ImageOff:"worship_off.gif",ImageDisabled:"worship_dis.gif"},{PinType:BingMap.PinType.Police,ShortName:"police",DisplayName:"Police Department",ImageOn:"police_on.gif",ImageOff:"police_off.gif",ImageDisabled:"police_dis.gif"},{PinType:BingMap.PinType.Fire,ShortName:"fire",DisplayName:"Fire Department",ImageOn:"fire_on.gif",ImageOff:"fire_off.gif",ImageDisabled:"fire_dis.gif"},{PinType:BingMap.PinType.Library,ShortName:"library",DisplayName:"Library",ImageOn:"library_on.gif",ImageOff:"library_off.gif",ImageDisabled:"library_dis.gif"},{PinType:BingMap.PinType.PostOffice,ShortName:"postoffice",DisplayName:"Post Office",ImageOn:"postoffice_on.gif",ImageOff:"postoffice_off.gif",ImageDisabled:"postoffice_dis.gif"},{PinType:BingMap.PinType.Cultural,ShortName:"cultural",DisplayName:"Cultural Center",ImageOn:"cultural_on.gif",ImageOff:"cultural_off.gif",ImageDisabled:"cultural_dis.gif"},{PinType:BingMap.PinType.Multiple,ShortName:"multiple",DisplayName:"Multiple",ImageOn:"multiple_on.gif",ImageOff:"multiple_off.gif",ImageDisabled:"multiple_dis.gif"},{PinType:BingMap.PinType.ListingOpenHouse,ShortName:"openhouselisting",DisplayName:"Open House",ImageOn:"listing_openhouse.gif",ImageOff:"listing_openhouse_off.gif",ImageDisabled:null},{PinType:BingMap.PinType.ListingSold,ShortName:"soldlisting",DisplayName:"Sold Listing",ImageOn:"listing_sold.gif",ImageOff:"listing_sold_off.gif",ImageDisabled:null},{PinType:BingMap.PinType.Address,ShortName:"address",DisplayName:"Address",ImageOn:"red-flag-only.png",ImageOff:null,ImageDisabled:null},{PinType:BingMap.PinType.ListingNew,ShortName:"newlisting",DisplayName:"New Listing",ImageOn:"listing_newlisting.gif",ImageOff:"listing_newlisting_off.gif",ImageDisabled:null},{PinType:BingMap.PinType.ListingPending,ShortName:"pendinglisting",DisplayName:"Pending Listing",ImageOn:"listing_pending.gif",ImageOff:"listing_pending_off.gif",ImageDisabled:null},{PinType:BingMap.PinType.ListingSoldMultiple,ShortName:"multiplesoldlistings",DisplayName:"Multiple Sold Listings",ImageOn:"listing_sold_multiple.gif",ImageOff:"listing_sold_multiple_off.gif",ImageDisabled:null}];(function(b){b.fn.elementready=function(d){var e=this.selector;if(!c[e]){c[e]=setInterval(function(){a(e,d)},25)}return this};var c=[];function a(e,d){b(e).each(function(){var f=b(this);if(f.attr("er")!="ready"){f.attr("er","ready");d.apply(this,[b])}c[e]=null});if(b.isReady&&c[e]!=null){clearInterval(c[e]);c[e]=null}}})(jQuery);var timeoutID=0;var searchStyleSet=false;var loginStyleSet=false;var navItems=new Array();var navNames=new Array();function rollover(b,a){b.src=a.src}function toggleImg(a,b){a.src=b}function rollover2(whichimg,overimg){eval('document.images["'+whichimg+'"].src = '+overimg+".src")}function showMyMenu(b,d){var a=document.getElementById(b);if(!a){return}var e=document.getElementById(d);if(e){if(b=="divNav1"){clearTimeout(timeoutID);if(!searchStyleSet&&document.all){searchStyleSet=true}}else{if(b=="divNav3"){if(!loginStyleSet){loginStyleSet=true;var c=document.getElementById("divNav3Login");if(orientation=="top"){c.style.top=0-e.offsetHeight-c.offsetHeight+"px"}}}}}if(orientation!="none"){if(b=="divNav3"){document.getElementById("divNav3Login").style.visibility="visible"}else{a.style.visibility="visible"}}}function hideMyMenu(b){var a=document.getElementById(b);if(!a){return}if(b=="divNav1"){timeoutID=setTimeout("document.getElementById('"+b+"').style.visibility = 'hidden'",800)}else{a.style.visibility="hidden"}if(b=="divNav3"){document.getElementById("divNav3Login").style.visibility="hidden"}}function setPosition(b,f){var a=document.getElementById(b);if(!a){return}var g=document.getElementById(f);if(g){if(document.all){var d=false;if(navItems.length==0){navItems[0]=f;navNames[0]=b}else{var e=0;for(;e<navItems.length;e++){if(navItems[e]==f){d=true;break}}if(d==false){navNames[e]=b;navItems[e]=f}}clearTimeout(timeoutID);for(e=0;e<navNames.length;e++){if(b==navNames[e]){a.style.visibility="visible";var c=document.getElementById(b.replace("divNav","subNav"));if(c){c.style.display="block"}}else{document.getElementById(navNames[e]).style.visibility="hidden"}}}else{var d=false;if(navItems.length==0){navItems[0]=f;navNames[0]=b}else{var e=0;for(;e<navItems.length;e++){if(navItems[e]==f){d=true;break}}if(d==false){navItems[e]=f;navNames[e]=b}}clearTimeout(timeoutID);for(e=0;e<navNames.length;e++){if(b==navNames[e]){a.style.visibility="visible";var c=document.getElementById(b.replace("divNav","subNav"));if(c){c.style.display="block"}}else{document.getElementById(navNames[e]).style.visibility="hidden"}}}}}function hideMenu(b){var a=document.getElementById(b);if(!a){return}timeoutID=setTimeout("document.getElementById('"+b+"').style.visibility = 'hidden'",400)};