CONTROLLER = {

	init: function( parentobject){
		CONTROLLER.root = parentobject;
		CONTROLLER.facetFrame = parentobject.frames['facetFrame'];
		CONTROLLER.mapFrame   = parentobject.frames['mapFrame'];
		CONTROLLER.timeFrame  = parentobject.frames['sliderFrame'];

		if (!CONTROLLER.mapState) {
		    CONTROLLER.mapState = '';	// information about current map zoom and bbox position
		}
	},

	mapMoved: function( args){
		// this event is triggered by user map movements, but only if map filter is ckecked

		this.mapState = args.zoom + "," + args.min_e + "," + args.min_n + "," + args.max_e + "," + args.max_n + "," + args.center_e + "," + args.center_n;

		if (this.mapFrame) {
			var mapfilter = this.mapFrame.document.getElementById("mapFilter");
			if (mapfilter && mapfilter.checked) {
				this.facetFrame.document.getElementById("mapfilt_txt").value = args.zoom + "," + args.min_e + "," + args.min_n + "," + args.max_e + "," + args.max_n + "," + args.center_e + "," + args.center_n;
			}
		}
	},
	
	showUnit: function( unitId){
		// tells map to show unit in highlighted mode
		if (!unitId) {
			alert('Unit ID not defined!');
		} else {
			this.mapFrame.centerToLayer('SELECTED','&unitId='+unitId)
		}
	},
	
	unitClicked: function( unitId, layerId) {
		// function is triggered by user click on the unit in the map
		
		// this is how to send information to Faceted component
		this.facetFrame.document.getElementById("test_txt").value = unitId;
		this.facetFrame.document.getElementById("test_txt").className = "highlightedText";
		window.setTimeout("this.facetFrame.document.getElementById('test_txt').className = 'usualText';", 1000);
	},

	timebarEvent: function( current, start, end) {
		// function is triggered by changeing of the timebar by user action

		this.facetFrame.document.getElementById("timebar_txt1").value = current;
		this.facetFrame.document.getElementById("timebar_txt2").value = start;
		this.facetFrame.document.getElementById("timebar_txt3").value = end;
	},

    
	
	timebarSet: function( current, start, end) {
		// function sets the timebar values
		this.timeFrame.timebar_set( current, start, end);
	}
}
