	var foundLocationsListArray = new Array();
	var generatedMap = null;
	var mapDefinitionList = null;
	var currImgFormat = 0;
	var currWithCopyright = true;
	var pinLogoList = new Array();
	var polylinesList = new Array();
	var numericCriteriaList = new Array();
	var pixelPointList = new Array();
	var mapActionList = new Array();
	var inputPOIList = new Array();	
	var inputAddressList = new Array();
	var geoCoordinatesList = new Array();
	var categoryList = new Array();
	var ititraceList = null;

	function Cost(price, currency) {
		this.price = price;
		this.currency = currency;
	};
		
	function ItineraryPreferences(favourMotorways, avoidCrossingBorders, avoidTolls, avoidRoadTaxAreas, avoidOffroadConnections, avoidMountainPass) {
	    this.favourMotorways = favourMotorways;
	    this.avoidCrossingBorders = avoidCrossingBorders;
	    this.avoidTolls = avoidTolls;
	    this.avoidRoadTaxAreas = avoidRoadTaxAreas;
	    this.avoidOffroadConnections = avoidOffroadConnections;;
	    this.avoidMountainPass = avoidMountainPass;		
	};
	
	function ItineraryOptions(itiDate, vehicleType, itiType, itiPref, fuelCost, fuelConsumption) {
		this.itiDate = itiDate;
		this.vehicleType = vehicleType;
		this.itiType = itiType;
		this.itiPref = itiPref;
		this.fuelCost = fuelCost;
		this.fuelConsumption = fuelConsumption;
	};
	
	function ExtendedPresentationOptions(detailLevel, language, instructionsFormat, tollCategory) {
		this.detailLevel = detailLevel;
		this.language = language;
		this.instructionsFormat = instructionsFormat;
		this.tollCategory = tollCategory;
	};
	
	function ResponseOptions(responseElts, mapDefCalc, mainMapWidth, mainMapHeight, blocMapWidth, blocMapHeight) {
		this.responseElts = responseElts;
		this.mapDefCalc = mapDefCalc;
		this.mainMapWidth = mainMapWidth;
		this.mainMapHeight = mainMapHeight;
		this.blocMapWidth = blocMapWidth;
		this.blocMapHeight = blocMapHeight;
	};
	
	function ItineraryRequest(locDefList, itiOptions, presentationOptions, responseOptions) {
	   	this.locDefList = locDefList;
	   	this.itiOptions = itiOptions;
	   	this.presentationOptions = presentationOptions;
	   	this.responseOptions = responseOptions;
	};
	
	function DecodeItineraryTraceRequest(itiTrace, range) {
		this.itiTrace = itiTrace;
	   	this.range = range;
	};
	
	function NumericCriteria(criteriaKey, criteriaValue, compOp) {
		this.key = criteriaKey;
		this.val = criteriaValue;
		this.compOp = compOp;
	};
	
	function InputPOI(id, lat, lon) {
		this.id = id;
		this.coord = new GeoCoordinates(lon, lat);
	};
	
	function InputAddress(address, cityName, stateName, postalCode, countryCode) {
		this.address = address;
		this.cityName = cityName;
		this.countryCode = countryCode; 
		this.postalCode = postalCode;
		this.stateName = stateName;
	};
	
	function MapDefinitionByID(MapId, MapWidth, MapHeight) {
		this.MapId = MapId;
		this.MapWidth = MapWidth;
		this.MapHeight = MapHeight;
	};
	
	function MapDefinitionByScale(psize, center, MapWidth, MapHeight) {
		this.psize = psize;
		this.center = center;
		this.MapWidth = MapWidth;
		this.MapHeight = MapHeight;
	};

	function MapDefinitionByRect(northWestPoint, southEastPoint, MapWidth, MapHeight) {
		this.MapWidth = MapWidth;
		this.MapHeight = MapHeight;
		this.northWestPoint = northWestPoint;
		this.southEastPoint = southEastPoint;
	};
	
	function MapDefinitionList(byId, byRect, byScale) {
		this.byId = byId;
		this.byRect = byRect;
		this.byScale = byScale;
	};
	
	function GeneratedMap(mapURL, copyright, mapDefinitions) {
		this.mapURL = mapURL;
		this.copyright = copyright;
		this.mapDefinitions = mapDefinitions;
		this.zoomout = function anonymous() {
			var omapActionList = new Array();
			var mapAction = new MapAction(3, 0);
			omapActionList[omapActionList.length] = mapAction;
			mapManagement_getMapByID(this.mapDefinitions.byId.MapId, this.mapDefinitions.byId.MapWidth, this.mapDefinitions.byId.MapHeight, omapActionList, currImgFormat, currWithCopyright, pinLogoList, polylinesList, ititraceList);
		};
		
		this.zoomin = function anonymous() {
			var omapActionList = new Array();
			var mapAction = new MapAction(2, 0);
			omapActionList[omapActionList.length] = mapAction;
			mapManagement_getMapByID(this.mapDefinitions.byId.MapId, this.mapDefinitions.byId.MapWidth, this.mapDefinitions.byId.MapHeight, omapActionList, currImgFormat, currWithCopyright, pinLogoList, polylinesList, ititraceList);
		};
		
		
		this.move = function anonymous(dir) {
			var omapActionList = new Array();
			var mapAction = null;
			// EAST
			if (dir == 1) {
				mapAction = new MapAction(0, 0.5);
				omapActionList[omapActionList.length] = mapAction;
			// NORTH-EAST
			} else if (dir == 2) {
				mapAction = new MapAction(0, 0.5);
				omapActionList[omapActionList.length] = mapAction;
				mapAction = new MapAction(1, 0.5);
				omapActionList[omapActionList.length] = mapAction;
			// NORTH
			} else if (dir == 3) {
				mapAction = new MapAction(1, 0.5);
				omapActionList[omapActionList.length] = mapAction;
			// NORTH-WEST
			} else if (dir == 4) {
				mapAction = new MapAction(0, -0.5);
				omapActionList[omapActionList.length] = mapAction;
				mapAction = new MapAction(1, 0.5);
				omapActionList[omapActionList.length] = mapAction;
			// WEST
			} else if (dir == 5) {
				mapAction = new MapAction(0, -0.5);
				omapActionList[omapActionList.length] = mapAction;
			// SOUTH-WEST
			} else if (dir == 6) {
				mapAction = new MapAction(0, -0.5);
				omapActionList[omapActionList.length] = mapAction;
				mapAction = new MapAction(1, -0.5);
				omapActionList[omapActionList.length] = mapAction;
			// SOUTH
			} else if (dir == 7) {
				mapAction = new MapAction(1, -0.5);
				omapActionList[omapActionList.length] = mapAction;
			// SOUTH-EST
			} else if (dir == 8) {
				mapAction = new MapAction(0, 0.5);
				omapActionList[omapActionList.length] = mapAction;
				mapAction = new MapAction(1, -0.5);
				omapActionList[omapActionList.length] = mapAction;
			}
			mapManagement_getMapByID(this.mapDefinitions.byId.MapId, this.mapDefinitions.byId.MapWidth, this.mapDefinitions.byId.MapHeight, omapActionList, currImgFormat, currWithCopyright, pinLogoList, polylinesList, ititraceList);
		};	
		this.setPixelSize = function anonymous(newPs) {
			genMapByScale(newPs, this.mapDefinitions.byScale.center, this.mapDefinitions.byScale.MapWidth, this.mapDefinitions.byScale.MapHeight, null, currImgFormat, currWithCopyright, pinLogoList, polylinesList, ititraceList);
		};
		
		this.resize = function anonymous(x0, y0, x1, y1) {
			// compute the new pixel size
			var newPs = this.mapDefinitions.byScale.psize;
			if (parseInt(x1) == parseInt(x0)) {
				newPs = this.mapDefinitions.byScale.psize;
			} else if (parseInt(x1) > parseInt(x0)) {
				newPs = this.mapDefinitions.byScale.psize * ((parseInt(x1) - parseInt(x0)) / this.mapDefinitions.byScale.MapWidth);
			} else {
				newPs = this.mapDefinitions.byScale.psize * ((parseInt(x0) - parseInt(x1)) / this.mapDefinitions.byScale.MapWidth);
			}
			// compute the new map center
			var x  = parseInt((parseInt(x0) +  parseInt(x1)) / 2);
			var y  = parseInt((parseInt(y0) +  parseInt(y1)) / 2);
			var pixelPoint = new PixelPoint(x, y);
			var pixelsList = new Array();
			pixelsList[pixelsList.length] = pixelPoint;
			var geoCoordinatesList = mapManagement_pixelsToXY(this.mapDefinitions.byId, null, pixelsList);
			var newcenter = geoCoordinatesList[0];
			// generate the new map
			genMapByScale(newPs, newcenter, this.mapDefinitions.byScale.MapWidth, this.mapDefinitions.byScale.MapHeight, null, currImgFormat, currWithCopyright, pinLogoList, polylinesList, ititraceList);
		};
	};

	function FoundLocationFormat(order, bPhoto, bAddr, bAddrDetail, bMetanum, bMetaStr, bDescLst, bCatLst, datasheetContent, language) {
		this.order = order;
		this.bPhoto = bPhoto;
		this.bAddr = bAddr;
		this.bAddrDetail = bAddrDetail;
		this.bMetanum = bMetanum;
		this.bMetaStr = bMetaStr;
		this.bDescLst = bDescLst;
		this.bCatLst = bCatLst;
		this.datasheetContent = datasheetContent; 
		this.language = language;
	};
	
	function KeyValuePair(key, val) {
		this.key = key;
		this.val = val;
	};
	
	function POI(poiDB, poilang, poiID, poiName, poiDatasheet, metanumList, metastringList, descriptionList, categories, photos) {
		this.poiDB = poiDB;
		this.poilang = poilang;
		this.poiID = poiID;
		this.poiName = poiName;
		this.poiDatasheet = poiDatasheet;
		this.metanumList = metanumList;
		this.metastringList = metastringList;
		this.descriptionList = descriptionList;
		this.categories = categories;
		this.photos = photos;
	};
	
	function CoherenceDegreeInfo(streetCoherence, cityCoherence) {
		this.streetCoherence = streetCoherence;
		this.cityCoherence = cityCoherence;
	};
	
	function AddressDetails(city, countryCode, countryLabel, district, gathering, officialCountryCode, state, streetLabel, streetNumber, zipCode) {
		this.city = city;
		this.countryCode = countryCode;
		this.countryLabel = countryLabel;
		this.district = district;
		this.gathering = gathering;
		this.officialCountryCode = officialCountryCode;
		this.state = state;
		this.streetLabel = streetLabel;
		this.streetNumber = streetNumber;
		this.zipCode = zipCode;		
	};
	
	function Address(coherenceDegreeInfo, formattedCityLine, formattedStreetLine, details) {
		this.coherenceDegreeInfo = coherenceDegreeInfo;
		this.formattedCityLine = formattedCityLine;
		this.formattedStreetLine = formattedStreetLine;
		this.details = details;
	};
	
	function PixelPoint(x, y) {
		this.x = x;
		this.y = y;
	};
	
	function GeoCoordinates(lon, lat) {
		this.lat = lat;
		this.lon = lon;
	};
		
	function Location(locid, locType, geoCoord, address, poi) {
		this.locid = locid; 
		this.locationType = locType;
		this.geoCoord = geoCoord;
		this.address = address;
		this.poi = poi;
	};
	
	function FoundLocation(distance, duration, locDesc) {
		this.distance = distance;
		this.duration = duration;
		this.locDesc = locDesc;
	};

	function FoundLocationList(searchStatus, size, foundLocations) {
		this.searchStatus = searchStatus;
		this.size = size;
		this.foundLocations = foundLocations;
	};
	
	function PoiID(id, dbId, lang) {
		this.id = id;
		this.dbId = dbId;
		this.lang = lang;
	};
	
	function LocDefinition(coord, locID, poiID) {
		this.coord = coord;
		this.locID = locID;
		this.poiID = poiID;
	};
	
	function MapAction(type, value) {
		this.type = type;
		this.value = value;
	};
	
	function InputTrace(color, thickness, pixelPointList, geoCoordinatesList) {
		this.color	= color;
		this.thickness = thickness;
		this.pixelPointList = pixelPointList;
		this.geoCoordinatesList = geoCoordinatesList;
	};
	
	function PinLogo(id, pixelPos, coord, displayMode, IconName, IconWidth, IconHeight, hotArea) {
		this.id = id;
		this.pixelPos = pixelPos;
		this.coord = coord;
		this.displayMode = displayMode;
		this.IconName = IconName;
		this.IconWidth = IconWidth;
		this.IconHeight = IconHeight;
		this.hotArea = hotArea;
	};
	
	function FindNearbyDailyServicesParams(searchCenter, maxResult, maxDistance, categories) {
		this.searchCenter = searchCenter;
		this.maxResult = maxResult;
		this.maxDistance = maxDistance;
		this.categories = categories;
	};
	
	function FindByKeywordsParams(keywords, maxResult, countryCode) {
		this.keywords = keywords;
		this.maxResult = maxResult;
		this.countryCode = countryCode;
	};
	
	function FindNearbyByRoadParams(searchCenter, maxResult, maxDistance, maxDuration, mode, itineraryOptions) {
		this.searchCenter = searchCenter;
		this.maxResult = maxResult;
		this.maxDistance = maxDistance;
		this.maxDuration = maxDuration;
		this.mode = mode;
		this.itineraryOptions = itineraryOptions;
	};
	
	function FindNearbyParams(searchCenter, maxResult, maxDistance) {
		this.searchCenter = searchCenter;
		this.maxResult = maxResult;
		this.maxDistance = maxDistance;
	};
	
	function NumCriteriaDefinition(mode, numericCriteriaList) {
		this.mode = mode;
		this.numericCriteriaList = numericCriteriaList;
	};
	
	function TextCriteriaDefinition(keywords, mode, scope) {
		this.keywords = keywords;
		this.mode = mode;
		this.scope = scope;
	};
	
	function SearchCriteria(textCriteria, numCriteria) {
		this.textCriteria = textCriteria;
		this.numCriteria = numCriteria;
	};
	
	function FindPOIRequest(searchDataset, searchParams, searchFilter, resultFormat) {
		this.searchDataset = searchDataset;
		this.searchParams = searchParams;
		this.searchFilter = searchFilter;
		this.resultFormat = resultFormat;
	};
	
	// ******************************************************
	// ******************************************************
	function getxhr_object() {
		if(window.XMLHttpRequest) {
		   return new XMLHttpRequest();
		} else if(window.ActiveXObject) {
		   return new ActiveXObject("Microsoft.XMLHTTP");
		} else { 
		   return null;
		}
	};
	
	// ******************************************************
	// invoke (synchrone) pixelsToXY method of MapManagement Web Service	
	// ******************************************************
	function mapManagement_pixelsToXY(mapDefByID, mapDefByScale, pixelsList) {
		var xhr_object = getxhr_object();
		if (xhr_object == null) return;
		
		var methodName = 'pixelsToXY';
		params = 'method=' + methodName;
		if ((mapDefByID != null) && (typeof(mapDefByID) != "undefined")) {
			params = params+"&mapDefByIdMapId="+mapDefByID.MapId+"&mapDefWidth="+mapDefByID.MapWidth+"&mapDefHeight="+mapDefByID.MapHeight;
		}
		if ((mapDefByScale != null) && (typeof(mapDefByScale) != "undefined")) {
			params = params+"&mapDefps="+mapDefByScale.psize+"&mapDefcenterlon="+mapDefByScale.center.lon+"&mapDefcenterlat="+mapDefByScale.center.lat+"&mapDefWidth="+mapDefByScale.MapWidth+"&mapDefHeight="+mapDefByScale.MapHeight;
		}

		if ((typeof(pixelsList) != "undefined")) {
			params = params + "&pixelsListSize="+pixelsList.length;
			for (var cpt = 0; cpt < pixelsList.length; cpt++) {
				params = params + "&x"+cpt+"="+pixelsList[cpt].x+"&y"+cpt+"="+pixelsList[cpt].y;
			}
		}
		xhr_object.open("POST", lib_folder + "pixelsToXY.php", false);
		
		xhr_object.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xhr_object.send(params);		
		
		if (xhr_object.readyState == 4) {
			var items = new Array();
			var str =  xhr_object.responseText;
			items = str.split('|');
			var idx = 0;
			var lat = 0;
			var lon = 0;
			var geoCoordinatesList = new Array();

			if ((pixelsList != null) && (typeof(pixelsList) != "undefined")) {
				for (var cpt = 0; cpt < pixelsList.length; cpt++) {
					var cpti = 0;
					var bfound = false;
					while ((cpti < items.length) && (bfound == false))  {
						if (items[cpti].indexOf("lon"+cpt+":") != -1) {
							lon = parseFloat(items[cpti].substring(("lon"+cpt+":").length));
							lat = parseFloat(items[cpti+1].substring(("lat"+cpt+":").length));
							var coord = new GeoCoordinates(lon, lat);
							geoCoordinatesList[cpt] = coord;		
							bfound = true;
						} 
						cpti = cpti + 1;
					}
					if (!bfound) {
						geoCoordinatesList[cpt] = null;
					}
				}
			} 
			cpti = 0;
			var errorMsg = null;
			var errorMsgDetail = null;
			while (cpti < items.length) {
				if (items[cpti].indexOf("error:") != -1) {				
					errorMsg = items[cpti].substring("error:".length);
				} else if (items[cpti].indexOf("errorDetail:") != -1) {				
					errorMsgDetail = items[cpti].substring("errorDetail:".length);
				}
				cpti = cpti + 1;
			}

			if ((errorMsg != null) || (errorMsgDetail != null)) {
				errorMsg = '[method: ' + methodName + '] ' + errorMsg;
				displayError(errorMsg, errorMsgDetail);
			}			
			return geoCoordinatesList;
		}
	};

	// ******************************************************
	// ******************************************************
	function getParamsFromMapActionList(omapActionList) {
		var _params = '';
		if (omapActionList != null) {
			_params  = _params  + '&mapActionSize='+omapActionList.length;
			for (var cptj=0; cptj < omapActionList.length; cptj++) {
				if (omapActionList[cptj] != null){
					_params  = _params  + '&mapActionType'+cptj+'='+omapActionList[cptj].type;
					_params  = _params  + '&mapActionValue'+cptj+'='+omapActionList[cptj].value;
				}
			}
		} 
		return _params;
	};
	
	// ******************************************************
	// ******************************************************
	function getParamsFromPinLogoList(opinLogoList) {
		var _params = '';
		if (opinLogoList != null) {
			_params = _params + '&pinLogoSize='+opinLogoList.length;
			for (var cptk=0; cptk < opinLogoList.length; cptk++) {
				if (opinLogoList[cptk] != null){
					_params = _params + '&pinLogoID'+cptk+'='+opinLogoList[cptk].id;
					if (opinLogoList[cptk].pixelPos != null) {
						_params = _params + '&pinLogoX'+cptk+'='+opinLogoList[cptk].pixelPos.x+'&pinLogoY'+cptk+'='+opinLogoList[cptk].pixelPos.y;
					}
					if (opinLogoList[cptk].coord != null) {
						_params = _params + '&pinLogoLon'+cptk+'='+opinLogoList[cptk].coord.lon+'&pinLogoLat'+cptk+'='+opinLogoList[cptk].coord.lat;
					}
					_params = _params + '&pinLogoMode'+cptk+'='+opinLogoList[cptk].displayMode;
					_params = _params + '&pinLogoIconName'+cptk+'='+opinLogoList[cptk].IconName;
					_params = _params + '&pinLogoIconWidth'+cptk+'='+opinLogoList[cptk].IconWidth;
					_params = _params + '&pinLogoIconHeight'+cptk+'='+opinLogoList[cptk].IconHeight;
					_params = _params + '&pinLogohotArea'+cptk+'='+opinLogoList[cptk].hotArea;
				}
			}
		} 
		return _params;
	};
		
	// ******************************************************
	// ******************************************************
	function getParamsFromPolylinesList(opolylinesList) {		
		var _params = '';
		if (opolylinesList != null) {
			_params = _params + '&polylinesSize='+opolylinesList.length;
			for (var cptl=0; cptl < opolylinesList.length; cptl++) {
				if (opolylinesList[cptl] != null){
					_params = _params + '&polylinesColor'+cptl+'='+opolylinesList[cptl].color;;
					_params = _params + '&polylinesThickness'+cptl+'='+opolylinesList[cptl].thickness;
					if (opolylinesList[cptl].pixelPointList != null) {
						_params = _params + '&polylinespixelPointListSize'+cptl+'='+opolylinesList[cptl].pixelPointList.length;
						for (var cptm=0; cptm < opolylinesList[cptl].pixelPointList.length; cptm++) {
							if (opolylinesList[cptl].pixelPointList[cptm] != null) {
								_params = _params + '&polylinespixelPointList'+cptl+'X'+cptm+'='+opolylinesList[cptl].pixelPointList[cptm].x;
								_params = _params + '&polylinespixelPointList'+cptl+'Y'+cptm+'='+opolylinesList[cptl].pixelPointList[cptm].y;
							}
						}
					} 
					if (opolylinesList[cptl].geoCoordinatesList != null) {
						_params = _params + '&polylinesgeoCoordListSize'+cptl+'='+opolylinesList[cptl].geoCoordinatesList.length;
						for (var cptn=0; cptn < opolylinesList[cptl].geoCoordinatesList.length; cptn++) {
							if (opolylinesList[cptl].geoCoordinatesList[cptn] != null) {
								_params = _params + '&polylinesgeoCoordList'+cptl+'Lon'+cptn+'='+opolylinesList[cptl].geoCoordinatesList[cptn].lon;
								_params = _params + '&polylinesgeoCoordList'+cptl+'Lat'+cptn+'='+opolylinesList[cptl].geoCoordinatesList[cptn].lat;
							}
						}
					}
				}
			}
		} 	
		return _params;	
	};
	
	// ******************************************************
	// ******************************************************
	function getParamsFromItitraceList(oititraceList) {		
		var _params = '';
		if ((oititraceList != null) && (typeof(oititraceList) != "undefined")) {
			_params = _params + '&ititraceSize='+oititraceList.length;
			for (var cptm=0; cptm < oititraceList.length; cptm++) {
				_params = _params + '&ititracePart' + cptm + '=' + oititraceList[cptm];
			}
		}	
		return _params;	
	};
	
	// *************************************************************
	// *************************************************************
	function displayGeneratedMap(methodName, xhr_object) {	
		if(xhr_object.readyState == 4) {
			var str = xhr_object.responseText;
			var items = new Array();
			var errorMsg = null;
			var errorMsgDetail = null;
			items = str.split('|');
			for (cpt = 0; cpt < items.length; cpt++) {
				if (items[cpt].indexOf("js:") != -1) {				
					eval(items[cpt].substring("js:".length));
					myKaMap.routingFuncs.getGeneratedMap(generatedMap);
					return true;
				} else if (items[cpt].indexOf("error:") != -1) {				
					errorMsg = items[cpt].substring("error:".length);
				} else if (items[cpt].indexOf("errorDetail:") != -1) {				
					errorMsgDetail = items[cpt].substring("errorDetail:".length);
				}
			}
			if ((errorMsg != null) || (errorMsgDetail != null)) {
				errorMsg = '[method: ' + methodName + '] ' + errorMsg;
				displayError(errorMsg, errorMsgDetail);
			}						
		} 		
		return false;
	};

	// ******************************************************
	// invoke getMapByScale method of MapManagement Web Service	
	// ******************************************************
	function mapManagement_getMapByScale(ps, center, width, height, mapActionList, imgFormat, withCopyright, pinLogoList, polylinesList, oititraceList) {
		var xhr_object = getxhr_object();
		if (xhr_object == null) return;
		
		currImgFormat = imgFormat;
		currWithCopyright = withCopyright;		
		
		var methodName = 'getMapByScale';
		params = 'method=' + methodName + '&ps='+ps+'&width='+width+'&height='+height+'&imgFormat='+imgFormat+'&withCopyright='+withCopyright;
		params = params + '&centerLon='+center.lon;
		params = params + '&centerLat='+center.lat;
		
		params = params + getParamsFromMapActionList(mapActionList);
		params = params + getParamsFromPinLogoList(pinLogoList);
		params = params + getParamsFromPolylinesList(polylinesList);
		params = params + getParamsFromItitraceList(oititraceList);

		xhr_object.open("POST", lib_folder + "getMapByScale.php", true); 
		xhr_object.onreadystatechange = function anonymous() {displayGeneratedMap(methodName, xhr_object);};
		xhr_object.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-1");
		xhr_object.send(params);		
	};		
	
	// ******************************************************
	// invoke getMapByID method of MapManagement Web Service	
	// ******************************************************
	function mapManagement_getMapByID(mapId, width, height, mapActionList, imgFormat, withCopyright, pinLogoList, polylinesList, oititraceList) {
		var xhr_object = getxhr_object();
		if (xhr_object == null) return;
		
		currImgFormat = imgFormat;
		currWithCopyright = withCopyright;		
		var methodName = 'getMapByID';
		params = 'method='+ methodName +'&mapId='+mapId+'&width='+width+'&height='+height+'&imgFormat='+imgFormat+'&withCopyright='+withCopyright;
		
		params = params + getParamsFromMapActionList(mapActionList);
		params = params + getParamsFromPinLogoList(pinLogoList);
		params = params + getParamsFromPolylinesList(polylinesList);
		params = params + getParamsFromItitraceList(oititraceList);
		xhr_object.open("POST", lib_folder + "getMapByID.php", true); 
		xhr_object.onreadystatechange = function anonymous() {displayGeneratedMap(methodName, xhr_object);};
		xhr_object.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-1");
		xhr_object.send(params);		
	};		
	
	// *************************************************************
	// *************************************************************
	function getGeneratedMap(methodName, xhr_object) {	
		if(xhr_object.readyState == 4) {
			var str = xhr_object.responseText;
			var items = new Array();
			var errorMsg = null;
			var errorMsgDetail = null;
			items = str.split('|');
			for (cpt = 0; cpt < items.length; cpt++) {
				if (items[cpt].indexOf("js:") != -1) {				
					eval(items[cpt].substring("js:".length));
					return generatedMap;
					return true;
				} else if (items[cpt].indexOf("error:") != -1) {				
					errorMsg = items[cpt].substring("error:".length);
				} else if (items[cpt].indexOf("errorDetail:") != -1) {				
					errorMsgDetail = items[cpt].substring("errorDetail:".length);
				}
			}
			if ((errorMsg != null) || (errorMsgDetail != null)) {
				errorMsg = '[method: ' + methodName + '] ' + errorMsg;
				displayError(errorMsg, errorMsgDetail);
			}						
		} 		
		return null;
	};	
	

	// ******************************************************
	// invoke getMapByID method of MapManagement Web Service	
	// ******************************************************
	function mapManagement_getMapByID_sync(mapId, width, height, mapActionList, imgFormat, withCopyright, pinLogoList, polylinesList, oititraceList) {
		var xhr_object = getxhr_object();
		if (xhr_object == null) return;
		
		currImgFormat = imgFormat;
		currWithCopyright = withCopyright;		
		var methodName = 'getMapByID';
		params = 'method='+ methodName +'&mapId='+mapId+'&width='+width+'&height='+height+'&imgFormat='+imgFormat+'&withCopyright='+withCopyright;
		
		params = params + getParamsFromMapActionList(mapActionList);
		params = params + getParamsFromPinLogoList(pinLogoList);
		params = params + getParamsFromPolylinesList(polylinesList);
		params = params + getParamsFromItitraceList(oititraceList);
		
		xhr_object.open("POST", lib_folder + "getMapByID.php", false); 
		xhr_object.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-1");
		xhr_object.send(params);		
		return getGeneratedMap(methodName, xhr_object);	
	};		
	
	// ******************************************************
	// invoke getLocationList method of Geocoding Web Service	
	// ******************************************************
	function geocoding_getLocationList_sync(formid, mode, inputAddressList) {
		var xhr_object = getxhr_object();
		if (xhr_object == null) return;
		
		params = "size="+inputAddressList.length + "&mode="+mode;
		for(cpt=0; cpt< inputAddressList.length; cpt++) {
			if (inputAddressList[cpt] != null) {
				params = params  + '&address'+cpt+'='+encodeURIComponent(inputAddressList[cpt].address);
				params = params  + '&cityName'+cpt+'='+encodeURIComponent(inputAddressList[cpt].cityName);
				params = params  + '&countryCode'+cpt+'='+inputAddressList[cpt].countryCode;
				params = params  + '&postalCode'+cpt+'='+inputAddressList[cpt].postalCode;
				params = params  + '&stateName'+cpt+'='+encodeURIComponent(inputAddressList[cpt].stateName);
				params = params  + '&coordX'+cpt+'='+encodeURIComponent(inputAddressList[cpt].coordX);
				params = params  + '&coordY'+cpt+'='+encodeURIComponent(inputAddressList[cpt].coordY);
			}
		}
		params = params  + '&form='+formid;
		params = params  + '&select=lstLocation';

		xhr_object.open("POST", lib_folder + "getLocation.php", false); 
		xhr_object.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-1");
		xhr_object.send(params);		
		if(xhr_object.readyState == 4) {
			var str = xhr_object.responseText;
			var items = new Array();
			var errorMsg = null;
			var errorMsgDetail = null;
			items = str.split('|');
			for (cpt = 0; cpt < items.length; cpt++) {
				if (items[cpt].indexOf("js:") != -1) {				
					eval(items[cpt].substring("js:".length));
				}
				else if (items[cpt].indexOf("error:") != -1) {				
					errorMsg = items[cpt].substring("error:".length);
				}
				else if (items[cpt].indexOf("errorDetail:") != -1) {				
					errorMsgDetail = items[cpt].substring("errorDetail:".length);
				}
			}
			if ((errorMsg != null) || (errorMsgDetail != null)) {
				errorMsg = '[method: ' + methodName + '] ' + errorMsg;
				displayError(errorMsg, errorMsgDetail);
				return false;
			} else {
				return true;
			}
		} 		
	};	
	
	
	// *************************************************************
	// *************************************************************
	function displayCalculatedRoute(calculatedRoute, itiRequest) {	
		if ((calculatedRoute != null) && (typeof(calculatedRoute) != "undefined")) {
			if (calculatedRoute.roadmap != null) 
				showItineraryRoadmap(calculatedRoute.roadmap);
			if (calculatedRoute.mapId != null)
				showItineraryMap(calculatedRoute.mapId, itiRequest.responseOptions.mainMapWidth, itiRequest.responseOptions.mainMapHeight, calculatedRoute.ititrace);
		}
	};
	
	// *************************************************************
	// *************************************************************
	function getCalculatedRoute(methodName, xhr_object) {	
		if(xhr_object.readyState == 4) {
			var str = xhr_object.responseText;
			var items = new Array();
			items = str.split('|');
			var errorMsg = null;
			var errorMsgDetail = null;
			var oititraceList = null;
			var mapId = null;
			var roadmap = null;
			for (cpt = 0; cpt < items.length; cpt++) {
				if (items[cpt].indexOf("html:") != -1) {	
					roadmap = items[cpt].substring("html:".length);
				} else if (items[cpt].indexOf("mapID:") != -1) {
					if (items[cpt].length > "mapID:".length) {
						mapId = items[cpt].substring("mapID:".length);
					}
				} else if (items[cpt].indexOf("itiTraceSize:") != -1) {
					nbtrace = parseInt(items[cpt].substring("itiTraceSize:".length));
					oititraceList = new Array();
					for (var cpti=cpt+1; cpti < cpt + 1 + nbtrace; cpti++) {
						oititraceList[oititraceList.length] = items[cpti].substring(("itiTracePart" + cpti+ ":").length);
					}
					currentItiTrace = oititraceList;
				} else if (items[cpt].indexOf("error:") != -1) {				
					errorMsg = items[cpt].substring("error:".length);
				} else if (items[cpt].indexOf("errorDetail:") != -1) {				
					errorMsgDetail = items[cpt].substring("errorDetail:".length);
				}
			}
			
			if ((errorMsg != null) || (errorMsgDetail != null)) {
				errorMsg = '[method: ' + methodName + '] ' + errorMsg;
				displayError(errorMsg, errorMsgDetail);
			} else {
				return {roadmap: roadmap, mapId: mapId, ititrace: oititraceList}
			}
		} 
	};
	
	// ******************************************************
	// ******************************************************
	function getParamsFromResponseOptions(oresponseOptions){
		var _params = '';
		_params = _params + '&relt=' + oresponseOptions.responseElts;
		_params = _params + '&mapdef=' + oresponseOptions.mapDefCalc;
		_params = _params + '&mmw=' + oresponseOptions.mainMapWidth;
		_params = _params + '&mmh=' + oresponseOptions.mainMapHeight;
		_params = _params + '&dmw=' + oresponseOptions.blocMapWidth;
		_params = _params + '&dmh=' + oresponseOptions.blocMapHeight;
		
		return _params;
	};
	
	// ******************************************************
	// ******************************************************
	function getParamsFromLocDefList(olocDefList) {
		var _params = '';
		if (olocDefList != null) {
			_params = _params + '&locDefSize='+olocDefList.length;
			for (var cpti=0; cpti < olocDefList.length; cpti++) {
				if ((olocDefList[cpti].locID != null) && (typeof(olocDefList[cpti].locID) != "undefined")){
					_params = _params + '&locDefLocID'+cpti+'='+olocDefList[cpti].locID;
				}
				if ((olocDefList[cpti].poiID != null) && (typeof(olocDefList[cpti].poiID) != "undefined")){
					_params = _params + '&locDefPoiID'+cpti+'='+olocDefList[cpti].poiID.id;
					_params = _params + '&locDefPoiLang'+cpti+'='+olocDefList[cpti].poiID.lang;
					_params = _params + '&locDefPoiDB'+cpti+'='+olocDefList[cpti].poiID.dbId;
				}
				if ((olocDefList[cpti].coord != null) && (typeof(olocDefList[cpti].coord) != "undefined")){
					_params = _params + '&locDefCoordLon'+cpti+'='+olocDefList[cpti].coord.lon;
					_params = _params + '&locDefCoordLat'+cpti+'='+olocDefList[cpti].coord.lat;
				}
			}
		} 
		return _params;
	};
			
	// **********************************************************************
	// invoke getRoute method of RouteCalculation Web Service (asynchronous)
	// **********************************************************************	
	function routeCalculation_getRoute(itiRequest) {
		var xhr_object = getxhr_object();
		if (xhr_object == null) return;
		
		// init parameters
		var methodName = 'getRoute';
		params = 'method=' + methodName;
		params = params + '&itiDate=' + itiRequest.itiOptions.itiDate;
		params = params + '&vType=' + itiRequest.itiOptions.vehicleType;
		params = params + '&iType=' + itiRequest.itiOptions.itiType;
		params = params + '&fmw=' + itiRequest.itiOptions.itiPref.favourMotorways;
		params = params + '&acb='+ itiRequest.itiOptions.itiPref.avoidCrossingBorders;
		params = params + '&at=' + itiRequest.itiOptions.itiPref.avoidTolls;
		params = params + '&art=' + itiRequest.itiOptions.itiPref.avoidRoadTaxAreas;
		params = params + '&aoc=' + itiRequest.itiOptions.itiPref.avoidOffroadConnections;
		params = params + '&amp=' + itiRequest.itiOptions.itiPref.avoidMountainPass;	  
		params = params + '&fprice=' + itiRequest.itiOptions.fuelCost.price;
		params = params + '&fcurr=' + itiRequest.itiOptions.fuelCost.currency;
		params = params + '&fcons1=' + itiRequest.itiOptions.fuelConsumption[0];
		params = params + '&fcons2=' + itiRequest.itiOptions.fuelConsumption[1];
		params = params + '&fcons3=' + itiRequest.itiOptions.fuelConsumption[2];

		params = params + '&dL=' + itiRequest.presentationOptions.detailLevel;
		params = params + '&lang=' + itiRequest.presentationOptions.language;
		params = params + '&format=' + itiRequest.presentationOptions.instructionsFormat;
		params = params + '&toll=' + itiRequest.presentationOptions.tollCategory;
		
		params = params + getParamsFromResponseOptions(itiRequest.responseOptions);
		params = params + getParamsFromLocDefList(itiRequest.locDefList);
		xhr_object.open("POST", lib_folder + "getRoute.php", true);
		xhr_object.onreadystatechange = function anonymous() {myKaMap.routingFuncs.routingCallback(getCalculatedRoute(methodName, xhr_object), itiRequest);};
		xhr_object.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-1");
		xhr_object.send(params);			
	};
	
	// *************************************************************
	// invoke getRouteNonMotorized method of RouteCalculation Web Service
	// *************************************************************	
	function routeCalculation_getRouteNonMotorized(itiRequest) {
		var xhr_object = getxhr_object();
		if (xhr_object == null) return;
		
		// init parameters
		var methodName = 'getRouteNonMotorized';
		params = 'method=' + methodName;
		params = params + '&itiDate=' + itiRequest.itiOptions.itiDate;
		params = params + '&vType=' + itiRequest.itiOptions.vehicleType;

		params = params + '&dL=' + itiRequest.presentationOptions.detailLevel;
		params = params + '&lang=' + itiRequest.presentationOptions.language;
		params = params + '&format=' + itiRequest.presentationOptions.instructionsFormat;
		
		params = params + getParamsFromResponseOptions(itiRequest.responseOptions);
		params = params + getParamsFromLocDefList(itiRequest.locDefList);
		
		xhr_object.open("POST", lib_folder + "getNonMotorizedRoute.php", true);
		xhr_object.onreadystatechange = function anonymous() {displayCalculatedRoute(getCalculatedRoute(methodName, xhr_object), itiRequest);};
		xhr_object.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-1");
		xhr_object.send(params);			
	};
