
function VE_SearchResult(id, name, description, phone, rating, type, latitude, longitude) {
this.id = id;
this.name = name;
this.description = description;
this.phone = phone;
this.rating = rating;
this.type = type;
this.latitude = latitude;
this.longitude = longitude;
this.pushPin = null;
this.pinId = null;
}
VE_SearchResult.prototype.Equals = function (result) {
return this.name == result.name && this.description == result.description && this.phone == result.phone && this.rating == result.rating && this.type == result.type && this.latitude == result.latitude && this.longitude == result.longitude;
};
VE_SearchResult.prototype.GetSerializedId = function () {
switch (this.type) {
case "al":
return "";
case "adr":
return "adr" + "." + this.name;
case "aN":
return VE_AnnotationData.SerializeAnnotation(this.pinId);
default:
return this.type + "." + this.id.toString();
}
};
function VE_Config() {
this.serializationVersion = currentUrlApiVersion;
this._items = new Array();
this._categories = new Array();
}
VE_Config.prototype.AddCategory = function (category) {
if (!category || category.constructor != VE_ConfigCat) {
return;
}
for (var i = 0; i < this._categories.length; i++) {
if (this._categories[i].name == category.name) {
this._categories[i] = category;
return;
}
}
this._categories.push(category);
};
VE_Config.prototype.RemoveCategory = function (categoryName) {
if (!categoryName) {
return;
}
for (var i = 0; i < this._categories.length; i++) {
if (this._categories[i].name == categoryName) {
this._categories.splice(i, 1);
break;
}
}
for (var i = 0; i < this._items.length; ) {
if (this._items[i].category == categoryName) {
this._items.splice(i, 1);
} else {
i++;
}
}
};
VE_Config.prototype.AddItem = function (item) {
if (!item || item.constructor != VE_ConfigItem) {
return;
}
var categoryExists = false;
for (var i = 0; i < this._categories.length; i++) {
if (this._categories[i].name == item.category) {
categoryExists = true;
break;
}
}
if (!categoryExists) {
return;
}
for (var i = 0; i < this._items.length; i++) {
if (this._items[i].name == item.name) {
this._items[i] = item;
return;
}
}
this._items.push(item);
};
VE_Config.prototype.RemoveItem = function (name) {
for (var i = 0; i < this._items.length; i++) {
if (this._items[i].name == name) {
this._items.splice(i, 1);
return;
}
}
};
VE_Config.prototype.GetItemsForCategory = function (category) {
var categoryItems = new Array();
for (var i = 0; i < this._items.length; i++) {
if (this._items[i].category == category) {
categoryItems.push(this._items[i]);
}
}
return categoryItems;
};
VE_Config.prototype.SetValue = function (name, value) {
if (!name || value == null) {
return;
}
for (var i = 0; i < this._items.length; i++) {
if (this._items[i].name == name) {
this._items[i].SetValue(value, this.serializationVersion);
return;
}
}
};
VE_Config.prototype.GetValue = function (name) {
if (!name) {
return;
}
for (var i = 0; i < this._items.length; i++) {
if (this._items[i].name == name) {
return this._items[i].value;
}
}
return null;
};
VE_Config.prototype.ToString = function (category, persistentOnly) {
var returnedString = "";
var isFirst = true;
for (var i = 0; i < this._items.length; i++) {
if (category && this._items[i].category != category) {
continue;
}
if (!this._items[i].HasValue() || (persistentOnly && !this._items[i].persist)) {
continue;
}
if (!isFirst) {
returnedString += "&";
}
// returnedString += this._items[i].ToString();
isFirst = false;
}
return returnedString;
};
VE_Config.prototype.LoadValuesFromString = function (configurationToString) {
if (!configurationToString) {
return;
}
var configItemStrings = configurationToString.split("&");
for (var i = 0; i < configItemStrings.length; i++) {
var nameValueStrings = configItemStrings[i].split("=");
if (nameValueStrings.length != 2) {
continue;
}
this.SetValue(nameValueStrings[0], nameValueStrings[1]);
}
};
function VE_ConfigCat(name, description) {
this.name = name;
this.description = description;
}
function VE_ConfigItem(name, description, category, validator, value, persist, userCanEdit) {
this.name = name;
this.description = description;
this.category = category;
this.persist = persist;
this.userCanEdit = userCanEdit;
this._validator = validator;
this.SetValue(value);
if (this.value == null) {
this.value = this._validator.DefaultValue();
}
}
VE_ConfigItem.prototype.GetType = function () {
return this._validator.type;
};
VE_ConfigItem.prototype.SetValue = function (value, apiVersion) {
var parsedValue = this._validator.ParseValue(value, apiVersion);
if (this._validator.ValidValue(parsedValue, apiVersion)) {
this.value = parsedValue;
}
};
VE_ConfigItem.prototype.HasValue = function () {
if (this._validator.validatorType == "VE_ArrayValidator") {
return this.value.length > 0;
} else {
return this.value != null;
}
};
VE_ConfigItem.prototype.ToString = function () {
var returnString = this.name + "=";
if (this.value.constructor == Array) {
var primarySeparator = VE_SerializationConstants.primarySeparator[currentUrlApiVersion];
var isFirst = true;
for (var i = 0; i < this.value.length; i++) {
if (!isFirst) {
returnString += primarySeparator;
}
returnString += VE_ConfigItem.EscapeValue(this.value[i]);
isFirst = false;
}
} else {
returnString += VE_ConfigItem.EscapeValue(this.value);
}
return returnString;
};
VE_ConfigItem.EscapeValue = function (value) {
if (!value || value.constructor != String) {
return escape(value);
}
var primarySeparator = VE_SerializationConstants.primarySeparator[currentUrlApiVersion];
return value.replace(new RegExp("(" + primarySeparator + ")|(" + IOSec.EncodeUrl(primarySeparator) + ")", "g"), " ");
};
currentUrlApiVersion = eval(currentUrlApiVersion);
function VE_LoadActions() {
this.initialLoad = true;
this.displayIntroPanel = false;
this.doBestFit = true;
}
function VE_State(pageLastModified) {
this.loadActions = new VE_LoadActions();
this._LoadStateDefault();
state = this;
this.loadActions.doBestFit = this._LoadStateFromUrl();
this._RestoreFromState();
}
VE_State.prototype._LoadStateDefault = function () {
this._config = new VE_Config();
var stringTypeValidator = new VE_TypeValidator("string");
var booleanTypeValidator = new VE_TypeValidator("boolean");
var numberTypeValidator = new VE_TypeValidator("number");
var urlApiVersionValidator = new VE_RangeValidator(1, 2, true);
this._config.AddCategory(new VE_ConfigCat(VE_State.CategorySystem, ""));
var currentUrlApiVersionItem = new VE_ConfigItem(VE_State.ItemCurrentUrlApiVersion, "", VE_State.CategorySystem, urlApiVersionValidator, currentUrlApiVersion, false, false);
this._config.AddItem(currentUrlApiVersionItem);
var maxInputCountValidator = new VE_RangeValidator(50, 1000, true);
var maxInputCountItem = new VE_ConfigItem(VE_State.ItemMaxInputCount, "", VE_State.CategorySystem, maxInputCountValidator, maxInputCount, false, false);
this._config.AddItem(maxInputCountItem);
var maxInputStringLengthValidator = new VE_StringLengthValidator(this.GetMaxInputCount());
var arrayStringLengthValueValidator = function (value) {
if (value == null || value.constructor != Array) {
return false;
}
for (var i = 0; i < value.length; i++) {
if (!maxInputStringLengthValidator.ValidValue(value[i])) {
return false;
}
}
return true;
};
var arrayStringLengthValueParser = function (value) {
return maxInputStringLengthValidator.ParseValue(value);
};
this._config.AddCategory(new VE_ConfigCat(VE_State.CategoryViewport, ""));
var cpValueValidator = function (value) {
if (value == null || value.constructor != Array || value.length != 2) {
return false;
}
var latValidator = new VE_RangeValidator(-85, 85);
var lonValidator = new VE_RangeValidator(-180, 180);
return latValidator.ValidValue(value[0]) && lonValidator.ValidValue(value[1]);
};
var cpValidator = new VE_ArrayValidator("number", 2, 2, false, cpValueValidator);
var cpConfigItem = new VE_ConfigItem(VE_State.ItemCenterPoint, "", VE_State.CategoryViewport, cpValidator, [eval(defaultLatitude), eval(defaultLongitude)], true, false);
this._config.AddItem(cpConfigItem);
var mapStyleValidator = new VE_ValidValuesValidator("string", ["a", "h", "r", "o"]);
var mapStyleConfigItem = new VE_ConfigItem(VE_State.ItemMapStyle, "", VE_State.CategoryViewport, mapStyleValidator, defaultMapStyle, true, false);
this._config.AddItem(mapStyleConfigItem);
var zoomValidator = new VE_RangeValidator(1, 19, true);
var zoomConfigItem = new VE_ConfigItem(VE_State.ItemZoom, "", VE_State.CategoryViewport, zoomValidator, defaultZoom, true, false);
this._config.AddItem(zoomConfigItem);
this._config.AddCategory(new VE_ConfigCat(VE_State.CategoryStartup, ""));
var specifiedUrlApiVersionItem = new VE_ConfigItem(VE_State.ItemSpecifiedUrlApiVersion, "", VE_State.CategoryStartup, urlApiVersionValidator, currentUrlApiVersion, false, false);
this._config.AddItem(specifiedUrlApiVersionItem);
var startWhereItem = new VE_ConfigItem(VE_State.ItemStartWhere, "", VE_State.CategoryStartup, maxInputStringLengthValidator, "", false, false);
this._config.AddItem(startWhereItem);
this._config.AddCategory(new VE_ConfigCat(VE_State.CategoryDirections, ""));
this._config.AddCategory(new VE_ConfigCat(VE_State.CategorySearches, ""));
var searchesValidator = new VE_ArrayValidator("string", 0, parseInt(maximumSearches), false, arrayStringLengthValueValidator, arrayStringLengthValueParser);
var searchesConfigItem = new VE_ConfigItem(VE_State.ItemSearches, "", VE_State.CategorySearches, searchesValidator, [], true, false);
this._config.AddItem(searchesConfigItem);
var serverPageSizeValidator = new VE_RangeValidator(1, 1000, true);
var serverPageSizeItem = new VE_ConfigItem(VE_State.ItemServerPageSize, "", VE_State.CategorySearches, serverPageSizeValidator, serverPageSize, false, false);
this._config.AddItem(serverPageSizeItem);
var maxSearchesValidator = new VE_RangeValidator(1, 10, true);
var maxSearchesItem = new VE_ConfigItem(VE_State.ItemMaxSearches, "", VE_State.CategorySearches, maxSearchesValidator, maximumSearches, false, false);
this._config.AddItem(maxSearchesItem);
this._config.AddCategory(new VE_ConfigCat(VE_State.CategoryScratchpad, ""));
var maxScratchpadStringLengthValidator = new VE_StringLengthValidator(320);
var arrayScratchpadStringLengthValueValidator = function (value) {
if (value == null || value.constructor != Array) {
return false;
}
for (var i = 0; i < value.length; i++) {
if (!maxScratchpadStringLengthValidator.ValidValue(value[i])) {
return false;
}
}
return true;
};
var arrayScratchpadStringLengthValueParser = function (value) {
return maxScratchpadStringLengthValidator.ParseValue(value);
};
var scratchpadValidator = new VE_ArrayValidator("string", 0, null, false, arrayScratchpadStringLengthValueValidator, arrayScratchpadStringLengthValueParser);
var scratchpadConfigItem = new VE_ConfigItem(VE_State.ItemScratchpadIds, "", VE_State.CategoryScratchpad, scratchpadValidator, [], true, false);
scratchpadConfigItem.ToString = VE_Scratchpad.ScratchpadSerializer;
this._config.AddItem(scratchpadConfigItem);
this._config.AddCategory(new VE_ConfigCat(VE_State.CategoryUserOptionsExit, "On Exit"));
this._config.AddCategory(new VE_ConfigCat(VE_State.CategoryUserOptionsMap, "Map Navigation"));
var enableAnimatedMovementConfigItem = new VE_ConfigItem(VE_State.ItemAnimatedMovementsEnabled, "Use animated pan and zoom", VE_State.CategoryUserOptionsMap, booleanTypeValidator, true, true, true);
this._config.AddItem(enableAnimatedMovementConfigItem);
this._config.AddCategory(new VE_ConfigCat(VE_State.CategoryUserOptionsSearch, "Searching"));
var clientPageSizeValidator = new VE_ValidValuesValidator("number", [1000, 10]);
var clientPageSizeConfigItem = new VE_ConfigItem(VE_State.ItemClientPageSize, "Select the number of search results to display at one time:", VE_State.CategoryUserOptionsSearch, clientPageSizeValidator, clientPageSize, true, true, true);
this._config.AddItem(clientPageSizeConfigItem);
this._config.AddCategory(new VE_ConfigCat(VE_State.CategoryUserOptionsLocate, "Locating Me"));
};
VE_State.prototype._LoadStateFromUrl = function () {
var parameterString = GetUrlParameterString();
if (!parameterString) {
return true;
}
// this.SetScratchpadEntityIds([]);
var cookieZoom = this.GetZoom();
var urlParameters = GetUrlParameters();
var centerPointSpecified = false;
var zoomSpecified = false;
for (var i = 0; i < urlParameters.length; i += 2) {
switch (urlParameters[i]) {
case VE_State.ItemCenterPoint:
centerPointSpecified = true;
break;
case VE_State.ItemZoom:
zoomSpecified = true;
break;
case VE_State.ItemSpecifiedUrlApiVersion:
var urlApiVersionValidator = new VE_RangeValidator(1, 2, true);
var serializationVersion = urlApiVersionValidator.ParseValue(urlParameters[i + 1]);
if (serializationVersion == null) {
serializationVersion = this.GetCurrentUrlApiVersion();
}
this._config.serializationVersion = serializationVersion;
break;
default:
break;
}
}
this._config.LoadValuesFromString(parameterString);
if (!zoomSpecified && centerPointSpecified) {
this.SetZoom(defaultZoom);
} else {
if (zoomSpecified && !centerPointSpecified) {
this.SetZoom(cookieZoom);
}
}
return !centerPointSpecified && this.GetStartWhere() == "";
};
VE_State._GetCookieName = function (cookieName, persistent) {
if (persistent) {
return cookieName + VE_State.CookieNameSuffixPersistent;
}
return cookieName + VE_State.CookieNameSuffixSession;
};
VE_State.prototype._RestoreFromState = function () {
var params = new Object();
params.latitude = this.GetLatitude();
params.longitude = this.GetLongitude();
var maxLat=0;
var minLat=0;
var maxLon=0;
var minLon=0;
if (OnAMap) {
var maxLat=poiLats[0];
var minLat=poiLats[0];
var maxLon=poiLons[0];
var minLon=poiLons[0];
for (var i=0;i<poiLons.length;i++){
if (poiLats[i]>maxLat)
maxLat=poiLats[i];
if (poiLats[i]<minLat)
minLat=poiLats[i];
if (poiLons[i]>maxLon)
maxLon=poiLons[i];
if (poiLons[i]<minLon)
minLon=poiLons[i];
}
params.latitude = (maxLat + minLat)/2;
params.longitude = (maxLon + minLon)/2;
}
params.zoomlevel = this.GetZoom();
params.mapstyle = this.GetMapStyle();
spll = false;
if (!spPrint || OnAMap)
{
if ((spLat && spLon) && (spLat != "" && spLon != "")) {
params.latitude = spLat;
params.longitude = spLon;
params.zoomlevel = spZoom;
params.mapstyle = "r";
spll = true;
}
}
if (imageWidth && imageWidth != "") {
windowWidth = imageWidth;
}else {
windowWidth = GetWindowWidth();
}
if (imageHeight && imageHeight != "") {
windowHeight = imageHeight;
}else {
windowHeight = GetWindowHeight();
}
StartMap(params, windowWidth, windowHeight);
var initialAction = "";
if (OnAMap) {
// var h = Math.max((maxLat - minLat) * 0.1, 0.005);
// var w = Math.max((maxLon - minLon) * 0.1, 0.005);
// map.SetViewport(maxLat + h, minLon - w, minLat - h , maxLon + w);
map.SetCenterAndZoom((maxLat+minLat)/2, (maxLon+minLon)/2, 18);
for (var m=17;m>=0;m--){
{
var topLeft = map.PixelToLatLongFromZoom(new Msn.VE.Pixel(0, 0),m);
var bottomRight = map.PixelToLatLongFromZoom(new Msn.VE.Pixel(windowWidth, windowHeight),m);
if (topLeft == null || bottomRight == null) {
return;
}
var c = topLeft.latitude;
var d = bottomRight.longitude;
var e = bottomRight.latitude;
var f = topLeft.longitude;
if (c < e) {
var t = c;
c = e;
e = t;
}
if (d < f) {
var t = d;
d = f;
f = t;
}
if (maxLat<c && minLat>e && maxLon<d && minLon>f) {
//map.SetViewport(c, f, e, d);
map.SetCenterAndZoom((maxLat+minLat)/2, (maxLon+minLon)/2, m);
break;
}
}
}
if (poiLons.length >= 1) {
for (var i=poiLons.length;i>0;i--){
VE_Scratchpad.OnAMap(i,'Test'+(i),poiLats[i-1],poiLons[i-1],'',poiTypes[i-1]);
}
}
}
if ((spll || spPrint)) {
initialAction = "VE_Scratchpad.AddLocation('";
initialAction += (!spAddress ? (!spName ? "" : spName) : spAddress) + "', " + spLat + ", " + spLon + ");state.UpdateFromMap();";
}
if (initialAction) {
window.setTimeout(initialAction, 1000);
}
};
VE_State.CategorySystem = "System";
VE_State.CategoryDirections = "Directions";
VE_State.CategoryViewport = "Viewport";
VE_State.CategoryStartup = "Startup";
VE_State.CategorySearches = "Searches";
VE_State.CategoryScratchpad = "Scratchpad";
VE_State.CategoryUserOptionsExit = "UserOptionsExit";
VE_State.CategoryUserOptionsMap = "UserOptionsMap";
VE_State.CategoryUserOptionsSearch = "UserOptionsSearch";
VE_State.CategoryUserOptionsLocate = "UserOptionsLocate";
VE_State.ItemMaxInputCount = "MaxInputCount";
VE_State.ItemCenterPoint = "cp";
VE_State.ItemMapStyle = "style";
VE_State.ItemZoom = "lvl";
VE_State.ItemSpecifiedUrlApiVersion = "v";
VE_State.ItemAutolocate = "autolocate";
VE_State.ItemStartWhere = "spaddress";
VE_State.ItemSearches = "ss";
VE_State.ItemServerPageSize = "ServerPageSize";
VE_State.ItemMaxSearches = "MaxSearches";
VE_State.ItemScratchpadIds = "sp";
VE_State.ItemSaveLocation = "SaveLocation";
VE_State.ItemSaveSearches = "SaveSearches2";
VE_State.ItemSaveScratchpad = "SaveScratchpad";
VE_State.ItemAnimatedMovementsEnabled = "AnimatedMovementsEnabled";
VE_State.ItemClientPageSize = "ClientPageSize";
VE_State.ItemDontAskWiFiLocator = "DontAskWiFiLocator";
VE_State.prototype.UpdateFromMap = function () {
var splLat = (map.GetCenterLatitude().toFixed ? map.GetCenterLatitude().toFixed(6) : map.GetCenterLatitude());
var splLon = (map.GetCenterLongitude().toFixed ? map.GetCenterLongitude().toFixed(6) : map.GetCenterLongitude());
this.SetCenterPoint([splLat, splLon]);
this.SetZoom(map.GetZoomLevel());
// this.SetMapStyle(map.GetMapStyle());
};
VE_State.prototype.UpdateFromScratchpad = function () {
var scratchpadEntities = new Array(VE_Scratchpad.entities.length);
for (var i = 0; i < VE_Scratchpad.entities.length; i++) {
if (!VE_Scratchpad.entities[i] || VE_Scratchpad.entities[i].type == "al") {
continue;
} else {
if (VE_Scratchpad.entities[i].type == "aN") {
scratchpadEntities.push(IOSec.EncodeUrl(VE_Scratchpad.entities[i].GetSerializedId()));
} else {
scratchpadEntities.push(VE_Scratchpad.entities[i].GetSerializedId());
}
}
}
this.SetScratchpadEntityIds(scratchpadEntities);
};
VE_Scratchpad.onAddSearchResult = function () {
if (state) {
state.UpdateFromScratchpad();
}
};
VE_Scratchpad.onAddLocation = function () {
if (state) {
state.UpdateFromScratchpad();
}
};
VE_Scratchpad.onAddResults = function () {
if (state) {
state.UpdateFromScratchpad();
}
};
VE_State.prototype.GetMaxInputCount = function () {
return this._config.GetValue(VE_State.ItemMaxInputCount);
};
VE_State.prototype.GetMaxSearches = function () {
return this._config.GetValue(VE_State.ItemMaxSearches);
};
VE_State.prototype.GetServerPageSize = function () {
return this._config.GetValue(VE_State.ItemServerPageSize);
};
VE_State.prototype.GetClientPageSize = function () {
return this._config.GetValue(VE_State.ItemClientPageSize);
};
VE_State.prototype.GetCenterPoint = function () {
return this._config.GetValue(VE_State.ItemCenterPoint);
};
VE_State.prototype.GetLatitude = function () {
return this._config.GetValue(VE_State.ItemCenterPoint)[0];
};
VE_State.prototype.GetLongitude = function () {
return this._config.GetValue(VE_State.ItemCenterPoint)[1];
};
VE_State.prototype.GetMapStyle = function () {
return this._config.GetValue(VE_State.ItemMapStyle);
};
VE_State.prototype.GetZoom = function () {
return this._config.GetValue(VE_State.ItemZoom);
};
VE_State.prototype.GetSearchKeywords = function () {
return this._config.GetValue(VE_State.ItemSearches);
};
VE_State.prototype.GetSaveLocation = function () {
return this._config.GetValue(VE_State.ItemSaveLocation);
};
VE_State.prototype.GetCurrentUrlApiVersion = function () {
return this._config.GetValue(VE_State.ItemCurrentUrlApiVersion);
};
VE_State.prototype.GetSaveSearches = function () {
return this._config.GetValue(VE_State.ItemSaveSearches);
};
VE_State.prototype.GetSaveScratchpad = function () {
return this._config.GetValue(VE_State.ItemSaveScratchpad);
};
VE_State.prototype.GetStartWhere = function () {
return this._config.GetValue(VE_State.ItemStartWhere);
};
VE_State.prototype.SetCenterPoint = function (value) {
this._config.SetValue(VE_State.ItemCenterPoint, value);
};
VE_State.prototype.SetMapStyle = function (value) {
this._config.SetValue(VE_State.ItemMapStyle, value);
};
VE_State.prototype.SetZoom = function (value) {
this._config.SetValue(VE_State.ItemZoom, value);
};
VE_State.prototype.SetSearchKeywords = function (value) {
this._config.SetValue(VE_State.ItemSearches, value);
};
VE_State.prototype.SetScratchpadEntityIds = function (value) {
this._config.SetValue(VE_State.ItemScratchpadIds, value);
};
VE_State.prototype.SetAnimatedMovementsEnabled = function (value) {
this._config.SetValue(VE_State.ItemAnimatedMovementsEnabled, value);
};
VE_ConfigItem.prototype.SetValueFromControl = function () {
var valueControl = document.getElementById(VE_ConfigItem.GenerateHtmlControlID(this.name));
if (!valueControl) {
return;
}
if (this._validator.type == "boolean" && this._validatorType != "VE_ArrayValidator") {
this.SetValue(valueControl.checked);
} else {
if (this._validator.validatorType == "VE_ValidValuesValidator") {
this.SetValue(valueControl.options[valueControl.selectedIndex].value);
} else {
this.SetValue(valueControl.value);
}
}
};
VE_ConfigItem.GenerateHtmlControlID = function (name) {
return "config_" + SanitizeHtmlString(name);
};
VE_Config.prototype.GetValuesFromControls = function () {
for (var i = 0; i < this._items.length; i++) {
this._items[i].SetValueFromControl();
}
};
VE_State.prototype.SaveOptionsValues = function () {
this._config.GetValuesFromControls();
};
function VE_SerializationConstants() {
}
VE_SerializationConstants.primarySeparator = primarySerializationSeparators.split(",");
VE_SerializationConstants.secondarySeparator = secondarySerializationSeparators.split(",");
function VE_TypeValidator(type) {
this.type = type;
this.validatorType = "VE_TypeValidator";
}
VE_TypeValidator.prototype.ValidValue = function (value) {
return VE_TypeValidator._ValidValue(value, this.type);
};
VE_TypeValidator.prototype.DefaultValue = function () {
return null;
};
VE_TypeValidator.prototype.ParseValue = function (value) {
return VE_TypeValidator._ParseValue(value, this.type);
};
VE_TypeValidator._ValidValue = function (value, type) {
if (value == null) {
return false;
}
if (type == "int") {
return typeof (value) == "number" && value.toString().indexOf(".") == -1;
}
return typeof (value) == type;
};
VE_TypeValidator._ParseValue = function (value, type) {
if (value == null) {
return null;
}
var typeOfValue = typeof (value);
if (typeOfValue == "string") {
value = unescape(value).replace(/^\s*|\s*$/g, "");
}
if (type == "int" && typeOfValue == "number") {
if (value.toString().indexOf(".") > -1) {
return null;
}
return value;
}
if (typeOfValue == type) {
return value;
}
if (typeOfValue == "string") {
if (type == "int") {
if (value.toString().indexOf(".") > -1) {
return null;
}
var returnedNumber = parseInt(value);
if (isNaN(returnedNumber)) {
return null;
}
return returnedNumber;
} else {
if (type == "number") {
var returnedNumber = parseFloat(value);
if (isNaN(returnedNumber)) {
returnedNumber = parseInt(value);
}
if (isNaN(returnedNumber)) {
return null;
}
return returnedNumber;
} else {
if (type == "boolean") {
if (value.toLowerCase() == "true") {
return true;
} else {
if (value.toLowerCase() == "false") {
return false;
}
}
}
}
}
}
return null;
};
VE_StringLengthValidator.prototype = new VE_TypeValidator();
function VE_StringLengthValidator(maxLength) {
this.type = "string";
this.validatorType = "VE_StringValidator";
if (maxLength && maxLength.constructor == Number & maxLength >= 0) {
this.maxLength = maxLength;
}
}
VE_StringLengthValidator.prototype.ParseValue = function (value) {
var parsedValue = VE_TypeValidator._ParseValue(value, "string");
if (parsedValue != null && this.maxLength != null && parsedValue.length > this.maxLength) {
parsedValue = parsedValue.substr(0, this.maxLength);
}
return parsedValue;
};
VE_StringLengthValidator.prototype.ValidValue = function (value) {
if (!VE_TypeValidator._ValidValue(value, "string")) {
return false;
}
if (this.maxLength != null && value.length > this.maxLength) {
return false;
}
return true;
};
VE_StringLengthValidator.prototype.DefaultValue = function (value) {
return "";
};
VE_ArrayValidator.prototype = new VE_TypeValidator();
function VE_ArrayValidator(type, minValues, maxValues, allowNull, valueValidationFunction, valueParsingFunction) {
this.type = type;
this.validatorType = "VE_ArrayValidator";
this.allowNull = allowNull;
if (valueValidationFunction != null && typeof (valueValidationFunction) == "function") {
this.valueValidationFunction = valueValidationFunction;
}
if (valueParsingFunction != null && typeof (valueParsingFunction) == "function") {
this.valueParsingFunction = valueParsingFunction;
}
if (minValues && minValues.constructor == Number & minValues >= 0) {
this.minValues = minValues;
} else {
this.minValues = 0;
}
if (maxValues && maxValues.constructor == Number & maxValues >= 0) {
this.maxValues = maxValues;
}
if (this.maxValues != null && this.minValues > this.maxValues) {
var oldMinValue = this.minValues;
this.minValues = this.maxValues;
this.maxValues = oldMinValue;
}
}
VE_ArrayValidator.prototype.ParseValue = function (value, apiVersion) {
if (value == null) {
return null;
}
if (apiVersion == null) {
apiVersion = currentUrlApiVersion;
}
primarySeparator = VE_SerializationConstants.primarySeparator[apiVersion];
var arrayValues = null;
if (value.constructor == Array) {
arrayValues = new Array();
for (var i = 0; i < value.length; i++) {
var parsedValue = this._ParseSingleValue(value[i], apiVersion);
if ((this.allowNull && parsedValue == null) || VE_TypeValidator._ValidValue(parsedValue, this.type)) {
arrayValues.push(parsedValue);
}
}
} else {
if (value.constructor == String) {
arrayValues = new Array();
value = value.replace(eval("/" + IOSec.EncodeUrl(primarySeparator) + "/gi"), primarySeparator);
var valueStrings = value.split(primarySeparator);
for (var i = 0; i < valueStrings.length; i++) {
if (!this.allowNull && !valueStrings[i]) {
continue;
}
var parsedValue = this._ParseSingleValue(valueStrings[i], apiVersion);
if ((this.allowNull && parsedValue == null) || VE_TypeValidator._ValidValue(parsedValue, this.type)) {
arrayValues.push(parsedValue);
}
}
}
}
if (arrayValues != null && this.maxValues != null && arrayValues.length > this.maxValues) {
arrayValues.splice(this.maxValues, arrayValues.length - this.maxValues);
}
return arrayValues;
};
VE_ArrayValidator.prototype.ValidValue = function (value, apiVersion) {
if (apiVersion == null) {
apiVersion = currentUrlApiVersion;
}
if (!value || value.constructor != Array) {
return false;
}
if (value.length < this.minValues || (this.maxValues != null && value.length > this.maxValues)) {
return false;
}
for (var i = 0; i < value.length; i++) {
if ((value[i] == null && !this.allowNull) || (value[i] != null && typeof (value[i]) != this.type)) {
return false;
}
}
if (this.valueValidationFunction) {
if (!this.valueValidationFunction(value, apiVersion)) {
return false;
}
}
return true;
};
VE_ArrayValidator.prototype.DefaultValue = function () {
return [];
};
VE_ArrayValidator.prototype._ParseSingleValue = function (value, apiVersion) {
if (this.valueParsingFunction != null) {
return this.valueParsingFunction(value, apiVersion);
} else {
return VE_TypeValidator._ParseValue(value, this.type);
}
};
VE_ValidValuesValidator.prototype = new VE_TypeValidator();
function VE_ValidValuesValidator(type, validValues) {
this.type = type;
this.validatorType = "VE_ValidValuesValidator";
this.validValues = new Array();
if (this.type == "boolean") {
this.validValues.push(true);
this.validValues.push(false);
} else {
if (validValues && validValues.constructor == Array) {
for (var i = 0; i < validValues.length; i++) {
if (VE_TypeValidator._ValidValue(validValues[i], this.type)) {
this.validValues.push(validValues[i]);
}
}
}
}
}
VE_ValidValuesValidator.prototype.ValidValue = function (value) {
if (!VE_TypeValidator._ValidValue(value, this.type)) {
return false;
}
if (this.validValues.length == 0) {
return true;
}
for (var i = 0; i < this.validValues.length; i++) {
if (value == this.validValues[i]) {
return true;
}
}
return false;
};
VE_ValidValuesValidator.prototype.DefaultValue = function () {
if (this.validValues.length > 0) {
return this.validValues[0];
} else {
return null;
}
};
VE_RangeValidator.prototype = new VE_TypeValidator();
function VE_RangeValidator(minValue, maxValue, integerOnly) {
if (integerOnly) {
this.type = "int";
} else {
this.type = "number";
}
this.multipleValues = false;
this.validatorType = "VE_RangeValidator";
if (VE_TypeValidator._ValidValue(minValue, this.type)) {
this.minValue = minValue;
}
if (VE_TypeValidator._ValidValue(maxValue, this.type)) {
this.maxValue = maxValue;
}
if (this.minValue && this.maxValue && this.minValue > this.maxValue) {
var oldMinValue = this.minValue;
this.minValue = this.maxValue;
this.maxValue = oldMinValue;
}
}
VE_RangeValidator.prototype.ValidValue = function (value) {
if (!VE_TypeValidator._ValidValue(value, "number")) {
return false;
}
if (this.minValue != null && value < this.minValue) {
return false;
}
if (this.maxValue != null && value > this.maxValue) {
return false;
}
return true;
};
VE_RangeValidator.prototype.DefaultValue = function () {
if (this.minValue != null) {
return this.minValue;
} else {
if (this.maxValue != null) {
return this.maxValue;
} else {
return null;
}
}
};
function VE_Range(min, max) {
this.min = min;
this.max = max;
}
VE_Range.prototype.IsInRange = function (val) {
return val >= this.min && val <= this.max;
};
VE_Range.prototype.toString = function () {
return this.min + "-" + this.max;
};
function SetCookie(name, value, expires, path, domain, secure) {
document.cookie = name + "=" + window.escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");
}
function GetCookie(name) {
var dc = document.cookie;
var prefix = name + "=";
var begin = dc.indexOf("; " + prefix);
if (begin == -1) {
begin = dc.indexOf(prefix);
if (begin != 0) {
return null;
}
} else {
begin += 2;
}
var end = document.cookie.indexOf(";", begin);
if (end == -1) {
end = dc.length;
}
return window.unescape(dc.substring(begin + prefix.length, end));
}
function DeleteCookie(name, path, domain) {
if (GetCookie(name)) {
document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
}
function SanitizeHtmlString(s) {
if (!s || typeof (s) != "string") {
return s;
}
return IOSec.EncodeHtml(s);
}
function OutputEncoder_EncodeHtml(strInput) {
var c;
var EncodeHtml = "";
for (var cnt = 0; cnt < strInput.length; cnt++) {
c = strInput.charCodeAt(cnt);
if (((c > 96) && (c < 123)) || ((c > 64) && (c < 91)) || (c == 32) || ((c > 47) && (c < 58)) || (c == 46) || (c == 44) || (c == 45) || (c == 95)) {
EncodeHtml = EncodeHtml + String.fromCharCode(c);
} else {
EncodeHtml = EncodeHtml + "&#" + c + ";";
}
}
return EncodeHtml;
}
function OutputEncoder_EncodeHtmlAttribute(strInput) {
var c;
var EncodeHtmlAttribute = "";
for (var cnt = 0; cnt < strInput.length; cnt++) {
c = strInput.charCodeAt(cnt);
if (((c > 96) && (c < 123)) || ((c > 64) && (c < 91)) || ((c > 47) && (c < 58)) || (c == 46) || (c == 44) || (c == 45) || (c == 95)) {
EncodeHtmlAttribute = EncodeHtmlAttribute + String.fromCharCode(c);
} else {
EncodeHtmlAttribute = EncodeHtmlAttribute + "&#" + c + ";";
}
}
return EncodeHtmlAttribute;
}
function OutputEncoder_EncodeXml(strInput) {
return OutputEncoder_EncodeHtml(strInput);
}
function OutputEncoder_EncodeXmlAttribute(strInput) {
return OutputEncoder_EncodeHtmlAttribute(strInput);
}
function OutputEncoder_EncodeJs(strInput) {
var c;
var EncodeJs = "";
for (var cnt = 0; cnt < strInput.length; cnt++) {
c = strInput.charCodeAt(cnt);
if (((c > 96) && (c < 123)) || ((c > 64) && (c < 91)) || (c == 32) || ((c > 47) && (c < 58)) || (c == 46) || (c == 44) || (c == 45) || (c == 95)) {
EncodeJs = EncodeJs + String.fromCharCode(c);
} else {
if (c > 127) {
EncodeJs = EncodeJs + "\\u" + OutputEncoder_TwoByteHex(c);
} else {
EncodeJs = EncodeJs + "\\x" + OutputEncoder_SingleByteHex(c);
}
}
}
return "'" + EncodeJs + "'";
}
function OutputEncoder_AsNumeric(strInput) {
if (isNaN(parseFloat(strInput))) {
throw "IOSec.AsNumeric(): Error input [" + strInput + "] not a valid number.";
}
return strInput;
}
function OutputEncode_TruncateUrlSafe(strUrl, intMaxLength, strNotification) {
if (strUrl.length <= intMaxLength) {
return strUrl;
}
var strEncNotification = "";
if (strNotification && strNotification.length > 0) {
strEncNotification = OutputEncoder_EncodeUrl(strNotification);
intMaxLength -= strEncNotification.length;
}
var strUrl = strUrl.substring(0, intMaxLength);
for (var ii = 1; ii < 6; ii++) {
if (strUrl.charAt(intMaxLength - ii) == "%") {
strUrl = strUrl.substring(0, intMaxLength - ii);
break;
}
}
return strUrl + strEncNotification;
}
function OutputEncode_EncodeUrlDelims(strDelim, strInput) {
if (!strDelim) {
return strInput;
}
var c;
var d;
var EncodeUrl = "";
for (var cnt = 0; cnt < strInput.length; cnt++) {
c = strInput.charCodeAt(cnt);
if (37 == c) {
EncodeUrl = EncodeUrl + "%" + OutputEncoder_SingleByteHex(c);
continue;
}
var encodedCharacter = strInput.charAt(cnt);
for (var dcnt = 0; dcnt < strDelim.length; dcnt++) {
d = strDelim.charCodeAt(dcnt);
if (d == c) {
if (c > 127) {
encodedCharacter = "%u" + OutputEncoder_TwoByteHex(c);
} else {
encodedCharacter = "%" + OutputEncoder_SingleByteHex(c);
}
break;
}
}
EncodeUrl += encodedCharacter;
}
return EncodeUrl;
}
function OutputEncoder_EncodeUrl(strInput) {
var c;
var EncodeUrl = "";
for (var cnt = 0; cnt < strInput.length; cnt++) {
c = strInput.charCodeAt(cnt);
if (((c > 96) && (c < 123)) || ((c > 64) && (c < 91)) || ((c > 47) && (c < 58)) || (c == 46) || (c == 45) || (c == 95)) {
EncodeUrl = EncodeUrl + String.fromCharCode(c);
} else {
if (c > 127) {
EncodeUrl = EncodeUrl + "%u" + OutputEncoder_TwoByteHex(c);
} else {
EncodeUrl = EncodeUrl + "%" + OutputEncoder_SingleByteHex(c);
}
}
}
return EncodeUrl;
}
function OutputEncoder_SingleByteHex(charC) {
var SingleByteHex = charC.toString(16);
for (var cnt = SingleByteHex.length; cnt < 2; cnt++) {
SingleByteHex = "0" + SingleByteHex;
}
return SingleByteHex;
}
function OutputEncoder_TwoByteHex(charC) {
var TwoByteHex = charC.toString(16);
for (var cnt = TwoByteHex.length; cnt < 4; cnt++) {
TwoByteHex = "0" + TwoByteHex;
}
return TwoByteHex;
}
function OutputEncoder() {
this.EncodeHtml = OutputEncoder_EncodeHtml;
this.EncodeHtmlAttribute = OutputEncoder_EncodeHtmlAttribute;
this.EncodeXml = OutputEncoder_EncodeXml;
this.EncodeXmlAttribute = OutputEncoder_EncodeXmlAttribute;
this.EncodeJs = OutputEncoder_EncodeJs;
this.AsNumeric = OutputEncoder_AsNumeric;
this.EncodeUrl = OutputEncoder_EncodeUrl;
this.EncodeUrlDelims = OutputEncode_EncodeUrlDelims;
this.TruncateUrlSafe = OutputEncode_TruncateUrlSafe;
this.SingleByteHex = OutputEncoder_SingleByteHex;
this.TwoByteHex = OutputEncoder_TwoByteHex;
}
var IOSec = new OutputEncoder();
var layers = new Array();
var state;
function Main() {
if (spCheckParameters()) {
if (imageWidth && imageWidth != "") {
windowWidth = imageWidth;
}else {
windowWidth = GetWindowWidth();
}
if (imageHeight && imageHeight != "") {
windowHeight = imageHeight;
}else {
windowHeight = GetWindowHeight();
}
state = new VE_State(timestamp);
SetCookie("reload-map", "", "", "", "", "");
}
}
function spCheckParameters() {
if (spAddress && spAddress != "") {
return true;
}
if ((spLat && spLat != "") && (spLon && spLon != "")) {
return true;
}
if (spPrint) {
return true;
}
return false;
}
function Destroy() {
if (map) {
map.Destroy();
map = null;
}
return true;
}
var map = null;
function VE_MapPushpin() {
}
VE_MapPushpin.baseZIndex = 11;
VE_MapPushpin.topZIndex = 20;
function StartMap(params, windowWidth, windowHeight) {
var mapDiv = document.createElement("div");
mapDiv.style.position = "relative";
mapDiv.style.overflow = "hidden";
mapDiv.style.top = "0px";
mapDiv.style.left = "0px";
mapDiv.style.width = windowWidth + "px";
mapDiv.style.height = windowHeight + "px";
//document.body.appendChild(mapDiv);
document.getElementById("containerid").appendChild(mapDiv);
//document.getElementById("containerid").innerHTML= mapDiv;
map = new Msn.VE.MapControl(mapDiv, params);
map.Init();
}
function SetViewport(lat1, lon1, lat2, lon2) {
map.SetViewport(lat1, lon1, lat2, lon2);
}
function VE_Scratchpad() {
}
VE_Scratchpad.maxScratchpadItems = 10;
VE_Scratchpad.entities = new Array();
VE_Scratchpad.panel = null;
VE_Scratchpad.locationCounter = 1;
VE_Scratchpad.panelColor = "blue";
VE_Scratchpad.panelZIndex = 31;
VE_Scratchpad.pinZIndex = 19;
VE_Scratchpad._typeToColor = {"adr":"blue", "yp":"blue", "al":"orange", "aN":"anno", "ad":"red" , "ls":"black"};
VE_Scratchpad.xmlHttp = null;
VE_Scratchpad.highWaterCount = 0;
VE_Scratchpad.Populate = function (entityIDs, doBestFit) {
if (!entityIDs || entityIDs.length == 0) {
return;
}
entityIDs = VE_AnnotationData.DeserializeAnnotationList(entityIDs);
state.UpdateFromScratchpad();
if (!entityIDs) {
if (doBestFit) {
window.setTimeout("VE_Scratchpad.SetBestMapView ()", 500);
}
return;
}
VE_Scratchpad.xmlHttp = GetXmlHttp();
var x = VE_Scratchpad.xmlHttp;
if (x) {
var primarySeparator = VE_SerializationConstants.primarySeparator[currentUrlApiVersion];
var url = "entities.ashx?fitmap=" + doBestFit + "&ids=" + escape(entityIDs.join(primarySeparator));
x.open("POST", url, true);
x.onreadystatechange = VE_Scratchpad._ResponseHandler;
x.send("");
}
};
VE_Scratchpad.SetBestMapView = function () {
if (VE_Scratchpad.entities) {
map.SetBestMapView(VE_Scratchpad.entities);
}
};
VE_Scratchpad._ResponseHandler = function () {
var x = VE_Scratchpad.xmlHttp;
if (x.readyState == 4) {
var code = x.responseText;
try {
eval(code);
}
catch (ex) {
}
VE_Scratchpad.xmlHttp == null;
}
};
VE_Scratchpad.AddSearchResult = function (searchIndex, entityID) {
// var s = VE_SearchManager.FindByIndex(searchIndex);
var s = 1;
if (!s) {
return;
}
var e = s.GetEntity(entityID);
if (!e) {
return;
}
if (VE_Scratchpad.Contains(entityID, e.type)) {
VE_Scratchpad.panel.Show();
VE_Scratchpad._ShowPins();
return;
}
VE_Scratchpad.AddResult(e);
if (this.onAddSearchResult) {
this.onAddSearchResult();
}
};
VE_Scratchpad.Contains = function (id, type) {
var e = VE_Scratchpad.entities;
for (var i = 0; i < e.length; i++) {
if (e[i].id == id && e[i].type == type) {
return true;
}
}
return false;
};
VE_Scratchpad.AddLocation = function (name, latitude, longitude, description, type) {
if (OnAMap) {
return;
}
if (!description) {
description = name;
}
name = (!spName ? "" : spName);
if (type != "adr" && type != "al" && type != "aN") {
type = "adr";
}
var id = VE_Scratchpad.locationCounter++;
var location = new VE_SearchResult(id, name, description, "", "", type, latitude, longitude);
var pinId = VE_Scratchpad.AddResult(location);
location.pinId = pinId;
if (this.onAddLocation)
{
this.onAddLocation();
}
return pinId;
};
VE_Scratchpad.OnAMap = function (id, name, latitude, longitude, description, type) {
if (!description) {
description = name;
}
if (type != "adr" && type != "al" && type != "aN" && type != "ad" && type != "ls") {
type = "adr";
}
var location = new VE_SearchResult(id, name, description, "", "", type, latitude, longitude);
var pinId = VE_Scratchpad.AddResult(location);
location.pinId = pinId;
if (this.onAddLocation) {
this.onAddLocation();
}
return pinId;
};
VE_Scratchpad.AddResults = function (entities) {
if (!entities || entities.constructor != Array) {
return;
}
var lengthItemsToAdd = Math.min(entities.length, VE_Scratchpad.maxScratchpadItems);
for (var i = 0; i < lengthItemsToAdd; i++) {
if (!entities[i] || entities[i].constructor != VE_SearchResult) {
continue;
}
if (entities[i].type == "adr" && entities[i].id == null) {
entities[i].id = VE_Scratchpad.locationCounter++;
}
VE_Scratchpad.AddResult(entities[i]);
}
if (this.onAddResults) {
this.onAddResults();
}
};
VE_Scratchpad.GeneratePinId = function (entity) {
if (!entity) {
return;
}
return "scratchpin_" + entity.id + "_" + entity.type;
};
VE_Scratchpad.GetColorForEntity = function (entity) {
if (!entity) {
return VE_Scratchpad.panelColor;
}
var color = VE_Scratchpad._typeToColor[entity.type];
if (color == null) {
color = VE_Scratchpad.panelColor;
}
return color;
};
VE_Scratchpad.AddResult = function (entity) {
if (!entity) {
return;
}
var e = VE_Scratchpad.entities;
e.push(entity);
var pinId = VE_Scratchpad.GeneratePinId(entity);
var pin = VE_Scratchpad._AddEntityPushpin(entity, entity.id);
if (entity.type == "aN") {
// pin.onmouseover = VE_Annotations.OpenPopup;
} else {
// pin.onmouseover = VE_SearchManager._ShowScratchpadPopup;
}
VE_Scratchpad._ShowPins();
VE_Scratchpad.highWaterCount = Math.max(VE_Scratchpad.highWaterCount, e.length);
return pinId;
};
VE_Scratchpad.GetEntity = function (id, type) {
var e = VE_Scratchpad.entities;
if (!e || e.length == 0) {
return null;
}
for (var i = 0; i < e.length; i++) {
if (e[i].id == id && e[i].type == type) {
return e[i];
}
}
return null;
};
VE_Scratchpad._ShowPins = function () {
var e = VE_Scratchpad.entities;
for (var i = 0; i < e.length; i++) {
if (e[i] && e[i].constructor == VE_SearchResult) {
VE_Scratchpad._AddEntityPushpin(e[i], e[i].id);
}
}
};
VE_Scratchpad._AddEntityPushpin = function (e, number) {
var color = VE_Scratchpad.GetColorForEntity(e);
var pinId = VE_Scratchpad.GeneratePinId(e);
var pinw = (e.type == "aN") ? 22 : 23;
var pinh = 17;
var pin = document.getElementById(pinId);
if (pin) {
return pin;
}
var spStyle = "VE_Pushpin_" + color;
if (navigator.userAgent.indexOf("IE") != -1 && navigator.userAgent.indexOf("IE 7") == -1 ) {
spStyle = "VE_Pushpin_IE";
}
var maptoolClass = "VE_Pushpin";
if (OnAMap) {
maptoolClass = "VE_Pushpin_onamap";
}
return map.AddPushpin(pinId, e.latitude, e.longitude, pinw, pinh, maptoolClass + " " + spStyle, number + "", VE_Scratchpad.pinZIndex);
};
var searchCounter = 0;
var searches = new Array();
var autoRefreshEnabled = 1;
var nextAutoRefresh = 0;
var activeSearch = null;
var useCurrentViewText = "[Use current map view]";
var maxsearches = 5;
function AutoRefresh() {
}
var windowWidth = 0;
var windowHeight = 0;
function GetWindowWidth() {
var width = 0;
if (typeof (window.innerWidth) == "number") {
width = window.innerWidth;
} else {
if (document.documentElement && document.documentElement.clientWidth) {
width = document.documentElement.clientWidth;
} else {
if (document.body && document.body.clientWidth) {
width = document.body.clientWidth;
}
}
}
if (!width || width < 100) {
width = 100;
}
return width;
}
function GetWindowHeight() {
var height = 0;
if (typeof (window.innerHeight) == "number") {
height = window.innerHeight;
} else {
if (document.documentElement && document.documentElement.clientHeight) {
height = document.documentElement.clientHeight;
} else {
if (document.body && document.body.clientHeight) {
height = document.body.clientHeight;
}
}
}
if (!height || height < 100) {
height = 100;
}
return height;
}
function GetUrlPrefix() {
var lastfslash = window.location.pathname.lastIndexOf("/");
var hosturl = window.location.protocol + "//" + window.location.hostname + window.location.pathname.substring(0, lastfslash + 1);
return hosturl;
}
function GetUrlParameterString() {
var urlParameterString = window.location.search;
if (urlParameterString.length == 0 || urlParameterString.indexOf("?") == -1) {
return "";
}
return urlParameterString.substr(urlParameterString.indexOf("?") + 1);
}
function GetUrlParameters() {
var parameters = new Array();
var urlParameterString = GetUrlParameterString();
if (!urlParameterString) {
return parameters;
}
var parameterStrings = urlParameterString.split("&");
for (var i = 0; i < parameterStrings.length; i++) {
var parameterParts = parameterStrings[i].split("=");
if (parameterParts.length == 2 && parameterParts[0] && parameterParts[1]) {
parameters.push(unescape(parameterParts[0]));
parameters.push(unescape(parameterParts[1]));
}
}
return parameters;
}
function GetXmlHttp() {
var x = null;
try {
x = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
try {
x = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {
x = null;
}
}
if (!x && typeof XMLHttpRequest != "undefined") {
x = new XMLHttpRequest();
}
return x;
}