/* seuraavissa funktioissa on eroja
	beginDrag     - erilainen event-käsittely, LISTAA EROT
	muut funtiot ovat tässä tiedostossa tai contactPoiServer.js-tiedostossa

function init()
function noSelect (element)
function ftAlert (string)
function doLoadingDiv ()
function removeLoadingDiv ()
function catList ()
function ft_classAttribute (obj, className)
function keyBoardMove(e)
function umlToSkand (tex)
function skandToUml (tex)
function panMap(dX,dY)
function calcInfo ()
function debugText (tex)
function mapSize(leveys, korkeus)
function drawCopyRight()
function zoomDivs (mScale)
function doZoom (mScale)
function doZoomPlus ()
function doZoomMinus ()
function createPOI (poiId, poiDbId, category, poiX, poiY, poiHref, poiTitle, poiInfo)
function createPOIList (ftPoiList)
function removePOIList () 
function updatePOIList () // poiObjektien liikuttelu
function createCP ()
function arrayMember (arr, member)
function arrayMones (arr, member)
function createCanvas ()
function calcMapCanvas ()
function doEditMode (eFlag)
function toggleCatRadioElement (catNum)
function doOpenCatRadioWindow ()
function drawCP ()
function clipMapDiv(element)
function addNewObject ()
function copyNewObject ()
function catchXYcoord ()
function saveToDbase ()
function removeFromDbase ()
function checkEngUrl()
function checkFinUrl()
function doLanguage ()
function getPoiIcon (catName)
function doSearch ()
function openSearchResultDiv (ftSearchResultPoiList)
function doCloseSearchResultDiv ()
function doShowOnMap (dbId, poiCat, xNew, yNew)
function doOpenCatWindow (eFlag)
function toggleCatElement (catNum)
function notShowPoiCat (catName)
function doCloseCatDiv ()
function copyLinkToClipBoard ()
function sendEmailF()
function doCloseEmail ()
function openFtWindow(osoite)
function startList()  // Tämä on menubaria varten ja vain ie:lle luulisin

*/


function init() {
	// ajetaan projekti kohtaiset tiedot conf-tiedostosta
	loadconf();
	//alert('Moi init.common');
	// ------------------------------
	
	catWindowFlag = false;
	editFlag = false;
	selLinksFlag = false;
	ftSelectedCatList = null;
	ftSelectedRadioCat = 'rakennus';
	ftPoiTemp = null;

	poiEditMode = 'new'; 'edit'/'new'
	debugMode = false; // näytetäänkö testDiv'issä debuggaus tekstiä (testTextDiv)
	// alustetaan ftPoiList
	ftPoiList = null;
	// UUSI lista, jossa eri katergorioista POI-objekteja
//	ftNewPoiList = null;
	ftDragtext = '';
	// koitetaan esilatausta IE:n bugin takia
	image1 = new Image();
	image1.src = "images/close.gif";
	
	// Tällä tarkistetaan tietyin välin DOM-puun orvot img-objektit
	// vielä käytössä, mutta jatkossa varmaankin tarpeeton
	virheLaskin = 0;

	// Nämä auttavat IE:n drag-ongelmaan, mutta estävät tekstin kopioinnin.
	// korjasin ongelman 2.9.2006 noSelect-funktiolla, joka
	// laitetaan jokaiselle img-objektille
	// tällöin kaikki muut osat voi valita
	// http://www.ditchnet.org/wp/2005/06/15/ajax-freakshow-drag-n-drop-events-2/
	// document.body.ondrag = function () { return false; };
	// document.body.onselectstart = function () { return false; };
	

	catList();
} // init

// tällämerkitään kaikki img-objektit ei valittaviksi, jotta niitä voisi dragatä
function noSelect (element) {
	element.ondrag = function () { return false; };
	element.onselectstart = function () { return false; };
}

function ftAlert (string) {
	if(ftDebugEcho == 1) {
		alert(string);
	}
}

// tällä kerrotaan käyttäjälle, että ladataan palvelimelta
function doLoadingDiv () {
	var loadingDiv = document.createElement("div");
	loadingDiv.setAttribute("id", "loadingDiv");
	document.body.appendChild(loadingDiv);
	loadingDiv.style.left= 200;
	loadingDiv.style.top = ftStatusDivHeight + ftUpperbannerHeight + 65; // vika 30
	loadingDiv.style.width = 180; // 200;
	loadingDiv.style.height = 50;
	if(ftLanguage == 'finnish')
		loadingDiv.innerHTML = 'Ladataan tietokannasta...';
	else
		loadingDiv.innerHTML = 'Loading from dataBase...';
}

// poistetaan "ladataan"-ilmoitus
function removeLoadingDiv () {
	var loadingDiv = document.getElementById("loadingDiv");
	document.body.removeChild(loadingDiv);
}


//
function catList () {
	var catLkm = ftCatNameList.length;
	ftCatList = new Array(catLkm);
	for (i=0; i<catLkm; i++) {
		var catName = ftCatNameList[i];
		var catPari = new Array(catName, false)
		ftCatList[i] = catPari;
	}
	//alert(ftCatList);
}
//
// tämän avulla toimii samat funktiot IE.ssä ja muissa, kun annetaan
// elementille class-attribuutti
function ft_classAttribute (obj, className) {
	if(selain == 'ie'){
		if (obj.getAttributeNode("class")) {
		  for (var i = 0; i < obj.attributes.length; i++) {
			 var attrName = obj.attributes[i].name.toUpperCase();
			 if (attrName == 'CLASS') {
				obj.attributes[i].value = className;
			 }
		  }
		// otherwise create a new attribute
		} else {
			obj.setAttribute("class", className);
		}
	}
	else {
		obj.setAttribute("class", className);
	}
}
// 

function keyBoardOn() {
	// Vaikuttako tämä IE-ongelmaan??
	if(selain == 'fox'){
		document.onkeydown = keyBoardMove;
		document.onkeyup = keyBoardMove;
	}
	else{

		ftMapDivElement.onkeydown = keyBoardMove;
		ftMapDivElement.onkeyup = keyBoardMove;
	}
}

//obj.setEvent("onkeydown", function(e) {this.trapkey (e);} );


function keyBoardOff() {
	if(selain == 'fox') {
		document.onkeydown = null;
		document.onkeyup = null;
	}
}

function keyBoardMove(e){
	//alert('painettu');
	if(selain == 'ie'){
		e = window.event;
	}
	//kbkoodi = e.button;
	kbkoodi = e.keyCode;

//	if(selain == 'fox'){
//		kbkoodi = e.which;
//	}


	//alert(kbkoodi);
	if(kbkoodi == 37){
		panMap(20,0);
	}
	else if(kbkoodi == 38){
		panMap(0,20);
	}
	else if(kbkoodi == 39){
		panMap(-20,0);
	}
	else if(kbkoodi == 40){
		panMap(0,-20);
	}
}

//
function umlToSkand (tex) {
	tex = tex.replace(/&auml;/g, 'ä');
	tex = tex.replace(/&Auml;/g, 'Ä');
	tex = tex.replace(/&ouml;/g, 'ö');
	tex = tex.replace(/&Ouml;/g, 'Ö');
	tex = tex.replace(/&aring;/g, 'å');
	tex = tex.replace(/&Aring;/g, 'Å');
	tex = tex.replace(/&quot;/g, '"');
	tex = tex.replace(/&aacute;/g, 'á');
	tex = tex.replace(/&Aacute;/g, 'Á');
	tex = tex.replace(/&eacute;/g, 'é');
	tex = tex.replace(/&Eacute;/g, 'É');
	tex = tex.replace(/&uuml;/g, 'ü');
	tex = tex.replace(/&Uuml;/g, 'Ü');
	tex = tex.replace(/&ecirc;/g, 'ê');
	tex = tex.replace(/&Uuml;/g, 'Ü');
	tex = tex.replace(/&amp;/g, '&');
	tex = tex.replace(/&acute;/g, '´');
	
//	&lt; <
//	&gt; >
//	&copy;  
	
	return tex
}
//
// tätä ei tarvita, koska char-coodaus toimii nyt cpaintissä
function skandToUml (tex) {
	tex = tex.replace(/ä/g, '&auml;');
	tex = tex.replace(/Ä/g, '&Auml;');
	tex = tex.replace(/ö/g, '&ouml;');
	tex = tex.replace(/Ö/g, '&Ouml;');
	tex = tex.replace(/å/g, '&aring;');
	tex = tex.replace(/Å/g, '&Aring;');
	return tex
}
//
//
function panMap(dX,dY) {
	ftMapX = ftMapX - ftMapScale/1000 * dX;
	ftMapY = ftMapY - ftMapScale/1000 * dY;
	calcMapCanvas();
	updatePOIList();
	drawCP();
	ftMapDivElement.focus();
}
//

function calcInfo (){
	//
	var ots = '&nbsp;&nbsp;CityGuide3D Beta 0.6 - 15.6.2006'
	str1 = "&nbsp;&nbsp;Width: " + ftWindowWidth + "," + ftWindowHeight + "." + "  |  X:" + ftMapX + ",Y:" + ftMapY + " | ftMapScale: " + ftMapScale;
	//str2 = '<br>DeltaX: ' + testD + ' | clX2: ' + clX2;
	str2 = ' | MapLev: ' + ftMapWidth + ', MapKor: ' + ftMapHeight;
	str = str0 + str1 + str2;
	str = ots + str + ftInfoTex3;
	debugText(str);
}

function debugText (tex) {
	if (ftdebugAreaMode == 'debug') {
		debugDivElement = document.getElementById("debugArea");
		debugDivElement.innerHTML = '&nbsp;ftdebugAreaMode on: ' + ftdebugAreaMode + tex;
	}
//	debugDivElement = document.getElementById("debugArea");
//	debugDivElement.innerHTML = tex;
}

function mapSize(leveys, korkeus) {
	ftMapWidth  = leveys;
	//alert(ftMapWidth + ' flag: ' + editFlag);
	ftMapHeight = korkeus;
	// yläbanneri
	bannerElement = document.getElementById("upperbanner")
	debugDivElement = document.getElementById("debugArea");
	bannerElement.style.width=ftWindowWidth;
	debugDivElement.style.left = (ftWindowWidth - 728 ) / 2;
	ftMapDivElement.style.width =  ftMapWidth;
	ftMapDivElement.style.height = ftMapHeight;
	//
	//alert('ms3');
	clipMapDiv(ftMapDivElement);
	//alert('ms4');
	calcMapCanvas();
	//alert('ms5');
	calcInfo();
	//alert('ms6');
	drawCP();
	//alert('ms7');
	drawCopyRight();
	//alert('ms8');
	
	if (document.getElementById("editDiv") != null) {
		document.getElementById("editDiv").style.left= ftMapWidth + ftLeftDivWidth;
	}
} // function mapSize


function drawCopyRight() {
	//alert('Piirretään copyright');
	var crElement = document.getElementById("copyRight");
	crElement.style.left = ftLeftDivWidth + 10; //ftMapWidth + ftLeftDivWidth;


	crElement.style.top = ftUpperbannerHeight + ftMapHeight - 20;
	//crElement.style.top = 400;
	crElement.innerHTML =  ftCopyRightText;//'&copy;Fontus Ltd';
}


function zoomDivs (mScale) {
	if (ftMapScale == ftMapScale_1) {
		document.getElementById("z1").src = 'images/zoomOn.gif';
	}
	else {
		document.getElementById("z1").src = 'images/zoomOff.gif';
	}
	//
	if (ftMapScale == ftMapScale_2) {
		document.getElementById("z2").src = 'images/zoomOn.gif';
	}
	else {
		document.getElementById("z2").src = 'images/zoomOff.gif';
	}
	// 4 => 2000
	if (ftMapScale == ftMapScale_3) {
		document.getElementById("z4").src = 'images/zoomOn.gif';
	}
	else {
		document.getElementById("z4").src = 'images/zoomOff.gif';
	}
	// 8 => 4000
	if (ftMapScale == ftMapScale_4) {
		document.getElementById("z8").src = 'images/zoomOn.gif';
	}
	else {
		document.getElementById("z8").src = 'images/zoomOff.gif';
	}
	// 16 => 8000
	if (ftMapScale == ftMapScale_5) {
		document.getElementById("z16").src = 'images/zoomOn.gif';
	}
	else {
		document.getElementById("z16").src = 'images/zoomOff.gif';
	}
} // function zoomDivs


function doZoom (mScale) {
	//alert('dZ_0');
	ftMapScale = mScale;
	var mapDivEl = document.getElementById("mapDiv");
	//alert(mapDivEl);
	// poistetaankin hyödyntäen ftMapList-arrayta
	var lask=0;
	var liLen = ftMapList.length;
	for (i=0; i<liLen; i++) {
		var oldImageId = ftMapList[i];
		//alert(oldImageId);
		var oldImageEl = document.getElementById(oldImageId);
		//alert(oldImageEl);
		if (oldImageEl != null) {
			mapDivEl.removeChild(oldImageEl);
		}
		lask++
	}
	zoomDivs(mScale);
	clipMapDiv(mapDivEl);
	createCanvas ();
	calcInfo();
	drawCP();

	if(ftPoiList != null) {
		// Mitä jos vain poistetaan kaikki POIDivit ja tehdään uudet
		removePOIList(ftPoiList);
		createPOIList(ftPoiList);
		updatePOIList();
	}
} // function doZoom
//

//
function doZoomPlus () {
	if(ftMapScale == ftMapScale_1)
		var flag = '1';
	else if(ftMapScale == ftMapScale_2)
		ftMapScale = ftMapScale_1;
	else if(ftMapScale == ftMapScale_3)
		ftMapScale = ftMapScale_2;
	else if(ftMapScale == ftMapScale_4)
		ftMapScale = ftMapScale_3;
	else if(ftMapScale == ftMapScale_5)
		ftMapScale = ftMapScale_4;
	if(flag != '1')
		doZoom (ftMapScale);
} // function doZoomPlus
//
function doZoomMinus () {
	if(ftMapScale == ftMapScale_5)
		var flag = '1';
	else if(ftMapScale == ftMapScale_1)
		ftMapScale = ftMapScale_2;
	else if(ftMapScale == ftMapScale_2)
		ftMapScale = ftMapScale_3;

	else if(ftMapScale == ftMapScale_3)
		ftMapScale = ftMapScale_4;
	else if(ftMapScale == ftMapScale_4)
		ftMapScale = ftMapScale_5;
	if(flag != '1')
		doZoom (ftMapScale);
} // function doZoomPlus
//

//
//
function createPOI (poiId, poiDbId, category, poiX, poiY, poiHref, poiTitle, poiInfo) {
	// pikseleinä
	var mapHalfW = parseInt(ftMapWidth / 2);
	var mapHalfH = parseInt(ftMapHeight / 2);
	//alert('create poi alkaa');
	var id2 = poiId.substring(3); // otetaan edestä 'poi' pois, koska muuteen muuttaa div-objektiksi
	//
	if (ftMapScale == ftMapScale_5) {
		ftPoiWidth = 10;
	}
	else if (ftMapScale == ftMapScale_4) {
		ftPoiWidth = 10;
	}
	else if (ftMapScale == ftMapScale_3) {
		ftPoiWidth = 15;
	}
	else if (ftMapScale == ftMapScale_2) {
		ftPoiWidth = 20;
	}
	else if (ftMapScale == ftMapScale_1) {
		ftPoiWidth = 20;
	}
	var iconName = getPoiIcon (category);
	iconName = iconName + '_' + ftPoiWidth + '.gif';
	//alert(iconName);
	newPOI = document.createElement("div");
	newPOI.setAttribute("id", poiId);
	ft_classAttribute(newPOI, "poiDiv");
	newPOI.style.position = 'absolute';
	
	var xLeft = parseInt(ftPoiDbScale * (poiX/(ftMapScale/1000)) + mapHalfW - ftMapX /(ftMapScale/1000));
	newPOI.style.left = xLeft - ftPoiWidth/2; //

	var yTop = parseInt(ftPoiDbScale * (poiY/(ftMapScale/1000)) + mapHalfH - ftMapY /(ftMapScale/1000));
	newPOI.style.top  = yTop - ftPoiWidth/2;
	ftMapDivElement.appendChild(newPOI);

	poiLink = document.createElement("a");

	if (editFlag == false) {
		poiLink.href = poiHref;
		poiLink.target = "blank";
	}
	else {
		poiLink.href = "#";
	}
	//poiLink.innerHTML = '<img src="images/poiRed.gif" height="10" width="10" border="0">'
	poiLink.innerHTML = '<img src="images/' + iconName + '" height="' + ftPoiWidth + '" width="' + ftPoiWidth  + '" border="0">'
	if(ftLanguage == 'finnish'){
		cat = category.toUpperCase();
	}
	else {
		if(category == 'none'){
			cat = 'NONE';
		}
		else if(category == 'rakennus')cat = 'BUILDING';
		else if(category == 'elokuva')cat = 'CINEMA';
		else if(category == 'teatteri')cat = 'THEATRE';
		else if(category == 'museo')cat = 'MUSEUM';
		else if(category == 'hotelli')cat = 'HOTEL';
		else if(category == 'ravintola')cat = 'RESTAURANT';
		else if(category == 'kahvila')cat = 'CAFE';
		else if(category == 'nahtavyys')cat = 'SIGHT';
		else if(category == 'kirkko')cat = 'CHURCH';
		else if(category == 'konserttitalo')cat = 'CONCERT';
		else if(category == 'kauppa')cat = 'SHOP';
		else if(category == 'ostoskeskus')cat = 'SHOPPING CENTER';
		else if(category == 'poliisi')cat = 'POLICE';
		else if(category == 'posti')cat = 'POST OFFICE';
		else if(category == 'pankki')cat = 'BANK';
		else if(category == 'yritys')cat = 'company';
		else if(category == 'yksityinen')cat = 'private';
	}

	var olCa = cat + " - " + poiTitle;
	olCa = olCa.replace(/'/g, "&#39;");
	olCa = olCa.replace(/\u000d/g, "");
	olCa = olCa.replace(/\u000a/g, "");
	olCa = olCa.replace(/\u0009/g, "");
	//olCa = olCa.slice(0,10);
	//alert(poiInfo);

	// escape-funktio muuttaa stringit html-muotoon, mm välilyönnin ja non-asciin
	// /g muuttaa globaalisti

	if(poiInfo != "") {
		var olText = poiInfo.replace(/\u000d/g, "");
		olText = olText.replace(/\u000a/g, "<br>");
		olText = olText.replace(/\u0009/g, "");
		olText = olText.replace(/'/g, "&#39;");
	}
	else {
		olText = "No info";
	}

	if(editFlag == true) {
		olText = olText + '<br>Id: ' +  poiId + ', IdDb: ' +  poiDbId ;
	}

	//olText = olText.replace(/\u0026/g, "&amp;"); // Tätä ei voi tehdä, koska muuten &auml; ei toimi
	//olText = olText.slice(0,5);
	//alert(olText);
	//var olText = "Haisuli/Nokinenä";
	poiLink.onmouseover = new Function("return overlib('" + olText + "',CAPTION, '" + olCa + "');");
	poiLink.onmouseout = new Function("return nd();");
	poiLink.onfocus = new Function("this.blur();");
	if (editFlag == true) {
		//poiLink.onclick = new Function("getPoiById(" + poiDbId + ");"); // toimii
		poiLink.onclick = new Function("getPoiById(" + poiDbId + ", " + id2  + ");"); // toimii
	}
	
	//poiLink.title = poiId + " - " + poiTitle;
	//poiLink.alt = poiId + " - " + poiTitle;

	//poiLink.alt = "";
	//poiLink.title = "";
	
	//alert('id2 on ' + id2);

	newPOI.appendChild(poiLink)
} //function createPOI

function createPOIList (ftPoiList) {
	//alert('function createPOIList   -  ' + ftPoiList);
	var pArr = ftPoiList;
//	for(i in pArr) { // }
	var ftpLen = pArr.length;
	for (i=0; i<ftpLen; i++) {
		poi = pArr[i];
		//createPOI(poi[0],poi[1],poi[2],poi[3],poi[4])
		createPOI(poi[0],poi[1],poi[2],poi[3],poi[4],poi[5],poi[6],poi[7])
	}
}

function removePOIList () {
	if(ftPoiList != null) {
		var ftpLen = ftPoiList.length;
		for (i=0; i<ftpLen; i++) {
			var sublist = ftPoiList[i];
			var poiId = sublist[0];
			ftMapDivElement.removeChild(document.getElementById(poiId));
		}
	}
}

// poiObjektien liikuttelu
function updatePOIList () {

	//	alert('ftPoiList: ' + ftPoiList);
	//alert(ftCategory);

	//if(ftPoiList != null && ftCategory != 'none') { //}

	if(ftPoiTemp != null) {
		var mapHalfW = parseInt(ftMapWidth / 2);
		var mapHalfH = parseInt(ftMapHeight / 2);

		var poiX = ftPoiTempX;
		var poiY = ftPoiTempY;

		var xLeft = parseInt(ftPoiDbScale * (poiX/(ftMapScale/1000)) + mapHalfW - ftMapX /(ftMapScale/1000));
		ftPoiTemp.style.left = xLeft - ftPoiWidth/2; //
		var yTop = parseInt(ftPoiDbScale * (poiY/(ftMapScale/1000)) + mapHalfH - ftMapY /(ftMapScale/1000));
		ftPoiTemp.style.top  = yTop - ftPoiWidth/2;
	}



	if(ftPoiList != null ) {
		var mapHalfW = parseInt(ftMapWidth / 2);
		var mapHalfH = parseInt(ftMapHeight / 2);

		//alert(ftPoiList);
		//for(i in ftPoiList) {   //}
		var ftpLen = ftPoiList.length;
		for (i=0; i<ftpLen; i++) {
			var poiArr = ftPoiList[i];
			//alert('poiArr: ' + poiArr.toString());
			var poiId = poiArr[0];
			var poiX = parseInt(poiArr[3]);
			var poiY = parseInt(poiArr[4]);
			//alert('poiId: ' + poiId + ' | poiX: ' + poiX  + ' | poiY: ' + poiY);
			
			var newPOI = document.getElementById(poiId);
			var xLeft = parseInt(ftPoiDbScale * (poiX/(ftMapScale/1000)) + mapHalfW - ftMapX /(ftMapScale/1000));
			newPOI.style.left = xLeft - ftPoiWidth/2; //
			var yTop = parseInt(ftPoiDbScale * (poiY/(ftMapScale/1000)) + mapHalfH - ftMapY /(ftMapScale/1000));
			newPOI.style.top  = yTop - ftPoiWidth/2;
		}
	}

//	if( (poiX > (0 - ftMapX)) && (poiX < (0 - ftMapX) + ftMapWidth) && (poiY > (0 - ftMapY)) && (poiY < (0 - ftMapY) + ftMapHeight))
//		newPOI.style.visibility = 'visible';
//	else
//		newPOI.style.visibility = 'hidden';
}




//
function createCP () {
	//var ftMapDivElement = document.getElementById("mapDiv"); // toimii IE:ssä
	newCP = document.createElement("div");				// toimii IE:ssä
	newCP.setAttribute("id", "CP"); // tuntuu toimivan IE.ssä
	ft_classAttribute(newCP, "centerPointDiv");
	ftMapDivElement.appendChild(newCP);
	cX = parseInt(ftMapWidth  / 2 - ftMapX - 3);
	cY = parseInt(ftMapHeight / 2 - ftMapY - 3);
	newCP.style.left = cX;
	newCP.style.top  = cY;
}

// --------------------------------------------------------------------------------------------

// SEURAAVA TEKI OMITUISIA ONGELMIA
// remove-metodi
//Array.prototype.remove = function(s) {
//	for(i=0;i<this .length;i++){
//		if(s==this[i]) this.splice(i, 1);
//	}
//}

function arrayMember (arr, member) {
	var pit = arr.length;
	var raja = pit ;
	var flag = false;
	var lask = 0;
	while (lask < raja && flag != true ) {
		var element = arr[lask];
		if (element == member)
			flag = true;
		else
			lask++;
	}
	
	if (flag == false)
		return false;
	else
		return true;
}
//
// HUOM! tulos on +1
function arrayMones (arr, member) {
	var pit = arr.length;
	var raja = pit ;
	var flag = false;
	var lask = 0;
	while (lask < raja && flag != true ) {
		var element = arr[lask];
		if (element == member)
			flag = true;
		else
			lask++;
	}

	if (flag == false)
		return false;
	else
		return lask + 1;
}
/*
function testImage(URL) {
    var tester=new Image();
    //tester.onLoad=isGood;
    tester.onError=isBad;
    tester.src=URL;
}

//function isGood() {
//    alert('That image exists!');
//}

function isBad() {
	alert('That image does no exist!');
	
}
*/
//
//
function createCanvas () {
	//alert('createcanvas alkaa');
	//var ftMapDivElement = document.getElementById("mapDiv");
	clipMapDiv(ftMapDivElement);
	// mitat jatkossa aina metreissä 1Px=1 metri - ei enää 0.5 metreinä
	// OK 28.4. klo 15.25 metreiksi
	var leftEdgeX   = ftMapX - ftMapScale/1000 * ftMapWidth / 2;
	var rightEdgeX  = ftMapX + ftMapScale/1000 * ftMapWidth  / 2;
	var topEdgeY    = ftMapY - ftMapScale/1000 * ftMapHeight / 2 ;
	var bottomEdgeY = ftMapY + ftMapScale/1000 * ftMapHeight / 2 ;
	// pikseleinä
	var mapHalfW = parseInt(ftMapWidth / 2);
	var mapHalfH = parseInt(ftMapHeight / 2);
	//alert('leftEdgeX' + leftEdgeX + 'topEdgeY' + topEdgeY + ' | ftMapWidth:' + ftMapWidth  + ' | ftMapHeight:' + ftMapHeight);
	/*	
	testArr = new Array('ar', 'or', 'er', 'tr', 'tp', 'rr', 'ttr', 'rtr');
	alert(testArr);
	mones = arrayMember (testArr, 'ar');
	alert(mones);
	*/
	ftMapList = new Array();
	// etsitään ensimmäinen karttapala vasemmasta yläkulmasta
	// muutetaan metreistä pikseleiksi

	//var xruutuLkm = parseInt( (leftEdgeX )   / sliceW);
	// 
	var xruutuLkm = parseInt( (leftEdgeX /(ftMapScale/1000)) / sliceW);



	var xraja = xruutuLkm * sliceW;
	//alert('xraja: ' + xraja);
	var zoomTex = ftMapScale.toString();
	if(zoomTex == '500')
		zoomTex='0500';
	ftLaskuri = 0;
	// xraja on pikseleitä ja rightEdgeX on metrejä
	while (xraja * ftMapScale/1000  < rightEdgeX) {
		var yruutuLkm = parseInt( (topEdgeY /(ftMapScale/1000) )/ sliceH);
		var yraja = yruutuLkm * sliceH;
		while (yraja * ftMapScale/1000 < bottomEdgeY) {
			var idName = zoomTex + '_' + xraja + '_' + yraja; //OK
			//ftMapList[laskuri] = idName;
			ftMapList.push(idName);
			var filename = mapSliceName + idName + '.jpg';
			//alert('filename: ' + filename);
			var newMapImage = document.createElement("img");
			newMapImage.setAttribute("src", filename);
			newMapImage.setAttribute("id", idName);
			// seuraava tarpeeton, jos headin sisällä on jo <meta http-equiv="imagetoolbar" content="no" />
			//newMapImage.setAttribute("galleryImg", 'no');
			//ft_classAttribute(newMapImage, "mapImage");
			ftMapDivElement.appendChild(newMapImage);
			newMapImage.style.width  = sliceW;  //
			newMapImage.style.height = sliceH;  //
			newMapImage.style.position = 'absolute';
			noSelect (newMapImage);
			//
			var xLeft = xraja + mapHalfW - ftMapX /(ftMapScale/1000);
			//xLeft = xraja + mapHalfW - ftMapX * ftMapScale/1000;
			newMapImage.style.left = xLeft; //
			// ----
			var yTop = yraja + mapHalfH - ftMapY /(ftMapScale/1000);
			newMapImage.style.top  = yTop; //
			ftLaskuri++;
			yraja = yraja + sliceH;
		}
		xraja = xraja + sliceW;
	}	
	var pit = ftMapList.length;
	//alert('mapList pituus: ' + pit);
	//alert(ftMapList);
	//alert(leftEdgeX + ' ' + rightEdgeX + ' ' + topEdgeY + ' ' + bottomEdgeY);
} //function createCanvas

/*
function jaaListaksi (s) {
	var array2 = s.split('_');
	return array2;
}
*/


/*
function kuvaVirhe() {
	newMapImage.setAttribute("src", "maps/noMap.jpg");
	
	onError="alert('Image missing')
}
*/

//
function calcMapCanvas () {
	//
	//var ftMapDivElement = document.getElementById("mapDiv");
	ftAlert('.1.');
	
	// metreinä
	var leftEdgeX   = ftMapX - ftMapScale/1000 * ftMapWidth / 2;
	var rightEdgeX  = ftMapX + ftMapScale/1000 * ftMapWidth  / 2;
	var topEdgeY    = ftMapY - ftMapScale/1000 * ftMapHeight / 2 ;
	var bottomEdgeY = ftMapY + ftMapScale/1000 * ftMapHeight / 2 ;
	// pikseleinä
	var mapHalfW = parseInt(ftMapWidth / 2);
	var mapHalfH = parseInt(ftMapHeight / 2);
	var aput = ' ';
	// siirretään olemassa olevia ja poistetaan tarpeettomat
	var lask = 0;
	var poistoLista = new Array();

	ftAlert('.2.');


//	for(i in ftMapList) { // }
	var liLen = ftMapList.length;
	for (i=0; i<liLen; i++) {
		var mapNimi = ftMapList[i];
		aput = aput + ' - ' + mapNimi;
		//var sana = mapId;
		var listaus = mapNimi.split('_');
		//var listaus = jaaListaksi(mapNimi);
		var zoomArvo = listaus[0];
		var xraja2 = parseInt(listaus[1]);
		var yraja2 = parseInt(listaus[2]);
		//alert(mapId + ' ' + xraja + ' ' + yraja);
		var newMapImage = document.getElementById(mapNimi);
		if (newMapImage != null) {
			var xLeft = xraja2 + mapHalfW - ftMapX /(ftMapScale/1000);
			newMapImage.style.left = xLeft;
			var yTop = yraja2 + mapHalfH - ftMapY /(ftMapScale/1000);
			newMapImage.style.top  = yTop;
			///
			/// Tutkitaan onko poissa näkymästä
			// yli oikean reunan
			
			// TÄHÄN CASE-RAKENNE !!!!!
			
			if(xraja2  * ftMapScale/1000 > rightEdgeX){
				var test = document.getElementById(mapNimi);
				if (test != null) {
					ftMapDivElement.removeChild(newMapImage); // VOI TULLA VIRHE
				}
				poistoLista.push(mapNimi);
				//ftMapList.splice(lask, 1)
				//mapList.remove(lask);
			}
			// yli vasemman reunan
			else if( (xraja2 + sliceW) * ftMapScale/1000 < leftEdgeX){
				test = document.getElementById(mapNimi);
				if (test != null) {
					ftMapDivElement.removeChild(newMapImage); // VOI TULLA VIRHE
				}
				//ftMapList.splice(lask, 1)
				poistoLista.push(mapNimi);
			}
			// yli yläreunan
			else if( (yraja2 + sliceH) * ftMapScale/1000 < topEdgeY){
				test = document.getElementById(mapNimi);
				if (test != null) {
					ftMapDivElement.removeChild(newMapImage); // VOI TULLA VIRHE
				}
				poistoLista.push(mapNimi);
				//ftMapList.splice(lask, 1)
			}
			// yli alareunan
			else if(yraja2 * ftMapScale/1000 > bottomEdgeY){
				test = document.getElementById(mapNimi);
				if (test != null) {
					ftMapDivElement.removeChild(newMapImage); // VOI TULLA VIRHE
				}
				poistoLista.push(mapNimi);
				//ftMapList.splice(lask, 1)
			}
		}
		else {
			//alert('Ongelma :' + mapNimi);
			//alert(ftMapList);
			poistoLista.push(mapNimi);
			//ftMapList.splice(lask, 1)
		}

		lask++
	} // loop: ftMapList
	//alert('poistoLista :' + poistoLista.toString());


	ftAlert('.3.');

	var lask4 = 0;
//	for(i in poistoLista) { //}
	var liLen = poistoLista.length;
	for (i=0; i<liLen; i++) {
		var mapNimi = poistoLista[i];
		// HUOM! koska javascriptille 0 = false, on seuraavan tulos 1+ jäsen arrayssa
		var mones = arrayMones (ftMapList, mapNimi);
		if (mones != false)
			ftMapList.splice(mones - 1, 1);
		lask4++;
	}
	//alert('ftMapList :' + ftMapList.toString());
	//alert('Poistolistasta : ' + lask4);
	///
	/// Seuraavaksi tutkitaan tarvittavat karttapalat ja lisätään uudet
	///
	var newMapList = new Array();
	var xruutuLkm = parseInt( (leftEdgeX /(ftMapScale/1000)) / sliceW);
	var xraja = xruutuLkm * sliceW;
	var zoomTex = ftMapScale.toString();
	if(zoomTex == '500')
		zoomTex='0500';

	ftAlert('.4a.');

	ftLaskuri = 0;
	while (xraja * ftMapScale/1000 < rightEdgeX) {
		var yruutuLkm = parseInt( (topEdgeY / (ftMapScale/1000) )/ sliceH);
		var yraja = yruutuLkm * sliceH;
		ftAlert('.4b.');
		while (yraja * ftMapScale/1000  < bottomEdgeY) {

			ftAlert('.4c.');
			var idName = zoomTex + '_' + xraja + '_' + yraja;
			if (arrayMember (ftMapList, idName)  == false) {
				//newMapList[laskuri] = idName;
				newMapList.push(idName);
				var filename = mapSliceName + idName + '.jpg';
				// MITEN TARKASTETAAN LÖYTYYKÖ?????? => noMap.jpg
				//alert('filename: ' + filename);
				newMapImage = document.createElement("img");
				//newMapImage.onError=kuvaVirhe;
				newMapImage.setAttribute("src", filename);
				newMapImage.setAttribute("id", idName);
				newMapImage.setAttribute("galleryImg", 'no');
				noSelect (newMapImage);
				//ft_classAttribute(newMapImage, "mapImage");
				ftMapDivElement.appendChild(newMapImage);
				newMapImage.style.width  = sliceW;  //
				newMapImage.style.height = sliceH;  //
				newMapImage.style.position = 'absolute';
				xLeft = xraja + mapHalfW - ftMapX /(ftMapScale/1000);
				newMapImage.style.left = xLeft; // OK
				// ----
				yTop = yraja + mapHalfH - ftMapY /(ftMapScale/1000);
				newMapImage.style.top  = yTop; // OK
			}
			ftAlert('.4d.');
			ftLaskuri++;
			yraja = yraja + sliceH;
		}
		xraja = xraja + sliceW;
	}
	/// yhdistetään ftMapList ja newMapList
	ftAlert('.5.');
	// concat
	ftMapList = ftMapList.concat(newMapList);
	var pitUusi = ftMapList.length; 
	//aput2 = ftMapList.toString();
	aput2 = '';
	var lask = 1;
//	for(i in ftMapList) { // }
	var liLen = ftMapList.length;
	for (i=0; i<liLen; i++) {
		var mapNimi = ftMapList[i];
		aput2 = aput2 + ' | ' + lask + ' :' + mapNimi;
		lask++
	}
	pit2=lask - 1;
	aput = aput + ' LOPPU '
	//if (virheLaskin == 50) {
	//
	//}

	// tarkistetaan DOM-puun virheet
	var lapsiArr = ftMapDivElement.childNodes;
	var lapsiArrPituus = lapsiArr.length;

	ftAlert('.6.');

	// seuraava ei enää ole voimassa, sillä mukana myös POI-objektit
	/*
	if(lapsiArrPituus - 2 > pitUusi) {
		//alert(lapsiArr);
		for(i in lapsiArr) {
			var lapsi = lapsiArr[i];
			nodeNimi = lapsi.nodeName;  // TÄMÄ ANTAA VIRHEITÄ !!!!!!!
			//alert(nodeNimi);
			if(nodeNimi == 'IMG') {
				var nodeId = lapsi.id;
				if (arrayMember (ftMapList, nodeId)  == false) {
					//alert('VirheNode: ' + nodeId);
					var virheMapImage = document.getElementById(nodeId);
					ftMapDivElement.removeChild(virheMapImage);
					virheLaskin++;
				}
			}
		}
	}
	//aput3 = ' | virheLask: ' + virheLaskin;
	*/
	
	aput3 = ' | lapsia: ' + lapsiArrPituus + ' | Korjattu DOM-virheitä: ' + virheLaskin + ' | PoistoLista: ' + lask4;
	ftInfoTex3 = '<br>&nbsp&nbsp;In use ' + pitUusi + '|' + pit2 + ' mapImg-objects - ' + aput3 + ftDragtext; 
	calcInfo();
} //function calcMapCanvas
//
// --------  Uudet funktiot tammikuussa 2006 -----------------------------------------
//
function doEditMode (eFlag) {
	//	alert('ftSelectedCatList: ' + ftSelectedCatList);
	editFlag = eFlag;
	//alert('doEditMode alkaa..');
	if(editFlag == true) {

		keyBoardOff();
		doOpenCatRadioWindow ();
		var edElement =document.getElementById("menuEditMap");
		edElement.onclick = new Function("doEditMode(false);");
		if(ftLanguage == 'finnish'){
			edElement.innerHTML = '&nbsp;Selaa karttaa';
		}
		else {
			edElement.innerHTML = '&nbsp;Browse map';
		}
		ftMapWidth = ftWindowWidth - ftLeftDivWidth - ftEditDivWidth;
		ftMapHeight = ftWindowHeight - ftStatusDivHeight - ftUpperbannerHeight - 2;
		//alert('0b');
		mapSize(ftMapWidth, ftMapHeight);
		if (document.getElementById("Poi0") != null) {
			removePOIList(ftPoiList);
			createPOIList(ftPoiList);
			updatePOIList();
		}
		//alert('1');
		newEditDiv = document.createElement("div");
		newEditDiv.setAttribute("id", "editDiv");
		document.body.appendChild(newEditDiv);
		newEditDiv.style.left= ftMapWidth + ftLeftDivWidth;
		newEditDiv.style.top = ftStatusDivHeight + ftUpperbannerHeight;
		//alert('2');
		//
		// ------- Close-ruksi -------------------
		//
		newCloseRuksiDiv = document.createElement("div");
		newCloseRuksiDiv.setAttribute("id", "newCloseRuksiDiv");
		newCloseRuksiDiv.onclick = new Function("doEditMode(false);");
		newEditDiv.appendChild(newCloseRuksiDiv);
		// ------- Status Title -------------------
		//
		newStatusTitleDiv = document.createElement("div");
		newStatusTitleDiv.setAttribute("id", "newStatusTitleDiv");
		//newStatusTitleDiv.innerHTML="Status - Adding new Object";
		if(ftLanguage == 'finnish')
			newStatusTitleDiv.innerHTML = newStatusTitleDivCapFin;
		else
			newStatusTitleDiv.innerHTML = newStatusTitleDivCapEng;
		newEditDiv.appendChild(newStatusTitleDiv);
		//
		// ------- Display Id div -------------------
		//
		newDisplayIdDiv = document.createElement("div");
		newDisplayIdDiv.setAttribute("id", "newDisplayIdDiv");
		newEditDiv.appendChild(newDisplayIdDiv);
		newDisplayIdDiv.innerHTML="";
		//
		// ------- New Object Button ----------------
		//
		addNewObjectButton = document.createElement("input");
		addNewObjectButton.setAttribute("id", "addNewObjectButton");
		ft_classAttribute(addNewObjectButton, "addNewObjectButton");
		addNewObjectButton.setAttribute("type", "button");
		if(ftLanguage == 'finnish')
			addNewObjectButton.setAttribute("value", addNewObjectButtonCapFin);
		else
			addNewObjectButton.setAttribute("value", addNewObjectButtonCapEng);
		addNewObjectButton.onclick = new Function("addNewObject();");
		newEditDiv.appendChild(addNewObjectButton);
		//
		// ------- Copy Object Button ----------------
		//
		copyNewObjectButton = document.createElement("input");
		copyNewObjectButton.setAttribute("id", "copyNewObjectButton");
		ft_classAttribute(copyNewObjectButton, "copyNewObjectButton");
		copyNewObjectButton.setAttribute("type", "button");
		if(ftLanguage == 'finnish')
			copyNewObjectButton.setAttribute("value", 'Kopioi uudeksi linkki-objektiksi');
		else
			copyNewObjectButton.setAttribute("value", 'Copy to a new LinkObject');
		copyNewObjectButton.onclick = new Function("copyNewObject();");
		newEditDiv.appendChild(copyNewObjectButton);
		//
		// ------- Eng Title -------------------
		//
		newEngTitleDiv = document.createElement("div");
		newEngTitleDiv.setAttribute("id", "newEngTitleDiv");
		newEditDiv.appendChild(newEngTitleDiv);
		// label
		newEngTitleLabel = document.createElement("label");
		newEngTitleLabel.setAttribute = ("id", "newEngTitleLabel");
		newEngTitleLabel.setAttribute = ("for", "newEngTitleInput");
		if( ftLanguage == 'finnish')
			newEngTitleLabel.innerHTML = newEngTitleLabelFin;
		else
			newEngTitleLabel.innerHTML = newEngTitleLabelEng;
		newEngTitleDiv.appendChild(newEngTitleLabel);
		// Input
		newEngTitleInput = document.createElement("input");
//		newEngTitleInput = document.createElement("textarea");
		ft_classAttribute(newEngTitleInput, "newEngTitleInput");
		newEngTitleInput.setAttribute("id", "newEngTitleInput");
		newEngTitleInput.setAttribute("type", "text");
		newEngTitleDiv.appendChild(newEngTitleInput);
		//
		// ------- Fin Title -------------------
		//
		newFinTitleDiv = document.createElement("div");
		newFinTitleDiv.setAttribute("id", "newFinTitleDiv");
		newEditDiv.appendChild(newFinTitleDiv);
		// Label
		newFinTitleLabel = document.createElement("label");
		newFinTitleLabel.setAttribute = ("id", "newFinTitleLabel");
		newFinTitleLabel.setAttribute = ("for", "newFinTitleInput");
		if( ftLanguage == 'finnish')
			newFinTitleLabel.innerHTML = newFinTitleLabelFin;
		else
			newFinTitleLabel.innerHTML = newFinTitleLabelEng;
		newFinTitleDiv.appendChild(newFinTitleLabel);
		// Input
		newFinTitleInput = document.createElement("input");
		ft_classAttribute(newFinTitleInput, "newFinTitleInput");
		newFinTitleInput.setAttribute("id", "newFinTitleInput");
		newFinTitleDiv.appendChild(newFinTitleInput);
		//
		// ------- Eng Descr -------------------
		//
		newEngDescrDiv = document.createElement("div");
		newEngDescrDiv.setAttribute("id", "newEngDescrDiv");
		newEditDiv.appendChild(newEngDescrDiv);
		// Label
		newEngDescrLabel = document.createElement("label");
		newEngDescrLabel.setAttribute = ("id", "newEngDescrLabel");
		newEngDescrLabel.setAttribute = ("for", "newEngDescrInput");
		if( ftLanguage == 'finnish')
			newEngDescrLabel.innerHTML = newEngDescrLabelFin;
		else
			newEngDescrLabel.innerHTML = newEngDescrLabelEng;
		newEngDescrDiv.appendChild(newEngDescrLabel);
		//newEngDescrDiv.innerHTML="English<br>Description:&nbsp;";
		// Input
		newEngDescrInput = document.createElement("textarea");

		ft_classAttribute(newEngDescrInput, "newEngDescrInput");
		newEngDescrInput.setAttribute("id", "newEngDescrInput");
		newEngDescrDiv.appendChild(newEngDescrInput);
		//
		// ------- Fin Descr -------------------
		//
		newFinDescrDiv = document.createElement("div");
		newFinDescrDiv.setAttribute("id", "newFinDescrDiv");
		newEditDiv.appendChild(newFinDescrDiv);
		// Label
		newFinDescrLabel = document.createElement("label");
		newFinDescrLabel.setAttribute = ("id", "newFinDescrLabel");
		newFinDescrLabel.setAttribute = ("for", "newFinDescrInput");
		if( ftLanguage == 'finnish')
			newFinDescrLabel.innerHTML = newFinDescrLabelFin;
		else
			newFinDescrLabel.innerHTML = newFinDescrLabelEng;
		newFinDescrDiv.appendChild(newFinDescrLabel);
		// Input
		newFinDescrInput = document.createElement("textarea");
		ft_classAttribute(newFinDescrInput, "newFinDescrInput");
		newFinDescrInput.setAttribute("id", "newFinDescrInput");
		newFinDescrDiv.appendChild(newFinDescrInput);
		//
		// ------- Eng URL -------------------
		//
		newEngUrlDiv = document.createElement("div");
		newEngUrlDiv.setAttribute("id", "newEngUrlDiv");
		newEditDiv.appendChild(newEngUrlDiv);
		// Label
		newEngUrlLabel = document.createElement("label");
		newEngUrlLabel.setAttribute = ("id", "newEngUrlLabel");
		newEngUrlLabel.setAttribute = ("for", "newEngUrlInput");
		if( ftLanguage == 'finnish')
			newEngUrlLabel.innerHTML = newEngUrlLabelFin;
		else
			newEngUrlLabel.innerHTML = newEngUrlLabelEng;
		newEngUrlDiv.appendChild(newEngUrlLabel);
		// Input
		newEngUrlInput = document.createElement("input");
		ft_classAttribute(newEngUrlInput, "newEngUrlInput");
		newEngUrlInput.setAttribute("id", "newEngUrlInput");
		newEngUrlInput.setAttribute("value", 'http://');
		newEngUrlDiv.appendChild(newEngUrlInput);
		//
		newEngUrlButton = document.createElement("input");
		ft_classAttribute(newEngUrlButton, "newEngUrlButton");
		newEngUrlButton.setAttribute("type", "button");
		newEngUrlButton.onclick = new Function("checkEngUrl();");
		newEngUrlDiv.appendChild(newEngUrlButton);
		//
		// ------- Fin URL -------------------
		//
		newFinUrlDiv = document.createElement("div");
		newFinUrlDiv.setAttribute("id", "newFinUrlDiv");
		newEditDiv.appendChild(newFinUrlDiv);
		// Label
		newFinUrlLabel = document.createElement("label");
		newFinUrlLabel.setAttribute = ("id", "newFinUrlLabel");
		newFinUrlLabel.setAttribute = ("for", "newFinUrlInput");
		if( ftLanguage == 'finnish')
			newFinUrlLabel.innerHTML = newFinUrlLabelFin;
		else
			newFinUrlLabel.innerHTML = newFinUrlLabelEng;
		newFinUrlDiv.appendChild(newFinUrlLabel);
		newFinUrlInput = document.createElement("input");
		ft_classAttribute(newFinUrlInput, "newFinUrlInput");
		newFinUrlInput.setAttribute("id", "newFinUrlInput");
		newFinUrlInput.setAttribute("value", 'http://');
		newFinUrlDiv.appendChild(newFinUrlInput);
		//
		newFinUrlButton = document.createElement("input");
		ft_classAttribute(newFinUrlButton, "newFinUrlButton");
		newFinUrlButton.setAttribute("type", "button");
		newFinUrlButton.onclick = new Function("checkFinUrl();");
		newFinUrlDiv.appendChild(newFinUrlButton);
		// ------- X,Y-coordinates -------------------
		newCoordDiv = document.createElement("div");
		newCoordDiv.setAttribute("id", "newCoordDiv");
		newEditDiv.appendChild(newCoordDiv);
		// X
		newXDiv = document.createElement("div");
		newXDiv.setAttribute("id", "newXDiv");
		newCoordDiv.appendChild(newXDiv);
		//
		newXDiv.innerHTML="X:&nbsp;";
		newXInput = document.createElement("input");
		ft_classAttribute(newXInput, "newXInput");
		newXInput.setAttribute("id", "newXInput");
		newXDiv.appendChild(newXInput);
		// Y
		newYDiv = document.createElement("div");
		newYDiv.setAttribute("id", "newYDiv");
		newCoordDiv.appendChild(newYDiv);
		//
		newYDiv.innerHTML="Y:&nbsp;";
		newYInput = document.createElement("input");
		ft_classAttribute(newYInput, "newYInput");
		newYInput.setAttribute("id", "newYInput");
		newYDiv.appendChild(newYInput);
		//
		newXYButton = document.createElement("input");
		newXYButton.setAttribute("id", "newXYButton");
		ft_classAttribute(newXYButton, "newXYButton");
		newXYButton.setAttribute("type", "button");
		//newXYButton.setAttribute("value", "Catch XY-coordinate from Canvas center point");
		newXYButton.onclick = new Function("catchXYcoord();");
		newCoordDiv.appendChild(newXYButton);
		// ------- Save To DBase Button ----------------
		saveToDbaseButton = document.createElement("input");
		saveToDbaseButton.setAttribute("id", "saveToDbaseButton");
		ft_classAttribute(saveToDbaseButton, "saveToDbaseButton");
		saveToDbaseButton.setAttribute("type", "button");
		//saveToDbaseButton.setAttribute("value", "Add To DataBase");
		saveToDbaseButton.onclick = new Function("saveToDbase();");
		newEditDiv.appendChild(saveToDbaseButton);
		// ------- Remove From DBase Button ----------------
		removeFromDbaseButton = document.createElement("input");
		removeFromDbaseButton.setAttribute("id", "removeFromDbaseButton");
		ft_classAttribute(removeFromDbaseButton, "removeFromDbaseButton");
		removeFromDbaseButton.setAttribute("type", "button");
		removeFromDbaseButton.onclick = new Function("removeFromDbase();");
		newEditDiv.appendChild(removeFromDbaseButton);
		if (ftLanguage == 'finnish') {
			newEngUrlButton.setAttribute("value", newEngUrlButtonCapFin);
			newFinUrlButton.setAttribute("value", newFinUrlButtonCapFin);
			newXYButton.setAttribute("value", newXYButtonCapFin);
			saveToDbaseButton.setAttribute("value", saveToDbaseButtonCapFin);
			removeFromDbaseButton.setAttribute("value", removeFromDbaseButtonCapFin);
		}
		else {
			newEngUrlButton.setAttribute("value", newEngUrlButtonCapEng);
			newFinUrlButton.setAttribute("value", newFinUrlButtonCapEng);
			newXYButton.setAttribute("value", newXYButtonCapEng);
			saveToDbaseButton.setAttribute("value", saveToDbaseButtonCapEng);
			removeFromDbaseButton.setAttribute("value", removeFromDbaseButtonCapEng);
		}
	}
	else {
		keyBoardOn();
		//editFlag = false;
		//alert('a');
		var edElement =document.getElementById("menuEditMap");
		edElement.onclick = new Function("doEditMode(true);");
		if(ftLanguage == 'finnish')
			edElement.innerHTML = '&nbsp;Editoi linkkej&auml;';
		else
			edElement.innerHTML = '&nbsp;Edit links';
		//alert('c');
		document.body.removeChild(document.getElementById("editDiv"));
		document.body.removeChild(document.getElementById("catRadioDiv"));
		ftMapWidth = ftWindowWidth - ftLeftDivWidth;
		ftMapHeight = ftWindowHeight - ftStatusDivHeight - ftUpperbannerHeight - 2;
		mapSize(ftMapWidth, ftMapHeight);
		if (document.getElementById("Poi0") != null) {
			removePOIList(ftPoiList);
			createPOIList(ftPoiList);
			updatePOIList();
		}
	}
	//alert(editFlag);
} //function doEditMode
//
//

function toggleCatRadioElement (catNum) {
	var catPari = ftCatList[catNum];
	var catName = catPari[0];
	//alert('toggleCatRadioElement: ' + catName);
	document.getElementById(catName).checked = true;
	ftSelectedRadioCat = catName;
	removePOIList(ftPoiList);
	ftPoiList = null;
	showPoiCat (catName);
	ftSelectedCatList = null;
	ftSelectedCatList = new Array();
	ftSelectedCatList[0] = catName;
}


function doOpenCatRadioWindow () {
	// suljetaan Cat-ikkuna
	if (catWindowFlag == true) {
		doCloseCatDiv();
	}
	if( ftSelectedCatList != null) {
		ftSelectedRadioCat = ftSelectedCatList[0];
	}
	// poistetaan valitut categoriat
	removePOIList(ftPoiList);
	ftPoiList = null;
	showPoiCat (ftSelectedRadioCat);
	ftSelectedCatList = null;
	ftSelectedCatList = new Array();
	ftSelectedCatList[0] = ftSelectedRadioCat;
	//
	var newCatRadioDiv = document.createElement("div");
	newCatRadioDiv.setAttribute("id", "catRadioDiv");
	document.body.appendChild(newCatRadioDiv);
	newCatRadioDiv.style.left= 0;  //ftLeftDivWidth + 2;
	newCatRadioDiv.style.top = ftStatusDivHeight + ftUpperbannerHeight; // + 65; // vika 30
	newCatRadioDiv.style.width = ftLeftDivWidth; // 200;
	newCatRadioDiv.style.height = 160;
	//alert('2');
	//
	// ------- Status Title -------------------
	//
	var newCatTitleDiv = document.createElement("div");
	newCatTitleDiv.setAttribute("id", "newCatTitleDiv");
	newCatTitleDiv.style.width = ftLeftDivWidth - 30; // 200;
	if(ftLanguage == 'finnish')
		newCatTitleDiv.innerHTML = 'Valitse<br>linkkikategoria';
	else
		newCatTitleDiv.innerHTML = 'Select Link Category';
	newCatRadioDiv.appendChild(newCatTitleDiv);
	//
	// ------- POI-categoria-luettelo -------------------
	//
	// simuloidaan hash-tablea ("catnimi" false/true)
	//ftCatList // muotoa ('hotelli' . false)(elokuva . true)
	//alert(ftCatList);
	var catLkm = ftCatList.length;
	var topY = 40;  // 40
	for (i=0; i<catLkm; i++) {
		var catPari = ftCatList[i];
		//alert(catPari);
		var catName  = catPari[0];
		var catValue = catPari[1];
		if(selain == 'ie') {
			if( catName == ftSelectedRadioCat ) {
				var optionToggleElement = document.createElement('<input type="radio" name="catRadioSelect" checked>')
			}
			else {
				var optionToggleElement = document.createElement('<input type="radio" name="catRadioSelect">')
			}
		}
		else {
			var optionToggleElement = document.createElement("input");
			optionToggleElement.setAttribute("type", "radio");
			optionToggleElement.setAttribute("name", "catRadioSelect");
			if( catName == ftSelectedRadioCat ) {
				//alert('checked catName: ' + catName);
				optionToggleElement.checked = true;
			}
		}
		//optionToggleElement.name = 'catRadioSelect';
		optionToggleElement.setAttribute("id", catName);
		optionToggleElement.style.position = 'absolute';
		optionToggleElement.style.top  = topY;
		optionToggleElement.style.left  = 90;
		optionToggleElement.setAttribute("value", catName);
		optionToggleElement.onclick = new Function("toggleCatRadioElement(" + i + ");");
		newCatRadioDiv.appendChild(optionToggleElement);
		// --- label ---
		var toggleElementLabel = document.createElement("label");
		toggleElementLabel.setAttribute("id", 'Label-' + catName);
		toggleElementLabel.setAttribute("for", "optionToggleElement");
		if(ftLanguage == 'finnish') {
			toggleElementLabel.innerHTML = catName;
		}
		else {
			var jas = arrayMones (ftCatNameList, catName);
			var catNameEng = ftCatNameList_eng[jas - 1];
			toggleElementLabel.innerHTML = catNameEng;
		}
		toggleElementLabel.style.position = 'absolute';
		toggleElementLabel.style.top  = topY;
		toggleElementLabel.style.left  = 20;
		toggleElementLabel.style.fontSize  = "12px"; // Toimii nyt
		newCatRadioDiv.appendChild(toggleElementLabel);
		//
		/*
		// --- poi lukumäärä-teksti
		var optionToggleLkm = document.createElement("div");
		optionToggleLkm.setAttribute("id", catName + 'Lkm');
		optionToggleLkm.style.position = 'absolute';
		optionToggleLkm.style.top  = topY;
		optionToggleLkm.style.left  = 120;
		optionToggleLkm.style.fontSize  = "12px";
		optionToggleLkm.innerHTML = '0';
		newCatRadioDiv.appendChild(optionToggleLkm);
		*/
		//
		// --- 
		var carIconDiv = document.createElement("div");
		carIconDiv.setAttribute("id", catName + 'Icon');
		carIconDiv.style.position = 'absolute';
		carIconDiv.style.top  = topY + 3;
		carIconDiv.style.left  = 5;
		carIconDiv.style.width  = 10;
		carIconDiv.style.height  = 10;

		var iconName = getPoiIcon (catName);
		var iconUrl = 'url(images/' + iconName + '_10.gif)';
		carIconDiv.style.backgroundImage  = iconUrl;
		newCatRadioDiv.appendChild(carIconDiv);
		//
		// ---
		topY = topY + 15;

	}

} //function doOpenCatRadioWindow


function drawCP () {
	//alert('cp0');
	newCP = document.getElementById("CP");
	var cX = ftMapWidth  / 2 - 3;
	var cY = ftMapHeight / 2 - 3;
	//alert('cp1');
	newCP.style.left = cX;
	//alert('cp2');
	newCP.style.top  = cY;
	//alert('cp3');
}

function clipMapDiv(element) {
	// clipataan emo-diviä eli mapDiv-objektia
	clipTop  = 0;
	clipLeft = 0;
	clipRight = clipLeft + ftMapWidth;
	clipBottom = clipTop + ftMapHeight;
	recbox = 'rect(' + clipTop + 'px ' + clipRight + 'px ' + clipBottom + 'px ' + clipLeft +'px)'
	//ftMapDivElement.style.clip  = recbox;
	element.style.clip  = recbox;
}

//-------------------------------
//
function addNewObject () {
	poiEditMode = 'new'; 'edit'/'new'
	if (ftLanguage == 'finnish') {
		document.getElementById('newStatusTitleDiv').innerHTML = newStatusTitleDivCapFin;
		document.getElementById('saveToDbaseButton').value = saveToDbaseButtonCapFin;
	}
	else {
		document.getElementById('newStatusTitleDiv').innerHTML = newStatusTitleDivCapEng;
		document.getElementById('saveToDbaseButton').value = saveToDbaseButtonCapEng;
	}
	document.getElementById('newDisplayIdDiv').innerHTML = '';
	document.getElementById('newEngTitleInput').value = '';
	document.getElementById('newFinTitleInput').value = '';
	document.getElementById('newEngDescrInput').value = '';
	document.getElementById('newFinDescrInput').value = '';
	document.getElementById('newEngUrlInput').value = 'http://';
	document.getElementById('newFinUrlInput').value = 'http://';
	document.getElementById('newXInput').value = '';
	document.getElementById('newYInput').value = '';
} //function addNewObject
//
//
//-------------------------------
//
function copyNewObject () {
	poiEditMode = 'new'; 'edit'/'new'
	if (ftLanguage == 'finnish') {
		document.getElementById('newStatusTitleDiv').innerHTML = newStatusTitleDivCapFin;
		document.getElementById('saveToDbaseButton').value = saveToDbaseButtonCapFin;
	}
	else {
		document.getElementById('newStatusTitleDiv').innerHTML = newStatusTitleDivCapEng;
		document.getElementById('saveToDbaseButton').value = saveToDbaseButtonCapEng;
	}

/*
	document.getElementById('newDisplayIdDiv').innerHTML = '';
	document.getElementById('newEngTitleInput').value = '';
	document.getElementById('newFinTitleInput').value = '';
	document.getElementById('newEngDescrInput').value = '';
	document.getElementById('newFinDescrInput').value = '';
	document.getElementById('newEngUrlInput').value = 'http://';
	document.getElementById('newFinUrlInput').value = 'http://';
	document.getElementById('newXInput').value = '';
	document.getElementById('newYInput').value = '';
*/
} //function copyNewObject
//
//
function catchXYcoord () {
	document.getElementById('newXInput').value = ftMapX;
	document.getElementById('newYInput').value = ftMapY;
	//ftPoiTempX = ftMapX;
	//ftPoiTempY = ftMapY;
	
	// poistetaan mahdollinen ftPoiTemp-objekti
	if(ftPoiTemp != null) {
		ftMapDivElement.removeChild(document.getElementById('ftPoiTemp'));
		ftPoiTemp = null;
	}
	// luodaan uusi
	var tempX = parseInt(ftMapX / ftPoiDbScale) + ftPoiXMove;
	var tempY = Math.round( parseInt(ftMapY / ftPoiDbScale)  * 1.41421356) + ftPoiYMove;
	// ok tämä on sama muoto kuin tietokannassa
	//alert ('tempX: ' + tempX  + ' tempY: ' + tempY   );
	// muunnetaan takaisin createPoi-muotoon
	ftPoiTempX = tempX - ftPoiXMove;
	ftPoiTempY = Math.round((tempY - ftPoiYMove) * 0.707106);
	//
	var mapHalfW = parseInt(ftMapWidth / 2);
	var mapHalfH = parseInt(ftMapHeight / 2);
	//alert('create poi alkaa');
	poiWidth = 25;
	iconName = 'poiTemp_25.gif';
	ftPoiTemp = document.createElement("div");
	ftPoiTemp.setAttribute("id", "ftPoiTemp");
	ftPoiTemp.style.position = 'absolute';
	var xLeft = parseInt(ftPoiDbScale * (ftPoiTempX/(ftMapScale/1000)) + mapHalfW - ftMapX /(ftMapScale/1000));
	ftPoiTemp.style.left = xLeft - poiWidth/2; //
	var yTop = parseInt(ftPoiDbScale * (ftPoiTempY/(ftMapScale/1000)) + mapHalfH - ftMapY /(ftMapScale/1000));
	ftPoiTemp.style.top  = yTop - poiWidth/2;
	ftMapDivElement.appendChild(ftPoiTemp);
} //function catchXYcoord
//
//
//
function saveToDbase () {
	// poistetaan mahdollinen ftPoiTemp-objekti
	if(ftPoiTemp != null) {
		ftMapDivElement.removeChild(document.getElementById('ftPoiTemp'));
		ftPoiTemp = null;
	}
	//
	//alert('0');
	var category = ftSelectedRadioCat;
	var poiTitle = document.getElementById('newEngTitleInput').value;
	var poiTitleFin = document.getElementById('newFinTitleInput').value;
	var poiInfo = document.getElementById('newEngDescrInput').value;
	//alert('1');
	var poiInfoFin = document.getElementById('newFinDescrInput').value;
	var poiHref = document.getElementById('newEngUrlInput').value;
	var poiHrefFin = document.getElementById('newFinUrlInput').value;
	var xCoord = document.getElementById('newXInput').value;
	var yCoord = document.getElementById('newYInput').value;
	var xNew = parseInt(xCoord / ftPoiDbScale) + ftPoiXMove;
	var yNew = Math.round( parseInt(yCoord / ftPoiDbScale)  * 1.41421356) + ftPoiYMove;  //0.7071067811865475244008443621052
	if ( poiEditMode == 'new') { //'edit'/'new'
		//alert('New to Dbase');
		//alert('function saveToDbase :' + ftPoiList);
		addDbPoi(category, poiTitle, poiTitleFin, poiInfo, poiInfoFin, poiHref, poiHrefFin, xNew, yNew);



	}
	else {  // 'update'
		// poiDbId on globaali
		var id2 = document.getElementById('newDisplayIdDiv').innerHTML;
		//alert('Updating Object to Dbase. ID":' + id2);
//		updateDbPoi(id2, poiDbId, category, poiTitle, poiTitleFin, poiInfo, poiInfoFin, poiHref, poiHrefFin, xNew, yNew);
		updateDbPoi(poiDbId, category, poiTitle, poiTitleFin, poiInfo, poiInfoFin, poiHref, poiHrefFin, xNew, yNew);
	}





} //function saveToDbase
//
//
function removeFromDbase () {
	//var id2 = document.getElementById('newDisplayIdDiv').innerHTML;
	// poiDbId on globaali
		remDbPoi(poiDbId);

		removePOIList(ftPoiList);
		ftPoiList = null;
		showPoiCat (ftSelectedRadioCat);

} //function removeFromDbase
//
//
//
function checkEngUrl() {
	var poiHref = document.getElementById('newEngUrlInput').value;
	window.open(poiHref);
} //function checkFinUrl
//
//
function checkFinUrl() {
	var poiHrefFin = document.getElementById('newFinUrlInput').value;
	window.open(poiHrefFin);
} //function checkFinUrl
//


function doLanguage () {
	//alert('doLanguage alkaa..');
	if (document.getElementById("languageRadioFin").checked == true ) {
		ftLanguage = 'finnish'; //finnish/english/(swedish)
		//alert('doLanguage, ftSelectedCatList: ' + ftSelectedCatList);
		// poistetaan vanhat poiDivit, jos niitä on
		removePOIList();
		ftPoiList = null;
		if(ftSelectedCatList != 'none' && ftSelectedCatList != null) {
			for(var i = 0; i < ftSelectedCatList.length; i++) {
				var cat = ftSelectedCatList[i];
				showPoiCat(cat);
			}
		}
		document.getElementById("upperbanner").style.backgroundImage = "url(images/logobanner.jpg)";
		if(editFlag == false)
			document.getElementById('menuEditMap').innerHTML = '&nbsp;Editoi linkkej&auml;';
		else
			document.getElementById('menuEditMap').innerHTML = '&nbsp;Selaa karttaa';
		//
		document.getElementById('menuForum').innerHTML = 'Keskustelu';
		document.getElementById('menuHelpHeader').innerHTML = 'Ohje';
		document.getElementById('menuNetLinks').innerHTML = 'NettiLinkit';

		// käydään läpi lista, joka on cityguide3d.conf.js-tiedostossa
		for(var i = 0; i < ftLangListFin.length; i++) {
    		var pari = ftLangListFin[i];
    		var elNimi = pari[0];
    		var elArvo = pari [1]
			document.getElementById(elNimi).innerHTML = elArvo;
    	}

		var helpElement = document.getElementById('menuHelp');
		helpElement.innerHTML = 'Ohjeita';
		document.getElementById('menuAbout').innerHTML = 'Tietoja sovelluksesta';
		document.getElementById('menuContact').innerHTML = 'Yhteystietoja';
		document.getElementById('menuProject').innerHTML = 'Tietoja projektista';
		//
		document.getElementById('menuTools').innerHTML = 'Ty&ouml;kalut';
		document.getElementById('menuSendF').innerHTML = 'L&auml;het&auml; kohde S&auml;hk&ouml;postina';
		
		// ------- etsintä ----------
		document.getElementById("searchButton").innerHTML = 'Etsi';

		// --------- cat Window -----------------
		if (catWindowFlag == true) {
			document.getElementById('newCatTitleDiv').innerHTML = 'Valitse<br>linkkikategoriat';
			document.getElementById("OpenCatWindow").innerHTML = '&nbsp;Sulje Linkkimenu';
			// muutetaan cat_Labelit
			var catLkm = ftCatList.length;
			for (i=0; i<catLkm; i++) {
				var catPari = ftCatList[i];
				var catName  = catPari[0];
				document.getElementById('Label-' + catName).innerHTML = catName;
			}
		}
		else {
			document.getElementById("OpenCatWindow").innerHTML = '&nbsp;Avaa Linkkimenu';
		}
		//
		// --------- editointi kaavake -----------------
		if (editFlag == true) {
			if(poiEditMode == 'new') {
				document.getElementById('newStatusTitleDiv').innerHTML = newStatusTitleDivCapFin;
			}
			else {
				document.getElementById('newStatusTitleDiv').innerHTML = 'Editoidaan Objektia Id: ' + poiDbId;
			}
			document.getElementById('addNewObjectButton').value = addNewObjectButtonCapFin;

			newEngTitleLabel.innerHTML = newEngTitleLabelFin;
			newFinTitleLabel.innerHTML = newFinTitleLabelFin;
			// miksi seuraava ei toimi, onneksi newEngTitleLabel on globaali
			//document.getElementById('newEngTitleLabel').innerHTML = newEngTitleLabelFin;
			//document.getElementById('newFinTitleLabel').innerHTML = newFinTitleLabelFin;

			newEngDescrLabel.innerHTML = newEngDescrLabelFin;
			newFinDescrLabel.innerHTML = newFinDescrLabelFin;
			newEngUrlLabel.innerHTML = newEngUrlLabelFin;
			newFinUrlLabel.innerHTML = newFinUrlLabelFin;
			//document.getElementById('newEngDescrDiv').innerHTML = newEngDescrDivCapFin;
			//document.getElementById('newFinDescrDiv').innerHTML = newFinDescrDivCapFin;
			//document.getElementById('newEngUrlDiv').innerHTML = newEngUrlDivCapFin;
			//document.getElementById('newFinUrlDiv').innerHTML = newFinUrlDivCapFin;

			newEngUrlButton.value = newEngUrlButtonCapFin;
			newFinUrlButton.value = newFinUrlButtonCapFin;
			newXYButton.setAttribute("value", newXYButtonCapFin);


			copyNewObjectButton.setAttribute("value", 'Kopioi uudeksi linkki-objektiksi');


			if(poiEditMode == 'new') {
				saveToDbaseButton.setAttribute("value", saveToDbaseButtonCapFin);
			}
			else {
				saveToDbaseButton.setAttribute("value", 'Päivitä tietokantaan');
			}


			removeFromDbaseButton.setAttribute("value", removeFromDbaseButtonCapFin);
			//document.getElementById('newEngUrlButton').value = newEngUrlButtonCapFin;
			//document.getElementById('newFinUrlButton').value = newFinUrlButtonCapFin;
			//document.getElementById('newXYButtonCap').value = newXYButtonCapFin;
			//document.getElementById('saveToDbaseButton').value = saveToDbaseButtonCapFin;
			//document.getElementById('removeFromDbaseButton').value = removeFromDbaseButtonCapFin;
			
			// --------- radioCat-ikkuna --------------
			document.getElementById('newCatTitleDiv').innerHTML = 'Valitse<br>linkkikategoria';
			// muutetaan cat_Labelit
			var catLkm = ftCatList.length;
			for (i=0; i<catLkm; i++) {
				var catPari = ftCatList[i];
				var catName  = catPari[0];
				document.getElementById('Label-' + catName).innerHTML = catName;
			}
			
		}
	} // finnish
	else {
		ftLanguage = 'english'; //finnish/english/(swedish)
		// poistetaan vanhat poiDivit, jos niitä on
		removePOIList();
		ftPoiList = null;
		//alert('ftSelectedCatList: '  + ftSelectedCatList);
		if(ftSelectedCatList != 'none'  && ftSelectedCatList != null) {
			for(var i = 0; i < ftSelectedCatList.length; i++) {
				var cat = ftSelectedCatList[i];
				showPoiCat(cat);
			}
		}
		//
		document.getElementById("upperbanner").style.backgroundImage = "url(images/logobanner.jpg)";
		if(editFlag == false)
			document.getElementById('menuEditMap').innerHTML = '&nbsp;Edit Links';
		else
			document.getElementById('menuEditMap').innerHTML = '&nbsp;Browse map';
		document.getElementById('menuForum').innerHTML = 'BB Forum';
		document.getElementById('menuHelpHeader').innerHTML = 'Help';
		document.getElementById('menuNetLinks').innerHTML = 'Net Links';
		//
		// käydään läpi id-text lista, joka on cityguide3d.conf.js-tiedostossa
		for(var i = 0; i < ftLangListEng.length; i++) {
    		var elPari = ftLangListEng[i];
    		var elNimi = elPari[0];
    		var elArvo = elPari[1];
    		//alert(elArvo);
			document.getElementById(elNimi).innerHTML = elArvo;
    	}
		var helpElement = document.getElementById('menuHelp');
		helpElement.innerHTML = 'Help';
		//helpElement.onClick = "openFtWindow(\'help_eng.html\')";

		document.getElementById('menuAbout').innerHTML = 'About application';
		document.getElementById('menuContact').innerHTML = 'Contact Information';
		document.getElementById('menuProject').innerHTML = 'About project';
		//
		document.getElementById('menuTools').innerHTML = 'Tools';
		document.getElementById('menuSendF').innerHTML = 'Send location in Email';
		//
		// ------- etsintä ----------
		document.getElementById("searchButton").innerHTML = 'Search';

		// --------- cat Window -----------------
		if (catWindowFlag == true) {
			document.getElementById('newCatTitleDiv').innerHTML = 'Select Link Categories';;
			document.getElementById("OpenCatWindow").innerHTML = '&nbsp;Close map Link menu';

			// muutetaan cat_Labelit
			var catLkm = ftCatList.length;
			for (i=0; i<catLkm; i++) {
				var catPari = ftCatList[i];
				var catName  = catPari[0];
				var jas = arrayMones (ftCatNameList, catName);
				var catNameEng = ftCatNameList_eng[jas - 1];
				document.getElementById('Label-' + catName).innerHTML = catNameEng;
			}

		}
		else {
			document.getElementById("OpenCatWindow").innerHTML = '&nbsp;Open map Link menu';
		}


		// --------- editointi kaavake -----------------
		if (editFlag == true) {

			if(poiEditMode == 'new') {
				document.getElementById('newStatusTitleDiv').innerHTML = newStatusTitleDivCapEng;
			}
			else {
				document.getElementById('newStatusTitleDiv').innerHTML = 'Editing Object Id: ' + poiDbId;
			}


			document.getElementById('addNewObjectButton').value = addNewObjectButtonCapEng;
			copyNewObjectButton.setAttribute("value", 'Copy to a new LinkObject');


			newEngTitleLabel.innerHTML = newEngTitleLabelEng;
			newFinTitleLabel.innerHTML = newFinTitleLabelEng;
			newEngDescrLabel.innerHTML = newEngDescrLabelEng;
			newFinDescrLabel.innerHTML = newFinDescrLabelEng;
			//document.getElementById('newEngTitleLabel').innerHTML = newEngTitleLabelEng;
			//document.getElementById('newFinTitleLabel').innerHTML = newFinTitleLabwlEng;
			//document.getElementById('newEngDescrDiv').innerHTML = newEngDescrDivCapEng;
			//document.getElementById('newFinDescrDiv').innerHTML = newFinDescrDivCapEng;

			newEngUrlLabel.innerHTML = newEngUrlLabelEng;
			newFinUrlLabel.innerHTML = newFinUrlLabelEng;
			newEngUrlButton.value = newEngUrlButtonCapEng;
			newFinUrlButton.value = newFinUrlButtonCapEng;
			//document.getElementById('newEngUrlDiv').innerHTML = newEngUrlDivCapEng;
			//document.getElementById('newFinUrlDiv').innerHTML = newFinUrlDivCapEng;
			//document.getElementById('newEngUrlButton').value = newEngUrlButtonCapEng;
			//document.getElementById('newFinUrlButton').value = newFinUrlButtonCapEng;

			newXYButton.setAttribute("value", newXYButtonCapEng);
			if(poiEditMode == 'new') {
				saveToDbaseButton.setAttribute("value", saveToDbaseButtonCapEng);
			}
			else {
				saveToDbaseButton.setAttribute("value", 'Update to Dbase');
			}
			removeFromDbaseButton.setAttribute("value", removeFromDbaseButtonCapEng);
			//document.getElementById('newXYButtonCap').value = newXYButtonCapEng;
			//document.getElementById('saveToDbaseButton').value = saveToDbaseButtonCapEng;
			//document.getElementById('removeFromDbaseButton').value = removeFromDbaseButtonCapEng;
			
			// ------------ radioCatWindow --------
			document.getElementById('newCatTitleDiv').innerHTML = 'Select Link Category';
			// muutetaan cat_Labelit
			var catLkm = ftCatList.length;
			for (i=0; i<catLkm; i++) {
				var catPari = ftCatList[i];
				var catName  = catPari[0];
				var jas = arrayMones (ftCatNameList, catName);
				var catNameEng = ftCatNameList_eng[jas - 1];
				document.getElementById('Label-' + catName).innerHTML = catNameEng;
			}
			
		}
	} //english

} // function doLanguage



function getPoiIcon (catName) {
	var iconName = null;
	if ( catName == 'rakennus') {
		iconName = 'poiViolet';
	}
	else if ( catName == 'yritys') {
		iconName = 'poiBrown';
	}
	else if ( catName == 'yksityinen') {
		iconName = 'poiGrey';
	}
	else if ( catName == 'museo' || catName == 'teatteri' || catName == 'konsertti' || catName == 'elokuva' ) {
		iconName = 'poiLightBlue';
	}
	else if ( catName == 'kirkko') {
		iconName = 'poiBlack';
	}
	else if ( catName == 'kauppa') {
		iconName = 'poiGreen';
	}
	else if ( catName == 'ravintola') {
		iconName = 'poiRed';
	}
	else if ( catName == 'kahvila') {
		iconName = 'poiRed';
	}
	else if ( catName == 'hotelli') {
		iconName = 'poiBlue';
	}
	else if ( catName == 'virasto') {
		iconName = 'poiYellow';
	}
	else if ( catName == 'pankki') {
		iconName = 'poiDarkGreen';
	}
	else if ( catName == 'liikenne') {
		iconName = 'poiOrange';
	}
	else {
		iconName = 'poiPink';
	}
	return iconName;
} //function getPoiIcon 


function doSearch () {
	var searchString = document.getElementById('searchText').value;

	//alert('Suoritetaan etsintä sanalla: ' + searchString);
	seachStringInDb(searchString, ftLanguage);
}


//
function openSearchResultDiv (ftSearchResultPoiList) {
		var srWinWidth = 600;
		newSearchResultDiv = document.createElement("div");
		newSearchResultDiv.setAttribute("id", "searchResultDiv");
		document.body.appendChild(newSearchResultDiv);
		newSearchResultDiv.style.left= ftLeftDivWidth + 5;
		newSearchResultDiv.style.top = 100  //ftStatusDivHeight + ftUpperbannerHeight + 5; // vika 30
		newSearchResultDiv.style.width = srWinWidth; // 200;
		newSearchResultDiv.style.height = 460;
		//
		// ------- Close-ruksi -------------------
		//
		newSearchCloseRuksiDiv = document.createElement("div");
		newSearchCloseRuksiDiv.setAttribute("id", "newSearchCloseRuksiDiv");
		newSearchCloseRuksiDiv.style.left= srWinWidth - 20;
		newSearchCloseRuksiDiv.onclick = new Function("doCloseSearchResultDiv();");
		newSearchResultDiv.appendChild(newSearchCloseRuksiDiv);
		//
		// ------- Otsikot jne -------------------
		//
		newSearchTitleDiv = document.createElement("div");
		newSearchTitleDiv.setAttribute("id", "newSearchTitleDiv");
		newSearchTitleDiv.style.width = srWinWidth - 60; // 200;
		if(ftLanguage == 'finnish')
			newSearchTitleDiv.innerHTML = '<h2>Etsint&auml;tulokset</h2>';
		else
			newSearchTitleDiv.innerHTML = '<h2>Search Results</h2>';
		newSearchResultDiv.appendChild(newSearchTitleDiv);
		//
		// ------- Div-taulukkoa varten -------------------
		//
		newSearchTableDiv = document.createElement("div");
		newSearchTableDiv.setAttribute("id", "searchTableDiv");
		newSearchTableDiv.style.width = srWinWidth - 16;
		newSearchResultDiv.appendChild(newSearchTableDiv);
		// ------- Taulukko -------------------
		newSearchTable = document.createElement("table");
		newSearchTable.setAttribute("id", "newSearchTable");
		//newSearchTable.style.left = 15; // 200;
		newSearchTable.style.width = srWinWidth - 32; // 200;
		newSearchTableDiv.appendChild(newSearchTable);
		// ------- tablebody -------------------
		searchTableBody = document.createElement("tbody");
		searchTableBody.setAttribute("id", "searchTableBody");
		//newSearchTable.style.width = srWinWidth - 32; // 200;
		newSearchTable.appendChild(searchTableBody);
		// ------- vaakarivit -------------------
		// MUOTO: poiId, poiDbId, poiCat, xNew, yNew, poiHref, poiTitle, poiInfo
		var poiLkm = ftSearchResultPoiList.length;
		for (i=0; i<poiLkm; i++) {
			//
			var newRow = document.createElement("tr");
			newRow.setAttribute("id", "newRow" + i);
			searchTableBody.appendChild(newRow);
			//
			var subLista = ftSearchResultPoiList[i];
			var poiId = subLista[0];
			var poiDbId = subLista[1];
			var poiCat = subLista[2];
			var xNew = subLista[3];
			var yNew = subLista[4];
			var poiHref = subLista[5];
			var poiTitle = subLista[6];
			var poiInfo = subLista[7];
			var newTD1 = document.createElement("td");
			//newTD1.setAttribute("id", "idNro");
			ft_classAttribute(newTD1, "idNro");
			newTD1.innerHTML = poiDbId;
			newRow.appendChild(newTD1);
			// --
			var newTD2 = document.createElement("td");
			//newTD2.setAttribute("id", "title");
			ft_classAttribute(newTD2, "title");
			newTD2.innerHTML = poiTitle;
			newRow.appendChild(newTD2);
			// -------
			var newTD3 = document.createElement("td");
			//newTD3.setAttribute("id", "newTD3");
			ft_classAttribute(newTD3, "poiInfo");
			newTD3.innerHTML = poiInfo;
			newRow.appendChild(newTD3);
			// -------
			var newTD4 = document.createElement("td");
			//newTD4.setAttribute("id", "newTD3");
			ft_classAttribute(newTD4, "showPoi");
			if(ftLanguage == 'finnish')
				newTD4.innerHTML = 'N&auml;yt&auml; kartalla';
			else
				newTD4.innerHTML = 'Show on map';
			//alert('poiCat ' + poiCat);
			//	poiLink.onmouseover = new Function("return overlib('" + olText + "',CAPTION, '" + olCa + "');");
			newTD4.onclick = new Function("doShowOnMap('" + poiDbId + "','" + poiCat + "','" + xNew + "','" + yNew + "');");
			newRow.appendChild(newTD4);
		}
} //function openSearchResultDiv

function doCloseSearchResultDiv () {
	//
	document.body.removeChild(document.getElementById("searchResultDiv"));
}

function doShowOnMap (dbId, poiCat, xNew, yNew) {
	document.body.removeChild(document.getElementById("searchResultDiv"));
	ftMapX = ftPoiDbScale * xNew;
	ftMapY = ftPoiDbScale * yNew;
	calcMapCanvas();
	updatePOIList();
	drawCP();
	if (ftMapScale != 500) {
		doZoom (500);
	}
	if(ftSelectedCatList == 'none' || ftSelectedCatList == null ) {
		showPoiCat (poiCat);
		ftSelectedCatList = new Array();
		ftSelectedCatList[0] = poiCat;
		if(selLinksFlag == true) {
			document.getElementById(poiCat).checked = true;
		}
	}
	else if(arrayMember(ftSelectedCatList, poiCat) != true ) {
		showPoiCat (poiCat);
		var pit = ftSelectedCatList.length;
		ftSelectedCatList[pit] = poiCat;
		if(selLinksFlag == true) {
			document.getElementById(poiCat).checked = true;
		}
	}
}


function doOpenCatWindow (eFlag) {
	selLinksFlag = eFlag;
	//alert('ftSelectedCatList: ' + ftSelectedCatList);
	if(selLinksFlag == true) {
		//alert('doOpenCatWindow alkaa');
		catWindowFlag = true;
		newCatDiv = document.createElement("div");
		newCatDiv.setAttribute("id", "catDiv");
		document.body.appendChild(newCatDiv);
		newCatDiv.style.left= 0;  //ftLeftDivWidth + 2;
		newCatDiv.style.top = ftStatusDivHeight + ftUpperbannerHeight + 65; // vika 30
		newCatDiv.style.width = ftLeftDivWidth; // 200;
		newCatDiv.style.height = 160;
		//alert('2');
		//
		// ------- Status Title -------------------
		//
		newCatTitleDiv = document.createElement("div");
		newCatTitleDiv.setAttribute("id", "newCatTitleDiv");
		newCatTitleDiv.style.width = ftLeftDivWidth - 30; // 200;
		if(ftLanguage == 'finnish')
			newCatTitleDiv.innerHTML = 'Valitse<br>linkkikategoriat';
		else
			newCatTitleDiv.innerHTML = 'Select Link Categories';
		newCatDiv.appendChild(newCatTitleDiv);
		//
		// ------- POI-categoria-luettelo -------------------
		//
		// simuloidaan hash-tablea ("catnimi" false/true)
		//ftCatList // muotoa ('hotelli' . false)(elokuva . true)
		//alert(ftCatList);
		var catLkm = ftCatList.length;
		var topY = 40;  // 40
		for (i=0; i<catLkm; i++) {
			var catPari = ftCatList[i];
			//alert(catPari);
			var catName  = catPari[0];
			var catValue = catPari[1];
			var optionToggleElement = document.createElement("input");
			optionToggleElement.setAttribute("id", catName);
			optionToggleElement.setAttribute("type", "checkbox");
			optionToggleElement.setAttribute("name", catName);
			optionToggleElement.style.position = 'absolute';
			optionToggleElement.style.top  = topY;
			optionToggleElement.style.left  = 90;
			if(ftLanguage == 'finnish')
				optionToggleElement.setAttribute("value", catName);
			else
				optionToggleElement.setAttribute("value", catName);
			//var tx = 'Cat_' + catName;
			//optionToggleElement.onclick = new Function("toggleCatElement(" + tx + ");");
			optionToggleElement.onclick = new Function("toggleCatElement(" + i + ");");
			newCatDiv.appendChild(optionToggleElement);
			// --- label ---
			var toggleElementLabel = document.createElement("label");
			toggleElementLabel.setAttribute("id", 'Label-' + catName);
			toggleElementLabel.setAttribute("for", "optionToggleElement");
			if(ftLanguage == 'finnish') {
				toggleElementLabel.innerHTML = catName;
			}
			else {
				var jas = arrayMones (ftCatNameList, catName);
				var catNameEng = ftCatNameList_eng[jas - 1];
				toggleElementLabel.innerHTML = catNameEng;
			}
			toggleElementLabel.style.position = 'absolute';
			toggleElementLabel.style.top  = topY;
			toggleElementLabel.style.left  = 20;
			toggleElementLabel.style.fontSize  = "12px"; // Toimii nyt
			newCatDiv.appendChild(toggleElementLabel);
			//
			// --- poi lukumäärä-teksti
			var optionToggleLkm = document.createElement("div");
			optionToggleLkm.setAttribute("id", catName + 'Lkm');
			optionToggleLkm.style.position = 'absolute';
			optionToggleLkm.style.top  = topY;
			optionToggleLkm.style.left  = 120;
			optionToggleLkm.style.fontSize  = "12px";
			optionToggleLkm.innerHTML = '0';
			newCatDiv.appendChild(optionToggleLkm);
			//
			// --- poi lukumäärä-teksti
			var carIconDiv = document.createElement("div");
			carIconDiv.setAttribute("id", catName + 'Icon');
			carIconDiv.style.position = 'absolute';
			carIconDiv.style.top  = topY + 3;
			carIconDiv.style.left  = 5;
			carIconDiv.style.width  = 10;
			carIconDiv.style.height  = 10;
			var iconName = getPoiIcon (catName);
			var iconUrl = 'url(images/' + iconName + '_10.gif)';
			carIconDiv.style.backgroundImage  = iconUrl;
			newCatDiv.appendChild(carIconDiv);
			//
			// ---
			topY = topY + 15;
		}
		// teksti joka kertoo poi-objektien total lkm
		var optionTotalLkm = document.createElement("div");
		optionTotalLkm.setAttribute("id", 'totalLkm');
		optionTotalLkm.style.position = 'absolute';
		optionTotalLkm.style.top  = topY + 5;
		optionTotalLkm.style.left  = 20;
		optionTotalLkm.style.fontSize  = "14px";
		optionTotalLkm.innerHTML = 'Total 0';
		newCatDiv.appendChild(optionTotalLkm);
		//
		// onko muistissa ftSelectedCatList
		//alert('ftSelectedCatList: ' + ftSelectedCatList);
		var totalLask = 0;
		if ( ftSelectedCatList != null) {
			var pit = ftSelectedCatList.length;
			for (i=0; i<pit; i++) {
				var catName = ftSelectedCatList[i];
				//alert('catName: ' + catName);
				var catElem = document.getElementById(catName);
				catElem.checked = true;
				// Vielä pitäisi laskea montako kappaletta tätä categoriaa on ftPoiList-listassa
				if (ftPoiList != null) {
					var pit2 = ftPoiList.length;
				}
				else {
					var pit2 = 0;
				}
				var lask2 = 0;
				for (i2=0; i2<pit2; i2++) {
					var poiList = ftPoiList[i2];
					poiCat = poiList[2];
					if(poiCat == catName) {
						lask2++
						totalLask++
					}
				}
				document.getElementById(catName + 'Lkm').innerHTML = lask2;
			}
		}
		else {
			document.getElementById(catName + 'Lkm').innerHTML = '0';
		}
		if(ftPoiList == null) {
			document.getElementById('totalLkm').innerHTML = 'Total 0';
		}
		else {
			document.getElementById('totalLkm').innerHTML = 'Total ' + ftPoiList.length;
		}
		//
		var edElement =document.getElementById("OpenCatWindow");
		edElement.onclick = new Function("doOpenCatWindow(false);");
		edElement.style.backgroundImage  = 'url(images/widearrowup.jpg)';
		if(ftLanguage == 'finnish') {
			edElement.innerHTML = '&nbsp;Sulje Linkkimenu';
		}
		else {
			edElement.innerHTML = '&nbsp;Close map Link menu';
		}
	}
	else {
		doCloseCatDiv();
	}

} //function doOpenCatWindow


function toggleCatElement (catNum) {
	var catPari = ftCatList[catNum];
	var catName = catPari[0];
	var catElem = document.getElementById(catName);
	var val = catElem.checked;
//	alert(catName + ' = ' + val);
	if (val == true) {
		document.getElementById(catName + 'Lkm').innerHTML = 'Haetaan...';
		showPoiCat (catName);
		// lisätään listaan
		if (ftSelectedCatList == null) {
			ftSelectedCatList = new Array();
			ftSelectedCatList[0] = catName;
		}
		else {
			var pit = ftSelectedCatList.length;
			ftSelectedCatList[pit] = catName;
		}
	}
	else {
		notShowPoiCat (catName);
		// poistetaan listasta
		mones = arrayMones(ftSelectedCatList, catName)
		ftSelectedCatList.splice(mones - 1, 1);
	}
	if(ftSelectedCatList.length == 0){
		ftSelectedCatList = null;
	}
	//alert(ftSelectedCatList);
}


function notShowPoiCat (catName) {
	document.getElementById(catName + 'Lkm').innerHTML = '0';
	var tempFtPoiList = ftPoiList;
	ftPoiList = new Array();
	var ftpLen = tempFtPoiList.length;
	// MUOTO: poiId, poiDbId, ftCategory, xNew, yNew, poiHref, poiTitle, poiInfo
	// rakennetaan uusi ftPoiList, niistä, jotka eivät ole == catName
	var poiLask = 0;
	for (i=0; i<ftpLen; i++) {
		var subList = tempFtPoiList[i];
		poiCat = subList[2];
		poiId = subList[0];
		if ( poiCat != catName) {
			ftPoiList[poiLask] = subList;
			poiLask++;
		}
		else {
			ftMapDivElement.removeChild(document.getElementById(poiId));
		}
	}
	tempFtPoiList = null;
	document.getElementById('totalLkm').innerHTML = 'Total ' + ftPoiList.length;
} //function notShowPoiCat


function doCloseCatDiv () {
	//
	catWindowFlag = false;
	var edElement = document.getElementById("OpenCatWindow");
	edElement.onclick = new Function("doOpenCatWindow(true);");
	edElement.style.backgroundImage  = 'url(images/widearrowdown.jpg)';
	if(ftLanguage == 'finnish') {
		edElement.innerHTML = '&nbsp;Avaa Linkkimenu';
	}
	else {
		edElement.innerHTML = '&nbsp;Open map Link menu';
	}
	document.body.removeChild(document.getElementById("catDiv"));
}


function copyLinkToClipBoard () {
	var cpteksti = newEmailInput.createTextRange();
	cpteksti.execCommand("Copy");
	if(ftLanguage == 'finnish')
		alert('Linkki kopioitu leikepöydällesi \nKäytä Ctrl-v komentoa siirtääksesi ohjelmaasi.');
	else
		alert('Link was copied to your ClipBoard. \nUse Ctrl-v command to paste it to your program.');
}

// ----- send by email ------------------------------------------------------------------


function sendEmailF() {
	if (document.getElementById("newEmailDiv") != null)
		document.body.removeChild(document.getElementById("newEmailDiv"));
	newEmailDiv = document.createElement("div");
	newEmailDiv.setAttribute("id", "newEmailDiv");
	document.body.appendChild(newEmailDiv);
	newEmailDiv.style.left= 10;
	newEmailDiv.style.top = 185;
	// ----- Input-ikkuna ----
	newEmailInput = document.createElement("input");
	newEmailInput.setAttribute("id", "newEmailInput");
	newEmailDiv.appendChild(newEmailInput);
	// ---- emailTextDiv-----
	emailTextDiv = document.createElement("div");
	emailTextDiv.setAttribute("id", "emailTextDiv");
	newEmailDiv.appendChild(emailTextDiv);

	// VAIN IE
	if(selain == 'ie'){
		// ----- ClipBoardButton ----
		copyClipBoardButton = document.createElement("input");
		copyClipBoardButton.setAttribute("id", "copyClipBoardButton");
		copyClipBoardButton.setAttribute("type", "button");
		if(ftLanguage == 'finnish')
			copyClipBoardButton.setAttribute("value", 'Kopioi linkki leikepöydälle');
		else
			copyClipBoardButton.setAttribute("value", 'Copy Link to ClipBoard');

		copyClipBoardButton.onclick = new Function("copyLinkToClipBoard();");
		newEmailDiv.appendChild(copyClipBoardButton);
	}

	//  ---- mailtoDiv Linkki ----------
	mailtoDiv = document.createElement("div");
	mailtoDiv.setAttribute("id", "mailtoDiv");
	newEmailDiv.appendChild(mailtoDiv);
	// PHP-parametrit

	//alert(ftSelectedCatList);
	var catListString = null;
	if (ftSelectedCatList == null) {
		catListString = 'none';
	}
	else if (ftSelectedCatList.length == 0) {
		catListString = 'none';
	}
	else if (ftSelectedCatList.length == 1) {
		catListString = ftSelectedCatList[0];
		//catListString = '\'' + catListString + '\'';
	}
	else {
		//catListString = '';
		catListString = ftSelectedCatList[0];
		//catListString = '\'' + catListString + '\'';
		for (i=1; i<ftSelectedCatList.length; i++) {
			var catstr = ftSelectedCatList[i];
			//catstr = '\'' + catstr + '\'';
			catListString = catListString + ',' + catstr;
		}
	}
	var currentPar = '?X=' + ftMapX + '&Y=' + ftMapY + '&Sc=' + ftMapScale;
	currentPar = currentPar + '&lg=' + ftLanguage + '&ca=' + catListString;
	if(ftLanguage == 'finnish'){
		var str1 = '<h2>L&auml;het&auml; kartta-asetukset s&auml;hk&ouml;postina</h2><br>';
		str1 = str1 + '<p>Kopioi karttalinkki parametreineen alla olevasta ikkunasta s&auml;hk&ouml;postiohjelmaasi ' +
		'tai avaa oletus s&auml;hk&ouml;postiohjelmasi alla olevasta linkist&auml;.'
		str2 = siteaddr + currentPar;
	}
	else {
		var str1 = '<h2>Send map location and settings in email</h2><br>';
		str1 = str1 + '<p>Copy link with its parameters from the lower form window into your email ' +
		'or open your defaulr email program from the link at the bottom of the window.'
		str2 = siteaddr + currentPar;
	}
	emailTextDiv.innerHTML = str1;
	newEmailInput.value = str2;
	var vastaanottaja = '';
	if(ftLanguage == 'finnish'){
		var otsikko = 'subject=' + escape('Virtuaali-Helsingin 3D-kartta');
		var sisalto1 = 'body=' + escape('\n\nKatso Virtuaali-Helsingin kohdetta: \n');
		var sisalto2 = escape(str2 + '\n\n');
	}
	else {
		var otsikko = 'subject=' + escape('Virtual Helsinki 3D map');
		var sisalto1 = 'body=' + escape('\n\nGo to check Virtual Helsinki 3Dmap location:\n');
		var sisalto2 = escape(str2 + '\n\n');
	}
	mailtoLink = document.createElement("a");
	mailtoLink.setAttribute("id", "mailtoLink");
	mailtoDiv.appendChild(mailtoLink);
	mailtoLink.href = 'mailto:' + vastaanottaja + '?' + otsikko + '&' + sisalto1 + sisalto2;
	if(ftLanguage == 'finnish'){
		mailtoLink.innerHTML = "Avaa karttalinkki s&auml;hk&ouml;postiohjelmassasi";
		mailtoLink.alt = 'Avaa s&auml;hk&ouml;postiohjelmasi'
		mailtoLink.title = 'Avaa s&auml;hk&ouml;postiohjelmasi'
	}
	else {
		mailtoLink.innerHTML = "Open map link in your email program";
		mailtoLink.alt = 'Open your email program'
		mailtoLink.title = 'Open your email program'
	}
	//
	// ------- Close-ruksi -------------------
	emailCloseRuksiDiv = document.createElement("div");
	emailCloseRuksiDiv.setAttribute("id", "emailCloseRuksiDiv");
	emailCloseRuksiDiv.style.backgroundColor  = "#888888";
	var imUrl = 'url("images/close.gif")';
	emailCloseRuksiDiv.style.backgroundImage  = imUrl;
	emailCloseRuksiDiv.style.backgroundPosition = '0px 0px';
	emailCloseRuksiDiv.style.backgroundRepeat = 'no-repeat';
	emailCloseRuksiDiv.onclick = new Function("doCloseEmail();");
	newEmailDiv.appendChild(emailCloseRuksiDiv);
} //function sendEmailF() {

function doCloseEmail () {
	document.body.removeChild(document.getElementById("newEmailDiv"));
}

// ---
function openFtWindow(osoite){
	if(ftLanguage == 'finnish')
		var osoite2 = osoite + '_fin.html';
	else
		var osoite2 = osoite + '_eng.html';
	var maxX=screen.width;
	var maxY=screen.height;
	var w=700;
	var h=500;
	var windowprops = 'width='+ w +',height='+h+',location=no,scrollbars=yes,'+
	'toolbar=no,resizable=yes,status=no,screenX=' + (maxX-w)/2+',screenY=' + (maxY-h)/2 + ','+
	'left=' + (maxX-w)/2 + ',top=' + (maxY-h)/2;
	//alert(windowprops);
	imageWindow=window.open(osoite2, '', windowprops);
}


// -----------------------------------------------------------------------
// Tämä on menubaria varten ja vain ie:lle luulisin
function startList() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("nav");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
	}
}





