function MapNavigator (EventManager, Map) {
	var SLIDER_MIN_PX = 140;
	var SLIDER_MAX_PX = 22;

	var SLIDER_SCALE_PER_PX = (SLIDER_MIN_PX - SLIDER_MAX_PX) / (SLIDER_MAX_SCALE - SLIDER_MIN_SCALE);


	var Parent;
	var SliderControl;
	var IncreaseScale;
	var DecreaseScale;

	this.createNavIcon = function(alt) {
		var obj = document.createElement('div');
		obj.title = alt;
		obj.alt = alt;
		obj.style.position = 'absolute';
		return obj;
	}

	this.navigate = function(percentEast, percentNorth,scaleChange) {
		var pointScale = Map.getPointScale();
		pointScale.Radius *= scaleChange;
		if(pointScale.Radius > SLIDER_MAX_SCALE) { pointScale.Radius = SLIDER_MAX_SCALE; }	
		if(pointScale.Radius < SLIDER_MIN_SCALE) { pointScale.Radius = SLIDER_MIN_SCALE; }	
		var mapDimension = Map.getMapSize();
		pointScale.Center.x += (mapDimension.x*percentEast*pointScale.Radius);
		pointScale.Center.y += (mapDimension.y*percentNorth*pointScale.Radius);

		EventManager.triggerEvent('navigate', pointScale);
	}

	this.onNavigate = function(psScale) {
		var Bottom = SLIDER_MIN_PX;
		if(SLIDER_MIN_PX > SLIDER_MAX_PX) { Bottom = SLIDER_MAX_PX; }
		var length = Math.abs(SLIDER_MAX_PX - SLIDER_MIN_PX - SliderControl.offsetHeight);
		var scaleLen = SLIDER_MAX_SCALE - SLIDER_MIN_SCALE;
		var percent =  pixelScaleToInchScale(Map,psScale.Radius) / scaleLen;
		if(percent > 1) { percent = 1; }
		SliderControl.style.top = Bottom+(percent*length) + 'px';	
	}

	var MySelf = this;

	this.onResize = function() {
		SLIDER_MAX_PX = DecreaseScale.offsetTop;
		SLIDER_MIN_PX = IncreaseScale.offsetTop + IncreaseScale.offsetHeight;
		SLIDER_SCALE_PER_PX = (SLIDER_MIN_PX - SLIDER_MAX_PX) / (SLIDER_MAX_SCALE - SLIDER_MIN_SCALE);
	}

	this.setParent = function(p) {
		Parent = p;
		var slider = this.createNavIcon('Scale Slider Bar');
		slider.style.border = '0px';
		Parent.appendChild(slider);

		var sliderControl = document.createElement('div');
		sliderControl.id = 'navigatorSliderControl';
		SliderControl = sliderControl;

		var draggable = new Draggable(sliderControl.id, sliderControl, false, true, true);
		slider.onclick = function (event) {
			if(window.event) { event = window.event; }
			var pos = objectClientPosition(this);
			var top = event.clientY-pos.y + this.offsetTop;
			sliderControl.style.top = top + 'px';
			draggable.onDrop();

			if(event.preventDefault) { event.preventDefault(); }
		}
		Parent.appendChild(sliderControl);
		SliderControl = sliderControl;

		var increaseScale = document.createElement('div');
		increaseScale.id = 'navigatorIncreaseScale';
		increaseScale.title = 'Zoom In';
		Parent.appendChild(increaseScale);
		IncreaseScale = increaseScale;

		var decreaseScale = document.createElement('div');
		decreaseScale.id = 'navigatorDecreaseScale';
		decreaseScale.title = 'Zoom Out';
		Parent.appendChild(decreaseScale);
		DecreaseScale = decreaseScale;
		
		SLIDER_MAX_PX = decreaseScale.offsetTop;
		SLIDER_MIN_PX = increaseScale.offsetTop + increaseScale.offsetHeight;
		SLIDER_SCALE_PER_PX = (SLIDER_MIN_PX - SLIDER_MAX_PX) / (SLIDER_MAX_SCALE - SLIDER_MIN_SCALE);
		

		increaseScale.onclick = function (event) {
			MySelf.navigate(0,0,.7);
		}
		decreaseScale.onclick = function (event) {
			MySelf.navigate(0,0,1.2);
		}


//		sliderControl.style.top = Top + SLIDER_MAX_PX + 'px';

		var n = this.createNavIcon('North');
		var s = this.createNavIcon('South');
		var e = this.createNavIcon('East');
		var w = this.createNavIcon('West');
		Parent.appendChild(n);
		Parent.appendChild(s);
		Parent.appendChild(e);
		Parent.appendChild(w);

		n.id = 'navigatorNorth';
		e.id = 'navigatorEast';
		w.id = 'navigatorWest';
		s.id = 'navigatorSouth';
		slider.id = 'navigatorBar';


		function changeVisibility(vis) {
			n.style.visibility = vis;
			e.style.visibility = vis;
			w.style.visibility = vis;
			s.style.visibility = vis;

			slider.style.visibility = vis;
			sliderControl.style.visibility = vis;
		}
	
		this.getVisibility = function () {
			return(n.style.visibility);
		}

		this.hideNavigator = function() {
			changeVisibility('hidden');
		}

		this.showNavigator = function() {
			changeVisibility('visible');
		}
		
		n.onclick = function () {
			MySelf.navigate(0,.25,1);
		}

		s.onclick = function () {
			MySelf.navigate(0,-.25,1);
		}

		e.onclick = function () {
			MySelf.navigate(.25,0,1);
		}

		w.onclick = function () {
			MySelf.navigate(-.25,0,1);
		}
	

		draggable.whileDrag = function(trigger,obj) {
			if(obj.offsetTop < SLIDER_MIN_PX - 5) {
				obj.style.top = SLIDER_MIN_PX - 3 + 'px';
			}
			if(obj.offsetTop+obj.offsetHeight > SLIDER_MAX_PX + 3) {
				obj.style.top = SLIDER_MAX_PX-obj.offsetHeight+'px';
			}
		}
		draggable.onDrop = function(trigger,obj) {
			var mapScale = Map.getPointScale();
			var scaleLen = SLIDER_MAX_SCALE - SLIDER_MIN_SCALE;
			var length = Math.abs(SLIDER_MAX_PX - SLIDER_MIN_PX);
			var slTop = SliderControl.offsetTop+SliderControl.offsetHeight;
			var percent = slTop - SLIDER_MIN_PX;
			percent = percent / length;
			if(percent < .01) { percent = 0; }
			if(percent > 1) { percent = 1; }
			mapScale.Radius = inchScaleToPixelScale(Map, scaleLen * percent + SLIDER_MIN_SCALE);
			EventManager.triggerEvent('navigate', mapScale);
		}
	}


}
