function mapCenter(oMap,fLat,fLon,iZoom){
	var oLonLat = new OpenLayers.LonLat(fLon,fLat).transform(new OpenLayers.Projection('EPSG:4326'), oMap.getProjectionObject());
	oMap.setCenter(oLonLat,iZoom);
}

function mapMarker(oMap,oLayer,fLat,fLon,sIcon,iSizeX,iSizeY,iOffsetX,iOffsetY,sText){
	var oLonLat = new OpenLayers.LonLat(fLon,fLat).transform(new OpenLayers.Projection('EPSG:4326'), oMap.getProjectionObject());
	var oSize = new OpenLayers.Size(iSizeX,iSizeY);
	var oOffset = new OpenLayers.Pixel(iOffsetX,iOffsetY);
	var oIcon = new OpenLayers.Icon(sIcon,oSize,oOffset);
	var oMarker = new OpenLayers.Marker(oLonLat,oIcon);

	if(sText){
		var AutoSizeFramedCloud = OpenLayers.Class(OpenLayers.Popup.FramedCloud, {
			'autoSize': true
		});

		var feature = new OpenLayers.Feature(oLayer, oLonLat);
		feature.closeBox = true;
		feature.popupClass = AutoSizeFramedCloud;
		feature.data.popupContentHTML = sText;
		feature.data.overflow = "auto";
		oMarker.feature = feature;

		var markerClick = function (evt) {
			if (this.popup == null) {
				this.popup = this.createPopup(this.closeBox);
				oMap.addPopup(this.popup);
				this.popup.show();
			} else {
				this.popup.toggle();
			}
		currentPopup = this.popup;
		OpenLayers.Event.stop(evt);
		};
		oMarker.events.register("mousedown", feature, markerClick);
	}

	oLayer.addMarker(oMarker);
}

function mapGpx(oMap,sFile,sTitle,sColor,iWidth){
	var oLayer = new OpenLayers.Layer.GML(sTitle,sFile,{
		format: OpenLayers.Format.GPX,
		style: {strokeColor:sColor, strokeWidth: iWidth, strokeOpacity:1},
		projection: new OpenLayers.Projection('EPSG:4326')
	});
	oMap.addLayer(oLayer);
}

function getTileURL(bounds) {
	var res = this.map.getResolution();
	var x = Math.round((bounds.left - this.maxExtent.left) / (res * this.tileSize.w));
	var y = Math.round((this.maxExtent.top - bounds.top) / (res * this.tileSize.h));
	var z = this.map.getZoom();
	var limit = Math.pow(2, z);
	if (y < 0 || y >= limit) {
		return null;
	} else {
		x = ((x % limit) + limit) % limit;
		url = this.url;
		path= z + "/" + x + "/" + y + "." + this.type;
		if (url instanceof Array) {
			url = this.selectUrl(path, url);
		}
		return url+path;
	}
}

