//
// Set values that are different between DigiTV and MobiiliTV mapservices.
//
var MAPPLET_PARAM_CALLBACKS = null;	    // Service specific events raised from the Applet.
var MAPPLET_PARAM_ARCHIVE = null;		// Resource zip-files (contains information about layout for the map. Colors, layers etc...).
var MAP_CENTERX = 3438072;              // Set the initial start view for the map.
var MAP_CENTERY = 6960361;              // Set the initial start view for the map.
var MAP_ZOOMLEVEL = 2000;               // Set the initial start view for the map.

if (location.hostname.match(/mobiilitv/gi)) {
	
	MAPPLET_PARAM_CALLBACKS = '<param name="applet.callback" value="onAppletStatusChanged">'+
	'<param name="geocoder.callback" value="onGeocodingResult">'+
	'<param name="digita.callbackDVBH" value="onDVBHClick">'+
	'<param name="digita.callbackMunicipality" value="onMunicipalityClick">';

	MAPPLET_PARAM_ARCHIVE = 'kk-applet-s.jar, kk-mapplet-digita-s.jar, kk-mapplet-digita-mtv-resources.zip';
}
else if (location.hostname.match(/450laajakaista/gi)) {

    MAPPLET_PARAM_CALLBACKS = '<param name="applet.callback" value="onAppletStatusChanged">'+
    '<param name="geocoder.callback" value="onGeocodingResult">'+
    '<param name="digita.callbackMunicipality" value="onMunicipalityClick">';

	MAPPLET_PARAM_ARCHIVE='kk-applet-s.jar, kk-mapplet-digita-s.jar, kk-mapplet-digita-450-resources.zip';    
    
    MAP_CENTERX = 3400386;
    MAP_CENTERY = 7205278;
    MAP_ZOOMLEVEL = 3600;    
    
}
else {

	MAPPLET_PARAM_CALLBACKS='<param name="applet.callback" value="onAppletStatusChanged">'+
	'<param name="geocoder.callback" value="onGeocodingResult">'+
	'<param name="digita.callbackAntenna" value="onAntennaClick">'+
	'<param name="digita.callbackMunicipality" value="onMunicipalityClick">';

	MAPPLET_PARAM_ARCHIVE='kk-applet-s.jar, kk-mapplet-digita-s.jar, kk-mapplet-digita-dtv-resources.zip';

}

// Karttakone Mapplet script
var MAPPLET_PARAM_NAME='Mapplet';
var MAPPLET_PARAM_TITLE='Karttakone Mapplet';
var MAPPLET_PARAM_WIDTH='20em';
var MAPPLET_PARAM_HEIGHT='20em';
var MAPPLET_PARAM_CODEBASE='http://' + location.host + '/karttapalvelu/karttakone/';
var MAPPLET_PARAM_CODE='fi/karttakone/applet/KApplet.class';
var MAPPLET_PARAM_CACHE_ARCHIVE='kk-applet-s.jar, kk-mapplet-digita-s.jar';
var MAPPLET_PARAM_CACHE_VERSION='1.3.8.7, 1.3.12.2';
var MAPPLET_PARAM_MINVERSION='1.4.2';

var MAPPLET_MSG_GET_JAVA= Array('Java version '+MAPPLET_PARAM_MINVERSION+' or later,',
						'is required to view this content.',
						'Download the latest version',
						'from  www.java.com');
var MAPPLET_MSG_ENABLE_JAVA=Array('Java is currently not enabled',
						'or not installed in your system');

var CODE_GET_JAVA='<div width="'+MAPPLET_PARAM_WIDTH+'" height="'+MAPPLET_PARAM_HEIGHT+'">'+
				  '<center><img src="images/karttakone.jpg" border="0"/></br></br>'+
				  MAPPLET_MSG_GET_JAVA[0]+'</br>'+MAPPLET_MSG_GET_JAVA[1]+'</br></br>'+
				  '<a target="_NEW" href="http://jdl.sun.com/webapps/getjava/BrowserRedirect?host=www.java.com:80">'+
				  MAPPLET_MSG_GET_JAVA[2]+'</br>'+MAPPLET_MSG_GET_JAVA[3]+'</a></center></div>';

var CODE_ENABLE_JAVA='<div width="'+MAPPLET_PARAM_WIDTH+'" height="'+MAPPLET_PARAM_HEIGHT+'">'+
				  '<center><img src="karttakone.jpg" border="0"/>'+
				  '</br></br>'+MAPPLET_MSG_GET_JAVA[0]+'</br>'+MAPPLET_MSG_GET_JAVA[1]+'</br></br>'+
				  '</br></br>'+MAPPLET_MSG_ENABLE_JAVA[0]+'</br>'+MAPPLET_MSG_ENABLE_JAVA[1]+'</br></br>'+
				  '<a target="_NEW" href="http://jdl.sun.com/webapps/getjava/BrowserRedirect?host=www.java.com:80">'+
				  MAPPLET_MSG_GET_JAVA[2]+'</br>'+MAPPLET_MSG_GET_JAVA[3]+'</a></center></div>';

var CODE_MAPPLET='<applet id="'+MAPPLET_PARAM_NAME+'" '+
				' code="'+MAPPLET_PARAM_CODE+'" '+
				' codebase="'+MAPPLET_PARAM_CODEBASE+'" '+
				' archive="'+MAPPLET_PARAM_ARCHIVE+'" '+
				' cache_archive="'+MAPPLET_PARAM_CACHE_ARCHIVE+'" '+
				' cache_version="'+MAPPLET_PARAM_CACHE_VERSION+'" '+
//				' style="width:'+MAPPLET_PARAM_WIDTH+'; height:'+MAPPLET_PARAM_HEIGHT+';" '+
				' alt="'+MAPPLET_PARAM_TITLE+'" title="'+MAPPLET_PARAM_TITLE+'" '+
				' name="'+MAPPLET_PARAM_NAME+'"'+
				' MAYSCRIPT>'+
		        '<param name="map.centerX" value="' + MAP_CENTERX + '">'+
		        '<param name="map.centerY" value="' + MAP_CENTERY + '">'+
		        '<param name="map.zoomLevel" value="' + MAP_ZOOMLEVEL + '">'+
		        '<param name="applet.bgcolor" value="ffffff">'+
		        '<param name="applet.info.message" value="Loading Applet ...">'+
		        //'<param name="applet.image" value="map.jpg">'+
		        //'<param name="applet.progress.location" value="200,200">'+
		        //'<param name="applet.applet.info.location" value="-1,100">'+
		        '<param name="applet.jvm.version" value="'+MAPPLET_PARAM_MINVERSION+'">'+
		        '<param name="applet.jvm.message" value="'+
		        	MAPPLET_MSG_GET_JAVA[0]+"|"+
			        MAPPLET_MSG_GET_JAVA[1]+"| |"+
			        MAPPLET_MSG_GET_JAVA[2]+"|"+
			        MAPPLET_MSG_GET_JAVA[3]+'">'+
		        '<param name="applet.proxy" value="fi.karttakone.mapplet.Mapplet">'+
					MAPPLET_PARAM_CALLBACKS+
		        //'<param name="image" value="images/karttakone.jpg">'+
		        '<param name="progressbar" value="true">'+
 				'<param name="boxmessage" value="Loading Karttakone Mapplet ...">'+
 				'<param name="boxbgcolor" value="white">'+
		        //'<param name="mayscript" value="true">'+
		        //'<param name="scriptable" value="true">'+
		        CODE_GET_JAVA+
				'</applet>';


// Map Constants wrapper object
function MapConstants() {

    this.STATUS_UNINITIALISED	=0;
    this.STATUS_INITIALISING	=1;
    this.STATUS_INITIALISED		=2;
    this.STATUS_STARTING		=3;
    this.STATUS_STARTED			=4;
    this.STATUS_STOPPING		=5;
    this.STATUS_UNINITIALISING	=6;

    this.NO_INCREMENTAL_UPDATE 	=1;
    this.NO_STORE_VIEW 			=2;

	this.LOCATION_NORTHWEST	=1;
	this.LOCATION_WEST		=2;
	this.LOCATION_SOUTHWEST	=3;
	this.LOCATION_NORTH		=4;
	this.LOCATION_CENTER	=5;
	this.LOCATION_SOUTH		=6;
	this.LOCATION_NORTHEAST	=7;
	this.LOCATION_EAST		=8;
	this.LOCATION_SOUTHEAST	=9;
	this.LOCATION_CURRENT	=10;
	this.LOCATION_HOME		=11;
	this.LOCATION_LAST		=12;
	this.LOCATION_PREVIOUS	=13;
	this.LOCATION_NEXT		=14;
	this.LOCATION_ZOOM_IN	=15;
	this.LOCATION_ZOOM_OUT	=16;
	this.LOCATION_WHERE_AM_I=17;

	this.COLUMN_GEOLOC_NAME			=0;
	this.COLUMN_GEOLOC_NAME2		=1;
	this.COLUMN_GEOLOC_AREA			=2;
	this.COLUMN_GEOLOC_COUNTRY		=3;
	this.COLUMN_GEOLOC_COORDX		=4;
	this.COLUMN_GEOLOC_COORDY		=5;
	this.COLUMN_GEOLOC_AREA_CODE	=6;

	this.decodeDirection=MapConstants_decodeDirection;
	function MapConstants_decodeDirection(direction) {
		var dir=0;
		if(direction=="NORTHWEST")
			dir=this.LOCATION_NORTHWEST;
		else if(direction=="WEST")
			dir=this.LOCATION_WEST;
		else if(direction=="SOUTHWEST")
			dir=this.LOCATION_SOUTHWEST;
		else if(direction=="NORTH")
			dir=this.LOCATION_NORTH;
		else if(direction=="CENTER")
			dir=this.LOCATION_CENTER;
		else if(direction=="SOUTH")
			dir=this.LOCATION_SOUTH;
		else if(direction=="NORTHEAST")
			dir=this.LOCATION_NORTHEAST;
		else if(direction=="EAST")
			dir=this.LOCATION_EAST;
		else if(direction=="SOUTHEAST")
			dir=this.LOCATION_SOUTHEAST;
		else if(direction=="CURRENT")
			dir=this.LOCATION_CURRENT;
		else if(direction=="HOME")
			dir=this.LOCATION_HOME;
		else if(direction=="LAST")
			dir=this.LOCATION_LAST;
		else if(direction=="PREVIOUS")
			dir=this.LOCATION_PREVIOUS;
		else if(direction=="NEXT")
			dir=this.LOCATION_NEXT;
		else if(direction=="ZOOM_IN")
			dir=this.LOCATION_ZOOM_IN;
		else if(direction=="ZOOM_OUT")
			dir=this.LOCATION_ZOOM_OUT;
		else if(direction=="WHERE_AM_I")
			dir=this.LOCATION_WHERE_AM_I;
		//
		return dir;
	}
}

// Mapplet wrapper object
function MapObject() {
	// applet reference
	this.oApplet=null;
	// applet proxy reference
	this.oAppletProxy=null;
	// applet ready flag
	this.bAppletReady=false;

	// applet ui reference
	this.oMappletUI=null;
	// applet mapper reference
	this.oMapper=null;
	// applet geocoder reference
	this.oGeocoder=null;
	// applet geocoder result table model
	this.oGeocoderResultModel=null;
	// applet geocoder bookmark table model
	this.oGeocoderBookmarkModel=null;
	// applet digita-plugin reference
	this.oDigita=null;


	// applet and applet proxy callback method
	// it is defined as applet parameter
	// it prepares the references
	this.onAppletStatusChanged=Map_onAppletStatusChanged;
	function Map_onAppletStatusChanged() {

		// check applet proxy reference
		if(this.oAppletProxy==null) {

			// check applet reference
			if(this.oApplet==null) {

				// get applet reference
				this.oApplet=document.getElementById("Mapplet");

			}

			// if is valid reference
			if(this.oApplet!=null) {
				
				try {
					
					// check if it's ready
					if(this.oApplet.isReady()) {

						//alert(this.oApplet);
						output("Applet init");

						// get proxy object
						this.oAppletProxy=this.oApplet.getProxy();

					} else {
						// Some error has occured.
						output("Applet error");
					}
					
				} catch(e) { }

			}
		}

		// if is valid reference
		if(this.oAppletProxy!=null) {

			// get the status
			var status=this.oAppletProxy.getStatus();
			output("Status: "+status);

			// check if it has started
			if(status==oMapConst.STATUS_STARTED) {

				output("Applet started");

				// set flag
				this.bAppletReady=true;

				// get mapper window
				this.getMapper();

				output("Applet loaded");

			}
		}
	}

	// gets the mapper window
	this.getMapper=Map_getMapper;
	function Map_getMapper() {
		if(this.oMapper==null) {
			// get mapplet ui plugin
			this.oMappletUI=this.oAppletProxy.getPlugin("mappletUI");
			if(this.oMappletUI==null) {
				output("Error: getPlugin: mappletUI");
				return false;
			}

			// get mapper window
			this.oMapper=this.oMappletUI.getMapCanvas();
			if(this.oMapper==null) {
				output("Error: getMapCanvas");
				return false;
			}
		}
		return true;
	}

	// gets the geocoder plugin
	this.getGeocoder=Map_getGeocoder;
	function Map_getGeocoder() {
		if(this.oGeocoder==null) {
			// get geocoder plugin
			this.oGeocoder=this.oAppletProxy.getPlugin("geocoder");
			if(this.oGeocoder==null) {
				output("Error: getPlugin: geocoder");
				return false;
			}

			// get geocoder result table model
			this.oGeocoderResultModel=this.oGeocoder.getResultTableModel();
			if(this.oGeocoderResultModel==null) {
				output("Error: geocoder.getResultTableModel");
				return false;
			}
			// get geocoder bookmark table model
			this.oGeocoderBookmarkModel=this.oGeocoder.getBookmarkTableModel();
			if(this.oGeocoderBookmarkModel==null) {
				output("Error: geocoder.getResultTableModel");
				return false;
			}
		}
		return true;
	}

	// geocoder event handler
	this.onGeocodingResult=Map_onGeocodingResult;
	function Map_onGeocodingResult() {
		// get plugin
		if(!this.getDigitaPlugin())
			return;
					
		var resCnt=this.oGeocoderResultModel.getRowCount();

		// Call outside function.
		if (typeof(Karttapalvelu) != "undefined") {
			if (typeof(Karttapalvelu.AppletEvents.onGeogodingResults) == "function") 
				Karttapalvelu.AppletEvents.onGeogodingResults(resCnt);
		}
			
	}

	// geocoder event handler
	this.geocode=Map_geocode;
	function Map_geocode(input, area, type) {
		// get geocoder
		if(!this.getGeocoder())
			return;
		// geocode name
		
		this.oGeocoder.geocode(input, area, "fi", type);
	}
	this.geocodeLayerVisible=Map_geocodeLayerVisible;
	function Map_geocodeLayerVisible(visible) {
		// get geocoder
		if(!this.getGeocoder())
			return;
		//
		this.oGeocoder.showLayer(visible);
	}
	this.geocodeDialogVisible=Map_geocodeDialogVisible;
	function Map_geocodeDialogVisible(visible) {
		// get geocoder
		if(!this.getGeocoder())
			return;
		//
		this.oGeocoder.showDialog(visible);
	}
	this.geocodeClear=Map_geocodeClear;
	function Map_geocodeClear() {
		// get geocoder
		if(!this.getGeocoder())
			return;
		//
		this.oGeocoderResultModel.clear();
	}


	// gets the current view
	this.getView=Map_getView;
	function Map_getView() {
		if(!this.bAppletReady) {
			output("Error: Applet is not ready");
			return;
		}
		// get mapper window
		if(!this.getMapper())
			return;
		//
		var oView=this.oMapper.getCurrentView();
		if(oView==null) {
			output("Error: getCurrentView");
			return;
		}
		//
		this.debugView(oView);
	}

	// debugs a map view
	this.debugView=Map_debugView;
	function Map_debugView(oView) {
		if(oView==null) {
			output("Error: oView");
			return;
		}

		if (location.search.substring(1, location.search.length).toLowerCase().indexOf("dbg=on") > -1){
			var sDbg = "";

			sDbg += "<b>Debug map view:</b><br>";
			sDbg += "getScale: " + oView.getScale() + "<br>";
			sDbg += "getZoomLevel: " + oView.getZoomLevel() + "<br>";
			sDbg += "getCx: " + oView.getCx() + "<br>";
			sDbg += "getCy: " + oView.getCy() + "<br>";
			sDbg += "getUrY: " + oView.getUrY() + "<br>";
			sDbg += "getUrX: " + oView.getUrX() + "<br>";
			sDbg += "getLlY: " + oView.getLlY() + "<br>";
			sDbg += "getLlX: " + oView.getLlX() + "<br>";
			sDbg += "<a href='javascript: oMap.debugView(oMap.oMapper.getCurrentView());'>Show current</a>";
			try {
				document.getElementById("debug").innerHTML = sDbg;
			}
			catch (e) {}
		}	
	}

	// show/hide layer
	this.showLayer=Map_showLayer;
	function Map_showLayer(layername, modifiers) {
		if(!this.bAppletReady) {
			output("Error: Applet is not ready");
			return;
		}
		// get mapper window
		if(!this.getMapper())
			return;
		//
		this.oMapper.showLayer(layername, modifiers);
	}

	// refresh
	this.refresh=Map_refresh;
	function Map_refresh(full) {
		if(!this.bAppletReady) {
			output("Error: Applet is not ready");
			return;
		}
		// get mapper window
		if(!this.getMapper())
			return;
		//
		this.oMapper.refresh(full);
	}

	// moves to new location
	this.goTo=Map_goTo;
	function Map_goTo(direction) {
		if(!this.bAppletReady) {
			output("Error: Applet is not ready");
			return;
		}
		// get mapper window
		if(!this.getMapper())
			return;
		//
		var dir=oMapConst.decodeDirection(direction);
		if(dir>0) {
			var flags=(document.getElementById('incremental').checked ? 0 : oMapConst.NO_INCREMENTAL_UPDATE);
			var oView=this.oMapper.goTo(dir, flags);
			if(oView==null)
				output("Failed: goTo");
			else
				this.debugView(oView);
		}
		return;
	}

	// moves to new center
	this.centerTo=Map_centerTo;
	function Map_centerTo(x, y) {
		if(!this.bAppletReady) {
			output("Error: Applet is not ready");
			return;
		}
		// get mapper window
		if(!this.getMapper())
			return;
		//
		var flags=(document.getElementById('incremental').checked ? 0 : oMapConst.NO_INCREMENTAL_UPDATE);
		var oView=this.oMapper.centerTo(x, y, flags);
		if(oView==null)
			output("Failed: centerTo");
		else
			this.debugView(oView);
		//
		return;
	}

	// moves to new extend
	this.extendTo=Map_extendTo;
	function Map_extendTo(x1, y1, x2, y2) {
		if(!this.bAppletReady) {
			output("Error: Applet is not ready");
			return;
		}
		// get mapper window
		if(!this.getMapper())
			return;
		//
		var flags=(document.getElementById('incremental').checked ? 0 : oMapConst.NO_INCREMENTAL_UPDATE);
		var oView=this.oMapper.extendTo(x1, y1, x2, y2, flags);
		if(oView==null)
			output("Failed: extendTo");
		else
			this.debugView(oView);
		//
		return;
	}

	// moves to new scale
	this.scaleTo=Map_scaleTo;
	function Map_scaleTo(s) {
		if(!this.bAppletReady) {
			output("Error: Applet is not ready");
			return;
		}
		// get mapper window
		if(!this.getMapper())
			return;
		//
		var flags=(document.getElementById('incremental').checked ? 0 : oMapConst.NO_INCREMENTAL_UPDATE);
		var oView=this.oMapper.scaleTo(s, flags);
		if(oView==null)
			output("Failed: scaleTo");
		else
			this.debugView(oView);
		//
		return;
	}

	// moves to new zoomlevel
	this.zoomLevelTo=Map_zoomLevelTo;
	function Map_zoomLevelTo(z) {
		if(!this.bAppletReady) {
			output("Error: Applet is not ready");
			return;
		}
		// get mapper window
		if(!this.getMapper())
			return;
		//
		var flags=(document.getElementById('incremental').checked ? 0 : oMapConst.NO_INCREMENTAL_UPDATE);
		var oView=this.oMapper.zoomLevelTo(z, flags);
		if(oView==null)
			output("Failed: zoomLevelTo");
		else
			this.debugView(oView);
		//
		return;
	}

	// gets the Digita plugin
	this.getDigitaPlugin=Map_getDigitaPlugin;
	function Map_getDigitaPlugin() {
		if(this.oDigita==null) {
			// get Digita plugin
			this.oDigita=this.oAppletProxy.getPlugin("digita");
			if(this.oDigita==null) {
				output("Error: getPlugin: digita");
				return false;
			}
		}
		return true;
	}

	//
	this.goToRegion=Map_goToRegion;
	function Map_goToRegion(code) {
		// get geocoder
		if(!this.getDigitaPlugin())
			return;
		//
		this.oDigita.highlightRegion(code);
		var flags=(document.getElementById('incremental').checked ? 0 : oMapConst.NO_INCREMENTAL_UPDATE);
		this.oDigita.goToRegion(code, flags);
	}
	//
	this.goToDVBHRegion=Map_goToDVBHRegion;
	function Map_goToDVBHRegion(code) {
		// get geocoder
		if(!this.getDigitaPlugin())
			return;
		//
		//alert("goToDVBHRegion:"+code);
		var flags=(document.getElementById('incremental').checked ? 0 : oMapConst.NO_INCREMENTAL_UPDATE);
		this.oDigita.goToDVBHRegion(code, flags);
	}
		//
	this.goToMunicipality=Map_goToMunicipality;
	function Map_goToMunicipality(code) {
		// get geocoder
		if(!this.getDigitaPlugin())
			return;
		//
		var flags=(document.getElementById('incremental').checked ? 0 : oMapConst.NO_INCREMENTAL_UPDATE);
		this.oDigita.goToMunicipality(code, flags);
	}
	//
	this.goToMunicipalityByName=Map_goToMunicipalityByName;
	function Map_goToMunicipalityByName(name) {
		// get geocoder
		if(!this.getDigitaPlugin())
			return;
		//
		var flags=(document.getElementById('incremental').checked ? 0 : oMapConst.NO_INCREMENTAL_UPDATE);
		return this.oDigita.goToMunicipalityByName(name, flags);
	}

	// digita plugin event handler
	this.onAntennaClick=Map_onAntennaClick;
	function Map_onAntennaClick() {
		// get plugin
		if(!this.getDigitaPlugin())
			return;
		//
		var code=this.oDigita.getLastClickedAntenna();
		this.oDigita.highlightRegion(code);
		var flags=(document.getElementById('incremental').checked ? 0 : oMapConst.NO_INCREMENTAL_UPDATE);
		this.oDigita.goToRegion(code, flags);

		// Show channels of the selected Antenna.
		if (typeof(MastClickedFromApplet) == "function") MastClickedFromApplet(code);

	}
	// digita plugin event handler
	this.onDVBHClick=Map_onDVBHClick;
	function Map_onDVBHClick() {
		// get plugin
		if(!this.getDigitaPlugin())
			return;
		//
		var code=this.oDigita.getLastClickedDVBHRegion();
		//alert("onDVBHClick:"+code);
		var flags=(document.getElementById('incremental').checked ? 0 : oMapConst.NO_INCREMENTAL_UPDATE);
		this.oDigita.goToDVBHRegion(code, flags);

		// Call outside function.
		// Check if there is a handler for this event.
		if (typeof(Karttapalvelu) != "undefined") {
			if (typeof(Karttapalvelu.AppletEvents.onClickInsideDvbhCoverage) == "function")
				Karttapalvelu.AppletEvents.onClickInsideDvbhCoverage(inside);
		}
		
	}
	// digita plugin event handler
	this.onMunicipalityClick=Map_onMunicipalityClick;
	function Map_onMunicipalityClick() {
		// get plugin
		if(!this.getDigitaPlugin())
			return;
		//
		var code=this.oDigita.getLastClickedMunicipality();
		var flags=(document.getElementById('incremental').checked ? 0 : oMapConst.NO_INCREMENTAL_UPDATE);
		this.oDigita.goToMunicipality(code, flags);
		
		// TODO: 
		// This should be removed and replaced as done at the end of this function.
		// But retain here for DigiTV map service.
		if (typeof(MunicipalityClickedFromApplet) == "function") MunicipalityClickedFromApplet(code);

		// Call outside function.
		// Check if there is a handler for this event.
		if (typeof(Karttapalvelu) != "undefined") {
			if (typeof(Karttapalvelu.AppletEvents.onMunicipalityClick) == "function")
				Karttapalvelu.AppletEvents.onMunicipalityClick(code);
		}
		
	}	
	// Highlight antenna.
	this.highlightAntennaRegion=Map_highlightAntennaRegion;
	function Map_highlightAntennaRegion(code) {
		// get geocoder
		if(!this.getDigitaPlugin())
			return;
		//
		this.oDigita.highlightRegion(code);
	}
	
}

var oDivInfo=null;
function output(text) {
	if (location.search.substring(1, location.search.length).toLowerCase().indexOf("dbg=on") > -1) {
		oDivInfo=document.getElementById("divInfo");
		if(oDivInfo==null) {
			oDivInfo=document.createElement("DIV");
			document.body.appendChild(oDivInfo);
		}
		oDivInfo.innerHTML=text.replace(/</gi, "&lt;");
	}
}

// create new MapObject
var oMapConst=new MapConstants();
// create new MapObject
var oMap=new MapObject();

// write applet tag
function writeApplet() {
	document.open();
	if(navigator.javaEnabled()) {
		document.writeln(CODE_MAPPLET);
	} else {
		document.writeln(CODE_ENABLE_JAVA);
	}
	document.close();
	output(CODE_MAPPLET);
}

// applet and applet proxy callback method
// it is defined as applet parameter
// it prepares the references
function onAppletStatusChanged() {
	oMap.onAppletStatusChanged();
}
function onGeocodingResult() {
	oMap.onGeocodingResult();
}
function onAntennaClick() {
	oMap.onAntennaClick();
}
function onMunicipalityClick() {
	oMap.onMunicipalityClick();
}
function onDVBHClick() {
	oMap.onDVBHClick();
}
