// ==================================================================
//
// This file contains functionality used for various  kinds of map (eg. 
// journey  planner traffic situation map, parking situation map, ...).
//
// ==================================================================

// ==================================================================
// Global variables
// ==================================================================

// the map
var mdvMap;
// array to store validity intervals
var validityIntervals = new Array();


// ==================================================================
// Common map functionality
// ==================================================================

// This function loads and initializes the map when the site is loaded.
function onLoadMapHandler(name) {
	initMdvMapConfig(name);
	if (mdvMap == null) {
		mdvMap = new MDVMapHelper(name);
	}
	// update validity on traffic/train situation screen
	if (currentPage == 'trainSituation' || currentPage == 'trafficSituation') {
		updateValidity();
	}
	else {
		// open journey if only one recomendation available
		if (isSingleJourney) {
			openFirstJourney();
		}
		// show ics messages monomodal car journeys
		if (document.getElementById('itdLPxx_showICSMsg') && document.getElementById('itdLPxx_showICSMsg').value=='true') {
			displayItICSMessages ('106');
		}
		// show parkings for monomodal car journeys
		if (document.getElementById('itdLPxx_showParking') && document.getElementById('itdLPxx_showParking').value!='') {
			parkingSearch (document.getElementById('itdLPxx_showParking').value);
		}
	}
}


// This function unloads the map when the site is unloaded.
// Parameter:	name - name of map that mus NOT be destroyed 
function onUnloadMapHandler(name) {
	if (mdvMap && (!name || mdvMap.mdvMap.name != name)) {
        // test if map has its own destroy function
        try {
            mdvMap.destroy();
        }
        catch (e) {
            mdvMap.mdvMap.destroy();
        }
		this.mdvMap = null;
	}	
}


// Create map control and translate the alt text.	
MDVMapHelper.prototype.createMapControl = function () {
	var controlText = new Array();
	controlText['goNorth'] = goNorth;
	controlText['goWest'] = goWest;
	controlText['goEast'] = goEast;
	controlText['goSouth'] = goSouth;
	controlText['lastResult'] = lastResult;
	controlText['zoomIn'] = zoomIn;
	controlText['zoomOut'] = zoomOut;
	
	new MDVMapControl(this.mdvMap, controlText);
}	


// Creates rectangle zoom functionality
MDVMapHelper.prototype.createZoomRectangle = function () {
	if (enableZoomRect == 'true') {
		this.rectZoom = new MDVRectZoom(this.mdvMap, {
			opacity: 0.3,
			border: '2px solid #407ABA',
			useButton: true,
			buttonImg: 'panBtn.png',
			buttonImgOver: 'panBtn_rollover.png',
			buttonImgActive: 'panBtn_active.png',
			buttonPosLeft: '20px',
			buttonPosTop: '280px',
            title: rectZoomTitle,
            alt: rectZoomTitle,
            titleActive: rectZoomTitleActive,
            altActive: rectZoomTitleActive

		});
	}
}


// This function stores the map centre and zoomlevel.
function storeMapCentreAndZoomlevel () {
	if (document.getElementById('itdLPxx_mapCentre') && document.getElementById('itdLPxx_zoomLevel')) {
		var mapCentre = mdvMap.mdvMap.getCentre();
		document.getElementById('itdLPxx_mapCentre').value = mapCentre.x + ':' + mapCentre.y + ':' + mapCentre.mapName;
		document.getElementById('itdLPxx_zoomLevel').value = parseInt(mdvMap.mdvMap.config.getZoomLevelIndex(), 10);
	}
}


// This function sets the map centre and zoomlevel.
function setMapCentreAndZoomlevel () {
	if (document.getElementById('itdLPxx_mapCentre') && document.getElementById('itdLPxx_zoomLevel')) {
		var coord = document.getElementById('itdLPxx_mapCentre').value.split(':');
		var zl = parseInt(document.getElementById('itdLPxx_zoomLevel').value, 10);
		if (zl > 8)
			zl = 8;
		mdvMap.mdvMap.setCentre (new MDVCoordinates(coord[2], parseInt(coord[0]), parseInt(coord[1])));
		mdvMap.mdvMap.setZoomLevel(zl);
		mdvMap.mdvMap.update();
	}
}


// This funtion returns the first DIV element with a certain class name.
// Parameter: 	clsName - class name of div element
function getDivsByClassName (clsName) {
	var retVal = new Array();
	var elements = document.getElementsByTagName("div");
	for(var i = 0;i < elements.length;i++){

		if(elements[i].className && elements[i].className.indexOf(" ") >= 0){
						
			var classes = elements[i].className.split(" ");
			for(var j = 0;j < classes.length;j++){
				if(classes[j] == clsName)
					retVal.push(elements[i]);
			}
		}
		else if(elements[i].className == clsName)
			retVal.push(elements[i]);
	}
	return retVal;
}


// This function inializes the resizing of map. It is necesarry for a correct centre. 
function ResizeMap () {
	mdvMap.mdvMap.resize();
}


if (window && window.onresize)
	window.onresize = ResizeMap;


// ==================================================================
// Tooltip common functionality 
// ==================================================================

// This function creates the tootltip.
MDVMapHelper.prototype.onToolTip = function(id, msg, obj) {
	if (obj.isFixed())
		return;
	if (obj.isVisible()) {
		if (!obj.helper) {
			obj.helper = new MDVToolTipHelper(obj);
        }
		obj.helper.execute(obj);
	}
	else if (obj.invisibleContent && obj.helper) {
		obj.helper.destroyContent(obj);
	}
}


// This function destroys the content of the tooltip bubble.
MDVToolTipHelper.prototype.destroyContent = function(tooltip) {
	var name = 'name_' + tooltip.id;
	var body = '<div id="' + name + '">';
	body += '</div>';
	this.toolTip.setInnerHTML(body);
	this.processed = false;
}


// Set tooltip fixed.
MDVToolTip.prototype.setFixedPin = function(state) {
	if (state) {
        this.setPin(state);
        this.setFixed(state);
        this.display(); 
        this.getContainer().complex['pin'].firstChild.style.left = '-681px';
	}
}
    
	
// ==================================================================
// Map Overlays.
// ==================================================================

// This function creates map overlays. 
function createMapOverlays (target) {}


// ==================================================================
// Traffic/Train Situation Overlay.
// ==================================================================

// This function will be passed to the overlay creation.
function TrafficSituationOverlay(x, y) {
	var zoomLevel = this.mdvMap.config.getZoomLevel(this.mdvMap.config.getZoomLevelIndex());
	var src  	  = this.getSrcPath();
	var t		  = '';
	var level = this.mdvMap.config.getZoomLevelIndex();

	if (zoomLevel.get('zoomLevel')) {
		level = zoomLevel.get('zoomLevel');
	}
		
	// determine validity period reference time	
	if (currentPage == 'trafficSituation' && document.getElementById('validityPeriod') && ((document.getElementById('validityPeriod').selectedIndex && document.getElementById('validityPeriod').selectedIndex >= 0) || document.getElementById('validityPeriod').selectedIndex == null)) {
		t = document.getElementById('validityPeriod').value;	
	}	
	else if (document.getElementById('validity') && document.getElementById('validity').firstChild && document.getElementById('validity').firstChild.selectedIndex >= 0) {
		t = document.getElementById('validity').firstChild.value;
	}

	src += '?';
	src += 'c=' + (this.mdvMap.startTileWidth + x) + '&';
	src += 'r=' + (this.mdvMap.startTileHeight + y) + '&';
	src += 'zoom=' + level + '&';
	src += 't=' + t + '&';
	if (currentPage == 'trainSituation') {
		src += 'mapType=PT';
	}
	else {
		src += 'mapType=IT';
	}
	
	return src;
 }

 
// Reverse default sorting of traffic overlay 
function overlaySorter (a, b) {
	return b.priority - a.priority;
}


// ==================================================================
// ICS messages
// ==================================================================

// This function returns an ICS reference HTML fragment 
function getICSReference (id) {
	var text = '';
	var displayText = '';
	switch (id) {
		case 'TICOE3':
			displayText = icsRef1;
			break;
		case 'ASFINAG_TM':
			displayText = icsRef2;
			break;
		case 'WIEN_Baustellen':
			displayText = icsRef3;
			break;
		case 'NOE_Baustellen':
			displayText = icsRef4;
			break;
	}
	if (id!= '') {
		// image
		text += '<img src="' + imgPath + 'ics_reference/';
		text += id + '.gif';
		text += '" alt="';
		text += displayText;
		text += '" class="icsRefImg"/> ';
		// text
		text += icsRef + ': ';
		text += displayText;
	}
	return text;
}


// this function creates the content of the ICS bubble
// Parameter: 	mode - IT or PT message (not used at the moment)
//				tooltip - tooltip object
function createICSBubble (mode, tooltip) {
	var name = 'name_' + tooltip.id;
	var body = '<div id="' + name + '">';
	if(!tooltip.getInnerHTML().indexOf('<b>')) { 
		body += tooltip.getInnerHTML();
		body += '<br/><br/>';
	}
	if (tooltip.invisibleContent == null || tooltip.invisibleContent == false || tooltip.isVisible()) {
		body += tooltip.content;
	}
	if (tooltip.additionalText && tooltip.validity && (tooltip.additionalText != '' || tooltip.validity != '')) {
		body += '<br/><br/>';
	}
	if (tooltip.additionalText && tooltip.additionalText != '') {
		body += '<br/><br/>';
		body += tooltip.additionalText;
	}
	if (tooltip.validity && tooltip.validity != '') {
		body += '<br/><br/>';
		body += '<i>' + tooltip.validity + '</i>';
	}
	if (tooltip.reference && (tooltip.reference == 'TICOE3' || tooltip.reference == 'ASFINAG_TM' || tooltip.reference == 'WIEN_Baustellen' || tooltip.reference == 'NOE_Baustellen')) {
		body += '<br/><br/>';
		body += '<div>' + getICSReference(tooltip.reference) + '</div>';
	}
	body += '</div>';
	tooltip.setInnerHTML(body);
}


// This function checks the validity of an ICS message
// Parameter: 	msg - message
function checkICSMsgValidity (msg) {
	var returnValue = true; 

	if (((!document.getElementById('noPrediction') || document.getElementById('noPrediction').style.display =='none') && document.getElementById('validityPeriod') && (!document.getElementById('validityClocks') || document.getElementById('validityClocks').style.display != 'none')) 
		|| currentPage == 'journeyPlanner'|| currentPage == 'parkAndRidePlanner' || currentPage == '') {
		// determine index of current validity period
		var currentInterval = 0;
		if (document.getElementById('validityPeriod')) {
			for (var i=0; i < validityIntervals.length; i++) {
				if (document.getElementById('validityPeriod').value == validityIntervals[i].referenceTime) 
					currentInterval = i;
			}
		}
		// validity period of IT message (Lokalzeit wird als UTC-Zeit betrachtet)
		var fromDate = new Date (Date.UTC(msg[0].yearFrom, parseInt(msg[0].monthFrom, 10)-1, msg[0].dayFrom, msg[0].hourFrom, msg[0].minuteFrom, 0)); 
		var toDate = new Date (Date.UTC(msg[0].yearTo, parseInt(msg[0].monthTo,10)-1, msg[0].dayTo, msg[0].hourTo, msg[0].minuteTo, 0));
		
		// validity time of trainSituation
		var validityStart = validityIntervals[currentInterval].start;
		var validityEnd = validityIntervals[currentInterval].end;
		
		// test
		if (toDate >= validityStart && fromDate <= validityEnd)
			returnValue = true;
		else
			returnValue = false;
	}
	return returnValue;
}


// This functions highlights a message of the ICS message list by clicking on the corresponding
// Icon on the map.
MDVMapHelper.prototype.highlightICSMessage = function(id, msg, obj) {
	if (document.getElementById('message_' + obj.id)) {
		// remove old  highlightning
		removeHighlightICSMessage();
		// open the message content
		toggleICSMessageContent (obj.id, true);
		// highlight message with css-styles
		document.getElementById('message_' + obj.id).className = document.getElementById('message_' + obj.id).className + ' highlightedICSMessage ';
		// scroll message to the top of message list
		divlink('message_' + obj.id);
	}
}


// This functions removes all highlightning of ICS messages in the list.
function removeHighlightICSMessage() {
	for (var i=0; i<icsEventsArr.length; i++) {
		if(document.getElementById('message_' + icsEventsArr[i][0].id)) {
			document.getElementById('message_' + icsEventsArr[i][0].id).className = document.getElementById('message_' + icsEventsArr[i][0].id).className.replace(/ highlightedICSMessage/g, "");
		}
	}
}


// This function hides all ICS messages of the list which do not fall within the validity period.
function hideInvalidICSMessage (id, state) {
	if (document.getElementById('listItem_' + id))	 {
		if (state) 
			document.getElementById('listItem_' + id).className += ' validICSMessage';
		else 
			document.getElementById('listItem_' + id).className += ' invalidICSMessage';
	}
}


// Display the blocking, attention and road works messages on the map.
MDVMapHelper.prototype.displayITEvents = function () {
	var size = new MDVPoint(300, 200);
	var icsEventsArrTmp = icsEventsArr;
	var displacedIcsEventsArr = new Array();
	
	// clear map
	this.blockingsLayer.removeAllMarkers();
	this.roadWorksLayer.removeAllMarkers();
	this.informationLayer.removeAllMarkers();
	
	// check if coord displacement necessary
	for (var  i=0; i < icsEventsArr.length; i++) {
		if (icsEventsArr[i][0].x != '' && icsEventsArr[i][0].y != '') {
			// consider only messages within the validity interval
			if (checkICSMsgValidity(icsEventsArr[i])) {
				for (var j=0; j<displacedIcsEventsArr.length; j++) {
					if (parseInt(icsEventsArr[i][0].x,10) >= parseInt(displacedIcsEventsArr[j][0].x,10) - 55 && parseInt(icsEventsArr[i][0].x,10) <= parseInt(displacedIcsEventsArr[j][0].x,10) + 55 && parseInt(icsEventsArr[i][0].y,10) >= parseInt(displacedIcsEventsArr[j][0].y,10) - 50 && parseInt(icsEventsArr[i][0].y,10) <= parseInt(displacedIcsEventsArr[j][0].y,10) + 50) {
						icsEventsArrTmp[i][0].x = parseInt(displacedIcsEventsArr[j][0].x, 10) + 55;
					}
				}
				// add to new individual transports events array
				displacedIcsEventsArr.push(icsEventsArrTmp[i]);
			}	
		}
	}
	
	// display valid and modified individual transport events
	for (var i=0; i < displacedIcsEventsArr.length; i++) {
		var coord = new MDVCoordinates(nameMap, parseInt(displacedIcsEventsArr[i][0].x), parseInt(displacedIcsEventsArr[i][0].y));
		if (displacedIcsEventsArr[i][0].type == 'blocking')
			this.marker = this.mdvMap.createMarker(coord, 0.5, imgPath + 'Sperre.gif');
		else if (displacedIcsEventsArr[i][0].type == 'roadWorks')
			this.marker = this.mdvMap.createMarker(coord, 0.5, imgPath + 'Baustelle.gif');
		else
			this.marker = this.mdvMap.createMarker(coord, 0.5, imgPath + 'information.gif');
		var title = displacedIcsEventsArr[i][0].subtitle;
		if (displacedIcsEventsArr[i][0].subtitle != '' && displacedIcsEventsArr[i][0].subject != '')
			title += ': ';
		title += displacedIcsEventsArr[i][0].subject;
		var tool = this.mdvMap.createToolTip(size,'<b>' + title + '</b>');
		tool.id = displacedIcsEventsArr[i][0].id;
		tool.content = displacedIcsEventsArr[i][0].content;
		tool.additionalText = displacedIcsEventsArr[i][0].additionalText;
		tool.validity = displacedIcsEventsArr[i][0].validity;
		tool.reference = displacedIcsEventsArr[i][0].reference;
		this.marker.setObjectId(displacedIcsEventsArr[i][0]);
		this.marker.setToolTip(tool);
		this.marker.toolTip.setPin(true);
		if (displacedIcsEventsArr[i][0].type == 'blocking')
			this.blockingsLayer.addMarker(this.marker);
		else if (displacedIcsEventsArr[i][0].type == 'roadWorks')
			this.roadWorksLayer.addMarker(this.marker);
		else
			this.informationLayer.addMarker(this.marker);
	}
	
	// update map
	mdvMap.mdvMap.update();
}


// ==================================================================
// Display external markers on the map.
// ==================================================================

// This function gets the json file with external markers.
MDVMapHelper.prototype.displayExternalMarkers = function (path) {
	var _path = absoluteServerPath.efa + '' + path;
	this.externalMarkersLayer = null;
	this.externalMarkersLayer = this.mdvMap.createLayer('externalMarkers'); 
	this.externalMarkersLayer.setZIndex('20');
	this.mdvMap.addLayer(this.externalMarkersLayer);
	if (_path != '') {
		var _ajax = mdvLib.ajax({ host: _path, method: 'get', parameters: null, onComplete: displayExternalMarkersComplete});
	}
}


// This function displays the external markers on the map.
function displayExternalMarkersComplete (response) {
	var json;
	var _response = response.responseText || response;
	eval('json=' + _response + ';');

	for (var i=0; i < json[0].mapmarker.length; i++) {
		// dipslay only valid markers 
		if (json[0].mapmarker[i].id!='' && json[0].mapmarker[i].symboltype!='' && json[0].mapmarker[i].coordx!='' && json[0].mapmarker[i].coordy!='') {
			var size = new MDVPoint(300, 250);
			var img = imgPath + 'transparent.gif';
			
			// bubble size
			if (json[0].mapmarker[i].bubble.width && json[0].mapmarker[i].bubble.height)
				size = new MDVPoint(parseInt(json[0].mapmarker[i].bubble.width,10), parseInt(json[0].mapmarker[i].bubble.height,10));
				
			// bubble position 
			var coord = new MDVCoordinates(nameMap, parseInt(json[0].mapmarker[i].coordx,10), parseInt(json[0].mapmarker[i].coordy,10));
			
			// determine symbol
			if (json[0].mapmarker[i].symboltype == 'CAMERA' ) {
				img = imgPath +  'camera.gif';	
			}
            else if (json[0].symboltype == 'CAMERA') {
                img = imgPath +  'camera.gif';	
            }
            
			// create marker
			mdvMap.marker = mdvMap.mdvMap.createMarker(coord, 0.5, img);		
			// bubble with dynamic content
			if (json[0].mapmarker[i].bubble.dynamiccontent) {
				var tool = mdvMap.mdvMap.createToolTip(size, ' ');
                var bubbleHeight = parseInt(json[0].mapmarker[i].bubble.height,10) - 40;
				var content = '<iframe src="' + json[0].mapmarker[i].bubble.dynamiccontent.contenturl + '" width="100%" height="' + bubbleHeight + '" frameborder="0"/>';
				tool.id = json[0].mapmarker[i].id;
				// load content if it will be loaded only once and cached
				if (json[0].mapmarker[i].bubble.cacheContent == false)
					tool.invisibleContent = true;
				tool.content = content;
				mdvMap.marker.setToolTip(tool);
				mdvMap.marker.toolTip.setPin(true);
			}
			// bubble with static content
			else if (json[0].mapmarker[i].bubble.staticcontent) {
				var title = json[0].mapmarker[i].bubble.staticcontent.header;
				var text = json[0].mapmarker[i].bubble.staticcontent.text;
				var imgURL = json[0].mapmarker[i].bubble.staticcontent.imageurl;
				var content = text;
				content += '<br/><br/>';
				content += '<img alt="" src="' + imgURL + '" class="externalMarkerImg"/>';
				
				// create tooltip
				var tool = mdvMap.mdvMap.createToolTip(size,'<b>' + title + '</b>');
				tool.id = json[0].mapmarker[i].id;
				if (json[0].mapmarker[i].bubble.cacheContent == false) 
					tool.invisibleContent = true;
				tool.content = content;
				mdvMap.marker.setToolTip(tool);
				mdvMap.marker.toolTip.setPin(true);
			}
			
			// add marker on map
			mdvMap.externalMarkersLayer.addMarker(mdvMap.marker);
		}
	}

	// update map
	mdvMap.mdvMap.update();
}


// ==================================================================
// Park Objects
// ==================================================================

// Park object
// Parameter:	id - id of park object
//				url - url for parkobject request (intermodalTooltipLayout)
// 				zoneAssignedStops - zone with assigned stops 
function MDVEFAParkObjectInfo(id, url, zoneAssignedStop) {
	this.id 	= id;
	this.url 	= url;
	this.zoneAssignedStop	= zoneAssignedStop;
}


// Request for information of park object.
// Parameter:	selPA - id of park object		
//				identifier - id of tooltip content container
//				link ['true|'false'] - display link to select/deselect the park object	
MDVEFAParkObjectInfo.prototype.getParkingInfo = function(identifier, selPA, link) {
	var _params = { language: mapLanguage, paID: selPA, parkObjInfo: 1, itdLPxx_id: identifier, itdLPxx_selectionLink: link, itdLPxx_parkingZone: this.zoneAssignedStops, itdLPxx_freeParking: enableFreeParkingInfo, itdLPxx_imgPath: imgPath, itdLPxx_infoCaption: bubbleInfoCaption, ts: new Date().getTime()};
	var ajax = mdvLib.ajax({host: this.url, parameters: _params, method: 'get', onComplete: MDVEFAParkObjectInfo_onAjaxComplete });
}


// Create bubble info of a park object.
function MDVEFAParkObjectInfo_onAjaxComplete(request) {
	if (request && request.responseXML) {
		var firstChild = request.responseXML.firstChild;

		while (firstChild.nodeType != 1) {
			firstChild = firstChild.nextSibling;
		}

		var id = firstChild.getAttribute('id');
		document.getElementById(id).innerHTML += request.responseText;
	}
}


// ==================================================================
// WMS Map Functionality 
// ==================================================================

// This function will be passed to the overlay creation.
function wmsOverlay(x, y) {
	if ((this.name.search(/overlay_Highway+/)!=-1 || (this.name.search(/overlay_VIONA+/)!=-1 && document.getElementById('itdLPxx_layer_externalMarkers') && document.getElementById('itdLPxx_layer_externalMarkers').checked)) && showHighwayLayer) {
		var zoomLevel = this.mdvMap.config.getZoomLevelIndex();
		var src  	  = this.getSrcPath();
		var re = /&amp;/g;
		src = src.replace(re,'&');
		
		// map config
		var mapWidth = parseInt(this.mdvMap.config.zoomLevels[zoomLevel].params.realWidth);
		var mapHeight = parseInt(this.mdvMap.config.zoomLevels[zoomLevel].params.realHeight);
		var realOffsetX = parseInt(this.mdvMap.config.zoomLevels[zoomLevel].params.realOffsetX);
		var realOffsetY = parseInt(this.mdvMap.config.zoomLevels[zoomLevel].params.realOffsetY);
		
		// bounding box of traffic  map
		var mapX1 = realOffsetX;
		var mapX2 = realOffsetX + mapWidth;
		var mapY1 = realOffsetY;
		var mapY2 = realOffsetY + mapHeight;
		
		// traffic map tile number
		var mapTileNoX = this.mdvMap.startTileWidth + x;
		var mapTileNoY = this.mdvMap.startTileHeight + y;
		
		// tile size (in coordinates) 
		var tileWidthCoord = mapWidth / parseInt(this.mdvMap.config.zoomLevels[zoomLevel].params.numberOfTilesX);
		var tileHeightCoord = mapHeight / parseInt(this.mdvMap.config.zoomLevels[zoomLevel].params.numberOfTilesY);
		
		// bounding box of current WMS tile
		var wmsTileX1 = mapX1 + mapTileNoX * tileWidthCoord;
		var wmsTileX2 = mapX1 + (mapTileNoX + 1) * tileWidthCoord;
		var wmsTileY1 = mapY1 + mapTileNoY * tileHeightCoord;	
		var wmsTileY2 = mapY1 + (mapTileNoY + 1) * tileHeightCoord;
		
		// show transparent image for tiles out of viona region
		if (enableVionaMap=='true' && this.name.search(/overlay_VIONA+/)!=-1 && (wmsTileX1 < vionaX1 || wmsTileX2 > vionaX2 || wmsTileY1 < vionaY1 || wmsTileY2 > vionaY2)) {
			src = imgPath +  'transparent.gif';
			return src;
		}
		else {
            // compute bounding box of current tile for WMS
			// transform coordinates from mdv coord system to VIONA coord system and compute bounding box
			var temp = GKOffsetY - wmsTileY2;
			wmsTileY2 = GKOffsetY - wmsTileY1;
			wmsTileY1 = temp;
			var tileBoundingBox = wmsTileX1 + ',' + wmsTileY1 + ',' + wmsTileX2 + ',' + wmsTileY2;
			
			var tileSizeX = parseInt(this.mdvMap.config.zoomLevels[zoomLevel].params.tileSizeX);
			var tileSizeY = parseInt(this.mdvMap.config.zoomLevels[zoomLevel].params.tileSizeY);
			
			src += '&' + 'width=' + tileSizeX;
			src += '&' + 'height=' + tileSizeY;
			src += '&' + 'bbox=' + tileBoundingBox;
		
			return src;
		}
	}
    return imgPath + 'transparent.gif';
}


// ==================================================================
// Overwritten map functionality: corrects the highlightning of an 
// icon on map.
// ==================================================================

function MDVMarker_onload (e) {
	e = e ? e : window.event;           
	// We need to wait for the onload event in Firefox as it doesn't provide proper values for img width and height, if we don't wait.
	if (this.marker) {
		this.marker.update();
		if (!this.marker.append && this.marker.layer) {
			this.mdvMap.markerObjects.appendChild(this);
			this.marker.append = true;	   
	   }
	}
}


