var map;

function osm_map(element, gpxfile, v_sc, v_sw, v_so) {

    map = new OpenLayers.Map (element, {
	    maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),
	    maxResolution: 156543.0399,
	    numZoomLevels: 19,
	    units: 'm',
	    projection: new OpenLayers.Projection("EPSG:900913"),
	    displayProjection: new OpenLayers.Projection("EPSG:4326"),
	    controls: [
		       new OpenLayers.Control.Navigation(),
		       new OpenLayers.Control.PanZoom(),
		       new OpenLayers.Control.Attribution({displayClass: "olControlAttributionLocal"}),
		       new OpenLayers.Control.ScaleLine()
		       ]
	});
    layerMapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik", {
	    attribution: 'Map data by <a href="http://www.osm.org/">OSM</a> (<a href="http://creativecommons.org/">CC</a> <a href="http://creativecommons.org/licenses/by-sa/2.0/">BY-SA</a>)'
	});
    map.addLayer(layerMapnik);

    var lgpx = new OpenLayers.Layer.GML("GPS route", gpxfile, {
	    format: OpenLayers.Format.GPX,
	    style: {strokeColor: v_sc, strokeWidth: v_sw, strokeOpacity: v_so},
	    projection: new OpenLayers.Projection("EPSG:4326")
	});
    map.addLayer(lgpx);
    
    if( ! map.getCenter() ){
	lgpx.events.register('loadend', map, function(){this.zoomToExtent(lgpx.getDataExtent())});
	map.setCenter(null, null);
    }
}


