function DSRange(low,high){this.low=low;this.high=high;}
DSRange.prototype.contains=function(n){return n>=this.low&&n<=this.high;};DSRange.prototype.limitNumber=function(number){number=Math.max(parseFloat(number),this.low);return Math.min(number,this.high);};function DSCircle(low,high){this.low=low;this.high=high;}
DSCircle.prototype.limitNumber=function(number){number=parseFloat(number);while(number>this.high){number-=this.high-this.low;}
while(number<this.low){number+=this.high-this.low;}
return number;};function DSCircleSegment(circle,low,high){this.circle=circle;this.low=low;this.high=high;}
DSCircleSegment.prototype.contains=function(point){var p=this.circle.limitNumber(point);if(this.low>this.high){return(p>=this.low&&p<=this.circle.high)||(p>=this.circle.low&&p<=this.high);}else{return p>=this.low&&p<=this.high;}};var DSLatitude=new DSRange(-90,90);var DSLongitude=new DSCircle(-180,180);function DSBoundingBox(lower,upper){this.lower=lower;this.upper=upper;this.width=new DSCircleSegment(DSLongitude,lower.lng,upper.lng);this.height=new DSRange(lower.lat,upper.lat);}
DSBoundingBox.prototype.contains=function(point){return this.width.contains(point.lng)&&this.height.contains(point.lat);};function DSCopyright(text,boxes,minzoom,maxzoom,tileset){this.text=text;this.boxes=(typeof boxes.length=='undefined'?[boxes]:boxes);this.minzoom=minzoom;this.maxzoom=maxzoom;this.tileset=tileset;}
DSCopyright.prototype.contains=function(point,zoom,tileset){var t=(!tileset||!this.tileset||(tileset==this.tileset));var z=(!this.minzoom||zoom>=this.minzoom)&&(!this.maxzoom||zoom<=this.maxzoom);var p=false;for(var i=0;i<this.boxes.length;++i){if(this.boxes[i].contains(point)){p=true;break;}}
return p&&z&&t;};function DSCopyrightSet(){this.copyrights=[];}
DSCopyrightSet.prototype.getCopyright=function(point,zoom,tileset){var t=[];if(point&&zoom){for(var i=0;i<this.copyrights.length;++i){if(this.copyrights[i].contains(point,zoom,tileset)){t.push(this.copyrights[i].text);}}}
return t.join(' - ');};DSCopyrightSet.prototype.addCopyright=function(c){this.copyrights.push(c);};function DSMapDecoratorCollection(){this.init();}
LMI.Lang.extend(DSMapDecoratorCollection,DSCollection);DSMapDecoratorCollection.prototype.getByType=function(type){var it=new DSIterator(this),ret=[],d;while((d=it.next())){if(d.type==type){ret.push(d);}}
return ret;};DSMapDecoratorCollection.prototype.getByName=function(name){var it=new DSIterator(this),d;while((d=it.next())){if(d.name==name){return d;}}
return null;};function DSMapDecorator(map,el,pos,type,name){this.init(map,el,pos,type,name);}
DSMapDecorator.prototype.init=function(map,el,pos,type,name){this.map=map;this.element=el;this.position=pos;this.type=type;this.name=name;this.updatePosition();};DSMapDecorator.prototype.getElement=function(){return this.element;};DSMapDecorator.prototype.getFirstElement=function(){for(i=0,iLen=this.element.childNodes.length;i<iLen;++i){var o=this.element.childNodes[i];if(!YAHOO.util.Dom.hasClass(o,'skip')){return o;}}};DSMapDecorator.prototype.updatePosition=function(){this.element.style.position='absolute';if(typeof this.position.left!='undefined'){this.element.style.left=parseInt(this.position.left,10)+'px';}
if(typeof this.position.right!='undefined'){this.element.style.right=parseInt(this.position.right,10)+'px';}
if(typeof this.position.top!='undefined'){this.element.style.top=parseInt(this.position.top,10)+'px';}
if(typeof this.position.bottom!='undefined'){this.element.style.bottom=parseInt(this.position.bottom,10)+'px';}
for(var i in{width:'',height:''}){if(typeof this.position[i]!='undefined'){this.element.style[i]=parseInt(this.position[i],10)+'px';}}
if(typeof this.position.zIndex!='undefined'){this.element.style.zIndex=parseInt(this.position.zIndex,10);}};DSMapDecorator.prototype.setPosition=function(pos){for(var i in pos){if(pos.hasOwnProperty(i)){this.position[i]=pos[i];}}
this.updatePosition();};DSMapDecorator.prototype.getPosition=function(){return this.position;};(function(){function InvalidLatException(msg){this.name='InvalidLatException';this.message=msg;}
LMI.Lang.extend(InvalidLatException,TypeError);function InvalidLngException(msg){this.name='InvalidLngException';this.message=msg;}
LMI.Lang.extend(InvalidLngException,TypeError);function degrees(rad){return rad*(180.0/Math.PI);}
function radians(deg){return deg*(Math.PI/180.0);}
var M=LMI.Lang.getObject('LMI.Mapping',true);M.Point=function(lat,lng){this.init(lat,lng);};M.Point.prototype={init:function(lat,lng){this.setLat(lat);this.setLng(lng);},latAsRad:function(){return radians(this.lat);},lngAsRad:function(){return radians(this.lng);},equals:function(p){return p&&this.lat===p.lat&&this.lng===p.lng;},limitLat:function(lat){return DSLatitude.limitNumber(lat);},limitLng:function(lng){return DSLongitude.limitNumber(lng);},toString:function(){return'LMI.Mapping.Point('+this.lat+','+this.lng+')';},setLat:function(lat){var latn=parseFloat(lat);if(latn!=lat||isNaN(latn)){throw new InvalidLatException('Invalid latitude: '+lat);}
this.lat=Math.round(this.limitLat(latn)*100000)/100000;},setLng:function(lng){var lngn=parseFloat(lng);if(lngn!=lng||isNaN(lngn)){throw new InvalidLngException('Invalid longitude: '+lng);}
this.lng=Math.round(this.limitLng(lngn)*100000)/100000;},setLatFromRad:function(latRad){this.setLat(degrees(latRad));},setLngFromRad:function(lngRad){this.setLng(degrees(lngRad));}};M.Point.fromRadians=function(lat,lng){return new M.Point(degrees(lat),degrees(lng));};M.Point.getPointsFromString=function(encodedPoints){var b,shift,result,delta,index=0,len=encodedPoints.length,lat=0,lng=0,points=[];try{while(index<len){shift=result=0;do{b=encodedPoints.charCodeAt(index++)-63;result|=(b&0x1f)<<shift;shift+=5;}while(b>=0x20);delta=((result&1)?~(result>>1):(result>>1));lat+=delta;shift=result=0;do{b=encodedPoints.charCodeAt(index++)-63;result|=(b&0x1f)<<shift;shift+=5;}while(b>=0x20);delta=((result&1)?~(result>>1):(result>>1));lng+=delta;points.push(new LMI.Mapping.Point(lat*1e-5,lng*1e-5));}}catch(ex)
{}
return points;};})();function DSMapObject_Iterator(coll,offset){this.coll=coll;this.pos=(offset?offset:0);}
function DSMapObject_HasNext(){if(this.coll&&(this.pos+1)<=this.coll.order.length){return true;}
this.pos=0;return false;}
function DSMapObject_Next(){return(this.coll.objects[this.coll.order[this.pos++]]);}
function DSMapObject_GetId(){return this.coll.order[this.pos-1];}
function DSMapObject_SetIteratorOffset(offset){this.pos=offset;}
function DSMapObject_GetIteratorOffset(){return this.pos;}
function DSMapObject_Add(obj){this.objects[this.currIdx]=obj;this.order.push(this.currIdx);return this.currIdx++;}
function DSMapObject_Remove(key){var i,len;if(this.objects[key]){delete this.objects[key];for(i=0,len=this.order.length;i<len;++i){if(this.order[i]==key){this.order.splice(i,1);}}
return true;}
return false;}
function DSMapObject_RemoveAll(){this.objects={};this.order=[];this.currPos=this.currIdx=0;}
function DSMapObject_GetByIndex(i){return this.objects[this.order[i]];}
function DSMapObject_GetById(id){return this.objects[id]?this.objects[id]:null;}
function DSMapObject_Size(){return this.order.length;}
function DSMapObject_GetByProperty(name,val){for(var i=0;i<this.order.length;++i){if(this.objects[this.order[i]].getProperty(name)==val){return this.objects[this.order[i]];}}
return null;}
function DSMapObject_GetIdsByProperty(name,val){var ids=[];for(var i=0;i<this.order.length;++i){if(this.objects[this.order[i]].getProperty(name)==val){ids.push(this.order[i]);}}
return ids;}
function DSMapObject_Collection(){this.objects={};this.order=[];this.currPos=this.currIdx=0;}
DSMapObject_Collection.prototype.add=DSMapObject_Add;DSMapObject_Collection.prototype.remove=DSMapObject_Remove;DSMapObject_Collection.prototype.getById=DSMapObject_GetById;DSMapObject_Collection.prototype.getByIndex=DSMapObject_GetByIndex;DSMapObject_Collection.prototype.size=DSMapObject_Size;DSMapObject_Collection.prototype.getByProperty=DSMapObject_GetByProperty;DSMapObject_Collection.prototype.getIdsByProperty=DSMapObject_GetIdsByProperty;DSMapObject_Collection.prototype.removeAll=DSMapObject_RemoveAll;DSMapObject_Iterator.prototype.next=DSMapObject_Next;DSMapObject_Iterator.prototype.getId=DSMapObject_GetId;DSMapObject_Iterator.prototype.hasNext=DSMapObject_HasNext;DSMapObject_Iterator.prototype.setOffset=DSMapObject_SetIteratorOffset;DSMapObject_Iterator.prototype.getOffset=DSMapObject_GetIteratorOffset;LMI.Mapping.EquiRectangularMapProjection=(function(){var EQUITORIAL_EARTH_RADIUS_MEAN_METERS=6.378245e6,HALF_PI=Math.PI/2.0;function adjust_lon(lon){if(lon<-Math.PI){return lon-(Math.floor(lon/Math.PI)*Math.PI);}else if(lon>Math.PI){return-(Math.PI-lon+(Math.floor(lon/Math.PI)*Math.PI));}
return lon;}
function EquiRectangularMapProjection(lon,lat){this._center_lon=lon;this._center_lat=lat;this._cos_center_lat=Math.cos(lat);this._R=EQUITORIAL_EARTH_RADIUS_MEAN_METERS;}
EquiRectangularMapProjection.prototype={setRadius:function(r){this._R=r;},getEarthRadius:function(){return EQUITORIAL_EARTH_RADIUS_MEAN_METERS;},setOrigin:function(lon,lat){this.translations=null;var xy=this.forward(lon,lat);this.translations={x:-xy.x,y:-xy.y}},forward:function(lon,lat){var xy={x:this._R*adjust_lon(lon-this._center_lon)*this._cos_center_lat,y:this._R*lat};if(this.translations){xy.x+=this.translations.x;xy.y+=this.translations.y;}
return xy;},inverse:function(x,y){if(this.translations){x-=this.translations.x;y-=this.translations.y;}
return{x:adjust_lon(this._center_lon+x/(this._R*this._cos_center_lat)),y:Math.min(y/this._R,HALF_PI)};}};EquiRectangularMapProjection.getGridCS=function(zoom,options){options=options||{};if(!('standardParallel'in options)){options.standardParallel=40;}
if(!('scales'in options)){options.scales=[1.7021276,3.4042553,6.80851064,13.61702128,27.23404256,54.46808512,108.93617024,217.87234048,435.74468096,871.48936192,1742.97872384,3485.95744768,6971.9148953,13943.82979072];}
var center=new LMI.Mapping.Point(options.standardParallel,0),origin=new LMI.Mapping.Point(90,-180),projection=new EquiRectangularMapProjection(center.lngAsRad(),center.latAsRad()),gcs=new LMI.Mapping.GridCS(projection,zoom),scale=options.scales[zoom-1];gcs.setGridWidth(((2*Math.PI*EQUITORIAL_EARTH_RADIUS_MEAN_METERS)/scale)/gcs.tileSize);projection.setRadius(gcs.radius);projection.setOrigin(origin.lngAsRad(),origin.latAsRad());return gcs;};return EquiRectangularMapProjection;})();LMI.Mapping.GridCS=(function(){function rint(n){var f=Math.floor(n);if(Math.abs(n-f)!==0.5){return Math.round(n);}
return(f%2===0?f:f+1);}
function GridCS(projection,zoom,size){this.projection=projection;this.tileSize=size||256;this.setGridWidth(rint(Math.pow(2,zoom)));}
GridCS.prototype={setGridWidth:function(w){this.gridWidth=w;this.radius=(w*this.tileSize)/(2*Math.PI);},getScale:function(){return this.projection.getEarthRadius()/this.radius;},gridX:function(x){return Math.floor(x/this.tileSize);},gridY:function(y){return Math.floor(y/this.tileSize);},grid:function(x,y){if(arguments.length===1){y=x.y;x=x.x;}
return{x:this.gridX(x),y:this.gridY(y)};},offsetX:function(x){return x%this.tileSize;},offsetY:function(y){return y%this.tileSize;},restrictGridX:function(x){if(x<0||x>=this.gridWidth){x-=Math.floor(this.gridWidth*Math.floor(x/this.gridWidth));}
return x;},offset:function(x,y){if(arguments.length==1){y=x.y;x=x.x;}
return{x:this.offsetX(x),y:this.offsetY(y)};},gridToX:function(grid){var offset=(arguments.length==2?arguments[1]:0);return(grid*this.tileSize)+offset;},gridToY:function(grid){var offset=(arguments.length==2?arguments[1]:0);return(grid*this.tileSize)+offset;},toXY:function(p){var xy=this.projection.forward(p.lngAsRad(),p.latAsRad());xy.y=-xy.y;return xy;},toLL:function(x,y){var xy=this.projection.inverse(x,-y);return LMI.Mapping.Point.fromRadians(xy.y,xy.x);},getUpperLeftPoint:function(center,width,height){var xy=this.toXY(center);return{x:xy.x-(width/2.0),y:xy.y-(height/2.0)};},getLowerRightPoint:function(center,width,height){var xy=this.toXY(center);return{x:xy.x+(width/2.0),y:xy.y+(height/2.0)};},getLowerLeftPoint:function(center,width,height){var xy=this.toXY(center);return{x:xy.x-(width/2.0),y:xy.y+(height/2.0)};},getUpperRightPoint:function(center,width,height){var xy=this.toXY(center);return{x:xy.x+(width/2.0),y:xy.y-(height/2.0)};},processBoundingBox:function(callback,ul,lr){var tile_min=this.grid(this.toXY(ul)),tile_max=this.grid(this.toXY(lr));this.processArea2(callback,tile_min.x,tile_min.y,tile_max.x,tile_max.y);},processArea:function(callback,center,width,height){var tile_min=this.grid(this.getUpperLeftPoint(center,width,height)),tile_max=this.grid(this.getLowerRightPoint(center,width,height));this.processArea2(callback,tile_min.x,tile_min.y,tile_max.x,tile_max.y);},processArea2:function(callback,min_x,min_y,max_x,max_y){var x,x_grid,y_grid,x_start=min_x,y_start=Math.max(0,min_y);while(min_x>max_x){min_x-=this.gridWidth;}
while(x_start<0){x_start+=this.gridWidth;}
for(y_grid=y_start;y_grid<=max_y;++y_grid){for(x_grid=x_start;x_grid<=max_x;++x_grid){x=this.restrictGridX(x_grid);callback.processArea(x,y_grid,x_grid-x_start,y_grid-y_start,max_x-x_start,max_y,y_start);}}}};return GridCS;})();LMI.Mapping.MercatorMapProjection=(function(){var EQUITORIAL_EARTH_RADIUS_WGS84_METERS=6.378137e6,INVERSE_FLATTEN_WGS84=298.257223563,HALF_PI=Math.PI/2.0,EPSLN=1.0e-10;function adjust_lon(lon){if(lon<-Math.PI){return lon-(Math.floor(lon/Math.PI)*Math.PI);}else if(lon>Math.PI){return-(Math.PI-lon+(Math.floor(lon/Math.PI)*Math.PI));}
return lon;}
function tsfnz(e,phi,sinphi){var e_sinphi,t=(1+sinphi)/(1-sinphi);if(e!==0){e_sinphi=e*sinphi;t*=Math.pow((1-e_sinphi)/(1+e_sinphi),e);}
return t;}
function phi2z(e,ts){var phi=HALF_PI-2.0*Math.atan(ts);if(e===0){return phi;}
var i,sinphi,e_sinphi,dphi;for(i=0;i<=15;++i){sinphi=Math.sin(phi);e_sinphi=e*sinphi;dphi=HALF_PI-2*Math.atan(ts*Math.pow((1-e_sinphi)/(1+e_sinphi),0.5*e))-phi;phi+=dphi;if(Math.abs(dphi)<=EPSLN){return phi;}}}
function MercatorMapProjection(lon,lat){this.center_lon=lon;this.center_lat=lat;this.setRadius(EQUITORIAL_EARTH_RADIUS_WGS84_METERS);}
MercatorMapProjection.prototype={setRadius:function(R,r){var temp;this.R=R;if(arguments.length===1){this.r=R;this.es=0;this.e=0;this.m1=Math.cos(this.center_lat);}else{temp=r/R;var sinPhi=Math.sin(this.center_lat);this.r=r;this.es=1.0-(temp*temp);this.e=Math.sqrt(this.es);this.m1=Math.cos(this.center_lat)/Math.sqrt(1-this.es*sinPhi*sinPhi);}},getEarthRadius:function(){return EQUITORIAL_EARTH_RADIUS_WGS84_METERS;},forward:function(lon,lat){if(Math.abs(Math.abs(lat)-HALF_PI)<=EPSLN){throw"transformation cannot be computed at the poles";}
return{x:this.falseEasting+this.R*this.m1*adjust_lon(lon-this.center_lon),y:this.falseNorthing+this.R*this.m1*0.5*Math.log(tsfnz(this.e,lat,Math.sin(lat)))};},inverse:function(x,y){x-=this.falseEasting;y-=this.falseNorthing;return{x:adjust_lon(this.center_lon+x/(this.R*this.m1)),y:phi2z(this.e,Math.exp(-y/(this.R*this.m1)))};}};MercatorMapProjection.getGridCS=function(zoom,options){var projection=new MercatorMapProjection(0,0),gcs=new LMI.Mapping.GridCS(projection,zoom),radius=gcs.radius;if('isEllipsoidal'in options&&options.isEllipsoidal){projection.setRadius(radius,radius-(radius/INVERSE_FLATTEN_WGS84));}else{projection.setRadius(radius);}
projection.falseEasting=radius*Math.PI;projection.falseNorthing=-radius*Math.PI;return gcs;};return MercatorMapProjection;})();LMI.Mapping.TileUrl=(function(){function TileUrl(options){this.init(options);}
TileUrl.defaults={baseUrl:'http://mapping-dev.corp.localmatters.com/tiles/mercator-ellipsoid/',extension:'.png',suffix:'',locale:''};TileUrl.prototype={init:function(options){this.initOptions(options);this.base=this.options.baseUrl;this.suffix=this.options.suffix;this.post=this.options.extension+'?';this.setLocale(this.options.locale);},initOptions:function(options){this.options=LMI.Lang.mergeObjects({},TileUrl.defaults);if('config'in TileUrl){LMI.Lang.mergeObjects(this.options,TileUrl.config);}
LMI.Lang.mergeObjects(this.options,options);},setMapWidth:function(w){this.mapWidth=w;},setMapHeight:function(h){this.mapHeight=h;},setManager:function(man){this.manager=man;},setLocale:function(l){this.locale=l;},getPre:function(){return this.base+(this.locale.length?this.locale+'/':'');},getPost:function(){return this.post+'w='+this.mapWidth+'&h='+this.mapHeight+this.suffix;},getUrl:function(x,y,z){return this.getPre()+z+'/'+x+'/'+y+this.getPost();}};return TileUrl;})();LMI.Mapping.TileManager=(function(){function TileManager(el,options){this.init(el,options);}
TileManager.defaults={minLevel:1,maxLevel:14,tileLevels:[1,2,3,4,5,6,7,8,9,10,11,12,13,14],totalLevels:14,invertLevels:true,projection:LMI.Mapping.MercatorMapProjection,projectionOptions:{isEllipsoidal:true},tileUrlStrategy:LMI.Mapping.TileUrl,tileUrlOptions:{},tileWidth:256,tileHeight:256};TileManager.prototype={init:function(el,options){this.tiles=[];this.parentEl=el;this.grids=[];this.initOptions(options);this.tileWidth=this.options.tileWidth;this.tileHeight=this.options.tileHeight;this.scale=1;this.minLevel=this.options.minLevel;this.maxLevel=this.options.maxLevel;this.tileLevels=this.options.tileLevels;this.zoomLevels=this.options.totalLevels;this.bufferWidth=this.tileWidth/2;this.bufferHeight=this.tileHeight/2;this.projection=this.options.projection;this.projectionOptions=this.options.projectionOptions;this.tileUrls=new this.options.tileUrlStrategy(this.options.tileUrlOptions);this.tileUrls.setManager(this);if('width'in this.options){this.setMapWidth(this.options.width);}
if('height'in this.options){this.setMapHeight(this.options.height);}
if('locale'in this.options){this.setLocale(this.options.locale);}
this.createTiles();},initOptions:function(options){this.options=LMI.Lang.mergeObjects({},TileManager.defaults);if('config'in TileManager){LMI.Lang.mergeObjects(this.options,TileManager.config);}
LMI.Lang.mergeObjects(this.options,options);},setMapWidth:function(w){this.mapWidth=w;this.tileUrls.setMapWidth(this.mapWidth);},setMapHeight:function(h){this.mapHeight=h;this.tileUrls.setMapHeight(this.mapHeight);},setLocale:function(locale){this.locale=locale;this.tileUrls.setLocale(locale);},setZoomLevel:function(z){this.setScale(1);this.zoomLevel=z;},getZoomLevel:function(z){z=z||this.zoomLevel||1;z=this.options.invertLevels?this.options.totalLevels-z+1:z;return Math.max(1,Math.min(z,this.options.totalLevels));},getScaledZoomLevel:function(z){z=z||this.zoomLevel||1;return this.options.invertLevels?this.tileLevels[this.options.totalLevels-z]:this.tileLevels[z-1];},getZoomLevelIndex:function(z){var i;z=z||this.zoomLevel||0;for(i=0;i<this.maxLevel;i++){if(z<=this.tileLevels[i]){if(this.options.invertLevels){return this.options.totalLevels-i;}else{return i;}}}
if(this.options.invertLevels){return this.minLevel;}else{return this.maxLevel;}},setCenterPoint:function(p){this.center=p;},getCenterPoint:function(){return this.center;},remove:function(){this.tileLayer.parentNode.removeChild(this.tileLayer);},add:function(map){map.tileLayer.appendChild(this.tileLayer);},createTiles:function(){var i,j,tw=this.tileWidth,th=this.tileHeight;this.rows=Math.ceil(this.mapHeight/th)+2;this.columns=Math.ceil(this.mapWidth/tw)+2;this.tileLayer=LMI.Element.create('div',null,{className:'tileLayer'});this.width=this.columns*tw;this.height=this.rows*th;var options=this.getTileOptions();for(i=0;i<this.rows;++i){for(j=0;j<this.columns;++j){this.tiles.push(new LMI.Mapping.Tile(this.tileLayer,options));}}},getTileOptions:function(){var options={width:this.tileWidth,height:this.tileHeight};if('brokenTile'in this.options){options.brokenTile=this.options.brokenTile;}
return options;},appendRow:function(){var r=this.rows++,opts=this.getTileOptions();for(var i=0;i<this.columns;++i){var t=new LMI.Mapping.Tile(this.tileLayer,opts);if(this.offsets){t.setSrc(this.tileUrls.getUrl(this.getGrid().restrictGridX(this.getGridLeft()+i),this.getGridTop()+r,this.tileLevels[this.getZoomLevel()-1]));}
this.tiles.push(t);this.positionTile(this.tiles.length-1);}},removeRow:function(){this.rows--;var c=this.tiles.length-this.columns;while(this.tiles.length>c){var i=this.tiles.length-1;this.tiles[i].removeFromDom();this.tiles.splice(i,1);}},appendColumn:function(){var c=this.columns++,opts=this.getTileOptions();for(var i=0;i<this.rows;++i){var n=(c*(1+i))+i;var t=new LMI.Mapping.Tile(this.tileLayer,opts);if(this.offsets){t.setSrc(this.tileUrls.getUrl(this.getGrid().restrictGridX(this.getGridLeft()+c),this.getGridTop()+i,this.tileLevels[this.getZoomLevel()-1]));}
this.tiles.splice(n,0,t);this.positionTile(n);}},removeColumn:function(){var c=this.columns--;for(var i=this.tiles.length-1;i>0;i-=c){this.tiles[i].removeFromDom();this.tiles.splice(i,1);}},resizeTileLayer:function(){var rows=Math.ceil(this.mapHeight/this.tileHeight)+2,cols=Math.ceil(this.mapWidth/this.tileWidth)+2;while(cols>this.columns){this.appendColumn();}
while(cols<this.columns){this.removeColumn();}
while(rows>this.rows){this.appendRow();}
while(rows<this.rows){this.removeRow();}
this.width=this.columns*this.tileWidth;this.height=this.rows*this.tileHeight;},mapResizeHandler:function(width,height){this.setMapWidth(width);this.setMapHeight(height);if(this.offsets){this.calculateCenterPoint();}
this.resizeTileLayer();},setCenterOffset:function(x,y){this.centerOffset={x:x,y:y};},getCenterOffset:function(){return{x:this.centerOffset.x*this.scale,y:this.centerOffset.y*this.scale};},getPosition:function(p){var grid,xy;if(this.offsets){grid=this.getGrid();xy=grid.toXY(p);return{x:xy.x-grid.gridToX(this.getGridLeft(),-this.offsets.x),y:xy.y-grid.gridToY(this.getGridTop(),-this.offsets.y)};}
return null;},getPointByPosition:function(x,y){var grid=this.getGrid();if(this.offsets){return grid.toLL(grid.gridToX(this.getGridLeft(),x-this.offsets.x),grid.gridToY(this.getGridTop(),y-this.offsets.y));}
return null;},wrapNorth:function(){var i,t,zoom=this.getZoomLevel();this.offsets.y-=this.tileHeight;this.setGridTop(this.getGridTop()-1);for(i=0;i<this.columns;++i){t=this.tiles.pop();this.tiles.unshift(t);t.setSrc(this.tileUrls.getUrl(this.getGrid().restrictGridX(this.getGridLeft()+((this.columns-1)-i)),this.getGridTop(),this.tileLevels[zoom-1]));}
for(i=0;i<this.columns;++i){this.positionTile(i);}},wrapSouth:function(){var i,len,t,zoom=this.getZoomLevel();this.offsets.y+=this.tileHeight;for(i=0;i<this.columns;++i){t=this.tiles.shift();this.tiles.push(t);t.setSrc(this.tileUrls.getUrl(this.getGrid().restrictGridX(this.getGridLeft()+i),this.getGridTop()+this.rows,this.tileLevels[zoom-1]));}
for(i=this.columns*(this.rows-1),len=this.tiles.length;i<len;++i){this.positionTile(i);}
this.setGridTop(this.getGridTop()+1);},wrapWest:function(){var i,t,x,zoom=this.getZoomLevel();this.offsets.x-=this.tileWidth;this.setGridLeft(this.getGridLeft()-1);for(i=1;i<=this.rows;++i){x=this.columns*i-1;t=this.tiles.splice(x,1)[0];x-=this.columns-1;this.tiles.splice(x,0,t);t.setSrc(this.tileUrls.getUrl(this.getGrid().restrictGridX(this.getGridLeft()),this.getGridTop()+i-1,this.tileLevels[zoom-1]));this.positionTile(x);}},wrapEast:function(){var i,t,x,zoom=this.getZoomLevel();this.offsets.x+=this.tileWidth;for(i=0;i<this.rows;++i){x=this.columns*i;t=this.tiles.splice(x,1)[0];x+=this.columns-1;this.tiles.splice(x,0,t);t.setSrc(this.tileUrls.getUrl(this.getGrid().restrictGridX(this.getGridLeft()+this.columns),this.getGridTop()+i,this.tileLevels[zoom-1]));this.positionTile(x);}
this.setGridLeft(this.getGridLeft()+1);},calculateCenterPoint:function(){if(this.offsets){var grid=this.getGrid();this.setCenterPoint(grid.toLL(grid.gridToX(this.getGridLeft(),-(this.mapOffsets.x+this.offsets.x)+(this.mapWidth/2)),grid.gridToY(this.getGridTop(),-(this.mapOffsets.y+this.offsets.y)+(this.mapHeight/2))));}},getZoomByBounds:function(bounds,width,height){var i,grid,nexy,swxy,max=this.tileLevels.length,ne=bounds.upper,sw=bounds.lower;width=width||this.mapWidth;height=height||this.mapHeight;for(i=1;i<max;++i){grid=this.getGrid(i);nexy=grid.toXY(ne);swxy=grid.toXY(sw);if(Math.abs(nexy.x-swxy.x)<width&&Math.abs(nexy.y-swxy.y)<height){return i}}
return max;},getBoundsAndCentroid:function(points){var xy,north,south,east,west,np,sp,ep,wp,proj=this.getGrid().projection;LMI.Lang.forEach(points,function(pt){xy=proj.forward(pt.lngAsRad(),pt.latAsRad());if(!north){north=south=xy.y;east=west=xy.x;np=sp=pt.lat;ep=wp=pt.lng;}else{if(xy.y>north){north=xy.y;np=pt.lat;}else if(xy.y<south){south=xy.y;sp=pt.lat;}
if(xy.x>east){east=xy.x;ep=pt.lng;}else if(xy.x<west){west=xy.x;wp=pt.lng;}}});xy=proj.inverse((west+east)/2,(south+north)/2);return{centroid:LMI.Mapping.Point.fromRadians(xy.y,xy.x),upper:new LMI.Mapping.Point(np,ep),lower:new LMI.Mapping.Point(sp,wp),upperGrid:{x:east,y:north},lowerGrid:{x:west,y:south}};},setMapOffsets:function(x,y){this.mapOffsets={x:x,y:y};},updateMap:function(){var l=this.offsets.x+this.mapOffsets.x,t=this.offsets.y+this.mapOffsets.y;if(l>-this.bufferWidth){this.wrapWest();}else if(l+this.width-this.mapWidth<this.bufferWidth){this.wrapEast();}
if(t>-this.bufferHeight){this.wrapNorth();}else if(t+this.height-this.mapHeight<this.bufferHeight){this.wrapSouth();}
this.calculateCenterPoint();},setOffsets:function(x,y){this.offsets={x:x,y:y};},positionTile:function(i){var t=this.tiles[i];if(this.offsets){t.setSize(this.tileWidth,this.tileHeight);t.setLeft(((i%this.columns)*t.getWidth()+this.offsets.x)+'px');t.setTop((Math.floor(i/this.columns)*t.getHeight()+this.offsets.y)+'px');}},getScale:function(){var p=this.getCenterPoint(),g=this.getGrid(),s=g.getScale();if(g.projection instanceof LMI.Mapping.MercatorMapProjection){s*=Math.cos(p.latAsRad());}
return s;},getCopyrightString:function(){return this.options.copyright;},updateTiles:function(){var i,len;for(i=0;i<this.tiles.length;++i){this.positionTile(i);}},setScale:function(scale){this.scale=scale;this.tileWidth=this.options.tileWidth*scale;this.tileHeight=this.options.tileHeight*scale;},previewZoomLevel:function(level){var lvl=Math.round(level+0.5),lvlFrac=level-lvl,grid=this.getGrid(),previewGrid=this.getGrid(lvl),followingGrid=this.getGrid(lvl+1);ratio=(previewGrid.gridWidth+((followingGrid.gridWidth-previewGrid.gridWidth)*lvlFrac))/grid.gridWidth;this.setScale(ratio);this.updateTiles();},getGrid:function(zoom){var z=this.getZoomLevel(zoom)-1;if(!this.grids[z]){this.grids[z]=this.projection.getGridCS(this.tileLevels[z],this.projectionOptions);}
return this.grids[z];},setGridLeft:function(n){this.gridLeft=n;},getGridLeft:function(){return this.gridLeft;},setGridTop:function(n){this.gridTop=n;},getGridTop:function(){return this.gridTop;},calculateGridPosition:function(){var g=this.getGrid(),p=this.getCenterPoint(),xy=g.toXY(p),tl=g.getUpperLeftPoint(p,this.mapWidth,this.mapHeight),tlTile=g.grid(tl);this.setCenterOffset(xy.x-g.gridToX(tlTile.x),xy.y-g.gridToY(tlTile.y));this.setGridLeft(tlTile.x);this.setGridTop(tlTile.y);},loadTiles:function(){var i,j,gridTop,right,bottom,left,tile=0,zoom=this.getZoomLevel(),grid=this.getGrid();this.setMapOffsets(0,0);this.setOffsets(0,0);this.calculateGridPosition();gridTop=this.getGridTop();bottom=gridTop+this.rows;left=this.getGridLeft();right=left+this.columns;for(i=gridTop;i<bottom;++i){for(j=left;j<right;++j){this.tiles[tile].setSrc(this.tileUrls.getUrl(grid.restrictGridX(j),i,this.tileLevels[zoom-1]));this.positionTile(tile++);}}}};return TileManager;})();LMI.Mapping.Map=(function(){var Y=YAHOO.util,$D=Y.Dom,_E=LMI.Element,$=_E.getOne;function prettifyScale(dist){var ret=1;while(ret*10<dist){ret*=10;}
if(ret*5<dist){ret*=5;}
if(ret*2<dist){ret*=2;}
return ret;}
function Map(container,options){this.init(container,options);}
Map.prototype={setZoomLevel:function(z,p){var tm=this.tileManager;if(z<tm.minLevel){z=tm.minLevel;}else if(z>tm.maxLevel){z=tm.maxLevel;}
if(p&&!p.equals(this.getCenterPoint())){this.tileManager.setCenterPoint(p);}
this.zoomLevel=z;this.tileManager.setZoomLevel(z);this.loadMap();this.triggerEvent('zoom',this.getEventObject(),this);},bestFit:function(factor,collection){var width,height,points=[],bounds,zoom,poi,bb,it;if(typeof factor==='number'){this.factor=factor;}else if(typeof this.factor==='number'){factor=this.factor;}else{this.factor=factor=0.9;}
collection=collection||this.objects;it=new DSMapObject_Iterator(collection);while(it.hasNext()){poi=it.next();if(!poi.isIncludedInBestFit()){continue;}
bb=poi.getBoundingBox();if(bb){points.push(bb.lower,bb.upper);}else if(poi.getPoint()){points.push(poi.getPoint());}}
if(points.length===0){if(this.getOption('defaultLat')&&this.getOption('defaultLng')&&this.getOption('emptyZoom')){this.centerAndZoom(new LMI.Mapping.Point(this.getOption('defaultLat'),this.getOption('defaultLng')),this.getOption('emptyZoom'));}}else if(points.length===1){this.centerAndZoom(points[0],this.getOption('singleZoom'));}else{width=this.width*factor;height=this.height*factor;bounds=this.tileManager.getBoundsAndCentroid(points);zoom=this.tileManager.getZoomByBounds(bounds,width,height);this.centerAndZoom(bounds.centroid,zoom);}},bestFitEventHandler:function(){this.bestFit();},centerOnPoint:function(p){if(!p.equals(this.getCenterPoint())){this.prepareEventObject();this.tileManager.setCenterPoint(new LMI.Mapping.Point(p.lat,p.lng));this.loadMap();var o=this.getEventObject();this.triggerEvent('recenter',o,this);}},centerAndZoom:function(p,z){this.prepareEventObject();this.setZoomLevel(z,p);var o=this.getEventObject();this.triggerEvent('recenter',o,this);},init:function(cont,options){var container=$(cont);if(!container){throw new Error('Map: unable to find container: "'+cont+'"');}
if(!container.id){$D.generateId(container);}
this.id=container.id;this.container=container;$D.addClass(container,'dsMap');this.initOptions(options);this.decorators=new DSMapDecoratorCollection();this.centerPoint=null;this.zoomLevel=1;this.locale=this.getOption('defaultLocale');var year=new Date().getYear();if(year<1000){year+=1900;}
this.copyrightTxt='\xa9'+year+' Local Matters, Inc.';this.copyrightSet=DSMapCopyrightSet;if(typeof(this.options.mapScales)==='undefined'){this.setOption('mapScales',['std','metric']);}
this.initContainer();this.setTileManager(new LMI.Mapping.TileManager(this.tileLayer,{width:this.width,height:this.height}));this.objects=new DSMapObject_Collection();this.messages=[];this.initEvents('zoom','recenter','resize');},initOptions:function(options){this.options=LMI.Lang.mergeObjects({},Map.Defaults);if('config'in Map){LMI.Lang.mergeObjects(this.options,Map.config);}
LMI.Lang.mergeObjects(this.options,options);},setTileManager:function(tileManager){var cp=this.getCenterPoint(),copyright;if(this.tileManager){this.tileManager.remove(this);}
this.tileManager=tileManager;if(this.tileManager){this.tileManager.add(this);this.tileManager.setMapWidth(this.width);this.tileManager.setMapHeight(this.height);if(cp){this.tileManager.setCenterPoint(cp);this.setZoomLevel(this.zoomLevel);}else{this.tileManager.setZoomLevel(this.zoomLevel);}
this.tileManager.setMapWidth(this.width);this.tileManager.setMapHeight(this.height);this.tileManager.resizeTileLayer();if(!this.parentMap){copyright=this.tileManager.getCopyrightString();if(copyright){this.setCopyright(copyright);}}}},getTileManager:function(tileManager){return this.tileManager;},setLocale:function(locale){this.locale=locale;this.tileManager.setLocale(locale);},setOption:function(key,value){this.options[key]=value;},getOption:function(key){return this.options[key]||'';},addDecorator:function(d){this.decorators.push(d);this.decoratorLayer.appendChild(d.getElement());},removeDecorator:function(d){var l=this.decorators.getLength();for(var i=0;i<l;++i){if(this.decorators.getByIndex(i)===d){this.decorators.remove(i);this.decoratorLayer.removeChild(d.getElement());return;}}},prepareEventObject:function(){this.beforeEvent={previousLeft:this.getMapLeft(true),previousTop:this.getMapTop(true),previousZoomLevel:this.zoomLevel,previousCenter:this.getCenterPoint()};},getEventObject:function(){var o=this.beforeEvent;this.beforeEvent={};o.zoomLevel=this.zoomLevel;o.center=this.getCenterPoint();o.left=this.getMapLeft(true);o.top=this.getMapTop(true);return o;},setCopyright:function(copyrightStr){this.copyright.getElement().firstChild.nodeValue=this.copyrightTxt=copyrightStr;},getGridLeft:function(){alert('XXX: in getGridLeft -- should fix that');return null;},getGridTop:function(){alert('XXX: in getGridTop -- should fix that');return null;},positionMap:function(){var xy=this.tileManager.getCenterOffset();this.mapLayer.style.left=Math.round((this.width/2)-xy.x)+'px';this.mapLayer.style.top=Math.round((this.height/2)-xy.y)+'px';},updateScale:function(){if(!this.getOption('enableScales')){return;}
var scaleWidth=100,scale=this.tileManager.getScale(),dist=scale*scaleWidth,metricUnit='km',metricScale=dist/1000,stdUnit='mi',stdScale=dist/1609.344,pretty;if(stdScale<1){stdScale=dist*3.2808399;stdUnit='ft';}
if(metricScale<1){metricScale=dist;metricUnit='m';}
if(this.stdScale){pretty=prettifyScale(stdScale);this.stdScale.style.width=Math.round(scaleWidth*pretty/stdScale)+'px';this.stdScaleText.innerHTML=pretty+' '+stdUnit;}
if(this.metricScale){pretty=prettifyScale(metricScale);this.metricScale.style.width=Math.round(scaleWidth*pretty/metricScale)+'px';this.metricScaleText.innerHTML=pretty+' '+metricUnit;}},loadMap:function(){this.tileManager.loadTiles();this.positionMap();this.updateObjects();this.updateScale();},updateObjects:function(){for(var it=new DSMapObject_Iterator(this.objects);it.hasNext();){this.positionObject(it.next());}},getGridCoordinates:function(p){return this.tileManager.getGrid().toXY(p);},getPointByXY:function(x,y){return this.tileManager.getPointByPosition(x-this.getMapLeft(true),y-this.getMapTop(true));},getCenterPoint:function(){return this.tileManager?this.tileManager.getCenterPoint():null;},getURPoint:function(){return this.getPointByXY(this.width,0);},getLLPoint:function(){return this.getPointByXY(0,this.height);},getULPoint:function(){return this.getPointByXY(0,0);},getLRPoint:function(){return this.getPointByXY(this.width,this.height);},positionObject:function(obj,point){var xy;if(point){obj.setPoint(point);}
point=obj.getPoint();if(point){xy=this.tileManager.getPosition(obj.point);if(xy){obj.element.style.left=Math.round(xy.x-obj.xOffset)+'px';obj.element.style.top=Math.round(xy.y-obj.yOffset)+'px';}}
obj.update(this);},addObject:function(obj){var id=this.objects.add(obj);obj.element.style.position='absolute';obj.z=5+obj.zOffset;obj.element.style.zIndex=obj.z;this.positionObject(obj);this.mapLayer.appendChild(obj.element);obj.add(this);return id;},batchAddObjects:function(objects){var i,len;this.viewport.removeChild(this.mapLayer);for(i=0,len=objects.length;i<len;++i){this.addObject(objects[i]);}
this.viewport.appendChild(this.mapLayer);},removeObject:function(o){var id=-1;if(typeof o==='object'){for(var it=new DSMapObject_Iterator(this.objects);it.hasNext();){var i=it.next();if(i===o){id=it.getId();break;}}}else{id=o;}
var obj=this.objects.getById(id);if(obj){obj.remove(this);this.mapLayer.removeChild(obj.element);this.objects.remove(id);}},batchRemoveObjects:function(objects){var i,len;this.viewport.removeChild(this.mapLayer);for(i=0,len=objects.length;i<len;++i){this.removeObject(objects[i]);}
this.viewport.appendChild(this.mapLayer);},removeAll:function(){var o;this.viewport.removeChild(this.mapLayer);for(var it=new DSMapObject_Iterator(this.objects);it.hasNext();){o=it.next();o.remove(this);o.element.parentNode.removeChild(o.element);}
this.objects.removeAll();this.viewport.appendChild(this.mapLayer);},updateDataCopyright:function(){if(!this.dataCopyright){var c=_E.create('div',null,{textValue:' ',className:'dataCopyright'});var pos={zIndex:100,bottom:0};if(this.width>=250){pos.right=0;}else{pos.left=0;}
this.dataCopyright=new DSMapDecorator(this,c,pos,'copyright','data copyright');this.addDecorator(this.dataCopyright);}
this.dataCopyright.getElement().firstChild.nodeValue=this.copyrightSet.getCopyright(this.getCenterPoint(),this.zoomLevel);},addCopyright:function(){var t=_E.create('div',null,{textValue:this.copyrightTxt});$D.addClass(t,'copyright');this.copyright=new DSMapDecorator(this,t,{bottom:this.width>=250?0:10},'copyright','main copyright');this.addDecorator(this.copyright);this.updateDataCopyright();},sizeLayers:function(){this.width=parseInt(this.container.clientWidth,10);this.height=parseInt(this.container.clientHeight,10);this.desiredRows=Math.ceil(this.height/this.getOption('tileHeight'))+2;this.desiredColumns=Math.ceil(this.width/this.getOption('tileWidth'))+2;this.mapLayerWidth=this.desiredColumns*this.getOption('tileWidth');this.mapLayerHeight=this.desiredRows*this.getOption('tileHeight');this.mapLayer.style.height=this.mapLayerHeight+'px';this.mapLayer.style.width=this.mapLayerWidth+'px';this.decoratorLayer.style.height=this.height+'px';this.decoratorLayer.style.width=this.width+'px';},initContainer:function(){var scales,scalesLen;this.decoratorLayer=_E.create('div',this.container,{'class':'decLayer'});this.viewport=_E.create('div',this.decoratorLayer,{'class':'viewport'});this.mapLayer=_E.create('div',this.viewport,{'class':'mapLayer'});this.tileLayer=_E.create('div',this.mapLayer,{'class':'tileLayer'});if(this.getOption('enableScales')){scales=this.getOption('mapScales');scalesLen=scales.length;while(scalesLen--){if(scales[scalesLen]=='std'){this.stdScale=_E.create('div',this.decoratorLayer,{'class':'mapScale stdScale'});this.stdScaleText=_E.create('span',this.stdScale);}else if(scales[scalesLen]=='metric'){this.metricScale=_E.create('div',this.decoratorLayer,{'class':'mapScale metricScale'});this.metricScaleText=_E.create('span',this.metricScale);}}}
if(!this.getOption('controlBuffer')){this.setOption('controlBuffer',0);}
this.sizeLayers();this.desiredRows;this.desiredColumns;this.addCopyright();},getMapLeft:function(){var l=parseInt($D.getStyle(this.mapLayer,'left'),10);return l;},getMapTop:function(){var t=parseInt($D.getStyle(this.mapLayer,'top'),10);return t;},addMessage:function(msg){this.messages.push(msg);},getMessages:function(msg){return this.messages;}};LMI.Lang.importFunctions(Map,LMI.Event);return Map;})();LMI.Mapping.Map.Defaults={'singleZoom':3,'emptyZoom':14,'defaultLat':39.73926,'defaultLng':-104.98478,'defaultLocale':'','enableScales':true,'imageBase':'img/','pixelUrl':'img/pixel_trans.gif','brokenUrl':'img/map_unavailable.gif','tileBase':'http://localhost/tiles/','tileExtension':'.png','tileSuffix':'','tileWidth':256,'tileHeight':256,'tileAttempts':1,'standardParallel':40};LMI.Mapping.Tile=(function(){var Y=YAHOO.util,ie=YAHOO.env.ua.ie,$D=Y.Dom,_E=LMI.Element;var errors={};function setAlphaImageLoader(img,src){if(img.style.filter.match(/progid:DXImageTransform.Microsoft.AlphaImageLoader\(src=\"(.*)\"\)/)){img.style.filter=img.style.filter.replace(/progid:DXImageTransform.Microsoft.AlphaImageLoader\(src=\"(.*)\"\)/,'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+src+'")');}else{img.style.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+src+'")'+img.style.filter;}
img.src=LMI.Urls.getImg('pixel_trans.gif');}
function setOpacity(el,val,transparent){if(!ie||ie>=7||!transparent){$D.setStyle(el,'opacity',val);}else{if(el.style.filter.match(/progid:DXImageTransform.Microsoft.Alpha\(opacity=\d+\.*\d*\)/)){el.style.filter=el.style.filter.replace(/progid:DXImageTransform.Microsoft.Alpha\(opacity=\d+\.*\d*\)/,'progid:DXImageTransform.Microsoft.Alpha(opacity='+(val*100)+')');}else{el.style.filter+='progid:DXImageTransform.Microsoft.Alpha(opacity='+(val*100)+')';}}}
function clearOpacity(el,transparent){if(ie&&(ie>=7||!transparent)){el.style.filter='';}else if(ie){el.style.filter=el.style.filter.replace(/progid:DXImageTransform.Microsoft.Alpha\(opacity=\d+\.*\d*\)/,'');}else{$D.setStyle(el,'opacity',1);}}
function Tile(el,options){this.init(el,options);};Tile.defaults={defaultTile:'/img/pixel_trans.gif',brokenTile:'/img/map_unavailable.gif',maxAttempts:1,width:256,height:256,transparent:false};Tile.prototype={init:function(el,options){var t=this,cl;this.parentEl=el;this.initOptions(options);cl=!this.options.transparent||navigator.platform.match(/Mac/)?'':'noprint';this.img=_E.create('img',this.parentEl,{src:this.options.defaultTile,style:'position: absolute;',galleryImg:'no',className:cl,events:{load:function(){t.load.apply(this,[t.options.transparent]);},error:{fn:this.error,obj:this,scope:true}}});this.setSize(this.options.width,this.options.height);setOpacity(this.img,0,this.options.transparent);},initOptions:function(options){this.options=LMI.Lang.mergeObjects({},Tile.defaults);if('config'in Tile){LMI.Lang.mergeObjects(this.options,Tile.config);}
LMI.Lang.mergeObjects(this.options,options);},error:function(){var s,i=this.img;if(!errors[i.src]){errors[i.src]=1;}
if(!i.src.match(this.options.brokenTile)){if(errors[i.src]++>=this.options.maxAttempts){i.src=this.options.brokenTile;}else{s=i.src;i.src=this.options.defaultTile;i.src=s;}}},load:function(transparent){var a,t=this;if('Anim'in Y){if(!ie||ie>=7||!transparent){a=new Y.Anim(this,{opacity:{to:1}},0.75);}else{a=new Y.Anim(this,{},0.75);a.onTween.subscribe(function(type,args){var o=args[0].currentFrame/a.totalFrames;setOpacity(t,o,true);});}
if(ie){a.onComplete.subscribe(function(){clearOpacity(t,transparent);});}
a.animate();}else{clearOpacity(this,transparent);}},removeFromDom:function(){_E.destroy(this.img);},setSize:function(width,height){this.width=this.img.width=width;this.height=this.img.height=height;},getWidth:function(){return this.width;},getHeight:function(){return this.height;},setLeft:function(left){this.img.style.left=left;},setTop:function(t){this.img.style.top=t;},setSrc:function(url){var that=this;this.src=url||this.options.defaultTile;if(this.loadTimeout){window.clearTimeout(this.loadTimeout);this.loadTimeout=null;}
if(typeof this.img.complete!='undefined'&&!this.img.complete){this.loadTimeout=window.setTimeout(function(){that.loadTimeout=null;that.setSrc(that.src);},1000);return;}
if(url){if(this.img.src!=url){setOpacity(this.img,0,this.options.transparent);this.setImgSrc();}}else{this.setImgSrc();}},setImgSrc:function(){var that=this;window.setTimeout(function(){var img=that.img,src=that.src;if(ie&&ie<7){if(that.options.transparent&&src.match(/\.png(;|$|\?)/)){setAlphaImageLoader(img,src);}else if(img.src!=src){img.src=src;}}else if(img){img.src=src;}},0);}};Tile.getErrors=function(){return errors;};return Tile;})();var DSMapCopyrightSet=new DSCopyrightSet();(function(){var year=new Date().getYear(),P=LMI.Mapping.Point;if(year<1000){year+=1900;}
var nt=new DSCopyright('\xa9'+year+' NAVTEQ',[new DSBoundingBox(new P(10.0,-135.0),new P(70.0,-60.0)),new DSBoundingBox(new P(48.0,-180.0),new P(75.0,-124.0)),new DSBoundingBox(new P(16.860777,-161.283172),new P(24.219651,-153.424705)),new DSBoundingBox(new P(12.5,-78.6),new P(33.0,-50.0))]);var ta=new DSCopyright('\xa9'+year+' TeleAtlas',[new DSBoundingBox(new P(48.478825,1.322422),new P(52.521175,7.677558)),new DSBoundingBox(new P(31.0,-10),new P(44.0,5.0)),new DSBoundingBox(new P(48.0,-0.6),new P(56.0,11.5)),new DSBoundingBox(new P(46.0,-20.0),new P(61.0,4.7))]);var tl='\xa9'+year+' Terralink Intl Ltd';DSMapCopyrightSet.addCopyright(nt);DSMapCopyrightSet.addCopyright(ta);DSMapCopyrightSet.addCopyright(new DSCopyright(tl,new DSBoundingBox(new P(-70.0,133.0),new P(-11.0,180.0))));})();LMI.Mapping.MapObject=(function(){function MapObject(point,element){this.init(point,element);}
MapObject.prototype={init:function(point,element){this.element=element;this.properties={};this.setPoint(point);this.setXOffset(0);this.setYOffset(0);this.setZOffset(0);this.setIncludedInBestFit(true);this.initEvents('click','mouseout','mouseover','add','remove');},setPoint:function(point){this.point=point;},getPoint:function(){return this.point;},getBoundingBox:function(){if('boundingBox'in this){return this.boundingBox;}
return null;},getWidth:function(){return this.element.offsetWidth;},getHeight:function(){return this.element.offsetHeight;},setXOffset:function(xOffset){this.xOffset=xOffset;},getXOffset:function(){return this.xOffset;},setYOffset:function(yOffset){this.yOffset=yOffset;},getYOffset:function(){return this.yOffset;},setZOffset:function(zOffset){this.zOffset=zOffset;},getZOffset:function(){return this.zOffset;},setProperty:function(name,val){this.properties[name]=val;},setProperties:function(){var i,o;if(typeof arguments[0]==='object'){o=arguments[0];for(i in o){if(o.hasOwnProperty(i)){this.setProperty(i,o[i]);}}}else{o=arguments.length;for(i=0;i<o;++i){this.properties[arguments[i]]=arguments[++i];}}
return this;},getProperty:function(name){return(name&&name in this.properties?this.properties[name]:"");},setIncludedInBestFit:function(included){this.includedInBestFit=!!included;},isIncludedInBestFit:function(){return this.includedInBestFit;},setZIndex:function(zIndex){this.element.style.zIndex=zIndex;},add:function(map){this.shownOnMap=true;this.map=map;this.triggerEvent('add',{map:map},this);},update:function(map){},remove:function(map){this.triggerEvent('remove',{map:map},this);this.shownOnMap=false;this.map=null;}};LMI.Lang.importFunctions(MapObject,LMI.Event);MapObject.prototype._addEventListener=MapObject.prototype.addEventListener;MapObject.prototype.addEventListener=function(type,func){var that;switch(type){case'click':YAHOO.util.Dom.setStyle(this.element,'cursor','pointer');case'mouseout':case'mouseover':if(this.getListeners(type).length===0){that=this;YAHOO.util.Event.on(this.element,type,function(e){that.triggerEvent(type,e,that);});}
break;}
return this._addEventListener(type,func);};MapObject.prototype.bindEvent=function(type,obj,func,arg){var f=function(e,o){func.call(obj,e,o,arg);};return this.addEventListener(type,f);};return MapObject;})();LMI.Mapping.Icon=(function(){function Icon(point,option){this.init(point,option);}
LMI.Lang.extend(Icon,LMI.Mapping.MapObject);var proto=Icon.prototype,superclass=Icon.superclass;proto.init=function(point,option){this.option=option;var img=LMI.Element.create('img');YAHOO.util.Event.on(img,'error',imgError,this,true);superclass.init.call(this,point,img);this.setIconSrc(this.getRecommendedIconSrc());this.setXOffset(24);this.setYOffset(27);};proto.getIconSrc=function(){return LMI.Element.getImageSrc(this.element);};proto.setIconSrc=function(src){LMI.Element.setImageSrc(this.element,src);};proto.getRecommendedIconSrc=function(){var i=parseInt(this.option,10),lets='abcdefghijklmnopqrstuvwxyz',l=(i>=0&&i<lets.length?lets.charAt(i):'blank');return'img/nodes/red/map_icon_'+l+'.png';};proto.getHeight=function(){return 27;};proto.getWidth=function(){return 24;};proto.getDefaultIcon=function(){var src=this.getIconSrc();return src.replace(/((?:https?:\/\/)?(?:[^\/]+\/)*)[^\/]+/,'$1map_icon_blank.png');};function imgError(e){var i=this.element,defaultIcon=this.getDefaultIcon();if(LMI.Element.getImageSrc(i).match(defaultIcon)){i.alt='X';}else{LMI.Element.setImageSrc(i,defaultIcon);}}
return Icon;})();LMI.Mapping.DSIcon=(function(){var _E=LMI.Element;function DSIcon(listing,label){this.init(listing,label);}
YAHOO.lang.extend(DSIcon,LMI.Mapping.Icon,{init:function(listing,label){var p=new LMI.Mapping.Point(listing.latitude,listing.longitude);this.option=label;this.createLabelElement();DSIcon.superclass.init.call(this,p,label);if(listing){this.setListing(listing);}},setListing:function(listing){var that=this;LMI.Lang.forEach(['name','streetAddress'],function(p){if(p in listing){that.setProperty(p,listing[p]);}});},getRecommendedIconSrc:function(){return LMI.Urls.getImg(LMI.Data.Urls.defaultIcon);},createLabelElement:function(){if(!this.labelElement&&this.option){this.labelElement=_E.create('div',null,{text:this.option,className:'DSIconLabel'});}},add:function(){DSIcon.superclass.add.apply(this,arguments);if(this.labelElement){this.element.parentNode.appendChild(this.labelElement);}},update:function(){DSIcon.superclass.update.apply(this,arguments);if(this.labelElement){this.labelElement.style.left=this.element.style.left;this.labelElement.style.top=this.element.style.top;this.labelElement.style.zIndex=this.element.style.zIndex;}},remove:function(){DSIcon.superclass.remove.apply(this,arguments);if(this.labelElement){this.element.parentNode.removeChild(this.labelElement);}},setZIndex:function(zIndex){this.element.style.zIndex=zIndex;if(this.labelElement){this.labelElement.style.zIndex=zIndex;}},addEventListener:function(type,func){var that=this,els=[this.element,this.labelElement];switch(type){case'click':YAHOO.util.Dom.setStyle(this.element,'cursor','pointer');YAHOO.util.Dom.setStyle(this.labelElement,'cursor','pointer');case'mouseout':case'mouseover':if(this.getListeners(type).length===0){YAHOO.util.Event.on(els,type,function(e){that.triggerEvent(type,e,that);});}
break;}
return this._addEventListener(type,func);}});return DSIcon;})();LMI.Mapping.CenterIcon=(function(){function CenterIcon(center,oldSearch){var point=new LMI.Mapping.Point(center.latitude,center.longitude);this.init(point,oldSearch);}
YAHOO.lang.extend(CenterIcon,LMI.Mapping.Icon,{getRecommendedIconSrc:function(){return this.option?LMI.Urls.getImg('mapping/map_node_faded_star.png'):LMI.Urls.getImg('mapping/map_node_red_star.png');}});return CenterIcon;})();if(DWREngine==null)var DWREngine={};DWREngine.setErrorHandler=function(handler){DWREngine._errorHandler=handler;};DWREngine.setWarningHandler=function(handler){DWREngine._warningHandler=handler;};DWREngine.setTimeout=function(timeout){DWREngine._timeout=timeout;};DWREngine.setPreHook=function(handler){DWREngine._preHook=handler;};DWREngine.setPostHook=function(handler){DWREngine._postHook=handler;};DWREngine.XMLHttpRequest=1;DWREngine.IFrame=2;DWREngine.setMethod=function(newMethod){if(newMethod!=DWREngine.XMLHttpRequest&&newMethod!=DWREngine.IFrame){DWREngine._handleError("Remoting method must be one of DWREngine.XMLHttpRequest or DWREngine.IFrame");return;}
DWREngine._method=newMethod;};DWREngine.setVerb=function(verb){if(verb!="GET"&&verb!="POST"){DWREngine._handleError("Remoting verb must be one of GET or POST");return;}
DWREngine._verb=verb;};DWREngine.setOrdered=function(ordered){DWREngine._ordered=ordered;};DWREngine.setAsync=function(async){DWREngine._async=async;};DWREngine.setTextHtmlHandler=function(handler){DWREngine._textHtmlHandler=handler;}
DWREngine.defaultMessageHandler=function(message){if(typeof message=="object"&&message.name=="Error"&&message.description){alert("Error: "+message.description);}
else{if(message.toString().indexOf("0x80040111")==-1){alert(message);}}};DWREngine.beginBatch=function(){if(DWREngine._batch){DWREngine._handleError("Batch already started.");return;}
DWREngine._batch={map:{callCount:0},paramCount:0,ids:[],preHooks:[],postHooks:[]};};DWREngine.endBatch=function(options){var batch=DWREngine._batch;if(batch==null){DWREngine._handleError("No batch in progress.");return;}
if(options&&options.preHook)batch.preHooks.unshift(options.preHook);if(options&&options.postHook)batch.postHooks.push(options.postHook);if(DWREngine._preHook)batch.preHooks.unshift(DWREngine._preHook);if(DWREngine._postHook)batch.postHooks.push(DWREngine._postHook);if(batch.method==null)batch.method=DWREngine._method;if(batch.verb==null)batch.verb=DWREngine._verb;if(batch.async==null)batch.async=DWREngine._async;if(batch.timeout==null)batch.timeout=DWREngine._timeout;batch.completed=false;DWREngine._batch=null;if(!DWREngine._ordered){DWREngine._sendData(batch);DWREngine._batches[DWREngine._batches.length]=batch;}
else{if(DWREngine._batches.length==0){DWREngine._sendData(batch);DWREngine._batches[DWREngine._batches.length]=batch;}
else{DWREngine._batchQueue[DWREngine._batchQueue.length]=batch;}}};DWREngine._errorHandler=DWREngine.defaultMessageHandler;DWREngine._warningHandler=null;DWREngine._preHook=null;DWREngine._postHook=null;DWREngine._batches=[];DWREngine._batchQueue=[];DWREngine._handlersMap={};DWREngine._method=DWREngine.XMLHttpRequest;DWREngine._verb="POST";DWREngine._ordered=false;DWREngine._async=true;DWREngine._batch=null;DWREngine._timeout=0;DWREngine._DOMDocument=["Msxml2.DOMDocument.6.0","Msxml2.DOMDocument.5.0","Msxml2.DOMDocument.4.0","Msxml2.DOMDocument.3.0","MSXML2.DOMDocument","MSXML.DOMDocument","Microsoft.XMLDOM"];DWREngine._XMLHTTP=["Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP.5.0","Msxml2.XMLHTTP.4.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"];DWREngine._execute=function(path,scriptName,methodName,vararg_params){var singleShot=false;if(DWREngine._batch==null){DWREngine.beginBatch();singleShot=true;}
var args=[];for(var i=0;i<arguments.length-3;i++){args[i]=arguments[i+3];}
if(DWREngine._batch.path==null){DWREngine._batch.path=path;}
else{if(DWREngine._batch.path!=path){DWREngine._handleError("Can't batch requests to multiple DWR Servlets.");return;}}
var params;var callData;var firstArg=args[0];var lastArg=args[args.length-1];if(typeof firstArg=="function"){callData={callback:args.shift()};params=args;}
else if(typeof lastArg=="function"){callData={callback:args.pop()};params=args;}
else if(lastArg!=null&&typeof lastArg=="object"&&lastArg.callback!=null&&typeof lastArg.callback=="function"){callData=args.pop();params=args;}
else if(firstArg==null){if(lastArg==null&&args.length>2){DWREngine._handleError("Ambiguous nulls at start and end of parameter list. Which is the callback function?");}
callData={callback:args.shift()};params=args;}
else if(lastArg==null){callData={callback:args.pop()};params=args;}
else{DWREngine._handleError("Missing callback function or metadata object.");return;}
var random=Math.floor(Math.random()*10001);var id=(random+"_"+new Date().getTime()).toString();var prefix="c"+DWREngine._batch.map.callCount+"-";DWREngine._batch.ids.push(id);if(callData.method!=null){DWREngine._batch.method=callData.method;delete callData.method;}
if(callData.verb!=null){DWREngine._batch.verb=callData.verb;delete callData.verb;}
if(callData.async!=null){DWREngine._batch.async=callData.async;delete callData.async;}
if(callData.timeout!=null){DWREngine._batch.timeout=callData.timeout;delete callData.timeout;}
if(callData.preHook!=null){DWREngine._batch.preHooks.unshift(callData.preHook);delete callData.preHook;}
if(callData.postHook!=null){DWREngine._batch.postHooks.push(callData.postHook);delete callData.postHook;}
if(callData.errorHandler==null)callData.errorHandler=DWREngine._errorHandler;if(callData.warningHandler==null)callData.warningHandler=DWREngine._warningHandler;DWREngine._handlersMap[id]=callData;DWREngine._batch.map[prefix+"scriptName"]=scriptName;DWREngine._batch.map[prefix+"methodName"]=methodName;DWREngine._batch.map[prefix+"id"]=id;for(i=0;i<params.length;i++){DWREngine._serializeAll(DWREngine._batch,[],params[i],prefix+"param"+i);}
DWREngine._batch.map.callCount++;if(singleShot){DWREngine.endBatch();}};DWREngine._sendData=function(batch){if(batch.map.callCount==0)return;for(var i=0;i<batch.preHooks.length;i++){batch.preHooks[i]();}
batch.preHooks=null;if(batch.timeout&&batch.timeout!=0){batch.interval=setInterval(function(){DWREngine._abortRequest(batch);},batch.timeout);}
var urlPostfix;if(batch.map.callCount==1){urlPostfix=batch.map["c0-scriptName"]+"."+batch.map["c0-methodName"]+".dwr";}
else{urlPostfix="Multiple."+batch.map.callCount+".dwr";}
if(batch.method==DWREngine.XMLHttpRequest){if(window.XMLHttpRequest){batch.req=new XMLHttpRequest();}
else if(window.ActiveXObject&&!(navigator.userAgent.indexOf("Mac")>=0&&navigator.userAgent.indexOf("MSIE")>=0)){batch.req=DWREngine._newActiveXObject(DWREngine._XMLHTTP);}}
var query="";var prop;if(batch.req){batch.map.xml="true";if(batch.async){batch.req.onreadystatechange=function(){DWREngine._stateChange(batch);};}
var indexSafari=navigator.userAgent.indexOf("Safari/");if(indexSafari>=0){var version=navigator.userAgent.substring(indexSafari+7);if(parseInt(version,10)<400)batch.verb=="GET";}
if(batch.verb=="GET"){batch.map.callCount=""+batch.map.callCount;for(prop in batch.map){var qkey=encodeURIComponent(prop);var qval=encodeURIComponent(batch.map[prop]);if(qval=="")DWREngine._handleError("Found empty qval for qkey="+qkey);query+=qkey+"="+qval+"&";}
try{var _url=batch.path;if(_url.indexOf(';')>=0){_url=_url.replace(/(;.*)/,"/exec/"+urlPostfix+"?"+query+"$1");}else{_url+="/exec/"+urlPostfix+"?"+query;}
batch.req.open("GET",_url,batch.async);batch.req.send(null);if(!batch.async)DWREngine._stateChange(batch);}
catch(ex){DWREngine._handleMetaDataError(null,ex);}}
else{for(prop in batch.map){if(typeof batch.map[prop]!="function"){query+=prop+"="+batch.map[prop]+"\n";}}
var _url=batch.path;if(_url.indexOf(';')>=0){_url=_url.replace(/(;.*)/,"/exec/"+urlPostfix+"$1");}else{_url+="/exec/"+urlPostfix;}
try{batch.req.open("POST",_url,batch.async);batch.req.setRequestHeader('Content-Type','text/plain');batch.req.send(query);if(!batch.async)DWREngine._stateChange(batch);}
catch(ex){DWREngine._handleMetaDataError(null,ex);}}}
else{batch.map.xml="false";var idname="dwr-if-"+batch.map["c0-id"];batch.div=document.createElement("div");batch.div.innerHTML="<iframe src='javascript:void(0)' frameborder='0' width='0' height='0' id='"+idname+"' name='"+idname+"'></iframe>";document.body.appendChild(batch.div);batch.iframe=document.getElementById(idname);batch.iframe.setAttribute("style","width:0px; height:0px; border:0px;");if(batch.verb=="GET"){for(prop in batch.map){if(typeof batch.map[prop]!="function"){query+=encodeURIComponent(prop)+"="+encodeURIComponent(batch.map[prop])+"&";}}
query=query.substring(0,query.length-1);batch.iframe.setAttribute("src",batch.path+"/exec/"+urlPostfix+"?"+query);document.body.appendChild(batch.iframe);}
else{batch.form=document.createElement("form");batch.form.setAttribute("id","dwr-form");batch.form.setAttribute("action",batch.path+"/exec"+urlPostfix);batch.form.setAttribute("target",idname);batch.form.target=idname;batch.form.setAttribute("method","POST");for(prop in batch.map){var formInput=document.createElement("input");formInput.setAttribute("type","hidden");formInput.setAttribute("name",prop);formInput.setAttribute("value",batch.map[prop]);batch.form.appendChild(formInput);}
document.body.appendChild(batch.form);batch.form.submit();}}};DWREngine._stateChange=function(batch){if(!batch.completed&&batch.req.readyState==4){try{var reply=batch.req.responseText;if(reply==null||reply==""){DWREngine._handleMetaDataWarning(null,"No data received from server");}
else{var contentType=batch.req.getResponseHeader("Content-Type");if(!contentType.match(/^text\/plain/)&&!contentType.match(/^text\/javascript/)){if(DWREngine._textHtmlHandler&&contentType.match(/^text\/html/)){DWREngine._textHtmlHandler();}
else{DWREngine._handleMetaDataWarning(null,"Invalid content type from server: '"+contentType+"'");}}
else{if(reply.search("DWREngine._handle")==-1){DWREngine._handleMetaDataWarning(null,"Invalid reply from server");}
else{eval(reply);}}}
DWREngine._clearUp(batch);}
catch(ex){if(ex==null)ex="Unknown error occured";DWREngine._handleMetaDataWarning(null,ex);}
finally{if(DWREngine._batchQueue.length!=0){var sendbatch=DWREngine._batchQueue.shift();DWREngine._sendData(sendbatch);DWREngine._batches[DWREngine._batches.length]=sendbatch;}}}};DWREngine._handleResponse=function(id,reply){var handlers=DWREngine._handlersMap[id];DWREngine._handlersMap[id]=null;if(handlers){try{if(handlers.callback)handlers.callback(reply);}
catch(ex){DWREngine._handleMetaDataError(handlers,ex);}}
if(DWREngine._method==DWREngine.IFrame){var responseBatch=DWREngine._batches[DWREngine._batches.length-1];if(responseBatch.map["c"+(responseBatch.map.callCount-1)+"-id"]==id){DWREngine._clearUp(responseBatch);}}};DWREngine._handleServerError=function(id,error){var handlers=DWREngine._handlersMap[id];DWREngine._handlersMap[id]=null;if(error.message)DWREngine._handleMetaDataError(handlers,error.message,error);else DWREngine._handleMetaDataError(handlers,error);};DWREngine._eval=function(script){return eval(script);}
DWREngine._abortRequest=function(batch){if(batch&&!batch.completed){clearInterval(batch.interval);DWREngine._clearUp(batch);if(batch.req)batch.req.abort();var handlers;for(var i=0;i<batch.ids.length;i++){handlers=DWREngine._handlersMap[batch.ids[i]];DWREngine._handleMetaDataError(handlers,"Timeout");}}};DWREngine._clearUp=function(batch){if(batch.completed){DWREngine._handleError("Double complete");return;}
if(batch.div)batch.div.parentNode.removeChild(batch.div);if(batch.iframe)batch.iframe.parentNode.removeChild(batch.iframe);if(batch.form)batch.form.parentNode.removeChild(batch.form);if(batch.req)delete batch.req;for(var i=0;i<batch.postHooks.length;i++){batch.postHooks[i]();}
batch.postHooks=null;for(var i=0;i<DWREngine._batches.length;i++){if(DWREngine._batches[i]==batch){DWREngine._batches.splice(i,1);break;}}
batch.completed=true;};DWREngine._handleError=function(reason,ex){if(DWREngine._errorHandler)DWREngine._errorHandler(reason,ex);};DWREngine._handleWarning=function(reason,ex){if(DWREngine._warningHandler)DWREngine._warningHandler(reason,ex);};DWREngine._handleMetaDataError=function(handlers,reason,ex){if(handlers&&typeof handlers.errorHandler=="function")handlers.errorHandler(reason,ex);else DWREngine._handleError(reason,ex);};DWREngine._handleMetaDataWarning=function(handlers,reason,ex){if(handlers&&typeof handlers.warningHandler=="function")handlers.warningHandler(reason,ex);else DWREngine._handleWarning(reason,ex);};DWREngine._serializeAll=function(batch,referto,data,name){if(data==null){batch.map[name]="null:null";return;}
switch(typeof data){case"boolean":batch.map[name]="boolean:"+data;break;case"number":batch.map[name]="number:"+data;break;case"string":batch.map[name]="string:"+encodeURIComponent(data);break;case"object":if(data instanceof String)batch.map[name]="String:"+encodeURIComponent(data);else if(data instanceof Boolean)batch.map[name]="Boolean:"+data;else if(data instanceof Number)batch.map[name]="Number:"+data;else if(data instanceof Date)batch.map[name]="Date:"+data.getTime();else if(data instanceof Array)batch.map[name]=DWREngine._serializeArray(batch,referto,data,name);else batch.map[name]=DWREngine._serializeObject(batch,referto,data,name);break;case"function":break;default:DWREngine._handleWarning("Unexpected type: "+typeof data+", attempting default converter.");batch.map[name]="default:"+data;break;}};DWREngine._lookup=function(referto,data,name){var lookup;for(var i=0;i<referto.length;i++){if(referto[i].data==data){lookup=referto[i];break;}}
if(lookup)return"reference:"+lookup.name;referto.push({data:data,name:name});return null;};DWREngine._serializeObject=function(batch,referto,data,name){var ref=DWREngine._lookup(referto,data,name);if(ref)return ref;if(data.nodeName&&data.nodeType){return DWREngine._serializeXml(batch,referto,data,name);}
var reply="Object:{";var element;for(element in data){batch.paramCount++;var childName="c"+DWREngine._batch.map.callCount+"-e"+batch.paramCount;DWREngine._serializeAll(batch,referto,data[element],childName);reply+=encodeURIComponent(element)+":reference:"+childName+", ";}
if(reply.substring(reply.length-2)==", "){reply=reply.substring(0,reply.length-2);}
reply+="}";return reply;};DWREngine._serializeXml=function(batch,referto,data,name){var ref=DWREngine._lookup(referto,data,name);if(ref)return ref;var output;if(window.XMLSerializer)output=new XMLSerializer().serializeToString(data);else output=data.toXml;return"XML:"+encodeURIComponent(output);};DWREngine._serializeArray=function(batch,referto,data,name){var ref=DWREngine._lookup(referto,data,name);if(ref)return ref;var reply="Array:[";for(var i=0;i<data.length;i++){if(i!=0)reply+=",";batch.paramCount++;var childName="c"+DWREngine._batch.map.callCount+"-e"+batch.paramCount;DWREngine._serializeAll(batch,referto,data[i],childName);reply+="reference:";reply+=childName;}
reply+="]";return reply;};DWREngine._unserializeDocument=function(xml){var dom;if(window.DOMParser){var parser=new DOMParser();dom=parser.parseFromString(xml,"text/xml");if(!dom.documentElement||dom.documentElement.tagName=="parsererror"){var message=dom.documentElement.firstChild.data;message+="\n"+dom.documentElement.firstChild.nextSibling.firstChild.data;throw message;}
return dom;}
else if(window.ActiveXObject){dom=DWREngine._newActiveXObject(DWREngine._DOMDocument);dom.loadXML(xml);return dom;}
else{var div=document.createElement("div");div.innerHTML=xml;return div;}};DWREngine._newActiveXObject=function(axarray){var returnValue;for(var i=0;i<axarray.length;i++){try{returnValue=new ActiveXObject(axarray[i]);break;}
catch(ex){}}
return returnValue;};if(typeof window.encodeURIComponent==='undefined'){DWREngine._utf8=function(wide){wide=""+wide;var c;var s;var enc="";var i=0;while(i<wide.length){c=wide.charCodeAt(i++);if(c>=0xDC00&&c<0xE000)continue;if(c>=0xD800&&c<0xDC00){if(i>=wide.length)continue;s=wide.charCodeAt(i++);if(s<0xDC00||c>=0xDE00)continue;c=((c-0xD800)<<10)+(s-0xDC00)+0x10000;}
if(c<0x80){enc+=String.fromCharCode(c);}
else if(c<0x800){enc+=String.fromCharCode(0xC0+(c>>6),0x80+(c&0x3F));}
else if(c<0x10000){enc+=String.fromCharCode(0xE0+(c>>12),0x80+(c>>6&0x3F),0x80+(c&0x3F));}
else{enc+=String.fromCharCode(0xF0+(c>>18),0x80+(c>>12&0x3F),0x80+(c>>6&0x3F),0x80+(c&0x3F));}}
return enc;}
DWREngine._hexchars="0123456789ABCDEF";DWREngine._toHex=function(n){return DWREngine._hexchars.charAt(n>>4)+DWREngine._hexchars.charAt(n&0xF);}
DWREngine._okURIchars="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-";window.encodeURIComponent=function(s){s=DWREngine._utf8(s);var c;var enc="";for(var i=0;i<s.length;i++){if(DWREngine._okURIchars.indexOf(s.charAt(i))==-1){enc+="%"+DWREngine._toHex(s.charCodeAt(i));}
else{enc+=s.charAt(i);}}
return enc;}}
if(typeof Array.prototype.splice==='undefined'){Array.prototype.splice=function(ind,cnt)
{if(arguments.length==0)return ind;if(typeof ind!="number")ind=0;if(ind<0)ind=Math.max(0,this.length+ind);if(ind>this.length){if(arguments.length>2)ind=this.length;else return[];}
if(arguments.length<2)cnt=this.length-ind;cnt=(typeof cnt=="number")?Math.max(0,cnt):0;removeArray=this.slice(ind,ind+cnt);endArray=this.slice(ind+cnt);this.length=ind;for(var i=2;i<arguments.length;i++)this[this.length]=arguments[i];for(i=0;i<endArray.length;i++)this[this.length]=endArray[i];return removeArray;}}
if(typeof Array.prototype.shift==='undefined'){Array.prototype.shift=function(str){var val=this[0];for(var i=1;i<this.length;++i)this[i-1]=this[i];this.length--;return val;}}
if(typeof Array.prototype.unshift==='undefined'){Array.prototype.unshift=function(){var i=unshift.arguments.length;for(var j=this.length-1;j>=0;--j)this[j+i]=this[j];for(j=0;j<i;++j)this[j]=unshift.arguments[j];}}
if(typeof Array.prototype.push==='undefined'){Array.prototype.push=function(){var sub=this.length;for(var i=0;i<push.arguments.length;++i){this[sub]=push.arguments[i];sub++;}}}
if(typeof Array.prototype.pop==='undefined'){Array.prototype.pop=function(){var lastElement=this[this.length-1];this.length--;return lastElement;}}
LMI.AjaxController=(function(){function handleMessage(errorStr,ex){if(typeof messageHandler==='function'){messageHandler.apply(this,arguments);}}
var path,uid,ptkn,messageHandler,className='mapping',L={getNearestRouteSegment:function(callback,point,shapeData){DWREngine._execute(path,className,'getNearestRouteSegment',callback,point.lat,point.lng,shapeData,uid,ptkn);},findClosestPoint:function(callback,point,points){var lats=[],lngs=[];LMI.Lang.forEach(points,function(p){lats.push(p.lat);lngs.push(p.lng);});DWREngine._execute(path,className,'findClosestPoint',callback,{lat:point.lat,lng:point.lng,lats:lats,lngs:lngs},uid,ptkn);},editListingNote:function(callback,id,note){DWREngine._execute(path,className,'editListingNote',callback,id,note,uid,ptkn);},saveSavedLocation:function(callback,id,name,address,note){DWREngine._execute(path,className,'saveSavedLocation',callback,id,name,address,note,uid,ptkn);},saveSavedLocationLatLng:function(callback,id,name,address,lat,lng,note){DWREngine._execute(path,className,'saveSavedLocation',callback,id,name,address,lat,lng,note,uid,ptkn);},getSearchCount:function(callback,what,latitude,longitude,distance,businessName){DWREngine._execute(path,className,'getSearchCount',callback,what,latitude,longitude,distance,businessName,uid,ptkn);},getNeighborhoodSearchCount:function(callback,what,neighborhoodId){DWREngine._execute(path,className,'getNeighborhoodSearchCount',callback,{'what':what,neighborhood:neighborhoodId},uid,ptkn);},getMapSearchCount:function(callback,what,lat,lng,geoPrecision,name,mapWidth,mapHeight,zoomLevel){zoomLevel=zoomLevel||-1;DWREngine._execute(path,className,'getMapSearchCount',callback,what,lat,lng,geoPrecision,name,mapWidth,mapHeight,zoomLevel,uid,ptkn);},getSearchResults:function(callback,params){DWREngine._execute(path,className,'getSearchResults',callback,params,uid,ptkn);},getListingDetails:function(callback,params){DWREngine._execute(path,className,'getListingDetails',callback,params,uid,ptkn);},addToMyList:function(callback,listingIds,savedLoc){DWREngine._execute(path,className,'addToMyList',callback,listingIds,savedLoc,uid,ptkn);},getPois:function(callback,cat,bounds){DWREngine._execute(path,className,'getPois',callback,cat,bounds,uid,ptkn);},getNearbySavedLocations:function(callback,bounds){DWREngine._execute(path,className,'getNearbySavedLocations',callback,bounds,uid,ptkn);},getRouteImageUrl:function(callback,shapeData,routeArea,boundingArea,zoomLevel){DWREngine._execute(path,className,'getRouteImageUrl',callback,shapeData,routeArea,boundingArea,zoomLevel,uid,ptkn,'png');},getPrintRouteImageUrl:function(callback,shapeData,routeArea,boundingArea,zoomLevel){DWREngine._execute(path,className,'getRouteImageUrl',callback,shapeData,routeArea,boundingArea,zoomLevel,uid,ptkn,'gif');},removeSavedLocations:function(callback,ids){DWREngine._execute(path,className,'removeSavedLocations',callback,ids,uid,ptkn);},submitReview:function(callback,review){DWREngine._execute(path,className,'submitReview',callback,review,uid,ptkn);},reportAbuse:function(callback,reportAbuse){DWREngine._execute(path,className,'reportAbuse',callback,reportAbuse,uid,ptkn);},getNeighborhoodData:function(callback,neighborhoodId){DWREngine._execute(path,className,'getNeighborhoodData',callback,{name:neighborhoodId},uid,ptkn);},setVisitorPreference:function(callback,key,value,session){DWREngine._execute(path,className,'setVisitorPreference',callback,uid,ptkn,key,value,(session?"SESSION":"VISITOR"));},validateUniqueSavedLocationName:function(callback,locationName){DWREngine._execute(path,className,'validateUniqueSavedLocationName',callback,locationName,uid,ptkn);},saveItinerary:function(callback,itineraryId,name,locations,locationTypes,properties){DWREngine._execute(path,className,'saveItinerary',callback,itineraryId,name,locations,locationTypes,properties,uid,ptkn);},getPath:function(){return path;},getClassName:function(){return className;},setMessageHandler:function(handler){messageHandler=handler;},handleMessage:handleMessage};LMI.Init.addFunction(function(){path=LMI.Urls.get("dwr");uid=LMI.Lang.getObject("LMI.Data.state.visitorVO.uid");ptkn=LMI.Lang.getObject("LMI.Data.state.visitorVO.passwordToken");DWREngine.setErrorHandler(handleMessage);DWREngine.setWarningHandler(handleMessage);});return L;})();(function(){var L=LMI.AjaxController,path,className,uid,ptkn;L.reorderItineraryPlaces=function(callback,placeIds){DWREngine._execute(path,className,'reorderItineraryPlaces',callback,placeIds,uid,ptkn);}
L.getSearchResults=function(callback,params){DWREngine._execute(L.getPath(),L.getClassName(),'getSearchResults',callback,params.encodedRefinement,params.what,params.llLat,params.llLng,params.urLat,params.urLng,params.width,params.height,params.zoomLevel,ptkn,uid,params.isPeopleSearch,params.isFolderSearch,params.folderId,params.requestId);};L.getListingDetails=function(callback,id,isPeopleSearch){DWREngine._execute(L.getPath(),L.getClassName(),'getListingDetails',callback,id,ptkn,uid,isPeopleSearch);};L.saveSavedMapLocation=function(callback,address,lat,lng,geoPrecision){DWREngine._execute(L.getPath(),L.getClassName(),'saveSavedLocationGeoPrecision',callback,address,lat,lng,geoPrecision,uid,ptkn);};L.submitReview=function(callback,review){DWREngine._execute(path,className,'submitReview',callback,review,uid,ptkn);};L.getAdvertiserPois=function(callback,pbtech,sttec3folder,params){DWREngine._execute(path,className,'getAdvertiserPois',callback,pbtech,sttec3folder,params.llLat,params.llLng,params.urLat,params.urLng,params.width,params.height,params.zoomLevel,uid,ptkn);}
LMI.Init.addFunction(function(){path=L.getPath();className=L.getClassName();uid=LMI.Lang.getObject("LMI.Data.state.visitorVO.uid");ptkn=LMI.Lang.getObject("LMI.Data.state.visitorVO.passwordToken");});})();
