//todo
//need to know if feature is associated with chosen wway and display
//only show fisheries associated with a waterway
//only show waterways at initial rendering

function mapInit()
{
	wwaybounds = new OpenSpace.MapBounds(min_e, min_n, max_e, max_n);
	//set the restricted bounds slightly bigger so users can select end of wway features.
	fullbounds = setBufferZone(wwaybounds, 20); 
	previousbounds = fullbounds;
//	osMap = new OpenSpace.Map('map', {restrictedExtent: fullbounds});
	osMap = new OpenSpace.Map('map');
	nav_control = osMap.getControlsByClass('OpenLayers.Control.Navigation')[0];
	nav_control.disableZoomWheel();
	
	osMap.setCenter(new OpenSpace.MapPoint(getCentrePoint(min_e, min_n, max_e,max_n)), 3);
	osMap.zoomToExtent(wwaybounds);
	
	osMap.addControl(new OpenLayers.Control.ScaleLine());
//	osMap.addControl(new OpenLayers.Control.LayerSwitcher());
	
	//catch any moves or zoom actions
	osMap.events.register('zoomend', osMap, function(e) {
		redrawMainMap(true);
	});
	osMap.events.register('moveend', osMap, function(e) {
		redrawMainMap(false);
	});
	if(document.getElementById('map_location_details')) {
		osMap.events.register('mousemove', osMap, writeMapLocation);
	}

	//remove the vector and marker layers set by Ordnance Survey.
	removeDefaultOSLayers();
	
	//draw white transluscent Bg box to help wways stand out
	generateWhiteBgBox(osMap.getExtent());
	
	var wwaylookup = {
			0: {strokeColor: '#5555ff', strokeWidth: 3,  strokeDashStyle: "longdash"}, //normal waterway
			1: {strokeColor: '#0000ff', strokeWidth: 5},//selected waterway
			2: {strokeColor: '#0000ff', strokeWidth: 5},//non-navigable waterway //@todo needs to be corrected back to #ff0000 when proposed stoppages are rolled out to overall stoppage system
			3: {strokeColor: '#0000ff', strokeWidth: 3}//stoppage
	}
	
	wwayStyleMap.addUniqueValueRules('default', 'selected', wwaylookup);
	
	wwayLayer = new OpenLayers.Layer.Vector('waterways', {styleMap: wwayStyleMap, resolutions: [500, 200, 100, 50, 25, 10, 5, 2.5, 2, 1], displayInLayerSwitcher: false});
	osMap.addLayer(wwayLayer);
	createWaterways();
	
	attractionLayer = new OpenLayers.Layer.Vector('attractions', {styleMap: attractionStyleMap, resolutions: [200, 100, 50, 25, 10, 5, 2.5, 2, 1]});
	osMap.addLayer(attractionLayer);
	
	fisheryLayer = new OpenLayers.Layer.Vector('fisheries', {styleMap: fisheryStyleMap, resolutions: [50, 25, 10, 5, 2.5, 2, 1]});
	osMap.addLayer(fisheryLayer);
	
	serviceLayer = new OpenLayers.Layer.Vector('services', {styleMap: serviceStyleMap, resolutions: [25, 10, 5, 2.5, 2, 1]});
	osMap.addLayer(serviceLayer);
	
	structureLayer = new OpenLayers.Layer.Vector('structures', {styleMap: structureStyleMap, resolutions: [25, 10, 5, 2.5, 2, 1]});
	osMap.addLayer(structureLayer);

	setupControls();

	for(key in controls) {
		osMap.addControl(controls[key]);
		//set wwayControl as the default
		if (key == 'wwayControl') {
			chosencontrol = controls[key];
			controls[key].activate();
		}
	}
	toggleInit();
	
	setAvailableInfoButtons();
		
}

