
function Address(buildingNumber, street, countrySubdivision, countrySecondarySubdivision, municipality, postalCode, municipalitySubdivision) {
	this.buildingNumber = buildingNumber;
	this.street = street;
	this.countrySubdivision = countrySubdivision;
	this.countrySecondarySubdivision = countrySecondarySubdivision;
	this.municipality = municipality;
	this.postalCode = postalCode;
	this.municipalitySubdivision = municipalitySubdivision;
	this.getBuildingNumber = function () {
		return this.buildingNumber;
	};
	this.getStreet = function () {
		return this.street;
	};
	this.getCountrySubdivision = function () {
		return this.countrySubdivision;
	};
	this.getCountrySecondarySubdivision = function () {
		return this.countrySecondarySubdivision;
	};
	this.getMunicipality = function () {
		return this.municipality;
	};
	this.getPostalCode = function () {
		return this.postalCode;
	};
	this.getMunicipalitySubdivision = function () {
		return this.municipalitySubdivision;
	};
	this.toString = function () {
		if (this.buildingNumber + this.street + this.municipality + this.countrySubdivision + this.postalCode == "") {
			return "";
		} else {
			return this.buildingNumber + " " + this.street + " " + this.municipality + " " + this.countrySubdivision + " " + this.postalCode;
		}
	};
}
function BoundingBox(minPos, maxPos) {
	if (!minPos || !maxPos) {
		throw new Exception("Error instantiating BoundingBox, invalid parameters.");
	}
	this.minPosition = minPos;
	this.maxPosition = maxPos;
	this.heightInDegrees = this.maxPosition.lat - this.minPosition.lat;
	this.widthInDegrees = this.maxPosition.lon - this.minPosition.lon;
	this.getMaxPosition = function () {
		return this.maxPosition;
	};
	this.getMinPosition = function () {
		return this.minPosition;
	};
	this.getCenterPosition = function () {
		var centerLat = parseFloat(this.maxPosition.lat - ((this.maxPosition.lat - this.minPosition.lat) / 2));
		var centerLng = parseFloat(this.maxPosition.lon - ((this.maxPosition.lon - this.minPosition.lon) / 2));
		return new Position(centerLat, centerLng);
	};
	this.getRadius = function () {
		if (this.heightInDegrees > this.widthInDegrees) {
			return (this.heightInDegrees * 136) / 2;
		} else {
			return (this.widthInDegrees * 136) / 2;
		}
	};
	this.contains = function (pos) {
		if (pos.lat > this.minPosition.lat && pos.lon > this.minPosition.lon && pos.lat < this.maxPosition.lat && pos.lon < this.maxPosition.lon) {
			return true;
		} else {
			return false;
		}
	};
	this.extendedContains = function (pos) {
		if (pos.lat > this.minPosition.lat - this.heightInDegrees && pos.lon > this.minPosition.lon - this.widthInDegrees && pos.lat < this.maxPosition.lat + this.heightInDegrees && pos.lon < this.maxPosition.lon + this.widthInDegrees) {
			return true;
		} else {
			return false;
		}
	};
	this.equals = function (bbox) {
		if (bbox && this.minPosition == bbox.getMinPosition() && this.maxPosition == bbox.getMaxPosition()) {
			return true;
		} else {
			return false;
		}
	};
	this.toString = function () {
		return this.minPosition.toString() + " " + this.maxPosition.toString();
	};
}
function Credentials() {
}
Credentials.url = "http://carsupermarkets.autotrader.co.uk/CarSupermarkets/ProxyServlet";
Credentials.clientName = "decartaProxyUser";
Credentials.clientPassword = "71gb7lp";
Credentials.configuration = "us-carto";
Credentials.transparentConfiguration = "transparent-tile";
Credentials.mapType = "STREET";
Credentials.ISOCountryCode = "US";
Credentials.trafficEnabled = false;
Credentials.rel = "";
Credentials.dgkey = "";
Credentials.errorTile = "img/tile.png";
function DDSShape() {
	this.borderColor = "(0.0.0)";
	this.borderStyle = "SOLID";
	this.borderWidth = "2";
	this.fillColor = "(255.0.0)";
	this.id = Math.floor(Math.random() * 10000000);
	this.opacity = "65";
	this.map = null;
}
DDSShape.prototype.setBorderColor = function (borderColor) {
	if (!borderColor.match(/\([0-9]+\.[0-9]+\.[0-9]+\)/)) {
		alert("Error setting RGB value in DDSShape.setBorderColor\nPlease use format (255.255.255)");
		return false;
	}
	this.borderColor = borderColor;
};
DDSShape.prototype.getBorderColor = function () {
	return this.borderColor;
};
DDSShape.prototype.setBorderStyle = function (borderStyle) {
	if (borderStyle == "SOLID" || borderStyle == "DASH" || borderStyle == "DOT" || borderStyle == "DASHDOTDOT" || borderStyle == "ALTBLACKDASH" || borderStyle == "RAIL" || borderStyle == "NONE") {
		this.borderStyle = borderStyle;
	} else {
		alert("Error setting border style value in DDSShape.setBorderStyle\nPlease use format SOLID, DASH, DOT, DASHDOTDOT, ALTBLACKDASH, RAIL, NONE");
		return false;
	}
};
DDSShape.prototype.getBorderStyle = function () {
	return this.borderStyle;
};
DDSShape.prototype.setBorderWidth = function (borderWidth) {
	this.borderWidth = borderWidth;
};
DDSShape.prototype.getBorderWidth = function () {
	return this.borderWidth;
};
DDSShape.prototype.setFillColor = function (fillColor) {
	if (!fillColor.match(/\([0-9]+\.[0-9]+\.[0-9]+\)/)) {
		alert("Error setting RGB value in DDSShape.setColor\nPlease use format (255.255.255)");
		return false;
	}
	this.fillColor = fillColor;
};
DDSShape.prototype.getFillColor = function () {
	return this.fillColor;
};
DDSShape.prototype.getId = function () {
	return this.id;
};
DDSShape.prototype.setOpacity = function (opacity) {
	this.opacity = opacity;
};
DDSShape.prototype.getOpacity = function () {
	return this.opacity;
};
DDSShape.prototype.equals = function (obj) {
	if (obj && this.id == obj.id) {
		return true;
	} else {
		return false;
	}
};
function DDSCircle(position, radius) {
	this.id = Math.floor(Math.random() * 10000000);
	this.type = "circle";
	this.radius = radius;
	this.position = position;
}
DDSCircle.prototype = new DDSShape();
DDSCircle.prototype.setPosition = function (position) {
	this.position = position;
	if (this.map != null && this.map.getShapeRendering() == "client") {
		map.redraw();
	}
};
DDSCircle.prototype.getPosition = function () {
	return this.position;
};
DDSCircle.prototype.setRadius = function (radius) {
	this.radius = radius;
	if (this.map != null && this.map.getShapeRendering() == "client") {
		map.redraw();
	}
};
DDSCircle.prototype.getRadius = function () {
	return this.radius;
};
function DDSLine(width) {
	this.id = Math.floor(Math.random() * 10000000);
	this.type = "line";
	this.positions = [];
	this.width = width;
	this.VR7;
}
DDSLine.prototype = new DDSShape();
DDSLine.prototype.setPositions = function (positions) {
	this.positions = positions;
	if (this.map != null && this.map.getShapeRendering() == "client") {
		map.redraw();
	}
};
DDSLine.prototype.getPositions = function () {
	return this.positions;
};
DDSLine.prototype.setWidth = function (width) {
	this.width = width;
};
DDSLine.prototype.getWidth = function () {
	return this.width;
};
DDSLine.prototype.setVR7 = function (VR7) {
	this.VR7 = VR7;
};
DDSLine.prototype.getVR7 = function () {
	return this.VR7;
};
function DDSPolygon() {
	this.id = Math.floor(Math.random() * 10000000);
	this.type = "polygon";
	this.positions = [];
	this.VR7;
}
DDSPolygon.prototype = new DDSShape();
DDSPolygon.prototype.setPositions = function (positions) {
	this.positions = positions;
	if (this.map != null && this.map.getShapeRendering() == "client") {
		map.redraw();
	}
};
DDSPolygon.prototype.getPositions = function () {
	return this.positions;
};
DDSPolygon.prototype.setVR7 = function (VR7) {
	this.VR7 = VR7;
	if (this.map != null) {
		map.redraw();
	}
};
DDSPolygon.prototype.getVR7 = function () {
	return this.VR7;
};
function EventRegistry() {
}
EventRegistry.addListener = function (source, event, callBack) {
	if (source.type == "map" && (event == "rightclick" || event == "dblclick" || event == "click" || event == "moveend" || event == "zoomend")) {
		source.addEventListener(event, callBack);
	} else {
		if (source.type == "pin" && (event == "rightclick" || event == "dblclick" || event == "click" || event == "mouseover" || event == "mouseout")) {
			source.addEventListener(event, callBack);
		} else {
			throw new Exception(event + " is unsupported event type for " + source.type);
		}
	}
};
EventRegistry.clearListeners = function (source, event) {
	source.clearListeners(event);
};
EventRegistry.clearInstanceListeners = function (source) {
	source.clearInstanceListeners();
};
function Exception(message) {
	this.message = message || "an exception has occurred";
	var self = this;
	this.getMessage = function () {
		return self.message;
	};
	this.toString = function () {
		return self.message;
	};
}
function FreeFormAddress(address, locale) {
	if (!address || address.toString() == "") {
		throw new Exception("Error instantiating FreeFormAddress, invalid parameters.");
		return false;
	}
	this.locale = locale || new Locale("en", "US");
	var self = this;
	this.address = address;
	this.getLocale = function () {
		return self.locale;
	};
	this.toString = function () {
		return this.address;
	};
}
function GeocodedAddress() {
	this.position = [];
	this.freeFormAddress = [];
	this.boundingBox = null;
	this.matchType = "";
}
GeocodedAddress.prototype.toString = function () {
	return this.position + "\n" + this.freeFormAddress + "\n" + this.boundingBox + "\n" + this.matchType;
};
function Geocoder() {
	this.xmlRecFac = new XMLRequestFactory();
	var ag = new Array();
	var self = this;
	this.authenticate = function (clientName, clientPassword) {
		if (!clientName || !clientPassword || clientName == "" || clientPassword == "") {
			throw new Exception("Error authenticating Geocoder, invalid parameters.");
			return false;
		}
		Credentials.clientName = clientName;
		Credentials.clientPassword = clientPassword;
	};
	this.geocode = function (address, callBack) {
		var reqId = Utilities.getRequestId();
		ag[reqId] = callBack;
		ab = this.xmlRecFac.createGeocodeRequestDOM(address, reqId);
		JSRequest.send(ab, self.geocodeCallback);
	};
	this.reverseGeocode = function (position, callBack) {
		var reqId = Utilities.getRequestId();
		ag[reqId] = callBack;
		ab = this.xmlRecFac.createReverseGeocodeRequestDOM(position, reqId);
		JSRequest.send(ab, self.reverseGeocodeCallback);
	};
	this.reverseGeocodeCallback = function (data) {
		var oDomDoc = Sarissa.getDomDocument();
		oDomDoc = (new DOMParser()).parseFromString(Utilities.normalizePrefixes(data), "text/xml");
		if (document.all) {
			oDomDoc.setProperty("SelectionLanguage", "XPath");
			oDomDoc.setProperty("SelectionNamespaces", "xmlns:xls='http://www.opengis.net/xls' xmlns:gml='http://www.opengis.net/gml'");
		}
		if (oDomDoc.selectNodes("//xls:Error").length > 0) {
			var reqId = Sarissa.getText(oDomDoc.selectSingleNode("//xls:Response/@requestID"));
			if (reqId != -1) {
				ag[reqId](new Address("", "", "", "", "", "", ""));
			} else {
				throw new Exception("Error looking up reverse geocode callback, server did not provide necessary information.");
				return false;
			}
			return false;
		} else {
			try {
				var num = Sarissa.getText(oDomDoc.selectSingleNode("//xls:Building/@number"));
			}
			catch (e) {
				var num = "";
			}
			try {
				var str = Sarissa.getText(oDomDoc.selectSingleNode("//xls:Street"));
			}
			catch (e) {
				var str = "";
			}
			try {
				var stt = Sarissa.getText(oDomDoc.selectSingleNode("//xls:Place[@type='CountrySubdivision']"));
			}
			catch (e) {
				var stt = "";
			}
			try {
				var cou = Sarissa.getText(oDomDoc.selectSingleNode("//xls:Place[@type='CountrySecondarySubdivision']"));
			}
			catch (e) {
				var cou = "";
			}
			try {
				var cit = Sarissa.getText(oDomDoc.selectSingleNode("//xls:Place[@type='Municipality']"));
			}
			catch (e) {
				var cit = "";
			}
			try {
				var citsub = Sarissa.getText(oDomDoc.selectSingleNode("//xls:Place[@type='MunicipalitySubdivision']"));
			}
			catch (e) {
				var citsub = "";
			}
			try {
				var pst = Sarissa.getText(oDomDoc.selectSingleNode("//xls:PostalCode"));
			}
			catch (e) {
				var pst = "";
			}
			var reqId = Sarissa.getText(oDomDoc.selectSingleNode("//xls:Response/@requestID"));
			ag[reqId](new Address(num, str, stt, cou, cit, pst, citsub));
		}
	};
	this.geocodeCallback = function (data) {
		var oDomDoc = (new DOMParser()).parseFromString(Utilities.normalizePrefixes(data), "text/xml");
		if (document.all) {
			oDomDoc.setProperty("SelectionLanguage", "XPath");
			oDomDoc.setProperty("SelectionNamespaces", "xmlns:xls='http://www.opengis.net/xls' xmlns:gml='http://www.opengis.net/gml'");
		}
		var posList = [];
		var addrList = [];
		var geocodedAddressList = [];
		if (oDomDoc.selectNodes("//xls:Error").length > 0) {
			var reqId = Sarissa.getText(oDomDoc.selectSingleNode("//xls:Response/@requestID"));
			ag[reqId](posList, addrList);
		} else {
			var geocodedAddresses = new Array();
			try {
				var geocodedAddresses = oDomDoc.selectNodes("//xls:GeocodedAddress");
			}
			catch (e) {
				var reqId = Sarissa.getText(oDomDoc.selectSingleNode("//xls:Response/@requestID"));
				ag[reqId](posList, addrList);
				return false;
			}
			for (var i = 0; i < geocodedAddresses.length; i++) {
				var geocodedAddress = new GeocodedAddress();
				var txtTmp = (Sarissa.serialize((geocodedAddresses[i])));
				if (txtTmp.indexOf("<gml:pos/>") > 0) {
					var pos = "0.0 0.0";
				} else {
					var pos = txtTmp.substring(txtTmp.indexOf("<gml:pos>") + "<gml:pos>".length, txtTmp.indexOf("</gml:pos>"));
				}
				geocodedAddress.position = new Position(pos);
				if (txtTmp.indexOf("<xls:freeFormAddress/>") > 0) {
					var ffa = "NO ADDRESS FOUND";
				} else {
					var ffa = txtTmp.substring(txtTmp.indexOf("<xls:freeFormAddress>") + "<xls:freeFormAddress>".length, txtTmp.indexOf("</xls:freeFormAddress>"));
				}
				geocodedAddress.freeFormAddress = new FreeFormAddress(ffa);
				if (txtTmp.indexOf("<xls:BoundingBox>") < 0) {
					var bb = null;
				} else {
					var tmpBB = txtTmp.substring(txtTmp.indexOf("<xls:BoundingBox>") + "<xls:BoundingBox>".length, txtTmp.indexOf("</xls:BoundingBox>"));
					var pos1 = tmpBB.substring(tmpBB.indexOf("\">") + "\">".length, tmpBB.indexOf("</gml"));
					var tmpBB2 = tmpBB.substring(tmpBB.indexOf("</gml") + 5, tmpBB.length);
					var pos2 = tmpBB2.substring(tmpBB2.indexOf("\">") + "\">".length, tmpBB2.indexOf("</gml"));
					var bb = new BoundingBox(new Position(pos1), new Position(pos2));
				}
				geocodedAddress.boundingBox = bb;
				if (txtTmp.indexOf("matchType") < 0) {
					var match = null;
				} else {
					var match = txtTmp.substring(txtTmp.indexOf("matchType="));
					match = match.substring(match.indexOf("\"") + 1);
					match = match.substring(0, match.indexOf("\""));
				}
				geocodedAddress.matchType = match;
				posList.push(new Position(pos));
				addrList.push(new FreeFormAddress(ffa));
				geocodedAddressList.push(geocodedAddress);
			}
			var reqId = Sarissa.getText(oDomDoc.selectSingleNode("//xls:Response/@requestID"));
			ag[reqId](posList, addrList, geocodedAddressList);
		}
	};
}
function GLOBALS() {
}
GLOBALS.HYBRID = "HYBRID";
GLOBALS.STREET = "STREET";
GLOBALS.SATELLITE = "SATELLITE";
GLOBALS.PAN_PIXEL_DISTANCE = 300;
function Icon(src, iconAnchorX, iconAnchorY, width, height, overlay) {
	if (!src || !iconAnchorX || !iconAnchorY || !width || !height) {
		alert("Error instantiating Icon, missing parameters.\n\n as of release 4.2.1 height and width are required parameters for Icon construction\n\n\t Icon(src,iconAnchorX,iconAnchorY,width,height) all required\n\n the overlay is still optional");
		return false;
	}
	this.ch;
	this.cg;
	var self = this;
	this.src = src;
	this.anchorX = iconAnchorX;
	this.anchorY = iconAnchorY;
	this.height = null;
	this.width = null;
	if (width) {
		this.width = width;
	}
	if (height) {
		this.height = height;
	}
	this.overlay = overlay || new TextOverlay("", 1, 1);
}
Icon.prototype.getAnchorX = function () {
	return this.anchorX;
};
Icon.prototype.getAnchorY = function () {
	return this.anchorY;
};
Icon.prototype.getHeight = function () {
	return this.height;
};
Icon.prototype.getOverlay = function () {
	return this.overlay;
};
Icon.prototype.getSrc = function () {
	return this.src;
};
Icon.prototype.getWidth = function () {
	return this.width;
};
Icon.prototype.setAnchorX = function (anchorX) {
	this.ch = this.anchorX;
	this.anchorX = anchorX;
};
Icon.prototype.setAnchorY = function (anchorY) {
	this.cg = this.anchorY;
	this.anchorY = anchorY;
};
Icon.prototype.setHeight = function (height) {
	this.height = height;
};
Icon.prototype.setOverlay = function (overlay) {
	this.overlay = overlay;
};
Icon.prototype.setSrc = function (src) {
	this.src = src;
};
Icon.prototype.setWidth = function (width) {
	this.width = width;
};
function InfoWindow(html, xOffset, yOffset, icon) {
	this.html = html;
	this.xOffset = xOffset;
	this.yOffset = yOffset;
	this.icon = icon;
}
function JSRequest() {
}
JSRequest.host = null;
JSRequest.interceptorRequestFunction = null;
JSRequest.interceptorResponseFunction = null;
JSRequest.TIMEOUT = 45000;
JSRequest.xmlhttp = true;
JSRequest.hostInProgress = false;
JSRequest.holder = [];
JSRequest.registerXMLRequestInterceptor = function (funct) {
	JSRequest.interceptorRequestFunction = funct;
};
JSRequest.registerXMLResponseInterceptor = function (funct) {
	JSRequest.interceptorResponseFunction = funct;
};
JSRequest.callbackFunctions = new Array();
JSRequest.callbackRegistry = function (d) {
	var data = d;
	try {
		if (data && data.response != null && data.response.indexOf("problem connecting to DDS") > 0) {
			alert("Problem connecting to DDS: Please try again later or contact support");
			return;
		}
		if (data.response != null) {
			try {
				if (typeof JSRequest.interceptorResponseFunction === "function") {
					var xml = (new DOMParser()).parseFromString(Utilities.normalizePrefixes(data.response), "text/xml");
					if (data.response.indexOf("RUOK") == -1) {
						data.response = Sarissa.serialize(JSRequest.interceptorResponseFunction(xml));
					}
				}
			}
			catch (e) {
				alert("Application Error:\n\nAPI user application response interceptor " + "function threw error:\n\n" + e.message);
				return;
			}
			JSRequest.callbackFunctions[data.requestID](data.response);
			JSRequest.callbackFunctions[data.requestID] = null;
		} else {
		}
		document.getElementsByTagName("head").item(0).removeChild(document.getElementById(data.requestID + ":" + data.chunkNo));
	}
	catch (e) {
		alert(e);
	}
};
JSRequest.checkTimeout = function (id) {
	var requestID = (id.split(":"))[0];
	if (JSRequest.callbackFunctions[requestID] != null) {
		alert("request time out");
		JSRequest.callbackFunctions[requestID] = null;
		document.getElementsByTagName("head").item(0).removeChild(document.getElementById(id));
	}
};
JSRequest.send = function (xmlDOM, callback) {
	if (JSRequest.xmlhttp) {
		try {
			if (!document.all) {
				try {
					netscape.security.PrivilegeManager.enablePrivilege("UniversalPreferencesWrite UniversalBrowserWrite UniversalPreferencesRead UniversalBrowserRead");
				}
				catch (e) {
				}
			}
			var xmlhttp = new XMLHttpRequest();
			xmlhttp.open("POST", Credentials.url, true);
		}
		catch (e) {
			alert(e + "\n\n Depending on your browser settings you may have troubles running JavaScript code that uses the XMLHTTPRequest from your local file system.  XMLHTTPRequest verifies that the request to the server is from a script that is downloaded from that same server.  To remedy this problem, place your app inside tomcat and access from localhost.  Or see the 4.2.2 feature of using dynamic script tags (JSON/GET) to bypass this security issue.");
		}
		xmlhttp.onreadystatechange = function () {
			if (xmlhttp.readyState == 4) {
				if (xmlhttp.responseText == "") {
					alert("Problem connecting to DDS Web Services: Please try again later or contact support");
					return;
				}
				if (xmlhttp.responseText && xmlhttp.responseText != null && xmlhttp.responseText.indexOf("problem connecting to DDS") > 0) {
					alert("Problem connecting to DDS: Please try again later or contact support");
					return;
				}
				callback(xmlhttp.responseText);
			}
		};
		xmlhttp.send(xmlDOM);
		return;
	}
	if (JSRequest.host == null) {
		JSRequest.holder.push(xmlDOM);
		JSRequest.holder.push(callback);
		if (JSRequest.hostInProgress) {
			return;
		}
		JSRequest.hostInProgress = true;
		var xmlRecFac = new XMLRequestFactory();
		var initial = xmlRecFac.createRUOKRequestDOM(Utilities.getRequestId());
		xmlDOM = initial;
		callback = JSRequest.getHost;
	}
	try {
		if (typeof JSRequest.interceptorRequestFunction === "function") {
			if (!JSRequest.xmlhttp && JSRequest.host == null) {
				var xml = Sarissa.serialize(xmlDOM);
			} else {
				var xml = Sarissa.serialize(JSRequest.interceptorRequestFunction(xmlDOM));
			}
		} else {
			var xml = Sarissa.serialize(xmlDOM);
		}
	}
	catch (e) {
		alert("Application Error:\n\nAPI user application request interceptor " + "function threw error:\n\n" + e.message);
		return;
	}
	var url = Credentials.url;
	max = 1800;
	var urlLength = url.length;
	var otherParamsLength = 80;
	var escXmlLength = (escape(xml)).length;
	var chunks;
	var i = 1;
	while (true) {
		if (urlLength + otherParamsLength + (escXmlLength / i) < max) {
			chunks = i;
			break;
		}
		i++;
	}
	var multipart = "";
	var multipartLength = xml.length / chunks;
	var reqId = Utilities.getRequestId();
	for (var i = 1; i <= chunks; i++) {
		JSRequest.callbackFunctions[reqId] = callback;
		var xmlSubStr = xml.substring(multipartLength * i - multipartLength, multipartLength * i);
		multipart = escape(xmlSubStr);
		var scriptObj = document.createElement("script");
		scriptObj.setAttribute("type", "text/javascript");
		var completeURL = url + "?reqID=" + reqId + "&chunkNo=" + i + "&numChunks=" + chunks + "&callback=JSRequest.callbackRegistry&data=" + multipart;
		completeURL = completeURL.replace(new RegExp("\\+", "g"), "%2b");
		scriptObj.setAttribute("src", completeURL);
		scriptObj.setAttribute("id", reqId + ":" + i);
		document.getElementsByTagName("head").item(0).appendChild(scriptObj);
		setTimeout("JSRequest.checkTimeout('" + reqId + ":" + i + "')", JSRequest.TIMEOUT);
	}
};
JSRequest.getHost = function (data) {
	var oDomDoc = Sarissa.getDomDocument();
	oDomDoc = (new DOMParser()).parseFromString(Utilities.normalizePrefixes(data), "text/xml");
	oDomDoc.setProperty("SelectionLanguage", "XPath");
	oDomDoc.setProperty("SelectionNamespaces", "xmlns:xls='http://www.opengis.net/xls' xmlns:gml='http://www.opengis.net/gml'");
	if (oDomDoc.selectNodes("//xls:Error").length > 0) {
		alert("Error Message:\n\n\n" + (oDomDoc.selectNodes("//@message"))[0].value);
		return false;
	}
	var host = oDomDoc.selectSingleNode("//xls:RUOKResponse/@hostName").value;
	var u = Credentials.url;
	var prefix, suffix;
	if (u.indexOf("https://") > -1) {
		prefix = "https://";
	} else {
		prefix = "http://";
	}
	var tmp = u.substring(prefix.length);
	if (tmp.indexOf(":") > -1) {
		suffix = tmp.substring(tmp.indexOf(":"));
	} else {
		suffix = tmp.substring(tmp.indexOf("/"));
	}
	JSRequest.host = prefix + host + suffix;
	Credentials.url = JSRequest.host;
	for (var i = 0; i < JSRequest.holder.length; i++) {
		JSRequest.send(JSRequest.holder[i], JSRequest.holder[i + 1]);
		i = i + 1;
	}
	JSRequest.holder = [];
};
JSRequest.setXMLHTTPMode = function () {
	JSRequest.xmlhttp = true;
	if (Credentials.url.indexOf("JSON") > -1) {
		var url = Credentials.url.substring(0, Credentials.url.indexOf("/JSON"));
		Credentials.url = url + "/openls";
	}
};
JSRequest.setDynamicScriptTagMode = function () {
	JSRequest.xmlhttp = false;
	if (Credentials.url.indexOf("/openls/openls") > -1) {
		var url = Credentials.url.substring(0, Credentials.url.indexOf("/openls/openls"));
		Credentials.url = url + "/openls/JSON";
	}
};
function Locale(language, country) {
	this.language = language.toUpperCase();
	this.country = country.toUpperCase();
	var self = this;
	this.toString = function () {
		return self.country + "_" + self.language;
	};
	this.getLanguage = function () {
		return self.language;
	};
	this.getCountry = function () {
		return self.country;
	};
	this.setLanguage = function (language) {
		self.language = language;
	};
	this.setCountry = function (country) {
		self.country = country;
	};
}
function Map(mapContainer) {
	if (!mapContainer) {
		alert("must supply the map div to construct the new Map");
		return false;
	}
	this.mapDiv = mapContainer;
	this.type = "map";
	this.routePreference = new RoutePreference("Fastest", new UOM("MI"));
	var by = "server";
	var cd = false;
	var bi = null;
	var br = null;
	var ai = 256;
	var am = "img/tile.png";
	var ap = new XMLRequestFactory();
	var dg = 0;
	var df = 0;
	var dk = 0;
	var dj = 0;
	var ae = null;
	var aa = new Array();
	var ad = 0;
	var ac = 0;
	var de = false;
	var aw = ai;
	var aj = 0;
	var ah = 0;
	var bv = 0;
	var bu = 2;
	var dr = "dashed";
	var bn = document.all;
	var ab = null;
	var az = null;
	var bc = 0;
	var ba = 0;
	var cs = 0;
	var da = 0;
	var cz = 0;
	var cw = 0;
	var bx = 0;
	var bw = 0;
	var cb = 0;
	var ca = 0;
	var be = 0;
	var bd = 0;
	var dm = 0;
	var dl = 0;
	var bk = 0;
	var bq = 0;
	var al = null;
	var self = this;
	var ag = new Array();
	var af = new Array();
	var as = null;
	var cl = false;
	var bz = true;
	var bh = true;
	var ak = new Array();
	var au = "px";
	var ao = null;
	var aq = null;
	var dt = new RegExp("\\amp;", "g");
	var an = "STREET";
	var di = new Array();
	var av = new Array(0, 0);
	var cc = new Date();
	var cn = new Date();
	var cr = parseInt(mapContainer.style.height);
	var db = parseInt(mapContainer.style.width);
	var cv = false;
	var cq = false;
	this.addCopyrightMessage = function (message, x, y) {
		aq = document.createElement("DIV");
		aq.id = "copyright";
		if (x && y) {
			aq.style.top = y + au;
			aq.style.left = x + au;
		} else {
			aq.style.top = ((parseInt(self.mapDiv.style.height)) - 20) + au;
			aq.style.left = "1px";
		}
		aq.style.backgroundColor = "#ffffff";
		aq.style.opacity = "50";
		aq.innerHTML = message;
		aq.style.filter = "alpha(opacity=80)";
		aq.style.opacity = "0.8";
		aq.style.borderWidth = "1px";
		aq.style.padding = "1px";
		aq.style.fontFamily = "arial";
		aq.style.fontColor = "#000000";
		aq.style.fontSize = "11px";
		aq.style.borderStyle = "solid";
		aq.style.borderColor = "gray";
		aq.style.display = "block";
		aq.style.position = "absolute";
		aq.style.zIndex = 9999;
		self.mapDiv.appendChild(aq);
	};
	this.addCustomInfoWindow = function (infoWindow) {
		if (!ao) {
			ao = initBubble();
		}
		if (ae) {
			ae.removeChild(ao);
		}
		ao = infoWindow.html;
		ao.id = "bubble";
		ao.type = "custom";
		ao.offX = infoWindow.xOffset;
		ao.offY = infoWindow.yOffset;
		if (ae) {
			ae.appendChild(ao);
		}
		_bubbleContent.style.position = "absolute";
		_bubbleClose.style.zIndex = "99999";
		ao.appendChild(_bubbleClose);
		ao.appendChild(_bubbleContent);
		if (infoWindow.icon) {
			_bubbleClose.src = infoWindow.icon.src;
			_bubbleClose.style.top = infoWindow.icon.anchorY + au;
			_bubbleClose.style.left = infoWindow.icon.anchorX + au;
			if (infoWindow.icon.height) {
				_bubbleClose.style.height = infoWindow.icon.height + au;
			}
			if (infoWindow.icon.width) {
				_bubbleClose.style.width = infoWindow.icon.width + au;
			}
			if (Utilities.ie6 && _bubbleClose.src.match(new RegExp("\\bpng\\b", "g"))) {
				Utilities.fixPng(_bubbleClose);
			}
		}
	};
	this.addAndCenterOnPin = function (pin) {
		this.addPin(pin);
		this.panToPosition(pin.position);
	};
	this.addEventListener = function (event, callBack) {
		var alreadyRegistered = false;
		for (var i = 0; i < ak.length; i++) {
			if (ak[i] == event) {
				ak[event] = callBack;
				alreadyRegistered = true;
				break;
			}
		}
		if (!alreadyRegistered) {
			ak.push(event);
			ak[event] = callBack;
		}
	};
	this.addOverlay = function (overlay) {
		overlay.map = self;
		ap.overlays.push(overlay);
		draw();
	};
	this.removeOverlay = function (overlay) {
		overlay.map = null;
		var tmp = new Array();
		for (var i = 0; i < ap.overlays.length; i++) {
			if (ap.overlays[i] && !ap.overlays[i].equals(overlay)) {
				tmp.push(ap.overlays[i]);
			}
		}
		ap.overlays = tmp;
		draw();
	};
	this.removeAllOverlays = function () {
		ap.overlays = [];
		draw(true);
	};
	this.removeOverlayById = function (id) {
		var tmp = new Array();
		for (var i = 0; i < ap.overlays.length; i++) {
			if (ap.overlays[i] && ap.overlays[i].id != (id)) {
				tmp.push(ap.overlays[i]);
			}
		}
		ap.overlays = tmp;
		draw();
	};
	this.setShapeRendering = function (style) {
		if (!style || !style == "client" || !style == "server") {
			alert(" map.setShapeRendering() error:\n\n use 'client' or 'server'");
		}
		if (style == "server") {
			clear();
		} else {
			draw();
		}
		by = style;
		ap.rendering = style;
	};
	this.getShapeRendering = function () {
		return by;
	};
	this.addPin = function (pin) {
		if (al == null) {
			throw new Exception("Error adding Pin, you can not add a pin until " + "the center Position is set, in the case of geocoding with " + "map.centerOnAddress(), add the pin in the callback from map.centerOnAddress()");
			return false;
		}
		if (!ao) {
			initBubble();
		}
		var gxZoom = as.getGXConvertedZoomLevel();
		var scale = Utilities.radsPerPixelAtZoom(256, gxZoom);
		var cy = Utilities.lat2pix(al.lat, scale);
		var cx = Utilities.lon2pix(al.lon, scale);
		var py = Utilities.lat2pix(pin.position.lat, scale);
		var px = Utilities.lon2pix(pin.position.lon, scale);
		var pix = new PixelPoint((ai * ad) / 2, (ai * ac) / 2);
		pin.setX(pix.x + bk - Math.round(cx - px));
		pin.setY(pix.y + bq + Math.round(cy - py));
		pin.map = self;
		af.push(pin);
		ae.appendChild(pin.pinImg);
		if (pin.pinTxt) {
			ae.appendChild(pin.pinTxt);
		}
	};
	this.addMapTypeController = function (mapTypeController) {
		if (!mapTypeController) {
			alert("error adding mapTypeController to map");
			return false;
		}
		_chooser = document.createElement("DIV");
		_chooser.id = "mapTypeController";
		_chooser.style.top = "5px";
		_chooser.style.left = ((parseInt(self.mapDiv.style.width)) - 207) + au;
		_chooser.style.backgroundColor = "#ffffff";
		_chooser.style.opacity = 50;
		mapReference = self;
		_chooser.innerHTML = "<A HREF=# onclick='mapReference.setMapType(GLOBALS.STREET); return false;'>STREET</A> | <A HREF=# onclick='mapReference.setMapType(GLOBALS.HYBRID); return false;'>HYBRID</A> | <A HREF=# onclick='mapReference.setMapType(GLOBALS.SATELLITE); return false;'>SATELLITE</A>";
		_chooser.style.filter = "alpha(opacity=80)";
		_chooser.style.opacity = 0.8;
		_chooser.style.borderWidth = "1px";
		_chooser.style.padding = "4px";
		_chooser.style.fontFamily = "Arial, sans-serif";
		_chooser.style.fontColor = "black";
		_chooser.style.fontSize = "11px";
		_chooser.style.fontWeight = "bold";
		_chooser.style.borderStyle = "solid";
		_chooser.style.borderColor = "gray";
		_chooser.style.display = "block";
		_chooser.style.position = "absolute";
		_chooser.style.zIndex = 9999;
		_chooser.onclick = function (e) {
			e = e || event;
			e.stoppropagation ? e.stoppropagation() : e.cancelBubble = true;
		};
		self.mapDiv.appendChild(_chooser);
	};
	this.addZoomController = function (zoomController) {
		as = zoomController;
		as.initialize(self);
	};
	this.authenticate = function (clientName, clientPassword) {
		if (!clientName || !clientPassword || clientName == "" || clientPassword == "") {
			throw new Exception("Error calling Map.authenticate(), bad params");
			return false;
		}
		Credentials.clientName = clientName;
		Credentials.clientPassword = clientPassword;
	};
	this.centerOnAddress = function (freeFormAddress, callBack, trafficTime) {
		populateTiles();
		var requestId = Utilities.getRequestId();
		if (callBack) {
			ag[requestId] = callBack;
		}
		ab = ap.createMapAddressRequestDOM(freeFormAddress, ai, ad, ac, requestId, as.getGXConvertedZoomLevel(), trafficTime);
		JSRequest.send(ab, centerOnAddressCallback);
	};
	this.centerOnPosition = function (position, callBack, trafficTime) {
		al = position;
		populateTiles();
		var requestId = Utilities.getRequestId();
		if (callBack && callBack != null) {
			ag[requestId] = callBack;
		}
		ab = ap.createMapRequestDOM(position, ai, ad, ac, requestId, as.getGXConvertedZoomLevel(), trafficTime);
		JSRequest.send(ab, centerOnPositionCallback);
	};
	this.changeCurrentMapStyle = function (newStyle) {
		setMapStyle(newStyle);
	};
	this.clearInstanceListeners = function () {
		for (var i = 0; i < ak.length; i++) {
			ak[ak[i]] = null;
			ak[i] = null;
		}
	};
	this.clearListeners = function (event) {
		for (var i = 0; i < ak.length; i++) {
			if (ak[i] == event) {
				ak[ak[i]] = null;
			}
		}
		ak[i] = null;
	};
	this.getBoundingBox = function () {
		var zl = as.getGXConvertedZoomLevel();
		var sl = Utilities.radsPerPixelAtZoom(256, zl);
		var cp = self.getCenterPosition();
		var cy = Utilities.lat2pix(cp.lat, sl);
		var maxY = cy + (ac * 256 / 2);
		var minY = cy - (ac * 256 / 2);
		var maxLat = Utilities.pix2lat(maxY, sl);
		var minLat = Utilities.pix2lat(minY, sl);
		var cx = Utilities.lon2pix(cp.lon, sl);
		var maxX = cx + (ad * 256 / 2);
		var minX = cx - (ad * 256 / 2);
		var maxLon = Utilities.pix2lon(maxX, sl);
		var minLon = Utilities.pix2lon(minX, sl);
		return new BoundingBox(new Position(minLat, minLon), new Position(maxLat, maxLon));
	};
	this.getGXPixelPoint = function (pos) {
		var scale = Utilities.radsPerPixelAtZoom(ai, as.getGXConvertedZoomLevel());
		var y = Utilities.lat2pix(pos.lat, scale);
		var x = Utilities.lon2pix(pos.lon, scale);
		return new PixelPointDP(x, y);
	};
	this.getGridSize = function () {
		return ac + " " + ad;
	};
	this.getBoundingBoxViewable = function () {
		var viewPctY = (parseInt(self.mapDiv.style.height) / (ai * ac));
		var viewPctX = (parseInt(self.mapDiv.style.width) / (ai * ad));
		var radX = as.getRadiusX() * viewPctX;
		var radY = as.getRadius() * viewPctY;
		return Utilities.centerContextToBoundingBoxViewable(self.getCenterPosition(), radX, radY);
	};
	this.getCenterPosition = function () {
		if (!al) {
			throw new Exception("Center Position not set");
			return null;
		}
		var tmp = al.clone();
		var gxZoom = as.getGXConvertedZoomLevel();
		var scale = Utilities.radsPerPixelAtZoom(256, gxZoom);
		var originalCenterY = Utilities.lat2pix(tmp.lat, scale);
		var originalCenterX = Utilities.lon2pix(tmp.lon, scale);
		var newCenterX = originalCenterX - bc;
		var newCenterY = originalCenterY + ba;
		var newLat = Utilities.pix2lat(newCenterY, scale);
		var newLon = Utilities.pix2lon(newCenterX, scale);
		return new Position(newLat, newLon);
	};
	this.getPins = function () {
		var tmp = new Array();
		for (var i = 0; i < af.length; i++) {
			if (af[i]) {
				tmp.push(af[i]);
			}
		}
		af = tmp;
		return af;
	};
	this.getZoomController = function () {
		return as;
	};
	this.getZoomLck = function () {
		return cl;
	};
	this.hidePins = function () {
		for (var i = 0; i < af.length; i++) {
			if (af[i] && af[i] != null && af[i].type == "pin") {
				af[i].pinImg.style.display = "none";
				af[i].pinTxt.style.display = "none";
			}
		}
	};
	this.hidePinsBeforeZoom = function () {
		for (var i = 0; i < af.length; i++) {
			if (af[i] && af[i] != null && af[i].type == "pin" && af[i].pinImg.style.display == "block") {
				af[i].zoomHide = true;
				af[i].pinImg.style.display = "none";
				af[i].pinTxt.style.display = "none";
			}
		}
	};
	this.panToPosition = function (position) {
		br = self.getGXPixelPoint(position);
		var position = position.clone();
		var scale = Utilities.radsPerPixelAtZoom(256, as.getGXConvertedZoomLevel());
		var tmp = self.getCenterPosition();
		var bbox = Utilities.centerContextToBoundingBox(tmp, as.getRadius());
		var cy = Utilities.lat2pix(tmp.lat, scale);
		var cx = Utilities.lon2pix(tmp.lon, scale);
		var cy2 = Utilities.lat2pix(position.lat, scale);
		var cx2 = Utilities.lon2pix(position.lon, scale);
		var pix = new PixelPoint(Math.round(cx - cx2), Math.round(cy - cy2));
		if (bbox.extendedContains(position)) {
			slider(pix.x, -1 * pix.y);
		} else {
			this.centerOnPosition(position);
		}
	};
	this.panWest = function () {
		slider(GLOBALS.PAN_PIXEL_DISTANCE, 0);
	};
	this.panEast = function () {
		slider(-GLOBALS.PAN_PIXEL_DISTANCE, 0);
	};
	this.panNorth = function () {
		slider(0, GLOBALS.PAN_PIXEL_DISTANCE);
	};
	this.panSouth = function () {
		slider(0, -GLOBALS.PAN_PIXEL_DISTANCE);
	};
	this.panSouthEast = function () {
		slider(-GLOBALS.PAN_PIXEL_DISTANCE, -GLOBALS.PAN_PIXEL_DISTANCE);
	};
	this.panNorthEast = function () {
		slider(-GLOBALS.PAN_PIXEL_DISTANCE, GLOBALS.PAN_PIXEL_DISTANCE);
	};
	this.panSouthWest = function () {
		slider(GLOBALS.PAN_PIXEL_DISTANCE, -GLOBALS.PAN_PIXEL_DISTANCE);
	};
	this.panNorthWest = function () {
		slider(GLOBALS.PAN_PIXEL_DISTANCE, GLOBALS.PAN_PIXEL_DISTANCE);
	};
	this.removeAllPins = function () {
		for (var i = 0; i < af.length; i++) {
			try {
				if (af[i] && af[i] != null) {
					Utilities.purge(af[i].pinImg);
					ae.removeChild(af[i].pinImg);
					af[i].pinImg = null;
					if (af[i].pinTxt) {
						Utilities.purge(af[i].pinTxt);
						ae.removeChild(af[i].pinTxt);
						af[i].pinTxt = null;
					}
				}
				af[i] = null;
			}
			catch (e) {
				throw new Exception("error removing all pins\n\n" + e.message);
			}
		}
		af = new Array();
	};
	this.removePin = function (pin) {
		for (var i = 0; i < af.length; i++) {
			if (af[i] && af[i].equals(pin)) {
				af[i] = null;
			}
		}
		if (pin.pinTxt) {
			Utilities.purge(pin.pinTxt);
			ae.removeChild(pin.pinTxt);
			pin.pinTxt = null;
		}
		Utilities.purge(pin.pinImg);
		ae.removeChild(pin.pinImg);
		pin = null;
	};
	this.removePinsById = function (id) {
		var pins = map.getPins();
		for (var i = 0; i < pins.length; i++) {
			if (pins[i].id == id) {
				this.removePin(pins[i]);
			}
		}
	};
	this.resize = function (height, width) {
		self.mapDiv.style.height = parseInt(height) + au;
		self.mapDiv.style.width = parseInt(width) + au;
		cd = true;
		if (ae) {
			self.reDrawMap();
		}
	};
	this.routeMap = function (posList, callBack, expectedStartTime) {
		requestId = Utilities.getRequestId();
		ag[requestId] = callBack;
		az = ap.createRouteGeometryRequestDOM(posList, requestId, self.routePreference, expectedStartTime);
		var xml = Sarissa.serialize(az);
		JSRequest.send(az, routeGeoCallback);
	};
	this.setConfiguration = function (configuration) {
		if (!configuration) {
			alert("error calling Map.setConfiguration()");
			return false;
		}
		Credentials.configuration = configuration;
	};
	this.setDragEnabled = function (enabled) {
		if (!"boolean" == (typeof enabled)) {
			throw new Exception("Map.setDragEnabled requires boolean");
		}
		bz = enabled;
	};
	this.setDoubleClickRecenteringEnabled = function (enabled) {
		if (!"boolean" == (typeof enabled)) {
			throw new Exception("Map.setDoubleClickRecenteringEnabled requires boolean");
		}
		bh = enabled;
	};
	this.setDoubleClickRecenterAndZoom = function (enabled) {
		if (!"boolean" == (typeof enabled)) {
			alert("Map.setDoubleClickRecenterAndZoom requires boolean");
		}
		cq = enabled;
	};
	this.setTransparentConfiguration = function (transparentConfiguration) {
		if (!transparentConfiguration) {
			alert("error calling Map.setTransparentConfiguration()");
			return false;
		}
		Credentials.transparentConfiguration = transparentConfiguration;
	};
	this.setCountryCode = function (ISOCountryCode) {
		if (!ISOCountryCode) {
			alert("error calling Map.setCountryCode()");
			return false;
		}
		Credentials.ISOCountryCode = ISOCountryCode;
	};
	this.setMapStyle = function (newStyle) {
		Credentials.configuration = newStyle;
		if (ab != null) {
			var tmp = ab.selectSingleNode("//xls:RequestHeader");
			tmp.setAttribute("configuration", newStyle);
			for (var y = 0; y < ac; ++y) {
				for (var x = 0; x < ad; ++x) {
					aa[y][x][1].src = am;
					changeURLConf(aa[y][x][1], newStyle);
					aa[y][x][1].loader.src = aa[y][x][1].altSrc;
				}
			}
		}
	};
	function changeURLConf(img, newStyle) {
		var tmp = img.altSrc;
		if (tmp.indexOf("?CONFIG=") > 0) {
			var tmp2 = tmp.substring(tmp.indexOf("?"), (tmp.indexOf("&") + 1));
			img.altSrc = (tmp).replace(tmp2, "?CONFIG=" + newStyle + "&");
		} else {
			img.altSrc = (tmp).replace("?", "?CONFIG=" + newStyle + "&");
		}
		var tmp2 = img.altSrc;
		if (an == "STREET") {
			img.altSrc = (tmp2).replace("FORMAT=PNG", "FORMAT=GIF");
		} else {
			img.altSrc = (tmp2).replace("FORMAT=GIF", "FORMAT=PNG");
		}
		img.src = img.altSrc;
	}
	this.setMapType = function (mapType) {
		if (!(mapType == "STREET" || mapType == "HYBRID" || mapType == "SATELLITE")) {
			alert("unsupported mapType\n\nUse 'STREET' || 'HYBRID' || 'SATELLITE'");
			return false;
		}
		an = mapType;
		Credentials.mapType = an;
		if (aa.length > 0) {
			if (mapType == "STREET") {
				for (var y = 0; y < ac; ++y) {
					for (var x = 0; x < ad; ++x) {
						aa[y][x][0].src = am;
						aa[y][x][1].src = am;
						changeURLConf(aa[y][x][1], Credentials.configuration);
						aa[y][x][1].loader.src = aa[y][x][1].altSrc;
					}
				}
			} else {
				if (mapType == "HYBRID") {
					for (var y = 0; y < ac; ++y) {
						for (var x = 0; x < ad; ++x) {
							aa[y][x][0].src = am;
							aa[y][x][1].src = am;
							aa[y][x][0].src = aa[y][x][0].altSrc;
							changeURLConf(aa[y][x][1], Credentials.transparentConfiguration);
							aa[y][x][1].loader.src = aa[y][x][1].altSrc;
						}
					}
				} else {
					if (mapType == "SATELLITE") {
						for (var y = 0; y < ac; ++y) {
							for (var x = 0; x < ad; ++x) {
								aa[y][x][1].loader.src = am;
								aa[y][x][0].src = am;
								aa[y][x][0].src = aa[y][x][0].altSrc;
								aa[y][x][1].src = am;
							}
						}
					}
				}
			}
		}
	};
	this.setRoutePreference = function (preference) {
		self.routePreference = preference;
	};
	this.setTileBorder = function (border) {
		if (border) {
			bv = 1;
		} else {
			bv = 0;
		}
		for (var y = 0; y < ac; ++y) {
			for (var x = 0; x < ad; ++x) {
				aa[y][x][0].border = bv;
				aa[y][x][1].border = bv;
			}
		}
	};
	this.setTileBuffer = function (buffer) {
		if (buffer) {
			bu = 2;
		} else {
			bu = 1;
		}
	};
	this.setURL = function (url) {
		Credentials.url = url;
	};
	this.showPins = function () {
		for (var i = 0; i < af.length; i++) {
			if (af[i] && af[i] != null && af[i].type == "pin") {
				af[i].pinImg.style.display = "block";
				af[i].pinTxt.style.display = "block";
			}
		}
	};
	this.showPinsAfterZoom = function () {
		for (var i = 0; i < af.length; i++) {
			if (af[i] && af[i] != null && af[i].type == "pin" && af[i].zoomHide) {
				af[i].pinImg.style.display = "block";
				af[i].pinTxt.style.display = "block";
				af[i].zoomHide = false;
			}
		}
	};
	this.zoomMap = function (newZoomLevel) {
		if (ab == null) {
			alert("Map not yet initialized.\nMap must be initialized before zooming.");
			return false;
		}
		if (cl) {
			return false;
		}
		cl = true;
		var oldZoomLevel = as.getGXConvertedZoomLevel();
		as.setZoomLevel(newZoomLevel);
		var newZoomLevel = as.getGXConvertedZoomLevel();
		if (bi && br && bi.x && br.x && bi.y && br.y) {
			var XXX = bi.x - br.x;
			var YYY = bi.y - br.y;
			var factionalNorth = parseFloat((YYY / 256)) * -1;
			var factionalEast = parseFloat((XXX / 256)) * -1;
			ab = ap.zoomMapRequestDOM(ab, factionalNorth, 0, factionalEast, 0, newZoomLevel, oldZoomLevel);
		} else {
			var factionalNorth = parseFloat(dg + (bd / ai));
			var factionalEast = parseFloat(dk - (be / ai));
			ab = ap.zoomMapRequestDOM(ab, factionalNorth, df, factionalEast, dj, newZoomLevel, oldZoomLevel);
		}
		bi = 0;
		br = 0;
		populateTiles();
		JSRequest.send(ab, zoomMapCallback);
	};
	this.clearRoute = function () {
		if (ab == null) {
			return false;
		}
		var pm = ab.selectSingleNode("//xls:PortrayMapRequest");
		pm.removeChild(pm.selectSingleNode("//xls:Overlay"));
	};
	this.reDrawMap = function () {
		if (ab == null) {
			return false;
		}
		var pos = ab.selectSingleNode("//gml:pos");
		for (var i = 0; i < pos.childNodes.length; i++) {
			pos.removeChild(pos.childNodes[i]);
		}
		var posTxt = ab.createTextNode(self.getCenterPosition().toString());
		pos.appendChild(posTxt);
		populateTiles();
		var tg = ab.selectSingleNode("//xls:TileGrid");
		tg.setAttribute("rows", ac);
		tg.setAttribute("columns", ad);
		JSRequest.send(ab, redrawMapCallback);
	};
	function redrawMapCallback(data) {
		var oDomDoc = Sarissa.getDomDocument();
		oDomDoc = (new DOMParser()).parseFromString(Utilities.normalizePrefixes(data), "text/xml");
		oDomDoc.setProperty("SelectionLanguage", "XPath");
		oDomDoc.setProperty("SelectionNamespaces", "xmlns:xls='http://www.opengis.net/xls' xmlns:gml='http://www.opengis.net/gml'");
		if (oDomDoc.selectNodes("//xls:Error").length > 0) {
			alert("Error Message:\n\n\n" + (oDomDoc.selectNodes("//@message"))[0].value);
			return false;
		}
		var panN = oDomDoc.selectSingleNode("//xls:Pan[@direction='N']");
		var panE = oDomDoc.selectSingleNode("//xls:Pan[@direction='E']");
		av = new Array(parseFloat(panE.getAttribute("numTiles")) * ai, parseFloat(panN.getAttribute("numTiles")) * ai);
		var urlList = oDomDoc.selectNodes("//xls:URL");
		updateUrlList(urlList);
		var tmpRadius = oDomDoc.selectSingleNode("//xls:Radius");
		as.setRadius((parseFloat(Sarissa.getText(tmpRadius)) / 1000));
		al = new Position(Sarissa.getText(oDomDoc.selectSingleNode("//gml:pos")));
		realignPushPins();
		bi = self.getGXPixelPoint(al);
		try {
			var centerContext = oDomDoc.selectSingleNode("//xls:CenterContext");
			ab = (new DOMParser()).parseFromString(Sarissa.serialize(ab), "text/xml");
			ab.setProperty("SelectionLanguage", "XPath");
			ab.setProperty("SelectionNamespaces", "xmlns:xls='http://www.opengis.net/xls' xmlns:gml='http://www.opengis.net/gml'");
			var centerContext2 = ab.selectSingleNode("//xls:CenterContext");
			var output = ab.selectSingleNode("//xls:Output");
			output.removeChild(centerContext2);
			var tileGrid = ab.selectSingleNode("//xls:TileGrid");
			var cloneNode = centerContext.cloneNode(true);
			output.insertBefore(cloneNode, tileGrid);
		}
		catch (e) {
			alert("sendMapRequest updating CenterContext from response \n\n\n" + e.message);
		}
		var height = parseInt(mapContainer.style.height);
		var width = parseInt(mapContainer.style.width);
		var diffHeight = cr - height;
		var diffWidth = db - width;
		if (document.getElementById("copyright")) {
			document.getElementById("copyright").style.top = parseInt(document.getElementById("copyright").style.top) - diffHeight;
		}
		if (document.getElementById("mapTypeController")) {
			document.getElementById("mapTypeController").style.left = parseInt(document.getElementById("mapTypeController").style.left) - diffWidth;
		}
		cr = height;
		db = width;
	}
	function routeGeoCallback(data) {
		var oDomDoc = (new DOMParser()).parseFromString(Utilities.normalizePrefixes(data), "text/xml");
		oDomDoc.setProperty("SelectionLanguage", "XPath");
		oDomDoc.setProperty("SelectionNamespaces", "xmlns:xls='http://www.opengis.net/xls' xmlns:gml='http://www.opengis.net/gml'");
		if (oDomDoc.selectNodes("//xls:Error").length > 0) {
			var reqId = Sarissa.getText(oDomDoc.selectSingleNode("//xls:Response/@requestID"));
			if (ag[reqId]) {
				ag[reqId](null);
				ag[reqId] = null;
				return;
			} else {
				return;
			}
		}
		populateTiles();
		var routeID = oDomDoc.selectSingleNode("//xls:RouteID");
		var minPos = (oDomDoc.selectNodes("//xls:RouteSummary/xls:BoundingBox/gml:pos/text()"))[0].data;
		var maxPos = (oDomDoc.selectNodes("//xls:RouteSummary/xls:BoundingBox/gml:pos/text()"))[1].data;
		var bbox = new BoundingBox(new Position(minPos), new Position(maxPos));
		var routeMapRadius = bbox.getRadius();
		as.setRadius(routeMapRadius);
		al = bbox.getCenterPosition();
		var fit = as.getZoomLevelToFitBoundingBox(bbox);
		as.setZoomLevel(fit);
		var centerContext = ap.createCenterContext(bbox.getCenterPosition(), as.getRadius());
		var trafficTime;
		if (trafficTime) {
			ab = ap.createRouteMapDOM(centerContext, routeID, Utilities.getRequestId(), ai, ad, ac, as.getGXConvertedZoomLevel(), self.routePreference, trafficTime);
		} else {
			ab = ap.createRouteMapDOM(centerContext, routeID, Utilities.getRequestId(), ai, ad, ac, as.getGXConvertedZoomLevel(), self.routePreference);
		}
		var route = Utilities.parseRoute(oDomDoc);
		var reqId = Sarissa.getText(oDomDoc.selectSingleNode("//xls:Response/@requestID"));
		if (ag[reqId]) {
			ag[reqId](route);
			ag[reqId] = null;
		}
		JSRequest.send(ab, centerOnPositionCallback);
	}
	function routeMapCallback(data) {
		var oDomDoc = Sarissa.getDomDocument();
		oDomDoc = (new DOMParser()).parseFromString(Utilities.normalizePrefixes(data), "text/xml");
		oDomDoc.setProperty("SelectionLanguage", "XPath");
		oDomDoc.setProperty("SelectionNamespaces", "xmlns:xls='http://www.opengis.net/xls' xmlns:gml='http://www.opengis.net/gml'");
		if (oDomDoc.selectNodes("//xls:Error").length > 0) {
			alert("Error Message:\n\n\n" + (oDomDoc.selectNodes("//@message"))[0].value);
			return false;
		}
		var panN = oDomDoc.selectSingleNode("//xls:Pan[@direction='N']");
		var panE = oDomDoc.selectSingleNode("//xls:Pan[@direction='E']");
		av = new Array(parseFloat(panE.getAttribute("numTiles")) * ai, parseFloat(panN.getAttribute("numTiles")) * ai);
		urlList = oDomDoc.selectNodes("//xls:URL");
		updateUrlList(urlList);
		var tmpRadius = oDomDoc.selectSingleNode("//xls:Radius");
		as.setRadius((parseFloat(Sarissa.getText(tmpRadius)) / 1000));
		realignPushPins();
	}
	function centerOnAddressCallback(data) {
		var oDomDoc = Sarissa.getDomDocument();
		oDomDoc = (new DOMParser()).parseFromString(Utilities.normalizePrefixes(data), "text/xml");
		oDomDoc.setProperty("SelectionLanguage", "XPath");
		oDomDoc.setProperty("SelectionNamespaces", "xmlns:xls='http://www.opengis.net/xls' xmlns:gml='http://www.opengis.net/gml'");
		if (oDomDoc.selectNodes("//xls:Error").length > 0) {
			alert("Error Message:\n\n\n" + (oDomDoc.selectNodes("//@message"))[0].value);
			return false;
		}
		var panN = oDomDoc.selectSingleNode("//xls:Pan[@direction='N']");
		var panE = oDomDoc.selectSingleNode("//xls:Pan[@direction='E']");
		av = new Array(parseFloat(panE.getAttribute("numTiles")) * ai, parseFloat(panN.getAttribute("numTiles")) * ai);
		urlList = oDomDoc.selectNodes("//xls:URL");
		updateUrlList(urlList);
		try {
			var tmpRadius = oDomDoc.selectSingleNode("//xls:Radius");
			as.setRadius((parseFloat(Sarissa.getText(tmpRadius)) / 1000));
			al = new Position(Sarissa.getText(oDomDoc.selectSingleNode("//gml:pos")));
			bi = self.getGXPixelPoint(al);
			var ffaTemp = Sarissa.getText(oDomDoc.selectSingleNode("//xls:freeFormAddress"));
			if (ffaTemp == "") {
				ffaTemp = "NO ADDRESS FOUND";
			}
			var freeFormAddress = new FreeFormAddress(ffaTemp);
			realignPushPins();
			var reqId = Sarissa.getText(oDomDoc.selectSingleNode("//xls:Response/@requestID"));
			if (ag[reqId]) {
				ag[reqId](freeFormAddress, al);
				ag[reqId] = null;
			}
			var centerContext = oDomDoc.selectSingleNode("//xls:CenterContext");
			ab = (new DOMParser()).parseFromString(Sarissa.serialize(ab), "text/xml");
			ab.setProperty("SelectionLanguage", "XPath");
			ab.setProperty("SelectionNamespaces", "xmlns:xls='http://www.opengis.net/xls' xmlns:gml='http://www.opengis.net/gml'");
			var centerAddress = ab.selectSingleNode("//xls:CenterAddress");
			var output = ab.selectSingleNode("//xls:Output");
			output.removeChild(centerAddress);
			var tileGrid = ab.selectSingleNode("//xls:TileGrid");
			var cloneNode = centerContext.cloneNode(true);
			output.insertBefore(cloneNode, tileGrid);
		}
		catch (e) {
			alert("Error updating the request center context from the response for subsequent requests.\n\n" + e.name + "\n\n" + e.message);
		}
	}
	function centerOnPositionCallback(data) {
		var oDomDoc = Sarissa.getDomDocument();
		oDomDoc = (new DOMParser()).parseFromString(Utilities.normalizePrefixes(data), "text/xml");
		oDomDoc.setProperty("SelectionLanguage", "XPath");
		oDomDoc.setProperty("SelectionNamespaces", "xmlns:xls='http://www.opengis.net/xls' xmlns:gml='http://www.opengis.net/gml'");
		if (oDomDoc.selectNodes("//xls:Error").length > 0) {
			alert("Error Message:\n\n\n" + (oDomDoc.selectNodes("//@message"))[0].value);
			return false;
		}
		var panN = oDomDoc.selectSingleNode("//xls:Pan[@direction='N']");
		var panE = oDomDoc.selectSingleNode("//xls:Pan[@direction='E']");
		av = new Array(parseFloat(panE.getAttribute("numTiles")) * ai, parseFloat(panN.getAttribute("numTiles")) * ai);
		var urlList = oDomDoc.selectNodes("//xls:URL");
		updateUrlList(urlList);
		var tmpRadius = oDomDoc.selectSingleNode("//xls:Radius");
		as.setRadius((parseFloat(Sarissa.getText(tmpRadius)) / 1000));
		realignPushPins();
		var reqId = Sarissa.getText(oDomDoc.selectSingleNode("//xls:Response/@requestID"));
		if (ag[reqId] && ag[reqId] != null) {
			ag[reqId](al);
			ag[reqId] = null;
		}
		bi = self.getGXPixelPoint(al);
		try {
			var centerContext = oDomDoc.selectSingleNode("//xls:CenterContext");
			ab = (new DOMParser()).parseFromString(Sarissa.serialize(ab), "text/xml");
			ab.setProperty("SelectionLanguage", "XPath");
			ab.setProperty("SelectionNamespaces", "xmlns:xls='http://www.opengis.net/xls' xmlns:gml='http://www.opengis.net/gml'");
			var centerContext2 = ab.selectSingleNode("//xls:CenterContext");
			var output = ab.selectSingleNode("//xls:Output");
			output.removeChild(centerContext2);
			var tileGrid = ab.selectSingleNode("//xls:TileGrid");
			var cloneNode = centerContext.cloneNode(true);
			output.insertBefore(cloneNode, tileGrid);
		}
		catch (e) {
			alert("sendMapRequest updating CenterContext from response \n\n\n" + e.message);
		}
	}
	function zoomMapCallback(data) {
		var oDomDoc = Sarissa.getDomDocument();
		oDomDoc = (new DOMParser()).parseFromString(Utilities.normalizePrefixes(data), "text/xml");
		oDomDoc.setProperty("SelectionLanguage", "XPath");
		oDomDoc.setProperty("SelectionNamespaces", "xmlns:xls='http://www.opengis.net/xls' xmlns:gml='http://www.opengis.net/gml'");
		al = new Position(oDomDoc.selectSingleNode("//gml:pos/text()").data);
		bi = self.getGXPixelPoint(al);
		var panN = oDomDoc.selectSingleNode("//xls:Pan[@direction='N']");
		var panE = oDomDoc.selectSingleNode("//xls:Pan[@direction='E']");
		av = new Array(parseFloat(panE.getAttribute("numTiles")) * ai, parseFloat(panN.getAttribute("numTiles")) * ai);
		var urlList = oDomDoc.selectNodes("//xls:URL");
		updateUrlList(urlList);
		try {
			ab = (new DOMParser()).parseFromString(Sarissa.serialize(ab), "text/xml");
			ab.setProperty("SelectionLanguage", "XPath");
			ab.setProperty("SelectionNamespaces", "xmlns:xls='http://www.opengis.net/xls' xmlns:gml='http://www.opengis.net/gml'");
			var newCenterContext = oDomDoc.selectSingleNode("//xls:CenterContext");
			var oldCenterContext = ab.selectSingleNode("//xls:CenterContext");
			var output = ab.selectSingleNode("//xls:Output");
			output.removeChild(oldCenterContext);
			var tileGrid = ab.selectSingleNode("//xls:TileGrid");
			var cloneNode = newCenterContext.cloneNode(true);
			output.insertBefore(cloneNode, tileGrid);
			if ((ab.selectSingleNode("//xls:Radius/@unit").value) == "M") {
				as.setRadius((parseFloat(oDomDoc.selectSingleNode("//xls:Radius/text()").data) / 1000));
			} else {
				as.setRadius((parseFloat(oDomDoc.selectSingleNode("//xls:Radius/text()").data)));
			}
			cl = false;
			realignPushPins();
			if (ak["zoomend"]) {
				ak["zoomend"]();
			}
		}
		catch (e) {
			alert("Map.sendZoomRequest\n\n" + e.message);
		}
	}
	function updateUrlList(urlList) {
		var imgCount = ad * ac;
		for (var i = 0; i < imgCount; i++) {
			try {
				di[i] = new URL(Sarissa.getText(urlList[i + imgCount]), Sarissa.getText(urlList[i]));
			}
			catch (e) {
				alert("error making URL array\n\n" + e.message);
			}
		}
		var urlcount = 0;
		var tmpArrayOfURLs = new Array(ac);
		for (var i = 0; i < ac; ++i) {
			tmpArrayOfURLs[i] = new Array(ad);
		}
		for (var y = 0; y < ac; ++y) {
			for (var x = 0; x < ad; ++x) {
				tmpArrayOfURLs[y][x] = di[urlcount];
				urlcount++;
			}
		}
		for (var y = 0; y < ac; ++y) {
			for (var x = 0; x < ad; ++x) {
				updateURL(x, y, tmpArrayOfURLs[y][x]);
			}
		}
		draw();
		return;
		for (var y = 1; y < ac - 1; ++y) {
			for (var x = 1; x < ad - 1; ++x) {
				updateURL(x, y, tmpArrayOfURLs[y][x]);
			}
		}
		for (var y = 0; y < ac; ++y) {
			updateURL(0, y, tmpArrayOfURLs[y][0]);
		}
		for (var y = 0; y < ac; ++y) {
			updateURL(ac - 1, y, tmpArrayOfURLs[y][ac - 1]);
		}
		for (var y = 1; y < ac - 1; ++y) {
			updateURL(y, ac - 1, tmpArrayOfURLs[ac - 1][y]);
		}
		for (var y = 1; y < ac - 1; ++y) {
			updateURL(y, 0, tmpArrayOfURLs[0][y]);
		}
	}
	function imgError(event) {
		var tile;
		if (document.all) {
			tile = window.event.srcElement;
		} else {
			tile = event.currentTarget;
		}
		tile.src = Credentials.errorTile;
	}
	function updateURL(x, y, url) {
		if (an == "SATELLITE") {
			aa[y][x][0].style.zIndex = 50;
			aa[y][x][1].style.zIndex = 100;
			aa[y][x][0].style.top = parseInt(aa[y][x][1].style.top) + av[1] + au;
			aa[y][x][0].style.left = parseInt(aa[y][x][1].style.left) - av[0] + au;
			aa[y][x][0].src = url.getGlobeExplorerURL();
			aa[y][x][0].altSrc = url.getGlobeExplorerURL();
			if (Utilities.ie6) {
				aa[y][x][1].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='img/tile.png')";
			}
			aa[y][x][1].altSrc = url.getDeCartaURL();
		} else {
			if (an == "STREET") {
				aa[y][x][0].style.zIndex = 50;
				aa[y][x][1].style.zIndex = 100;
				aa[y][x][0].style.top = parseInt(aa[y][x][1].style.top) + av[1] + au;
				aa[y][x][0].style.left = parseInt(aa[y][x][1].style.left) - av[0] + au;
				aa[y][x][0].altSrc = url.getGlobeExplorerURL();
				aa[y][x][1].src = url.getDeCartaURL();
				aa[y][x][1].altSrc = url.getDeCartaURL();
			} else {
				if (an == "HYBRID") {
					aa[y][x][0].style.zIndex = 1;
					aa[y][x][0].style.top = parseInt(aa[y][x][1].style.top) + av[1] + au;
					aa[y][x][0].style.left = parseInt(aa[y][x][1].style.left) - av[0] + au;
					aa[y][x][0].src = url.getGlobeExplorerURL();
					aa[y][x][0].altSrc = url.getGlobeExplorerURL();
					aa[y][x][1].zIndex = 10;
					aa[y][x][1].altSrc = url.getDeCartaURL();
					aa[y][x][1].loader.src = aa[y][x][1].altSrc;
				}
			}
		}
	}
	function realignPushPins() {
		var scale = Utilities.radsPerPixelAtZoom(256, as.getGXConvertedZoomLevel());
		for (var i = 0; i < af.length; i++) {
			if (af[i] && af[i] != null) {
				var cy = Utilities.lat2pix(al.lat, scale);
				var cx = Utilities.lon2pix(al.lon, scale);
				var py = Utilities.lat2pix(af[i].position.lat, scale);
				var px = Utilities.lon2pix(af[i].position.lon, scale);
				var pix = new PixelPoint((ai * ad) / 2, (ai * ac) / 2);
				af[i].setX(pix.x + bk - Math.round(cx - px));
				af[i].setY(pix.y + bq + Math.round(cy - py));
				ae.appendChild(af[i].pinImg);
				af[i].hideInfoWindow();
				if (af[i].pinTxt) {
					ae.appendChild(af[i].pinTxt);
				}
			}
		}
		self.showPinsAfterZoom();
	}
	function initBubble() {
		try {
			ao = document.createElement("div");
			ao.type = "default";
			_bubbleClose = document.createElement("img");
			_bubbleClose.src = "img/close.png";
			_bubbleClose.id = "close";
			_bubbleClose.style.zIndex = 1002;
			_bubbleClose.style.position = "absolute";
			_bubbleClose.style.width = "20px";
			_bubbleClose.style.height = "20px";
			_bubbleClose.style.top = "2px";
			_bubbleClose.style.left = "178px";
			_bubbleClose.style.display = "block";
			_bubbleClose.style.cursor = "pointer";
			_bubbleClose.onclick = function (e) {
				e = e || event;
				e.stoppropagation ? e.stoppropagation() : e.cancelBubble = true;
				document.getElementById("bubble").style.display = "none";
			};
			_bubbleContent = document.createElement("div");
			_bubbleContent.style.padding = "16px";
			_bubbleContent.style.zIndex = 10001;
			_bubbleContent.id = "bubbleContent";
			ao.id = "bubble";
			ao.style.display = "none";
			ao.style.width = "200px";
			ao.style.backgroundColor = "#ffffff";
			ao.style.opacity = 50;
			ao.style.filter = "alpha(opacity=90)";
			ao.style.opacity = 0.9;
			ao.style.borderWidth = 1;
			ao.style.borderStyle = "solid";
			ao.style.position = "absolute";
			ao.style.zIndex = 1111;
			ao.style.display = "none";
			ao.style.fontColor = "#000000";
			ao.style.fontSize = "11px";
			ao.appendChild(_bubbleClose);
			ao.appendChild(_bubbleContent);
			if (ae != null) {
				ae.appendChild(ao);
			}
		}
		catch (e) {
			alert("Map.initBubble\n\n" + e.message);
		}
	}
	function devnull() {
		return false;
	}
	function populateTiles() {
		if (ae) {
			reset();
			if (!cd) {
				return;
			} else {
				cd = false;
			}
		}
		var mapPaneDiv = self.mapDiv;
		var mapDivHeight = parseInt(mapPaneDiv.style.height);
		var mapDivWidth = parseInt(mapPaneDiv.style.width);
		var greaterSide = mapDivHeight > mapDivWidth ? mapDivHeight : mapDivWidth;
		var yEven = true;
		var xEven = true;
		ac = Math.ceil(mapDivHeight / ai) + bu;
		if (ac % 2 != 0) {
			yEven = false;
		}
		ad = Math.ceil(mapDivWidth / ai) + bu;
		if (ad % 2 != 0) {
			xEven = false;
		}
		if (yEven != xEven) {
			ad++;
		}
		if (!as) {
			as = new ZoomController();
			self.addZoomController(as);
			as.hide();
		}
		mapPaneDiv.style.overflow = "hidden";
		mapPaneDiv.style.position = "relative";
		mapPaneDiv.style.zIndex = 0;
		mapPaneDiv.oncontextmenu = devnull;
		mapPaneDiv.onmousedown = startDrag;
		window.onmouseup = endDrag;
		mapPaneDiv.onmouseup = capture;
		mapPaneDiv.ondblclick = capture;
		mapPaneDiv.onclick = capture;
		mapPaneDiv.unselectable = "on";
		for (var i = mapPaneDiv.childNodes.length - 1; i >= 0; i--) {
			if (mapPaneDiv.childNodes.item(i).id != "copyright" && mapPaneDiv.childNodes.item(i).id != "zoom" && mapPaneDiv.childNodes.item(i).id != "mapTypeController") {
				mapPaneDiv.removeChild(mapPaneDiv.childNodes.item(i));
			}
		}
		ae = document.createElement("div");
		ae.id = "tiles";
		ae.style.position = "absolute";
		ae.style.left = 0 + au;
		ae.style.top = 0 + au;
		ae.style.zIndex = 0;
		mapPaneDiv.appendChild(ae);
		da = Utilities.getAbsoluteTop(ae) + (parseInt(mapPaneDiv.style.height) / 2);
		cs = Utilities.getAbsoluteLeft(ae) + (parseInt(mapPaneDiv.style.width) / 2);
		if (!ao) {
			initBubble();
		}
		ao.style.display = "none";
		ae.appendChild(ao);
		cz = (ad * ai) / 2;
		cw = (ac * ai) / 2;
		bk = -((ad * ai) - mapDivWidth) / 2;
		bq = -((ac * ai) - mapDivHeight) / 2;
		var tmpX = bk;
		var tmpY = bq;
		aa = new Array(ac);
		for (var i = 0; i < ac; ++i) {
			aa[i] = new Array(ad);
		}
		for (var y = 0; y < ac; ++y) {
			for (var x = 0; x < ad; ++x) {
				if (x == 0) {
					tmpX = bk;
				}
				var layerArray = new Array();
				aa[y][x] = layerArray;
				var img = document.createElement("IMG");
				img.style.position = "absolute";
				img.style.visibility = "visible";
				img.id = "SATTILE";
				img.onerror = imgError;
				img.style.zIndex = 0;
				img.unselectable = "on";
				img.style.width = ai + au;
				img.style.height = ai + au;
				img.style.left = tmpX + au;
				img.style.top = tmpY + au;
				img.src = "img/tile.png";
				ae.appendChild(img);
				var imgMap = createImage(tmpX, tmpY);
				ae.appendChild(imgMap);
				layerArray[0] = img;
				layerArray[1] = imgMap;
				tmpX += ai;
			}
			tmpY += ai;
		}
	}
	function createImage(tmpX, tmpY) {
		var imgMap = document.createElement("IMG");
		imgMap.style.position = "absolute";
		imgMap.style.height = "256px";
		imgMap.style.width = "256px";
		imgMap.unselectable = "on";
		imgMap.style.visibility = "visible";
		imgMap.id = "MAPTILE";
		imgMap.style.zIndex = 30;
		imgMap.style.left = tmpX + au;
		imgMap.style.top = tmpY + au;
		imgMap.src = "img/x.gif";
		imgMap.loader = document.createElement("img");
		imgMap.loader.style.visibility = "hidden";
		imgMap.loader.onload = function () {
			if (!imgMap.cleared) {
				if (Utilities.ie6) {
					imgMap.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.src + "')";
					imgMap.src = "img/x.gif";
				} else {
					imgMap.src = this.src;
				}
			}
		};
		return imgMap;
	}
	function rotateTiles() {
		var tmp = 0;
		var tmp1 = 0;
		if (be < -aw) {
			dk++;
			for (var i = 0; i < ac; ++i) {
				tmp = parseInt(aa[i][ah][1].style.left) + (ad * ai);
				aa[i][ah][1].style.left = (tmp) + au;
				var tmpUrl = updateUrlEast(aa[i][ah][1].altSrc);
				aa[i][ah][1].altSrc = tmpUrl;
				tmp1 = parseInt(aa[i][ah][0].style.left) + (ad * ai);
				aa[i][ah][0].style.left = (tmp1) + au;
				var tmpUrl1 = updateUrlEast(aa[i][ah][0].altSrc);
				aa[i][ah][0].altSrc = tmpUrl1;
				if (an == "HYBRID") {
					aa[i][ah][1].src = am;
					aa[i][ah][0].src = am;
					aa[i][ah][1].loader.src = aa[i][ah][1].altSrc;
					aa[i][ah][0].src = aa[i][ah][0].altSrc;
				} else {
					if (an == "SATELLITE") {
						aa[i][ah][0].src = am;
						aa[i][ah][0].src = aa[i][ah][0].altSrc;
					} else {
						if (an == "STREET") {
							aa[i][ah][1].src = am;
							aa[i][ah][1].src = aa[i][ah][1].altSrc;
						}
					}
				}
			}
			ah = (ah + 1) % ad;
			be = be + aw;
			draw();
		} else {
			if (be >= aw) {
				dj++;
				ah = (ah == 0) ? ah = (ad - 1) : --ah;
				for (var i = 0; i < ac; ++i) {
					tmp = parseInt(aa[i][ah][0].style.left) - (ad * ai);
					aa[i][ah][0].style.left = (tmp) + au;
					var tmpUrl = updateUrlWest(aa[i][ah][0].altSrc);
					aa[i][ah][0].altSrc = tmpUrl;
					tmp1 = parseInt(aa[i][ah][1].style.left) - (ad * ai);
					aa[i][ah][1].style.left = (tmp1) + au;
					var tmpUrl1 = updateUrlWest(aa[i][ah][1].altSrc);
					aa[i][ah][1].altSrc = tmpUrl1;
					if (an == "HYBRID") {
						aa[i][ah][1].src = am;
						aa[i][ah][0].src = am;
						aa[i][ah][1].loader.src = aa[i][ah][1].altSrc;
						aa[i][ah][0].src = aa[i][ah][0].altSrc;
					} else {
						if (an == "SATELLITE") {
							aa[i][ah][0].src = am;
							aa[i][ah][0].src = aa[i][ah][0].altSrc;
						} else {
							if (an == "STREET") {
								aa[i][ah][1].src = am;
								aa[i][ah][1].src = aa[i][ah][1].altSrc;
							}
						}
					}
				}
				be = be - aw;
				draw();
			} else {
				if (bd < -aw) {
					df++;
					for (var i = 0; i < ad; ++i) {
						tmp = parseInt(aa[aj][i][0].style.top) + (ac * ai);
						aa[aj][i][0].style.top = (tmp) + au;
						var tmpUrl = updateUrlSouth(aa[aj][i][0].altSrc);
						aa[aj][i][0].altSrc = tmpUrl;
						tmp1 = parseInt(aa[aj][i][1].style.top) + (ac * ai);
						aa[aj][i][1].style.top = (tmp1) + au;
						var tmpUrl1 = updateUrlSouth(aa[aj][i][1].altSrc);
						aa[aj][i][1].altSrc = tmpUrl1;
						if (an == "HYBRID") {
							aa[aj][i][1].src = am;
							aa[aj][i][0].src = am;
							aa[aj][i][1].loader.src = aa[aj][i][1].altSrc;
							aa[aj][i][0].src = aa[aj][i][0].altSrc;
						} else {
							if (an == "SATELLITE") {
								aa[aj][i][0].src = am;
								aa[aj][i][0].src = aa[aj][i][0].altSrc;
							} else {
								if (an == "STREET") {
									aa[aj][i][1].src = am;
									aa[aj][i][1].src = aa[aj][i][1].altSrc;
								}
							}
						}
					}
					aj = (aj + 1) % ac;
					bd = bd + aw;
					draw();
				} else {
					if (bd >= -aw) {
						dg++;
						aj = (aj == 0) ? aj = (ac - 1) : --aj;
						for (var i = 0; i < ad; ++i) {
							tmp = parseInt(aa[aj][i][0].style.top) - (ac * ai);
							aa[aj][i][0].style.top = (tmp) + au;
							var tmpUrl = updateUrlNorth(aa[aj][i][0].altSrc);
							aa[aj][i][0].altSrc = tmpUrl;
							tmp1 = parseInt(aa[aj][i][1].style.top) - (ac * ai);
							aa[aj][i][1].style.top = (tmp1) + au;
							var tmpUrl1 = updateUrlNorth(aa[aj][i][1].altSrc);
							aa[aj][i][1].altSrc = tmpUrl1;
							if (an == "HYBRID") {
								aa[aj][i][1].src = am;
								aa[aj][i][0].src = am;
								aa[aj][i][1].loader.src = aa[aj][i][1].altSrc;
								aa[aj][i][0].src = aa[aj][i][0].altSrc;
							} else {
								if (an == "SATELLITE") {
									aa[aj][i][0].src = am;
									aa[aj][i][0].src = aa[aj][i][0].altSrc;
								} else {
									if (an == "STREET") {
										aa[aj][i][1].src = am;
										aa[aj][i][1].src = aa[aj][i][1].altSrc;
									}
								}
							}
						}
						draw();
						bd = bd - aw;
					}
				}
			}
		}
	}
	function updateUrlNorth(urlIn) {
		var tileUrl = urlIn.substring(0, urlIn.indexOf("&N="));
		var panParams = urlIn.substring(urlIn.indexOf("&N="));
		var northValue = parseInt((panParams.split("="))[1]) + ac;
		var eastValue = parseInt((panParams.split("="))[2]);
		tileUrl += "&N=" + northValue + "&E=" + eastValue;
		return tileUrl;
	}
	function updateUrlSouth(urlIn) {
		var tileUrl = urlIn.substring(0, urlIn.indexOf("&N="));
		var panParams = urlIn.substring(urlIn.indexOf("&N="));
		var northValue = parseInt((panParams.split("="))[1]) - ac;
		var eastValue = parseInt((panParams.split("="))[2]);
		tileUrl += "&N=" + northValue + "&E=" + eastValue;
		return tileUrl;
	}
	function updateUrlEast(urlIn) {
		var tileUrl = urlIn.substring(0, urlIn.indexOf("&N="));
		var panParams = urlIn.substring(urlIn.indexOf("&N="));
		var northValue = parseInt((panParams.split("="))[1]);
		var eastValue = parseInt((panParams.split("="))[2]) + ad;
		tileUrl += "&N=" + northValue + "&E=" + eastValue;
		return tileUrl;
	}
	function updateUrlWest(urlIn) {
		var tileUrl = urlIn.substring(0, urlIn.indexOf("&N="));
		var panParams = urlIn.substring(urlIn.indexOf("&N="));
		var northValue = parseInt((panParams.split("="))[1]);
		var eastValue = parseInt((panParams.split("="))[2]) - ad;
		tileUrl += "&N=" + northValue + "&E=" + eastValue;
		return tileUrl;
	}
	function capture(e) {
		e = e || event;
		e.stoppropagation ? e.stoppropagation() : e.cancelBubble = true;
		if (e.type == "mouseup") {
			endDrag(e);
			cn = new Date();
		} else {
			if (e.type == "click" && ((cn - cc) < 300)) {
				click(e);
			} else {
				if (e.type == "dblclick") {
					doubleClick(e);
				}
			}
		}
	}
	function click(e) {
		self.mapDiv.style.cursor = "pointer";
		self.mapDiv.unselectable = "on";
		var top = (bn ? event.clientY : e.clientY) - Utilities.getAbsoluteTop(ae) + Utilities.getScrollTop();
		var left = (bn ? event.clientX : e.clientX) - Utilities.getAbsoluteLeft(ae) + Utilities.getScrollLeft();
		var cPos = self.getCenterPosition();
		var pixelPercentY = 1 - ((parseInt(top) - bq + ba) / (ai * ac));
		var pixelPercentX = ((parseInt(left) - bk + bc) / (ai * ad));
		var bbox = self.getBoundingBox();
		var gx = as.getGXConvertedZoomLevel();
		var sl = Utilities.radsPerPixelAtZoom(256, gx);
		var blY = Math.round(Utilities.lat2pix(bbox.minPosition.lat, sl));
		var newAbsY = blY + ((ai * ac) * pixelPercentY);
		var y = Utilities.pix2lat(newAbsY, sl);
		var x = (bbox.widthInDegrees * pixelPercentX) + bbox.getMinPosition().getLon();
		if (ak["rightclick"] && (bn && event.button == 2) || (!bn && e.which == 3)) {
			ak["rightclick"](new Position(y, x));
			return false;
		}
		if (ak["click"] && e.type == "click") {
			ak["click"](new Position(y, x));
		}
		if (ak["dblclick"] && e.type == "dblclick") {
			ak["dblclick"](new Position(y, x));
		}
	}
	function startDrag(e) {
		cc = new Date();
		if ((bn && event.button == 2) || (!bn && e.which == 3)) {
			if (ak["rightclick"]) {
				click(e);
			}
		}
		if (!bz) {
			endDrag();
			return false;
		}
		de = true;
		self.mapDiv.style.cursor = "move";
		bx = bn ? event.clientX : e.clientX;
		bw = bn ? event.clientY : e.clientY;
		document.body.onmousemove = whileDragging;
		return false;
	}
	var cu = false;
	function endDrag(e) {
		de = false;
		self.mapDiv.style.cursor = "default";
		document.body.onmousemove = null;
		if (cu && ak["moveend"]) {
			ak["moveend"]();
			cu = false;
		}
		return false;
	}
	function doubleClick(e) {
		br = null;
		cv = true;
		if (ak["dblclick"]) {
			click(e);
		}
		if (!bh) {
			return false;
		}
		var clickX = bn ? event.clientX : e.clientX;
		var clickY = bn ? event.clientY : e.clientY;
		var divPosX = Utilities.getAbsoluteLeft(self.mapDiv) - Utilities.getScrollLeft();
		var divPosY = Utilities.getAbsoluteTop(self.mapDiv) - Utilities.getScrollTop();
		var moveX = (parseInt(clickX - divPosX) - Math.round(parseInt(self.mapDiv.style.width) / 2)) * -1;
		var moveY = (parseInt(clickY - divPosY) - Math.round(parseInt(self.mapDiv.style.height) / 2)) * -1;
		slider(moveX, moveY);
	}
	function move(x, y) {
		bc = -x;
		ba = -y;
		ae.style.left = -x + au;
		ae.style.top = -y + au;
	}
	function whileDragging(e) {
		cu = true;
		br = null;
		if (!de) {
			return false;
		}
		var draggingX = (bn ? event.clientX : e.clientX) - bx;
		var draggingY = (bn ? event.clientY : e.clientY) - bw;
		be += draggingX;
		bd += draggingY;
		if (Math.abs(be) > aw) {
			rotateTiles();
		}
		if (Math.abs(bd) > aw) {
			rotateTiles();
		}
		cb -= draggingX;
		ca -= draggingY;
		move(cb, ca);
		bx = bn ? event.clientX : e.clientX;
		bw = bn ? event.clientY : e.clientY;
		return false;
	}
	var ct = false;
	function slider(x, y) {
		if (x > 0) {
			ae.style.left = parseInt(ae.style.left) + 1 + au;
		} else {
			ae.style.left = parseInt(ae.style.left) - 1 + au;
		}
		if (y > 0) {
			ae.style.top = parseInt(ae.style.top) + 1 + au;
		} else {
			ae.style.top = parseInt(ae.style.top) - 1 + au;
		}
		ct = true;
		bc = bc + (x);
		ba = ba + (y);
		slide(x, y, true);
	}
	var x = 0;
	var y = 0;
	function slide(dv, du, first) {
		if (first) {
			x = dv;
		}
		if (first) {
			y = du;
		}
		var percentX = Math.round(Math.abs(x) * 0.3);
		var percentY = Math.round(Math.abs(y) * 0.3);
		if (percentX > 0 || percentY > 0) {
			if (x < 0) {
				ae.style.left = parseInt(ae.style.left) - percentX + au;
				x += percentX;
				be -= percentX;
				cb += percentX;
				dm += percentX;
			} else {
				if (x > 0) {
					ae.style.left = parseInt(ae.style.left) + percentX + au;
					x -= percentX;
					be += percentX;
					cb -= percentX;
					dm -= percentX;
				}
			}
			if (y < 0) {
				ae.style.top = parseInt(ae.style.top) - percentY + au;
				y += percentY;
				bd -= percentY;
				ca += percentY;
				dl += percentY;
			} else {
				if (y > 0) {
					ae.style.top = parseInt(ae.style.top) + percentY + au;
					y -= percentY;
					bd += percentY;
					ca -= percentY;
					dl -= percentY;
				}
			}
			if (Math.abs(be) > aw || Math.abs(bd) > aw) {
				rotateTiles();
			}
			setTimeout(slide, 1);
		} else {
			if (ak["moveend"]) {
				ak["moveend"]();
			}
			if (cv && cq) {
				self.getZoomController().zoomInOneLevel();
			}
			dm = 0;
			dl = 0;
			ct = false;
			cv = false;
			draw();
		}
	}
	function reset() {
		ae.style.left = 0 + au;
		ae.style.top = 0 + au;
		var tmpX = bk;
		var tmpY = bq;
		self.hidePinsBeforeZoom();
		for (var y = 0; y < ac; ++y) {
			for (var x = 0; x < ad; ++x) {
				if (x == 0) {
					tmpX = bk;
				}
				aa[y][x][0].style.left = tmpX + au;
				aa[y][x][0].style.top = tmpY + au;
				aa[y][x][0].src = "img/tile.png";
				aa[y][x][1].style.left = tmpX + au;
				aa[y][x][1].style.top = tmpY + au;
				aa[y][x][1].src = "img/tile.png";
				tmpX += ai;
			}
			tmpY += ai;
		}
		bc = 0;
		ba = 0;
		cb = 0;
		ca = 0;
		bx = 0;
		bw = 0;
		de = false;
		be = 0;
		bd = 0;
		aj = 0;
		ah = 0;
		dg = 0;
		df = 0;
		dk = 0;
		dj = 0;
	}
	this.redraw = function () {
		draw();
	};
	function clear() {
		if (by == "server") {
			return;
		}
		var canvas = getCanvas();
		var ctx = canvas.getContext("2d");
		ctx.clearRect(0, 0, canvas.width, canvas.height);
	}
	function draw(clear) {
		var clear = clear || false;
		if (by == "server" || !document.getElementById("tiles")) {
			return;
		}
		if (ap.overlays.length == 0 && !clear) {
			return;
		}
		if (ct) {
			return;
		}
		var canvas = getCanvas();
		var g = self.getGridSize().split(" ");
		canvas.width = parseInt(g[1]) * 256;
		canvas.height = parseInt(g[0]) * 256;
		var gx = as.getGXConvertedZoomLevel();
		var sl = Utilities.radsPerPixelAtZoom(256, gx);
		var bbox = self.getBoundingBox();
		var posTR = new Position(bbox.maxPosition.lat + " " + bbox.minPosition.lon);
		var trY = Math.round(Utilities.lat2pix(posTR.lat, sl));
		var trX = Math.round(Utilities.lon2pix(posTR.lon, sl));
		var tp = self.mapDiv;
		var bq = -(((parseInt(g[1]) * 256)) - parseInt(tp.style.width)) / 2;
		var bk = -(((parseInt(g[0]) * 256)) - parseInt(tp.style.height)) / 2;
		var t = document.getElementById("tiles");
		canvas.style.top = bk - parseInt(t.style.top) + "px";
		canvas.style.left = bq - parseInt(t.style.left) + "px";
		var ctx = canvas.getContext("2d");
		ctx.lineCap = "round";
		ctx.lineJoin = "round";
		shapeStore = ap.overlays;
		for (var ii = 0; ii < shapeStore.length; ii++) {
			ctx.beginPath();
			var color = shapeStore[ii].getFillColor();
			var border = shapeStore[ii].getBorderColor();
			var opacity = shapeStore[ii].getOpacity();
			ctx.lineWidth = shapeStore[ii].getBorderWidth();
			var f = color.replace(")", "");
			f = f.replace("(", "");
			f = f.split(".");
			var b = border.replace(")", "");
			b = b.replace("(", "");
			b = b.split(".");
			ctx.fillStyle = "rgba(" + f[0] + "," + f[1] + "," + f[2] + ",." + opacity + ")";
			ctx.strokeStyle = "rgba(" + b[0] + "," + b[1] + "," + b[2] + ",." + opacity + ")";
			if (shapeStore[ii].type == "polygon") {
				var posStore = shapeStore[ii].getPositions();
				for (var i = 0; i < posStore.length; i++) {
					var pos = (posStore[i]);
					var pY = Math.round(Utilities.lat2pix(pos.lat, sl));
					var pX = Math.round(Utilities.lon2pix(pos.lon, sl));
					var ex = parseInt(trX - pX);
					var ey = parseInt(trY - pY);
					if (i == 0) {
						ctx.moveTo((ex * -1), (ey));
					} else {
						ctx.lineTo((ex * -1), (ey));
					}
				}
				if (!document.all) {
					ctx.stroke();
				}
				ctx.fill();
			} else {
				if (shapeStore[ii].type == "line") {
					ctx.lineWidth = shapeStore[ii].getWidth();
					ctx.strokeStyle = ctx.fillStyle;
					var posStore = shapeStore[ii].getPositions();
					for (var i = 0; i < posStore.length; i++) {
						var pos = (posStore[i]);
						var pY = Math.round(Utilities.lat2pix(pos.lat, sl));
						var pX = Math.round(Utilities.lon2pix(pos.lon, sl));
						var ex = parseInt(trX - pX);
						var ey = parseInt(trY - pY);
						if (i == 0) {
							ctx.moveTo((ex * -1), (ey));
						} else {
							ctx.lineTo((ex * -1), (ey));
						}
					}
					ctx.stroke();
				} else {
					if (shapeStore[ii].type == "circle") {
						var pos = shapeStore[ii].getPosition();
						var pY = Math.round(Utilities.lat2pix(pos.lat, sl));
						var pX = Math.round(Utilities.lon2pix(pos.lon, sl));
						var ex = parseInt(trX - pX);
						var ey = parseInt(trY - pY);
						var r = shapeStore[ii].getRadius().getDegrees();
						var rY = Math.round(Utilities.lat2pix(pos.lat + r, sl));
						var ry = parseInt(rY - pY);
						ctx.arc((ex * -1), ey, Math.abs(ry), 0, Math.PI * 2, true);
						ctx.fill();
						if (!document.all) {
							ctx.stroke();
						}
					}
				}
			}
		}
	}
	function getCanvas() {
		if (!document.getElementById("tiles")) {
			return null;
		}
		var canvas;
		if (document.getElementById("canvas")) {
			canvas = document.getElementById("canvas");
			canvas.style.position = "relative";
			canvas.style.zIndex = 100;
			var t = document.getElementById("tiles");
			t.appendChild(canvas);
		} else {
			canvas = document.getElementsByTagName("body")[0].appendChild(document.createElement("canvas"));
			canvas.id = "canvas";
			if (typeof G_vmlCanvasManager != "undefined") {
				canvas = G_vmlCanvasManager.initElement(canvas);
			}
			canvas.style.position = "relative";
			canvas.style.zIndex = 100;
			var t = document.getElementById("tiles");
			t.appendChild(canvas);
		}
		return canvas;
	}
}
function MapTypeController() {
}
function Pin(pos, message, bubbleEventType, icon) {
	if (!pos) {
		throw new Exception("Error instantiating Pin, must at least provide a Position.");
		return false;
	}
	this.type = "pin";
	var self = this;
	var ak = new Array();
	this.position = pos;
	this.icon = icon || new Icon("img/greenDot.png", 12, 12, 24, 24);
	this.pinImg = null;
	this.pinTxt = null;
	this.zoomHide = false;
	this.id = "";
	this.map = null;
	this.pinImg = document.createElement("img");
	this.pinImg.style.position = "absolute";
	this.pinImg.id = pos.toString();
	Pin.zIndexCounter++;
	this.pinImg.style.zIndex = Pin.zIndexCounter;
	this.pinImg.src = this.icon.src;
	if (this.icon.width && this.icon.height) {
		this.pinImg.style.width = parseInt(this.icon.width) + "px";
		this.pinImg.style.height = parseInt(this.icon.height) + "px";
	}
	this.pinTxt = document.createElement("DIV");
	this.pinTxt.innerHTML = this.icon.overlay.text;
	this.pinTxt.style.position = "absolute";
	this.pinTxt.style.color = this.icon.overlay.color;
	this.pinTxt.style.fontSize = this.icon.overlay.size;
	this.pinTxt.style.fontFamily = this.icon.overlay.fontFamily;
	Pin.zIndexCounter++;
	this.pinTxt.style.zIndex = Pin.zIndexCounter;
	this.pinTxt.onmousedown = function (e) {
		if ((document.all && event.button == 2) || (!document.all && e.which == 3)) {
			rightclick(e);
		} else {
			click(e);
		}
	};
	this.pinTxt.onmouseover = function (e) {
		mouseover(e);
	};
	this.pinImg.style.cursor = "pointer";
	this.pinTxt.style.cursor = "pointer";
	this.pinImg.style.display = "block";
	this.pinImg.msg = message || "";
	this.pinImg.xOff = (this.icon.anchorX * 2) + 2;
	if (Utilities.ie6 && this.pinImg.src.match(new RegExp("\\bpng\\b", "g"))) {
		Utilities.fixPng(this.pinImg);
	}
	this.setId = function (id) {
		this.id = id;
	};
	this.getId = function () {
		return this.id;
	};
	this.setCursorStyle = function (style) {
		this.pinImg.style.cursor = style;
		this.pinTxt.style.cursor = style;
	};
	this.getCursorStyle = function (style) {
		return this.pinImg.style.cursor;
	};
	this.setIcon = function (icon) {
		self.pinImg.src = icon.src;
		if (self.icon.anchorY == icon.anchorY && self.icon.anchorX == icon.anchorX && icon.cg && icon.ch) {
			self.pinImg.style.top = (parseInt(self.pinImg.style.top) + icon.cg - icon.anchorY) + "px";
			self.pinImg.style.left = (parseInt(self.pinImg.style.left) + icon.ch - icon.anchorX) + "px";
		} else {
			self.pinImg.style.top = (parseInt(self.pinImg.style.top) + self.icon.anchorY - icon.anchorY) + "px";
			self.pinImg.style.left = (parseInt(self.pinImg.style.left) + self.icon.anchorX - icon.anchorX) + "px";
		}
		if (icon.width) {
			self.pinImg.style.width = icon.width + "px";
		}
		if (icon.height) {
			self.pinImg.style.height = icon.height + "px";
		}
		self.icon = icon;
		if (icon.overlay.text != "") {
			self.pinTxt.innerHTML = this.icon.overlay.text;
			self.pinTxt.style.position = "absolute";
			if (icon.overlay.color) {
				self.pinTxt.style.color = icon.overlay.color;
			}
			if (icon.overlay.size) {
				self.pinTxt.style.fontSize = icon.overlay.size;
			}
			if (icon.overlay.fontFamily) {
				self.pinTxt.style.fontFamily = icon.overlay.fontFamily;
			}
			self.pinTxt.style.left = (parseInt(self.pinImg.style.left) + parseInt(self.icon.overlay.anchorX)) + "px";
			self.pinTxt.style.top = (parseInt(self.pinImg.style.top) + parseInt(self.icon.overlay.anchorY)) + "px";
			self.pinTxt.style.zIndex = 200;
			self.pinTxt.onmousedown = function (e) {
				if ((document.all && event.button == 2) || (!document.all && e.which == 3)) {
					rightclick(e);
				} else {
					click(e);
				}
			};
			self.pinTxt.onmouseover = function (e) {
				mouseover(e);
			};
		} else {
			self.pinTxt.innerHTML = "";
		}
		if (Utilities.ie6 && this.pinImg.src.match(new RegExp("\\bpng\\b", "g"))) {
			var src = this.pinImg.src;
			this.pinImg.src = "img/x.gif";
			this.pinImg.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
		}
	};
	this.getIcon = function () {
		return self.icon;
	};
	this.setX = function (x) {
		self.pinImg.style.left = (x - self.icon.anchorX) + "px";
		if (self.pinTxt) {
			self.pinTxt.style.left = (x - self.icon.anchorX + self.icon.overlay.anchorX) + "px";
		}
		if (document.all) {
			for (var i = 0; i < ak.length; i++) {
				self.reRegister(ak[i], ak[ak[i]]);
			}
		}
	};
	this.setY = function (y) {
		self.pinImg.style.top = (y - self.icon.anchorY) + "px";
		if (self.pinTxt) {
			self.pinTxt.style.top = (y - self.icon.anchorY + self.icon.overlay.anchorY) + "px";
		}
	};
	this.getPosition = function () {
		return self.position;
	};
	this.setPosition = function (pos) {
		if (self.map != null) {
			var pp1 = self.map.getGXPixelPoint(self.position);
			var pp2 = self.map.getGXPixelPoint(pos);
			var diffX = parseInt(pp1.x) - parseInt(pp2.x);
			var diffY = parseInt(pp1.y) - parseInt(pp2.y);
			self.setX(parseInt(self.pinImg.style.left) + self.icon.anchorX - diffX);
			self.setY(parseInt(self.pinImg.style.top) + self.icon.anchorY + diffY);
		}
		self.position = pos;
	};
	this.setMessage = function (message) {
		self.pinImg.msg = message;
		if (self.pinImg.id == document.getElementById("bubble").whichPin) {
			document.getElementById("bubbleContent").innerHTML = message;
		}
	};
	this.getMessage = function () {
		return self.pinImg.msg;
	};
	this.hide = function () {
		self.pinImg.style.display = "none";
		self.pinTxt.style.display = "none";
	};
	this.show = function () {
		self.pinImg.style.display = "block";
		self.pinTxt.style.display = "block";
	};
	this.showInfoWindow = function () {
		if (document.getElementById("bubble").type == "custom") {
			document.getElementById("bubble").style.left = (parseInt(self.pinImg.style.left) - parseInt(document.getElementById("bubble").offX)) + "px";
			document.getElementById("bubble").style.top = (parseInt(self.pinImg.style.top) - parseInt(document.getElementById("bubble").offY)) + "px";
		} else {
			document.getElementById("bubble").style.left = (parseInt(self.pinImg.style.left) + (self.icon.anchorX * 2) + 2) + "px";
			document.getElementById("bubble").style.top = parseInt(self.pinImg.style.top) + "px";
		}
		document.getElementById("bubbleContent").innerHTML = self.pinImg.msg;
		document.getElementById("bubble").style.display = "block";
		document.getElementById("bubble").whichPin = self.pinImg.id;
		if (document.all) {
			document.getElementById("close").onclick = function (e) {
				e = e || event;
				e.stoppropagation ? e.stoppropagation() : e.cancelBubble = true;
				document.getElementById("bubble").style.display = "none";
			};
		}
	};
	this.hideInfoWindow = function () {
		document.getElementById("bubble").style.display = "none";
	};
	this.reRegister = function (event, callBack) {
		if (!self.pinImg.onclick && event == "click") {
			self.pinImg.onclick = click;
		} else {
			if (event == "rightclick") {
				self.pinImg.onmousedown = rightclick;
			} else {
				if (!self.pinImg.onmouseover && event == "mouseover") {
					self.pinImg.onmouseover = mouseover;
				} else {
					if (!self.pinImg.onmouseout && event == "mouseout") {
						self.pinImg.onmouseout = mouseout;
					}
				}
			}
		}
	};
	this.addEventListener = function (event, callBack) {
		var already = false;
		for (var i = 0; i < ak.length; i++) {
			if (ak[i] == event) {
				ak[event] = callBack;
				already = true;
				break;
			}
		}
		if (!already) {
			ak.push(event);
			ak[event] = callBack;
		}
		if (!self.pinImg.onclick && event == "click") {
			self.pinImg.onclick = click;
		} else {
			if (event == "rightclick") {
				self.pinImg.onmousedown = rightclick;
			} else {
				if (!self.pinImg.onmouseover && event == "mouseover") {
					self.pinImg.onmouseover = mouseover;
				} else {
					if (!self.pinImg.onmouseout && event == "mouseout") {
						self.pinImg.onmouseout = mouseout;
					}
				}
			}
		}
	};
	this.clearInstanceListeners = function () {
		for (var i = 0; i < ak.length; i++) {
			ak[ak[i]] = null;
			ak[i] = null;
		}
	};
	this.clearListeners = function (event) {
		for (var i = 0; i < ak.length; i++) {
			if (ak[i] == event) {
				ak[ak[i]] = null;
			}
		}
		ak[i] = null;
	};
	function click(e) {
		e = e || event;
		e.stoppropagation ? e.stoppropagation() : e.cancelBubble = true;
		if (ak["click"]) {
			ak["click"](self);
		}
	}
	function rightclick(e) {
		e = e || event;
		e.stoppropagation ? e.stoppropagation() : e.cancelBubble = true;
		if (ak["rightclick"]) {
			if ((document.all && event.button == 2) || (!document.all && e.which == 3)) {
				ak["rightclick"](self);
			}
			return false;
		}
	}
	function mouseover() {
		if (ak["mouseover"]) {
			ak["mouseover"](self);
		}
	}
	function mouseout() {
		if (ak["mouseout"]) {
			ak["mouseout"](self);
		}
	}
	if (bubbleEventType && (bubbleEventType == "onmouseover" || bubbleEventType == "mouseover")) {
		self.addEventListener("mouseover", self.showInfoWindow);
		self.addEventListener("mouseout", self.hideInfoWindow);
	} else {
		if (bubbleEventType && (bubbleEventType == "onclick" || bubbleEventType == "click")) {
			self.addEventListener("click", self.showInfoWindow);
		}
	}
	this.toString = function () {
		return self.position;
	};
	this.equals = function (pin) {
		if (pin && pin.toString() == this.toString() && pin.pinImg == this.pinImg) {
			return true;
		} else {
			return false;
		}
	};
}
Pin.zIndexCounter = 100;
function PixelPoint(v1, v2) {
	try {
		this.x = parseInt(v1);
		this.y = parseInt(v2);
	}
	catch (e) {
		throw new Exception("bad constructor values for x/y");
	}
	var self = this;
	this.getX = function () {
		return parseInt(self.x);
	};
	this.getY = function () {
		return parseInt(self.y);
	};
	this.equals = function (pd) {
		if (pd && pd.toString() == self.toString()) {
			return true;
		} else {
			return false;
		}
	};
	this.toString = function () {
		return self.x + " " + self.y;
	};
}
function PixelPointDP(v1, v2) {
	try {
		this.x = parseFloat(v1);
		this.y = parseFloat(v2);
	}
	catch (e) {
		throw new Exception("bad constructor values for x/y");
	}
	var self = this;
	this.getX = function () {
		return (self.x);
	};
	this.getY = function () {
		return (self.y);
	};
	this.equals = function (pd) {
		if (pd && pd.toString() == self.toString()) {
			return true;
		} else {
			return false;
		}
	};
	this.toString = function () {
		return self.x + " " + self.y;
	};
}
function POI(name, position, address, phoneNumber) {
	this.name = name;
	this.position = position;
	this.address = address;
	this.phoneNumber = phoneNumber;
	this.toString = function () {
		return this.name + " " + this.position + " " + this.address + " " + this.phoneNumber;
	};
}
function POIQuery() {
	this.xmlRecFac = new XMLRequestFactory();
	var ag = new Array();
	var self = this;
	this.authenticate = function (clientName, clientPassword) {
		if (!clientName || !clientPassword || clientName == "" || clientPassword == "") {
			throw new Exception("Error authenticating POIQuery, invalid parameters.");
			return false;
		}
		Credentials.clientName = clientName;
		Credentials.clientPassword = clientPassword;
	};
	this.query = function (searchCriteria, callBack) {
		var reqId = Utilities.getRequestId();
		ag[reqId] = callBack;
		ab = this.xmlRecFac.createPOIRequestDOM(searchCriteria, reqId);
		JSRequest.send(ab, self.queryCallback);
	};
	this.queryCallback = function (data) {
		var oDomDoc = (new DOMParser()).parseFromString(Utilities.normalizePrefixes(data), "text/xml");
		if (document.all) {
			oDomDoc.setProperty("SelectionLanguage", "XPath");
			oDomDoc.setProperty("SelectionNamespaces", "xmlns:xls='http://www.opengis.net/xls' xmlns:gml='http://www.opengis.net/gml'");
		}
		var poiList = new Array();
		if (oDomDoc.selectNodes("//xls:Error").length > 0) {
			var reqId = Sarissa.getText(oDomDoc.selectSingleNode("//xls:Response/@requestID"));
			ag[reqId](null);
		} else {
			if (oDomDoc.selectNodes("//xls:POI").length == 0) {
				var reqId = Sarissa.getText(oDomDoc.selectSingleNode("//xls:Response/@requestID"));
				ag[reqId](poiList);
			} else {
				var POIS = oDomDoc.selectNodes("//xls:POIContext");
				for (var i = 0; i < POIS.length; i++) {
					var tmpDomTxt = Sarissa.serialize((POIS[i]));
					var domParser = (new DOMParser()).parseFromString(Utilities.normalizePrefixes(tmpDomTxt), "text/xml");
					if (document.all) {
						domParser.setProperty("SelectionLanguage", "XPath");
						domParser.setProperty("SelectionNamespaces", "xmlns:xls='http://www.opengis.net/xls' xmlns:gml='http://www.opengis.net/gml'");
					}
					var prefix = "xls:";
					if (navigator.userAgent.toLowerCase().indexOf("safari") != -1) {
						prefix = "";
					}
					try {
						var name = Sarissa.getText(domParser.selectSingleNode("//" + prefix + "POI/@POIName"));
						var phoneNumber = Sarissa.getText(domParser.selectSingleNode("//" + prefix + "POI/@phoneNumber"));
					}
					catch (e) {
					}
					var pos = tmpDomTxt.substring(tmpDomTxt.indexOf("<gml:pos>") + "<gml:pos>".length, tmpDomTxt.indexOf("</gml:pos>"));
					var num = "";
					var str = "";
					var stt = "";
					var cou = "";
					var cit = "";
					var pst = "";
					try {
						num = Sarissa.getText(domParser.selectSingleNode("//" + prefix + "Building/@number"));
					}
					catch (e) {
					}
					try {
						str = Sarissa.getText(domParser.selectSingleNode("//" + prefix + "Street"));
					}
					catch (e) {
					}
					try {
						stt = Sarissa.getText(domParser.selectSingleNode("//" + prefix + "Place[@type='CountrySubdivision']"));
					}
					catch (e) {
					}
					try {
						cou = Sarissa.getText(domParser.selectSingleNode("//" + prefix + "Place[@type='CountrySecondarySubdivision']"));
					}
					catch (e) {
					}
					try {
						cit = Sarissa.getText(domParser.selectSingleNode("//" + prefix + "Place[@type='Municipality']"));
					}
					catch (e) {
					}
					try {
						pst = Sarissa.getText(domParser.selectSingleNode("//" + prefix + "PostalCode"));
					}
					catch (e) {
					}
					var adr = new Address(num, str, stt, cou, cit, pst);
					poiList.push(new POI(name, new Position(pos), adr, phoneNumber));
				}
				var reqId = Sarissa.getText(oDomDoc.selectSingleNode("//xls:Response/@requestID"));
				ag[reqId](poiList);
			}
		}
	};
}
function Position(latitude, longitude) {
	if (arguments.length == 1) {
		var stringSplit = latitude.split(" ");
		if (stringSplit.length != 2) {
			throw new Exception("error initializing Position object");
		}
		try {
			this.lat = parseFloat(stringSplit[0]);
			this.lon = parseFloat(stringSplit[1]);
		}
		catch (e) {
			throw new Exception("error initializing Position object");
		}
	} else {
		if (arguments.length == 2) {
			try {
				this.lat = parseFloat(latitude);
				this.lon = parseFloat(longitude);
			}
			catch (e) {
				throw new Exception("error initializing Position object");
			}
		} else {
			throw new Exception("error initializing Position object");
		}
	}
	if (this.lat > 90 || this.lat < -90) {
		throw new Exception("error initializing Position object: lat out of bounds");
	}
	if (this.lon > 180 || this.lon < -180) {
		throw new Exception("error initializing Position object: lon out of bounds");
	}
	this.clone = function () {
		return new Position(this.toString());
	};
	this.getLat = function () {
		return this.lat;
	};
	this.getLon = function () {
		return this.lon;
	};
	this.setLat = function (lt) {
		this.lat = lt;
	};
	this.setLon = function (ln) {
		this.lon = ln;
	};
	this.getLatLon = function () {
		return this.lat + " " + this.lon;
	};
	this.getLatCommaLon = function () {
		return this.lat + ", " + this.lon;
	};
	this.equals = function (position) {
		if (position && position.getLatLon() == this.getLatLon()) {
			return true;
		} else {
			return false;
		}
	};
	this.toString = function () {
		return this.lat + " " + this.lon;
	};
}
function Radius(distance, uom) {
	this.distance = distance;
	this.uom = uom || new UOM("KM");
	var tmp;
	if (uom == "KM") {
		tmp = "K";
	} else {
		if (uom == "M") {
			tmp = "M";
		} else {
			if (uom == "MI") {
				tmp = "R";
			} else {
				if (uom == "FT") {
					tmp = "F";
				}
			}
		}
	}
	this.uomdds = tmp;
	this.toString = function () {
		return this.distance + " " + this.uom;
	};
	this.getDegrees = function () {
		if (uom == "KM") {
			return this.distance / 111.111;
		} else {
			if (uom == "M") {
				return (this.distance / 1000) / 111.111;
			} else {
				if (uom == "MI") {
					return (this.distance * 1.609) / 111.111;
				} else {
					if (uom == "FT") {
						return ((this.distance / 3.28) / 1000) / 111.111;
					}
				}
			}
		}
	};
}
function Route() {
	this.TotalTime = "";
	this.TotalDistance = "";
	this.viaPointSequence = "";
	this.RouteInstructions = [];
	this.RouteGeometry = [];
}
function RouteInstruction() {
	this.Instruction = "";
	this.distance = "";
	this.duration = "";
	this.position = null;
	this.tour = "";
}
function RoutePreference(routePreference, uom, routeQueryType) {
	if (routePreference != "Fastest" && routePreference != "Shortest" && routePreference != "Pedestrian" && routePreference != "AvoidFreeways" && routePreference != "NoFreeways" && routePreference != "IgnorePipes" && routePreference != "MoreFreeways" && routePreference != "Easy") {
		alert("invalid route preference type, please see documentation");
		return false;
	}
	this.routePreference = routePreference;
	this.uom = uom || new UOM("KM");
	this.routeQueryType = routeQueryType || "RTXT";
	this.rules = null;
	this.optimized = false;
}
RoutePreference.prototype.setOptimized = function (optimized) {
	this.optimized = optimized;
};
RoutePreference.prototype.getOptimized = function () {
	return this.optimized;
};
RoutePreference.prototype.setRules = function (rules) {
	this.rules = rules;
};
RoutePreference.prototype.getRules = function () {
	return this.rules;
};
function RouteQuery() {
	this.xmlRecFac = new XMLRequestFactory();
	var ag = new Array();
	var self = this;
	this.authenticate = function (clientName, clientPassword) {
		if (!clientName || !clientPassword || clientName == "" || clientPassword == "") {
			throw new Exception("Error authenticating RouteQuery, invalid parameters.");
			return false;
		}
		Credentials.clientName = clientName;
		Credentials.clientPassword = clientPassword;
	};
	this.query = function (positions, routePreference, callBack) {
		var reqId = Utilities.getRequestId();
		ag[reqId] = callBack;
		ab = this.xmlRecFac.createRouteGeometryRequestDOM(positions, reqId, routePreference, null, true);
		JSRequest.send(ab, self.queryCallback);
	};
	this.queryCallback = function (data) {
		var oDomDoc = (new DOMParser()).parseFromString(Utilities.normalizePrefixes(data), "text/xml");
		if (document.all) {
			oDomDoc.setProperty("SelectionLanguage", "XPath");
			oDomDoc.setProperty("SelectionNamespaces", "xmlns:xls='http://www.opengis.net/xls' xmlns:gml='http://www.opengis.net/gml'");
		}
		var RouteList = new Array();
		if (oDomDoc.selectNodes("//xls:Error").length > 0) {
			var reqId = Sarissa.getText(oDomDoc.selectSingleNode("//xls:Response/@requestID"));
			ag[reqId](null);
		} else {
			var rt = Utilities.parseRoute(oDomDoc);
			var reqId = Sarissa.getText(oDomDoc.selectSingleNode("//xls:Response/@requestID"));
			ag[reqId](rt);
		}
	};
}
function Sarissa() {
}
Sarissa.VERSION = "${project.version}";
Sarissa.PARSED_OK = "Document contains no parsing errors";
Sarissa.PARSED_EMPTY = "Document is empty";
Sarissa.PARSED_UNKNOWN_ERROR = "Not well-formed or other error";
Sarissa.IS_ENABLED_TRANSFORM_NODE = false;
var co = 0;
var bm = "";
var bg = document.implementation && true;
var ax = bg && document.implementation.createDocument;
var bf = bg && document.implementation.hasFeature;
var ds = ax && bf;
var bp = navigator.userAgent.toLowerCase().indexOf("safari") != -1 || navigator.userAgent.toLowerCase().indexOf("konqueror") != -1;
var cf = bp && parseInt((navigator.userAgent.match(/AppleWebKit\/(\d+)/) || {})[1]) < 420;
var bt = document.all && window.ActiveXObject && navigator.userAgent.toLowerCase().indexOf("msie") > -1 && navigator.userAgent.toLowerCase().indexOf("opera") == -1;
var dq = navigator.userAgent.toLowerCase().indexOf("opera") != -1;
if (!window.Node || !Node.ELEMENT_NODE) {
	Node = {ELEMENT_NODE:1, ATTRIBUTE_NODE:2, TEXT_NODE:3, CDATA_SECTION_NODE:4, ENTITY_REFERENCE_NODE:5, ENTITY_NODE:6, PROCESSING_INSTRUCTION_NODE:7, COMMENT_NODE:8, DOCUMENT_NODE:9, DOCUMENT_TYPE_NODE:10, DOCUMENT_FRAGMENT_NODE:11, NOTATION_NODE:12};
}
if (cf) {
	HTMLHtmlElement = document.createElement("html").constructor;
	Node = HTMLElement = {};
	HTMLElement.prototype = HTMLHtmlElement.__proto__.__proto__;
	HTMLDocument = Document = document.constructor;
	var x = new DOMParser();
	XMLDocument = x.constructor;
	Element = x.parseFromString("<Single />", "text/xml").documentElement.constructor;
	x = null;
}
if (typeof XMLDocument == "undefined" && typeof Document != "undefined") {
	XMLDocument = Document;
}
if (bt) {
	bm = "xsl:";
	var at = "";
	var ay = "";
	var bj = "";
	Sarissa.pickRecentProgID = function (idList) {
		var bFound = false, e;
		for (var i = 0; i < idList.length && !bFound; i++) {
			try {
				var oDoc = new ActiveXObject(idList[i]);
				var o2Store = idList[i];
				bFound = true;
			}
			catch (objException) {
				e = objException;
			}
		}
		if (!bFound) {
			throw "Could not retrieve a valid progID of Class: " + idList[idList.length - 1] + ". (original exception: " + e + ")";
		}
		idList = null;
		return o2Store;
	};
	at = null;
	_SARISSA_THREADEDDOM_PROGID = null;
	_SARISSA_XSLTEMPLATE_PROGID = null;
	ay = null;
	if (!window.XMLHttpRequest) {
		XMLHttpRequest = function () {
			if (!ay) {
				ay = Sarissa.pickRecentProgID(["Msxml2.XMLHTTP.6.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP"]);
			}
			return new ActiveXObject(ay);
		};
	}
	Sarissa.getDomDocument = function (sUri, sName) {
		if (!at) {
			at = Sarissa.pickRecentProgID(["Msxml2.DOMDocument.6.0", "Msxml2.DOMDocument.3.0", "MSXML2.DOMDocument", "MSXML.DOMDocument", "Microsoft.XMLDOM"]);
		}
		var oDoc = new ActiveXObject(at);
		if (sName) {
			var prefix = "";
			if (sUri) {
				if (sName.indexOf(":") > 1) {
					prefix = sName.substring(0, sName.indexOf(":"));
					sName = sName.substring(sName.indexOf(":") + 1);
				} else {
					prefix = "a" + (co++);
				}
			}
			if (sUri) {
				oDoc.loadXML("<" + prefix + ":" + sName + " xmlns:" + prefix + "=\"" + sUri + "\"" + " />");
			} else {
				oDoc.loadXML("<" + sName + " />");
			}
		}
		return oDoc;
	};
	Sarissa.getParseErrorText = function (oDoc) {
		var parseErrorText = Sarissa.PARSED_OK;
		if (oDoc && oDoc.parseError && oDoc.parseError.errorCode && oDoc.parseError.errorCode != 0) {
			parseErrorText = "XML Parsing Error: " + oDoc.parseError.reason + "\nLocation: " + oDoc.parseError.url + "\nLine Number " + oDoc.parseError.line + ", Column " + oDoc.parseError.linepos + ":\n" + oDoc.parseError.srcText + "\n";
			for (var i = 0; i < oDoc.parseError.linepos; i++) {
				parseErrorText += "-";
			}
			parseErrorText += "^\n";
		} else {
			if (oDoc.documentElement == null) {
				parseErrorText = Sarissa.PARSED_EMPTY;
			}
		}
		return parseErrorText;
	};
	Sarissa.setXpathNamespaces = function (oDoc, sNsSet) {
		oDoc.setProperty("SelectionLanguage", "XPath");
		oDoc.setProperty("SelectionNamespaces", sNsSet);
	};
	XSLTProcessor = function () {
		if (!_SARISSA_XSLTEMPLATE_PROGID) {
			_SARISSA_XSLTEMPLATE_PROGID = Sarissa.pickRecentProgID(["Msxml2.XSLTemplate.6.0", "MSXML2.XSLTemplate.3.0"]);
		}
		this.template = new ActiveXObject(_SARISSA_XSLTEMPLATE_PROGID);
		this.processor = null;
	};
	XSLTProcessor.prototype.importStylesheet = function (xslDoc) {
		if (!_SARISSA_THREADEDDOM_PROGID) {
			_SARISSA_THREADEDDOM_PROGID = Sarissa.pickRecentProgID(["MSXML2.FreeThreadedDOMDocument.6.0", "MSXML2.FreeThreadedDOMDocument.3.0"]);
		}
		xslDoc.setProperty("SelectionLanguage", "XPath");
		xslDoc.setProperty("SelectionNamespaces", "xmlns:xsl='http://www.w3.org/1999/XSL/Transform'");
		var converted = new ActiveXObject(_SARISSA_THREADEDDOM_PROGID);
		try {
			converted.resolveExternals = true;
			converted.setProperty("AllowDocumentFunction", true);
		}
		catch (e) {
		}
		if (xslDoc.url && xslDoc.selectSingleNode("//xsl:*[local-name() = 'import' or local-name() = 'include']") != null) {
			converted.async = false;
			converted.load(xslDoc.url);
		} else {
			converted.loadXML(xslDoc.xml);
		}
		converted.setProperty("SelectionNamespaces", "xmlns:xsl='http://www.w3.org/1999/XSL/Transform'");
		var output = converted.selectSingleNode("//xsl:output");
		this.outputMethod = output ? output.getAttribute("method") : "html";
		this.template.stylesheet = converted;
		this.processor = this.template.createProcessor();
		this.paramsSet = [];
	};
	XSLTProcessor.prototype.transformToDocument = function (sourceDoc) {
		if (_SARISSA_THREADEDDOM_PROGID) {
			this.processor.input = sourceDoc;
			var outDoc = new ActiveXObject(at);
			this.processor.output = outDoc;
			this.processor.transform();
			return outDoc;
		} else {
			if (!bj) {
				bj = Sarissa.pickRecentProgID(["Msxml2.MXXMLWriter.6.0", "Msxml2.MXXMLWriter.3.0", "MSXML2.MXXMLWriter", "MSXML.MXXMLWriter", "Microsoft.XMLDOM"]);
			}
			this.processor.input = sourceDoc;
			var outDoc = new ActiveXObject(bj);
			this.processor.output = outDoc;
			this.processor.transform();
			var oDoc = new ActiveXObject(at);
			oDoc.loadXML(outDoc.output + "");
			return oDoc;
		}
	};
	XSLTProcessor.prototype.transformToFragment = function (sourceDoc, ownerDoc) {
		this.processor.input = sourceDoc;
		this.processor.transform();
		var s = this.processor.output;
		var f = ownerDoc.createDocumentFragment();
		if (this.outputMethod == "text") {
			f.appendChild(ownerDoc.createTextNode(s));
		} else {
			if (ownerDoc.body && ownerDoc.body.innerHTML) {
				var container = ownerDoc.createElement("div");
				container.innerHTML = s;
				while (container.hasChildNodes()) {
					f.appendChild(container.firstChild);
				}
			} else {
				var oDoc = new ActiveXObject(at);
				if (s.substring(0, 5) == "<?xml") {
					s = s.substring(s.indexOf("?>") + 2);
				}
				var xml = "".concat("<my>", s, "</my>");
				oDoc.loadXML(xml);
				var container = oDoc.documentElement;
				while (container.hasChildNodes()) {
					f.appendChild(container.firstChild);
				}
			}
		}
		return f;
	};
	XSLTProcessor.prototype.setParameter = function (nsURI, name, value) {
		value = value ? value : "";
		if (nsURI) {
			this.processor.addParameter(name, value, nsURI);
		} else {
			this.processor.addParameter(name, value);
		}
		nsURI = "" + (nsURI || "");
		if (!this.paramsSet[nsURI]) {
			this.paramsSet[nsURI] = new Array();
		}
		this.paramsSet[nsURI][name] = value;
	};
	XSLTProcessor.prototype.getParameter = function (nsURI, name) {
		nsURI = "" + (nsURI || "");
		if (this.paramsSet[nsURI] && this.paramsSet[nsURI][name]) {
			return this.paramsSet[nsURI][name];
		} else {
			return null;
		}
	};
	XSLTProcessor.prototype.clearParameters = function () {
		for (var nsURI in this.paramsSet) {
			for (var name in this.paramsSet[nsURI]) {
				if (nsURI != "") {
					this.processor.addParameter(name, "", nsURI);
				} else {
					this.processor.addParameter(name, "");
				}
			}
		}
		this.paramsSet = new Array();
	};
} else {
	if (ax) {
		Sarissa.__handleLoad__ = function (oDoc) {
			Sarissa.__setReadyState__(oDoc, 4);
		};
		_sarissa_XMLDocument_onload = function () {
			Sarissa.__handleLoad__(this);
		};
		Sarissa.__setReadyState__ = function (oDoc, iReadyState) {
			oDoc.readyState = iReadyState;
			oDoc.readystate = iReadyState;
			if (oDoc.onreadystatechange != null && typeof oDoc.onreadystatechange == "function") {
				oDoc.onreadystatechange();
			}
		};
		Sarissa.getDomDocument = function (sUri, sName) {
			var oDoc = document.implementation.createDocument(sUri ? sUri : null, sName ? sName : null, null);
			if (!oDoc.onreadystatechange) {
				oDoc.onreadystatechange = null;
			}
			if (!oDoc.readyState) {
				oDoc.readyState = 0;
			}
			oDoc.addEventListener("load", _sarissa_XMLDocument_onload, false);
			return oDoc;
		};
		if (window.XMLDocument) {
		} else {
			if (bf && window.Document && !Document.prototype.load && document.implementation.hasFeature("LS", "3.0")) {
				Sarissa.getDomDocument = function (sUri, sName) {
					var oDoc = document.implementation.createDocument(sUri ? sUri : null, sName ? sName : null, null);
					return oDoc;
				};
			} else {
				Sarissa.getDomDocument = function (sUri, sName) {
					var oDoc = document.implementation.createDocument(sUri ? sUri : null, sName ? sName : null, null);
					if (oDoc && (sUri || sName) && !oDoc.documentElement) {
						oDoc.appendChild(oDoc.createElementNS(sUri, sName));
					}
					return oDoc;
				};
			}
		}
	}
}
if (!window.DOMParser) {
	if (bp) {
		DOMParser = function () {
		};
		DOMParser.prototype.parseFromString = function (sXml, contentType) {
			var xmlhttp = new XMLHttpRequest();
			xmlhttp.open("GET", "data:text/xml;charset=utf-8," + encodeURIComponent(sXml), false);
			xmlhttp.send(null);
			return xmlhttp.responseXML;
		};
	} else {
		if (Sarissa.getDomDocument && Sarissa.getDomDocument() && Sarissa.getDomDocument(null, "bar").xml) {
			DOMParser = function () {
			};
			DOMParser.prototype.parseFromString = function (sXml, contentType) {
				var doc = Sarissa.getDomDocument();
				doc.loadXML(sXml);
				return doc;
			};
		}
	}
}
if ((typeof (document.importNode) == "undefined") && bt) {
	try {
		document.importNode = function (oNode, bChildren) {
			var tmp;
			if (oNode.nodeName == "#text") {
				return document.createTextElement(oNode.data);
			} else {
				if (oNode.nodeName == "tbody" || oNode.nodeName == "tr") {
					tmp = document.createElement("table");
				} else {
					if (oNode.nodeName == "td") {
						tmp = document.createElement("tr");
					} else {
						if (oNode.nodeName == "option") {
							tmp = document.createElement("select");
						} else {
							tmp = document.createElement("div");
						}
					}
				}
				if (bChildren) {
					tmp.innerHTML = oNode.xml ? oNode.xml : oNode.outerHTML;
				} else {
					tmp.innerHTML = oNode.xml ? oNode.cloneNode(false).xml : oNode.cloneNode(false).outerHTML;
				}
				return tmp.getElementsByTagName("*")[0];
			}
		};
	}
	catch (e) {
	}
}
if (!Sarissa.getParseErrorText) {
	Sarissa.getParseErrorText = function (oDoc) {
		var parseErrorText = Sarissa.PARSED_OK;
		if (!oDoc.documentElement) {
			parseErrorText = Sarissa.PARSED_EMPTY;
		} else {
			if (oDoc.documentElement.tagName == "parsererror") {
				parseErrorText = oDoc.documentElement.firstChild.data;
				parseErrorText += "\n" + oDoc.documentElement.firstChild.nextSibling.firstChild.data;
			} else {
				if (oDoc.getElementsByTagName("parsererror").length > 0) {
					var parsererror = oDoc.getElementsByTagName("parsererror")[0];
					parseErrorText = Sarissa.getText(parsererror, true) + "\n";
				} else {
					if (oDoc.parseError && oDoc.parseError.errorCode != 0) {
						parseErrorText = Sarissa.PARSED_UNKNOWN_ERROR;
					}
				}
			}
		}
		return parseErrorText;
	};
}
Sarissa.getText = function (oNode, deep) {
	var s = "";
	var nodes = oNode.childNodes;
	for (var i = 0; i < nodes.length; i++) {
		var node = nodes[i];
		var nodeType = node.nodeType;
		if (nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE) {
			s += node.data;
		} else {
			if (deep == true && (nodeType == Node.ELEMENT_NODE || nodeType == Node.DOCUMENT_NODE || nodeType == Node.DOCUMENT_FRAGMENT_NODE)) {
				s += Sarissa.getText(node, true);
			}
		}
	}
	return s;
};
if (!window.XMLSerializer && Sarissa.getDomDocument && Sarissa.getDomDocument("", "foo", null).xml) {
	XMLSerializer = function () {
	};
	XMLSerializer.prototype.serializeToString = function (oNode) {
		return oNode.xml;
	};
}
Sarissa.stripTags = function (s) {
	return s.replace(/<[^>]+>/g, "");
};
Sarissa.clearChildNodes = function (oNode) {
	while (oNode.firstChild) {
		oNode.removeChild(oNode.firstChild);
	}
};
Sarissa.copyChildNodes = function (nodeFrom, nodeTo, bPreserveExisting) {
	if (bp && nodeTo.nodeType == Node.DOCUMENT_NODE) {
		nodeTo = nodeTo.documentElement;
	}
	if ((!nodeFrom) || (!nodeTo)) {
		throw "Both source and destination nodes must be provided";
	}
	if (!bPreserveExisting) {
		Sarissa.clearChildNodes(nodeTo);
	}
	var ownerDoc = nodeTo.nodeType == Node.DOCUMENT_NODE ? nodeTo : nodeTo.ownerDocument;
	var nodes = nodeFrom.childNodes;
	if (typeof (ownerDoc.importNode) != "undefined") {
		for (var i = 0; i < nodes.length; i++) {
			nodeTo.appendChild(ownerDoc.importNode(nodes[i], true));
		}
	} else {
		for (var i = 0; i < nodes.length; i++) {
			nodeTo.appendChild(nodes[i].cloneNode(true));
		}
	}
};
Sarissa.moveChildNodes = function (nodeFrom, nodeTo, bPreserveExisting) {
	if ((!nodeFrom) || (!nodeTo)) {
		throw "Both source and destination nodes must be provided";
	}
	if (!bPreserveExisting) {
		Sarissa.clearChildNodes(nodeTo);
	}
	var nodes = nodeFrom.childNodes;
	if (nodeFrom.ownerDocument == nodeTo.ownerDocument) {
		while (nodeFrom.firstChild) {
			nodeTo.appendChild(nodeFrom.firstChild);
		}
	} else {
		var ownerDoc = nodeTo.nodeType == Node.DOCUMENT_NODE ? nodeTo : nodeTo.ownerDocument;
		if (typeof (ownerDoc.importNode) != "undefined") {
			for (var i = 0; i < nodes.length; i++) {
				nodeTo.appendChild(ownerDoc.importNode(nodes[i], true));
			}
		} else {
			for (var i = 0; i < nodes.length; i++) {
				nodeTo.appendChild(nodes[i].cloneNode(true));
			}
		}
		Sarissa.clearChildNodes(nodeFrom);
	}
};
Sarissa.xmlize = function (anyObject, objectName, indentSpace) {
	indentSpace = indentSpace ? indentSpace : "";
	var s = indentSpace + "<" + objectName + ">";
	var isLeaf = false;
	if (!(anyObject instanceof Object) || anyObject instanceof Number || anyObject instanceof String || anyObject instanceof Boolean || anyObject instanceof Date) {
		s += Sarissa.escape("" + anyObject);
		isLeaf = true;
	} else {
		s += "\n";
		var isArrayItem = anyObject instanceof Array;
		for (var name in anyObject) {
			s += Sarissa.xmlize(anyObject[name], (isArrayItem ? "array-item key=\"" + name + "\"" : name), indentSpace + "   ");
		}
		s += indentSpace;
	}
	return (s += (objectName.indexOf(" ") != -1 ? "</array-item>\n" : "</" + objectName + ">\n"));
};
Sarissa.escape = function (sXml) {
	return sXml.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
};
Sarissa.unescape = function (sXml) {
	return sXml.replace(/&apos;/g, "'").replace(/&quot;/g, "\"").replace(/&gt;/g, ">").replace(/&lt;/g, "<").replace(/&amp;/g, "&");
};
var dc = new XMLSerializer();
Sarissa.serialize = function (x) {
	return dc.serializeToString(x);
};
if (!bt) {
	if (ax) {
		Sarissa.__handleLoad__ = function (oDoc) {
			Sarissa.__setReadyState__(oDoc, 4);
		};
		function SarissaParseError() {
			this.errorCode = 0;
		}
		_sarissa_XMLDocument_onload = function () {
			Sarissa.__handleLoad__(this);
		};
		Sarissa.__setReadyState__ = function (oDoc, iReadyState) {
			oDoc.readyState = iReadyState;
			oDoc.readystate = iReadyState;
			if (oDoc.onreadystatechange != null && typeof oDoc.onreadystatechange == "function") {
				oDoc.onreadystatechange();
			}
		};
		Sarissa.getDomDocument = function (sUri, sName) {
			var oDoc = document.implementation.createDocument(sUri ? sUri : null, sName ? sName : null, null);
			if (!oDoc.onreadystatechange) {
				oDoc.onreadystatechange = null;
			}
			if (!oDoc.readyState) {
				oDoc.readyState = 0;
			}
			if (!oDoc.parseError) {
				oDoc.parseError = new SarissaParseError();
			}
			oDoc.addEventListener("load", _sarissa_XMLDocument_onload, false);
			return oDoc;
		};
		if (window.XMLDocument) {
			XMLDocument.prototype.dd = XMLDocument.prototype.load;
			XMLDocument.prototype.load = function (sURI) {
				var oDoc = Sarissa.getDomDocument();
				Sarissa.copyChildNodes(this, oDoc);
				this.parseError.errorCode = 0;
				Sarissa.__setReadyState__(this, 1);
				try {
					if (this.async == false && _SARISSA_SYNC_NON_IMPLEMENTED) {
						var tmp = new XMLHttpRequest();
						tmp.open("GET", sURI, false);
						tmp.send(null);
						Sarissa.__setReadyState__(this, 2);
						Sarissa.copyChildNodes(tmp.responseXML, this);
						Sarissa.__setReadyState__(this, 3);
					} else {
						this.dd(sURI);
					}
				}
				catch (objException) {
					oDoc.parseError.errorCode = -1;
				}
				finally {
					if (!oDoc.documentElement || oDoc.documentElement.tagName == "parsererror") {
						oDoc.parseError.errorCode = -1;
					}
					if (this.async == false) {
						Sarissa.__handleLoad__(this);
					}
				}
				return oDoc;
			};
		} else {
			if (document.implementation && document.implementation.hasFeature && document.implementation.hasFeature("LS", "3.0")) {
				Document.prototype.async = true;
				Document.prototype.onreadystatechange = null;
				Document.prototype.load = function (sURI) {
					var oldDoc = Sarissa.getDomDocument();
					Sarissa.copyChildNodes(this, oldDoc, false);
					var parser = document.implementation.createLSParser(this.async ? document.implementation.MODE_ASYNCHRONOUS : document.implementation.MODE_SYNCHRONOUS, null);
					if (this.async) {
						var self = this;
						parser.addEventListener("load", function (e) {
							self.readyState = 4;
							Sarissa.copyChildNodes(e.newDocument, self, false);
							self.onreadystatechange.call();
						}, false);
					}
					try {
						var oDoc = parser.parseURI(sURI);
						if (!this.async) {
							Sarissa.copyChildNodes(oDoc, this, false);
						}
					}
					catch (e) {
						this.parseError.errorCode = -1;
					}
					return oldDoc;
				};
				Sarissa.getDomDocument = function (sUri, sName) {
					var oDoc = document.implementation.createDocument(sUri ? sUri : null, sName ? sName : null, null);
					if (!oDoc.parseError) {
						oDoc.parseError = {errorCode:0};
					}
					return oDoc;
				};
			} else {
				Sarissa.getDomDocument = function (sUri, sName) {
					var oDoc = document.implementation.createDocument(sUri ? sUri : null, sName ? sName : null, null);
					if (oDoc && (sUri || sName) && !oDoc.documentElement) {
						oDoc.appendChild(oDoc.createElementNS(sUri, sName));
					}
					if (!oDoc.load) {
						oDoc.load = function (sUrl) {
							var oldDoc = document.implementation.createDocument();
							Sarissa.copyChildNodes(this, oldDoc);
							this.parseError = {errorCode:0};
							Sarissa.__setReadyState__(this, 1);
							if (this.async == false) {
								var tmp = new XMLHttpRequest();
								tmp.open("GET", sUrl, false);
								tmp.send(null);
								Sarissa.__setReadyState__(this, 2);
								Sarissa.copyChildNodes(tmp.responseXML, oDoc);
								if (!oDoc.documentElement || oDoc.getElementsByTagName("parsererror").length > 0) {
									oDoc.parseError.errorCode = -1;
								}
								Sarissa.__setReadyState__(this, 3);
								Sarissa.__setReadyState__(this, 4);
							} else {
								var xmlhttp = new XMLHttpRequest();
								xmlhttp.open("GET", sUrl, true);
								xmlhttp.onreadystatechange = function () {
									if (xmlhttp.readyState == 4) {
										Sarissa.copyChildNodes(xmlhttp.responseXML, oDoc);
										if (!oDoc.documentElement || oDoc.getElementsByTagName("parsererror").length > 0) {
											oDoc.parseError.errorCode = -1;
										}
									}
									Sarissa.__setReadyState__(oDoc, xmlhttp.readyState);
								};
								xmlhttp.send(null);
							}
							return oldDoc;
						};
					}
					return oDoc;
				};
			}
		}
	}
}
if (bf && document.implementation.hasFeature("XPath", "3.0")) {
	function SarissaNodeList(i) {
		this.length = i;
	}
	SarissaNodeList.prototype = new Array(0);
	SarissaNodeList.prototype.constructor = Array;
	SarissaNodeList.prototype.item = function (i) {
		return (i < 0 || i >= this.length) ? null : this[i];
	};
	SarissaNodeList.prototype.expr = "";
	if (window.XMLDocument && (!XMLDocument.prototype.setProperty)) {
		XMLDocument.prototype.setProperty = function (x, y) {
		};
	}
	Sarissa.setXpathNamespaces = function (oDoc, sNsSet) {
		oDoc.bl = true;
		var namespaces = sNsSet.indexOf(" ") > -1 ? sNsSet.split(" ") : new Array(sNsSet);
		oDoc._sarissa_xpathNamespaces = new Array(namespaces.length);
		for (var i = 0; i < namespaces.length; i++) {
			var ns = namespaces[i];
			var colonPos = ns.indexOf(":");
			var assignPos = ns.indexOf("=");
			if (colonPos > 0 && assignPos > colonPos + 1) {
				var prefix = ns.substring(colonPos + 1, assignPos);
				var uri = ns.substring(assignPos + 2, ns.length - 1);
				oDoc._sarissa_xpathNamespaces[prefix] = uri;
			} else {
				throw "Bad format on namespace declaration(s) given";
			}
		}
	};
	XMLDocument.prototype.bl = false;
	XMLDocument.prototype._sarissa_xpathNamespaces = new Array();
	XMLDocument.prototype.selectNodes = function (sExpr, contextNode, returnSingle) {
		var nsDoc = this;
		var nsresolver = this.bl ? function (prefix) {
			var s = nsDoc._sarissa_xpathNamespaces[prefix];
			if (s) {
				return s;
			} else {
				throw "No namespace URI found for prefix: '" + prefix + "'";
			}
		} : this.createNSResolver(this.documentElement);
		var result = null;
		if (!returnSingle) {
			var oResult = this.evaluate(sExpr, (contextNode ? contextNode : this), nsresolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
			var nodeList = new SarissaNodeList(oResult.snapshotLength);
			nodeList.expr = sExpr;
			for (var i = 0; i < nodeList.length; i++) {
				nodeList[i] = oResult.snapshotItem(i);
			}
			result = nodeList;
		} else {
			result = oResult = this.evaluate(sExpr, (contextNode ? contextNode : this), nsresolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
		}
		return result;
	};
	Element.prototype.selectNodes = function (sExpr) {
		var doc = this.ownerDocument;
		if (doc.selectNodes) {
			return doc.selectNodes(sExpr, this);
		} else {
			throw "Method selectNodes is only supported by XML Elements";
		}
	};
	XMLDocument.prototype.selectSingleNode = function (sExpr, contextNode) {
		var ctx = contextNode ? contextNode : null;
		return this.selectNodes(sExpr, ctx, true);
	};
	Element.prototype.selectSingleNode = function (sExpr) {
		var doc = this.ownerDocument;
		if (doc.selectSingleNode) {
			return doc.selectSingleNode(sExpr, this);
		} else {
			throw "Method selectNodes is only supported by XML Elements";
		}
	};
	Sarissa.IS_ENABLED_SELECT_NODES = true;
}
if (!Sarissa.IS_ENABLED_TRANSFORM_NODE && window.XSLTProcessor && self.XMLElement) {
	XMLElement.prototype.transformNodeToObject = function (xslDoc, oResult) {
		var oDoc = document.implementation.createDocument("", "", null);
		Sarissa.copyChildNodes(this, oDoc);
		oDoc.transformNodeToObject(xslDoc, oResult);
	};
	Document.prototype.transformNodeToObject = function (xslDoc, oResult) {
		var xsltProcessor = null;
		try {
			xsltProcessor = new XSLTProcessor();
			if (xsltProcessor.reset) {
				xsltProcessor.importStylesheet(xslDoc);
				var newFragment = xsltProcessor.transformToFragment(this, oResult);
				Sarissa.copyChildNodes(newFragment, oResult);
			} else {
				xsltProcessor.transformDocument(this, xslDoc, oResult, null);
			}
		}
		catch (e) {
			if (xslDoc && oResult) {
				throw "Failed to transform document. (original exception: " + e + ")";
			} else {
				if (!xslDoc) {
					throw "No Stylesheet Document was provided. (original exception: " + e + ")";
				} else {
					if (!oResult) {
						throw "No Result Document was provided. (original exception: " + e + ")";
					} else {
						if (xsltProcessor == null) {
							throw "Could not instantiate an XSLTProcessor object. (original exception: " + e + ")";
						} else {
							throw e;
						}
					}
				}
			}
		}
	};
	XMLElement.prototype.transformNode = function (xslDoc) {
		var oDoc = document.implementation.createDocument("", "", null);
		Sarissa.copyChildNodes(this, oDoc);
		return oDoc.transformNode(xslDoc);
	};
	Document.prototype.transformNode = function (xslDoc) {
		var out = document.implementation.createDocument("", "", null);
		this.transformNodeToObject(xslDoc, out);
		var str = null;
		try {
			var serializer = new XMLSerializer();
			str = serializer.serializeToString(out);
		}
		catch (e) {
			throw "Failed to serialize result document. (original exception: " + e + ")";
		}
		return str;
	};
	Sarissa.IS_ENABLED_TRANSFORM_NODE = true;
}
Sarissa.setXslParameter = function (oXslDoc, sParamQName, sParamValue) {
	try {
		var params = oXslDoc.getElementsByTagName(bm + "param");
		var iLength = params.length;
		var bFound = false;
		var param;
		if (sParamValue) {
			for (var i = 0; i < iLength && !bFound; i++) {
				if (params[i].getAttribute("name") == sParamQName) {
					param = params[i];
					while (param.firstChild) {
						param.removeChild(param.firstChild);
					}
					if (!sParamValue || sParamValue == null) {
					} else {
						if (typeof sParamValue == "string") {
							param.setAttribute("select", sParamValue);
							bFound = true;
						} else {
							if (sParamValue.nodeName) {
								param.removeAttribute("select");
								param.appendChild(sParamValue.cloneNode(true));
								bFound = true;
							} else {
								if (sParamValue.item(0) && sParamValue.item(0).nodeType) {
									for (var j = 0; j < sParamValue.length; j++) {
										if (sParamValue.item(j).nodeType) {
											param.appendChild(sParamValue.item(j).cloneNode(true));
										}
									}
									bFound = true;
								} else {
									throw "Failed to set xsl:param " + sParamQName + " (original exception: " + e + ")";
								}
							}
						}
					}
				}
			}
		}
		return bFound;
	}
	catch (e) {
		throw e;
		return false;
	}
};
function SearchCriteria(queryString, position, radius, maximumResponses, database) {
	if (maximumResponses > 100) {
		alert("maximumResponses cannot exceed 100");
		return false;
	}
	this.queryString = queryString;
	this.position = position;
	this.radius = radius;
	this.maximumResponses = maximumResponses;
	this.database = database || null;
}
function ServerMonitor() {
	this.xmlRecFac = new XMLRequestFactory();
	this.query = function () {
		var reqId = Utilities.getRequestId();
		ab = this.xmlRecFac.createRUOKRequestDOM(reqId);
		this.sendServerMonitorQueryRequest();
	};
	this.sendServerMonitorQueryRequest = function () {
		if (!document.all) {
			try {
				netscape.security.PrivilegeManager.enablePrivilege("UniversalPreferencesWrite UniversalBrowserWrite UniversalPreferencesRead UniversalBrowserRead");
			}
			catch (e) {
			}
		}
		var xmlhttp = new XMLHttpRequest();
		xmlhttp.open("POST", Credentials.url, true);
		xmlhttp.onreadystatechange = function () {
			if (xmlhttp.readyState == 4) {
				try {
					if (xmlhttp.status != 200) {
						alert(ServerMonitor.WS_ERR);
						return false;
					}
				}
				catch (e) {
					alert(ServerMonitor.WS_ERR);
					return false;
				}
				var oDomDoc = (new DOMParser()).parseFromString(Utilities.normalizePrefixes(xmlhttp.responseText), "text/xml");
				if (document.all) {
					oDomDoc.setProperty("SelectionLanguage", "XPath");
					oDomDoc.setProperty("SelectionNamespaces", "xmlns:xls='http://www.opengis.net/xls' xmlns:gml='http://www.opengis.net/gml'");
				}
				if (oDomDoc.selectNodes("//xls:Error").length > 0) {
					if (((oDomDoc.selectNodes("//@message"))[0].value).indexOf("internal problem connecting to DDS") > -1) {
						alert(ServerMonitor.DDS_ERR);
					} else {
						if (((oDomDoc.selectNodes("//@message"))[0].value).indexOf("'rel' attribute") > -1) {
							alert(ServerMonitor.VER_ERR);
						} else {
							alert((oDomDoc.selectNodes("//@message"))[0].value);
						}
					}
					return false;
				}
			}
		};
		xmlhttp.send(ab);
	};
}
ServerMonitor.WS_ERR = "ERROR\n\nThere was an error connecting to the server.  Please verify that the server is running before you continue.";
ServerMonitor.DDS_ERR = "ERROR\n\ndeCarta Web Services is running, but it is unable to connect to the Drill Down Server.\n\nPlease check Drill Down Server or contact the administrator.";
ServerMonitor.VER_ERR = "ERROR\n\nThere is a version incompatibility between this version of the deCarta JavaScript API and deCarta DDS Web Services.";
function TextOverlay(text, anchorX, anchorY, color, size, fontFamily) {
	this.text = text;
	this.anchorX = anchorX;
	this.anchorY = anchorY;
	this.color = color || null;
	this.size = size || null;
	this.fontFamily = fontFamily || null;
	this.toString = function () {
		return this.text + " " + this.anchorX + " " + this.anchorY + " " + this.size + " " + fontFamily;
	};
}
TextOverlay.prototype.getAnchorX = function () {
	return this.anchorX;
};
TextOverlay.prototype.getAnchorY = function () {
	return this.anchorY;
};
TextOverlay.prototype.getText = function () {
	return this.text;
};
TextOverlay.prototype.getColor = function () {
	return this.color;
};
TextOverlay.prototype.getSize = function () {
	return this.size;
};
TextOverlay.prototype.getFontFamily = function () {
	return this.fontFamily;
};
TextOverlay.prototype.setAnchorX = function (anchorX) {
	this.anchorX = anchorX;
};
TextOverlay.prototype.setAnchorY = function (anchorY) {
	this.anchorY = anchorY;
};
TextOverlay.prototype.setText = function (text) {
	this.text = text;
};
TextOverlay.prototype.setColor = function (color) {
	this.color = color;
};
TextOverlay.prototype.setSize = function (size) {
	this.size = size;
};
TextOverlay.prototype.setFontFamily = function (fontFamily) {
	this.fontFamily = fontFamily;
};
function TrafficIncident(position, description) {
	this.position = position;
	this.description = description;
	this.toString = function () {
		return this.position + "  " + this.description;
	};
}
function TrafficIncidentQuery() {
	this.xmlRecFac = new XMLRequestFactory();
	var ag = new Array();
	var self = this;
	this.authenticate = function (clientName, clientPassword) {
		if (!clientName || !clientPassword || clientName == "" || clientPassword == "") {
			alert("Error authenticating TrafficIncidentQuery, invalid parameters.");
			return false;
		}
		Credentials.clientName = clientName;
		Credentials.clientPassword = clientPassword;
	};
	this.query = function (searchCriteria, callBack) {
		var reqId = Utilities.getRequestId();
		ag[reqId] = callBack;
		ab = this.xmlRecFac.createTrafficIncidentRequestDOM(searchCriteria, reqId);
		JSRequest.send(ab, self.queryCallback);
	};
	this.queryCallback = function (data) {
		var oDomDoc = (new DOMParser()).parseFromString(Utilities.normalizePrefixes(data), "text/xml");
		if (document.all) {
			oDomDoc.setProperty("SelectionLanguage", "XPath");
			oDomDoc.setProperty("SelectionNamespaces", "xmlns:xls='http://www.opengis.net/xls' xmlns:gml='http://www.opengis.net/gml'");
		}
		var trafficList = new Array();
		if (oDomDoc.selectNodes("//xls:Error").length > 0) {
			var reqId = Sarissa.getText(oDomDoc.selectSingleNode("//xls:Response/@requestID"));
			ag[reqId](null);
		} else {
			if (oDomDoc.selectNodes("//xls:Incident").length == 0) {
				var reqId = Sarissa.getText(oDomDoc.selectSingleNode("//xls:Response/@requestID"));
				ag[reqId](trafficList);
			} else {
				var incidents = oDomDoc.selectNodes("//xls:Incident");
				for (var i = 0; i < incidents.length; i++) {
					var tmpDomTxt = Sarissa.serialize((incidents[i]));
					var domParser = (new DOMParser()).parseFromString(Utilities.normalizePrefixes(tmpDomTxt), "text/xml");
					if (document.all) {
						domParser.setProperty("SelectionLanguage", "XPath");
						domParser.setProperty("SelectionNamespaces", "xmlns:xls='http://www.opengis.net/xls' xmlns:gml='http://www.opengis.net/gml'");
					}
					var severity = Sarissa.getText(domParser.selectSingleNode("//@severity"));
					var desc = Sarissa.getText(domParser.selectSingleNode("//xls:Description"));
					var pos = Sarissa.getText(domParser.selectSingleNode("//xls:Position"));
					trafficList.push(new TrafficIncident(new Position(pos), desc));
				}
				var reqId = Sarissa.getText(oDomDoc.selectSingleNode("//xls:Response/@requestID"));
				ag[reqId](trafficList);
			}
		}
	};
}
function TrafficIncidentSearchCriteria(position, radius, maximumResponses, minimumSeverity) {
	if (maximumResponses > 100) {
		alert("maximumResponses cannot exceed 100");
		return false;
	}
	this.position = position;
	this.radius = radius;
	this.maximumResponses = maximumResponses;
	this.minimumSeverity = minimumSeverity;
}
function UOM(value) {
	if (value != "KM" && value != "M" && value != "MI" && value != "FT") {
		alert("invalid UOM type,  KM M MI FT");
		return false;
	}
	this.value = value;
	this.toString = function () {
		return this.value;
	};
}
function URL(globeExplorerURL, deCartaURL) {
	if (Credentials.dgkey != null) {
		globeExplorerURL = globeExplorerURL.replace(/key.+?&/, "key=" + Credentials.dgkey + "&");
	}
	this.globeExplorerURL = globeExplorerURL.replace(URL.urlregx, "");
	this.deCartaURL = deCartaURL.replace(URL.urlregx, "");
	this.getDeCartaURL = function () {
		return this.deCartaURL;
	};
	this.getGlobeExplorerURL = function () {
		return this.globeExplorerURL;
	};
}
URL.urlregx = new RegExp("\\amp;", "g");
function Utilities() {
}
Utilities.getElementByTagName = function (dom, namespace, tag) {
	if (navigator.userAgent.toLowerCase().indexOf("safari") != -1) {
		return (dom.getElementsByTagName(tag))[0];
	} else {
		return (dom.getElementsByTagName(namespace + ":" + tag))[0];
	}
};
Utilities.px = "px";
Utilities.LL2VR7 = function (positions) {
	var posPrev = positions[0];
	var tenMil = 10000000;
	var vr = (positions.length) + "," + (positions[0].lat * tenMil) + "," + (positions[0].lon * tenMil);
	for (var i = 1; i < positions.length; i++) {
		var vr1 = Math.round((positions[i].lat - posPrev.lat) * tenMil);
		var vr2 = Math.round((positions[i].lon - posPrev.lon) * tenMil);
		posPrev = positions[i];
		vr += "," + vr1 + "," + vr2;
	}
	return vr;
};
Utilities.timer = function () {
	this.green;
	this.red;
	this.start = function () {
		this.green = new Date().getTime();
	};
	this.stop = function () {
		this.red = new Date().getTime();
		return this.red - this.green;
	};
};
Utilities.ie6 = (document.all && !window.opera && (typeof document.documentElement.style.maxHeight == "undefined")) ? true : false;
Utilities.ie7 = (document.all && !window.opera && (typeof document.documentElement.style.maxHeight != "undefined")) ? true : false;
Utilities.fixPng = function (img) {
	var src = img.src;
	img.src = "img/x.gif";
	if (img.style.height && img.style.width) {
		img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
	} else {
		img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "')";
	}
};
Utilities.getScrollTop = function () {
	var ck = 0;
	if (document.documentElement && document.documentElement.scrollTop) {
		ck = document.documentElement.scrollTop;
	} else {
		if (document.body && document.body.scrollTop) {
			ck = document.body.scrollTop;
		}
	}
	return parseInt(ck);
};
Utilities.getScrollLeft = function () {
	var ce = 0;
	if (document.documentElement && document.documentElement.scrollLeft) {
		ce = document.documentElement.scrollLeft;
	} else {
		if (document.body && document.body.scrollLeft) {
			ce = document.body.scrollLeft;
		}
	}
	return parseInt(ce);
};
Utilities.podParse = function (pod) {
	var days = parseInt(pod.substring(pod.indexOf("P") + 1, pod.indexOf("D")));
	var hours = parseInt(pod.substring(pod.indexOf("T") + 1, pod.indexOf("H")));
	var minutes = parseInt(pod.substring(pod.indexOf("H") + 1, pod.indexOf("M")));
	var seconds = parseInt(pod.substring(pod.indexOf("M") + 1, pod.indexOf("S")));
	if (days > 0) {
		return ((days * 24) + hours) + " hours " + minutes + " minutes ";
	} else {
		if (hours > 0) {
			return hours + " hours " + minutes + " minutes ";
		} else {
			if (minutes > 0) {
				return minutes + " minutes " + seconds + " seconds ";
			} else {
				return seconds + " seconds";
			}
		}
	}
};
Utilities.htmlizeXMLDom = function (oDomDoc) {
	var regx1 = new RegExp("\\>", "g");
	var regx2 = new RegExp("\\<", "g");
	var xmlS = (Sarissa.serialize(oDomDoc));
	xmlS = xmlS.replace(regx1, "&gt;");
	xmlS = xmlS.replace(regx2, "&lt;");
	return "<PRE>" + xmlS + "</PRE>";
};
Utilities.p = function (txt) {
	if (document.getElementById("___decarta_console")) {
		document.getElementById("___decarta_console").innerHTML += "<br/>" + txt;
	} else {
		var n = document.createElement("div");
		n.style.position = "absolute";
		n.style.top = "10px";
		n.style.left = "600px";
		n.style.fontSize = "8pt";
		n.style.border = "1px inset #cccccc";
		n.id = "___decarta_console";
		document.body.appendChild(n);
		n.innerHTML += "<br/>" + txt;
	}
};
Utilities.clearConsole = function () {
	if (document.getElementById("stdout")) {
		document.getElementById("stdout").innerHTML = "";
	}
};
Utilities.getRequestId = function () {
	return Math.floor(Math.random() * 10000000);
};
Utilities.getAbsoluteLeft = function (obj) {
	var left = obj.offsetLeft;
	var parent = obj.offsetParent;
	while (parent != null) {
		left += parent.offsetLeft;
		parent = parent.offsetParent;
	}
	return left;
};
Utilities.getAbsoluteTop = function (obj) {
	var top = obj.offsetTop;
	var parent = obj.offsetParent;
	while (parent != null) {
		top += parent.offsetTop;
		parent = parent.offsetParent;
	}
	return top;
};
Utilities.purge = function (d) {
	var a = d.attributes, i, l, n;
	if (a) {
		l = a.length;
		for (i = 0; i < l; i += 1) {
			n = a[i].name;
			if (typeof d[n] === "function") {
				d[n] = null;
			}
		}
	}
	a = d.childNodes;
	if (a) {
		l = a.length;
		for (i = 0; i < l; i += 1) {
			Utilities.purge(d.childNodes[i]);
		}
	}
};
Utilities.normalizePrefixes = function (XMLText) {
	var reg1 = new RegExp("ns1:", "g");
	var tmp1 = XMLText.replace(reg1, "xls:");
	var reg2 = new RegExp("ns\\d+:", "g");
	var tmp2 = tmp1.replace(reg2, "gml:");
	var reg3 = new RegExp("\\sxmlns:ns\\d+=\"http://www.opengis.net/gml\"", "g");
	var tmp3 = tmp2.replace(reg3, "");
	var reg4 = new RegExp("xmlns:ns1=\"http://www.opengis.net/xls\"", "g");
	var tmp4 = tmp3.replace(reg4, "xmlns:xls=\"http://www.opengis.net/xls\" xmlns:gml=\"http://www.opengis.net/gml\"");
	return tmp4;
};
Utilities.centerContextToBoundingBox = function (pos, radius) {
	var degreesofRadius = radius / 111.111;
	var minLon = (pos.lon - parseFloat(degreesofRadius));
	var maxLon = (pos.lon + parseFloat(degreesofRadius));
	var degreesofLat = degreesofRadius * Math.cos(((pos.lat * Math.PI) / 180));
	var minLat = (pos.lat - parseFloat(degreesofLat));
	var maxLat = (pos.lat + parseFloat(degreesofLat));
	return new BoundingBox(new Position(minLat, minLon), new Position(maxLat, maxLon));
};
Utilities.centerContextToBoundingBoxViewable = function (pos, radiusX, radiusY) {
	var degreesofRadiusX = radiusX / 111.111;
	var degreesofRadiusY = radiusY / 111.111;
	var minLon = (pos.lon - parseFloat(degreesofRadiusX));
	var maxLon = (pos.lon + parseFloat(degreesofRadiusX));
	var degreesofLatY = degreesofRadiusY * Math.cos(((pos.lat * Math.PI) / 180));
	var minLat = (pos.lat - parseFloat(degreesofLatY));
	var maxLat = (pos.lat + parseFloat(degreesofLatY));
	return new BoundingBox(new Position(minLat, minLon), new Position(maxLat, maxLon));
};
Utilities.latLonToPixels = function (bb, pos, pixels) {
	var pixelX = pixels * ((pos.lon - bb.minPosition.lon) / (bb.maxPosition.lon - bb.minPosition.lon));
	var pixelY = pixels * ((bb.maxPosition.lat - pos.lat) / (bb.maxPosition.lat - bb.minPosition.lat));
	return new PixelPoint(Math.round(pixelX), Math.round(pixelY));
};
Utilities.formatRadiusToString = function (radius) {
	if (typeof radius == "number" || typeof radius != "string") {
		radius = radius.toString();
	}
	return radius.replace(new RegExp(","), ".");
};
Utilities.pixelsToLatLon = function (x, y, cs, da, ai, ac, cPos, _presentRadius) {
	try {
		x = cs - x;
		y = da - y;
		var cLat = cPos.getLat();
		var cLon = cPos.getLon();
		var cm = (_presentRadius * 2) / 111.111;
		var cj = cm / (ai * ac);
		var ci = (cm / Math.cos(((cLat * Math.PI) / 180))) / (ai * ac);
		if (y != 0) {
			cLat = "" + (parseFloat(cLat) + parseFloat(y * cj));
		}
		if (x != 0) {
			cLon = "" + (parseFloat(cLon) - parseFloat(x * ci));
		}
		return new Position(cLat, cLon);
	}
	catch (e) {
		alert(e.message);
	}
};
Utilities.positionsToBoundingBox = function (positions) {
	if (!positions || positions.length < 2) {
		throw new Exception("Utilities.positionsToBoundingBox requires at least two positions");
	}
	var bboxTmp;
	for (var i = 0; i < positions.length; i++) {
		if (i == 0) {
			bboxTmp = new BoundingBox(new Position(positions[i].toString()), new Position(positions[i].toString()));
		} else {
			if (positions[i].lat > bboxTmp.getMaxPosition().lat) {
				bboxTmp.getMaxPosition().lat = positions[i].lat;
			}
			if (positions[i].lon > bboxTmp.getMaxPosition().lon) {
				bboxTmp.getMaxPosition().lon = positions[i].lon;
			}
			if (positions[i].lat < bboxTmp.getMinPosition().lat) {
				bboxTmp.getMinPosition().lat = positions[i].lat;
			}
			if (positions[i].lon < bboxTmp.getMinPosition().lon) {
				bboxTmp.getMinPosition().lon = positions[i].lon;
			}
		}
	}
	bboxTmp.heightInDegrees = bboxTmp.maxPosition.lat - bboxTmp.minPosition.lat;
	bboxTmp.widthInDegrees = bboxTmp.maxPosition.lon - bboxTmp.minPosition.lon;
	return bboxTmp;
};
Utilities.pixYDist = function (lat1, lat2, zoom) {
	var zl = zoom.getGXConvertedZoomLevel();
	var sl = Utilities.radsPerPixelAtZoom(256, zl);
	var p1 = Math.round(Utilities.lat2pix(lat1, sl));
	var p2 = Math.round(Utilities.lat2pix(lat2, sl));
	return p1 - p2;
};
Utilities.pixXDist = function (lon1, lon2, scale) {
	var zl = zoom.getGXConvertedZoomLevel();
	var sl = Utilities.radsPerPixelAtZoom(256, zl);
	var p1 = Math.round(Utilities.lon2pix(lon1, sl));
	var p2 = Math.round(Utilities.lon2pix(lon2, sl));
	return -(p1 - p2);
};
Utilities.lat2pix = function (lat, scale) {
	var radLat = (parseFloat(lat) * (2 * Math.PI)) / 360;
	var ecc = 0.08181919084262157;
	var sinPhi = Math.sin(radLat);
	var eSinPhi = ecc * sinPhi;
	var retVal = Math.log(((1 + sinPhi) / (1 - sinPhi)) * Math.pow((1 - eSinPhi) / (1 + eSinPhi), ecc)) / 2;
	return (retVal / scale);
};
Utilities.lon2pix = function (lon, scale) {
	return ((lon / 180) * Math.PI) / scale;
};
Utilities.radsPerPixelAtZoom = function (tileSize, gxZoom) {
	return 2 * Math.PI / (tileSize << gxZoom);
};
Utilities.pix2lon = function (x, scale) {
	return (x * scale) * 180 / Math.PI;
};
Utilities.pix2lat = function (y, scale) {
	var phiEpsilon = 1e-7;
	var phiMaxIter = 12;
	var t = Math.pow(Math.E, -y * scale);
	var prevPhi = Utilities.mercatorUnproject(t);
	var newPhi = Utilities.findRadPhi(prevPhi, t);
	var iterCount = 0;
	while (iterCount < phiMaxIter && Math.abs(prevPhi - newPhi) > phiEpsilon) {
		prevPhi = newPhi;
		newPhi = Utilities.findRadPhi(prevPhi, t);
		iterCount++;
	}
	return newPhi * 180 / Math.PI;
};
Utilities.mercatorUnproject = function (t) {
	return (Math.PI / 2) - 2 * Math.atan(t);
};
Utilities.findRadPhi = function (phi, t) {
	var ecc = 0.08181919084262157;
	var eSinPhi = ecc * Math.sin(phi);
	return (Math.PI / 2) - (2 * Math.atan(t * Math.pow((1 - eSinPhi) / (1 + eSinPhi), ecc / 2)));
};
Utilities.parseRoute = function (oDomDoc) {
	var route = new Route();
	var seq = null;
	try {
		seq = oDomDoc.selectSingleNode("//xls:DetermineRouteResponse/@viaPointSequence").value;
	}
	catch (e) {
	}
	var tt = Utilities.podParse(Sarissa.getText(oDomDoc.selectSingleNode("//xls:TotalTime")));
	var td = oDomDoc.selectSingleNode("//xls:TotalDistance/@value").value;
	var routeInstructions = oDomDoc.selectNodes("//xls:Instruction");
	var points = oDomDoc.selectNodes("//xls:Point");
	var dist = oDomDoc.selectNodes("//xls:distance/@value");
	var dura = oDomDoc.selectNodes("//xls:RouteInstruction/@duration");
	var tour = null;
	try {
		tour = oDomDoc.selectNodes("//xls:RouteInstruction/@tour");
	}
	catch (e) {
	}
	route.TotalTime = tt;
	route.TotalDistance = td;
	route.viaPointSequence = seq;
	route.RouteInstructions = [];
	route.RouteGeometry = [];
	var quoteRemover = new RegExp("'", "g");
	for (var i = 0; i < routeInstructions.length; i++) {
		var tmpInstr = (Sarissa.getText((routeInstructions[i]))).replace(quoteRemover, "");
		var tmpPoint = Sarissa.getText((points[i]));
		var routeIns = new RouteInstruction();
		routeIns.Instruction = tmpInstr;
		routeIns.distance = dist[i].value;
		routeIns.duration = Utilities.podParse(dura[i].value);
		routeIns.position = tmpPoint;
		if (tour && tour.length > 0) {
			routeIns.tour = tour[i].value;
		}
		route.RouteInstructions.push(routeIns);
	}
	var rgeo = oDomDoc.selectSingleNode("//gml:LineString");
	if (rgeo) {
		var geom = rgeo.childNodes;
		for (var i = 0; i < geom.length; i++) {
			route.RouteGeometry.push(new Position(Sarissa.getText(geom[i])));
		}
	}
	return route;
};
function WSXMLTunnel() {
	this.dp = [];
	var self = this;
	this.send = function (xml, cb) {
		var oDomDoc = Sarissa.getDomDocument();
		oDomDoc = (new DOMParser()).parseFromString(Sarissa.serialize(xml), "text/xml");
		oDomDoc.setProperty("SelectionLanguage", "XPath");
		oDomDoc.setProperty("SelectionNamespaces", "xmlns:xls='http://www.opengis.net/xls' xmlns:gml='http://www.opengis.net/gml'");
		var dh = (oDomDoc.selectSingleNode("//xls:Request/@requestID").value);
		self.dp[dh] = cb;
		JSRequest.send(oDomDoc, this.dn);
	};
	this.dn = function (xml) {
		var oDomDoc = Sarissa.getDomDocument();
		oDomDoc = (new DOMParser()).parseFromString(Utilities.normalizePrefixes(xml), "text/xml");
		oDomDoc.setProperty("SelectionLanguage", "XPath");
		oDomDoc.setProperty("SelectionNamespaces", "xmlns:xls='http://www.opengis.net/xls' xmlns:gml='http://www.opengis.net/gml'");
		var dh = (oDomDoc.selectSingleNode("//xls:Response/@requestID").value);
		self.dp[dh](oDomDoc);
	};
}
function XMLRequestFactory() {
	this.overlays = [];
	this.rendering = "server";
	this.routeID = null;
	var self = this;
	this.getHeader = function (methodName, requestId, maximumResponses) {
		var maximumResponses = maximumResponses || "10";
		try {
			var head = Sarissa.getDomDocument();
			var xls = head.createElement("xls:XLS");
			xls.setAttribute("xls:lang", "en");
			xls.setAttribute("version", "1");
			if (Credentials.rel && Credentials.rel != null) {
				xls.setAttribute("rel", Credentials.rel);
			}
			xls.setAttribute("xmlns:xls", "http://www.opengis.net/xls");
			xls.setAttribute("xmlns:gml", "http://www.opengis.net/gml");
			head.appendChild(xls);
			var requestHeader = head.createElement("xls:RequestHeader");
			requestHeader.setAttribute("clientName", Credentials.clientName);
			if (Credentials.mapType == "STREET") {
				requestHeader.setAttribute("configuration", Credentials.configuration);
			} else {
				requestHeader.setAttribute("configuration", Credentials.transparentConfiguration);
			}
			requestHeader.setAttribute("sessionID", Utilities.getRequestId());
			requestHeader.setAttribute("clientPassword", Credentials.clientPassword);
			xls.appendChild(requestHeader);
			var request = head.createElement("xls:Request");
			request.setAttribute("maximumResponses", maximumResponses);
			request.setAttribute("version", "1.0");
			request.setAttribute("requestID", requestId);
			request.setAttribute("methodName", methodName);
			xls.appendChild(request);
			return head;
		}
		catch (e) {
			alert("XMLRequestFactory.this.getHeader\n\n" + e.message);
		}
	};
}
XMLRequestFactory.prototype.createMapAddressRequestDOM = function (freeFormAddressIn, tileSize, horizontalTiles, verticalTiles, requestId, zoomLevel, trafficTime) {
	try {
		var xmlRequestDOM = this.getHeader("PortrayMapRequest", requestId);
		var mapRequest = xmlRequestDOM.createElement("xls:PortrayMapRequest");
		Utilities.getElementByTagName(xmlRequestDOM, "xls", "Request").appendChild(mapRequest);
		var output = xmlRequestDOM.createElement("xls:Output");
		output.setAttribute("width", tileSize);
		output.setAttribute("height", tileSize);
		if (Credentials.mapType == "STREET") {
			output.setAttribute("format", "GIF");
		} else {
			output.setAttribute("format", "PNG");
		}
		output.setAttribute("content", "URL");
		mapRequest.appendChild(output);
		var centerAddress = xmlRequestDOM.createElement("xls:CenterAddress");
		var tileGrid = xmlRequestDOM.createElement("xls:TileGrid");
		tileGrid.setAttribute("rows", verticalTiles);
		tileGrid.setAttribute("columns", horizontalTiles);
		var tileGridLayerGX = xmlRequestDOM.createElement("xls:GridLayer");
		tileGridLayerGX.setAttribute("name", "globexplorer");
		tileGridLayerGX.setAttribute("meta-inf", "zoom=" + zoomLevel);
		var tileGridLayerDC = xmlRequestDOM.createElement("xls:GridLayer");
		tileGridLayerDC.setAttribute("name", "deCarta");
		tileGrid.appendChild(tileGridLayerDC);
		tileGrid.appendChild(tileGridLayerGX);
		var panN = xmlRequestDOM.createElement("xls:Pan");
		panN.setAttribute("direction", "N");
		panN.setAttribute("numTiles", "0");
		var panS = xmlRequestDOM.createElement("xls:Pan");
		panS.setAttribute("direction", "S");
		panS.setAttribute("numTiles", "0");
		var panE = xmlRequestDOM.createElement("xls:Pan");
		panE.setAttribute("direction", "E");
		panE.setAttribute("numTiles", "0");
		var panW = xmlRequestDOM.createElement("xls:Pan");
		panW.setAttribute("direction", "W");
		panW.setAttribute("numTiles", "0");
		tileGrid.appendChild(panN);
		tileGrid.appendChild(panS);
		tileGrid.appendChild(panE);
		tileGrid.appendChild(panW);
		output.appendChild(centerAddress);
		output.appendChild(tileGrid);
		var address2 = xmlRequestDOM.createElement("xls:Address");
		address2.setAttribute("countryCode", freeFormAddressIn.getLocale().getCountry());
		address2.setAttribute("language", freeFormAddressIn.getLocale().getLanguage());
		centerAddress.appendChild(address2);
		var freeFormAddress = xmlRequestDOM.createElement("xls:freeFormAddress");
		freeFormAddressValue = xmlRequestDOM.createTextNode(freeFormAddressIn.toString());
		freeFormAddress.appendChild(freeFormAddressValue);
		address2.appendChild(freeFormAddress);
		if (Credentials.trafficEnabled) {
			var trafficOverLay = xmlRequestDOM.createElement("xls:Overlay");
			var traffic = xmlRequestDOM.createElement("xls:Traffic");
			var flowReporting = xmlRequestDOM.createElement("xls:FlowReporting");
			if (trafficTime) {
				flowReporting.setAttribute("time", trafficTime);
			}
			traffic.appendChild(flowReporting);
			trafficOverLay.appendChild(traffic);
			mapRequest.appendChild(trafficOverLay);
		}
		if (document.all) {
			xmlRequestDOM.setProperty("SelectionLanguage", "XPath");
			xmlRequestDOM.setProperty("SelectionNamespaces", "xmlns:xls='http://www.opengis.net/xls' xmlns:gml='http://www.opengis.net/gml'");
		}
		return xmlRequestDOM;
	}
	catch (e) {
		alert("XMLRequestFactory.prototype.createMapAddressRequestDOM\n\n" + e.message);
	}
};
XMLRequestFactory.prototype.createMapRequestDOM = function (positionIn, tileSize, horizontalTiles, verticalTiles, requestId, zoomLevel, trafficTime) {
	try {
		var xmlRequestDOM = this.getHeader("PortrayMapRequest", requestId);
		var mapRequest = xmlRequestDOM.createElement("xls:PortrayMapRequest");
		Utilities.getElementByTagName(xmlRequestDOM, "xls", "Request").appendChild(mapRequest);
		var output = xmlRequestDOM.createElement("xls:Output");
		output.setAttribute("width", tileSize);
		output.setAttribute("height", tileSize);
		if (Credentials.mapType == "STREET") {
			output.setAttribute("format", "GIF");
		} else {
			output.setAttribute("format", "PNG");
		}
		output.setAttribute("content", "URL");
		mapRequest.appendChild(output);
		this.addOverlays(mapRequest, xmlRequestDOM);
		var centerContext = xmlRequestDOM.createElement("xls:CenterContext");
		centerContext.setAttribute("SRS", "WGS-84");
		var tileGrid = xmlRequestDOM.createElement("xls:TileGrid");
		tileGrid.setAttribute("rows", verticalTiles);
		tileGrid.setAttribute("columns", horizontalTiles);
		var tileGridLayerGX = xmlRequestDOM.createElement("xls:GridLayer");
		tileGridLayerGX.setAttribute("name", "globexplorer");
		tileGridLayerGX.setAttribute("meta-inf", "zoom=" + zoomLevel);
		var tileGridLayerDC = xmlRequestDOM.createElement("xls:GridLayer");
		tileGridLayerDC.setAttribute("name", "deCarta");
		tileGrid.appendChild(tileGridLayerDC);
		tileGrid.appendChild(tileGridLayerGX);
		var panN = xmlRequestDOM.createElement("xls:Pan");
		panN.setAttribute("direction", "N");
		panN.setAttribute("numTiles", "0");
		var panS = xmlRequestDOM.createElement("xls:Pan");
		panS.setAttribute("direction", "S");
		panS.setAttribute("numTiles", "0");
		var panE = xmlRequestDOM.createElement("xls:Pan");
		panE.setAttribute("direction", "E");
		panE.setAttribute("numTiles", "0");
		var panW = xmlRequestDOM.createElement("xls:Pan");
		panW.setAttribute("direction", "W");
		panW.setAttribute("numTiles", "0");
		tileGrid.appendChild(panN);
		tileGrid.appendChild(panS);
		tileGrid.appendChild(panE);
		tileGrid.appendChild(panW);
		output.appendChild(centerContext);
		output.appendChild(tileGrid);
		var radius = xmlRequestDOM.createElement("xls:Radius");
		radius.setAttribute("unit", "KM");
		radiusValue = xmlRequestDOM.createTextNode("0");
		radiusValue = xmlRequestDOM.createTextNode("200");
		radius.appendChild(radiusValue);
		var centerPoint = xmlRequestDOM.createElement("xls:CenterPoint");
		var pos = xmlRequestDOM.createElement("gml:pos");
		posTxt = xmlRequestDOM.createTextNode(positionIn.getLatLon());
		pos.appendChild(posTxt);
		centerPoint.appendChild(pos);
		centerContext.appendChild(centerPoint);
		centerContext.appendChild(radius);
		if (Credentials.trafficEnabled) {
			var trafficOverLay = xmlRequestDOM.createElement("xls:Overlay");
			var traffic = xmlRequestDOM.createElement("xls:Traffic");
			var flowReporting = xmlRequestDOM.createElement("xls:FlowReporting");
			if (trafficTime) {
				flowReporting.setAttribute("time", trafficTime);
			}
			traffic.appendChild(flowReporting);
			trafficOverLay.appendChild(traffic);
			mapRequest.appendChild(trafficOverLay);
		}
		if (document.all) {
			xmlRequestDOM.setProperty("SelectionLanguage", "XPath");
			xmlRequestDOM.setProperty("SelectionNamespaces", "xmlns:xls='http://www.opengis.net/xls' xmlns:gml='http://www.opengis.net/gml'");
		}
		return xmlRequestDOM;
	}
	catch (e) {
		alert("XMLRequestFactory.prototype.createBasicMapRequestDOM\n\n" + e.message);
	}
};
XMLRequestFactory.prototype.zoomMapRequestDOM = function (xmlRequestDOM, n, s, e, w, newZoomLevel, oldZoomLevel) {
	try {
		var oDomDoc = (new DOMParser()).parseFromString(Sarissa.serialize(xmlRequestDOM), "text/xml");
		oDomDoc.setProperty("SelectionLanguage", "XPath");
		oDomDoc.setProperty("SelectionNamespaces", "xmlns:xls='http://www.opengis.net/xls' xmlns:gml='http://www.opengis.net/gml'");
		var mapRequest = oDomDoc.selectSingleNode("//xls:PortrayMapRequest");
		var tmpN = oDomDoc.selectSingleNode("//xls:Pan[@direction='N']");
		tmpN.setAttribute("numTiles", n);
		var tmpS = oDomDoc.selectSingleNode("//xls:Pan[@direction='S']");
		tmpS.setAttribute("numTiles", s);
		var tmpE = oDomDoc.selectSingleNode("//xls:Pan[@direction='E']");
		tmpE.setAttribute("numTiles", e);
		var tmpW = oDomDoc.selectSingleNode("//xls:Pan[@direction='W']");
		tmpW.setAttribute("numTiles", w);
		if (Credentials.mapType != "STREET") {
			var tmpConf = (oDomDoc.selectSingleNode("//xls:RequestHeader"));
			tmpConf.setAttribute("configuration", Credentials.transparentConfiguration);
		} else {
			var tmpConf = (oDomDoc.selectSingleNode("//xls:RequestHeader"));
			tmpConf.setAttribute("configuration", Credentials.configuration);
		}
		var tmpFormat = (oDomDoc.selectSingleNode("//xls:Output"));
		if (Credentials.mapType == "STREET") {
			tmpFormat.setAttribute("format", "GIF");
		} else {
			tmpFormat.setAttribute("format", "PNG");
		}
		var metaInf = oDomDoc.selectSingleNode("//xls:GridLayer[@name='globexplorer']");
		metaInf.setAttribute("meta-inf", "zoom=" + newZoomLevel + ":" + oldZoomLevel);
		return oDomDoc;
	}
	catch (e) {
		alert("XMLRequestFactory.prototype.zoomMapRequestDOM\n\n" + e.message);
	}
};
XMLRequestFactory.prototype.changeMapStyleRequestDOM = function (xmlRequestDOM, configuration, n, s, e, w) {
	try {
		Credentials.configuration = configuration;
		var oDomDoc = (new DOMParser()).parseFromString(Sarissa.serialize(xmlRequestDOM), "text/xml");
		oDomDoc.setProperty("SelectionLanguage", "XPath");
		oDomDoc.setProperty("SelectionNamespaces", "xmlns:xls='http://www.opengis.net/xls' xmlns:gml='http://www.opengis.net/gml'");
		var imgSettings = oDomDoc.selectSingleNode("//xls:RequestHeader/@configuration");
		imgSettings.value = configuration;
		var requestHeader = oDomDoc.selectSingleNode("//xls:RequestHeader/@sessionID");
		requestHeader.value = Utilities.getRequestId();
		var tmpN = oDomDoc.selectSingleNode("//xls:Pan[@direction='N']");
		tmpN.setAttribute("numTiles", n);
		var tmpS = oDomDoc.selectSingleNode("//xls:Pan[@direction='S']");
		tmpS.setAttribute("numTiles", s);
		var tmpE = oDomDoc.selectSingleNode("//xls:Pan[@direction='E']");
		tmpE.setAttribute("numTiles", e);
		var tmpW = oDomDoc.selectSingleNode("//xls:Pan[@direction='W']");
		tmpW.setAttribute("numTiles", w);
		return oDomDoc;
	}
	catch (e) {
		alert("XMLRequestFactory.prototype.zoomMapRequestDOM\n\n" + e.message);
	}
};
XMLRequestFactory.prototype.createGeocodeRequestDOM = function (address, requestId) {
	try {
		var xmlRequestDOM = this.getHeader("GeocodeRequest", requestId);
		var geocodeRequest = xmlRequestDOM.createElement("xls:GeocodeRequest");
		geocodeRequest.setAttribute("returnFreeForm", "true");
		Utilities.getElementByTagName(xmlRequestDOM, "xls", "Request").appendChild(geocodeRequest);
		var address2 = xmlRequestDOM.createElement("xls:Address");
		address2.setAttribute("countryCode", address.getLocale().getCountry());
		address2.setAttribute("language", address.getLocale().getLanguage());
		geocodeRequest.appendChild(address2);
		var freeFormAddress = xmlRequestDOM.createElement("xls:freeFormAddress");
		freeFormAddressValue = xmlRequestDOM.createTextNode(address.toString());
		freeFormAddress.appendChild(freeFormAddressValue);
		address2.appendChild(freeFormAddress);
		return xmlRequestDOM;
	}
	catch (e) {
		alert("XMLRequestFactory.prototype.getGeocodeRequestDOM\n\n" + e.message);
	}
};
XMLRequestFactory.prototype.createReverseGeocodeRequestDOM = function (positionIn, requestId) {
	try {
		var xmlRequestDOM = this.getHeader("ReverseGeocodeRequest", requestId);
		var revGeoRequest = xmlRequestDOM.createElement("xls:ReverseGeocodeRequest");
		revGeoRequest.setAttribute("returnFreeForm", "true");
		Utilities.getElementByTagName(xmlRequestDOM, "xls", "Request").appendChild(revGeoRequest);
		var position = xmlRequestDOM.createElement("xls:Position");
		var point = xmlRequestDOM.createElement("gml:Point");
		var pos = xmlRequestDOM.createElement("gml:pos");
		var positionTxt = xmlRequestDOM.createTextNode(positionIn.getLatLon());
		pos.appendChild(positionTxt);
		point.appendChild(pos);
		position.appendChild(point);
		revGeoRequest.appendChild(position);
		var reverseGeocodePreference = xmlRequestDOM.createElement("xls:ReverseGeocodePreference");
		var reverseGeocodePreferenceTxt = xmlRequestDOM.createTextNode("StreetAddress");
		reverseGeocodePreference.appendChild(reverseGeocodePreferenceTxt);
		revGeoRequest.appendChild(reverseGeocodePreference);
		return xmlRequestDOM;
	}
	catch (e) {
		alert("XMLRequestFactory.prototype.createReverseGeocodeRequestDOM\n\n" + e.message);
	}
};
XMLRequestFactory.prototype.createCenterContext = function (centerPosition, radiusIn) {
	var xmlRequestDOM = Sarissa.getDomDocument();
	var centerContext = xmlRequestDOM.createElement("xls:CenterContext");
	centerContext.setAttribute("SRS", "WGS-84");
	var radius = xmlRequestDOM.createElement("xls:Radius");
	radius.setAttribute("unit", "KM");
	radiusValue = xmlRequestDOM.createTextNode(Utilities.formatRadiusToString(radiusIn));
	radius.appendChild(radiusValue);
	var centerPoint = xmlRequestDOM.createElement("xls:CenterPoint");
	var pos = xmlRequestDOM.createElement("gml:pos");
	posTxt = xmlRequestDOM.createTextNode(centerPosition);
	pos.appendChild(posTxt);
	centerPoint.appendChild(pos);
	centerContext.appendChild(centerPoint);
	centerContext.appendChild(radius);
	return centerContext;
};
XMLRequestFactory.prototype.createRouteGeometryRequestDOM = function (positionList, requestId, routePreference, expectedStartTime, returnGeometry) {
	try {
		var xmlRequestDOM = this.getHeader("DetermineRouteRequest", requestId);
		var routeRequest = xmlRequestDOM.createElement("xls:DetermineRouteRequest");
		routeRequest.setAttribute("distanceUnit", routePreference.uom);
		routeRequest.setAttribute("routeQueryType", routePreference.routeQueryType);
		Utilities.getElementByTagName(xmlRequestDOM, "xls", "Request").appendChild(routeRequest);
		var routePlan = xmlRequestDOM.createElement("xls:RoutePlan");
		if (Credentials.trafficEnabled) {
			routePlan.setAttribute("useRealTimeTraffic", "true");
		}
		if (routePreference.optimized) {
			routePlan.setAttribute("optimize", "true");
		}
		if (Credentials.trafficEnabled && expectedStartTime) {
			routePlan.setAttribute("expectedStartTime", (expectedStartTime.replace("-07:00", "-06:00")));
		}
		routeRequest.appendChild(routePlan);
		var routePref = xmlRequestDOM.createElement("xls:RoutePreference");
		var routePreferenceText = xmlRequestDOM.createTextNode(routePreference.routePreference);
		routePref.appendChild(routePreferenceText);
		routePlan.appendChild(routePref);
		var wayPointList = xmlRequestDOM.createElement("xls:WayPointList");
		for (var i = 0; i < positionList.length; i++) {
			if (i == 0) {
				var startPoint = xmlRequestDOM.createElement("xls:StartPoint");
				var position = xmlRequestDOM.createElement("xls:Position");
				var point = xmlRequestDOM.createElement("gml:Point");
				var pos = xmlRequestDOM.createElement("gml:pos");
				var positionTxt = xmlRequestDOM.createTextNode(positionList[i]);
				pos.appendChild(positionTxt);
				point.appendChild(pos);
				position.appendChild(point);
				startPoint.appendChild(position);
				wayPointList.appendChild(startPoint);
			} else {
				if (i > 0 && i < (positionList.length - 1)) {
					var wayPoint = xmlRequestDOM.createElement("xls:ViaPoint");
					var position = xmlRequestDOM.createElement("xls:Position");
					var point = xmlRequestDOM.createElement("gml:Point");
					var pos = xmlRequestDOM.createElement("gml:pos");
					var positionTxt = xmlRequestDOM.createTextNode(positionList[i]);
					pos.appendChild(positionTxt);
					point.appendChild(pos);
					position.appendChild(point);
					wayPoint.appendChild(position);
					wayPointList.appendChild(wayPoint);
				} else {
					if (i == (positionList.length - 1)) {
						var endPoint = xmlRequestDOM.createElement("xls:EndPoint");
						var position = xmlRequestDOM.createElement("xls:Position");
						var point = xmlRequestDOM.createElement("gml:Point");
						var pos = xmlRequestDOM.createElement("gml:pos");
						var positionTxt = xmlRequestDOM.createTextNode(positionList[i]);
						pos.appendChild(positionTxt);
						point.appendChild(pos);
						position.appendChild(point);
						endPoint.appendChild(position);
						wayPointList.appendChild(endPoint);
					}
				}
			}
		}
		routePlan.appendChild(wayPointList);
		var routeInstructionsRequest = xmlRequestDOM.createElement("xls:RouteInstructionsRequest");
		routeInstructionsRequest.setAttribute("providePoint", "true");
		var routeGeometryRequest = xmlRequestDOM.createElement("xls:RouteGeometryRequest");
		if (routePreference.rules != null) {
			routeInstructionsRequest.setAttribute("rules", routePreference.rules);
		}
		if (!returnGeometry) {
			routeGeometryRequest.setAttribute("returnRouteIDOnly", "true");
		}
		routeRequest.appendChild(routeInstructionsRequest);
		routeRequest.appendChild(routeGeometryRequest);
		return xmlRequestDOM;
	}
	catch (e) {
		alert("XMLRequestFactory.prototype.createRouteGeometryRequestDOM\n\n" + e.message);
	}
};
XMLRequestFactory.prototype.createRouteMapDOM = function (centerContext, routeID, requestId, tileSize, horizontalTiles, verticalTiles, zoomLevel, routePreference, trafficTime) {
	try {
		var xmlRequestDOM = this.getHeader("PortrayMapRequest", requestId);
		var mapRequest = xmlRequestDOM.createElement("xls:PortrayMapRequest");
		mapRequest.setAttribute("fitOverlays", "false");
		Utilities.getElementByTagName(xmlRequestDOM, "xls", "Request").appendChild(mapRequest);
		var output = xmlRequestDOM.createElement("xls:Output");
		output.setAttribute("width", tileSize);
		output.setAttribute("height", tileSize);
		if (Credentials.mapType == "STREET") {
			output.setAttribute("format", "GIF");
		} else {
			output.setAttribute("format", "PNG");
		}
		output.setAttribute("content", "URL");
		output.appendChild(centerContext);
		var overLay = xmlRequestDOM.createElement("xls:Overlay");
		routeID.setAttribute("preference", routePreference.routePreference);
		this.routeID = routeID;
		overLay.appendChild(routeID.cloneNode(true));
		mapRequest.appendChild(output);
		mapRequest.appendChild(overLay);
		var tileGrid = xmlRequestDOM.createElement("xls:TileGrid");
		tileGrid.setAttribute("rows", verticalTiles);
		tileGrid.setAttribute("columns", horizontalTiles);
		var tileGridLayerGX = xmlRequestDOM.createElement("xls:GridLayer");
		tileGridLayerGX.setAttribute("name", "globexplorer");
		tileGridLayerGX.setAttribute("meta-inf", "zoom=" + zoomLevel);
		var tileGridLayerDC = xmlRequestDOM.createElement("xls:GridLayer");
		tileGridLayerDC.setAttribute("name", "deCarta");
		tileGrid.appendChild(tileGridLayerDC);
		tileGrid.appendChild(tileGridLayerGX);
		var panN = xmlRequestDOM.createElement("xls:Pan");
		panN.setAttribute("direction", "N");
		panN.setAttribute("numTiles", "0");
		var panS = xmlRequestDOM.createElement("xls:Pan");
		panS.setAttribute("direction", "S");
		panS.setAttribute("numTiles", "0");
		var panE = xmlRequestDOM.createElement("xls:Pan");
		panE.setAttribute("direction", "E");
		panE.setAttribute("numTiles", "0");
		var panW = xmlRequestDOM.createElement("xls:Pan");
		panW.setAttribute("direction", "W");
		panW.setAttribute("numTiles", "0");
		tileGrid.appendChild(panN);
		tileGrid.appendChild(panS);
		tileGrid.appendChild(panE);
		tileGrid.appendChild(panW);
		output.appendChild(tileGrid);
		if (Credentials.trafficEnabled) {
			var trafficOverLay = xmlRequestDOM.createElement("xls:Overlay");
			var traffic = xmlRequestDOM.createElement("xls:Traffic");
			var flowReporting = xmlRequestDOM.createElement("xls:FlowReporting");
			if (trafficTime) {
				flowReporting.setAttribute("time", trafficTime);
			}
			traffic.appendChild(flowReporting);
			trafficOverLay.appendChild(traffic);
			mapRequest.appendChild(trafficOverLay);
		}
		return xmlRequestDOM;
	}
	catch (e) {
		alert("XMLRequestFactory.prototype.createRouteMapDOM \n\n" + e.message);
	}
};
XMLRequestFactory.prototype.createPOIRequestDOM = function (searchCriteria, reqId) {
	var xmlRequestDOM = this.getHeader("DirectoryRequest", reqId, searchCriteria.maximumResponses);
	var poiRequest = xmlRequestDOM.createElement("xls:DirectoryRequest");
	if (searchCriteria.database != null) {
		poiRequest.setAttribute("database", searchCriteria.database);
	}
	Utilities.getElementByTagName(xmlRequestDOM, "xls", "Request").appendChild(poiRequest);
	poiRequest.setAttribute("sortDirection", "Ascending");
	poiRequest.setAttribute("sortCriteria", "Distance");
	var poiLocation = xmlRequestDOM.createElement("xls:POILocation");
	poiRequest.appendChild(poiLocation);
	var withinDist = xmlRequestDOM.createElement("xls:WithinDistance");
	poiLocation.appendChild(withinDist);
	var maxDist = xmlRequestDOM.createElement("xls:MaximumDistance");
	maxDist.setAttribute("value", searchCriteria.radius.distance);
	maxDist.setAttribute("uom", searchCriteria.radius.uom.value);
	var minDist = xmlRequestDOM.createElement("xls:MinimumDistance");
	minDist.setAttribute("unit", searchCriteria.radius.uom.value);
	minDist.setAttribute("value", "0");
	var POI = xmlRequestDOM.createElement("xls:POI");
	POI.setAttribute("ID", "1");
	var point = xmlRequestDOM.createElement("gml:Point");
	var pos = xmlRequestDOM.createElement("gml:pos");
	var posTxt = xmlRequestDOM.createTextNode(searchCriteria.position.toString());
	pos.appendChild(posTxt);
	point.appendChild(pos);
	POI.appendChild(point);
	withinDist.appendChild(POI);
	withinDist.appendChild(minDist);
	withinDist.appendChild(maxDist);
	var poiProperties = xmlRequestDOM.createElement("xls:POIProperties");
	var poiProperty = xmlRequestDOM.createElement("xls:POIProperty");
	poiProperties.appendChild(poiProperty);
	poiRequest.appendChild(poiProperties);
	poiProperty.setAttribute("name", "POIName");
	poiProperty.setAttribute("value", searchCriteria.queryString);
	return xmlRequestDOM;
};
XMLRequestFactory.prototype.createRUOKRequestDOM = function (reqId) {
	var xmlRequestDOM = this.getHeader("RuokRequest", reqId);
	var RUOKRequest = xmlRequestDOM.createElement("xls:RUOKRequest");
	Utilities.getElementByTagName(xmlRequestDOM, "xls", "Request").appendChild(RUOKRequest);
	return xmlRequestDOM;
};
XMLRequestFactory.prototype.addOverlays = function (mapRequest, xmlRequestDOM) {
	if (this.rendering != "server") {
		return;
	}
	if (this.routeID != null) {
		var overLay = xmlRequestDOM.createElement("xls:Overlay");
		overLay.appendChild(this.routeID);
		mapRequest.appendChild(overLay);
	}
	for (var i = 0; i < this.overlays.length; i++) {
		if (!this.overlays[i]) {
			continue;
		}
		var ovr = this.overlays[i];
		var overlay = xmlRequestDOM.createElement("xls:Overlay");
		var shape = xmlRequestDOM.createElement("xls:Shape");
		overlay.appendChild(shape);
		shape.setAttribute("type", ovr.type);
		shape.setAttribute("opacity", ovr.opacity);
		shape.setAttribute("color", ovr.fillColor + "_" + ovr.borderColor);
		shape.setAttribute("style", ovr.borderStyle);
		if (ovr.type == "line") {
			shape.setAttribute("width", ovr.width + "_" + ovr.borderWidth);
		} else {
			shape.setAttribute("width", ovr.borderWidth);
		}
		if (ovr.type == "circle") {
			shape.setAttribute("pointspec", "LL");
			shape.setAttribute("radius", ovr.radius.uomdds + ovr.radius.distance);
			var shapePos = xmlRequestDOM.createTextNode(ovr.position.lat + "," + ovr.position.lon);
		} else {
			try {
				var vr = Utilities.LL2VR7(ovr.positions);
				ovr.VR7 = vr;
			}
			catch (e) {
				continue;
			}
			if (ovr.type == "line") {
				shape.setAttribute("pointspec", "VR7");
			} else {
				shape.setAttribute("pointspec", "VR7PG");
			}
			var shapePos = xmlRequestDOM.createTextNode(vr);
		}
		shape.appendChild(shapePos);
		mapRequest.appendChild(overlay);
	}
};
XMLRequestFactory.prototype.createTrafficIncidentRequestDOM = function (searchCriteria, reqId) {
	var xmlRequestDOM = this.getHeader("TrafficRequest", reqId, searchCriteria.maxiumResponses);
	var traffic = xmlRequestDOM.createElement("xls:TrafficRequest");
	Utilities.getElementByTagName(xmlRequestDOM, "xls", "Request").appendChild(traffic);
	var incidentReporting = xmlRequestDOM.createElement("xls:IncidentReporting");
	incidentReporting.setAttribute("minimumSeverity", searchCriteria.minimumSeverity);
	traffic.appendChild(incidentReporting);
	var centerContext = xmlRequestDOM.createElement("xls:CenterContext");
	centerContext.setAttribute("SRS", "WGS-84");
	var radius = xmlRequestDOM.createElement("xls:Radius");
	radius.setAttribute("unit", searchCriteria.radius.uom.value);
	radiusValue = xmlRequestDOM.createTextNode(searchCriteria.radius.distance);
	radius.appendChild(radiusValue);
	var centerPoint = xmlRequestDOM.createElement("xls:CenterPoint");
	var pos = xmlRequestDOM.createElement("gml:pos");
	posTxt = xmlRequestDOM.createTextNode(searchCriteria.position);
	pos.appendChild(posTxt);
	centerPoint.appendChild(pos);
	centerContext.appendChild(centerPoint);
	centerContext.appendChild(radius);
	traffic.appendChild(centerContext);
	return xmlRequestDOM;
};
function ZoomController(selected, color, checkedSrc, uncheckedSrc, topSrc, bottomSrc) {
	if (selected && selected < 1 || selected > 17) {
		throw new Exception("Error instantiating ZoomController, invalid initial" + " value for ZoomController must be between 1 and 17");
		return false;
	}
	this.uncheckedSrc = uncheckedSrc || "img/zoom.png";
	this.checkedSrc = checkedSrc || "img/zoomChecked.png";
	this.color = color || "";
	this.selected = selected || 5;
	this.zoomLevels = 17;
	this.topCap = document.createElement("IMG");
	this.topCap.src = topSrc || "img/zoomTop.png";
	this.topCap.style.height = "17px";
	this.topCap.style.width = "17px";
	this.topCap.style.padding = "0px";
	if (Utilities.ie6) {
		Utilities.fixPng(this.topCap);
	}
	this.bottomCap = document.createElement("IMG");
	this.bottomCap.src = bottomSrc || "img/zoomBottom.png";
	if (!bottomSrc) {
		this.bottomCap.style.height = "17px";
	}
	if (!bottomSrc) {
		this.bottomCap.style.width = "17px";
	}
	if (Utilities.ie6) {
		Utilities.fixPng(this.bottomCap);
	}
	this.bottomCap.style.padding = "0px";
	var ar = new Array();
	var bs;
	var bo;
	var self = this;
	this.zoomer;
	this.map;
	this.initialize = function (map1) {
		self.map = map1;
		for (var i = 1; i <= self.zoomLevels; i++) {
			var tmp = document.createElement("IMG");
			tmp.style.height = "9px";
			tmp.style.width = "17px";
			tmp.id = "" + i;
			tmp.src = self.uncheckedSrc;
			tmp.checkedSrc = self.checkedSrc;
			tmp.onclick = function (e) {
				e = e || event;
				e.stoppropagation ? e.stoppropagation() : e.cancelBubble = true;
				if (map1.getZoomLck()) {
					return false;
				}
				clear();
				this.src = this.checkedSrc;
				map1.zoomMap(this.id);
			};
			ar.push(tmp);
		}
		self.zoomer = document.createElement("DIV");
		self.zoomer.style.cursor = "pointer";
		self.zoomer.id = "zoom";
		self.zoomer.style.width = "20px";
		self.zoomer.style.top = "1px";
		self.zoomer.style.left = "1px";
		self.zoomer.style.opacity = 50;
		self.zoomer.innerHTML = "";
		self.zoomer.style.filter = "alpha(opacity=80)";
		self.zoomer.style.opacity = 0.8;
		self.zoomer.style.display = "block";
		self.zoomer.style.position = "absolute";
		self.zoomer.style.zIndex = 9999;
		self.zoomer.appendChild(self.topCap);
		for (var i = 0; i < ar.length; i++) {
			self.zoomer.appendChild(ar[i]);
		}
		self.zoomer.appendChild(self.bottomCap);
		map1.mapDiv.appendChild(self.zoomer);
		self.topCap.onclick = function (e) {
			e = e || event;
			e.stoppropagation ? e.stoppropagation() : e.cancelBubble = true;
			self.zoomInOneLevel();
		};
		self.bottomCap.onclick = function (e) {
			e = e || event;
			e.stoppropagation ? e.stoppropagation() : e.cancelBubble = true;
			self.zoomOutOneLevel();
		};
		this.setZoomLevel(self.selected);
	};
	this.setZoomButtonImages = function (checked, unchecked) {
		this.checkedSrc = checked;
		this.uncheckedSrc = unchecked;
		for (var i = 0; i < ar.length; i++) {
			ar[i].src = unchecked;
		}
		if (self.selected) {
			ar[self.selected - 1].src = checked;
		}
	};
	this.setColor = function (newColor) {
		this.zoomer.style.backgroundColor = newColor;
	};
	this.show = function () {
		this.zoomer.style.display = "block";
	};
	this.hide = function () {
		this.zoomer.style.display = "none";
	};
	this.getRadius = function () {
		return bs;
	};
	this.setRadius = function (r) {
		bs = r;
		var grid = self.map.getGridSize().split(" ");
		var y = grid[0];
		var x = grid[1];
		if (y == x) {
			bo = r;
		} else {
			bo = (bs / y) * x;
		}
	};
	this.getRadiusX = function () {
		return bo;
	};
	this.setRadiusX = function (r) {
		bo = r;
	};
	this.getZoomLevel = function () {
		return self.selected;
	};
	this.setZoomLevel = function (level) {
		if (selected && selected < 1 || selected > 17) {
			throw new Exception("Error calling setZoomLevel, level must be between 1 and 17");
			return false;
		}
		self.selected = level;
		clear();
		for (var i = 0; i < self.zoomLevels; i++) {
			if (ar[i].id == level) {
				ar[i].src = self.checkedSrc;
			}
			if (Utilities.ie6) {
				Utilities.fixPng(ar[i]);
			}
		}
	};
	this.getGXConvertedZoomLevel = function () {
		return Math.abs(21 - self.selected);
	};
	this.zoomToNewLevel = function (level) {
		if (selected && selected < 1 || selected > 17) {
			throw new Exception("Error calling zoomToNewLevel, level must be between 1 and 17");
			return false;
		}
		clear();
		for (var i = 0; i < self.zoomLevels; i++) {
			if (ar[i].id == level) {
				ar[i].src = self.checkedSrc;
			}
			if (Utilities.ie6) {
				Utilities.fixPng(ar[i]);
			}
		}
		self.map.zoomMap(level);
	};
	this.zoomInOneLevel = function () {
		if (self.selected == 1) {
			return false;
		}
		clear();
		for (var i = 0; i < self.zoomLevels; i++) {
			if (ar[i].id == self.selected) {
				ar[i].src = self.checkedSrc;
			}
		}
		self.map.zoomMap(parseInt(self.selected) - 1);
	};
	this.zoomOutOneLevel = function () {
		if (self.selected == 17) {
			return false;
		}
		clear();
		for (var i = 0; i < self.zoomLevels; i++) {
			if (ar[i].id == self.selected) {
				ar[i].src = self.checkedSrc;
			}
		}
		self.map.zoomMap(parseInt(self.selected) + 1);
	};
	this.getZoomLevelToFitBoundingBox = function (boundingBox) {
		var tmpY = parseInt(self.map.mapDiv.style.height) / 2;
		var tmpX = parseInt(self.map.mapDiv.style.width) / 2;
		for (var gxZoom = 20; gxZoom > 0; --gxZoom) {
			var scale = Utilities.radsPerPixelAtZoom(256, gxZoom);
			var pixelsY = Utilities.lat2pix(boundingBox.getCenterPosition().getLat(), scale);
			var pixelsX = Utilities.lon2pix(boundingBox.getCenterPosition().getLon(), scale);
			var maxlat = Utilities.pix2lat(pixelsY + tmpY, scale);
			var maxlon = Utilities.pix2lon(pixelsX + tmpX, scale);
			var minlat = Utilities.pix2lat(pixelsY - tmpY, scale);
			var minlon = Utilities.pix2lon(pixelsX - tmpX, scale);
			var gxbbox = new BoundingBox(new Position(minlat, minlon), new Position(maxlat, maxlon));
			if (gxbbox.contains(boundingBox.minPosition) && gxbbox.contains(boundingBox.maxPosition)) {
				return Math.abs(21 - gxZoom);
				break;
			}
		}
	};
	this.getZoomLevelToFitPositions = function (positions) {
		var bbox = Utilities.positionsToBoundingBox(positions);
		return self.getZoomLevelToFitBoundingBox(bbox);
	};
	this.setZoomValue = function (level) {
		self.setZoomLevel(level);
	};
	function clear() {
		for (var i = 0; i < ar.length; i++) {
			ar[i].src = self.uncheckedSrc;
		}
	}
}

// excanvas
if (!window.CanvasRenderingContext2D) {
	(function () {
		var I = Math, i = I.round, L = I.sin, M = I.cos, m = 10, A = m / 2, Q = {init:function (a) {
			var b = a || document;
			if (/MSIE/.test(navigator.userAgent) && !window.opera) {
				var c = this;
				b.attachEvent("onreadystatechange", function () {
					c.r(b);
				});
			}
		}, r:function (a) {
			if (a.readyState == "complete") {
				if (!a.namespaces["s"]) {
					a.namespaces.add("g_vml_", "urn:schemas-microsoft-com:vml");
				}
				var b = a.createStyleSheet();
				b.cssText = "canvas{display:inline-block;overflow:hidden;text-align:left;width:300px;height:150px}g_vml_\\:*{behavior:url(#default#VML)}";
				var c = a.getElementsByTagName("canvas");
				for (var d = 0; d < c.length; d++) {
					if (!c[d].getContext) {
						this.initElement(c[d]);
					}
				}
			}
		}, q:function (a) {
			var b = a.outerHTML, c = a.ownerDocument.createElement(b);
			if (b.slice(-2) != "/>") {
				var d = "/" + a.tagName, e;
				while ((e = a.nextSibling) && e.tagName != d) {
					e.removeNode();
				}
				if (e) {
					e.removeNode();
				}
			}
			a.parentNode.replaceChild(c, a);
			return c;
		}, initElement:function (a) {
			a = this.q(a);
			a.getContext = function () {
				if (this.l) {
					return this.l;
				}
				return this.l = new K(this);
			};
			a.attachEvent("onpropertychange", V);
			a.attachEvent("onresize", W);
			var b = a.attributes;
			if (b.width && b.width.specified) {
				a.style.width = b.width.nodeValue + "px";
			} else {
				a.width = a.clientWidth;
			}
			if (b.height && b.height.specified) {
				a.style.height = b.height.nodeValue + "px";
			} else {
				a.height = a.clientHeight;
			}
			return a;
		}};
		function V(a) {
			var b = a.srcElement;
			switch (a.propertyName) {
			  case "width":
				b.style.width = b.attributes.width.nodeValue + "px";
				b.getContext().clearRect();
				break;
			  case "height":
				b.style.height = b.attributes.height.nodeValue + "px";
				b.getContext().clearRect();
				break;
			}
		}
		function W(a) {
			var b = a.srcElement;
			if (b.firstChild) {
				b.firstChild.style.width = b.clientWidth + "px";
				b.firstChild.style.height = b.clientHeight + "px";
			}
		}
		Q.init();
		var R = [];
		for (var E = 0; E < 16; E++) {
			for (var F = 0; F < 16; F++) {
				R[E * 16 + F] = E.toString(16) + F.toString(16);
			}
		}
		function J() {
			return [[1, 0, 0], [0, 1, 0], [0, 0, 1]];
		}
		function G(a, b) {
			var c = J();
			for (var d = 0; d < 3; d++) {
				for (var e = 0; e < 3; e++) {
					var g = 0;
					for (var h = 0; h < 3; h++) {
						g += a[d][h] * b[h][e];
					}
					c[d][e] = g;
				}
			}
			return c;
		}
		function N(a, b) {
			b.fillStyle = a.fillStyle;
			b.lineCap = a.lineCap;
			b.lineJoin = a.lineJoin;
			b.lineWidth = a.lineWidth;
			b.miterLimit = a.miterLimit;
			b.shadowBlur = a.shadowBlur;
			b.shadowColor = a.shadowColor;
			b.shadowOffsetX = a.shadowOffsetX;
			b.shadowOffsetY = a.shadowOffsetY;
			b.strokeStyle = a.strokeStyle;
			b.d = a.d;
			b.e = a.e;
		}
		function O(a) {
			var b, c = 1;
			a = String(a);
			if (a.substring(0, 3) == "rgb") {
				var d = a.indexOf("(", 3), e = a.indexOf(")", d + 1), g = a.substring(d + 1, e).split(",");
				b = "#";
				for (var h = 0; h < 3; h++) {
					b += R[Number(g[h])];
				}
				if (g.length == 4 && a.substr(3, 1) == "a") {
					c = g[3];
				}
			} else {
				b = a;
			}
			return [b, c];
		}
		function S(a) {
			switch (a) {
			  case "butt":
				return "flat";
			  case "round":
				return "round";
			  case "square":
			  default:
				return "square";
			}
		}
		function K(a) {
			this.a = J();
			this.m = [];
			this.k = [];
			this.c = [];
			this.strokeStyle = "#000";
			this.fillStyle = "#000";
			this.lineWidth = 1;
			this.lineJoin = "miter";
			this.lineCap = "butt";
			this.miterLimit = m * 1;
			this.globalAlpha = 1;
			this.canvas = a;
			var b = a.ownerDocument.createElement("div");
			b.style.width = a.clientWidth + "px";
			b.style.height = a.clientHeight + "px";
			b.style.overflow = "hidden";
			b.style.position = "absolute";
			a.appendChild(b);
			this.j = b;
			this.d = 1;
			this.e = 1;
		}
		var j = K.prototype;
		j.clearRect = function () {
			this.j.innerHTML = "";
			this.c = [];
		};
		j.beginPath = function () {
			this.c = [];
		};
		j.moveTo = function (a, b) {
			this.c.push({type:"moveTo", x:a, y:b});
			this.f = a;
			this.g = b;
		};
		j.lineTo = function (a, b) {
			this.c.push({type:"lineTo", x:a, y:b});
			this.f = a;
			this.g = b;
		};
		j.bezierCurveTo = function (a, b, c, d, e, g) {
			this.c.push({type:"bezierCurveTo", cp1x:a, cp1y:b, cp2x:c, cp2y:d, x:e, y:g});
			this.f = e;
			this.g = g;
		};
		j.quadraticCurveTo = function (a, b, c, d) {
			var e = this.f + 0.6666666666666666 * (a - this.f), g = this.g + 0.6666666666666666 * (b - this.g), h = e + (c - this.f) / 3, l = g + (d - this.g) / 3;
			this.bezierCurveTo(e, g, h, l, c, d);
		};
		j.arc = function (a, b, c, d, e, g) {
			c *= m;
			var h = g ? "at" : "wa", l = a + M(d) * c - A, n = b + L(d) * c - A, o = a + M(e) * c - A, f = b + L(e) * c - A;
			if (l == o && !g) {
				l += 0.125;
			}
			this.c.push({type:h, x:a, y:b, radius:c, xStart:l, yStart:n, xEnd:o, yEnd:f});
		};
		j.rect = function (a, b, c, d) {
			this.moveTo(a, b);
			this.lineTo(a + c, b);
			this.lineTo(a + c, b + d);
			this.lineTo(a, b + d);
			this.closePath();
		};
		j.strokeRect = function (a, b, c, d) {
			this.beginPath();
			this.moveTo(a, b);
			this.lineTo(a + c, b);
			this.lineTo(a + c, b + d);
			this.lineTo(a, b + d);
			this.closePath();
			this.stroke();
		};
		j.fillRect = function (a, b, c, d) {
			this.beginPath();
			this.moveTo(a, b);
			this.lineTo(a + c, b);
			this.lineTo(a + c, b + d);
			this.lineTo(a, b + d);
			this.closePath();
			this.fill();
		};
		j.createLinearGradient = function (a, b, c, d) {
			var e = new H("gradient");
			return e;
		};
		j.createRadialGradient = function (a, b, c, d, e, g) {
			var h = new H("gradientradial");
			h.n = c;
			h.o = g;
			h.i.x = a;
			h.i.y = b;
			return h;
		};
		j.drawImage = function (a, b) {
			var c, d, e, g, h, l, n, o, f = a.runtimeStyle.width, k = a.runtimeStyle.height;
			a.runtimeStyle.width = "auto";
			a.runtimeStyle.height = "auto";
			var q = a.width, r = a.height;
			a.runtimeStyle.width = f;
			a.runtimeStyle.height = k;
			if (arguments.length == 3) {
				c = arguments[1];
				d = arguments[2];
				h = (l = 0);
				n = (e = q);
				o = (g = r);
			} else {
				if (arguments.length == 5) {
					c = arguments[1];
					d = arguments[2];
					e = arguments[3];
					g = arguments[4];
					h = (l = 0);
					n = q;
					o = r;
				} else {
					if (arguments.length == 9) {
						h = arguments[1];
						l = arguments[2];
						n = arguments[3];
						o = arguments[4];
						c = arguments[5];
						d = arguments[6];
						e = arguments[7];
						g = arguments[8];
					} else {
						throw "Invalid number of arguments";
					}
				}
			}
			var s = this.b(c, d), t = [], v = 10, w = 10;
			t.push(" <g_vml_:group", " coordsize=\"", m * v, ",", m * w, "\"", " coordorigin=\"0,0\"", " style=\"width:", v, ";height:", w, ";position:absolute;");
			if (this.a[0][0] != 1 || this.a[0][1]) {
				var x = [];
				x.push("M11='", this.a[0][0], "',", "M12='", this.a[1][0], "',", "M21='", this.a[0][1], "',", "M22='", this.a[1][1], "',", "Dx='", i(s.x / m), "',", "Dy='", i(s.y / m), "'");
				var p = s, y = this.b(c + e, d), z = this.b(c, d + g), B = this.b(c + e, d + g);
				p.x = Math.max(p.x, y.x, z.x, B.x);
				p.y = Math.max(p.y, y.y, z.y, B.y);
				t.push("padding:0 ", i(p.x / m), "px ", i(p.y / m), "px 0;filter:progid:DXImageTransform.Microsoft.Matrix(", x.join(""), ", sizingmethod='clip');");
			} else {
				t.push("top:", i(s.y / m), "px;left:", i(s.x / m), "px;");
			}
			t.push(" \">", "<g_vml_:image src=\"", a.src, "\"", " style=\"width:", m * e, ";", " height:", m * g, ";\"", " cropleft=\"", h / q, "\"", " croptop=\"", l / r, "\"", " cropright=\"", (q - h - n) / q, "\"", " cropbottom=\"", (r - l - o) / r, "\"", " />", "</g_vml_:group>");
			this.j.insertAdjacentHTML("BeforeEnd", t.join(""));
		};
		j.stroke = function (a) {
			var b = [], c = O(a ? this.fillStyle : this.strokeStyle), d = c[0], e = c[1] * this.globalAlpha, g = 10, h = 10;
			b.push("<g_vml_:shape", " fillcolor=\"", d, "\"", " filled=\"", Boolean(a), "\"", " style=\"position:absolute;width:", g, ";height:", h, ";\"", " coordorigin=\"0 0\" coordsize=\"", m * g, " ", m * h, "\"", " stroked=\"", !a, "\"", " strokeweight=\"", this.lineWidth, "\"", " strokecolor=\"", d, "\"", " path=\"");
			var l = {x:null, y:null}, n = {x:null, y:null};
			for (var o = 0; o < this.c.length; o++) {
				var f = this.c[o];
				if (f.type == "moveTo") {
					b.push(" m ");
					var k = this.b(f.x, f.y);
					b.push(i(k.x), ",", i(k.y));
				} else {
					if (f.type == "lineTo") {
						b.push(" l ");
						var k = this.b(f.x, f.y);
						b.push(i(k.x), ",", i(k.y));
					} else {
						if (f.type == "close") {
							b.push(" x ");
						} else {
							if (f.type == "bezierCurveTo") {
								b.push(" c ");
								var k = this.b(f.x, f.y), q = this.b(f.cp1x, f.cp1y), r = this.b(f.cp2x, f.cp2y);
								b.push(i(q.x), ",", i(q.y), ",", i(r.x), ",", i(r.y), ",", i(k.x), ",", i(k.y));
							} else {
								if (f.type == "at" || f.type == "wa") {
									b.push(" ", f.type, " ");
									var k = this.b(f.x, f.y), s = this.b(f.xStart, f.yStart), t = this.b(f.xEnd, f.yEnd);
									b.push(i(k.x - this.d * f.radius), ",", i(k.y - this.e * f.radius), " ", i(k.x + this.d * f.radius), ",", i(k.y + this.e * f.radius), " ", i(s.x), ",", i(s.y), " ", i(t.x), ",", i(t.y));
								}
							}
						}
					}
				}
				if (k) {
					if (l.x == null || k.x < l.x) {
						l.x = k.x;
					}
					if (n.x == null || k.x > n.x) {
						n.x = k.x;
					}
					if (l.y == null || k.y < l.y) {
						l.y = k.y;
					}
					if (n.y == null || k.y > n.y) {
						n.y = k.y;
					}
				}
			}
			b.push(" \">");
			if (typeof this.fillStyle == "object") {
				var v = {x:"50%", y:"50%"}, w = n.x - l.x, x = n.y - l.y, p = w > x ? w : x;
				v.x = i(this.fillStyle.i.x / w * 100 + 50) + "%";
				v.y = i(this.fillStyle.i.y / x * 100 + 50) + "%";
				var y = [];
				if (this.fillStyle.p == "gradientradial") {
					var z = this.fillStyle.n / p * 100, B = this.fillStyle.o / p * 100 - z;
				} else {
					var z = 0, B = 100;
				}
				var C = {offset:null, color:null}, D = {offset:null, color:null};
				this.fillStyle.h.sort(function (T, U) {
					return T.offset - U.offset;
				});
				for (var o = 0; o < this.fillStyle.h.length; o++) {
					var u = this.fillStyle.h[o];
					y.push(u.offset * B + z, "% ", u.color, ",");
					if (u.offset > C.offset || C.offset == null) {
						C.offset = u.offset;
						C.color = u.color;
					}
					if (u.offset < D.offset || D.offset == null) {
						D.offset = u.offset;
						D.color = u.color;
					}
				}
				y.pop();
				b.push("<g_vml_:fill", " color=\"", D.color, "\"", " color2=\"", C.color, "\"", " type=\"", this.fillStyle.p, "\"", " focusposition=\"", v.x, ", ", v.y, "\"", " colors=\"", y.join(""), "\"", " opacity=\"", e, "\" />");
			} else {
				if (a) {
					b.push("<g_vml_:fill color=\"", d, "\" opacity=\"", e, "\" />");
				} else {
					b.push("<g_vml_:stroke", " opacity=\"", e, "\"", " joinstyle=\"", this.lineJoin, "\"", " miterlimit=\"", this.miterLimit, "\"", " endcap=\"", S(this.lineCap), "\"", " weight=\"", this.lineWidth, "px\"", " color=\"", d, "\" />");
				}
			}
			b.push("</g_vml_:shape>");
			this.j.insertAdjacentHTML("beforeEnd", b.join(""));
			this.c = [];
		};
		j.fill = function () {
			this.stroke(true);
		};
		j.closePath = function () {
			this.c.push({type:"close"});
		};
		j.b = function (a, b) {
			return {x:m * (a * this.a[0][0] + b * this.a[1][0] + this.a[2][0]) - A, y:m * (a * this.a[0][1] + b * this.a[1][1] + this.a[2][1]) - A};
		};
		j.save = function () {
			var a = {};
			N(this, a);
			this.k.push(a);
			this.m.push(this.a);
			this.a = G(J(), this.a);
		};
		j.restore = function () {
			N(this.k.pop(), this);
			this.a = this.m.pop();
		};
		j.translate = function (a, b) {
			var c = [[1, 0, 0], [0, 1, 0], [a, b, 1]];
			this.a = G(c, this.a);
		};
		j.rotate = function (a) {
			var b = M(a), c = L(a), d = [[b, c, 0], [-c, b, 0], [0, 0, 1]];
			this.a = G(d, this.a);
		};
		j.scale = function (a, b) {
			this.d *= a;
			this.e *= b;
			var c = [[a, 0, 0], [0, b, 0], [0, 0, 1]];
			this.a = G(c, this.a);
		};
		j.clip = function () {
		};
		j.arcTo = function () {
		};
		j.createPattern = function () {
			return new P;
		};
		function H(a) {
			this.p = a;
			this.n = 0;
			this.o = 0;
			this.h = [];
			this.i = {x:0, y:0};
		}
		H.prototype.addColorStop = function (a, b) {
			b = O(b);
			this.h.push({offset:1 - a, color:b});
		};
		function P() {
		}
		G_vmlCanvasManager = Q;
		CanvasRenderingContext2D = K;
		CanvasGradient = H;
		CanvasPattern = P;
	})();
}
function getBBoxToFitAroundCenter(center, positions) {
	var tmpMinLat, tmpMinLon, tmpMaxLat, tmpMaxLon;
	for (var i = 0; i < positions.length; i++) {
		var absDiffLat = Math.abs(center.lat - positions[i].lat);
		var absDiffLon = Math.abs(center.lon - positions[i].lon);
            // first pass
		if (i == 0) {
                  // mins
			var tmpMinLat = center.lat - absDiffLat;
			var tmpMinLon = center.lon - absDiffLon;
                  // maxs
			var tmpMaxLat = center.lat + absDiffLat;
			var tmpMaxLon = center.lon + absDiffLon;
		} else {
                  // if smaller then stretch
			if (center.lat - absDiffLat < tmpMinLat) {
				tmpMinLat = center.lat - absDiffLat;
			}
			if (center.lat + absDiffLat > tmpMaxLat) {
				tmpMaxLat = center.lat + absDiffLat;
			}
                  // if bigger then stretch
			if (center.lon - absDiffLon < tmpMinLon) {
				tmpMinLon = center.lon - absDiffLon;
			}
			if (center.lon + absDiffLon > tmpMaxLon) {
				tmpMaxLon = center.lon + absDiffLon;
			}
		}
	}
	return new BoundingBox(new Position(tmpMinLat, tmpMinLon), new Position(tmpMaxLat, tmpMaxLon));
}

