	function LoadMap() {
		if (GBrowserIsCompatible()) {
			MapDisableLocatorControls();
			MapUpdateStatusMessage( "Loading data...", 1 );
			
			goMap = new MapData();
			
			goMap.map.addControl( new GLargeMapControl() );
			goMap.map.addControl( new GMapTypeControl() );
			goMap.map.setCenter( goMap.center, goMap.zoom );
			goMap.map.hideControls();
			
			GEvent.addListener(goMap.map, "mouseover", goMap.map.showControls);
			GEvent.addListener(goMap.map, "mouseout", goMap.map.hideControls);
			
			MapEnableLocatorControls();
			MapUpdateStatusMessage( "Ready!", 0 );
		}
	}
	
	
	function MapData() {
		this.map = new GMap2(document.getElementById("map"));
		this.geocoder = new GClientGeocoder();
		this.center = new GLatLng(40.17887331434696, -94.04296875);
		this.zoom = 3;
		this.icons = new MapIcons();
		this.status = new MapStatus();
		this.tools = new MapTools();
		this.constants = new MapConstants();
		this.offices = new Array();
		this.states = new Array();
		this.zips = new Array();
		
		return this;
	}
	
	
	function MapIcons() {
		var loOfficeIcon = new GIcon();
		loOfficeIcon.image = "/locations/images/icon_red.png";
		loOfficeIcon.shadow = "/locations/images/icon_shadow.png";
		loOfficeIcon.iconSize = new GSize(12, 20);
		loOfficeIcon.shadowSize = new GSize(22, 20);
		loOfficeIcon.iconAnchor = new GPoint(6, 20);
		loOfficeIcon.infoWindowAnchor = new GPoint(5, 1);
		
		var loHereIcon = new GIcon();
		loHereIcon.image = "/locations/images/icon_point.png";
		loHereIcon.shadow = "/locations/images/icon_point_shadow.png";
		loHereIcon.iconSize = new GSize(15, 14);
		loHereIcon.shadowSize = new GSize(24, 14);
		loHereIcon.iconAnchor = new GPoint(8, 14);
		loHereIcon.infoWindowAnchor = new GPoint(5, 1);
		
		this.office = loOfficeIcon;
		this.here = loHereIcon;
		
		return this;
	}
	
	
	function MapStatus() {
		this.zip = null;
		this.state = null;
		this.city = null;
		this.center = null;
		this.zoom = null;
		this.marker = null;
		this.markerInterval = null;
		
		return this;
	}
	
	
	function MapState( pName, pCode, pLat, pLng, pZoom ) {
		this.name = pName;
		this.code = pCode;
		this.center = new GLatLng( pLat, pLng );
		this.zoom = pZoom;
		this.cities = new Array();
		this.offices = new Array();
		
		this.loadCityStatus = goMap.constants.loadStatus.isReady;
		this.loadOfficeStatus = goMap.constants.loadStatus.isReady;
		
		this.isLoadedMarkers = false;
		this.isLoadedTabs = false;
		
		return this;
	}
	
	
	function MapCity( pName ) {
		this.name = pName;
		this.zoom = null;
		this.center = null;
		this.offices = new Array();
		
		this.loadOfficeStatus = goMap.constants.loadStatus.isReady;
		
		this.isLoadedMarkers = false;
		this.isLoadedTabs = false;
		
		return this;
	}
	
	
	function MapZip( pCode, pState, pLat, pLng, pZoom ) {
		this.code = pCode;
		this.state = pState;
		this.center = new GLatLng( pLat, pLng );
		this.zoom = pZoom;
		this.offices = new Array();
		
		this.loadOfficeStatus = goMap.constants.loadStatus.isReady;
		
		this.isLoadedMarkers = false;
		this.isLoadedTabs = false;
		
		return this;
	}
	
	
	function MapOffice( pID, pName, pServices, pAddress, pCity, pState, pZip, pPhone, pFax, pTollfree, pWebsite, pTestimonials, pHomestyle, pLatitude, pLongitude, pCoded ) {
		this.id = pID;
		this.name = pName;
		this.services = pServices;
		this.address = pAddress;
		this.city = pCity;
		this.state = pState;
		this.zip = pZip;
		this.phone = pPhone;
		this.fax = pFax;
		this.tollfree = pTollfree;
		this.website = pWebsite;
		this.testimonials = pTestimonials;
		this.homestyle = pHomestyle;
		this.latitude = pLatitude;
		this.longitude = pLongitude;
		this.center = new GLatLng( pLatitude, pLongitude );
		this.coded = pCoded;
		this.marker = null;
		this.tabs = null;
		
		this.loadMarkerStatus = goMap.constants.loadStatus.isReady;
		this.isActiveMarker = false;
		
		return this;
	}
	
	
	function MapConstants() {
		this.loadStatus = new MapLoadStatus();
		
		return this;
	}
	
	function MapLoadStatus() {
		this.isReady = 0;
		this.isDone = 1;
		this.isLoading = 2;
		this.isProcessing = 3;
		
		return this;
	}
	
	
	function MapTools() {
		this.Convert2Boolean = function( psValue ) {
									return (psValue.toLowerCase() == "true") ? true : false;
								}
		
		this.SetHere = function( point, txt ) {
							goMap.status.center = point;
							goMap.status.marker = goMap.tools.CreateHereMarker( point, txt );
							goMap.map.addOverlay( goMap.status.marker );
						}
		
		this.ClearLocation = function( psWhere ) {
							if (goMap.status.marker != null) goMap.map.removeOverlay( goMap.status.marker );
							
							goMap.status.center = null;
							goMap.status.marker = null;
							
							if (psWhere != "zip") {
								var loZip = document.getElementById( "zip" );
								if (loZip) loZip.value = "";
								
								goMap.status.zip = null;
							}
							
							if (psWhere != "city") {
								var loCity = document.getElementById( "city" );
								if (loCity) loCity.selectedIndex = 0;
								
								goMap.status.city = null;
								
								var loPanel = document.getElementById( "cityPanel" );
								if (loPanel) loPanel.style.visibility = "hidden";
							}
								
							if (psWhere != "state" && psWhere != "city") {
								var loState = document.getElementById( "state" );
								if (loState) loState.selectedIndex = 0;
								
								goMap.status.state = null;
							}
							
							goMap.tools.ClearOfficeMarkers();
						}
		
		this.CreateOfficeTabs = function( pOffices ) {
									var mOffice = '';
									var mContact = '';
									var mServices = '';
									
									for (var i = 0; i < pOffices.length; i++) {
										mOffice +=		((i == 0) ? '' : '<hr style="width: 250px; margin: 10px 0px;">') + 
														'<strong>' + pOffices[i].name + '</strong>' +
														'<br>' + 
														pOffices[i].address + ((pOffices[i].address.length == 0) ? '' : '<br>') + 
														pOffices[i].city + ', ' + pOffices[i].state + ' ' + pOffices[i].zip + ' &nbsp;' +
														'(<a href="http://maps.google.com/maps?f=d&hl=en&saddr=&daddr=' + pOffices[i].address.replace(/#/g, '') + ',+' + pOffices[i].city + ',+' + pOffices[i].state + '+' + pOffices[i].zip + '&ie=UTF8&om=1" target="_blank">get directions</a>)<br>' + 
														((pOffices[i].website.length == 0) ? '' : ('<a href="http://' + pOffices[i].website + '" target="_blank">' + pOffices[i].website + '</a><br>')) + 
														'<img src="/locations/images/blank.gif" width="270" height="1" alt="" border="0">';
									
										mContact +=		((i == 0) ? '' : '<hr style="width: 250px; margin: 10px 0px;">') + 
														'<strong>' + pOffices[i].name + '</strong><br>' +
														'Phone: ' + pOffices[i].phone + '<br>' + 
														'Fax: ' + pOffices[i].fax + '<br>' + 
														((pOffices[i].tollfree.length == 0) ? '' : ('Toll Free: ' + pOffices[i].tollfree + '<br>')) + 
														((pOffices[i].website.length == 0) ? '' : ('<a href="http://' + pOffices[i].website + '" target="_blank">' + pOffices[i].website + '</a><br>')) + 
														((pOffices[i].testimonials) ? ('<br><a href="/officeTestimonials.asp?id=' + pOffices[i].id + '&city=' + pOffices[i].city + '&state=' + pOffices[i].state + '" target="_blank">Click here for client testimonials.</a>') : '');
									
										mServices +=	((i == 0) ? '' : '<hr style="width: 250px; margin: 10px 0px;">') + 
														'<strong>' + pOffices[i].name + '</strong> offers the following services:' + 
														'<ul style="margin-top: 5px; margin-bottom: 5px;">' + 
														'<li>' + pOffices[i].services.replace(/\|/g, '</li><li>') + '</li>' +
														'</ul>';
									}
									
									var tabs = [
										new GInfoWindowTab("Location", mOffice),
										new GInfoWindowTab("Contact", mContact),
										new GInfoWindowTab("Services", mServices)
									];
									
									return tabs;
								}
		
		this.CreateOfficeMarker = function( pOffice ) {
										var marker = new GMarker( pOffice.center, goMap.icons.office );
										
										GEvent.addListener(marker, "click", function() {
												marker.openInfoWindowTabsHtml( pOffice.tabs );
											});
										
										return marker;
									}
		
		this.CreateHereMarker = function( point, txt ) {
									var marker = new GMarker( point, goMap.icons.here );
									
									GEvent.addListener(marker, "click", function() {
											marker.openInfoWindowHtml(txt);
										});
									
									return marker;
								}
		
		this.ClearOfficeMarkers = function() {
										goMap.tools.ClearOfficeList();
										
										for (var i = 0; i < goMap.offices.length; i++) {
											if (goMap.offices[i].isActiveMarker) {
												goMap.map.removeOverlay( goMap.offices[i].marker );
												goMap.offices[i].isActiveMarker = false;
											}
										}
									}
		
		this.GetMarkerListBounds = function( pList ) {
									var bounds = new GLatLngBounds();
									
									for (var i = 0; i < pList.length; i++) {
										bounds.extend( pList[i].center );
									}
									
									return bounds;
								}
		
		this.GetState = function( pState ) {
							var ord = null;
							
							for (var i = 0; i < goMap.states.length; i++) {
								if (goMap.states[i].code == pState) {
									ord = i;
									break;
								}
							}
							
							return ord;
						}
		
		this.GetCity = function( psCity, piState ) {
							var ord = null;
							
							for (var i = 0; i < goMap.states[piState].cities.length; i++) {
								if (goMap.states[piState].cities[i].name == psCity) {
									ord = i;
									break;
								}
							}
							
							return ord;
						}
		
		this.GetZip = function( pZip ) {
							var ord = null;
							
							for (var i = 0; i < goMap.zips.length; i++) {
								if (goMap.zips[i].code == pZip) {
									ord = i;
									break;
								}
							}
							
							return ord;
						}
		
		this.GetOffice = function( pOffice ) {
							var ord = null;
							
							for (var i = 0; i < goMap.offices.length; i++) {
								if (goMap.offices[i].id == pOffice) {
									ord = i;
									break;
								}
							}
							
							return ord;
						}
		
		this.UpdateOfficeCollections = function( pOffice, pState, pCity, pZip ) {
											if (pState != null) {
												var lbIsStateOffice = false;
												 
												for (var i = 0; i < goMap.states[pState].offices.length; i++) {
													if (goMap.states[pState].offices[i] == pOffice) {
														lbIsStateOffice = true;
														break;
													}
												}
												
												if (!lbIsStateOffice) goMap.states[pState].offices.push( pOffice );
												
												if (pCity != null) {
													var lbIsCityOffice = false;
													 
													for (var i = 0; i < goMap.states[pState].cities[pCity].offices.length; i++) {
														if (goMap.states[pState].cities[pCity].offices[i] == pOffice) {
															lbIsCityOffice = true;
															break;
														}
													}
													
													if (!lbIsCityOffice) goMap.states[pState].cities[pCity].offices.push( pOffice );
												}
											}
											
											if (pZip != null) {
												var lbIsZipOffice = false;
												 
												for (var i = 0; i < goMap.zips[pZip].offices.length; i++) {
													if (goMap.zips[pZip].offices[i] == pOffice) {
														lbIsZipOffice = true;
														break;
													}
												}
												
												if (!lbIsZipOffice) goMap.zips[pZip].offices.push( pOffice );
											}
										}
		
		this.UpdateGeocode = function( poOffice ) {
									var path = "http://" + gsURL + "/locations/data.update.aspx?office=" + poOffice.id + "&lat=" + poOffice.center.y + "&lng=" + poOffice.center.x;
									var request = GXmlHttp.create();
									
									request.open("GET", path, true);
									request.onreadystatechange = function() {
																	if (request.readyState == 4) {
																		// nothing to do...
																	}
																}
									request.send(null);
								}
		
		this.CheckMarkerStatus = function( poObj ) {
										if (!poObj.isLoadedMarkers) {
											var lbIsLoaded = true;
											
											for (var i = poObj.offices.length - 1; i >= 0; i--) {
												if (goMap.offices[poObj.offices[i]].loadMarkerStatus != goMap.constants.loadStatus.isDone) {
													lbIsLoaded = false;
													break;
												}
											}
											
											poObj.isLoadedMarkers = lbIsLoaded;
										}
										
										if (lbIsLoaded && goMap.status.markerInterval != null) {
											clearInterval( goMap.status.markerInterval );
											goMap.status.markerInterval = null;
										}
										
										return poObj.isLoadedMarkers;
									}
		
		this.GroupEqualPointOffices = function( pObj ) {
										if (!pObj.isLoadedTabs) {
											for (var i = 0; i < pObj.offices.length; i++) {
												var dupes = new Array();
												dupes.push( goMap.offices[pObj.offices[i]] );
												
												for (var j = 0; j < pObj.offices.length; j++) {
													if (j != i && goMap.offices[pObj.offices[j]].center.equals( goMap.offices[pObj.offices[i]].center )) {
														dupes.push( goMap.offices[pObj.offices[j]] );
													}
												}
												
												if (dupes.length > 1) {
													goMap.offices[pObj.offices[i]].tabs = goMap.tools.CreateOfficeTabs( dupes );
													goMap.offices[pObj.offices[i]].marker = goMap.tools.CreateOfficeMarker( goMap.offices[pObj.offices[i]] );
												}
											}
											
											pObj.isLoadedTabs = true;
										}
										
										return pObj.isLoadedTabs;
									}
		
		this.ClearOfficeList = function( pOffice ) {
								var obj = document.getElementById( "office_results" );
								if (obj) obj.innerHTML = "";
							}
		
		this.ListOffice = function( pOffice ) {
								var obj = document.getElementById( "office_results" );
								if (obj) {
									var lsOfficeInfo =	'<a href="#" onclick="return goMap.tools.RevealOffice(' + pOffice.id + ');"><strong>' + pOffice.name + '</strong></a><br>' +
														pOffice.address + ((pOffice.address.length == 0) ? '' : '<br>') +
														pOffice.city + ', ' + pOffice.state + ' ' + pOffice.zip
									
									obj.innerHTML += '<li>' + lsOfficeInfo + '</li>';
								}
							}

		this.RevealOffice = function( piOffice ) {
								var liOfficeOrd = goMap.tools.GetOffice( piOffice );
								goMap.offices[liOfficeOrd].marker.openInfoWindowTabsHtml( goMap.offices[liOfficeOrd].tabs );
								
								return false;
							}
		
		this.DisplayState = function() {
								if (goMap.status.state != null) {
									if (goMap.states[goMap.status.state].loadOfficeStatus == goMap.constants.loadStatus.isDone) {
										if (goMap.tools.CheckMarkerStatus( goMap.states[goMap.status.state] )) {
											goMap.tools.GroupEqualPointOffices( goMap.states[goMap.status.state] );
											
											// display office markers...
											for (var i = 0; i < goMap.states[goMap.status.state].offices.length; i++) {
												goMap.map.addOverlay( goMap.offices[goMap.states[goMap.status.state].offices[i]].marker );
												goMap.offices[goMap.states[goMap.status.state].offices[i]].isActiveMarker = true;
												goMap.tools.ListOffice( goMap.offices[goMap.states[goMap.status.state].offices[i]] );
											}
											
											// move to new location...
											if (goMap.states[goMap.status.state].zoom == goMap.map.getZoom()) {
												goMap.map.panTo( goMap.states[goMap.status.state].center );
											} else {
												goMap.map.setCenter( goMap.states[goMap.status.state].center, goMap.states[goMap.status.state].zoom );
											}
											
											// update message...
											var count = goMap.states[goMap.status.state].offices.length;
											var msg = (goMap.status.state == null) ? null : ('There ' + ((count == 1) ? 'is' : 'are') + ' ' + ((count == 0) ? 'no' : count) + ' office' + ((count == 1) ? '' : 's') + ' in the state of ' + goMap.states[goMap.status.state].name + '.');
											MapUpdateStatusMessage( msg, ((count == 0) ? 2 : 0) );
											
											var loPanel = document.getElementById("cityPanel");
											if (loPanel) loPanel.style.visibility = "visible";
											
											goMap.tools.PopulateCityOptions();
										}
									}
								}
							}
		
		this.DisplayCity = function() {
								if (goMap.status.city != null && goMap.status.state != null) {
									if (goMap.states[goMap.status.state].cities[goMap.status.city].loadOfficeStatus == goMap.constants.loadStatus.isDone) {
										if (goMap.tools.CheckMarkerStatus( goMap.states[goMap.status.state].cities[goMap.status.city] )) {
											goMap.tools.GroupEqualPointOffices( goMap.states[goMap.status.state].cities[goMap.status.city] );
											
											// display office markers...
											for (var i = 0; i < goMap.states[goMap.status.state].cities[goMap.status.city].offices.length; i++) {
												goMap.map.addOverlay( goMap.offices[goMap.states[goMap.status.state].cities[goMap.status.city].offices[i]].marker );
												goMap.offices[goMap.states[goMap.status.state].cities[goMap.status.city].offices[i]].isActiveMarker = true;
												goMap.tools.ListOffice( goMap.offices[goMap.states[goMap.status.state].cities[goMap.status.city].offices[i]] );
											}
											
											goMap.tools.SetHere( goMap.states[goMap.status.state].cities[goMap.status.city].center, ("The city of " + goMap.states[goMap.status.state].cities[goMap.status.city].name + ", " + goMap.states[goMap.status.state].code + " is located here.") );
											
											// move to new location...
											if (goMap.states[goMap.status.state].cities[goMap.status.city].zoom == goMap.map.getZoom()) {
												goMap.map.panTo( goMap.states[goMap.status.state].cities[goMap.status.city].center );
											} else {
												goMap.map.setCenter( goMap.states[goMap.status.state].cities[goMap.status.city].center, goMap.states[goMap.status.state].cities[goMap.status.city].zoom );
											}
											
//											if (goMap.states[goMap.status.state].cities[goMap.status.city].offices.length > 0) {
//												var bounds = new GLatLngBounds();
//												for (var i = 0; i < goMap.states[goMap.status.state].cities[goMap.status.city].offices.length; i++) {
//													bounds.extend( goMap.offices[goMap.states[goMap.status.state].cities[goMap.status.city].offices[i]].center );
//												}
//												var zoom = goMap.map.getBoundsZoomLevel( bounds );
//												
//												goMap.map.setZoom( zoom );
//											}
											
											// update message...
											var count = goMap.states[goMap.status.state].cities[goMap.status.city].offices.length;
											var msg = 'There ' + ((count == 1) ? 'is' : 'are') + ' ' + ((count == 0) ? 'no' : count) + ' office' + ((count == 1) ? '' : 's') + ' that provide' + ((count == 1) ? 's' : '') + ' service to ' + goMap.states[goMap.status.state].cities[goMap.status.city].name + ', ' + goMap.states[goMap.status.state].code + '.';
											MapUpdateStatusMessage( msg, ((count == 0) ? 2 : 0) );
										}
									}
								}
							}
		
		this.DisplayZip = function() {
								if (goMap.status.zip != null) {
									if (goMap.zips[goMap.status.zip].loadOfficeStatus == goMap.constants.loadStatus.isDone) {
										if (goMap.tools.CheckMarkerStatus( goMap.zips[goMap.status.zip] )) {
											goMap.tools.GroupEqualPointOffices( goMap.zips[goMap.status.zip] );
											
											// display office markers...
											for (var i = 0; i < goMap.zips[goMap.status.zip].offices.length; i++) {
												goMap.map.addOverlay( goMap.offices[goMap.zips[goMap.status.zip].offices[i]].marker );
												goMap.offices[goMap.zips[goMap.status.zip].offices[i]].isActiveMarker = true;
												goMap.tools.ListOffice( goMap.offices[goMap.zips[goMap.status.zip].offices[i]] );
											}
											
											if (goMap.zips[goMap.status.zip].state.length == 0) {
												goMap.map.setCenter( goMap.center, goMap.zoom );
												MapUpdateStatusMessage( 'The requested zip code was not found!', 3 );
											} else {
												goMap.tools.SetHere( goMap.zips[goMap.status.zip].center, ("The zipcode of " + goMap.zips[goMap.status.zip].code + " is located here.") );
												
												// move to new location...
												if (goMap.zips[goMap.status.zip].zoom == goMap.map.getZoom()) {
													goMap.map.panTo( goMap.zips[goMap.status.zip].center );
												} else {
													goMap.map.setCenter( goMap.zips[goMap.status.zip].center, goMap.zips[goMap.status.zip].zoom );
												}
												
												// update message...
												var count = goMap.zips[goMap.status.zip].offices.length;
												var msg = 'There ' + ((count == 1) ? 'is' : 'are') + ' ' + ((count == 0) ? 'no' : count) + ' office' + ((count == 1) ? '' : 's') + ' that service' + ((count == 1) ? 's' : '') + ' the zipcode ' + goMap.zips[goMap.status.zip].code + '.';
												MapUpdateStatusMessage( msg, ((count == 0) ? 2 : 0) );
											}
										}
									}
								}
							}
		
		this.PopulateCityOptions = function() {
										var loCity = document.getElementById("city");
										loCity.options.length = 0;
										
										if (goMap.status.state != null) {
											if (goMap.states[goMap.status.state].loadCityStatus == goMap.constants.loadStatus.isDone) {
												loCity.options[loCity.options.length] = new Option(((goMap.states[goMap.status.state].cities.length == 0) ? 'No Cities Serviced!' : 'Select a City'), '');
												
												for (var i = 0; i < goMap.states[goMap.status.state].cities.length; i++) {
													loCity.options[loCity.options.length] = new Option(goMap.states[goMap.status.state].cities[i].name, i);
												}
											} else {
												loCity.options[loCity.options.length] = new Option('Loading cities...', '');
												
												goMap.tools.LoadStateCities();
											}
										}
									}
		
		this.LoadStateCities = function() {
									if (goMap.status.state != null) {
										goMap.states[goMap.status.state].loadCityStatus = goMap.constants.loadStatus.isLoading;
										
										var path = "http://" + gsURL + "/locations/data.cities.aspx?state=" + goMap.states[goMap.status.state].code;
										var request = GXmlHttp.create();
										
										request.open("GET", path, true);
										request.onreadystatechange = function() {
																		if (request.readyState == 4) {
																			var xmlDoc = request.responseXML;
																			var cities = xmlDoc.documentElement.getElementsByTagName("city");
																			
																			var liStateOrd = goMap.status.state;
																			goMap.states[liStateOrd].loadCityStatus = goMap.constants.loadStatus.isLoading;
																			
																			for (var i = 0; i < cities.length; i++) {
																				var lName = cities[i].getAttribute("name");
																				
																				goMap.states[liStateOrd].cities.push( new MapCity(lName) );
																			}
																			
																			goMap.states[liStateOrd].loadCityStatus = goMap.constants.loadStatus.isDone;
																			
																			if (goMap.status.state != null) goMap.tools.PopulateCityOptions();
																		}
																	}
										
										request.send(null);
									}
								}
		
		this.LoadOffice = function( pMapOffice ) {
							goMap.offices.push( pMapOffice );
							
							var liOffice = goMap.offices.length - 1;
							var office = goMap.offices[liOffice];
							
							office.loadMarkerStatus = goMap.constants.loadStatus.isLoading;
							
							if (office.coded) {
								office.tabs = goMap.tools.CreateOfficeTabs( [office] );
								office.marker = goMap.tools.CreateOfficeMarker( office );
								office.loadMarkerStatus = goMap.constants.loadStatus.isDone;
							} else {
								var address = (office.address + ', ' + office.city + ', ' + office.state);
								var point = goMap.geocoder.getLatLng( address, function(point) {
										if (point) {
											office.center = point;
											goMap.tools.UpdateGeocode( office );
										}
										
										office.tabs = goMap.tools.CreateOfficeTabs( [office] );
										office.marker = goMap.tools.CreateOfficeMarker( office );
										office.loadMarkerStatus = goMap.constants.loadStatus.isDone;
									} );
							}
						}
		
		this.ParseOfficeData = function( pOffices, piState, piCity, piZip ) {
									for (var i = 0; i < pOffices.length; i++) {
										var lsID = pOffices[i].getAttribute("id");
										var liOfficeOrd = goMap.tools.GetOffice( parseInt(lsID) );
										
										if (liOfficeOrd == null) {
											var lsName = pOffices[i].getAttribute("name");
											var lsServices = pOffices[i].getAttribute("services");
											var lsAddress = pOffices[i].getAttribute("address");
											var lsCity = pOffices[i].getAttribute("city");
											var lsState = pOffices[i].getAttribute("state");
											var lsZip = pOffices[i].getAttribute("zip");
											var lsPhone = pOffices[i].getAttribute("phone");
											var lsFax = pOffices[i].getAttribute("fax");
											var lsToll = pOffices[i].getAttribute("tollfree");
											var lsWeb = pOffices[i].getAttribute("website");
											var lsTest = pOffices[i].getAttribute("testimonials");
											var lsHS = pOffices[i].getAttribute("homestyle");
											var lsLat = pOffices[i].getAttribute("latitude");
											var lsLng = pOffices[i].getAttribute("longitude");
											var lsIsCoded = pOffices[i].getAttribute("iscoded");
											
											var loOffice = new MapOffice( parseInt(lsID), lsName, lsServices, lsAddress, lsCity, lsState, lsZip, lsPhone, lsFax, lsToll, lsWeb, goMap.tools.Convert2Boolean(lsTest), goMap.tools.Convert2Boolean(lsHS), parseFloat(lsLat), parseFloat(lsLng), goMap.tools.Convert2Boolean(lsIsCoded) );
											if (piState == null) piState = goMap.tools.GetState( lsState );
											
											goMap.tools.LoadOffice( loOffice );
										}
										
										if (liOfficeOrd == null) liOfficeOrd = goMap.tools.GetOffice( parseInt(lsID) );
										
										goMap.tools.UpdateOfficeCollections( liOfficeOrd, piState, piCity, piZip );
									}
								}
		
		this.LoadStateOfficeData = function( psState ) {
										if (psState != null) {
											var path = "http://" + gsURL + "/locations/data.offices.aspx?state=" + psState;
											var request = GXmlHttp.create();
											
											request.open("GET", path, true);
											request.onreadystatechange = function() {
																			if (request.readyState == 4) {
																				var xmlDoc = request.responseXML;
																				var lsStateName = xmlDoc.documentElement.getAttribute("name");
																				var lsStateCode = xmlDoc.documentElement.getAttribute("code");
																				var lsStateLat = xmlDoc.documentElement.getAttribute("lat");
																				var lsStateLng = xmlDoc.documentElement.getAttribute("lng");
																				var lsStateZoom = xmlDoc.documentElement.getAttribute("zoom");
																				
																				var liStateOrd = goMap.tools.GetState( psState );
																				if (liStateOrd == null) {
																					goMap.states.push( new MapState( lsStateName, lsStateCode, parseFloat(lsStateLat), parseFloat(lsStateLng), parseInt(lsStateZoom) ) );
																					liStateOrd = goMap.states.length - 1;
																				}
																				
																				goMap.status.state = liStateOrd;
																				
																				if (goMap.states[liStateOrd].loadOfficeStatus == goMap.constants.loadStatus.isReady) {
																					goMap.states[liStateOrd].loadOfficeStatus = goMap.constants.loadStatus.isLoading;
																					goMap.tools.ParseOfficeData( xmlDoc.documentElement.getElementsByTagName("office"), liStateOrd, null, null );
																					goMap.states[liStateOrd].loadOfficeStatus = goMap.constants.loadStatus.isDone;
																				}
																				
																				if (liStateOrd == goMap.status.state) {
																					if (goMap.status.markerInterval != null) {
																						clearInterval( goMap.status.markerInterval );
																						goMap.status.markerInterval = null;
																					}
																					
																					goMap.status.markerInterval = setInterval(goMap.tools.DisplayState, 500);
																				}
																			}
																		}
											
											request.send(null);
										}
									}
		
		this.LoadCityOfficeData = function() {
										if (goMap.status.city != null && goMap.status.state != null) {
											var liStateOrd = goMap.status.state;
											var liCityOrd = goMap.status.city;
											
											var path = "http://" + gsURL + "/locations/data.offices.aspx?city=" + goMap.states[liStateOrd].cities[liCityOrd].name + "&state=" + goMap.states[liStateOrd].code;
											var request = GXmlHttp.create();
											
											request.open("GET", path, true);
											request.onreadystatechange = function() {
																			if (request.readyState == 4) {
																				if (liStateOrd != null && liCityOrd != null) {
																					var xmlDoc = request.responseXML;
																					var lsCityName = xmlDoc.documentElement.getAttribute("state");
																					var lsCityLat = xmlDoc.documentElement.getAttribute("lat");
																					var lsCityLng = xmlDoc.documentElement.getAttribute("lng");
																					var lsCityZoom = xmlDoc.documentElement.getAttribute("zoom");
																					
																					goMap.states[liStateOrd].cities[liCityOrd].center = new GLatLng( parseFloat(lsCityLat), parseFloat(lsCityLng) );
																					goMap.states[liStateOrd].cities[liCityOrd].zoom = parseInt(lsCityZoom);
																					
																					if (goMap.states[liStateOrd].cities[liCityOrd].loadOfficeStatus == goMap.constants.loadStatus.isReady) {
																						goMap.states[liStateOrd].cities[liCityOrd].loadOfficeStatus = goMap.constants.loadStatus.isLoading;
																						goMap.tools.ParseOfficeData( xmlDoc.documentElement.getElementsByTagName("office"), liStateOrd, liCityOrd, null );
																						goMap.states[liStateOrd].cities[liCityOrd].loadOfficeStatus = goMap.constants.loadStatus.isDone;
																					}
																				}
																				
																				if (liStateOrd == goMap.status.state && liCityOrd == goMap.status.city) {
																					if (goMap.status.markerInterval != null) {
																						clearInterval( goMap.status.markerInterval );
																						goMap.status.markerInterval = null;
																					}
																					
																					goMap.status.markerInterval = setInterval(goMap.tools.DisplayCity, 500);
																				}
																			}
																		}
											
											request.send(null);
										}
									}
		
		this.LoadZipOfficeData = function( psZip ) {
									if (psZip != null) {
										var path = "http://" + gsURL + "/locations/data.offices.aspx?zip=" + psZip;
										var request = GXmlHttp.create();
										
										request.open("GET", path, true);
										request.onreadystatechange = function() {
																		if (request.readyState == 4) {
																			var xmlDoc = request.responseXML;
																			var lsZipState = xmlDoc.documentElement.getAttribute("state");
																			var lsZipLat = xmlDoc.documentElement.getAttribute("lat");
																			var lsZipLng = xmlDoc.documentElement.getAttribute("lng");
																			var lsZipZoom = xmlDoc.documentElement.getAttribute("zoom");
																			
																			var liZipOrd = goMap.tools.GetZip( psZip );
																			if (liZipOrd == null) {
																				goMap.zips.push( new MapZip( psZip, lsZipState, parseFloat(lsZipLat), parseFloat(lsZipLng), parseInt(lsZipZoom) ) );
																				liZipOrd = goMap.zips.length - 1;
																			}
																			
																			goMap.status.zip = liZipOrd;
																			
																			if (goMap.zips[liZipOrd].loadOfficeStatus == goMap.constants.loadStatus.isReady) {
																				goMap.zips[liZipOrd].loadOfficeStatus = goMap.constants.loadStatus.isLoading;
																				goMap.tools.ParseOfficeData( xmlDoc.documentElement.getElementsByTagName("office"), null, null, liZipOrd );
																				goMap.zips[liZipOrd].loadOfficeStatus = goMap.constants.loadStatus.isDone;
																			}
																			
																			if (liZipOrd == goMap.status.zip) {
																				if (goMap.status.markerInterval != null) {
																					clearInterval( goMap.status.markerInterval );
																					goMap.status.markerInterval = null;
																				}
																				
																				goMap.status.markerInterval = setInterval(goMap.tools.DisplayZip, 500);
																			}
																		}
																	}
										
										request.send(null);
									}
								}
		
		return this;
	}
	
	
	function MapChangeState() {
		MapUpdateStatusMessage( "Loading state data...", 1 );
		goMap.tools.ClearLocation( "state" );
		
		var loState = document.getElementById( "state" );
		var lsState = (loState) ? loState.value : "";
		
		if (lsState.length == 0) {
			goMap.status.state = null;
			goMap.map.setCenter( goMap.center, goMap.zoom );
			
			var loPanel = document.getElementById("cityPanel");
			if (loPanel) loPanel.style.visibility = "hidden";
			
			MapUpdateStatusMessage( null, 0 );
		} else {
			goMap.status.state = goMap.tools.GetState( lsState );
			
			var liLoadStatus = (goMap.status.state == null) ? goMap.constants.loadStatus.isReady : goMap.states[goMap.status.state].loadOfficeStatus;
			if (liLoadStatus == goMap.constants.loadStatus.isReady) {
				goMap.tools.LoadStateOfficeData( lsState );
			} else {
				goMap.tools.DisplayState();
			}
		}
	}
	
	
	function MapChangeCity() {
		MapUpdateStatusMessage( "Loading city data...", 1 );
		goMap.tools.ClearLocation( "city" );
				
		var loCity = document.getElementById( "city" );
		var lsCity = (loCity) ? loCity.value : "";
		
		if (lsCity.length == 0) {
			goMap.status.city = null;
			goMap.map.setCenter( goMap.states[goMap.status.state].center, goMap.states[goMap.status.state].zoom );
			
			MapUpdateStatusMessage( null, 0 );
		} else {
			goMap.status.city = parseInt(lsCity);
			
			if (goMap.states[goMap.status.state].cities[goMap.status.city].loadOfficeStatus == goMap.constants.loadStatus.isReady) {
				goMap.tools.LoadCityOfficeData();
			} else {
				goMap.tools.DisplayCity();
			}
		}
	}
	
	
	function MapChangeZip( obj ) {
		MapUpdateStatusMessage( 'Loading zipcode data...', 1 );
		goMap.tools.ClearLocation( "zip" );
				
		var loZip = document.getElementById( "zip" );
		var lsZip = (loZip) ? loZip.value : "";
		
		if (lsZip.length == 5) {
			goMap.status.zip = goMap.tools.GetZip( lsZip );
			
			var liLoadStatus = (goMap.status.zip == null) ? goMap.constants.loadStatus.isReady : goMap.zips[goMap.status.zip].loadOfficeStatus;
			if (liLoadStatus == goMap.constants.loadStatus.isReady) {
				goMap.tools.LoadZipOfficeData( lsZip );
			} else {
				goMap.tools.DisplayZip();
			}
		} else {
			MapUpdateStatusMessage( 'You must enter a valid zip code!', 3 );
			alert('You must enter a valid 5-digit zip code!');
		}
		
	}
	
	
	function MapUpdateStatusMessage( msg, icon ) {
		var obj = document.getElementById( "statusmsg" );
		if (obj) obj.innerText = (msg == null) ? "" : msg;
		
		var obj = document.getElementById( "statusimg" );
		if (obj) {
			var file;
			
			switch(icon) {
				case 1:
					file = 'rotate.gif';
					break;
				case 2:
					file = 'error.gif';
					break;
				case 3:
					file = 'exclamation.gif';
					break;
				default:
					file = 'comment.gif';
					break;
			}
			
			obj.src = "/locations/images/" + file;
		}
	}
	
	
	function MapDisableLocatorControls() {
		var loLoading = document.getElementById( "formbox_loading" );
		if (loLoading) loLoading.style.display = "block";
		
		var loFormBox = document.getElementById( "formbox" );
		if (loFormBox) loFormBox.style.display = "none";
	}
	
	
	function MapEnableLocatorControls() {
		var loLoading = document.getElementById( "formbox_loading" );
		if (loLoading) loLoading.style.display = "none";
		
		var loFormBox = document.getElementById( "formbox" );
		if (loFormBox) loFormBox.style.display = "block";
	}
