	    /* (c) 2007 www.imaps.lt
	     *** init map JS functions:
	     $ load map on page:
	        imaps_initMap(id, background, width, height, addon)
		              id          - user id
			      background  - "RRGGBB"
			      width       - map width
			      height      - map height
			      addon       - can be: <name=value>&[<name=value>&..]
			                        firstDClickScale - 0, 1, 2 ...
						    how much resize on first Double Click.
						curves - "0,1,2,3,5" <- curve ids.
						    what curves to show on screen.

	     $ init map controller: (on same .html API's works without controller)
		imaps_initControl(superdomain), when all API's below can be called:
	     *** external swf API's:			
		goTo(obj_id)                   - place map to this obj center
		addTarget("id[,id1][,id2]")    - add targets
		removeTarget("id[,id1][,id2]") - remove targets
		updateInfo(obj_id)             - update only this object info.
		setLang(language)              - set map language

		showCurve(curve_nr)            - show course ["all" - show all]
		hideCurve(curve_nr)            - hide course [ -- // --- ]
		curveLock(1/0)                 - show dots attached to curves.

        ** added 2010-06-11
        externalFilter("id[,id1][,id2]") - show only these dots (id - is dot id, NOT TYPE!).

		API's called:
		  imaps_onLang(language);      - call then language changes
		  imaps_onOver(obj_id, title); - call then mouse is over obj.
		               obj_id = -1     - then roll out.
	    */
	var imaps_global_user_id = 0;
	var imaps_global_control_name = "imapCtrl";
	var imaps_global_core_name = "imapCore";
	var imaps_global_flash = null;
	var imaps_global_core_port = 0;
	function __imaps_getFlashMovieObject(n) {
	    if (window.document[n]) return window.document[n];
	    if (navigator.appName.indexOf("Microsoft Internet")==-1)
		if (document.embeds && document.embeds[n])
    		    return document.embeds[n];
	    return document.getElementById(n);
	}
	function imaps_getiMapObject() {
	    if (imaps_global_flash) return imaps_global_flash;
	    if (!(imaps_global_flash = __imaps_getFlashMovieObject(imaps_global_control_name)))
		imaps_global_flash = __imaps_getFlashMovieObject(imaps_global_core_name);
	    return imaps_global_flash;
	}
	function imaps_updateInfo(dot_id) {
	    imaps_getiMapObject();
	    if (imaps_global_flash && imaps_global_flash.updateInfo)
		imaps_global_flash.updateInfo(dot_id);
	}
	function imaps_goTo(dot_id) {
	    imaps_getiMapObject();
	    if (imaps_global_flash && imaps_global_flash.goTo)
		imaps_global_flash.goTo(dot_id);
	}
	function imaps_addTarget(id) {
	    imaps_getiMapObject();
	    if (imaps_global_flash && imaps_global_flash.addTarget)
		imaps_global_flash.addTarget(id);
	}
	function imaps_removeTarget(id) {
	    imaps_getiMapObject();
	    if (imaps_global_flash && imaps_global_flash.removeTarget)
		imaps_global_flash.removeTarget(id);
	}
	function imaps_showCurve(id) {
	    imaps_getiMapObject();
	    if (imaps_global_flash && imaps_global_flash.showCurve)
		imaps_global_flash.showCurve(id);
	}
	function imaps_hideCurve(id) {
	    imaps_getiMapObject();
	    if (imaps_global_flash && imaps_global_flash.hideCurve)
		imaps_global_flash.hideCurve(id);
	}
	function imaps_curveLock(id) {
	    imaps_getiMapObject();
	    if (imaps_global_flash && imaps_global_flash.curveLock)
		imaps_global_flash.curveLock(id);
	}
	function imaps_setLang(id) {
	    imaps_getiMapObject();
	    if (imaps_global_flash && imaps_global_flash.setLang)
		imaps_global_flash.setLang(id);
	}

	function imaps_getPort() {
	    imaps_getiMapObject();
	    if (imaps_global_flash && imaps_global_flash.getPort)
		return imaps_global_flash.getPort();
	    return 0;
	}
	function imaps_externalFilter(ids) {
	    imaps_getiMapObject();
	    if (imaps_global_flash && imaps_global_flash.externalFilter)
		imaps_global_flash.externalFilter(ids);
	}
	function imaps_initControl(superdomain, port) { // imaps_onCtrlLoad() function is called then control is loaded.
	    if (typeof(AC_FL_RunContent) == 'undefined') { alert('please include: http://data.imaps.lt/js/swf.js'); return; }
    AC_FL_RunContent(
	'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
	'width', '0',
	'height', '0',
	'src', 'http://data.imaps.lt/imapCtrl',
	'quality', 'high',
	'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
	'align', 'middle',
	'play', 'true',
	'loop', 'true',
	'scale', 'showall',
	'wmode', 'window',
	'devicefont', 'false',
	'Flashvars', 'host='+superdomain+'&port='+port,
	'id', imaps_global_control_name,
	'bgcolor', '#000000',
	'name', imaps_global_control_name,
	'menu', 'false',
	'allowFullScreen', 'false',
	'allowScriptAccess','always',
	'movie', 'http://data.imaps.lt/imapCtrl',
	'salign', '',
	'style', 'width: 0px; height: 0px; position: absolute;'
    );
	}
	function imaps_initMap(id, background, width, height, addon) {
	    imaps_global_user_id = id;
	    imaps_global_core_port = Math.floor(Math.random() * 65535) + 1;
	    if (typeof(addon) == 'undefined') addon = "";
	    if (typeof(AC_FL_RunContent) == 'undefined') { alert('please include: http://data.imaps.lt/js/swf.js'); return false; }
	    if (!(isIE && !isOpera)) {
		if (!DetectFlashVer(10, 0, 0)) { // not found... 28 ok
		    document.write(
		    'Jus naudojates sena flash versija, prasome parsisiusti naujesne versija: '+
		    '<a href=https://www.macromedia.com/go/getflash/>Parsisiusti</a>'
		    );
		    return false;
		}
	    }
		AC_FL_RunContent(
			'codebase',
'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
			'width', width,
			'height', height,
			'src', 'http://data.imaps.lt/imapCore',
			'quality', 'high',
			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			'align', 'middle',
			'play', 'true',
			'loop', 'true',
			'scale', 'showall',
			'wmode', 'window',
			'devicefont', 'false',
			'id', imaps_global_core_name,
			'bgcolor', '#'+background,
			'name', imaps_global_core_name,
			'menu', 'false',
			'allowFullScreen', 'false',
			'Flashvars', 'id='+id+'&bg=0x'+background+'&port_nr='+imaps_global_core_port+"&"+addon,
			'allowScriptAccess','always',
			'movie', 'http://data.imaps.lt/imapCore',
			'salign', ''
		);
		return true;
	}
	function imaps_showInfo(id, target, port, lang, sid) { // [sid]-optional
	    var url = "http://data.imaps.lt/info/index.php?id="+id+"&target="+target;
	    var width;
	    var wnd;
	    if (sid !== undefined) {
		url = url + "&port="+port+"&sid="+sid;
		width = 670;
	    } else {
		width = 640;
	    }
	    url = url + "&lang=" + lang;
	    wnd = window.open(url, "imapsInfoBox", "directories=0, location=0, menubar=0, toolbar=0, resizable=1, scrollbars=1, width="+width+", height=480");
	    if (wnd) wnd.focus();
	    return true;
	}
