/**
 * Active Website Map Search
 * 
 * @author Nick Verbeck <nick@activewebsite.com>
 * @since 10/1/2008
 */

var MapSearch = {};
MapSearch.version = '3.2';

/**
 * Map Search Console
 * 
 * Used as a wrapper to Firebug console. To resolve IE not having cool tools.
 * 
 * @author Nick Verbeck <nick@activewebsite.com>
 */
MapSearch.Console = {
	Levels: {None: 0,Info: 1,Warn: 2,Debug: 4,Error: 8,All: 15},
	CurrentLevel: 0,
	debug: function(msg){
		if (MapSearch.Console.CurrentLevel & MapSearch.Console.Levels.Debug != 0) {
			Try.these(
			function(){console.debug(msg);},
			function(){alert(msg.toString());},
			function(){alert(msg);}
			);
		}
	},
	error: function(msg){
		if (MapSearch.Console.CurrentLevel & MapSearch.Console.Levels.Error != 0) {
			Try.these(
			function(){console.error(msg);},
			function(){alert(msg.toString());},
			function(){alert(msg);}
			);
		}
	},
	info: function(msg){
		if (MapSearch.Console.CurrentLevel & MapSearch.Console.Levels.Info != 0) {
			Try.these(
			function(){console.info(msg);},
			function(){alert(msg.toString());},
			function(){alert(msg);}
			);
		}
	},
	warn: function(msg){
		if (MapSearch.Console.CurrentLevel & MapSearch.Console.Levels.Warn != 0) {
			Try.these(
			function(){console.warn(msg);},
			function(){alert(msg.toString());}, 
			function(){alert(msg);}
			);
		}
	}
}

MapSearch.EventTracking = {
		POINewEvent: function(value){
			try {
				pageTracker._trackEvent('MapSearch', 'POI - New', value);
			} catch (e){}
		},
		POIPrevEvent: function(value){
			try {
				pageTracker._trackEvent('MapSearch', 'POI - Prev', value);
			} catch (e){}
		},
		StatsEvent: function(value){
			try {
				pageTracker._trackEvent('MapSearch', 'Stats', value);
			} catch (e){}
		},
		ZoomToolEvent: function(value){
			try {
				pageTracker._trackEvent('MapSearch', 'Zoom Tool Search', value);
			} catch (e){}
		},
		LegendEvent: function(){
			try {
				pageTracker._trackEvent('MapSearch', 'Show Legend');
			} catch (e){}
		}
		//TODO: Polygon Event Tracking. Create/Edit/Delete
		//TODO: Streetview Event Tracking. Bubble/Button
		//TODO: Sub Area Event Tracking
		//TODO: Search Results Paging
}/*
 * @file MapSearch.SearchArea
 * @author Nick Verbeck <nick@activewebsite.com>
 */

MapSearch.SearchArea = {}
MapSearch.SearchArea.AreaManager = Class.create({
	initialize: function(){
		this.areas = new Array(new MapSearch.SearchArea.Area('Select an Area', null, null));
		this.currentTeir1 = null;
		this.currentTeir2 = null;
		this.currentTeir3 = null;
		this.elements = {
			teir1: null,
			teir2: null,
			teir3: null,
			teir1Select: null,
			teir2Select: null,
			teir3Select: null,
			currentListElement: null
		}
		this.currentShowingArea = null;
	},
	getSearchPolygonWKT: function(){
		if(this.currentTeir3 != null){
			return this.currentTeir3.area;
		} else if(this.currentTeir2 != null){
			return this.currentTeir2.area;
		} else if(this.currentTeir1 != null){
			return this.currentTeir1.area;
		} else {
			return '';
		}
	},
	getTeir1: function(){
		return this.areas;
	},
	getTeir2: function(){
		if(this.currentTeir1 != null){
			return this.currentTeir1.children;
		} else {
			return null;
		}
	},
	getTeir3: function(){
		if(this.currentTeir2 != null){
			return this.currentTeir2.children;
		} else {
			return null;
		}
	},
	changeShowingArea: function(area){
		if(this.currentShowingArea != null){
			this.currentShowingArea.hide();
		}
		this.currentShowingArea = area;
		this.currentShowingArea.show();
	},
	toggleDrawnPolygons: function(area){
		if (area == this.areas[0]) {
			MapSearch.GUI.Base.I().Tools.PanPoly.Polygons.each(function(iter){iter.show();});
		} else {
			MapSearch.GUI.Base.I().Tools.PanPoly.Polygons.each(function(iter){iter.hide();});
		}
	},
	reset: function(){
		if (this.areas.length > 1) {
			this.setTeir1(this.areas[0]);
		}
	},
	setTeir1: function(area){
		this.toggleDrawnPolygons(area);
		//Set Teir1 Area
		this.elements.teir1.innerHTML = area.name;
		this.currentTeir1 = area;
		//Set Teir2 to defaults
		this.elements.teir2.innerHTML = 'Select an Area';
		this.elements.teir2.style.display = '';
		this.elements.teir2Select.innerHTML = '';
		this.currentTeir2 = null;
		//Set Teir3 to defaults
		this.elements.teir3.innerHTML = 'Select an Area';
		this.elements.teir3.style.display = 'none';
		this.elements.teir3Select.innerHTML = '';
		this.currentTeir3 = null;
		
		if (this.getTeir2().length > 1) {
			//Built out the Drop down list
			this.getTeir2().each(function(iter){
				var temp = document.createElement("div");
				temp.appendChild(document.createTextNode(iter.name));
				temp.style.color = '#000';
				temp.style.cursor = 'pointer';
				temp.onmouseover = function(){
					if (this.elements.currentListElement != null) {
						this.elements.currentListElement.style.color = '#000';
						this.elements.currentListElement.style.backgroundColor = '';
					}
					this.elements.currentListElement = temp;
					this.elements.currentListElement.style.color = '#fff';
					this.elements.currentListElement.style.backgroundColor = '#464646';
				}.bind(this);
				temp.onclick = function(){
					this.setTeir2(iter);
					this.elements.teir2Select.style.display = 'none';
					if (this.elements.currentListElement != null) {
						this.elements.currentListElement.style.color = '#000';
						this.elements.currentListElement.style.backgroundColor = '';
						this.elements.currentListElement = null;
					}
				}.bind(this);
				this.elements.teir2Select.appendChild(temp);
			}.bind(this));
		} else {
			//Hide Teir2 as I don't have any items for it
			this.elements.teir2.style.display = 'none';
		}
		this.changeShowingArea(area);
	},
	setTeir2: function(area){
		this.elements.teir2.innerHTML = area.name;
		this.currentTeir2 = area;
		//Set Teir3 to Defaults
		this.elements.teir3.innerHTML = 'Select an Area';
		this.elements.teir3.style.display = '';
		this.elements.teir3Select.innerHTML = '';
		this.currentTeir3 = null;
		
		if (this.getTeir3().length > 1) {
			this.getTeir3().each(function(iter){
				var temp = document.createElement("div");
				temp.appendChild(document.createTextNode(iter.name));
				temp.style.color = '#000';
				temp.style.cursor = 'pointer';
				temp.onmouseover = function(){
					if (this.elements.currentListElement != null) {
						this.elements.currentListElement.style.color = '#000';
						this.elements.currentListElement.style.backgroundColor = '';
					}
					this.elements.currentListElement = temp;
					this.elements.currentListElement.style.color = '#fff';
					this.elements.currentListElement.style.backgroundColor = '#464646';
				}.bind(this);
				temp.onclick = function(){
					this.setTeir3(iter);
					this.elements.teir3Select.style.display = 'none';
					if (this.elements.currentListElement != null) {
						this.elements.currentListElement.style.color = '#000';
						this.elements.currentListElement.style.backgroundColor = '';
						this.elements.currentListElement = null;
					}
				}.bind(this);
				this.elements.teir3Select.appendChild(temp);
			}.bind(this));
		} else {
			this.elements.teir3.style.display = 'none';
		}
		this.changeShowingArea(area);
	},
	setTeir3: function(area){
		this.elements.teir3.innerHTML = area.name;
		this.currentTeir3 = area;
		this.changeShowingArea(area);
	},
	build: function(){
		this.elements.teir1Select = document.createElement("div");
		this.elements.teir1Select.style.border = '1px #000 solid';
		this.elements.teir1Select.style.position = 'absolute';
		this.elements.teir1Select.style.maxWidth = '168px';
		this.elements.teir1Select.style.minWidth = '95px';
		this.elements.teir1Select.style.fontSize = '12px';
		this.elements.teir1Select.style.zIndex = '1000';
		this.elements.teir1Select.style.backgroundColor = '#fff';
		this.elements.teir1Select.style.display = 'none';
		
		this.elements.teir2Select = document.createElement("div");
		this.elements.teir2Select.style.border = '1px #000 solid';
		this.elements.teir2Select.style.position = 'absolute';
		this.elements.teir2Select.style.maxWidth = '168px';
		this.elements.teir2Select.style.minWidth = '95px';
		this.elements.teir2Select.style.fontSize = '12px';
		this.elements.teir2Select.style.zIndex = '1000';
		this.elements.teir2Select.style.backgroundColor = '#fff';
		this.elements.teir2Select.style.display = 'none';
		
		this.elements.teir3Select = document.createElement("div");
		this.elements.teir3Select.style.border = '1px #000 solid';
		this.elements.teir3Select.style.position = 'absolute';
		this.elements.teir3Select.style.maxWidth = '168px';
		this.elements.teir3Select.style.minWidth = '95px';
		this.elements.teir3Select.style.fontSize = '12px';
		this.elements.teir3Select.style.zIndex = '1000';
		this.elements.teir3Select.style.backgroundColor = '#fff';
		this.elements.teir3Select.style.display = 'none';
		
		document.body.appendChild(this.elements.teir1Select);
		document.body.appendChild(this.elements.teir2Select);
		document.body.appendChild(this.elements.teir3Select);
		
		this.getTeir1().each(function(iter){
			var temp = document.createElement("div");
			temp.appendChild(document.createTextNode(iter.name));
			temp.style.color = '#000';
			temp.style.cursor = 'pointer';
			temp.onmouseover = function(){
				if (this.elements.currentListElement != null) {
					this.elements.currentListElement.style.color = '#000';
					this.elements.currentListElement.style.backgroundColor = '';
				}
				this.elements.currentListElement = temp;
				this.elements.currentListElement.style.color = '#fff';
				this.elements.currentListElement.style.backgroundColor = '#464646';
			}.bind(this);
			temp.onclick = function(){
				this.setTeir1(iter);
				this.elements.teir1Select.style.display = 'none';
				if (this.elements.currentListElement != null) {
					this.elements.currentListElement.style.color = '#000';
					this.elements.currentListElement.style.backgroundColor = '';
					this.elements.currentListElement = null;
				}
			}.bind(this);
			this.elements.teir1Select.appendChild(temp);
		}.bind(this));
		
		this.elements.teir1.onclick = function(){
			var pos = jUtilities.Graphics.getAbsolutePosition(this.elements.teir1);
			this.elements.teir1Select.style.top = (pos.y + $(this.elements.teir1).getHeight()) + 'px'; 
			//this.elements.teir1Select.style.left = (pos.x - ($(this.elements.teir1Select).getWidth() - $(this.elements.teir1).getWidth())) + 'px'; 
			this.elements.teir1Select.style.left = pos.x +'px';
			
			this.elements.teir1Select.style.display = '';
			this.elements.teir2Select.style.display = 'none';
			this.elements.teir3Select.style.display = 'none';
			if(this.elements.currentListElement != null){
				this.elements.currentListElement.style.color = '#000';
				this.elements.currentListElement.style.backgroundColor = '';
				this.elements.currentListElement = null;
			}
		}.bind(this);
		
		this.elements.teir2.onclick = function(){
			var pos = jUtilities.Graphics.getAbsolutePosition(this.elements.teir2);
			this.elements.teir2Select.style.top = (pos.y + $(this.elements.teir2).getHeight()) + 'px'; 
			//this.elements.teir2Select.style.left = (pos.x - ($(this.elements.teir2Select).getWidth() - $(this.elements.teir2).getWidth())) + 'px';
			this.elements.teir2Select.style.left = pos.x +'px';
			
			this.elements.teir1Select.style.display = 'none';
			this.elements.teir2Select.style.display = '';
			this.elements.teir3Select.style.display = 'none';
			if(this.elements.currentListElement != null){
				this.elements.currentListElement.style.color = '#000';
				this.elements.currentListElement.style.backgroundColor = '';
				this.elements.currentListElement = null;
			}
		}.bind(this);
		
		this.elements.teir3.onclick = function(){
			var pos = jUtilities.Graphics.getAbsolutePosition(this.elements.teir3);
			this.elements.teir3Select.style.top = (pos.y + $(this.elements.teir3).getHeight()) + 'px'; 
			//this.elements.teir3Select.style.left = (pos.x - ($(this.elements.teir3Select).getWidth() - $(this.elements.teir3).getWidth())) + 'px';
			this.elements.teir3Select.style.left = pos.x +'px';
			
			this.elements.teir1Select.style.display = 'none';
			this.elements.teir2Select.style.display = 'none';
			this.elements.teir3Select.style.display = '';
			if(this.elements.currentListElement != null){
				this.elements.currentListElement.style.color = '#000';
				this.elements.currentListElement.style.backgroundColor = '';
				this.elements.currentListElement = null;
			}
		}.bind(this);
	},
	addArea: function(area){
		this.areas[this.areas.length] = area;
	}
});
MapSearch.SearchArea.AreaManager.Instance = null;
MapSearch.SearchArea.AreaManager.I = function(){
	if(MapSearch.SearchArea.AreaManager.Instance == null){MapSearch.SearchArea.AreaManager.Instance = new MapSearch.SearchArea.AreaManager();}
	return MapSearch.SearchArea.AreaManager.Instance;
}

MapSearch.SearchArea.Area = Class.create({
	initialize: function(name, desc, area, propertyCount){
		this.children = new Array();
		this.name = name == "" ? null : name;
		this.desc = desc == "" ? '' : desc;
		this.area = area == "" ? null : area;
		this.propertyCount = propertyCount == "" ? null : propertyCount;
		this.polygons = new Array();
		this.bounds = null;
		this.pushpin = null;
	},
	addChild: function(child){
		if(this.children.length == 0){
			//Add a default 1 if I end up having any number of children. 
			//Doing this here saves be from a recursive nightmare.
			this.children[0] = new MapSearch.SearchArea.Area('Select an Area', null, null);
		}
		this.children[this.children.length] = child;
	},
	show: function(){
		if (this.polygons.length == 0) {
			this.createPolygons();
		} else {
			this.polygons.each(function(iter){iter.show();});
		}
		if (this.bounds != null) {
			MapSearch.Map.I().map.setCenter(this.bounds.getCenter(), MapSearch.Map.I().map.getBoundsZoomLevel(this.bounds));
		}
		if(this.pushpin != null){
			this.pushpin.show();
			this.pushpin.showWindow();
		}
	},
	hide: function(){
		this.polygons.each(function(iter){iter.hide();});
		if(this.pushpin != null){
			this.pushpin.hide();
		}
	},
	createPolygons: function(){
		if(this.area != null){
			this.bounds = new GLatLngBounds();
			$A(this.area.split('|')).each(function(iter){
				var temp = new GPolygon([], '#2b1931', 3, 1, '#522437', 0.2);
				MapSearch.Map.I().map.addOverlay(temp);
				var count = 0;
				$RWKT(iter).each(function(point){
					var latlng = new GLatLng(point.Latitude, point.Longitude);
					this.bounds.extend(latlng);
					temp.insertVertex(count, latlng);
					count++;
				}.bind(this));
				
				this.polygons[this.polygons.length] = temp;
			}.bind(this));
			var html = MapSearch.Template.Bubble.SearchArea.evaluate({
				title:this.name, 
				desc:this.desc, 
				propertyCount: this.propertyCount == null ? '' : this.propertyCount +" Properties"});
			this.pushpin = MapSearch.Map.I().createPushpin(this.bounds.getCenter(), html, MapSearch.Config.Icons.Base.community);
			this.pushpin.add();
		}
	}
});/**
 * @author nick
 */
MapSearch.Office = {}
MapSearch.Office.Collection = Class.create({
	initialize: function() {
		this.offices = new Array();
		this.length = 0;
	},
	concat: function(office){
		this.offices = this.offices.concat(office);
		this.length = this.offices.length;
	},
	push: function(office){
		this.offices.push(office);
		this.length = this.offices.length;
	},
	clear: function(){
		this.offices = new Array();
		this.length = 0;
	},
	each: function(call){
		this.offices.each(call);
	},
	getOfficeCodes: function(){
		var codes = new Array();
		this.each(function(iter){
			codes = codes.concat(iter.info.codes);
		});
		return codes;
	}
});
MapSearch.Office.Collection.Instance = null;
MapSearch.Office.Collection.I = function(){
	if(MapSearch.Office.Collection.Instance == null){
		MapSearch.Office.Collection.Instance = new MapSearch.Office.Collection();
	}
	return MapSearch.Office.Collection.Instance;
}

MapSearch.Office.Office = Class.create();
MapSearch.Office.Office.prototype = {
	initialize: function(info) {
		this.info = {
			codes: new Array(),
			title: '',
			latitude: 0,
			longitude: 0,
			streetAddress: '',
			city: '',
			state: '',
			phone: '',
			image: ''
		}
		Object.extend(this.info, info || {});
		this.pushpin = null;
	},
	changeInfo: function(info){
		Object.extend(this.info, info || {});
	},
	getPushpin: function(){
		if(this.pushpin == null){
			var html = MapSearch.Template.Bubble.Office.evaluate({
				img:this.info.image == '' ? '' : '<div class="Photo"><img src="'+ this.info.image +'/maxwidth/150/maxheight/110/matte/!000/" style="width:150px; height:110px;" /></div>',
				title:this.info.title,
				street:this.info.streetAddress,
				city:this.info.city,
				state:this.info.state,
				phone:this.info.phone
			});
			//html = new Array(new GInfoWindowTab('Desc', html), new GInfoWindowTab('Test','Test Content'));
			this.point = new MapSearch.Map.LatLong(this.info.latitude, this.info.longitude);
			this.pushpin = MapSearch.Map.I().createPushpin(this.point.getObject(), html, MapSearch.Config.Icons.Base.office);
		}
		return this.pushpin;
	}
}/**
 * @author nick
 */
MapSearch.Search = {};
MapSearch.Search.Instance = null;
MapSearch.Search.I = function(){
	if (MapSearch.Search.instance == null){
		MapSearch.Search.instance = new MapSearch.Search.Base();
	}
	return MapSearch.Search.instance;
}
MapSearch.Search.Base = Class.create({
	initialize: function() {
		this.GUI = MapSearch.GUI.Base.I();
		this.Map = MapSearch.Map.I();
		this.Results = new MapSearch.Property.Collection(MapSearch.Property.Types.Results);
		this.pageing = false;
		this.searchQueue = new MapSearch.Search.SearchQueue(this.searchSuccess.bind(this), this.searchFail.bind(this));
		this.AutoSearchTimer = null;
		
		this.Params = {
			propertyType: '',
			sqftMin: 0,
			sqftMax: '',
			priceMin: 0,
			priceMax: 0,
			beds: 0,
			baths: 0,
			bounds: '',
			limit: 50,
			wkt: '',
			areaWKT: false,
			order: 'PriceDesc',
			offset: 0,
			owner_only: '',
			New_Property: '',
			WithPics: '',
			Virtual_Tour: '',
			video: ''
		}
		this.runUpdateParams = false;
		
		this.GUI.Panels.Search.loaded(function(){this.onLoadSearch();}.bind(this));
		
		this.GUI.Status.setSearchResultsCallback(function(pEvent){
			this.searchEvent(pEvent);
		}.bind(this));
		this.parseQueryString();
	},
	onLoadSearch: function(){
		try{
			Event.observe(this.GUI.Panels.Search.items.searchBtn, 'click', this.searchEvent.bindAsEventListener(this));
		} catch(e){}
		try{
			Event.observe(this.GUI.Panels.Search.items.pagePrev, 'click', this.pageEvent.bindAsEventListener(this));
		} catch(e){}
		try{
			Event.observe(this.GUI.Panels.Search.items.pageNext, 'click', this.pageEvent.bindAsEventListener(this));
		} catch(e){}
		try{
			Event.observe(this.GUI.Panels.Search.items.sort, 'change', this.orderEvent.bindAsEventListener(this));
		} catch(e){}
		
		this.updateSearchItems();
		MapSearch.Map.I().events.zoomEnd[MapSearch.Map.I().events.zoomEnd.length] = this.autoSearchEvent.bind(this);
		MapSearch.Map.I().events.dragEnd[MapSearch.Map.I().events.dragEnd.length] = this.autoSearchEvent.bind(this);
		MapSearch.Map.I().events.dragStart[MapSearch.Map.I().events.dragStart.length] = this.autoSearchEventClear.bind(this);
	},
	parseQueryString: function(){
		this.query = document.location.search.toQueryParams();
		$H(this.query).each(function(iter){
			if(this.Params[iter.key] != undefined && this.Params[iter.key] != null && iter.key != 'mls'){
				this.Params[iter.key] = iter.value;
				this.runUpdateParams = true;
			} else if(iter.key == 'mls'){
				MapSearch.Search.SingleProperty.I().setMLS(iter.value);
			}
		}.bind(this));
		this.updateSearchItems();
		MapSearch.Search.SingleProperty.I().search();
	},
	updateSearchItems: function(){
		if(this.runUpdateParams){
			this.GUI.Panels.Search.items.propType.value = this.Params.propertyType;
			this.GUI.Panels.Search.items.priceMin.value = this.Params.priceMin;
			this.GUI.Panels.Search.items.priceMax.value = this.Params.priceMax;
			this.GUI.Panels.Search.items.beds.value = this.Params.beds;
			this.GUI.Panels.Search.items.baths.value = this.Params.baths;
			this.GUI.Panels.Search.items.minSQFT.value = this.Params.sqftMin;
			this.GUI.Panels.Search.items.maxSQFT.value = this.Params.sqftMax;
			this.searchEvent();
		}
	},
	orderEvent: function(pEvent){
		if (this.Results.length > 0) {
			this.Params.offset = 0;
			this.pageing = true;
			this.searchEvent(pEvent);
		}
	},
	pageEvent: function(pEvent){
		var limit = Number(this.GUI.Panels.Search.items.limit.getValue());
		if(limit != this.Params.limit){
			//Reset Paging. They changed there limit to show per page.
			this.Params.offset = 0;
			this.searchEvent(pEvent);
		} else if(this.Results.length == 0){
			this.searchEvent(pEvent);
		} else {
			//Continue Paging
			this.pageing = true;
			var element = Event.element(pEvent);
			if(element == this.GUI.Panels.Search.items.pagePrev){
				//Page Prev
				if((this.Params.offset - limit) < 0){
					this.Params.offset = 0;
				} else {
					this.Params.offset -= limit;
				}
				this.searchEvent(pEvent);
			} else {
				//Page Next
				this.Params.offset += limit;
				this.searchEvent(pEvent);
			}
		}
	},
	autoSearchEvent: function(){
		if(this.AutoSearchTimer != null){
			clearTimeout(this.AutoSearchTimer);
		}
		if (MapSearch.Config.Search.Auto) {
			this.AutoSearchTimer = setTimeout(this.searchEvent.bind(this), 1000);
		}
	},
	autoSearchEventClear: function(){
		if(this.AutoSearchTimer != null){
			clearTimeout(this.AutoSearchTimer);
		}
		this.AutoSearchTimer = null;
	},
	searchEvent: function(pEvent){
		if(!MapSearch.Config.Search.Enabled){
			alert(MapSearch.Config.GUI.MSGs.SearchDisabled);
			return;
		}
		this.Params.propertyType = this.GUI.Panels.Search.items.propType.getValue();
		this.Params.priceMin = this.GUI.Panels.Search.items.priceMin.getValue();
		this.Params.priceMax = this.GUI.Panels.Search.items.priceMax.getValue();
		this.Params.beds = this.GUI.Panels.Search.items.beds.getValue();
		this.Params.baths = this.GUI.Panels.Search.items.baths.getValue();
		this.Params.sqftMin = this.GUI.Panels.Search.items.minSQFT.getValue().replace(',', '').replace("'", '').replace('"', '');
		this.Params.sqftMax = this.GUI.Panels.Search.items.maxSQFT.getValue().replace(',', '').replace("'", '').replace('"', '');
		this.Params.limit = this.GUI.Panels.Search.items.limit.getValue();
		this.Params.order = this.GUI.Panels.Search.items.sort.getValue();
		
		if(this.GUI.Panels.Search.searchOptionsWindow.created){
			//this.GUI.Panels.Search.getSearchOptionItems();
			this.Params.owner_only = this.GUI.Panels.Search.items.owner_only.checked == true ? 1 : '';
			this.Params.New_Property = this.GUI.Panels.Search.items.New_Property.checked == true ? 30 : '';
			this.Params.WithPics = this.GUI.Panels.Search.items.WithPics.checked == true ? 1 : '';
			this.Params.Virtual_Tour = this.GUI.Panels.Search.items.Virtual_Tour.checked == true ? 1 : '';
			this.Params.video = this.GUI.Panels.Search.items.video.checked == true ? 1 : '';
		}
		
		this.Params.wkt = null;
		this.Params.areaWKT = false;
		
		if (MapSearch.SearchArea.AreaManager.I().getSearchPolygonWKT() != '' && MapSearch.SearchArea.AreaManager.I().getSearchPolygonWKT() != null) {
			this.Params.areaWKT = true;
			this.Params.wkt = MapSearch.SearchArea.AreaManager.I().getSearchPolygonWKT();
		} else {
			try {
				//Got to Try Catch this because IE has desided to fire events out of order.
				var polygons = MapSearch.GUI.Base.I().Tools.PanPoly.Polygons;
				polygons.each(function(iter){
					var temp = new Array();
					for(var i = 0; i<iter.getVertexCount(); i++){
						temp[temp.length] = {
							Latitude: iter.getVertex(i).lat(),
							Longitude: iter.getVertex(i).lng()
						}
					}
					if(this.Params.wkt == null){
						this.Params.wkt = $WKT(temp);
					} else {
						this.Params.wkt += '|'+ $WKT(temp);
					}
				}.bind(this));
			} catch (e){}
		}
		
		
		
		if (this.pageing === false) {
			var NE = this.Map.getNorthEast();
			var SW = this.Map.getSouthWest();
			var TL = {
				Latitude: NE.Lat,
				Longitude: SW.Long
			};
			var TR = {
				Latitude: NE.Lat,
				Longitude: NE.Long
			};
			var BR = {
				Latitude: SW.Lat,
				Longitude: NE.Long
			};
			var BL = {
				Latitude: SW.Lat,
				Longitude: SW.Long
			};
			this.Params.bounds = $WKT(new Array(TL, TR, BR, BL));
			
			this.Params.offset = 0;
		}
		this.pageing = false;
		
		this.searchQueue.addSearch(this.Params);
	},
	searchSuccess: function(response, json){
		this.Results.clear();
		try{
			var body = response.responseText.evalJSON();
			var length = body.property.length;
			this.GUI.Status.postSearchResults(length);
			if (length > 0) {
				this.GUI.Status.setMapStatus(MapSearch.Config.GUI.MSGs.MapPlotting);
				body.property.each(function(prop){
					var ignore = false;
					MapSearch.Search.SingleProperty.I().Properties.each(function(iter){
						if(iter.details.pid == prop.pid){
							ignore = true
							throw $break;
						}
					})
					if (!ignore) {
						var prop = this.Results.createProperty(prop);
					}
				}.bind(this));
				this.Results.displayIcons();
				this.Results.displayList();
				
				
				$$('#SearchResultsTabAreaResults div.MapSearchSearchResult').each(function(iter){
					//Had to go old school. Prototype failed me with the event management. Kept firing the last that should have been fired.
					iter.onmouseover = function(event){
						this.resultMouseOver(iter);
					}.bind(this)
				}.bind(this));
				
				
				$$('#SearchResultsTabAreaResults div.MapSearchSearchResult>table').each(function(iter){
					//Had to go old school. Prototype failed me with the event management. Kept firing the last that should have been fired.
					iter.onmouseover = function(event){
						this.resultMouseOverTable(iter);
					}.bind(this)
				}.bind(this));
				
				
				
				if(this.Params.offset == 0){
					this.GUI.Panels.Search.items.page.innerHTML = '1';
				} else {
					var page = this.Params.offset/this.Params.limit + 1;
					this.GUI.Panels.Search.items.page.innerHTML = page;
				}
				
				try{
					//MapSearch.Search.SingleProperty.I().Properties.delIcons();
					//MapSearch.Search.SingleProperty.I().Properties.displayIcons();
				} catch(e){}
			} else {
				this.GUI.Panels.Search.items.page.innerHTML = '0';
				this.Results.clearList();
				this.GUI.Status.postSearchResults(0);
			}
		} catch(e){
			this.GUI.Panels.Search.items.page.innerHTML = '0';
			this.Results.clearList();
			this.GUI.Status.postSearchResults(0);
		}
	},
	searchFail: function(response, json){
		if (this.searchQueue.hasQueueItems()) {
			this.searchQueue.search();
		} else {
			this.GUI.Status.postSearchResults(0);
			this.Results.clear();
			this.GUI.Panels.Search.items.page.innerHTML = '0';
		}
	},
	resultMouseOver: function(element){
		try{
			var pid = element.attributes['pid'].nodeValue;
			var property = this.Results.find(function(prop){if(prop.details.pid == pid){return true;}});
			if(property){property.pushpin.showWindow();}
		} catch(e){}
	},
	resultMouseOverTable: function(element){
		var element = element.parentNode;
		try{
			var pid = element.attributes['pid'].nodeValue;
			var property = this.Results.find(function(prop){if(prop.details.pid == pid){return true;}});
			if(property){property.pushpin.showWindow();}
		} catch(e){}
		
	}
});

MapSearch.Search.SearchQueue = Class.create({
	initialize: function(successCallback, failCallback){
		this.queue = new Array();
		this.successCallback = successCallback;
		this.failCallback = failCallback;
		this.isSearching = false;
	},
	hasQueueItems: function(){
		if (this.queue.length > 0){
			return true;
		} else {
			return false;
		}
	},
	addSearch: function(params){
		var temp = {}
		Object.extend(temp, params);
		this.queue[this.queue.length] = temp;
		if(this.queue.length == 1 && !this.isSearching){
			this.search();
		}
	},
	search: function(){
		if (!MapSearch.Config.Search.Auto) {
			MapSearch.GUI.Base.I().Status.toggleMapStatus(true);
			MapSearch.GUI.Base.I().Status.setMapStatus(MapSearch.Config.GUI.MSGs.MapSearch);
		} else {
			MapSearch.GUI.Base.I().Status.toggleSearchingControl(true);
		}
		MapSearch.GUI.Base.I().Status.postSearchResultsMsg('<img src="/images/system/map_search/load_small.gif" /> Searching...');
		
		this.isSearching = true;
		var params = this.queue[this.queue.length-1];
		this.queue = new Array();
		var options = { 
			method: 'post',
			parameters: params,
			onSuccess: function(response, json){this.__searchSuccess(response, json);}.bind(this),
			onFailure: function(response, json){this.__searchFail(response, json);}.bind(this)
		};
		var myAjax = new Ajax.Request('/map_search/search/', options);
	},
	__searchSuccess: function(response, json){
		this.isSearching = false;
		if (this.queue.length >= 1) {
			this.search();
		} else {
			this.successCallback(response, json);
			if (!MapSearch.Config.Search.Auto) {
				MapSearch.GUI.Base.I().Status.toggleMapStatus(false);
			} else {
				MapSearch.GUI.Base.I().Status.toggleSearchingControl(false);
			}
		}
	},
	__searchFail: function(response, json){
		this.isSearching = false;
		if (this.queue.length >= 1) {
			this.search();
		} else {
			this.failCallback(response, json);
			if (!MapSearch.Config.Search.Auto) {
				MapSearch.GUI.Base.I().Status.toggleMapStatus(false);
			} else {
				MapSearch.GUI.Base.I().Status.toggleSearchingControl(false);
			}
		}
	}
});

MapSearch.Search.Favorites = Class.create({
	initialize: function(){
		this.Results = new MapSearch.Property.Collection(MapSearch.Property.Types.Favorites);
		this.request();
	},
	request: function(){
		var options = { 
			method: 'post',
			parameters: {},
			onSuccess: function(response, json){this.searchSuccess(response, json);}.bind(this),
			onFailure: function(response, json){this.searchFail(response, json);}.bind(this)
		};
		var myAjax = new Ajax.Request('/map_search/favorites/', options);
	},
	searchSuccess: function(response, json){
		try{
			var body = response.responseText.evalJSON();
			if(body.property != null){
				this.Results.clear();
				body.property.each(function(prop){
					var prop = this.Results.createProperty(prop);
				}.bind(this));
				this.Results.displayIcons();
				this.Results.displayList();
				
				$$('#FavoritesTabArea div.MapSearchSearchResult').each(function(iter){
					iter.onmouseover = function(event){
						this.resultMouseOver(iter);
					}.bind(this)
				}.bind(this));
			}
		} catch(e){}
		
		setTimeout(function(){this.request();}.bind(this), 17000);
	},
	searchFail: function(response, json){
		this.Results.clear();
		setTimeout(function(){this.request();}.bind(this), 17000);
	},
	resultMouseOver: function(element){
		try{
			var pid = element.attributes['pid'].nodeValue;
			var property = this.Results.find(function(prop){if(prop.details.pid == pid){return true;}});
			if(property){property.pushpin.showWindow();}
		} catch(e){}
	}
});


MapSearch.Search.Favorites.Instance = null;
MapSearch.Search.Favorites.I = function(){
	if (MapSearch.Search.Favorites.instance == null){MapSearch.Search.Favorites.instance = new MapSearch.Search.Favorites();}
	return MapSearch.Search.Favorites.instance;
}

MapSearch.Search.RecentViewed = Class.create({
	initialize: function(){
		this.Results = new MapSearch.Property.Collection(MapSearch.Property.Types.Viewed);
		this.request();
	},
	request: function(){
		var options = { 
			method: 'post',
			parameters: {},
			onSuccess: function(response, json){this.searchSuccess(response, json);}.bind(this),
			onFailure: function(response, json){this.searchFail(response, json);}.bind(this)
		};
		var myAjax = new Ajax.Request('/map_search/recentlyViewed/', options);
	},
	searchSuccess: function(response, json){
		try{
			var body = response.responseText.evalJSON();
			if(body.property != null){
				this.Results.clear();
				body.property.each(function(prop){
					var ignore = false;
					MapSearch.Search.SingleProperty.I().Properties.each(function(iter){
						if(iter.details.pid == prop.pid){
							ignore = true
							throw $break;
						}
					})
					if (!ignore) {
						var prop = this.Results.createProperty(prop);
					}
				}.bind(this));
				this.Results.displayIcons();
				this.Results.displayList();
				
				$$('#RecentlyViewedTabArea div.MapSearchSearchResult').each(function(iter){
					iter.onmouseover = function(event){
						this.resultMouseOver(iter);
					}.bind(this)
				}.bind(this));
			}
		} catch(e){}
		
		setTimeout(function(){this.request();}.bind(this), 15000);
	},
	searchFail: function(response, json){
		this.Results.clear();
		setTimeout(function(){this.request();}.bind(this), 15000);
	},
	resultMouseOver: function(element){
		try{
			var pid = element.attributes['pid'].nodeValue;
			var property = this.Results.find(function(prop){if(prop.details.pid == pid){return true;}});
			if(property){property.pushpin.showWindow();}
		} catch(e){}
	}
});


MapSearch.Search.RecentViewed.Instance = null;
MapSearch.Search.RecentViewed.I = function(){
	if (MapSearch.Search.RecentViewed.instance == null){MapSearch.Search.RecentViewed.instance = new MapSearch.Search.RecentViewed();}
	return MapSearch.Search.RecentViewed.instance;
}


MapSearch.Search.SingleProperty = Class.create({
	initialize: function(){
		this.mls = null;
		this.Properties = new MapSearch.Property.Collection(MapSearch.Property.Types.SingleProperty);
	},
	setMLS: function(mlsNumber){
		this.mls = mlsNumber;
	},
	search: function(){
		if(this.mls != null){
			var options = { 
				method: 'post',
				parameters: {mls:this.mls},
				onSuccess: function(response, json){this.__searchSuccess(response, json);}.bind(this),
				onFailure: function(response, json){this.__searchFail(response, json);}.bind(this)
			};
			var myAjax = new Ajax.Request('/map_search/search/', options);
		}
	},
	__searchSuccess: function(response, json){
		var body = response.responseText.evalJSON();
		if (body.property.length > 0) {
			body.property.each(function(prop){
				var prop = this.Properties.createProperty(prop);
			}.bind(this));
			
			this.Properties.displayIcons();
			
			try{
				var bounds = new GLatLngBounds();
				this.Properties.each(function(iter){
					bounds.extend(iter.point.getObject());
				}.bind(this));
				if(MapSearch.Config.Search.SignleProperty.Zoom != null){
					MapSearch.Map.I().map.setCenter(bounds.getCenter(), MapSearch.Config.Search.SignleProperty.Zoom);
				} else {
					MapSearch.Map.I().map.setCenter(bounds.getCenter(), MapSearch.Map.I().map.getBoundsZoomLevel(bounds));
				}
			} catch(e){}
		} else {
			alert('Sorry but the MLS Number provided cannot be found.');
		}
	},
	__searchFail: function(response, json){
		alert('Sorry but the MLS Number provided cannot be found.');
	}
});
MapSearch.Search.SingleProperty.Instance = null;
MapSearch.Search.SingleProperty.I = function(){
	if (MapSearch.Search.SingleProperty.instance == null){MapSearch.Search.SingleProperty.instance = new MapSearch.Search.SingleProperty();}
	return MapSearch.Search.SingleProperty.instance;
}/**
 * Manages a Collection of Property Objs
 * 
 * Used for Paging and Sorting
 * 
 * @author Nick Verbeck
 * @since 6/4/2008
 */
MapSearch.Property = {}
MapSearch.Property.Types = {}
MapSearch.Property.Types.Results = 1;
MapSearch.Property.Types.Favorites = 2;
MapSearch.Property.Types.Viewed = 3;
MapSearch.Property.Types.SingleProperty = 4;

MapSearch.Property.Collection = Class.create(Enumerable, {
	initialize: function(type){
		this.properties = new Array();
		this.length = 0;
		this.cursor = 0;
		this.type = type;
	},
	concat: function(properties){
		this.properties = this.properties.concat(properties);
		this.length = this.properties.length;
	},
	append: function(property){
		this.properties[this.properties.length] = property;
		this.length = this.properties.length;
	},
	clear: function(){
		this.properties.each(function(iter){iter.del();});
		this.properties = new Array();
		this.length = 0;
		this.cursor = 0;
	},
	_each: function(iterator){
		this.properties.each(iterator);
	},
	createProperty: function(data){
		var property = new MapSearch.Property.Property(data, this.type)
		if (property.details.LatLong.Latitude != 0 && property.details.LatLong.Longitude != 0) {
			property.propertyNumber = this.properties.length + 1;
			
			this.append(property);
			return property;
		}
	},
	displayIcons: function(){
		this.properties.each(function(iter){
			iter.getPushpin().add();
		});
	},
	delIcons: function(){
		this.properties.each(function(iter){
			iter.getPushpin().del();
		});
	},
	showIcons: function(){
		this.properties.each(function(iter){
			iter.getPushpin().show();
		});
	},
	hideIcons: function(){
		this.properties.each(function(iter){
			iter.getPushpin().hide();
		});
	},
	displayList: function(){
		var html = new StringBuilder();
		this.properties.each(function(iter){
			try{
				html.append(iter.getListHTML());
			} catch(e){}
		});
		
		try{
			var index = 0;
			if(this.type == MapSearch.Property.Types.Results){
				index = 0;
			} else if (this.type == MapSearch.Property.Types.Favorites){
				index = 1;
			} else if (this.type == MapSearch.Property.Types.Viewed){
				index = 2;
			}
			MapSearch.GUI.Base.I().Panels.Search.accordians.items[index].setHTML(html.toString());
		} catch(e){
		}
	},
	clearList: function(){
		try{
			var index = 0;
			if(this.type == MapSearch.Property.Types.Results){
				index = 0;
			} else if (this.type == MapSearch.Property.Types.Favorites){
				index = 1;
			} else if (this.type == MapSearch.Property.Types.Viewed){
				index = 2;
			}
			MapSearch.GUI.Base.I().Panels.Search.accordians.items[index].setHTML('');
		} catch(e){
		}
	}
});

/**
 * Represents a property
 * 
 * Used for a Generic Representation of a Property
 * 
 * @author Nick Verbeck
 * @since 6/4/2008
 */
MapSearch.Property.Property = Class.create({
	initialize: function(details, type){
		this.propertyNumber = null;
		this.pushpin = null;
		this.point = null;
		this.type = type;
		this.isCompanyProperty = false;
		
		this.details = {
			pid: null,
			mls: null,
			ds: null,
			ds_raw: null,
			office: null,
			listing: {
				officeName: null,
				agentName: null
			},
			address: {
				street: {
					number: null,
					direction: null,
					name: null,
					type: null
				},
				unit_no: null,
				city: null,
				state: null,
				zip: null
			},
			LatLong: {
				Latitude: null,
				Longitude: null
			},
			date: {
				added: null,
				updated: null
			},
			info: {
				beds: 0,
				baths: 0,
				baths_full: 0,
				baths_half: 0,
				baths_test: 0,
				price: 0,
				style: '',
				sqft: 0,
				photo_count: 0,
				photo: null
			},
			generalInfo: {
				openhouse: null
			},
			remarks: null,
			name: null,
			is_favorite:false,
			has_permissions: true
		}
		Object.extend(this.details, details || {});
		if(this.details.info.beds == null){
			this.details.info.beds = 0;
		}
		if(this.details.info.baths == null){
			this.details.info.baths = 0;
		}
		if(this.details.listing.officeName == null){
			this.details.listing.officeName = '';
		}
		if(this.details.listing.agentName == null){
			this.details.listing.agentName = '';
		}
		
		try {
			if(this.details.date.added != null){
				this.details.date.added = String(this.details.date.added).toDate('yyyy-mm-dd hh:ii:ss');
			}
		} catch(e){MapSearch.Console.error(e);}
		try {
			if(this.details.date.updated != null){
				this.details.date.updated = String(this.details.date.updated).toDate('yyyy-mm-dd hh:ii:ss');
			}
		} catch(e){MapSearch.Console.error(e);}
		
		var codes = MapSearch.Office.Collection.I().getOfficeCodes();
		if(codes.indexOf(this.details.office) != -1 ){
			this.isCompanyProperty = true;
			switch(this.type){
				case MapSearch.Property.Types.Results:
					if(this.details.generalInfo == 'true'){
						this.iconSet = MapSearch.Config.Icons.Base.myOpenHouse;
					} else if(this.details.date.added >= MapSearch.Config.Dates.propAdded) {
						this.iconSet = MapSearch.Config.Icons.Base.myNewProp;
					} else if(this.details.date.added >= MapSearch.Config.Dates.propUpdated) {
						this.iconSet = MapSearch.Config.Icons.Base.myUpdatedProp;
					} else {
						this.iconSet = MapSearch.Config.Icons.Base.myOldProp;
					}
					break;
				case MapSearch.Property.Types.Favorites:
					this.iconSet = MapSearch.Config.Icons.Base.favorites;
					break;
				case MapSearch.Property.Types.Viewed:
					this.iconSet = MapSearch.Config.Icons.Base.viewed;
					break;
				case MapSearch.Property.Types.SingleProperty:
					this.iconSet = MapSearch.Config.Icons.Base.singleProperty;
					break;
			}
		} else {
			switch(this.type){
				case MapSearch.Property.Types.Results:
					if(this.details.generalInfo == 'true'){
						this.iconSet = MapSearch.Config.Icons.Base.openHouse;
					} else if(this.details.date.added >= MapSearch.Config.Dates.propAdded) {
						this.iconSet = MapSearch.Config.Icons.Base.newProp;
					} else if(this.details.date.added >= MapSearch.Config.Dates.propUpdated) {
						this.iconSet = MapSearch.Config.Icons.Base.updatedProp;
					} else {
						this.iconSet = MapSearch.Config.Icons.Base.oldProp;
					}
					break;
				case MapSearch.Property.Types.Favorites:
					this.iconSet = MapSearch.Config.Icons.Base.favorites;
					break;
				case MapSearch.Property.Types.Viewed:
					this.iconSet = MapSearch.Config.Icons.Base.viewed;
					break;
				case MapSearch.Property.Types.SingleProperty:
					this.iconSet = MapSearch.Config.Icons.Base.singleProperty;
					break;
			}
		}
	},
	/**
	 * Returns a Well Formated Street Address
	 * 
	 * @since 6/6/2008
	 * @author Nick Verbeck
	 */
	getStreetAddress: function(){
		var street = (this.details.address.street.number != null ? this.details.address.street.number : '');
		if(this.details.address.street.direction != '' && this.details.address.street.direction != null)
			street += " "+ this.details.address.street.direction;
		street += " "+ (this.details.address.street.name != null ? this.details.address.street.name : '') +" "+ (this.details.address.street.type != null ? this.details.address.street.type : '');
		if(this.details.address.unit_number != '' && this.details.address.unit_number != null)
			street += " #"+ this.details.address.unit_number;
		street = street.toProperCase();
		return street;
	},
	getStreetAddres: function(){
		return this.getStreetAddress();
	},
	/**
	 * Returns a Full Street Address
	 * 
	 * @since 6/6/2008
	 * @author Nick Verbeck
	 */
	getAddress: function(){
		var address = this.getStreetAddres() +' '+  this.getCityState();
		return address;
	},
	
	getCityState: function(){
		var address = (this.details.address.city != null ? this.details.address.city : '');
		address += (this.details.address.state != null && this.details.address.city ? ', ' : '');
		address += (this.details.address.state != null ? this.details.address.state : '');
		return address;
	},
	calcDays: function(){
		if(this.details.date.added != null){
			try{
				var today = new Date();
				var diff = today.getTime() - this.details.date.added.getTime();
				var days = Math.ceil(diff/(1000*60*60*24));
				return days;
			} catch(e){
				return 0;
			}
		} else {
			return 0;
		}
	},
	getPushpinHTML: function(){
		var streetAddress = this.getStreetAddres();
		if(this.details.has_permissions == 'false'){
			streetAddress = this.details.name;
		}
		
		var tab1Vals = {
			image: this.details.info.photo ? this.details.info.photo + "/maxheight/110/maxwidth/150/" : "http://74.63.137.149/pics/property/"+this.details.pid+"/0/maxheight/110/maxwidth/150/",
			photocount:this.details.info.photo_count,
			price:this.details.info.price,
			beds:this.details.info.beds ? this.details.info.beds : 0,
			baths:this.details.info.baths ? this.details.info.baths : 0,
			sqft:this.details.info.sqft,
			streetAddress: streetAddress,
			cityState: this.getCityState(),
			days: this.calcDays(),
			pid: this.details.pid,
			property_id: this.details.mls,
			status: this.details.info.status ? this.details.info.status : 'N/A',
			office_name: this.details.listing.officeName.toProperCase(),
			agent_name: this.details.listing.agentName.toProperCase()
		}
		
		
		
		if(this.isCompanyProperty){
			switch(this.type){
				case MapSearch.Property.Types.Favorites:
					var tab1 = MapSearch.Template.Bubble.Client.Favorite.evaluate(tab1Vals);
					break;
				case MapSearch.Property.Types.Results:
					var tab1 = MapSearch.Template.Bubble.Client.Result.evaluate(tab1Vals);
					break;
				default:
					var tab1 = MapSearch.Template.Bubble.Client.Result.evaluate(tab1Vals);
					break;
			}
		} else {
			switch(this.type){
				case MapSearch.Property.Types.Favorites:
					var tab1 = MapSearch.Template.Bubble.Generic.Favorite.evaluate(tab1Vals);
					break;
				case MapSearch.Property.Types.Results:
					var tab1 = MapSearch.Template.Bubble.Generic.Result.evaluate(tab1Vals);
					break;
				default:
					var tab1 = MapSearch.Template.Bubble.Generic.Result.evaluate(tab1Vals);
					break;
			}
		}
		var tab1 = MapSearch.Template.Bubble.Base.evaluate({content:tab1, price:this.details.info.price,streetAddress: streetAddress, pid: this.details.pid});
		var tab2 = MapSearch.Template.Bubble.Base.evaluate({content:MapSearch.Template.Bubble.Remarks.evaluate({remarks:this.details.remarks}), price:this.details.info.price,streetAddress: streetAddress, pid: this.details.pid});
		var tab3Vals = {
			pid: this.details.pid, 
			zipcode:this.details.address.zip, 
			lat:this.details.LatLong.Latitude, 
			lng:this.details.LatLong.Longitude, 
			fullStreetAddress: this.getAddress()
		}
		var tab3 = MapSearch.Template.Bubble.Base.evaluate({content:MapSearch.Template.Bubble.Links.evaluate(tab3Vals), price:this.details.info.price,streetAddress: streetAddress, pid: this.details.pid});
		
		if(MapSearch.Config.Urls.Base.propertyPicServer != null && this.details.info.photo_count > 0){
			var tab4 = '<tr><td class="content" colspan="3"><div class="contentContainer"><table><tr>';
			for(var i=1; i<=this.details.info.photo_count; i++){
				var imgUrl = MapSearch.Config.Urls.Base.propertyPicServer +'/pics/property/'+ this.details.pid +'/'+ (i-1) +'/';
				tab4 += '<td><img class="LazyLoadImg" src="/images/system/map_search/small_image_load.gif" imageSrc="'+ imgUrl +'crop/65,65/" onMouseOver="MapSearch.Base.I().pushpinBubbleImageRollover(\''+ imgUrl +'\', this);" onMouseOut="MapSearch.Base.I().pushpinBubbleImageRolloff();" style="cursor:pointer; widht:65px; height:65px;" /></td>';
				if(i%5 == 0){
					tab4 += '</tr><tr>';
				}
			}
			tab4 += '</tr></table></div></td></tr><tr><td class="misc" colspan="3"><a href="/property/'+ this.details.pid +'/" target="_Blank">View Property Details</a></td></tr>';
			tab4 = MapSearch.Template.Bubble.Base.evaluate({content:tab4, price:this.details.info.price,streetAddress: streetAddress, pid: this.details.pid});
			return new Array(new GInfoWindowTab('Details', tab1),
			new GInfoWindowTab('Photos', tab4), 
			new GInfoWindowTab('Remarks', tab2),
			new GInfoWindowTab('Tools', tab3));
		} else {
			return new Array(new GInfoWindowTab('Details', tab1), 
			new GInfoWindowTab('Remarks', tab2),
			new GInfoWindowTab('Tools', tab3));
		}
		
	},
	getListHTML: function(){
		var vals = {
			icon: this.iconSet.result,
			number: this.propertyNumber,
			street: this.getStreetAddres(),
			cityState: this.getCityState(),
			zip: this.details.address.zip,
			pid: this.details.pid,
			idx_logo: '',
			property_id: this.details.mls,
			status: this.details.info.status ? this.details.info.status : 'N/A',
			office_name: this.details.listing.officeName.toProperCase()
		}
		
		if(this.details.has_permissions == 'false'){
			vals.street = this.details.name;
		}
		
		if(MapSearch.Config.IDX[this.details.ds_raw] != undefined && MapSearch.Config.IDX[this.details.ds_raw] != null){
			vals.idx_logo = MapSearch.Config.IDX[this.details.ds_raw];
		}
		if(this.isCompanyProperty){
			switch(this.type){
				case MapSearch.Property.Types.Favorites:
					var html = MapSearch.Template.Accordian.Favorite.Client.evaluate(vals);
					break;
				case MapSearch.Property.Types.Results:
					var html = MapSearch.Template.Accordian.Search.Client.evaluate(vals);
					break;
				default:
					var html = MapSearch.Template.Accordian.Search.Client.evaluate(vals);
					break;
			}
		} else {
			switch(this.type){
				case MapSearch.Property.Types.Favorites:
					var html = MapSearch.Template.Accordian.Favorite.Generic.evaluate(vals);
					break;
				case MapSearch.Property.Types.Results:
					var html = MapSearch.Template.Accordian.Search.Generic.evaluate(vals);
					break;
				default:
					var html = MapSearch.Template.Accordian.Search.Generic.evaluate(vals);
					break;
			}
		}
		return html;
	},
	getPushpin: function(){
		if(this.pushpin == null){
			var html = this.getPushpinHTML();
			//html = new Array(new GInfoWindowTab('Desc', html), new GInfoWindowTab('Test','Test Content'));
			this.point = new MapSearch.Map.LatLong(this.details.LatLong.Latitude, this.details.LatLong.Longitude);
			this.pushpin = MapSearch.Map.I().createPushpin(this.point.getObject(), html, this.iconSet);
		}
		return this.pushpin;
	},
	del: function(){
		if(this.pushpin != null){
			this.pushpin.del();
		}
		//TODO: Remove from List View
	}
});
/**
 * @author nick
 */
MapSearch.Base = Class.create();
MapSearch.Base.Instance = null;
MapSearch.Base.I = function(){
	if (MapSearch.Base.instance == null){
		MapSearch.Base.instance = new MapSearch.Base();
	}
	return MapSearch.Base.instance;
}
MapSearch.Base.prototype = {
	initialize: function() {
		MapSearch.Map.InitilizeCallback = function(){this.mapLoaded();}.bind(this)
		this.GUI = MapSearch.GUI.Base.I();
		this.Map = MapSearch.Map.I();
		this.isMapLoaded = false;
		this.pushpinBubbleRollover = null;
	},
	mapLoaded: function(){
		var icons = new Array();
		MapSearch.Office.Collection.I().each(
			function(iter){
				iter.getPushpin().add();
			}.bind(this)
		);
		
		this.isMapLoaded = true;
		MapSearch.Search.I();
	},
	addOffice: function(office){
		MapSearch.Office.Collection.I().push(office);
		if(this.isMapLoaded){
			office.getPushpin().add();
		}
	},
	setIconSet: function(set, icons){
		Object.extend(MapSearch.Config.Icons.Base[set], icons);
	},
	setPOIIconSet: function(set, icons){
		Object.extend(MapSearch.Config.Icons.POI[set], icons);
	},
	pushpinShowStreetview: function(lat,lng){
		MapSearch.Map.Streetview.I().show(lat, lng);
	},
	pushpinShowStats: function(zipcode){
		MapSearch.GUI.Panels.Manager.I().changeItem(MapSearch.GUI.Base.I().Panels.Stats);
		MapSearch.GUI.Base.I().Panels.Stats.items.zipcode.value = zipcode;
		MapSearch.GUI.Base.I().Panels.Stats.search();
	},
	pushpinDrivingDirections: function(streetAddress){
		var center = MapSearch.Map.I().getCenter();
		var directionsWindow = window.open('/map_search/generic/directions/?action=directions&to='+ streetAddress +'&lat='+ center.lat() +'&lng='+ center.lng(), 'directionsWindow', 'width=850,height=650,resizable=1,scrollbars=0,toolbar=0,location=0,directories=0,status=0,menubar=0');
		if(window.focus){
			directionsWindow.focus();
		}
	},
	pushpinBubbleImageRollover: function(url, element){
		element = $(element);
		if(this.pushpinBubbleRollover == null){
			this.pushpinBubbleRollover = document.createElement('div');
			this.pushpinBubbleRollover.style.border = '1px solid #333';
			this.pushpinBubbleRollover.style.backgroundColor = '#fff';
			this.pushpinBubbleRollover.style.position = 'absolute';
			this.pushpinBubbleRollover.style.display = 'none';
			document.body.appendChild(this.pushpinBubbleRollover);
		}
		this.pushpinBubbleRollover.innerHTML = '<img src="'+ url +'/maxwidth/250/maxheight/250/" />';
		var pos = jUtilities.Graphics.getAbsolutePosition(element);
		
		this.pushpinBubbleRollover.style.top = (pos.y+element.getHeight())+'px';
		this.pushpinBubbleRollover.style.left = (pos.x+(element.getWidth()/2)-125)+'px';
		this.pushpinBubbleRollover.style.display = '';
	},
	pushpinBubbleImageRolloff: function(element){
		if (this.pushpinBubbleRollover != null) {
			this.pushpinBubbleRollover.style.display = 'none';
		}
	}
}/**
 * @author nick
 */
MapSearch.GUI = {
	Theme: {
		Red: {
			Search: {
				active: '/images/system/map_search/Red_Search_Active.gif',
				inactive: '/images/system/map_search/Red_Search_Inactive.gif'
			},
			POI: {
				active: '/images/system/map_search/Red_POI_Active.gif',
				inactive: '/images/system/map_search/Red_POI_Inactive.gif'
			},
			Stats: {
				active: '/images/system/map_search/Red_Stats_Active.gif',
				inactive: '/images/system/map_search/Red_Stats_Inactive.gif'
			},
			images: {
				searching: '/images/system/map_search/red_search.gif',
				searchingI: '/images/system/map_search/Red/red_search_i.gif'
			},
			mapControls: {
				leftEndCap: '/images/system/map_search/Red/leftend.png',
				rightEndCap: '/images/system/map_search/Red/rightend.png',
				gradient: '/images/system/map_search/Red/gradient.png',
				arrow: '/images/system/map_search/Red/arrow.png'
			},
			colors: {
				bgcolor: '#8e0309',
				text: '#fff'
			}
		},
		Blue: {
			Search: {
				active: '/images/system/map_search/Search_Active.gif',
				inactive: '/images/system/map_search/Search_Inactive.gif'
			},
			POI: {
				active: '/images/system/map_search/POI_Active.gif',
				inactive: '/images/system/map_search/POI_Inactive.gif'
			},
			Stats: {
				active: '/images/system/map_search/Stats_Active.gif',
				inactive: '/images/system/map_search/Stats_Inactive.gif'
			},
			images: {
				searching: '/images/system/map_search/blue_search.gif',
				searchingI: '/images/system/map_search/Blue/blue_search_i.gif'
			},
			mapControls: {
				leftEndCap: '/images/system/map_search/Blue/leftend.png',
				rightEndCap: '/images/system/map_search/Blue/rightend.png',
				gradient: '/images/system/map_search/Blue/gradient.png',
				arrow: '/images/system/map_search/Blue/arrow.png'
			},
			colors: {
				bgcolor: '#2C6B7F',
				text: '#fff'
			}
		},
		Green: {
			Search: {
				active: '/images/system/map_search/Green_Search_Active.gif',
				inactive: '/images/system/map_search/Green_Search_Inactive.gif'
			},
			POI: {
				active: '/images/system/map_search/Green_POI_Active.gif',
				inactive: '/images/system/map_search/Green_POI_Inactive.gif'
			},
			Stats: {
				active: '/images/system/map_search/Green_Stats_Active.gif',
				inactive: '/images/system/map_search/Green_Stats_Inactive.gif'
			},
			images: {
				searching: '/images/system/map_search/green_search.gif',
				searchingI: '/images/system/map_search/Green/green_search_i.gif'
			},
			mapControls: {
				leftEndCap: '/images/system/map_search/Green/leftend.png',
				rightEndCap: '/images/system/map_search/Green/rightend.png',
				gradient: '/images/system/map_search/Green/gradient.png',
				arrow: '/images/system/map_search/Green/arrow.png'
			},
			colors: {
				bgcolor: '#417a26',
				text: '#fff'
			}
		},
		DarkGreen: {
			Search: {
				active: '/images/system/map_search/DarkGreen_Search_Active.gif',
				inactive: '/images/system/map_search/DarkGreen_Search_Inactive.gif'
			},
			POI: {
				active: '/images/system/map_search/DarkGreen_POI_Active.gif',
				inactive: '/images/system/map_search/DarkGreen_POI_Inactive.gif'
			},
			Stats: {
				active: '/images/system/map_search/DarkGreen_Stats_Active.gif',
				inactive: '/images/system/map_search/DarkGreen_Stats_Inactive.gif'
			},
			images: {
				searching: '/images/system/map_search/DarkGreen_search.gif',
				searchingI: '/images/system/map_search/DarkGreen/darkgreen_search_i.gif'
			},
			mapControls: {
				leftEndCap: '/images/system/map_search/DarkGreen/leftend.png',
				rightEndCap: '/images/system/map_search/DarkGreen/rightend.png',
				gradient: '/images/system/map_search/DarkGreen/gradient.png',
				arrow: '/images/system/map_search/DarkGreen/arrow.png'
			},
			colors: {
				bgcolor: '#0D5014',
				text: '#fff'
			}
		},
		Teil: {
			Search: {
				active: '/images/system/map_search/Teil_Search_Active.gif',
				inactive: '/images/system/map_search/Teil_Search_Inactive.gif'
			},
			POI: {
				active: '/images/system/map_search/Teil_POI_Active.gif',
				inactive: '/images/system/map_search/Teil_POI_Inactive.gif'
			},
			Stats: {
				active: '/images/system/map_search/Teil_Stats_Active.gif',
				inactive: '/images/system/map_search/Teil_Stats_Inactive.gif'
			},
			images: {
				searching: '/images/system/map_search/Teil_search.gif',
				searchingI: '/images/system/map_search/Teil/teil_search_i.gif'
			},
			mapControls: {
				leftEndCap: '/images/system/map_search/Teil/leftend.png',
				rightEndCap: '/images/system/map_search/Teil/rightend.png',
				gradient: '/images/system/map_search/Teil/gradient.png',
				arrow: '/images/system/map_search/Teil/arrow.png'
			},
			colors: {
				bgcolor: '#759489',
				text: '#fff'
			}
		},
		Sage: {
			Search: {
				active: '/images/system/map_search/Sage_Search_Active.gif',
				inactive: '/images/system/map_search/Sage_Search_Inactive.gif'
			},
			POI: {
				active: '/images/system/map_search/Sage_POI_Active.gif',
				inactive: '/images/system/map_search/Sage_POI_Inactive.gif'
			},
			Stats: {
				active: '/images/system/map_search/Sage_Stats_Active.gif',
				inactive: '/images/system/map_search/Sage_Stats_Inactive.gif'
			},
			images: {
				searching: '/images/system/map_search/sage_search.gif',
				searchingI: '/images/system/map_search/Sage/sage_search_i.gif'
			},
			mapControls: {
				leftEndCap: '/images/system/map_search/Sage/leftend.png',
				rightEndCap: '/images/system/map_search/Sage/rightend.png',
				gradient: '/images/system/map_search/Sage/gradient.png',
				arrow: '/images/system/map_search/Sage/arrow.png'
			},
			colors: {
				bgcolor: '#a9b39a',
				text: '#000'
			}
		},
		EvenDarkerGreen: {
			Search: {
				active: '/images/system/map_search/EvenDarkerGreen_Search_Active.gif',
				inactive: '/images/system/map_search/EvenDarkerGreen_Search_Inactive.gif'
			},
			POI: {
				active: '/images/system/map_search/EvenDarkerGreen_POI_Active.gif',
				inactive: '/images/system/map_search/EvenDarkerGreen_POI_Inactive.gif'
			},
			Stats: {
				active: '/images/system/map_search/EvenDarkerGreen_Stats_Active.gif',
				inactive: '/images/system/map_search/EvenDarkerGreen_Stats_Inactive.gif'
			},
			images: {
				searching: '/images/system/map_search/EvenDarkerGreen/search.gif',
				searchingI: '/images/system/map_search/EvenDarkerGreen/search_i.gif'
			},
			mapControls: {
				leftEndCap: '/images/system/map_search/EvenDarkerGreen/leftend.png',
				rightEndCap: '/images/system/map_search/EvenDarkerGreen/rightend.png',
				gradient: '/images/system/map_search/EvenDarkerGreen/gradient.png',
				arrow: '/images/system/map_search/EvenDarkerGreen/arrow.png'
			},
			colors: {
				bgcolor: '#063626',
				text: '#ffffff'
			}
		},
		Cream: {
			Search: {
				active: '/images/system/map_search/Cream_Search_Active.gif',
				inactive: '/images/system/map_search/Cream_Search_Inactive.gif'
			},
			POI: {
				active: '/images/system/map_search/Cream_POI_Active.gif',
				inactive: '/images/system/map_search/Cream_POI_Inactive.gif'
			},
			Stats: {
				active: '/images/system/map_search/Cream_Stats_Active.gif',
				inactive: '/images/system/map_search/Cream_Stats_Inactive.gif'
			},
			images: {
				searching: '/images/system/map_search/Cream/search.gif',
				searchingI: '/images/system/map_search/Cream/search_i.gif'
			},
			mapControls: {
				leftEndCap: '/images/system/map_search/Cream/leftend.png',
				rightEndCap: '/images/system/map_search/Cream/rightend.png',
				gradient: '/images/system/map_search/Cream/gradient.png',
				arrow: '/images/system/map_search/Cream/arrow.png'
			},
			colors: {
				bgcolor: '#f58428',
				text: '#ffffff'
			}
		},
		Blueberry: {
			Search: {
				active: '/images/system/map_search/blueberry/Blueberry_Search_Active.gif',
				inactive: '/images/system/map_search/blueberry/Blueberry_Search_Inactive.gif'
			},
			POI: {
				active: '/images/system/map_search/blueberry/Blueberry_POI_Active.gif',
				inactive: '/images/system/map_search/blueberry/Blueberry_POI_Inactive.gif'
			},
			Stats: {
				active: '/images/system/map_search/blueberry/Blueberry_Stats_Active.gif',
				inactive: '/images/system/map_search/blueberry/Blueberry_Stats_Inactive.gif'
			},
			images: {
				searching: '/images/system/map_search/blueberry/search.gif',
				searchingI: '/images/system/map_search/blueberry/search_i.gif'
			},
			mapControls: {
				leftEndCap: '/images/system/map_search/blueberry/leftend.png',
				rightEndCap: '/images/system/map_search/blueberry/rightend.png',
				gradient: '/images/system/map_search/blueberry/gradient.png',
				arrow: '/images/system/map_search/blueberry/arrow.png'
			},
			colors: {
				bgcolor: '#055692',
				text: '#ffffff'
			}
		}
	}
}

/*
 * Base GUI
 */
MapSearch.GUI.Base = Class.create();
MapSearch.GUI.Base.Instance = null;
MapSearch.GUI.Base.I = function(){
	if(MapSearch.GUI.Base.Instance == null){MapSearch.GUI.Base.Instance = new MapSearch.GUI.Base();}
	return MapSearch.GUI.Base.Instance;
}
MapSearch.GUI.Base.prototype = {
	initialize: function() {
		this.Status = new MapSearch.GUI.Status();
		
		this.Status.togglePageLoading(true);
		this.Status.setPageStatus(MapSearch.Config.GUI.MSGs.Loading);
		
		this.Panels = {
			Search: new MapSearch.GUI.Panels.Search(),
			POI: new MapSearch.GUI.Panels.POI(),
			Stats: new MapSearch.GUI.Panels.Stats()
		}
		
		this.Tools = {
			Legend: new MapSearch.GUI.Legend(),
			ShareSearch: null,
			Print: null,
			Help: null,
			PanPoly: null
		}
		
		Event.observe(window, 'load', this.onLoad.bindAsEventListener(this));
	},
	onLoad: function(pEvent){
		this.Status.setPageStatus(MapSearch.Config.GUI.MSGs.BindingInterface);
		
		//Status Loads
		this.Status.onLoad(pEvent);
		
		//Panel Loads
		this.Panels.Search.onLoad(pEvent);
		this.Panels.POI.onLoad(pEvent);
		this.Panels.Stats.onLoad(pEvent);
		
		this.Status.togglePageLoading(false);
		
		//Tool Loads
		//this.Tools.Legend = $('Legend');
		//this.Tools.ShareSearch = $('SendViaEmail');
		this.Tools.Print = $('Print');
		this.Tools.Help = $('Help');
		this.Tools.Legend.onLoad(pEvent);
		this.Tools.PanPoly = new MapSearch.GUI.ToolManager();
		
		Event.observe(this.Tools.Help, 'click', this._helpClick.bindAsEventListener(this));
		Event.observe(this.Tools.Print, 'click', this._print.bindAsEventListener(this));
	},
	_helpClick: function(pEvent){
		url = '/help/map_search/';
		var fullSearchWindow = window.open(url, 'HelpWindow', 'width=700,height=600,resizable=0,scrollbars=0,toolbar=0,location=0,directories=0,status=0,menubar=0');
		if(window.focus){
			fullSearchWindow.focus();
		}
	},
	_print: function(pEvent){
		var printWindow = window.open('/map_search/generic/print/?action=print', 'printWindow', 'width=850,height=650,resizable=1,scrollbars=0,toolbar=0,location=0,directories=0,status=0,menubar=0');
		if(window.focus){
			printWindow.focus();
		}
	}
}
/* 
 * Legend 
 */

MapSearch.GUI.Legend = Class.create({
	initialize: function(){
		this.tool = null;
		this.window = null;
	},
	onLoad: function(pEvent){
		this.tool = $('Legend');
		this.window = new MapSearch.GUI.Window.Window('Legend');
		var html = '<table><tr><td colspan="2" style="font-weight:bold; font-size:14px;">Property Icons</td></tr>';
		
		$H(MapSearch.Config.Icons.Base).each(function(iter){
			var icon = iter.value.result;
			var name = iter.value.name.evaluate({company:MapSearch.Config.Company});
			html += '<tr><td><img src="'+ icon +'" /></td><td>'+ name +'</td></tr>';
		});
		html += '<tr><td colspan="2">&nbsp;</td></tr><tr><td colspan="2" style="font-weight:bold; font-size:14px;">POI Icons</td></tr>';
		$H(MapSearch.Config.Icons.POI).each(function(iter){
			var icon = iter.value.mid.icon;
			var name = iter.value.name;
			html += '<tr><td><img src="'+ icon +'" /></td><td>'+ name +'</td></tr>';
		});
		html += '</table>'
		
		this.window.setHTML(html);
		
		Event.observe(this.tool, 'click', this.click.bindAsEventListener(this));
	},
	click: function(pEvent){
		this.window.showCenter();
		MapSearch.EventTracking.LegendEvent();
	}
});

/*
 * Advanced Search
 */

MapSearch.GUI.AdvancedSearch = Class.create({
	initialize: function(){
	}
});

/*
 * Tool Manager
 */

MapSearch.GUI.ToolManager = Class.create({
	initialize: function(){
		MapSearch.Map.I().regEventCallback('rightClick', function(event){this._rightClick(event);}.bind(this));
		MapSearch.Map.I().regEventCallback('click', function(event){this._click(event);}.bind(this));
		
		this.Polygons = new Array();
		this.PolygonTool = $('PolygonTool');
		this.ResetPolygonsTool = $('ResetPolygonsTool');
		this.ResetSearchTool = $('ResetSearchTool');
		
		this.PolygonStatus = false;
		this.CurrentPolygon = null;
		this.PolygonEventsEnd = null;
		this.PolygonEventsCancel = null;
		Event.observe(this.PolygonTool, 'click', this._togglePolygon.bindAsEventListener(this));
		Event.observe(this.ResetPolygonsTool, 'click', this._resetPolygons.bindAsEventListener(this));
		Event.observe(this.ResetSearchTool, 'click', this._resetSearch.bindAsEventListener(this));
		
		this.PanMenu = new MapSearch.GUI.ContextMenu.Menu();
		this.PanMenu.addItem(new MapSearch.GUI.ContextMenu.Item('Legend', function(pEvent){this._legend(pEvent);}.bind(this)));
		this.PanMenu.addItem(new MapSearch.GUI.ContextMenu.Item('Print', function(pEvent){this._print(pEvent);}.bind(this)));
		this.PanMenu.addItem(new MapSearch.GUI.ContextMenu.Item('Help', function(pEvent){this._help(pEvent);}.bind(this)));
		this.PanMenu.addItem(new MapSearch.GUI.ContextMenu.Seperator());
		this.PanMenu.addItem(new MapSearch.GUI.ContextMenu.Item('Search', function(pEvent){this._search(pEvent);}.bind(this)));
		this.PanMenu.addItem(new MapSearch.GUI.ContextMenu.Seperator());
		this.PanMenu.addItem(new MapSearch.GUI.ContextMenu.Item('Map', function(pEvent){this._map(pEvent);}.bind(this)));
		this.PanMenu.addItem(new MapSearch.GUI.ContextMenu.Item('Satellite', function(pEvent){this._sat(pEvent);}.bind(this)));
		this.PanMenu.addItem(new MapSearch.GUI.ContextMenu.Item('Satellite with Labels', function(pEvent){this._hybrid(pEvent);}.bind(this)));
		this.PanMenu.addItem(new MapSearch.GUI.ContextMenu.Seperator());
		this.PanMenu.addItem(new MapSearch.GUI.ContextMenu.Item('Toggle Streeview', function(pEvent){this._street(pEvent);}.bind(this)));
		this.PanMenu.addItem(new MapSearch.GUI.ContextMenu.Seperator());
		this.PanMenu.addItem(new MapSearch.GUI.ContextMenu.Item('Clear Search Fields', function(pEvent){this._resetSearch(pEvent);}.bind(this)));
		this.PanMenu.addItem(new MapSearch.GUI.ContextMenu.Item('Clear Polygons', function(pEvent){this._resetPolygons(pEvent);}.bind(this)));
		
		this.PolygonMenu = new MapSearch.GUI.ContextMenu.Menu();
		this.PolygonMenu.addItem(new MapSearch.GUI.ContextMenu.Item('Edit', function(pEvent){this._editPolygon(pEvent);}.bind(this)));
		this.PolygonMenu.addItem(new MapSearch.GUI.ContextMenu.Item('Delete', function(pEvent){this._deletePolygon(pEvent);}.bind(this)));
		this.PolygonMenu.addItem(new MapSearch.GUI.ContextMenu.Seperator());
		this.PolygonMenu.addItem(new MapSearch.GUI.ContextMenu.Item('Legend', function(pEvent){this._legend(pEvent);}.bind(this)));
		this.PolygonMenu.addItem(new MapSearch.GUI.ContextMenu.Item('Print', function(pEvent){this._print(pEvent);}.bind(this)));
		this.PolygonMenu.addItem(new MapSearch.GUI.ContextMenu.Item('Help', function(pEvent){this._help(pEvent);}.bind(this)));
		this.PolygonMenu.addItem(new MapSearch.GUI.ContextMenu.Seperator());
		this.PolygonMenu.addItem(new MapSearch.GUI.ContextMenu.Item('Search', function(pEvent){this._search(pEvent);}.bind(this)));
		this.PolygonMenu.addItem(new MapSearch.GUI.ContextMenu.Seperator());
		this.PolygonMenu.addItem(new MapSearch.GUI.ContextMenu.Item('Map', function(pEvent){this._map(pEvent);}.bind(this)));
		this.PolygonMenu.addItem(new MapSearch.GUI.ContextMenu.Item('Satellite', function(pEvent){this._sat(pEvent);}.bind(this)));
		this.PolygonMenu.addItem(new MapSearch.GUI.ContextMenu.Item('Satellite with Labels', function(pEvent){this._hybrid(pEvent);}.bind(this)));
		this.PolygonMenu.addItem(new MapSearch.GUI.ContextMenu.Seperator());
		this.PolygonMenu.addItem(new MapSearch.GUI.ContextMenu.Item('Toggle Streeview', function(pEvent){this._street(pEvent);}.bind(this)));
		this.PolygonMenu.addItem(new MapSearch.GUI.ContextMenu.Seperator());
		this.PolygonMenu.addItem(new MapSearch.GUI.ContextMenu.Item('Clear Search Fields', function(pEvent){this._resetSearch(pEvent);}.bind(this)));
		this.PolygonMenu.addItem(new MapSearch.GUI.ContextMenu.Item('Clear Polygons', function(pEvent){this._resetPolygons(pEvent);}.bind(this)));
		
		this.PolygonEditMenu = new MapSearch.GUI.ContextMenu.Menu();
		this.PolygonEditMenu.addItem(new MapSearch.GUI.ContextMenu.Item('Finish Polygon', function(pEvent){this._finishEditPolygon(pEvent);}.bind(this)));
		
		
		this.street = false;
	},
	_rightClick: function(mEvent){
		if (!mEvent.getMapElement() && !this.PolygonStatus) {
			this.PanMenu.show(mEvent.getMouseXY().x, mEvent.getMouseXY().y);
		} else if(!this.PolygonStatus) {
			try {
				//Lets only display the Polygon Menu when its a polygon I can edit. Not a SearchArea Polygon
				if(this.Polygons.indexOf(mEvent.getMapElement()) !== -1){
					mEvent.getMapElement().getVertexCount();
					this.CurrentPolygon = mEvent.getMapElement();
					this.PolygonMenu.show(mEvent.getMouseXY().x, mEvent.getMouseXY().y);
				}
			} catch(e){}
		} else if(this.PolygonStatus){
			this.PolygonEditMenu.show(mEvent.getMouseXY().x, mEvent.getMouseXY().y);
		}
	},
	_click: function(mEvent){
		MapSearch.GUI.ContextMenu.Manager.I().hideLast();
	},
	_legend: function(pEvent){
		MapSearch.GUI.Base.I().Tools.Legend.click();
	},
	_print: function(pEvent){
		var printWindow = window.open('/map_search/generic/print/?action=print', 'printWindow', 'width=850,height=650,resizable=1,scrollbars=0,toolbar=0,location=0,directories=0,status=0,menubar=0');
		if(window.focus){
			printWindow.focus();
		}
	},
	_help: function(pEvent){
		MapSearch.GUI.Base.I()._helpClick(pEvent);
	},
	_search: function(pEvent){
		MapSearch.Search.I().searchEvent(pEvent);
	},
	_map: function(pEvent){
		MapSearch.Map.I().setType(MapSearch.Map.I().Types.Normal);
	},
	_sat: function(pEvent){
		MapSearch.Map.I().setType(MapSearch.Map.I().Types.Sat);
	},
	_hybrid: function(pEvent){
		MapSearch.Map.I().setType(MapSearch.Map.I().Types.Hybrid);
	},
	_street: function(pEvent){
		if (this.street) {
			MapSearch.Map.I().toggleStreetview(false);
			this.street = false;
		} else {
			MapSearch.Map.I().toggleStreetview(true);
			this.street = true;
		}
	},
	_togglePolygon: function(){
		if(!this.PolygonStatus){
			MapSearch.SearchArea.AreaManager.I().reset();
			this.CurrentPolygon = new GPolygon([], '#ff0000', 3, 1, '#00ff00', 0.2);
			this.Polygons[this.Polygons.length] = this.CurrentPolygon;
			this.PolygonEventsEnd = GEvent.addListener(this.CurrentPolygon, 'endline', function(){this._polygonEnd();}.bind(this));
			this.PolygonEventsCancel = GEvent.addListener(this.CurrentPolygon, 'cancelline', function(){this._polygonEndCancel();}.bind(this));
			
			MapSearch.Map.I().map.addOverlay(this.CurrentPolygon);
			this.CurrentPolygon.enableDrawing();
			this.PolygonStatus = true;
			this.PolygonTool.style.backgroundPosition = '-157px 0px';
		} else {
			this.CurrentPolygon.disableEditing();
			this._polygonEndCancel();
		}
	},
	_polygonEnd: function(){
		GEvent.removeListener(this.PolygonEventsEnd);
		GEvent.removeListener(this.PolygonEventsCancel);
		this.CurrentPolygon = null;
		this.PolygonStatus = false;
		this.PolygonTool.style.backgroundPosition = '0px 0px';
	},
	_polygonEndCancel: function(){
		var v1 = this.CurrentPolygon.getVertex(0);
		var v2 = this.CurrentPolygon.getVertex(this.CurrentPolygon.getVertexCount()-1);
		if (v1.lat() == v2.lat() && v1.lng() == v2.lng()) {
		}else {
			this.CurrentPolygon.insertVertex(this.CurrentPolygon.getVertexCount(), this.CurrentPolygon.getVertex(0));
		}
		this._polygonEnd();
	},
	_editPolygon: function(pEvent){
		this.PolygonTool.style.backgroundPosition = '-157px 0px';
		this.PolygonEventsEnd = GEvent.addListener(this.CurrentPolygon, 'endline', function(){this._polygonEnd();}.bind(this));
		this.PolygonEventsCancel = GEvent.addListener(this.CurrentPolygon, 'cancelline', function(){this._polygonEndCancel();}.bind(this));
		this.CurrentPolygon.enableDrawing();
		this.PolygonStatus = true;
	},
	_deletePolygon: function(pEvent){
		this.Polygons[this.Polygons.indexOf(this.CurrentPolygon)] = null;
		MapSearch.Map.I().map.removeOverlay(this.CurrentPolygon);
		this.Polygons = this.Polygons.compact();
		this._polygonEnd();
	},
	_finishEditPolygon: function(pEvent){
		this.CurrentPolygon.disableEditing();
		this._polygonEndCancel();
	},
	_resetSearch: function(pEvent){
		MapSearch.Search.I().Results.clear();
		MapSearch.Search.I().Results.displayList();
		MapSearch.GUI.Base.I().Panels.Search.reset();
		MapSearch.GUI.Base.I().Status.postSearchResults(0)
	},
	_resetPolygons: function(pEvent){
		this.Polygons.each(function(polygon){
			MapSearch.Map.I().map.removeOverlay(polygon);
		}.bind(this));
		this.Polygons = new Array();
	}
});

/*
 * Status Display
 */
MapSearch.GUI.Status = Class.create({
	initialize: function(){
		this.pageLoad = {
			Screen:$('MapSearchLoadingInterface'), 
			MSG:$('MapSearchPageLoadStatus')
		}
		this.search = {
			results: $('PropertyFoundInfo'),
			resultsCallback: Prototype.emptyFunction,
			control: null
		}
		this.map = {
			Screen: $('MapSearchSearchingMap'),
			MSG: $('MapSearchSearchingMapStatus')
		}
	},
	onLoad: function(pEvent){
		Event.observe(this.search.results, 'click', this.onClickSearchResults.bindAsEventListener(this));
	},
	togglePageLoading: function(toggle){
		if(toggle){
			this.pageLoad.Screen.style.display = 'block';
		} else {
			this.pageLoad.Screen.style.display = 'none';
			this.pageLoad.MSG.innerHTML = '';
		}
	},
	setPageStatus: function(Msg){
		this.pageLoad.MSG.innerHTML = Msg;
	},
	postSearchResults: function(total){
		this.search.results.innerHTML = total +' Properties Found';
	},
	postSearchResultsMsg: function(msg){
		this.search.results.innerHTML = msg;
	},
	setSearchResultsCallback: function(callback){
		this.search.resultsCallback = callback;
	},
	toggleMapStatus: function(toggle){
		if(toggle){
			this.map.Screen.style.display = 'block';
		} else {
			this.map.Screen.style.display = 'none';
			this.map.MSG.innerHTML = '';
		}
	},
	toggleSearchingControl: function(toggle){
		if (this.search.control) {
			if (toggle) {
				this.search.control.display();
			}
			else {
				this.search.control.hide();
			}
		}
	},
	setSearchingControl: function(control){
		this.search.control = control;
	},
	setMapStatus: function(Msg){
		this.map.MSG.innerHTML = Msg;
	},
	
	/* 
	 * Events
	 */
	
	onClickSearchResults: function(pEvent){
		this.search.results.innerHTML = 'Searching..';
		this.search.resultsCallback(pEvent);
	}
});

/*
 * Panels
 */
MapSearch.GUI.Panels = {}
MapSearch.GUI.Panels.Manager = Class.create({
	initialize: function(){
		this.items = new Array();
		this.currentItem = null;
	},
	onLoad: function(pEvent){
		this.items.each(function(iter){iter.onLoad(pEvent);}.bind(this));
	},
	changeItem: function(item){
		if (item != this.currentItem) {
			this.items.each(function(iter){iter.tab.style.zIndex = 1;});
			item.tab.style.zIndex = 3;
			this.currentItem.tab.style.zIndex = 2;
			
			if (this.currentItem != null) {this.currentItem.hide();}
			item.show();
			this.currentItem = item;
		}
	},
	addItem: function(item){
		if(this.items.length < 1){this.currentItem = item;}
		this.items.push(item);
	} 
});
MapSearch.GUI.Panels.Manager.Instance = null;
MapSearch.GUI.Panels.Manager.I = function(){
	if(MapSearch.GUI.Panels.Manager.Instance == null){MapSearch.GUI.Panels.Manager.Instance = new MapSearch.GUI.Panels.Manager();}
	return MapSearch.GUI.Panels.Manager.Instance;
}

MapSearch.GUI.Panels.Base = Class.create({
	initialize: function() {
		this.accordians = new MapSearch.GUI.Panels.Accordians.Manager();
		this.items = {}
		this.tab = null;
		this.panel = null;
		this.sized = false;
		MapSearch.GUI.Panels.Manager.I().addItem(this);
	},
	onLoad: function(pEvent){
		Event.observe(this.tab, 'click', this.tabClickEvent.bindAsEventListener(this));
		this.accordians.onLoad(pEvent);
	},
	tabClickEvent: function(pEvent){
		var x = pEvent.pointerX();
		var element = Event.element(pEvent);
		var eABS = $GetAbsPos(element);
		x = x-eABS.x;
		
		if(x <= 66){
			MapSearch.GUI.Panels.Manager.I().changeItem(MapSearch.GUI.Base.I().Panels.Search);
		} else if(x <= 188){
			MapSearch.GUI.Panels.Manager.I().changeItem(MapSearch.GUI.Base.I().Panels.POI);
		} else {
			MapSearch.GUI.Panels.Manager.I().changeItem(MapSearch.GUI.Base.I().Panels.Stats);
		}
	},
	resizeAccordians: function(){
		this.sized = true;
	},
	hide: function(){
		this.panel.style.display = 'none';
	},
	show: function(){
		this.panel.style.display = '';
		this.resizeAccordians();
	}
});

MapSearch.GUI.Panels.Search = Class.create(MapSearch.GUI.Panels.Base, {
	initialize: function($super) {
		$super();
		this.tab = $('SearchTab');
		this.panel = $('SearchTabArea');
		this.isLoaded = false;
		this.loadedCallback = Prototype.emptyFunction;
		
		this.loadedCallbackQueue = new Array();
		
		this.accordians.addItem(new MapSearch.GUI.Panels.Accordians.SearchResults(this.accordians, 'SearchResultsTab', 'SearchResultsTabArea'));
		//this.accordians.addItem(new MapSearch.GUI.Panels.Accordians.Base(this.accordians, 'SavedSearchesTab', 'SavedSearchesTabArea'));
		this.accordians.addItem(new MapSearch.GUI.Panels.Accordians.Base(this.accordians, 'FavoritesTab', 'FavoritesTabArea'));
		this.accordians.addItem(new MapSearch.GUI.Panels.Accordians.Base(this.accordians, 'RecentlyViewedTab', 'RecentlyViewedTabArea'));
		
		this.searchOptionsWindow = new MapSearch.GUI.Window.Window('Search Options');
		this.searchOptionsWindow.setHTML(MapSearch.Template.Search.SearchOptions.evaluate({}));
		
		
	},
	onLoad: function($super, pEvent){
		if(!MapSearch.Config.Search.Enabled){
			this.hideSearchFilters();
		}
		$super(pEvent);
		this.resizeAccordians();
		
		this.items.priceMin = $('MapSearchFieldPriceMin');
		this.items.priceMax = $('MapSearchFieldPriceMax');
		this.items.beds = $('MapSearchFieldBeds');
		this.items.baths = $('MapSearchFieldBaths');
		this.items.minSQFT = $('MapSearchFieldsqftMin');
		this.items.maxSQFT = $('MapSearchFieldSqftMax');
		this.items.limit = $('MapSearchFieldLimit');
		this.items.sort = $('MapSearchFieldSort');
		this.items.propType = $('MapSearchFieldPropertyType');
		this.items.searchBtn = $('MapPropertySearchButton');
		this.items.pagePrev = $('SearchResultsPrevPage');
		this.items.pageNext = $('SearchResultsNextPage');
		this.items.page = $('SearchResultsPage');
		this.items.searchOptions = $('MapSearchAdvancedSearch');
		
		MapSearch.Search.Favorites.I();
		MapSearch.Search.RecentViewed.I();
		this.isLoaded = true;
		//this.loadedCallback();
		
		this.loadedCallbackQueue.each(function(iter){iter();});
		
		Event.observe(this.items.searchOptions, 'click', function(pEvent){this.searchOptionsWindow.showCenter();}.bindAsEventListener(this));
		
		this.searchOptionsWindow.show();
		this.getSearchOptionItems();
		this.searchOptionsWindow.hide();
	},
	hideSearchFilters: function(){
		var theTable = $$('#SearchTabArea>table')[0];
		theTable.style.display = 'none';
	},
	reset: function (){
		this.items.page.innerHTML = '0';
		this.items.priceMin.value = '';
		this.items.priceMax.value = '';
		this.items.beds.value = '';
		this.items.baths.value = '';
		this.items.minSQFT.value = '';
		this.items.maxSQFT.value = '';
		this.items.propType.value = '';
	},
	getSearchOptionItems: function(){
		this.items.owner_only = $('MapSearchFieldOwner');
		this.items.New_Property = $('MapSearchFieldNewProp');
		this.items.WithPics = $('MapSearchFieldWithPics');
		this.items.Virtual_Tour = $('MapSearchFieldVT');
		this.items.video = $('MapSearchFieldVideo');
	},
	loaded: function(callback){
		if(this.isLoaded){
			callback();
		} else {
			this.loadedCallbackQueue[this.loadedCallbackQueue.length] = callback;
			/*
			cCallback = this.loadedCallback;
			this.loadedCallback = function(){
				callback();
				if(cCallback != Prototype.emptyFunction){cCallback();}
			};
			*/
		} 
	},
	resizeAccordians: function($super){
		if (!this.sized) {
			$super();
			var main = $('MapControls');
			var container = $('SearchTabArea');
			var containers = $$('#SearchTabAreaAccordian div.TabAreaAccordianTabArea');
			var mainContainer = $('SearchResultsTabArea');
			var height = main.getHeight() - container.getHeight() + mainContainer.getHeight();
			height -= 30; //Browser ajust for some reason unknone to me but whatever.
			containers.each(function(iter){iter.style.height = height + "px";}.bind(this));
			
			var sort = $('SearchResultsTabAreaSort');
			var page = $('SearchResultsTabAreaPage');
			var area = $('SearchResultsTabAreaResults');
			height = height - sort.getHeight() - page.getHeight();
			area.style.height = height + 'px';
		}
	},
	hide: function($super){
		$super();
		this.tab.style.backgroundImage = "url("+ MapSearch.Config.GUI.Theme.Search.inactive +")";
	},
	show: function($super){
		$super();
		this.tab.style.backgroundImage = "url("+ MapSearch.Config.GUI.Theme.Search.active +")";
	}
});
MapSearch.GUI.Panels.POI = Class.create(MapSearch.GUI.Panels.Base, {
	initialize: function($super) {
		$super();
		this.tab = $('POITab');
		this.panel = $('POITabArea');
		
		this.panel.style.display = 'none';
		
		this.searches = new Array();
		
		//this.accordians.addItem(new MapSearch.GUI.Panels.Accordians.Base(this.accordians, 'POITab', 'POITabAreaPOIItems'));
		//this.accordians.addItem(new MapSearch.GUI.Panels.Accordians.Base(this.accordians, 'POIResultsTab', 'POITabAreaPOIResults'));
	},
	onLoad: function($super, pEvent){
		$super(pEvent);
		this.items.term = $('POIFindField');
		this.items.search = $('POIFindFieldSearchButton');
		this.items.searching = $('POISearching');
		this.items.searchingIMG = $('POISearchingImg');
		this.items.searchingIMG.src = MapSearch.Config.GUI.Theme.images.searching;
		this.items.newSearch = $('POITabAreaMyPOIItems');
		
		Event.observe(this.items.search, 'click', this.newSearch.bindAsEventListener(this));
		
		var poiLI = $$('#POITabAreaPOIItems>ul li>ul li>input');
		poiLI.each(function(iter){
			if (BrowserDetect.browser == 'MSIE' || BrowserDetect.browser == 'Explorer') {
				Event.observe(iter, 'click', this.prevSearch.bindAsEventListener(this));
			} else {
				Event.observe(iter, 'change', this.prevSearch.bindAsEventListener(this));
			}
		}.bind(this));
	},
	hide: function($super){
		$super();
		this.tab.style.backgroundImage = "url("+ MapSearch.Config.GUI.Theme.POI.inactive +")";
	},
	show: function($super){
		$super();
		this.tab.style.backgroundImage = "url("+ MapSearch.Config.GUI.Theme.POI.active +")";
	},
	resizeAccordians: function($super){
		if (!this.sized) {
			$super();
			var main = $('MapControlTabAreas');
			var container = $('POITabArea');
			var containers = $$('#POITabAreaAccordian div.TabAreaAccordianTabArea');
			var mainContainer = $('POITabAreaPOIItems');
			var height = main.getHeight() - container.getHeight() + mainContainer.getHeight();
			containers.each(function(iter){iter.style.height = height + "px";}.bind(this));
		}
	},
	newSearch: function(pEvent){
		if (this.items.term.getValue() != '' && this.items.term.getValue() != null) {
			MapSearch.Map.Search.I().search(this.items.term.getValue(), function(results){this.newSearchResults(results);}.bind(this))
			MapSearch.EventTracking.POINewEvent(this.items.term.getValue());
		}
	},
	newSearchResults: function(results){
		var id = results.term.replace(' ', '').replace('-', '').replace('\'', '').replace('&', '');
		if (typeof(this.searches[id]) == 'undefined') {
			this.items.newSearch.innerHTML += '<li><input type="checkbox" id="' + id + '" value="' + results.term + '"><label for="' + id + '">' + results.term + '</label></li>';
			var element = $(id);
			element.checked = true;
			if (BrowserDetect.browser == 'MSIE' || BrowserDetect.browser == 'Explorer') {
				Event.observe(element, 'click', this.prevSearch.bindAsEventListener(this));
			} else {
				Event.observe(element, 'change', this.prevSearch.bindAsEventListener(this));
			}
			var pushpins = new Array();
			results.results.each(function(iter){
				var point = new MapSearch.Map.LatLong(iter.lat, iter.lng);
				var html = MapSearch.Template.POI.Generic.evaluate({
					title: iter.title,
					streetAddress: iter.streetAddress,
					cityState: iter.cityState,
					phone: iter.phones[0].number,
					lat: iter.lat,
					lng: iter.lng,
					url: iter.url
				});
				var iconSet = MapSearch.Config.Icons.POI.mySearch;
				var pushpin = new MapSearch.Map.Pushpin.Google(point.getObject(), html, iconSet);
				pushpin.add();
				pushpins[pushpins.length] = pushpin;
			});
			this.searches[id] = pushpins;
		} else if(this.searches[id] == null || this.searches[id].length <= 0) {
			var element = $(id);
			element.checked = true;
			var pushpins = new Array();
			results.results.each(function(iter){
				var point = new MapSearch.Map.LatLong(iter.lat, iter.lng);
				var html = MapSearch.Template.POI.Generic.evaluate({
					title: iter.title,
					streetAddress: iter.streetAddress,
					cityState: iter.cityState,
					phone: iter.phones[0].number,
					lat: iter.lat,
					lng: iter.lng,
					url: iter.url
				});
				var iconSet = MapSearch.Config.Icons.POI.mySearch;
				var pushpin = new MapSearch.Map.Pushpin.Google(point.getObject(), html, iconSet);
				pushpin.add();
				pushpins[pushpins.length] = pushpin;
			});
			this.searches[id] = pushpins;
		} else if(this.searches[id].length > 0) {
			var element = $(id);
			element.checked = true;
			
			this.searches[id].each(function(iter){
				iter.del();
			});
			
			var pushpins = new Array();
			results.results.each(function(iter){
				var point = new MapSearch.Map.LatLong(iter.lat, iter.lng);
				var html = MapSearch.Template.POI.Generic.evaluate({
					title: iter.title,
					streetAddress: iter.streetAddress,
					cityState: iter.cityState,
					phone: iter.phones[0].number,
					lat: iter.lat,
					lng: iter.lng,
					url: iter.url
				});
				var iconSet = MapSearch.Config.Icons.POI.mySearch;
				var pushpin = new MapSearch.Map.Pushpin.Google(point.getObject(), html, iconSet);
				pushpin.add();
				pushpins[pushpins.length] = pushpin;
			});
			this.searches[id] = pushpins;
			
		}
		
	},
	prevSearch: function(pEvent){
		var id = pEvent.element().id;
		if (typeof(this.searches[id]) == 'undefined' || this.searches[id] == null || this.searches[id].length <= 0) {
			pEvent.element().checked = true;
			MapSearch.Map.Search.I().search(pEvent.element().getValue(), function(results){this.prevSearchResponse(results);}.bind(this))
			MapSearch.EventTracking.POIPrevEvent(this.items.term.getValue());
		} else {
			this.searches[id].each(function(iter){
				iter.hide();
				iter.del();
			});
			this.searches[id] = null;
		}
		
	},
	prevSearchResponse: function(results){
		var id = results.term.replace(' ', '').replace('-', '').replace('\'', '').replace('&', '');
		var pushpins = new Array();
		results.results.each(function(iter){
			var point = new MapSearch.Map.LatLong(iter.lat, iter.lng);
			var html = MapSearch.Template.POI.Generic.evaluate({
				title: iter.title,
				streetAddress: iter.streetAddress,
				cityState: iter.cityState,
				phone: iter.phones[0].number,
				lat: iter.lat,
				lng: iter.lng,
				url: iter.url
			});
			var iconSet = this.getIconSet(id);
			var pushpin = new MapSearch.Map.Pushpin.Google(point.getObject(), html, iconSet);
			pushpin.add();
			pushpin.show();
			pushpins[pushpins.length] = pushpin;
		}.bind(this));
		this.searches[id] = pushpins;
	},
	getIconSet: function(id){
		switch(id){
			case 'Restaurants':
				var returnSet = MapSearch.Config.Icons.POI.restaurant;
				break;
			case 'Bars':
				var returnSet = MapSearch.Config.Icons.POI.bar;
				break;
			case 'Coffee':
				var returnSet = MapSearch.Config.Icons.POI.coffee;
				break;
			case 'HighSchools':
			case 'MiddleSchools':
			case 'Elementary':
				var returnSet = MapSearch.Config.Icons.POI.school;
				break;
			case 'GroceryStores':
				var returnSet = MapSearch.Config.Icons.POI.grocery;
				break;
			case 'DepartmentStores':
				var returnSet = MapSearch.Config.Icons.POI.department;
				break;
			case 'BookStores':
				var returnSet = MapSearch.Config.Icons.POI.bookStore;
				break;
			case 'DrugStores':
				var returnSet = MapSearch.Config.Icons.POI.drugStore;
				break;
			case 'WineLiquor':
				var returnSet = MapSearch.Config.Icons.POI.wine;
				break;
			case 'MovieTheaters':
				var returnSet = MapSearch.Config.Icons.POI.movie;
				break;
			case 'HealthClubs':
				var returnSet = MapSearch.Config.Icons.POI.health;
				break;
			case 'GolfCourses':
				var returnSet = MapSearch.Config.Icons.POI.golf;
				break;
			case 'SportsStadiums':
				var returnSet = MapSearch.Config.Icons.POI.arena;
				break;
			case 'Recreation':
				var returnSet = MapSearch.Config.Icons.POI.recreation;
				break;
			case 'TouristAttractions':
				var returnSet = MapSearch.Config.Icons.POI.tourist;
				break;
			case 'Hotel':
				var returnSet = MapSearch.Config.Icons.POI.hotel;
				break;
			case 'Clinics':
				var returnSet = MapSearch.Config.Icons.POI.clinic;
				break;
			case 'Hospitals':
				var returnSet = MapSearch.Config.Icons.POI.hospital;
				break;
			case 'PostOffice':
				var returnSet = MapSearch.Config.Icons.POI.postOffice;
				break;
			case 'PublicLibraries':
				var returnSet = MapSearch.Config.Icons.POI.library;
				break;
			case 'FireDepartments':
				var returnSet = MapSearch.Config.Icons.POI.fire;
				break;
			case 'PoliceDepartments':
				var returnSet = MapSearch.Config.Icons.POI.police;
				break;
			case 'Courts':
				var returnSet = MapSearch.Config.Icons.POI.courts;
				break;
			case 'Airports':
				var returnSet = MapSearch.Config.Icons.POI.airport;
				break;
			case 'Banks':
				var returnSet = MapSearch.Config.Icons.POI.bank;
				break;
			case 'Laundry':
				var returnSet = MapSearch.Config.Icons.POI.laundry;
				break;
			case 'PlacesofWorshipandChurch':
				var returnSet = MapSearch.Config.Icons.POI.worship;
				break;
			default:
				var returnSet = MapSearch.Config.Icons.POI.mySearch;
				
		}
		return returnSet;
	}
});
MapSearch.GUI.Panels.Stats = Class.create(MapSearch.GUI.Panels.Base, {
	initialize: function($super) {
		$super();
		this.tab = $('StatsTab');
		this.panel = $('StatsTabArea');
		
		this.panel.style.display = 'none';
		this.accordians.addItem(new MapSearch.GUI.Panels.Accordians.Base(this.accordians, 'DemographicsTab', 'DemographicsTabAreaDemographicsItems'));
	},
	onLoad: function($super, pEvent){
		$super(pEvent);
		this.items.zipcode = $('StatsFindField');
		this.items.search = $('StatsFindFieldSearchButton');
		this.items.searching = $('StatsLoading');
		this.items.searchingIMG = $('StatsLoadingImg');
		this.items.searchingIMG.src = MapSearch.Config.GUI.Theme.images.searching;
		
		Event.observe(this.items.search, 'click', this.search.bindAsEventListener(this));
	},
	hide: function($super){
		$super();
		this.tab.style.backgroundImage = "url("+ MapSearch.Config.GUI.Theme.Stats.inactive +")";
	},
	show: function($super){
		$super();
		this.tab.style.backgroundImage = "url("+ MapSearch.Config.GUI.Theme.Stats.active +")";
	},
	resizeAccordians: function($super){
		if (!this.sized) {
			$super();
			var main = $('MapControlTabAreas');
			var container = $('StatsTabArea');
			var containers = $$('#StatsTabAreaAccordian div.TabAreaAccordianTabArea');
			var mainContainer = $('DemographicsTabAreaDemographicsItems');
			var height = main.getHeight() - container.getHeight() + mainContainer.getHeight();
			containers.each(function(iter){iter.style.height = height + "px";}.bind(this));
		}
	},
	search: function(pEvent){
		this.items.searching.style.display = '';
		var options = { 
			method: 'post',
			parameters: {zipcode:this.items.zipcode.getValue()},
			onSuccess: function(response, json){this.searchSuccess(response, json);}.bind(this),
			onFailure: function(response, json){this.searchFail(response, json);}.bind(this)
		};
		var myAjax = new Ajax.Request('/map_search/demographics/', options);
		MapSearch.EventTracking.StatsEvent(this.items.zipcode.getValue());
	},
	searchSuccess: function(response, json){
		var html = MapSearch.Template.Stats.Demo.evaluate(json);
		this.accordians.items[0].content.innerHTML = html;
		this.items.searching.style.display = 'none';
	},
	searchFail: function(response, json){
		this.items.searching.style.display = 'none';
	}
});

/*
 * Panel Accordians
 */
MapSearch.GUI.Panels.Accordians = {}
MapSearch.GUI.Panels.Accordians.Manager = Class.create({
	initialize: function(){
		this.items = new Array();
		this.currentItem = null;
	},
	onLoad: function(pEvent){
		this.items.each(function(iter){iter.onLoad(pEvent);}.bind(this));
	},
	changeItem: function(item){
		if (item != this.currentItem) {
			if (this.currentItem != null) {this.currentItem.collapse();}
			item.expand();
			this.currentItem = item;
		}
	},
	addItem: function(item){
		if(this.items.length < 1){this.currentItem = item;}
		this.items.push(item);
	} 
});
MapSearch.GUI.Panels.Accordians.Base = Class.create({
	initialize: function(manager, tab, content){
		this.manager = manager;
		this.tab = $(tab);
		this.content = $(content);
	},
	onLoad: function(pEvent){
		Event.observe(this.tab, 'click', this.toggleDisplay.bindAsEventListener(this));
	},
	toggleDisplay: function(pEvent){
		MapSearch.Console.info({msg: 'Changing Accordian', event:pEvent});
		this.manager.changeItem(this);
	},
	expand: function(){
		this.content.style.display = '';
	},
	collapse: function(){
		this.content.style.display = 'none';
	},
	setHTML: function(html){
		this.content.innerHTML = html;
	}
});
MapSearch.GUI.Panels.Accordians.SearchResults = Class.create(MapSearch.GUI.Panels.Accordians.Base, {
	initialize: function($super, manager, tab, content){
		$super(manager, tab, content);
		this.contentExpanded = $('SearchResultsTabAreaResults');
	},
	onLoad: function($super, pEvent){
		$super(pEvent);
		if(!MapSearch.Config.Search.Enabled){
			this.tab.style.display = 'none';
		}
	},
	setHTML: function(html){
		this.contentExpanded.innerHTML = html;
	}
});MapSearch.GUI.ContextMenu = {}
MapSearch.GUI.ContextMenu.Manager = Class.create({
	initialize: function(){
		this.menus = new Array();
		this.currentMenu = null;
	},
	addMenu: function(menu){
		this.menus[this.menus.length] = menu;
		menu.setID('Menu'+this.menus.length);
	},
	displayMenu: function(menu){
		if(this.currentMenu != null && this.currentMenu != menu){
			this.currentMenu._hide();
		}
		menu._show();
		this.currentMenu = menu;
	},
	hideLast: function(){
		if(this.currentMenu != null){
			this.currentMenu._hide();
			this.currentMenu = null;
		}
	}
});
MapSearch.GUI.ContextMenu.Manager.Instance = null;
MapSearch.GUI.ContextMenu.Manager.I = function(){
	if(MapSearch.GUI.ContextMenu.Manager.Instance == null){MapSearch.GUI.ContextMenu.Manager.Instance = new MapSearch.GUI.ContextMenu.Manager();}
	return MapSearch.GUI.ContextMenu.Manager.Instance;
}

MapSearch.GUI.ContextMenu.Menu = Class.create({
	initialize: function(){
		this.created = false;
		this.items = new Array();
		
		this.menu = null;
		this.id = null;
		MapSearch.GUI.ContextMenu.Manager.I().addMenu(this);
	},
	setID: function(id){
		this.id = id;
	},
	addItem: function(item){
		this.items[this.items.length] = item;
		item.setID(this.id+'Item'+this.items.length);
	},
	_hide: function(){
		this.menu.style.display = 'none';
	},
	_show: function(){
		this.menu.style.display = '';
	},
	show: function(x, y){
		if(!this.created){
			this.create();
		}
		this.menu.style.top = y+'px';
		this.menu.style.left = x+'px';
		this.menu.style.zIndex = 1001;
		
		var dim = $(document.body).getDimensions();
		var menuDim = this.menu.getDimensions();
		
		if (dim.height < (menuDim.height+y)){
			var mod = (menuDim.height+y) - dim.height + 5;
			this.menu.style.top = (y-mod)+'px';
		} else if (dim.height == (menuDim.height+y)){
			this.menu.style.top = (y-5)+'px';
		}
		
		if (dim.width < (menuDim.width+x)){
			var mod = (menuDim.width+x) - dim.width + 5;
			this.menu.style.left = (x-mod)+'px';
		} else if (dim.width == (menuDim.width+x)){
			this.menu.style.left = (y-5)+'px';
		}
		
		MapSearch.GUI.ContextMenu.Manager.I().displayMenu(this);
	},
	hide: function(){
		MapSearch.GUI.ContextMenu.Manager.I().currentMenu = null;
		this._hide();
	},
	create: function(){
		var html = '<div id="'+ this.id +'" class="MSContextMenu">';
		html += '<b class="RoundedCorner">'+
		'		<b class="RoundedCornerLevel" style="margin:0 4px;"></b>'+
		'		<b class="RoundedCornerLevel" style="margin:0 2px;"></b>'+
		'		<b class="RoundedCornerLevel" style="margin:0 1px;"></b>'+
		'		<b class="RoundedCornerLevel"></b>'+
		'	</b>';
		html += '<div class="MSContextMenuContent"><ul>'
		this.items.each(function(iter){
			if(iter.isSeperator){
				html += '</ul><div>&nbsp;</div><ul>';
			} else {
				html += '<li id="'+iter.id+'">'+ iter.title +'</li>';
			}
		});
		html += '</ul></div>';
		html += '<b class="RoundedCorner">'+
		'		<b class="RoundedCornerLevel"></b>'+
		'		<b class="RoundedCornerLevel" style="margin:0 1px;"></b>'+
		'		<b class="RoundedCornerLevel" style="margin:0 2px;"></b>'+
		'		<b class="RoundedCornerLevel" style="margin:0 4px;"></b>'+
		'	</b>';
		html += '</div>';
		var wrapper = new Element('div'); wrapper.innerHTML = html; document.body.appendChild(wrapper.down());
		
		this.menu = $(this.id);
		this.items.each(function(iter){iter.buildEvents()});
		Event.observe(this.menu, 'click', this._click.bindAsEventListener(this))
		this.created = true;
	},
	_click: function(pEvent){
		MapSearch.GUI.ContextMenu.Manager.I().hideLast();
	}
});
MapSearch.GUI.ContextMenu.Item = Class.create({
	initialize: function(title, callback){
		this.isSeperator = false;
		this.title = title;
		this.callback = callback;
		this.id = null;
	},
	setID: function(id){
		this.id = id;
	},
	buildEvents: function(){
		Event.observe($(this.id), 'click', this._click.bindAsEventListener(this));
	},
	_click: function(pEvent){
		this.callback(pEvent);
	}
});
MapSearch.GUI.ContextMenu.Seperator = Class.create({initialize: function(){this.isSeperator = true;}, buildEvents: function(){}, setID: function(){}});MapSearch.GUI.Window={}
MapSearch.GUI.Window.Manager = Class.create({
	initialize: function(){
		this.windows = new Array();
	},
	addWindow: function(window){
		this.windows[this.windows.length] = window;
		return 'Window'+ this.windows.length;
	}
});
MapSearch.GUI.Window.Manager.Instance = null;
MapSearch.GUI.Window.Manager.I = function(){
	if(MapSearch.GUI.Window.Manager.Instance == null){MapSearch.GUI.Window.Manager.Instance = new MapSearch.GUI.Window.Manager();}
	return MapSearch.GUI.Window.Manager.Instance;
}

MapSearch.GUI.Window.Window = Class.create({
	initialize: function(title){
		this.title = title;
		this.html = null;
		this.htmlChanged = false;
		this.window = null;
		this.windowContent = null;
		this.closeButton = null;
		this.titleBar = null;
		this.created = false;
		this.isDragging = false;
		this.mousePOS = {x:0,y:0};
		this.hideCallback = Prototype.emptyFunction;
		
		this.id = MapSearch.GUI.Window.Manager.I().addWindow(this);
	},
	create: function(){
		var html = ''+
		'<div class="window" id="'+ this.id +'">'+
		'	<b class="RoundedCorner">'+
		'		<b class="RoundedCornerLevel" style="margin:0 4px;"></b>'+
		'		<b class="RoundedCornerLevel" style="margin:0 2px;"></b>'+
		'		<b class="RoundedCornerLevel" style="margin:0 1px;"></b>'+
		'		<b class="RoundedCornerLevel"></b>'+
		'	</b>'+
		'	<div id="'+ this.id +'Title" class="windowTitle">'+
		'		<img id="'+ this.id +'Close" src="/images/system/map_search/window_close.gif" class="windowImage" />'+ this.title +
		'	</div>'+
		'	<div class="windowContent" id="'+ this.id +'Content">'+ this.html +
		'	</div>'+
		'	<b class="RoundedCorner">'+
		'		<b class="RoundedCornerLevel"></b>'+
		'		<b class="RoundedCornerLevel" style="margin:0 1px;"></b>'+
		'		<b class="RoundedCornerLevel" style="margin:0 2px;"></b>'+
		'		<b class="RoundedCornerLevel" style="margin:0 4px;"></b>'+
		'	</b>'+
		'</div>';
		var wrapper = new Element('div'); wrapper.innerHTML = html; document.body.appendChild(wrapper.down());
		this.window = $(this.id);
		this.windowContent = $(this.id+'Content');
		this.closeButton = $(this.id+'Close');
		this.titleBar = $(this.id+'Title');
		
		Event.observe(this.closeButton, 'click', this._closeClick.bindAsEventListener(this));
		Event.observe(document, 'mouseover', this._mouseMove.bindAsEventListener(this));
		Event.observe(this.titleBar, 'mousedown', this._mouseDown.bindAsEventListener(this));
		Event.observe(document, 'mouseup', this._mouseUp.bindAsEventListener(this));
		
		this.created = true;
	},
	setHTML: function(html){
		this.html = html;
		this.htmlChange = true;
	},
	setDim: function(width, height){
		if(!this.created){
			this.create();
		}
		this.window.style.width = (width+12)+'px';
		this.windowContent.style.height = height+'px';
		this.windowContent.style.width = width+'px';
		this.windowContent.style.maxHeight = height+'px';
		this.windowContent.style.maxWidth = width+'px';
	},
	setHideCallback: function(callback){
		this.hideCallback = callback;
	},
	show: function(){
		if(!this.created){
			this.create();
		}
		if(this.htmlChanged){
			this.windowContent.innerHTML = this.html;
			this.htmlChanged = false;
		}
		this.window.style.display = '';
	},
	showCenter: function(){
		this.show();
		var dim = $(document.body).getDimensions();
		var wDim = this.window.getDimensions();
		var top = (dim.height/2) - (wDim.height/2);
		var left = (dim.width/2) - (wDim.width/2);
		this.window.style.top = top+'px';
		this.window.style.left = left+'px';
	},
	hide: function(){
		this.hideCallback();
		this.window.style.display = 'none';
	},
	_closeClick: function(pEvent){
		this.hide();
	},
	_mouseMove: function(pEvent){
		if(this.isDragging){
			var top = (Event.pointerY(pEvent) - this.mousePOS.y);
			var left = (Event.pointerX(pEvent) - this.mousePOS.x);
			this.window.style.top = top +'px';
			this.window.style.left = left +'px';
		}
	},
	_mouseDown: function(pEvent){
		this.isDragging = true;
		//this.windowContent.innerHTML = '';
		var x = Event.pointerX(pEvent);
		var y = Event.pointerY(pEvent);
		var wX = this.window.offsetLeft;
		var wY = this.window.offsetTop;
		
		this.mousePOS = {x:(x-wX), y:(y-wY)};
		
	},
	_mouseUp: function(pEvent){
		this.isDragging = false;
		//this.windowContent.innerHTML = this.html;
	}
});/*
 * @file MapSearch.Map
 * @author Nick Verbeck <nick@activewebsite.com>
 */

MapSearch.Map = {}
MapSearch.Map.Instance = null;
MapSearch.Map.Type = 'Google';
MapSearch.Map.InitilizeCallback = Prototype.emptyFunction;
MapSearch.Map.I = function(){
	if(MapSearch.Map.Instance == null){
		if(MapSearch.Map.Type == 'Google'){
			MapSearch.Map.Instance = new MapSearch.Map.Google();
		}
	}
	return MapSearch.Map.Instance;
}
MapSearch.Map.LatLong = Class.create({
	initialize: function(Lat, Long){
		this.Lat = Lat;
		this.Long = Long;
		this.object = null
	},
	getObject: function(){
		if(this.object == null){
			if(MapSearch.Map.Type == 'Google'){
				this.object = new google.maps.LatLng(this.Lat, this.Long);
			}
		}
		return this.object;
	}
});
MapSearch.Map.Event = Class.create({
	initialize: function(){
		this.MapElement = false;
		this.LatLong = false;
		this.mousePOS = {x:0,y:0}
	},
	getLatLong: function(){
		return this.LatLong;
	},
	getMapElement: function(){
		return this.MapElement;
	},
	getMouseXY: function(){
		return this.mousePOS;
	},
	setLatLong: function(LatLong){
		this.LatLong =  new MapSearch.Map.LatLong(LatLong.lat(), LatLong.lng());
	},
	setMouseXY: function(mXY){
		this.mousePOS.x = mXY.x;
		this.mousePOS.y = mXY.y;
	},
	setMapElement: function(){
		var el = arguments[0];
		this.MapElement = el;
		try {
			el.getIcon();
			this.MapElement = el;
		} catch(e){
			try{
				el.getVertexCount();
				this.MapElement = el;
			} catch(e){
				this.MapElement = false;
			}
		}
	}
});

MapSearch.Map.Base = Class.create({
	Types:{
		Normal: null,
		Sat: null,
		Hybrid: null
	},
	initialize: function() {
		this.GUI = MapSearch.GUI.Base.I();
		this.GUI.Status.toggleMapStatus(true);
		this.GUI.Status.setMapStatus(MapSearch.Config.GUI.MSGs.MapLoading);
		this.map = null;
		this.mapContainer = $('SearchMap');
		MapSearch.Config.Map.defaultLocation = new MapSearch.Map.LatLong(MapSearch.Config.Map.defaultLatLong.Lat,MapSearch.Config.Map.defaultLatLong.Long);
		
		this.events = {
			rightClick: new Array(),
			click: new Array(),
			moveEnd: new Array(),
			zoomEnd: new Array(),
			dragEnd: new Array(),
			dragStart: new Array()
		}
	},
	regEventCallback: function(event, callback){
		this.events[event][this.events[event].length] = callback;
	}
});

MapSearch.Map.Google = Class.create(MapSearch.Map.Base, {
	initialize: function($super) {
		$super();
		//google.load("maps", "2", {'other_params': 'client=gme-activewebsite'});
		//google.load("search", "1", {'other_params': 'client=gme-activewebsite'});
		google.load("maps", "2", {"other_params":'channel='+MapSearch.Config.CompanyID});
		google.load("search", "1");
		google.setOnLoadCallback(function(){this.mapInitialize();}.bind(this));
		Event.observe(window, 'unload', this.unLoadMap.bindAsEventListener(this));
	},
	mapInitialize: function(){
		if (GBrowserIsCompatible()) {
			this.GUI.Status.setMapStatus(MapSearch.Config.GUI.MSGs.MapInit);
			this.map = new google.maps.Map2(this.mapContainer);
			this.map.addMapType(G_PHYSICAL_MAP);
			if(BrowserDetect.browser != 'Explorer'){
				this.map.enablePinchToZoom();
				this.map.enableScrollWheelZoom();
			} else if(BrowserDetect.browser == 'Explorer' && BrowserDetect.version > 6) {
				this.map.enablePinchToZoom();
				this.map.enableScrollWheelZoom();
			}
			this.setCenter(MapSearch.Config.Map.defaultLocation.getObject(), MapSearch.Config.Map.defaultZoom);
			this.map.addControl(new GLargeMapControl3D(), new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(10, 34)));
			this.map.addControl(new GHierarchicalMapTypeControl(), new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(7, 36)));
			this.map.addControl(new GScaleControl());
			
			function SearchAreas(){}
			SearchAreas.prototype = new GControl();
			SearchAreas.prototype.initialize = function(map){
				var container = document.createElement("div");
				container.style.color = MapSearch.Config.GUI.Theme.colors.text;
				container.style.zIndex = '2';
				map.getContainer().appendChild(container);
				
				if(MapSearch.SearchArea.AreaManager.I().getTeir1().length > 1){
					var dataContainer = document.createElement("div");
					dataContainer.style.backgroundImage = 'url('+ MapSearch.Config.GUI.Theme.mapControls.gradient +')';
					dataContainer.style.backgroundRepeat = 'repeat-x';
					dataContainer.style.height = '26px';
					dataContainer.style.cssFloat = 'left';
					dataContainer.style.styleFloat = 'left';
					dataContainer.style.textDecoration = 'underline';
					container.appendChild(dataContainer);
					
					var teir1Container = document.createElement("div");
					teir1Container.appendChild(document.createTextNode("Select an Area"));
					teir1Container.style.backgroundImage = 'url('+ MapSearch.Config.GUI.Theme.mapControls.arrow +')';
					teir1Container.style.backgroundRepeat = 'no-repeat';
					teir1Container.style.backgroundPosition = 'right';
					teir1Container.style.marginRight = '5px';
					teir1Container.style.paddingRight = '15px';
					teir1Container.style.paddingLeft = '5px';
					teir1Container.style.paddingTop = '5px';
					teir1Container.style.fontWeight = 'bold';
					teir1Container.style.height = '21px';
					teir1Container.style.cssFloat = 'left';
					teir1Container.style.styleFloat = 'left';
					teir1Container.style.cursor = 'pointer';
					teir1Container.style.minWidth = '30px';
					teir1Container.id = 'SearchAreasTeir1';
					
					var teir2Container = document.createElement("div");
					teir2Container.appendChild(document.createTextNode("Select an Area"));
					teir2Container.style.backgroundImage = 'url('+ MapSearch.Config.GUI.Theme.mapControls.arrow +')';
					teir2Container.style.backgroundRepeat = 'no-repeat';
					teir2Container.style.backgroundPosition = 'right';
					teir2Container.style.marginRight = '5px';
					teir2Container.style.paddingRight = '15px';
					teir2Container.style.paddingLeft = '5px';
					teir2Container.style.paddingTop = '5px';
					teir2Container.style.fontWeight = 'bold';
					teir2Container.style.display = 'none';
					teir2Container.style.height = '21px';
					teir2Container.style.cssFloat = 'left';
					teir2Container.style.styleFloat = 'left';
					teir2Container.style.cursor = 'pointer';
					teir2Container.style.borderLeft = '1px #fff solid';
					teir1Container.style.minWidth = '30px';
					teir2Container.id = 'SearchAreasTeir2';
					
					var teir3Container = document.createElement("div");
					teir3Container.appendChild(document.createTextNode("Select an Area"));
					teir3Container.style.backgroundImage = 'url('+ MapSearch.Config.GUI.Theme.mapControls.arrow +')';
					teir3Container.style.backgroundRepeat = 'no-repeat';
					teir3Container.style.backgroundPosition = 'right';
					teir3Container.style.marginRight = '5px';
					teir3Container.style.paddingRight = '15px';
					teir3Container.style.paddingLeft = '5px';
					teir3Container.style.paddingTop = '5px';
					teir3Container.style.fontWeight = 'bold';
					teir3Container.style.display = 'none';
					teir3Container.style.height = '21px';
					teir3Container.style.cssFloat = 'left';
					teir3Container.style.styleFloat = 'left';
					teir3Container.style.cursor = 'pointer';
					teir3Container.style.borderLeft = '1px #fff solid';
					teir1Container.style.minWidth = '30px';
					teir3Container.id = 'SearchAreasTeir3';
					
					dataContainer.appendChild(teir1Container);
					dataContainer.appendChild(teir2Container);
					dataContainer.appendChild(teir3Container);
					
					Object.extend(MapSearch.SearchArea.AreaManager.I().elements, {teir1: teir1Container, teir2: teir2Container, teir3: teir3Container});
					MapSearch.SearchArea.AreaManager.I().build();
				}
				return container;
			}
			SearchAreas.prototype.getDefaultPosition = function(){return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(0, 0));}
			try {this.map.addControl(new SearchAreas());} catch(e){console.error(e);}
			
			function MapControls(){}
			MapControls.prototype = new GControl();
			MapControls.prototype.initialize = function(map){
				var container = document.createElement("div");
				
				var streetView = document.createElement("div");
				streetView.appendChild(document.createTextNode("Street View"));
				streetView.style.color = "#000";
				streetView.style.backgroundColor = "white";
				streetView.style.fontSize = "12px";
				streetView.style.border = "1px solid black";
				streetView.style.textAlign = "center";
				streetView.style.cursor = "pointer";
				streetView.style.cssFloat = 'left';
				streetView.style.styleFloat = 'left';
				streetView.style.marginLeft = '7px';
				streetView.style.width = '70px';
				streetView.style.padding = '1px';
				streetView.onclick = function(){
					if (MapSearch.Map.I().overlays.streetDisplay) {
						MapSearch.Map.I().toggleStreetview(false);
					} else {
						MapSearch.Map.I().toggleStreetview(true);
					}
				}
				
				var traffic = document.createElement("div");
				traffic.appendChild(document.createTextNode("Traffic"));
				traffic.style.color = "#000";
				traffic.style.backgroundColor = "white";
				streetView.style.fontSize = "12px";
				traffic.style.border = "1px solid black";
				traffic.style.textAlign = "center";
				traffic.style.width = "6em";
				traffic.style.cursor = "pointer";
				traffic.style.cssFloat = 'left';
				traffic.style.styleFloat = 'left';
				traffic.style.width = '70px';
				traffic.style.padding = '1px';
				traffic.onclick = function(){
					if (MapSearch.Map.I().overlays.trafficDisplay) {
						MapSearch.Map.I().toggleTraffic(false);
					} else {
						MapSearch.Map.I().toggleTraffic(true);
					}
				}
				
				container.appendChild(traffic);
				container.appendChild(streetView);
				
				map.getContainer().appendChild(container);
				return container;
			}
			MapControls.prototype.getDefaultPosition = function(){return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(198, 36));}
			try {this.map.addControl(new MapControls());} catch(e){console.error(e);}
			
			function SearchingDialog(){}
			SearchingDialog.prototype = new GControl();
			SearchingDialog.prototype.initialize = function(map){
				this.container = document.createElement("div");
				this.container.style.display = 'none';
				
				var cornerL = document.createElement("img");
				cornerL.src = MapSearch.Config.GUI.Theme.mapControls.leftEndCap;
				cornerL.style.height = '26px';
				cornerL.style.width = '26px';
				
				var cornerR = document.createElement("img");
				cornerR.src = MapSearch.Config.GUI.Theme.mapControls.rightEndCap;
				cornerR.style.height = '26px';
				cornerR.style.width = '26px';
				
				var cornerContainerL = document.createElement("div");
				cornerContainerL.style.height = '26px';
				cornerContainerL.style.cssFloat = 'left';
				cornerContainerL.style.styleFloat = 'left';
				cornerContainerL.appendChild(cornerL);
				
				var cornerContainerR = document.createElement("div");
				cornerContainerR.style.height = '26px';
				cornerContainerR.style.cssFloat = 'left';
				cornerContainerR.style.styleFloat = 'left';
				cornerContainerR.appendChild(cornerR);
				
				var dataContainer = document.createElement("div");
				dataContainer.style.backgroundImage = 'url('+ MapSearch.Config.GUI.Theme.mapControls.gradient +')';
				dataContainer.style.backgroundRepeat = 'repeat-x';
				dataContainer.style.height = '26px';
				dataContainer.style.cssFloat = 'left';
				dataContainer.style.styleFloat = 'left';
				dataContainer.style.paddingTop = '3px';
				
				var searchingImg = document.createElement("img");
				searchingImg.src = MapSearch.Config.GUI.Theme.images.searching;
				searchingImg.align = 'absmiddle';
				
				var txtContainer = document.createElement("span");
				txtContainer.appendChild(document.createTextNode("Searching Properties..."));
				txtContainer.style.marginRight = '5px';
				txtContainer.style.marginLeft = '5px';
				txtContainer.style.fontWeight = 'bold';
				txtContainer.style.color = '#fff';
				dataContainer.appendChild(searchingImg);
				dataContainer.appendChild(txtContainer);
				
				this.container.appendChild(cornerContainerL);
				this.container.appendChild(dataContainer);
				this.container.appendChild(cornerContainerR);
				
				map.getContainer().appendChild(this.container);
				return this.container;
			}
			SearchingDialog.prototype.getDefaultPosition = function(){return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(55, 26));}
			SearchingDialog.prototype.display = function(){this.container.style.display = '';}
			SearchingDialog.prototype.hide = function(){this.container.style.display = 'none';}
			
			try {
				var temp = new SearchingDialog();
				this.GUI.Status.setSearchingControl(temp);
				this.map.addControl(temp);
			} catch(e){}
			
			function LocationSearchControl(){}
			LocationSearchControl.prototype = new GControl();
			LocationSearchControl.prototype.initialize = function(map){
				this.map = map;
				this.search = new MapSearch.Map.LocationSearch(function(point){this.searchResults(point);}.bind(this));
				
				var container = document.createElement("div");
				container.style.color = MapSearch.Config.GUI.Theme.colors.text;
				container.style.backgroundImage = 'url('+ MapSearch.Config.GUI.Theme.mapControls.gradient +')';
				container.style.backgroundRepeat = 'repeat-x';
				container.style.height = '26px';
				container.style.width = '100%';
				container.style.zIndex = '1';
				
				var dataContainer = document.createElement("div");
				dataContainer.style.backgroundImage = 'url('+ MapSearch.Config.GUI.Theme.mapControls.gradient +')';
				dataContainer.style.backgroundRepeat = 'repeat-x';
				dataContainer.style.height = '26px';
				dataContainer.style.cssFloat = 'right';
				dataContainer.style.styleFloat = 'right';
				container.appendChild(dataContainer);
				
				var txtContainer = document.createElement("span");
				txtContainer.appendChild(document.createTextNode("Zoom Tool"));
				txtContainer.style.marginRight = '5px';
				txtContainer.style.marginLeft = '5px';
				txtContainer.style.fontWeight = 'bold';
				dataContainer.appendChild(txtContainer);
				
				this.image = document.createElement("img");
				this.image.src = MapSearch.Config.GUI.Theme.images.searchingI;
				this.image.style.display = 'none';
				this.image.style.position = 'absolute';
				this.image.style.top = '8px';
				this.image.style.right = '80px';
				
				dataContainer.appendChild(this.image);
				
				var input = document.createElement('input');
				input.type = 'text';
				input.value = 'Address, City & State or Zip';
				input.style.width = '160px';
				input.style.height = '14px';
				input.style.fontWeight = 'bold';
				input.style.marginRight = '3px';
				input.onfocus= function(){
					this.value = ''; 
					this.onfocus = function(){}
				}
				input.onclick= function(){
					this.value = '';
				}
				input.onsearch = function(){
					MapSearch.Map.LocationSearch.Areas.I().enterKeyPressed();
					this.image.style.display = '';
					this.search.search(input.value);
					MapSearch.Map.LocationSearch.Areas.I().hide();
				}.bind(this)
				input.onkeyup = function(event){
					if (window.event){event = window.event;}
					var charCode = event.keyCode;
					if (charCode == 8 || charCode == 38 || charCode == 40){
						MapSearch.Map.LocationSearch.Areas.I().keyUp(charCode);
					}
				}
				input.onkeypress = function(event){
					if (window.event){event = window.event;}
					var charCode = event.keyCode;
					if (charCode == 0){
						var charCode = event.charCode;
					}
					
					if(charCode == 13){
						MapSearch.Map.LocationSearch.Areas.I().enterKeyPressed();
						this.image.style.display = '';
						this.search.search(input.value);
						MapSearch.Map.LocationSearch.Areas.I().hide();
					} else if (charCode && event.charCode != 0){
						MapSearch.Map.LocationSearch.Areas.I().keyPresed(charCode);
					}
				}.bind(this)
				input.ondblclick = function(){
					this.value = '';
					MapSearch.Map.LocationSearch.Areas.I().hide();
				}
				MapSearch.Map.LocationSearch.Areas.I().inputField = input;
				
				var inputBtn = document.createElement('input');
				inputBtn.type = 'button';
				inputBtn.value = 'Go To';
				inputBtn.style.height = '23px';
				inputBtn.onclick= function(){
					this.image.style.display = '';
					this.search.search(input.value);
				}.bind(this)
				
				dataContainer.appendChild(input);
				dataContainer.appendChild(inputBtn);
				map.getContainer().appendChild(container);
				return container;
			}
			LocationSearchControl.prototype.getDefaultPosition = function(){return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(0, 0));}
			LocationSearchControl.prototype.searchResults = function(point){
				this.image.style.display = 'none';
				if(point != null){
					if(this.map.getZoom() >= 15){
						var zoom = this.map.getZoom()
					} else {
						var zoom = 15;
					}
					this.map.setCenter(point, zoom);
					if (!MapSearch.Config.Search.Auto) {
						MapSearch.Search.I().searchEvent();
					}
				} else {alert('Sorry but your location couldn\'t be found. Please try again.');}
			}
			try {this.map.addControl(new LocationSearchControl());} catch(e){}
			
			this.Types.Normal = G_NORMAL_MAP;
			this.Types.Sat = G_SATELLITE_MAP;
			this.Types.Hybrid = G_HYBRID_MAP;
			this.Types.Terrain = G_PHYSICAL_MAP;
			
			this.overlays = {
				street: new GStreetviewOverlay(),
				streetDisplay: false,
				traffic: new GTrafficOverlay(),
				trafficDisplay: false,
				trafficAdded: false
			}
			
			this.addEvent('singlerightclick', function(){this._rightClick(arguments[0], arguments[1], arguments[2]);}.bind(this));
			this.addEvent('click', function(){this._click(arguments[0], arguments[1], arguments[2]);}.bind(this));
			this.addEvent('moveend', function(){this._moveend();}.bind(this));
			this.addEvent('zoomend', function(){this._zoomend(arguments[0], arguments[1]);}.bind(this));
			this.addEvent('dragend', function(){this._dragend();}.bind(this));
			this.addEvent('dragstart', function(){this._dragstart();}.bind(this));
			
			MapSearch.Map.Search.I();
			
			this.GUI.Status.toggleMapStatus(false);
			
			MapSearch.Map.InitilizeCallback();
		} else {
			this.GUI.Status.setMapStatus(MapSearch.Config.GUI.MSGs.MapInCompatible);
		}
	},
	unLoadMap: function(pEvent){
		GUnload();
	},
	createPushpin: function(point, html, iconSet){
		return new MapSearch.Map.Pushpin.Google(point, html, iconSet);
	},
	addPushpins: function(pushpins){
		pushpins.each(
			function(iter){
				this.map.addOverlay(iter);
			}.bind(this)
		);
	},
	setType: function(type){
		this.map.setMapType(type);
	},
	toggleStreetview: function(display){
		if(display && !this.overlays.streetDisplay){
			this.map.addOverlay(this.overlays.street);
			this.overlays.streetDisplay = true;
			if(MapSearch.Map.Streetview.I().icon != null){
				MapSearch.Map.Streetview.I().icon.show();
			} else {
				var center = this.getCenter();
				MapSearch.Map.Streetview.I().createIcon(center);
			}
		} else if(!display && this.overlays.streetDisplay) {
			this.map.removeOverlay(this.overlays.street);
			this.overlays.streetDisplay = false;
			if(MapSearch.Map.Streetview.I().icon != null){
				MapSearch.Map.Streetview.I().icon.hide();
			}
		}
	},
	toggleTraffic: function(display){
		if(display && !this.overlays.trafficDisplay){
			if (!this.overlays.trafficAdded) {
				this.map.addOverlay(this.overlays.traffic);
				this.overlays.trafficAdded = true;
			} else {
				this.overlays.traffic.show()
			}
			this.overlays.trafficDisplay = true;
		} else if(!display && this.overlays.trafficDisplay) {
			this.overlays.traffic.hide();
			this.overlays.trafficDisplay = false;
		}
	},
	/*
	 * Sets
	 */
	setMapType: function(type){
		this.map.setMapType = type;
	},
	setCenter: function(LatLong, Zoom){
		this.map.setCenter(LatLong, Zoom);
	},
	/*
	 * Gets
	 */
	getBounds: function(){
		return this.map.getBounds();
	},
	getSouthWest: function(){
		var temp = this.getBounds().getSouthWest();
		return new MapSearch.Map.LatLong(temp.lat(), temp.lng());
	},
	getNorthEast: function(){
		var temp = this.getBounds().getNorthEast();
		return new MapSearch.Map.LatLong(temp.lat(), temp.lng());
	},
	getZoom: function(){
		return this.map.getZoom();
	},
	getCenter: function(){
		return this.map.getCenter();
	},
	/*
	 * Events
	 */
	zoomIn: function(){
		this.map.zoomOut();
	},
	zoomOut: function(){
		this.map.zoomIn();
	},
	panTo: function(LatLong){
		this.map.panTo(LatLong);
	},
	addEvent: function(event, callback){
		return GEvent.addListener(this.map, event, callback);
	},
	_rightClick: function(mXY, tileURL, gMarker){
		var event = new MapSearch.Map.Event();
		var pos = $GetAbsPos($('SearchMap'));
		pos.x += mXY.x;
		pos.y += mXY.y;
		event.setMouseXY(pos);
		event.setMapElement(gMarker);
		
		this.events.rightClick.each(function(iter){
			iter(event);
		});
	},
	_click: function(){
		var event = new MapSearch.Map.Event();
		if (arguments[0] != null) {
			event.setMapElement(arguments[0]);
			event.setLatLong(arguments[2]);
		} else {
			event.setLatLong(arguments[1]);
		}
		
		this.events.click.each(function(iter){
			iter(event);
		});
	},
	_moveend: function(){
		this.events.moveEnd.each(function(iter){
			iter();
		});
	},
	_dragend: function(){
		this.events.dragEnd.each(function(iter){
			iter();
		});
	},
	_dragstart: function(){
		this.events.dragStart.each(function(iter){
			iter();
		});
	},
	_zoomend: function(oldLvl, newLvl){
		this.events.zoomEnd.each(function(iter){
			iter();
		});
		
	}
});
/**
 * @author nick
 */
MapSearch.Map.LocationSearch = Class.create({
	initialize: function(callback){
		this.geocoder = new GClientGeocoder();
		this.callback = callback;
	},
	search: function(address){
		foundLocation = null;
		MapSearch.Map.LocationSearch.Areas.I().areas.each(function(iter){
				if(String(iter.value).toLowerCase().startsWith(String(address).toLowerCase())){
					if (iter.Lat != 0 && iter.Lng != 0) {
						foundLocation = true;
						this.searchResult(new google.maps.LatLng(iter.Lat, iter.Lng));
					}
					throw $break;
				}
		}.bind(this));
		if(foundLocation == null){
			this.geocoder.getLatLng(address, function(point){this.searchResult(point);}.bind(this));
		}
		MapSearch.EventTracking.ZoomToolEvent(address);
	},
	searchResult: function(point){
		if(!point){
			this.callback(null);
		} else {
			this.callback(point);
		}
	}
});

MapSearch.Map.LocationSearch.Areas = Class.create({
	initialize: function(){
		this.inputField = null;
		this.areas = new Array();
		this.theDiv = null;
		this.currentElement = null;
	},
	keyPresed: function(keyCode){
		if(this.theDiv == null){
			this.create();
		}
		if (keyCode != 0) {
			//Alpha
			if(keyCode >= 33 && keyCode <= 126) {
				this.filter(this.inputField.getValue() + String.fromCharCode(keyCode));
			} else {
				this.filter(this.inputField.getValue());
			}
		}
	},
	keyUp: function(keyCode){
		if(keyCode == 38){
			//Arrow Up
			if(this.currentElement != null){
				this.currentElement.style.backgroundColor = '#fff';
				this.currentElement.style.color = '#464646';
				this.currentElement = $(this.currentElement).previous(0);
			} else {
				this.currentElement = this.theDiv.lastChild;
			}
			if(this.currentElement){
				this.currentElement.style.backgroundColor = '#464646';
				this.currentElement.style.color = '#fff';
			} else {
				this.currentElement = null;
			}
		} else if (keyCode == 40) {
			//Arrow Down
			if(this.currentElement == null){
				this.currentElement = $(this.theDiv).down(0);
			} else {
				this.currentElement.style.backgroundColor = '#fff';
				this.currentElement.style.color = '#464646';
				this.currentElement = $(this.currentElement).next(0);
			}
			if(this.currentElement){
				this.currentElement.style.backgroundColor = '#464646';
				this.currentElement.style.color = '#fff';
			} else {
				this.currentElement = null;
			}
		} else if (keyCode == 8) {
			//Backspace
			this.filter(this.inputField.getValue());
			
		}
	},
	enterKeyPressed: function(){
		if(this.currentElement){
			this.inputField.value = this.currentElement.innerHTML;
		}
	},
	addArea: function(value, lat, lng){
		this.areas[this.areas.length] = {
			value:value,
			Lat: lat,
			Lng: lng
		};
	},
	hide: function(){
		if(this.theDiv == null){
			this.create();
		}
		this.currentElement = null;
		this.theDiv.innerHTML = '';
		this.theDiv.style.display = 'None';
	},
	create: function(){
		this.theDiv = document.createElement('div');
		var pos = $G.getAbsolutePosition(this.inputField);
		var height = $(this.inputField).getHeight();
		var x = pos.x;
		var y = pos.y + height;
		this.theDiv.style.position = 'absolute';
		this.theDiv.style.top = y+'px';
		this.theDiv.style.left = x+'px';
		this.theDiv.style.borderColor = '#000';
		this.theDiv.style.borderWidth = '1px';
		this.theDiv.style.borderStyle = 'solid';
		this.theDiv.style.backgroundColor = '#fff';
		this.theDiv.style.color = '#464646';
		this.theDiv.style.display = '';
		this.theDiv.style.zIndex = '1000';
		this.theDiv.style.fontSize = '12px';
		this.theDiv.style.width = this.inputField.getWidth() +'px';
		document.body.appendChild(this.theDiv);
	},
	filter: function(value){
		if (value) {
			this.currentElement = null;
			this.theDiv.innerHTML = '';
			this.theDiv.style.display = '';
			this.areas.each(function(iter){
				if(String(iter.value).toLowerCase().startsWith(String(value).toLowerCase())){
					var tempEl = document.createElement('div')
					tempEl.style.padding = '2px';
					tempEl.style.paddingLeft = '4px';
					tempEl.style.paddingRight = '4px';
					tempEl.style.cursor = 'pointer';
					tempEl.appendChild(document.createTextNode(iter.value));
					tempEl.onmouseover = function(){
						if (this.currentElement != null) {
							this.currentElement.style.backgroundColor = '#fff';
							this.currentElement.style.color = '#464646';
						}
						this.currentElement = tempEl;
						this.currentElement.style.backgroundColor = '#464646';
						this.currentElement.style.color = '#fff';
					}.bind(this)
					tempEl.onclick = function(){
						this.inputField.onsearch();
					}.bind(this)
					
					this.theDiv.appendChild(tempEl);
				}
			}.bind(this));
		} else {
			this.hide();
		}
	}
});
MapSearch.Map.LocationSearch.Areas.Instance = null;
MapSearch.Map.LocationSearch.Areas.I = function(){
	if(MapSearch.Map.LocationSearch.Areas.Instance == null){
		MapSearch.Map.LocationSearch.Areas.Instance = new MapSearch.Map.LocationSearch.Areas();
	}
	return MapSearch.Map.LocationSearch.Areas.Instance;
}
/**
 * @author nick
 */
MapSearch.Map.Search = Class.create({
	initialize: function(){
		this.localSearch = new google.search.LocalSearch();
		this.localSearch.setNoHtmlGeneration();
		this.localSearch.setCenterPoint(MapSearch.Map.I().map);
		this.localSearch.setResultSetSize(google.search.Search.LARGE_RESULTSET);
		this.localSearch.setSearchCompleteCallback(this, this.searchReturn);
		this.searchQueue = new Array();
		this.searching = false;
	},
	search: function(term, callback){
		this.searchQueue[this.searchQueue.length] = {term: term, callback: callback}
		if(!this.searching){
			this._search(term);
		}
	},
	_search: function(term){
		this.searching = true;
		this.localSearch.execute(term);
	},
	searchReturn: function(){
		var results = new Array();
		this.localSearch.results.each(function(result){
			var temp = {
				streetAddress: result.addressLines[0],
				cityState: result.addressLines[1],
				title: result.titleNoFormatting,
				url: result.url,
				lat: result.lat,
				lng: result.lng,
				phones: result.phoneNumbers
			}
			results[results.length] = temp;
		});
		results = {results:results, term: this.searchQueue[0].term}
		this.searchQueue[0].callback(results);
		this.searchQueue[0] = null;
		this.searchQueue = this.searchQueue.compact();
		if(this.searchQueue.length > 0){
			this._search(this.searchQueue[0].term);
		} else {
			this.searching = false;
		}
	}
});
MapSearch.Map.Search.Instance = null;
MapSearch.Map.Search.I = function(){
	if(MapSearch.Map.Search.Instance == null){MapSearch.Map.Search.Instance = new MapSearch.Map.Search();}
	return MapSearch.Map.Search.Instance;
}
MapSearch.Map.Pushpin = {}
MapSearch.Map.Pushpin.Manager = Class.create({
	initialize: function(){
		this.markers = new Array();
		this.zoomLevel = null;
		
		this.map = MapSearch.Map.I();
		this.zoomEvent = this.map.addEvent('zoomend', function(){this.mapZoom();}.bind(this));
	},
	mapZoom: function(){
		var zoom = Number(this.map.getZoom());
		
		if(this.zoomLevel == null){
			this.zoomLevel = zoom;
			this.updateZoom(zoom);
		} else if(zoom != this.zoomLevel){
			if(zoom >= 0 && zoom <= MapSearch.Config.Map.iconLevels.tier1 && this.zoomLevel >= 0 && this.zoomLevel <= MapSearch.Config.Map.iconLevels.tier1){
				//Do nothing Still in the same zone 1
			} else if(zoom > MapSearch.Config.Map.iconLevels.tier1 && zoom <= MapSearch.Config.Map.iconLevels.tier2 && this.zoomLevel > MapSearch.Config.Map.iconLevels.tier1 && this.zoomLevel <= MapSearch.Config.Map.iconLevels.tier2) {
				//Do nothing Still in the same zone 2
			} else if(zoom > MapSearch.Config.Map.iconLevels.tier2 && zoom <= MapSearch.Config.Map.iconLevels.tier3 && this.zoomLevel > MapSearch.Config.Map.iconLevels.tier2 && this.zoomLevel <= MapSearch.Config.Map.iconLevels.tier3) {
				//Do nothing Still in the same zone 3
			} else {
				this.updateZoom(zoom);
			}
			this.zoomLevel = zoom;
		}
	},
	updateZoom: function(zoom){
		this.markers.each(function(iter){
			iter.updateIcon(zoom);
		});
	},
	addMarker: function(marker){
		this.markers[this.markers.length] = marker;
	},
	removeMarker: function(marker){
		var index = this.markers.indexOf(marker);
		if (index != -1) {
			this.markers[index] = null;
			this.markers = this.markers.compact();
		}
	}
});
MapSearch.Map.Pushpin.Manager.Instance = null;
MapSearch.Map.Pushpin.Manager.I = function(){
	if(MapSearch.Map.Pushpin.Manager.Instance == null){
		MapSearch.Map.Pushpin.Manager.Instance = new MapSearch.Map.Pushpin.Manager();
	}
	return MapSearch.Map.Pushpin.Manager.Instance;
}

MapSearch.Map.Pushpin.Base = Class.create({
	initialize: function(id, point, html){
		
	}
});
MapSearch.Map.Pushpin.Google = Class.create(MapSearch.Map.Pushpin.Base, {
	initialize: function($super, point, html, iconSet, iconOptions){
		$super();
		this.html = html;
		this.point = point;
		this.iconSet = iconSet;
		
		this.icon = new GIcon(G_DEFAULT_ICON);
		this.icon.image = this.iconSet.near.icon;
		this.icon.shadow = this.iconSet.near.shadow;
		this.icon.iconSize = new GSize(this.iconSet.near.iconW,this.iconSet.near.iconH);
		this.icon.shadowSize = new GSize(this.iconSet.near.shadowW,this.iconSet.near.shadowH);
		this.icon.iconAnchor = new GPoint(this.iconSet.near.anchorX,this.iconSet.near.anchorY);
		if (this.iconSet.near.windowX != null && this.iconSet.near.windowY != null) {
			this.icon.infoWindowAnchor = new GPoint(this.iconSet.near.windowX, this.iconSet.near.windowY);
		}
		if (this.iconSet.near.imageMap != null) {
			this.icon.imageMap = this.iconSet.near.imageMap;
		}
		if (this.iconSet.near.printImage != null) {
			this.icon.printImage = this.iconSet.near.printImage;
			this.icon.mozPrintImage = this.iconSet.near.printImage;
		}
		if (this.iconSet.near.transparent != null) {
			this.icon.transparent = this.iconSet.near.transparent;
		}

		var MarkerOptions = {
			icon:this.icon
		}
		Object.extend(MarkerOptions, iconOptions || {});
		
		this.pushpin = new GMarker(point, MarkerOptions);
		
		this.map = MapSearch.Map.I();
		
		//this.zoomEvent = this.map.addEvent('zoomend', function(){this.mapZoom();}.bind(this));
		this.event = GEvent.addListener(this.pushpin, 'click', function(){this.iconClick();}.bind(this));
		this.windowEvent = GEvent.addListener(this.pushpin, 'infowindowopen', function(){this._windowOpened();}.bind(this));
		this.windowCloseEvent = GEvent.addListener(this.pushpin, 'infowindowbeforeclose', function(){if(this.lazyLoadTimer != null){clearTimeout(this.lazyLoadTimer);}}.bind(this));
		this.extendedEvents = new Array();
		
		this.lazyLoadTimer = null;
		
		MapSearch.Map.Pushpin.Manager.I().addMarker(this);
	},
	setPoint: function(point){
		this.pushpin.setLatLng(point);
		this.point = point;
	},
	setHTML: function(html){
		this.html = html;
	},
	showWindow: function(){
		if ($E.isArray(this.html)) {
			this.pushpin.openInfoWindowTabsHtml(this.html);
		} else {
			this.pushpin.openInfoWindowHtml(this.html);
		}
	},
	hideWindow: function(){
		this.pushpin.closeInfoWindow();
	},
	_windowOpened: function(){
		$$('img.LazyLoadImg').each(function(image){
			if (image.isVisible()) {
				image.src = image.attributes['imageSrc'].nodeValue;
			}
		});
		
		this.lazyLoadTimer = setTimeout(function(){
			$$('img.LazyLoadImg').each(function(image){
				image.src = image.attributes['imageSrc'].nodeValue;
			})
			this.lazyLoadTimer = null;
		}.bind(this), 1000);
	},
	del: function(){
		GEvent.removeListener(this.event);
		GEvent.removeListener(this.windowEvent);
		this.event = null;
		this.windowEvent = null;
		this.extendedEvents.each(function(iter){GEvent.removeListener(iter);});
		this.map.map.removeOverlay(this.pushpin);
		this.pushpin = null;
		MapSearch.Map.Pushpin.Manager.I().removeMarker(this);
	},
	add: function(){
		this.map.map.addOverlay(this.pushpin);
		this.updateIcon(this.map.getZoom());
	},
	show: function(){
		this.pushpin.show();
		this.updateIcon(this.map.getZoom());
	},
	hide: function(){
		this.pushpin.hide();
	},
	isHidden: function(){
		return this.pushpin.isHidden();
	},
	updateIcon: function(zoom){
		if (!this.isHidden()) {
			if(zoom <= MapSearch.Config.Map.iconLevels.tier1){
				this.icon.image = this.iconSet.far.icon;
				this.icon.iconSize = new GSize(this.iconSet.far.iconW,this.iconSet.far.iconH);
				this.icon.shadow = this.iconSet.far.shadow;
				this.icon.shadowSize = new GSize(this.iconSet.far.shadowW,this.iconSet.far.shadowH);
				this.icon.iconAnchor = new GPoint(this.iconSet.far.anchorX,this.iconSet.far.anchorY);
				if (this.iconSet.far.windowX != null && this.iconSet.far.windowY != null) {
					this.icon.infoWindowAnchor = new GPoint(this.iconSet.far.windowX, this.iconSet.far.windowY);
				}
				if (this.iconSet.far.imageMap != null) {
					this.icon.imageMap = this.iconSet.far.imageMap;
				}
				if (this.iconSet.far.printImage != null) {
					this.icon.printImage = this.iconSet.far.printImage;
					this.icon.mozPrintImage = this.iconSet.far.printImage;
				}
				if (this.iconSet.far.transparent != null) {
					this.icon.transparent = this.iconSet.far.transparent;
				}
			} else if(zoom <= MapSearch.Config.Map.iconLevels.tier2){
				this.icon.image = this.iconSet.mid.icon;
				this.icon.iconSize = new GSize(this.iconSet.mid.iconW,this.iconSet.mid.iconH);
				this.icon.shadow = this.iconSet.mid.shadow;
				this.icon.shadowSize = new GSize(this.iconSet.mid.shadowW,this.iconSet.mid.shadowH);
				this.icon.iconAnchor = new GPoint(this.iconSet.mid.anchorX,this.iconSet.mid.anchorY);
				if (this.iconSet.mid.windowX != null && this.iconSet.mid.windowY != null) {
					this.icon.infoWindowAnchor = new GPoint(this.iconSet.mid.windowX, this.iconSet.mid.windowY);
				}
				if (this.iconSet.mid.imageMap != null) {
					this.icon.imageMap = this.iconSet.mid.imageMap;
				}
				if (this.iconSet.mid.printImage != null) {
					this.icon.printImage = this.iconSet.mid.printImage;
					this.icon.mozPrintImage = this.iconSet.mid.printImage;
				}
				if (this.iconSet.mid.transparent != null) {
					this.icon.transparent = this.iconSet.mid.transparent;
				}
			} else {
				this.icon.image = this.iconSet.near.icon;
				this.icon.iconSize = new GSize(this.iconSet.near.iconW,this.iconSet.near.iconH);
				this.icon.shadow = this.iconSet.near.shadow;
				this.icon.shadowSize = new GSize(this.iconSet.near.shadowW,this.iconSet.near.shadowH);
				this.icon.iconAnchor = new GPoint(this.iconSet.near.anchorX,this.iconSet.near.anchorY);
				if (this.iconSet.near.windowX != null && this.iconSet.near.windowY != null) {
					this.icon.infoWindowAnchor = new GPoint(this.iconSet.near.windowX, this.iconSet.near.windowY);
				}
				if (this.iconSet.near.imageMap != null) {
					this.icon.imageMap = this.iconSet.near.imageMap;
				}
				if (this.iconSet.near.printImage != null) {
					this.icon.printImage = this.iconSet.near.printImage;
					this.icon.mozPrintImage = this.iconSet.near.printImage;
				}
				if (this.iconSet.near.transparent != null) {
					this.icon.transparent = this.iconSet.near.transparent;
				}
			}
			this.pushpin.remove();
			this.pushpin.initialize(this.map.map);
			this.pushpin.redraw(true);
		}
	},
	
	/*
	 * Events
	 */
	
	mapZoom: function(){
		//Deprecated
		MapSearch.Console.warn('[Deprecated]: MapSearch.Map.Pushpin.Google.mapZoom');
		this.updateIcon();
	},
	iconClick: function(){
		this.showWindow();
	},
	addEvent: function(event, callback){
		var event = GEvent.addListener(this.pushpin, event, callback);
		this.extendedEvents[this.extendedEvents.length] = event;
		return event;
	}
});
MapSearch.Map.Streetview = Class.create({
	initialize: function(){
		this.window = new MapSearch.GUI.Window.Window('Streetview');
		this.window.setHideCallback(function(){this._hide();}.bind(this));
		this.window.setHTML('');
		this.location = null;
		this.pano = null;
		this.created=false;
		this.client = new GStreetviewClient();
		
		this.icon = null;
	},
	create: function(){
		this.window.setDim(700,400);
		this.window.showCenter();
		this.pano = new GStreetviewPanorama(this.window.windowContent);
		GEvent.addListener(this.pano, 'initialized', function(data){this._updateLocation(data);}.bind(this));
		this.created = true;
	},
	createIcon: function(latLng){
		if (this.icon == null) {
			this.icon = new MapSearch.Map.Pushpin.Google(latLng, 'Steetview Location', MapSearch.Config.Icons.Base.littleMan, {draggable:true, bouncy:true, title:'StreetView'});
			this.icon.add();
			this.icon.setHTML(MapSearch.Template.Streetview.littleManBlank.evaluate({
				lat: latLng.lat(),
				lng: latLng.lng()
			}));
			this.icon.addEvent('dragend', function(latLng){this.iconDragend(latLng);}.bind(this));
		}
	},
	show: function(Lat, Lng){
		this.location = new GLatLng(Lat, Lng);
		if (this.icon == null) {
			this.createIcon(this.location);
		} else {
			if(this.icon.isHidden()){
				this.icon.show();
			}
			this.icon.hideWindow();
		}
		
		this.client.getNearestPanorama(this.location, function(data){this._show(data);}.bind(this));
	},
	_show: function(data){
		if (data.code != 200) {
			alert('Sorry but we could not locate a Streetview near this Property.');
			//this.icon.hide();
		} else {
			if (!this.created) {
				this.create();
			} else {
				this.window.show();
				this.pano.show();
			}
			
			//Display Streetview Overlay
			MapSearch.Map.I().toggleStreetview(true);
			MapSearch.GUI.Base.I().Tools.PanPoly.street=true;
			
			this.icon.setHTML(MapSearch.Template.Streetview.littleMan.evaluate({
				description: data.Location.description,
				lat: data.Location.lat,
				lng: data.Location.lng,
				copyright: data.Data.copyright
			}));
			
			this.location = data.Location.latlng;
			this.icon.setPoint(this.location);
			this.pano.setLocationAndPOV(this.location);
		}
	},
	_hide: function(){
		this.pano.hide();
	},
	_updateLocation: function(data){
		this.location = data.latlng;
		this.icon.setPoint(this.location);
		this.icon.setHTML(MapSearch.Template.Streetview.littleMan.evaluate({
				description: data.description,
				lat: data.lat,
				lng: data.lng,
				copyright: '&copy; Google'
			}));
	},
	iconDragend: function(latLng){
		this.show(latLng.lat(), latLng.lng());
		/*
		this.icon.setHTML(MapSearch.Template.Streetview.littleManBlank.evaluate({
			lat: latLng.lat(),
			lng: latLng.lng()
		}));
		*/
		//this.client.getNearestPanorama(new GLatLng(latLng.lat(), latLng.lng()), function(data){this._iconDragend(data);}.bind(this));
	},
	_iconDragend: function(data){
		if (data.code != 200) {
			alert('Sorry but we could not locate a Streetview near this Property.');
		} else {
			this.location = data.Location.latlng;
			this.icon.setPoint(this.location);
			this.icon.setHTML(MapSearch.Template.Streetview.littleMan.evaluate({
					description: data.description,
					lat: this.location.lat(),
					lng: this.location.lng(),
					copyright: '&copy; Google'
				}));
			this.icon.showWindow();
		}
	}
});
MapSearch.Map.Streetview.Instance = null;
MapSearch.Map.Streetview.I = function(){
	if(MapSearch.Map.Streetview.Instance == null){
		MapSearch.Map.Streetview.Instance = new MapSearch.Map.Streetview();
	}
	return MapSearch.Map.Streetview.Instance;
}
/**
 * Map Search Configs
 * 
 * @author Nick Verbeck <nick@activewebsitecom>
 * @file /js/map_search/MapSearch.Config.js
 */
MapSearch.Config = {
	Company:'Active Website',
	CompanyID: 0
}
MapSearch.Config.GUI = {
	windowSize: {width:1000, height:700},
	Theme: MapSearch.GUI.Theme.Blue
}
MapSearch.Config.Search = {
	Auto: false,
	Enabled: true,
	SignleProperty: {
		Zoom: null
	}
}
MapSearch.Config.Urls = {}
MapSearch.Config.Urls.Base = {
	imageServer: '',
	propertyPicServer: null
}
MapSearch.Config.GUI.MSGs = {
	Loading: 'Loading Map Interface.....',
	BindingInterface: 'Binding Events to Interface.....',
	MapLoading: 'Loading Map',
	MapInit: 'Initializing Map',
	MapInCompatible: 'We are sorry to inform you that your browser is not supported by this map',
	MapSearch: 'Searching for Real Estate in the Area',
	MapPlotting: 'Properties Found. Plotting Results.',
	SearchDisabled: "We're sorry but search has been disabled."
}
MapSearch.Config.Map = {
	defaultLatLong: {
		Lat: 39.73042572969996,
		Long: -104.99908447265625
	},
	defaultLocation:null,
	defaultZoom: 16,
	iconLevels: {
		tier1: 9,
		tier2: 13,
		tier3: 19
	}
}
MapSearch.Config.Dates = {
	propAdded: new Date(),
	propUpdated: new Date()
}
MapSearch.Config.Dates.propAdded.setDate(MapSearch.Config.Dates.propAdded.getDate()-30);
MapSearch.Config.Dates.propUpdated.setDate(MapSearch.Config.Dates.propUpdated.getDate()-10);

MapSearch.Config.IDX = new Array();
//IRES
MapSearch.Config.IDX[1] = '<img align="right" src="/images/system/map_search/idx_logos/ires.gif" />';
//Jackson
MapSearch.Config.IDX[3] = '<img align="right" src="/images/system/map_search/idx_logos/idx.gif" />';
//AAAR
MapSearch.Config.IDX[4] = '<img align="right" src="/images/system/map_search/idx_logos/idx.gif" />';
//Metrolist
MapSearch.Config.IDX[5] = '<img align="right" src="/images/system/map_search/idx_logos/idx.gif" />';
//Reinhart
MapSearch.Config.IDX[6] = '';
//Tricmls
MapSearch.Config.IDX[7] = '<img align="right" src="/images/system/map_search/idx_logos/idx.gif" />';
//MRed
MapSearch.Config.IDX[8] = '<img align="right" src="/images/system/map_search/idx_logos/broker_recip.gif" />';
//GNair
MapSearch.Config.IDX[9] = '<img align="right" src="/images/system/map_search/idx_logos/broker_recip.gif" />';
//Swmric
MapSearch.Config.IDX[10] = '<img align="right" src="/images/system/map_search/idx_logos/broker_recip.gif" />';
//Statewide
MapSearch.Config.IDX[11] = '<img align="right" src="/images/system/map_search/idx_logos/state-wide.gif" />';
//NTreis
MapSearch.Config.IDX[12] = '<img align="right" src="/images/system/map_search/idx_logos/ebby.gif" />';
//Rubloff
MapSearch.Config.IDX[13] = '';
//VAIL
MapSearch.Config.IDX[14] = '<img align="right" src="/images/system/map_search/idx_logos/idx.gif" />';
//GSMLS
MapSearch.Config.IDX[15] = '<img align="right" src="/images/system/map_search/idx_logos/gsmlx.gif" />';
//Resi
MapSearch.Config.IDX[16] = '';
//CMLS
MapSearch.Config.IDX[17] = '<img align="right" src="/images/system/map_search/idx_logos/helen_adams.gif" />';
//Trend
MapSearch.Config.IDX[18] = '<img align="right" src="/images/system/map_search/idx_logos/trend.gif" />';
//Piedmont
MapSearch.Config.IDX[19] = '<img align="right" src="/images/system/map_search/idx_logos/helen_adams.gif" />';
//Ebby
MapSearch.Config.IDX[20] = '';
/**
 * Map Search Base Icon Configs
 * 
 * @author Nick Verbeck <nick@activewebsitecom>
 * @file /js/map_search/MapSearch.Config.Icons.Base.js
 */
MapSearch.Config.Icons = {}
MapSearch.Config.Icons.Base = {
	newProp: {
		far: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/GreenFar.png',
			iconH: 14, iconW: 12,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/shadow-house-far.png',
			shadowH: 14, shadowW: 20,
			anchorX: 5, anchorY: 13,
			windowX: 6, windowY: 0,
			imageMap: new Array(0,5, 6,0, 9,2, 11,5, 9,10, 5,13, 1,9)
		},
		mid: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/GreenMid.png',
			iconH: 26, iconW: 22,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/shadow-house-mid.png',
			shadowH: 26, shadowW: 36,
			anchorX: 10, anchorY: 25,
			windowX: 11, windowY: 0,
			imageMap: new Array(0,9, 11,0, 18,2, 21,9, 17,18, 10,25, 3,18)
		},
		near: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/GreenNewHouse.png',
			iconH: 39, iconW: 33,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/shadow-house-close.png',
			shadowH: 39, shadowW: 53,
			anchorX: 14, anchorY: 37,
			windowX: 18, windowY: 0,
			imageMap: new Array(0,14, 15,0, 28,4, 32,15, 27,28, 15,38, 5,28)
		},
		result: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/Green-Result.gif',
		name: new Template('New Properties')
	},
	oldProp: {
		far: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/OrangeFar.png',
			iconH: 14, iconW: 12,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/shadow-house-far.png',
			shadowH: 14, shadowW: 20,
			anchorX: 5, anchorY: 13,
			windowX: 6, windowY: 0,
			imageMap: new Array(0,5, 6,0, 9,2, 11,5, 9,10, 5,13, 1,9)
		},
		mid: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/OrangeMid.png',
			iconH: 26, iconW: 22,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/shadow-house-mid.png',
			shadowH: 26, shadowW: 36,
			anchorX: 10, anchorY: 25,
			windowX: 11, windowY: 0,
			imageMap: new Array(0,9, 11,0, 18,2, 21,9, 17,18, 10,25, 3,18)
		},
		near: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/OrangeOldHouse.png',
			iconH: 39, iconW: 33,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/shadow-house-close.png',
			shadowH: 39, shadowW: 53,
			anchorX: 14, anchorY: 37,
			windowX: 18, windowY: 0,
			imageMap: new Array(0,14, 15,0, 28,4, 32,15, 27,28, 15,38, 5,28)
		},
		result: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/Orange-Result.gif',
		name: new Template('Current Listings')
	},
	updatedProp: {
		far: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/BlueFar.png',
			iconH: 14, iconW: 12,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/shadow-house-far.png',
			shadowH: 14, shadowW: 20,
			anchorX: 5, anchorY: 13,
			windowX: 6, windowY: 0,
			imageMap: new Array(0,5, 6,0, 9,2, 11,5, 9,10, 5,13, 1,9)
		},
		mid: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/BlueMid.png',
			iconH: 26, iconW: 22,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/shadow-house-mid.png',
			shadowH: 26, shadowW: 36,
			anchorX: 10, anchorY: 25,
			windowX: 11, windowY: 0,
			imageMap: new Array(0,9, 11,0, 18,2, 21,9, 17,18, 10,25, 3,18)
		},
		near: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/BlueUpdatedHouse.png',
			iconH: 39, iconW: 33,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/shadow-house-close.png',
			shadowH: 39, shadowW: 53,
			anchorX: 14, anchorY: 37,
			windowX: 18, windowY: 0,
			imageMap: new Array(0,14, 15,0, 28,4, 32,15, 27,28, 15,38, 5,28)
		},
		result: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/Blue-Result.gif',
		name: new Template('Recently Updated Properties')
	},
	viewed: {
		far: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/viewed-far.png',
			iconH: 14, iconW: 12,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/shadow-house-far.png',
			shadowH: 14, shadowW: 20,
			anchorX: 5, anchorY: 13,
			windowX: 6, windowY: 0,
			imageMap: new Array(0,5, 6,0, 9,2, 11,5, 9,10, 5,13, 1,9)
		},
		mid: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/viewed-mid.png',
			iconH: 26, iconW: 22,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/shadow-house-mid.png',
			shadowH: 26, shadowW: 36,
			anchorX: 10, anchorY: 25,
			windowX: 11, windowY: 0,
			imageMap: new Array(0,9, 11,0, 18,2, 21,9, 17,18, 10,25, 3,18)
		},
		near: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/viewed.png',
			iconH: 39, iconW: 33,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/shadow-house-close.png',
			shadowH: 39, shadowW: 53,
			anchorX: 14, anchorY: 37,
			windowX: 18, windowY: 0,
			imageMap: new Array(0,14, 15,0, 28,4, 32,15, 27,28, 15,38, 5,28)
		},
		result: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/Yellow-Result.gif',
		name: new Template('Recently Viewed')
	},
	singleProperty: {
		far: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/mlshouse-far.png',
			iconH: 26, iconW: 23,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/shadow-mlshouse-far.png',
			shadowH: 26, shadowW: 37,
			anchorX: 12, anchorY: 26,
			windowX: 12, windowY: 2,
			imageMap: new Array(0,10, 11,0, 18,3, 21,10, 19,19, 11,25, 3,18, 1,10)
		},
		mid: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/mlshouse-mid.png',
			iconH: 40, iconW: 35,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/shadow-mlshouse-mid.png',
			shadowH: 40, shadowW: 56,
			anchorX: 17, anchorY: 40,
			windowX: 17, windowY: 2,
			imageMap: new Array(1,15, 17,1, 29,5, 33,16, 28,28, 17,38, 6,28)
		},
		near: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/mlshouse.png',
			iconH: 56, iconW: 49,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/shadow-mlshouse-close.png',
			shadowH: 56, shadowW: 78,
			anchorX: 25, anchorY: 56,
			windowX: 25, windowY: 2,
			imageMap: new Array(2,23, 24,2, 40,7, 46,23, 40,4, 24,54, 8,40)
		},
		result: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/mlshouse-mid.png',
		name: new Template('MLS Search Result')
	},
	openHouse: {
		far: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/OpenHouseFar.png',
			iconH: 24, iconW: 20,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/shadow-openhouse-far.png',
			shadowH: 26, shadowW: 35,
			anchorX: 5, anchorY: 19,
			windowX: 14, windowY: 0,
			imageMap: new Array(0,16, 6,10, 7,1, 20,1, 20,12, 11,12, 12,16, 10,22, 5,25, 2,22)
		},
		mid: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/OpenHouseMid.png',
			iconH: 43, iconW: 35,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/shadow-openhouse-mid.png',
			shadowH: 57, shadowW: 43,
			anchorX: 10, anchorY: 35,
			windowX: 23, windowY: 2,
			imageMap: new Array(0,27, 12,17, 12,1, 33,2, 34,19, 17,20, 20,27, 17,36, 10,41, 3,36)
		},
		near: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/OpenHouseClose.png',
			iconH: 62, iconW: 51,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/shadow-openhouse-close.png',
			shadowH: 63, shadowW: 83,
			anchorX: 14, anchorY: 51,
			windowX: 34, windowY: 2,
			imageMap: new Array(0,4, 15,25, 17,2, 49,2, 29,28, 27,29, 30,40, 25,51, 14,61, 5,51)
		},
		result: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/Open-Result.gif',
		name: new Template('Open House')
	},
	office: {
		far: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/office-far.png',
			iconH: 15, iconW: 15,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/shadow-office-far.png',
			shadowH: 16, shadowW: 25,
			anchorX: 7, anchorY: 7,
			windowX: 7, windowY: 0
		},
		mid: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/office-mid.png',
			iconH: 24, iconW: 24,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/shadow-office-mid.png',
			shadowH: 37, shadowW: 24,
			anchorX: 12, anchorY: 12,
			windowX: 12, windowY: 0
		},
		near: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/office-close.png',
			iconH: 35, iconW: 35,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/shadow-office-close.png',
			shadowH: 35, shadowW: 53,
			anchorX: 17, anchorY: 17,
			windowX: 17, windowY: 0
		},
		result: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/office-close.png',
		name: new Template('#{company} Offices')
	},
	favorites: {
		far: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/FavFar.png',
			iconH: 11, iconW: 12,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/shadow-fav-far.png',
			shadowH: 10, shadowW: 18,
			anchorX: 2, anchorY: 9,
			windowX: 6, windowY: 0
		},
		mid: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/FavMid.png',
			iconH: 20, iconW: 22,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/shadow-fav-mid.png',
			shadowH: 19, shadowW: 32,
			anchorX: 9, anchorY: 19,
			windowX: 11, windowY: 0
		},
		near: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/FavHeart.png',
			iconH: 27, iconW: 30,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/shadow-fav-close.png',
			shadowH: 27, shadowW: 46,
			anchorX: 12, anchorY: 23,
			windowX: 15, windowY: 0
		},
		result: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/FavHeart.png',
		name: new Template('My Favorites')
	},
	littleMan: {
		far: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/person.png',
			iconH: 35, iconW: 20,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/shadow-person.png',
			shadowH: 35, shadowW: 38,
			anchorX: 10, anchorY: 35,
			windowX: null, windowY: null
		},
		mid: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/person.png',
			iconH: 35, iconW: 20,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/shadow-person.png',
			shadowH: 35, shadowW: 38,
			anchorX: 10, anchorY: 35,
			windowX: null, windowY: null
		},
		near: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/person.png',
			iconH: 35, iconW: 20,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/shadow-person.png',
			shadowH: 35, shadowW: 38,
			anchorX: 10, anchorY: 35,
			windowX: null, windowY: null
		},
		result: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/person.png',
		name: new Template('Streetview Location')
	},
	community: {
		far: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/community-far.png',
			iconH: 13, iconW: 9,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/shadow-community-far.png',
			shadowH: 13, shadowW: 16,
			anchorX: 4, anchorY: 12,
			windowX: 4, windowY: 0,
			imageMap: new Array(0,6, 4,0, 8,6, 4,12)
		},
		mid: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/community-mid.png',
			iconH: 23, iconW: 16,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/shadow-community-mid.png',
			shadowH: 23, shadowW: 28,
			anchorX: 7, anchorY: 22,
			windowX: 7, windowY: 0,
			imageMap: new Array(0,11, 7,0, 15,11, 7,21)
		},
		near: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/community.png',
			iconH: 34, iconW: 24,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/shadow-community.png',
			shadowH: 34, shadowW: 42,
			anchorX: 11, anchorY: 31,
			windowX: 11, windowY: 0,
			imageMap: new Array(0,17, 11,0, 23,16, 12,32)
		},
		farHover: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/community_hover-far.png',
			iconH: 18, iconW: 13,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/shadow-community_hover-far.png',
			shadowH: 18, shadowW: 23,
			anchorX: 5, anchorY: 17,
			windowX: 5, windowY: 0,
			imageMap: new Array(0,8, 6,0, 11,8, 6,17)
		},
		midHover: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/community_hover-far.png',
			iconH: 28, iconW: 20,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/shadow-community_hover-mid.png',
			shadowH: 28, shadowW: 35,
			anchorX: 9, anchorY: 25,
			windowX: 9, windowY: 0,
			imageMap: new Array(0,14, 9,0, 19,13, 9,26)
		},
		nearHover: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/community_hover-far.png',
			iconH: 39, iconW: 27,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/shadow-community_hover-close.png',
			shadowH: 39, shadowW: 47,
			anchorX: 11, anchorY: 37,
			windowX: 11, windowY: 0,
			imageMap: new Array(0,17, 11,0, 26,18, 13,37)
		},
		result: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/Base_Icons/community.png',
		name: new Template('Search Area')
	}
}
//Lets reduce as much code as we can.
MapSearch.Config.Icons.Base.myOpenHouse = {};
MapSearch.Config.Icons.Base.myNewProp = {};
MapSearch.Config.Icons.Base.myOldProp = {};
MapSearch.Config.Icons.Base.myUpdatedProp = {};
Object.extend(MapSearch.Config.Icons.Base.myOpenHouse, MapSearch.Config.Icons.Base.openHouse);
Object.extend(MapSearch.Config.Icons.Base.myNewProp, MapSearch.Config.Icons.Base.newProp);
Object.extend(MapSearch.Config.Icons.Base.myOldProp, MapSearch.Config.Icons.Base.oldProp);
Object.extend(MapSearch.Config.Icons.Base.myUpdatedProp, MapSearch.Config.Icons.Base.updatedProp);
MapSearch.Config.Icons.Base.myOpenHouse.name = new Template('#{company} Open House');
MapSearch.Config.Icons.Base.myNewProp.name = new Template('#{company} New Listing');
MapSearch.Config.Icons.Base.myOldProp.name = new Template('#{company} Current Listing');
MapSearch.Config.Icons.Base.myUpdatedProp.name = new Template('#{company} Recently Updated');/**
 * Map Search POI Icon Configs
 * 
 * @author Nick Verbeck <nick@activewebsitecom>
 * @file /js/map_search/MapSearch.Config.Icons.POI.js
 */
MapSearch.Config.Icons.POI = {
	golf: {
		far: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/attraction-golf-far.png',
			iconH: 21,
			iconW: 12,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-far.png',
			shadowH: 21,
			shadowW: 23,
			anchorX: 5,
			anchorY: 20,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,5, 4,0, 9,0, 11,4, 6,20),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-far.png',
			printImage: null
		},
		mid: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/attraction-golf-mid.png',
			iconH: 38,
			iconW: 22,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-mid.png',
			shadowH: 39,
			shadowW: 42,
			anchorX: 9,
			anchorY: 38,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,10, 3,1, 11,0, 20,4, 21,9, 13,38, 9,37),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-mid.png',
			printImage: null
		},
		near: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/attraction-golf.png',
			iconH: 57,
			iconW: 33,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-close.png',
			shadowH: 57,
			shadowW: 61,
			anchorX: 13,
			anchorY: 55,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,14, 4,4, 15,0, 38,3, 31,13, 17,55, 14,55),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi.png',
			printImage: null
		},
		name: 'Golf Courses'
	},
	health: {
		far: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/attraction-health_club-far.png',
			iconH: 21,
			iconW: 12,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-far.png',
			shadowH: 21,
			shadowW: 23,
			anchorX: 5,
			anchorY: 20,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,5, 4,0, 9,0, 11,4, 6,20),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-far.png',
			printImage: null
		},
		mid: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/attraction-health_club-mid.png',
			iconH: 38,
			iconW: 22,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-mid.png',
			shadowH: 39,
			shadowW: 42,
			anchorX: 9,
			anchorY: 38,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,10, 3,1, 11,0, 20,4, 21,9, 13,38, 9,37),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-mid.png',
			printImage: null
		},
		near: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/attraction-health_club.png',
			iconH: 57,
			iconW: 33,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-close.png',
			shadowH: 57,
			shadowW: 61,
			anchorX: 13,
			anchorY: 55,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,14, 4,4, 15,0, 38,3, 31,13, 17,55, 14,55),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi.png',
			printImage: null
		},
		name: 'Health Clubs'
	},
	movie: {
		far: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/attraction-movie_theater-fa.png',
			iconH: 21,
			iconW: 12,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-far.png',
			shadowH: 21,
			shadowW: 23,
			anchorX: 5,
			anchorY: 20,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,5, 4,0, 9,0, 11,4, 6,20),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-far.png',
			printImage: null
		},
		mid: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/attraction-movie_theater-mi.png',
			iconH: 38,
			iconW: 22,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-mid.png',
			shadowH: 39,
			shadowW: 42,
			anchorX: 9,
			anchorY: 38,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,10, 3,1, 11,0, 20,4, 21,9, 13,38, 9,37),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-mid.png',
			printImage: null
		},
		near: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/attraction-movie_theater.png',
			iconH: 57,
			iconW: 33,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-close.png',
			shadowH: 57,
			shadowW: 61,
			anchorX: 13,
			anchorY: 55,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,14, 4,4, 15,0, 38,3, 31,13, 17,55, 14,55),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi.png',
			printImage: null
		},
		name: 'Movie Theaters'
	},
	arena: {
		far: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/attractions-arena-far.png',
			iconH: 21,
			iconW: 12,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-far.png',
			shadowH: 21,
			shadowW: 23,
			anchorX: 5,
			anchorY: 20,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,5, 4,0, 9,0, 11,4, 6,20),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-far.png',
			printImage: null
		},
		mid: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/attractions-arena-mid.png',
			iconH: 38,
			iconW: 22,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-mid.png',
			shadowH: 39,
			shadowW: 42,
			anchorX: 9,
			anchorY: 38,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,10, 3,1, 11,0, 20,4, 21,9, 13,38, 9,37),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-mid.png',
			printImage: null
		},
		near: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/attractions-arena.png',
			iconH: 57,
			iconW: 33,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-close.png',
			shadowH: 57,
			shadowW: 61,
			anchorX: 13,
			anchorY: 55,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,14, 4,4, 15,0, 38,3, 31,13, 17,55, 14,55),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi.png',
			printImage: null
		},
		name: 'Sports Stadiums'
	},
	recreation: {
		far: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/attractions-recreation-far.png',
			iconH: 21,
			iconW: 12,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-far.png',
			shadowH: 21,
			shadowW: 23,
			anchorX: 5,
			anchorY: 20,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,5, 4,0, 9,0, 11,4, 6,20),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-far.png',
			printImage: null
		},
		mid: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/attractions-recreation-mid.png',
			iconH: 38,
			iconW: 22,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-mid.png',
			shadowH: 39,
			shadowW: 42,
			anchorX: 9,
			anchorY: 38,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,10, 3,1, 11,0, 20,4, 21,9, 13,38, 9,37),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-mid.png',
			printImage: null
		},
		near: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/attractions-recreation.png',
			iconH: 57,
			iconW: 33,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-close.png',
			shadowH: 57,
			shadowW: 61,
			anchorX: 13,
			anchorY: 55,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,14, 4,4, 15,0, 38,3, 31,13, 17,55, 14,55),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi.png',
			printImage: null
		},
		name: 'Recreation'
	},
	tourist: {
		far: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/attraction-tourist-far.png',
			iconH: 21,
			iconW: 12,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-far.png',
			shadowH: 21,
			shadowW: 23,
			anchorX: 5,
			anchorY: 20,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,5, 4,0, 9,0, 11,4, 6,20),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-far.png',
			printImage: null
		},
		mid: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/attraction-tourist-mid.png',
			iconH: 38,
			iconW: 22,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-mid.png',
			shadowH: 39,
			shadowW: 42,
			anchorX: 9,
			anchorY: 38,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,10, 3,1, 11,0, 20,4, 21,9, 13,38, 9,37),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-mid.png',
			printImage: null
		},
		near: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/attraction-tourist.png',
			iconH: 57,
			iconW: 33,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-close.png',
			shadowH: 57,
			shadowW: 61,
			anchorX: 13,
			anchorY: 55,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,14, 4,4, 15,0, 38,3, 31,13, 17,55, 14,55),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi.png',
			printImage: null
		},
		name: 'Tourist Attractions'
	},
	courts: {
		far: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/government-courts-far.png',
			iconH: 21,
			iconW: 12,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-far.png',
			shadowH: 21,
			shadowW: 23,
			anchorX: 5,
			anchorY: 20,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,5, 4,0, 9,0, 11,4, 6,20),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-far.png',
			printImage: null
		},
		mid: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/government-courts-mid.png',
			iconH: 38,
			iconW: 22,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-mid.png',
			shadowH: 39,
			shadowW: 42,
			anchorX: 9,
			anchorY: 38,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,10, 3,1, 11,0, 20,4, 21,9, 13,38, 9,37),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-mid.png',
			printImage: null
		},
		near: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/government-courts.png',
			iconH: 57,
			iconW: 33,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-close.png',
			shadowH: 57,
			shadowW: 61,
			anchorX: 13,
			anchorY: 55,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,14, 4,4, 15,0, 38,3, 31,13, 17,55, 14,55),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi.png',
			printImage: null
		},
		name: 'Courts'
	},
	fire: {
		far: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/government-fire-far.png',
			iconH: 21,
			iconW: 12,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-far.png',
			shadowH: 21,
			shadowW: 23,
			anchorX: 5,
			anchorY: 20,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,5, 4,0, 9,0, 11,4, 6,20),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-far.png',
			printImage: null
		},
		mid: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/government-fire-mid.png',
			iconH: 38,
			iconW: 22,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-mid.png',
			shadowH: 39,
			shadowW: 42,
			anchorX: 9,
			anchorY: 38,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,10, 3,1, 11,0, 20,4, 21,9, 13,38, 9,37),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-mid.png',
			printImage: null
		},
		near: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/government-fire.png',
			iconH: 57,
			iconW: 33,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-close.png',
			shadowH: 57,
			shadowW: 61,
			anchorX: 13,
			anchorY: 55,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,14, 4,4, 15,0, 38,3, 31,13, 17,55, 14,55),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi.png',
			printImage: null
		},
		name: 'Fire Departments'
	},
	library: {
		far: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/government-library-far.png',
			iconH: 21,
			iconW: 12,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-far.png',
			shadowH: 21,
			shadowW: 23,
			anchorX: 5,
			anchorY: 20,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,5, 4,0, 9,0, 11,4, 6,20),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-far.png',
			printImage: null
		},
		mid: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/government-library-mid.png',
			iconH: 38,
			iconW: 22,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-mid.png',
			shadowH: 39,
			shadowW: 42,
			anchorX: 9,
			anchorY: 38,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,10, 3,1, 11,0, 20,4, 21,9, 13,38, 9,37),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-mid.png',
			printImage: null
		},
		near: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/government-library.png',
			iconH: 57,
			iconW: 33,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-close.png',
			shadowH: 57,
			shadowW: 61,
			anchorX: 13,
			anchorY: 55,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,14, 4,4, 15,0, 38,3, 31,13, 17,55, 14,55),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi.png',
			printImage: null
		},
		name: 'Libraries'
	},
	police: {
		far: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/government-police-far.png',
			iconH: 21,
			iconW: 12,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-far.png',
			shadowH: 21,
			shadowW: 23,
			anchorX: 5,
			anchorY: 20,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,5, 4,0, 9,0, 11,4, 6,20),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-far.png',
			printImage: null
		},
		mid: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/government-police-mid.png',
			iconH: 38,
			iconW: 22,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-mid.png',
			shadowH: 39,
			shadowW: 42,
			anchorX: 9,
			anchorY: 38,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,10, 3,1, 11,0, 20,4, 21,9, 13,38, 9,37),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-mid.png',
			printImage: null
		},
		near: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/government-police.png',
			iconH: 57,
			iconW: 33,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-close.png',
			shadowH: 57,
			shadowW: 61,
			anchorX: 13,
			anchorY: 55,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,14, 4,4, 15,0, 38,3, 31,13, 17,55, 14,55),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi.png',
			printImage: null
		},
		name: 'Police Departments'
	},
	postOffice: {
		far: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/government-post_office-far.png',
			iconH: 21,
			iconW: 12,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-far.png',
			shadowH: 21,
			shadowW: 23,
			anchorX: 5,
			anchorY: 20,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,5, 4,0, 9,0, 11,4, 6,20),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-far.png',
			printImage: null
		},
		mid: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/government-post_office-mid.png',
			iconH: 38,
			iconW: 22,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-mid.png',
			shadowH: 39,
			shadowW: 42,
			anchorX: 9,
			anchorY: 38,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,10, 3,1, 11,0, 20,4, 21,9, 13,38, 9,37),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-mid.png',
			printImage: null
		},
		near: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/government-post_office.png',
			iconH: 57,
			iconW: 33,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-close.png',
			shadowH: 57,
			shadowW: 61,
			anchorX: 13,
			anchorY: 55,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,14, 4,4, 15,0, 38,3, 31,13, 17,55, 14,55),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi.png',
			printImage: null
		},
		name: 'Post Offices'
	},
	clinic: {
		far: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/healthcare-clinic-far.png',
			iconH: 21,
			iconW: 12,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-far.png',
			shadowH: 21,
			shadowW: 23,
			anchorX: 5,
			anchorY: 20,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,5, 4,0, 9,0, 11,4, 6,20),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-far.png',
			printImage: null
		},
		mid: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/healthcare-clinic-mid.png',
			iconH: 38,
			iconW: 22,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-mid.png',
			shadowH: 39,
			shadowW: 42,
			anchorX: 9,
			anchorY: 38,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,10, 3,1, 11,0, 20,4, 21,9, 13,38, 9,37),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-mid.png',
			printImage: null
		},
		near: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/healthcare-clinic.png',
			iconH: 57,
			iconW: 33,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-close.png',
			shadowH: 57,
			shadowW: 61,
			anchorX: 13,
			anchorY: 55,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,14, 4,4, 15,0, 38,3, 31,13, 17,55, 14,55),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi.png',
			printImage: null
		},
		name: 'Clinics'
	},
	hospital: {
		far: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/healthcare-hospital-far.png',
			iconH: 21,
			iconW: 12,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-far.png',
			shadowH: 21,
			shadowW: 23,
			anchorX: 5,
			anchorY: 20,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,5, 4,0, 9,0, 11,4, 6,20),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-far.png',
			printImage: null
		},
		mid: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/healthcare-hospital-mid.png',
			iconH: 38,
			iconW: 22,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-mid.png',
			shadowH: 39,
			shadowW: 42,
			anchorX: 9,
			anchorY: 38,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,10, 3,1, 11,0, 20,4, 21,9, 13,38, 9,37),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-mid.png',
			printImage: null
		},
		near: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/healthcare-hospital.png',
			iconH: 57,
			iconW: 33,
			shadow: 'http://www.google.com/mapfiles/shadow50.png',
			shadowH: 34,
			shadowW: 37,
			anchorX: 13,
			anchorY: 55,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,14, 4,4, 15,0, 38,3, 31,13, 17,55, 14,55),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi.png',
			printImage: null
		},
		name: 'Hospitals'
	},
	airport: {
		far: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/other-airport-far.png',
			iconH: 21,
			iconW: 12,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-far.png',
			shadowH: 21,
			shadowW: 23,
			anchorX: 5,
			anchorY: 20,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,5, 4,0, 9,0, 11,4, 6,20),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-far.png',
			printImage: null
		},
		mid: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/other-airport-mid.png',
			iconH: 38,
			iconW: 22,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-mid.png',
			shadowH: 39,
			shadowW: 42,
			anchorX: 9,
			anchorY: 38,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,10, 3,1, 11,0, 20,4, 21,9, 13,38, 9,37),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-mid.png',
			printImage: null
		},
		near: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/other-airport.png',
			iconH: 57,
			iconW: 33,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-close.png',
			shadowH: 57,
			shadowW: 61,
			anchorX: 13,
			anchorY: 55,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,14, 4,4, 15,0, 38,3, 31,13, 17,55, 14,55),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi.png',
			printImage: null
		},
		name: 'Airports'
	},
	bank: {
		far: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/other-bank-far.png',
			iconH: 21,
			iconW: 12,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-far.png',
			shadowH: 21,
			shadowW: 23,
			anchorX: 5,
			anchorY: 20,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,5, 4,0, 9,0, 11,4, 6,20),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-far.png',
			printImage: null
		},
		mid: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/other-bank-mid.png',
			iconH: 38,
			iconW: 22,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-mid.png',
			shadowH: 39,
			shadowW: 42,
			anchorX: 9,
			anchorY: 38,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,10, 3,1, 11,0, 20,4, 21,9, 13,38, 9,37),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-mid.png',
			printImage: null
		},
		near: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/other-bank.png',
			iconH: 57,
			iconW: 33,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-close.png',
			shadowH: 57,
			shadowW: 61,
			anchorX: 13,
			anchorY: 55,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,14, 4,4, 15,0, 38,3, 31,13, 17,55, 14,55),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi.png',
			printImage: null
		},
		name: 'Banks'
	},
	laundry: {
		far: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/other-laundry-far.png',
			iconH: 21,
			iconW: 12,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-far.png',
			shadowH: 21,
			shadowW: 23,
			anchorX: 5,
			anchorY: 20,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,5, 4,0, 9,0, 11,4, 6,20),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-far.png',
			printImage: null
		},
		mid: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/other-laundry-mid.png',
			iconH: 38,
			iconW: 22,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-mid.png',
			shadowH: 39,
			shadowW: 42,
			anchorX: 9,
			anchorY: 38,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,10, 3,1, 11,0, 20,4, 21,9, 13,38, 9,37),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-mid.png',
			printImage: null
		},
		near: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/other-laundry.png',
			iconH: 57,
			iconW: 33,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-close.png',
			shadowH: 57,
			shadowW: 61,
			anchorX: 13,
			anchorY: 55,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,14, 4,4, 15,0, 38,3, 31,13, 17,55, 14,55),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi.png',
			printImage: null
		},
		name: 'Laundry'
	},
	worship: {
		far: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/other-worship-far.png',
			iconH: 21,
			iconW: 12,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-far.png',
			shadowH: 21,
			shadowW: 23,
			anchorX: 5,
			anchorY: 20,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,5, 4,0, 9,0, 11,4, 6,20),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-far.png',
			printImage: null
		},
		mid: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/other-worship-mid.png',
			iconH: 38,
			iconW: 22,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-mid.png',
			shadowH: 39,
			shadowW: 42,
			anchorX: 9,
			anchorY: 38,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,10, 3,1, 11,0, 20,4, 21,9, 13,38, 9,37),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-mid.png',
			printImage: null
		},
		near: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/other-worship.png',
			iconH: 57,
			iconW: 33,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-close.png',
			shadowH: 57,
			shadowW: 61,
			anchorX: 13,
			anchorY: 55,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,14, 4,4, 15,0, 38,3, 31,13, 17,55, 14,55),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi.png',
			printImage: null
		},
		name: 'Places of Worship'
	},
	bar: {
		far: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/restaurant-bar-far.png',
			iconH: 21,
			iconW: 12,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-far.png',
			shadowH: 21,
			shadowW: 23,
			anchorX: 5,
			anchorY: 20,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,5, 4,0, 9,0, 11,4, 6,20),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-far.png',
			printImage: null
		},
		mid: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/restaurant-bar-mid.png',
			iconH: 38,
			iconW: 22,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-mid.png',
			shadowH: 39,
			shadowW: 42,
			anchorX: 9,
			anchorY: 38,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,10, 3,1, 11,0, 20,4, 21,9, 13,38, 9,37),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-mid.png',
			printImage: null
		},
		near: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/restaurant-bar.png',
			iconH: 57,
			iconW: 33,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-close.png',
			shadowH: 57,
			shadowW: 61,
			anchorX: 13,
			anchorY: 55,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,14, 4,4, 15,0, 38,3, 31,13, 17,55, 14,55),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi.png',
			printImage: null
		},
		name: 'Bars'
	},
	coffee: {
		far: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/restaurant-coffee-far.png',
			iconH: 21,
			iconW: 12,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-far.png',
			shadowH: 21,
			shadowW: 23,
			anchorX: 5,
			anchorY: 20,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,5, 4,0, 9,0, 11,4, 6,20),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-far.png',
			printImage: null
		},
		mid: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/restaurant-coffee-mid.png',
			iconH: 38,
			iconW: 22,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-mid.png',
			shadowH: 39,
			shadowW: 42,
			anchorX: 9,
			anchorY: 38,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,10, 3,1, 11,0, 20,4, 21,9, 13,38, 9,37),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-mid.png',
			printImage: null
		},
		near: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/restaurant-coffee.png',
			iconH: 57,
			iconW: 33,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-close.png',
			shadowH: 57,
			shadowW: 61,
			anchorX: 13,
			anchorY: 55,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,14, 4,4, 15,0, 38,3, 31,13, 17,55, 14,55),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi.png',
			printImage: null
		},
		name: 'Coffee Shops'
	},
	restaurant: {
		far: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/restaurant-far.png',
			iconH: 21,
			iconW: 12,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-far.png',
			shadowH: 21,
			shadowW: 23,
			anchorX: 5,
			anchorY: 20,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,5, 4,0, 9,0, 11,4, 6,20),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-far.png',
			printImage: null
		},
		mid: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/restaurant-mid.png',
			iconH: 38,
			iconW: 22,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-mid.png',
			shadowH: 39,
			shadowW: 42,
			anchorX: 9,
			anchorY: 38,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,10, 3,1, 11,0, 20,4, 21,9, 13,38, 9,37),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-mid.png',
			printImage: null
		},
		near: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/restaurant.png',
			iconH: 57,
			iconW: 33,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-close.png',
			shadowH: 57,
			shadowW: 61,
			anchorX: 13,
			anchorY: 55,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,14, 4,4, 15,0, 38,3, 31,13, 17,55, 14,55),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi.png',
			printImage: null
		},
		name: 'Restaurants'
	},
	school: {
		far: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/school-far.png',
			iconH: 21,
			iconW: 12,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-far.png',
			shadowH: 21,
			shadowW: 23,
			anchorX: 5,
			anchorY: 20,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,5, 4,0, 9,0, 11,4, 6,20),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-far.png',
			printImage: null
		},
		mid: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/school-mid.png',
			iconH: 38,
			iconW: 22,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-mid.png',
			shadowH: 39,
			shadowW: 42,
			anchorX: 9,
			anchorY: 38,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,10, 3,1, 11,0, 20,4, 21,9, 13,38, 9,37),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-mid.png',
			printImage: null
		},
		near: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/school.png',
			iconH: 57,
			iconW: 33,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-close.png',
			shadowH: 57,
			shadowW: 61,
			anchorX: 13,
			anchorY: 55,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,14, 4,4, 15,0, 38,3, 31,13, 17,55, 14,55),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi.png',
			printImage: null
		},
		name: 'Schools'
	},
	bookStore: {
		far: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shopping-book_store-far.png',
			iconH: 21,
			iconW: 12,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-far.png',
			shadowH: 21,
			shadowW: 23,
			anchorX: 5,
			anchorY: 20,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,5, 4,0, 9,0, 11,4, 6,20),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-far.png',
			printImage: null
		},
		mid: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shopping-book_store-mid.png',
			iconH: 38,
			iconW: 22,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-mid.png',
			shadowH: 39,
			shadowW: 42,
			anchorX: 9,
			anchorY: 38,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,10, 3,1, 11,0, 20,4, 21,9, 13,38, 9,37),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-mid.png',
			printImage: null
		},
		near: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shopping-book_store.png',
			iconH: 57,
			iconW: 33,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-close.png',
			shadowH: 57,
			shadowW: 61,
			anchorX: 13,
			anchorY: 55,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,14, 4,4, 15,0, 38,3, 31,13, 17,55, 14,55),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi.png',
			printImage: null
		},
		name: 'Book Stores'
	},
	department: {
		far: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shopping-department-far.png',
			iconH: 21,
			iconW: 12,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-far.png',
			shadowH: 21,
			shadowW: 23,
			anchorX: 5,
			anchorY: 20,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,5, 4,0, 9,0, 11,4, 6,20),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-far.png',
			printImage: null
		},
		mid: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shopping-department-mid.png',
			iconH: 38,
			iconW: 22,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-mid.png',
			shadowH: 39,
			shadowW: 42,
			anchorX: 9,
			anchorY: 38,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,10, 3,1, 11,0, 20,4, 21,9, 13,38, 9,37),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-mid.png',
			printImage: null
		},
		near: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shopping-department.png',
			iconH: 57,
			iconW: 33,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-close.png',
			shadowH: 57,
			shadowW: 61,
			anchorX: 13,
			anchorY: 55,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,14, 4,4, 15,0, 38,3, 31,13, 17,55, 14,55),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi.png',
			printImage: null
		},
		name: 'Department Stores'
	},
	drugStore: {
		far: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shopping-drug_store-far.png',
			iconH: 21,
			iconW: 12,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-far.png',
			shadowH: 21,
			shadowW: 23,
			anchorX: 5,
			anchorY: 20,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,5, 4,0, 9,0, 11,4, 6,20),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-far.png',
			printImage: null
		},
		mid: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shopping-drug_store-mid.png',
			iconH: 38,
			iconW: 22,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-mid.png',
			shadowH: 39,
			shadowW: 42,
			anchorX: 9,
			anchorY: 38,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,10, 3,1, 11,0, 20,4, 21,9, 13,38, 9,37),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-mid.png',
			printImage: null
		},
		near: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shopping-drug_store.png',
			iconH: 57,
			iconW: 33,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-close.png',
			shadowH: 57,
			shadowW: 61,
			anchorX: 13,
			anchorY: 55,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,14, 4,4, 15,0, 38,3, 31,13, 17,55, 14,55),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi.png',
			printImage: null
		},
		name: 'Drug Stores'
	},
	grocery: {
		far: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shopping-grocery-far.png',
			iconH: 21,
			iconW: 12,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-far.png',
			shadowH: 21,
			shadowW: 23,
			anchorX: 5,
			anchorY: 20,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,5, 4,0, 9,0, 11,4, 6,20),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-far.png',
			printImage: null
		},
		mid: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shopping-grocery-mid.png',
			iconH: 38,
			iconW: 22,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-mid.png',
			shadowH: 39,
			shadowW: 42,
			anchorX: 9,
			anchorY: 38,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,10, 3,1, 11,0, 20,4, 21,9, 13,38, 9,37),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-mid.png',
			printImage: null
		},
		near: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shopping-grocery.png',
			iconH: 57,
			iconW: 33,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-close.png',
			shadowH: 57,
			shadowW: 61,
			anchorX: 13,
			anchorY: 55,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,14, 4,4, 15,0, 38,3, 31,13, 17,55, 14,55),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi.png',
			printImage: null
		},
		name: 'Grocery Stores'
	},
	wine: {
		far: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shopping-wine-far.png',
			iconH: 21,
			iconW: 12,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-far.png',
			shadowH: 21,
			shadowW: 23,
			anchorX: 5,
			anchorY: 20,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,5, 4,0, 9,0, 11,4, 6,20),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-far.png',
			printImage: null
		},
		mid: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shopping-wine-mid.png',
			iconH: 38,
			iconW: 22,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-mid.png',
			shadowH: 39,
			shadowW: 42,
			anchorX: 9,
			anchorY: 38,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,10, 3,1, 11,0, 20,4, 21,9, 13,38, 9,37),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-mid.png',
			printImage: null
		},
		near: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shopping-wine.png',
			iconH: 57,
			iconW: 33,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-close.png',
			shadowH: 57,
			shadowW: 61,
			anchorX: 13,
			anchorY: 55,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,14, 4,4, 15,0, 38,3, 31,13, 17,55, 14,55),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi.png',
			printImage: null
		},
		name: 'Wine & Liquor'
	},
	hotel: {
		far: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/hotel-far.png',
			iconH: 21,
			iconW: 12,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-far.png',
			shadowH: 21,
			shadowW: 23,
			anchorX: 5,
			anchorY: 20,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,5, 4,0, 9,0, 11,4, 6,20),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-far.png',
			printImage: null
		},
		mid: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/hotel-mid.png',
			iconH: 38,
			iconW: 22,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-mid.png',
			shadowH: 39,
			shadowW: 42,
			anchorX: 9,
			anchorY: 38,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,10, 3,1, 11,0, 20,4, 21,9, 13,38, 9,37),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-mid.png',
			printImage: null
		},
		near: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/hotel.png',
			iconH: 57,
			iconW: 33,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-close.png',
			shadowH: 57,
			shadowW: 61,
			anchorX: 13,
			anchorY: 55,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,14, 4,4, 15,0, 38,3, 31,13, 17,55, 14,55),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi.png',
			printImage: null
		},
		name: 'Hotels & Motels'
	},
	mySearch: {
		far: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/general-far.png',
			iconH: 21,
			iconW: 12,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-far.png',
			shadowH: 21,
			shadowW: 23,
			anchorX: 5,
			anchorY: 20,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,5, 4,0, 9,0, 11,4, 6,20),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-far.png',
			printImage: null
		},
		mid: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/general-mid.png',
			iconH: 38,
			iconW: 22,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-mid.png',
			shadowH: 39,
			shadowW: 42,
			anchorX: 9,
			anchorY: 38,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,10, 3,1, 11,0, 20,4, 21,9, 13,38, 9,37),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi-mid.png',
			printImage: null
		},
		near: {
			icon: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/general.png',
			iconH: 57,
			iconW: 33,
			shadow: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/shadow-poi-close.png',
			shadowH: 57,
			shadowW: 61,
			anchorX: 13,
			anchorY: 55,
			windowX: null,
			windowY: null,
			imageMap: new Array(0,14, 4,4, 15,0, 38,3, 31,13, 17,55, 14,55),
			transparent: MapSearch.Config.Urls.Base.imageServer +'/images/system/map_search/POI_Icons/trans_poi.png',
			printImage: null
		},
		name: 'My Searches'
	}
}/**
 * Map Search HTML Templates
 * 
 * @author Nick Verbeck <nick@activewebsite.com>
 * @file /js/map_search/MapSearch.Template.js
 */
MapSearch.Template = {Bubble:{Client: {},Generic: {}, Base: null, Remarks:null, Links:null}, Accordian: null}
MapSearch.Template.Bubble.Base = new Template(''+
'<table class="MapSearchIconPopUp" cellpadding="0" cellspacing="0">'+
'	<thead><tr><th class="headLeft" colspan="2"><a href="/property/#{pid}" target="_Blank" onClick="">#{streetAddress}</a></th><th class="headRight">#{price}</th></tr></thead>'+
'	<tbody>#{content}</tbody>'+
'</table>');
MapSearch.Template.Bubble.Remarks = new Template('<tr><td class="content" colspan="3"><div class="contentContainer">#{remarks}</div></td></tr>');
MapSearch.Template.Bubble.Links = new Template(''+
'<tr><td class="content" colspan="3"><div class="contentContainer"><ul class="linkList">'+
'	<li><img src="/images/system/map_search/Link_Icons/propdetails_square.png" align="absmiddle" border="0" />&nbsp;<a href="/property/#{pid}" target="_Blank" onClick="">View Property Details</a></li>'+
'	<li><img src="/images/system/map_search/Link_Icons/addtofav_square.png" align="absmiddle" border="0" />&nbsp;<a href="#" onClick="window.open(\'/popup/account/addPropertyForm/#{pid}\', \'FavWindow\', \'width=300,height=300\'); return false;">Add to Favorites</a></li>'+
'	<li><img src="/images/system/map_search/Link_Icons/stats_square.png" align="absmiddle" border="0" />&nbsp;<a href="#" onClick="MapSearch.Base.I().pushpinShowStats(\'#{zipcode}\'); return false;">View Statistics</a></li>'+
'	<li><img src="/images/system/map_search/Link_Icons/streetview_square.png" align="absmiddle" border="0" />&nbsp;<a href="#" onClick="MapSearch.Base.I().pushpinShowStreetview(#{lat}, #{lng}); return false;">View Street View</a></li>'+
'	<li><img src="/images/system/map_search/Link_Icons/drivingdirections_square.png" align="absmiddle" border="0" />&nbsp;<a href="#" onClick="MapSearch.Base.I().pushpinDrivingDirections(\'#{fullStreetAddress}\'); return false;">Driving Directions</a></li>'+
'</ul></div></td></tr>');

MapSearch.Template.Bubble.Generic.Result = new Template(''+
'<tr><td class="title" colspan="2">#{streetAddress}</td>'+
'	<td rowspan="9" valign="top"><div class="Photo"><img class="LazyLoadImg" src="/images/system/map_search/small_image_load.gif" imageSrc="#{image}" /></div><div class="PhotoCount">#{photocount} Photos Available</div></td>'+
'</tr>'+
'<tr><td class="title" colspan="2">#{cityState}</td></tr>'+
'<tr><td class="title" colspan="2">&nbsp;</td></tr>'+
'<tr><td class="title">MLS:</td><td class="value">#{property_id}</td></tr>'+
'<tr><td class="title">Price:</td><td class="value">#{price}</td></tr>'+
'<tr><td class="title">Beds:</td><td class="value">#{beds}</td></tr>'+
'<tr><td class="title">Baths:</td><td class="value">#{baths}</td></tr>'+
'<tr><td class="title">Total Sqft:</td><td class="value">#{sqft}</td></tr>'+
'<tr><td class="title">&nbsp;</td><td class="value">&nbsp;</td></tr>'+
'<tr><td style="font-size:10px; padding-left:4px; padding-bottom:2px;" colspan="3">&nbsp;</td></tr>'+
'<tr><td class="misc" colspan="3"><a href="/property/#{pid}" target="_Blank" onClick="">View Property Details</a></td>'+
'<tr><td style="font-size:10px; padding-left:4px; padding-bottom:2px;" colspan="3">Listing Courtesy of: #{office_name}</td></tr>'+
'</tr>');

MapSearch.Template.Bubble.Client.Result = {};
MapSearch.Template.Bubble.Generic.Favorite = {};
MapSearch.Template.Bubble.Client.Favorite = {};
Object.extend(MapSearch.Template.Bubble.Client.Result, MapSearch.Template.Bubble.Generic.Result);
Object.extend(MapSearch.Template.Bubble.Generic.Favorite, MapSearch.Template.Bubble.Generic.Result);
Object.extend(MapSearch.Template.Bubble.Client.Favorite, MapSearch.Template.Bubble.Generic.Favorite);

MapSearch.Template.Bubble.Office = new Template(''+
'<div><table class="MapSearchIconPopUp" style="width:300px;" cellpadding="0" cellspacing="0">'+
'<thead><tr><th class="headLeft" style="background-color:#434343;" colspan="2">#{title}</th></tr></thead>'+
'<tbody>'+
'<tr><td valign="top" rowspan="6">#{img}</td><td class="value">#{street}</td></tr>'+
'<tr><td class="value">&nbsp;#{city}, #{state}</td></tr>'+
'<tr><td class="value">&nbsp;</td></tr>'+
'<tr><td class="value">&nbsp;#{phone}</td></tr>'+
'<tr><td class="value">&nbsp;</td></tr>'+
'<tr><td class="value">&nbsp;</td></tr>'+
'<tr><td class="misc" colspan="2"><a style="color:#225969;" href="#" onClick="MapSearch.Base.I().pushpinDrivingDirections(\'#{street}, #{city}, #{state}\'); return false;">Driving Directions</a></td>'+
'</tbody>'+
'</table></div>');

MapSearch.Template.Bubble.SearchArea = new Template(''+
'<div><table class="MapSearchIconPopUp" style="width:300px;" cellpadding="0" cellspacing="0">'+
'<thead><tr><th class="headLeft" style="background-color:#522437;">#{title}</th><th class="headRight" style="background-color:#522437;">#{propertyCount}</th></tr></thead>'+
'<tbody><tr><td class="content" colspan="2"><div class="contentContainer" style="height:100px;">#{desc}</div></td></tr></tbody>'+
'</table></div>');


MapSearch.Template.Accordian = {Search: {Client: null, Generic: null}, Favorite: {Client: null, Generic: null}, RecentViewed: {Client: null, Generic: null}};
MapSearch.Template.Accordian.Search.Generic = new Template(''+
'<div class="MapSearchSearchResult" pid="#{pid}">'+
'<table><tr>'+
'<td style="background-image:url(\'#{icon}\'); background-repeat:no-repeat; background-position:center center; width:30px; line-height:38px; vertical-align:center; text-align:center; text-decoration:none; color:#fff; padding-top:10px;">#{number}</td>'+
'<td width="180">#{street}<br />#{cityState} #{zip}</td>'+
'<td>#{idx_logo}</td>'+
'</tr></table></div>');

MapSearch.Template.Accordian.Search.Client = new Template(''+
'<div class="MapSearchSearchResult" pid="#{pid}">'+
'<table><tr>'+
'<td style="background-image:url(\'#{icon}\'); background-repeat:no-repeat; background-position:center center; width:30px; line-height:38px; vertical-align:center; text-align:center; text-decoration:none; color:#fff; padding-top:10px;">#{number}</td>'+
'<td>#{street}<br />#{cityState} #{zip}</td>'+
'</tr></table></div>');

MapSearch.Template.Accordian.Favorite.Generic = new Template(''+
'<div class="MapSearchSearchResult" pid="#{pid}">'+
'<table><tr>'+
'<td style="background-image:url(\'#{icon}\'); background-repeat:no-repeat; background-position:center center; width:30px; line-height:38px; vertical-align:center; text-align:center; text-decoration:none; color:#fff; padding-top:10px;">#{number}</td>'+
'<td width="180">#{street}<br />#{cityState} #{zip}</td>'+
'<td>#{idx_logo}</td>'+
'</tr></table></div>');
MapSearch.Template.Accordian.Favorite.Client = new Template(''+
'<div class="MapSearchSearchResult" pid="#{pid}">'+
'<table><tr>'+
'<td style="background-image:url(\'#{icon}\'); background-repeat:no-repeat; background-position:center center; width:30px; line-height:38px; vertical-align:center; text-align:center; text-decoration:none; color:#fff; padding-top:10px;">#{number}</td>'+
'<td>#{street}<br />#{cityState} #{zip}</td>'+
'</tr></table></div>');

MapSearch.Template.Stats = {}
MapSearch.Template.Stats.Demo = new Template('<ul>'+
'<li>Populations'+
'	<ul>'+
'		<li><div style="float:right;">#{white_pop}</div>White</li>'+
'		<li><div style="float:right;">#{black_pop}</div>Black</li>'+
'		<li><div style="float:right;">#{hispanic_pop}</div>Hispanic</li>'+
'		<li><div style="float:right;">#{asian_pop}</div>Asian</li>'+
'		<li><div style="float:right;">#{hawaiian_pop}</div>Hawaiian</li>'+
'		<li><div style="float:right;">#{indian_pop}</div>Indian</li>'+
'		<li><div style="float:right;">#{other_pop}</div>Other</li>'+
'		<li><div style="float:right;">#{male_pop}</div>Male</li>'+
'		<li><div style="float:right;">#{female_pop}</div>Female</li>'+
'		<li><div style="float:right;">#{population}</div>Total</li>'+
'	</ul>'+
'</li>'+
'<li>Households'+
'	<ul>'+
'		<li><div style="float:right;">#{households}</div>Total Households</li>'+
'		<li><div style="float:right;">#{persons_per_household}</div>Persons Per Household</li>'+
'		<li><div style="float:right;">#{avg_house_value}</div>Avg House Value</li>'+
'		<li><div style="float:right;">#{income_per_household}</div>Income Per Household</li>'+
'	</ul>'+
'</li>'+
'<li>Business'+
'	<ul>'+
'		<li><div style="float:right;">#{establishments_2003}</div>Business Establishments</li>'+
'		<li><div style="float:right;">#{employment_2003}</div>Employed</li>'+
'		<li><div style="float:right;">#{annual_payroll_2003}</div>Annual Payroll</li>'+
'	</ul>'+
'</li>'+
'</ul><div style="font-size:10px; margin-top:10px;">Data provided is based on 2000/2003 Census data.</div>');

MapSearch.Template.Streetview = {}
MapSearch.Template.Streetview.littleMan = new Template(''+
'<table class="MapSearchIconPopUp" cellpadding="0" cellspacing="0">'+
'	<thead><tr><th class="headLeft">Last Streeview</th><th class="headRight">#{description}</th></tr></thead>'+
'	<tbody>'+
'<tr><td class="title">Latitude:</td><td class="value">#{lat}</td></tr>'+
'<tr><td class="title">Longitude:</td><td class="value">#{lng}</td></tr>'+
'<tr><td colspan="2" style="text-align:center;"><a href="#" onClick="MapSearch.Base.I().pushpinShowStreetview(#{lat}, #{lng}); return false;">View Streeview</a></td></tr>'+
'<tr><td colspan="2" style="font-size:10px; text-align:right;">#{copyright}</td></tr>'+
'	</tbody>'+
'</table>');
MapSearch.Template.Streetview.littleManBlank = new Template(''+
'<table class="MapSearchIconPopUp" cellpadding="0" cellspacing="0">'+
'	<thead><tr><th class="headLeft">No Streetview Yet</th><th class="headRight">&nbsp;</th></tr></thead>'+
'	<tbody>'+
'<tr><td class="title">Latitude:</td><td class="value">#{lat}</td></tr>'+
'<tr><td class="title">Longitude:</td><td class="value">#{lng}</td></tr>'+
'<tr><td colspan="2" style="text-align:center;"><a href="#" onClick="MapSearch.Base.I().pushpinShowStreetview(#{lat}, #{lng}); return false;">View Streeview</a></td></tr>'+
'	</tbody>'+
'</table>');

MapSearch.Template.POI = {}
MapSearch.Template.POI.Generic = new Template(''+
'<table class="MapSearchIconPopUp" cellpadding="0" cellspacing="0">'+
'	<thead>'+
'		<tr>'+
'			<th class="headLeft" colspan="2">#{title}</th>'+
'		</tr>'+
'	</thead>'+
'	<tbody>'+
'		<tr><td class="title" colspan="2">#{streetAddress}</td></tr>'+
'		<tr><td class="title" colspan="2">#{cityState}</td></tr>'+
'		<tr><td class="title" colspan="2">&nbsp;</td></tr>'+
'		<tr><td class="title">Phone:</td><td class="value">#{phone}</td></tr>'+
'		<tr><td class="title" colspan="2">&nbsp;</td></tr>'+
'		<tr><td class="misc" colspan="2"><a href="#{url}" target="_blank">More Info</a></td></tr>'+
'	</tbody>'+
'</table>');

MapSearch.Template.Search = {}
MapSearch.Template.Search.SearchOptions = new Template(''+
'<table cellpadding="0" cellspacing="0">'+
'	<tr>'+
'		<td><input type="checkbox" id="MapSearchFieldOwner" /></td>'+
'		<td><label for="MapSearchFieldOwner">Company Listing Only</label></td>'+
'	</tr>'+
'	<tr>'+
'		<td><input type="checkbox" id="MapSearchFieldNewProp" /></td>'+
'		<td><label for="MapSearchFieldNewProp">New Properties in 30 Days</label></td>'+
'	</tr>'+
'	<tr>'+
'		<td><input type="checkbox" id="MapSearchFieldWithPics" /></td>'+
'		<td><label for="MapSearchFieldWithPics">Properties with Photos Only</label></td>'+
'	</tr>'+
'	<tr>'+
'		<td><input type="checkbox" id="MapSearchFieldVT" /></td>'+
'		<td><label for="MapSearchFieldVT">Properties with a Virtual Tour</label></td>'+
'	</tr>'+
'	<tr>'+
'		<td><input type="checkbox" id="MapSearchFieldVideo" /></td>'+
'		<td><label for="MapSearchFieldVideo">Property with Videos</label></td>'+
'	</tr>'+
'</table>');<!-- //0.052469968795776 --><!-- //10.10.98.78 -->