
function zeigeKartenpunkt(setposition)
{
    if (markpunktnr < 0) return;
    var punktoptdivobj = document.getElementById('punktoptdiv');
    var s = punktData[markpunktnr]["punkttitel"];
    s = getHtmlStr(s);
    s = s.replace(/[\n\r]+$/,'');
    s = s.replace(/[\n]/g, "<br>");
    s = s.replace(/[\r]/g, "");    
    s = s.replace(/ /g, "&nbsp;");    
    marktext.innerHTML = s;
    var punktart = eval(punktData[markpunktnr]["punktart"]);
    switch (punktart)
    {
        case 0:  // nur Text
            if (punktoptdivobj)
            {
                s = "./images/punkte/anker4.png";
                markpunkt.style.background = "url("+s+") no-repeat";
            }
            else
                markpunkt.style.background = "";
            break;
        case 1:  // normaler Punkt
				    s = "./images/punkte/"+punktData[markpunktnr]["punktform"]+"_"+punktcol_arr[punktData[markpunktnr]["punktfarbe"]]+".png";
				    s = s.replace(/#/g, "");
				    markpunkt.style.background = "url("+s+") no-repeat";
				    break;
				case 2:  // Icon
				    s = punktData[markpunktnr]["punkticondatei"];
				    s = s.replace(/\.\/eigeneicons\//, usermapsbasistemp+usermapsdir+"/");
				    markpunkt.style.background = "url('"+s+"') no-repeat";
				    break;
		}
    var punktgroessex = punktData[markpunktnr]["punktgroessex"];
    var punktgroessey = punktData[markpunktnr]["punktgroessey"];
    markpunkt.style.width = punktgroessex+"px";
    markpunkt.style.height = punktgroessey+"px";
    markpunkt.style.zIndex = punktData[markpunktnr]["punktebene"];
    marktext.style.color = punktData[markpunktnr]["punkttextfarbe"];
    marktext.style.fontSize = punktData[markpunktnr]["punkttextgroesse"];
    marktext.style.fontFamily = schriftart_arr[punktData[markpunktnr]["punktschriftart"]];
    marktext.style.fontWeight = (punktData[markpunktnr]["punktschriftstilfett"]) ? "bold" : "";
    marktext.style.fontStyle = (punktData[markpunktnr]["punktschriftstilkursiv"]) ? "italic" : "";
    marktext.style.textDecoration = (punktData[markpunktnr]["punktschriftstilunterstrichen"]) ? "underline" : "";
    var fs = parseInt(punktData[markpunktnr]["punkttextgroesse"].replace(/pt/g, ""));
    if (fs <= 10) marktext.style.padding = "2px 4px";  else marktext.style.padding = "2px 5px";
    var s = "transparent";
    if ((marktext.innerHTML.length > 0) && (punktData[markpunktnr]["punktbackfarbe"] != "transparent"))
    {
        if (punktData[markpunktnr]["punktbackdeck"] < 100)
        {
            s = " url(getcolimg.php?farbe="+encodeURIComponent(punktData[markpunktnr]["punktbackfarbe"]);
            s += "&deck="+punktData[markpunktnr]["punktbackdeck"]+")";
        }
        else
            s = punktData[markpunktnr]["punktbackfarbe"];
    }
    marktext.style.background = s;

    if (setposition)
    {
        var posx = eval(punktData[markpunktnr]["punktposx"]);
        var posy = eval(punktData[markpunktnr]["punktposy"]);
        var punktgroessex2 = punktgroessex/2;
        var punktgroessey2 = punktgroessey/2;
        var q0 = markpunkt.style.left;
        markpunkt.style.left = (posx-punktgroessex2)+"px";
        markpunkt.style.top  = (posy-punktgroessey2)+"px";
        markpunkt.style.display = 'block';
    }
    calcPunktTextposition();
    if (punktoptdivobj)
        zeigePunktOptDiv();
}

function calcPunktTextposition()
{
    if (markpunkt == null) return;
    var s = punktData[markpunktnr]["punkttextposition"];
    var br = marktext.offsetWidth;
    var ho = marktext.offsetHeight;
    var punktgroessex = eval(punktData[markpunktnr]["punktgroessex"]);
    var punktgroessey = eval(punktData[markpunktnr]["punktgroessey"]);
    var punktgroessex2 = punktgroessex/2;
    var punktgroessey2 = punktgroessey/2;
    var d = 0;
    if (punktData[markpunktnr]["punktbackfarbe"] != "transparent") d = 2;
    switch (eval(s))
    {
        case 0: // rechts
          marktext.style.left = punktgroessex+d;
          marktext.style.top = (punktgroessey2-(ho/2));
          break;
        case 1: // unten
          marktext.style.left = punktgroessex2-br/2;
          marktext.style.top = punktgroessey+d;
          break;
        case 2: // links
          marktext.style.left = -d-br;
          marktext.style.top = (punktgroessey2-(ho/2));
          break;
        case 3: // oben
          marktext.style.left = punktgroessex2-br/2;
          marktext.style.top = -d-ho;
          break;
    }
}

function setMarkpunktObj(elem)
{
    markpunkt = elem;
    if (markpunkt != null)
    {
        var res = markpunkt.id.match(/punkt(.*)/i);
        markpunktnr = eval(res[1]);
        marktext = document.getElementById('text'+markpunktnr);
    }
    else
    {
        markpunktnr = -1;
        markpunkt = null;
        marktext = null;
    }
}

function setMarkpunktNr(nr)
{
    markpunktnr = nr;
    if (markpunktnr >= 0)
    {
        markpunkt = document.getElementById('punkt'+markpunktnr);
        marktext = document.getElementById('text'+markpunktnr);
    }
    else
    {
        markpunktnr = -1;
        markpunkt = null;
        marktext = null;
    }
}

function initKartenpunkte()
{
    for (var i=0;i<anzpunkte;i++)
    {
        setMarkpunktNr(i);
        zeigeKartenpunkt(true);
    }
}

function setMarkLinieObj(elem)
{
    marklinie = elem;
    if (marklinie != null)
    {
        res = marklinie.id.match(/linie(.*)/i);
        marklinienr = eval(res[1]);
    }
    else
    {
        marklinienr = -1;
        marklinie = null;
    }
    zeigeLinieOptDiv();
}

function setMarkLinieNr(nr)
{
    marklinienr = nr;
    if (marklinienr >= 0)
    {
        marklinie = document.getElementById('linie'+marklinienr);
    }
    else
    {
        marklinienr = -1;
        markpunkt = null;
    }
    zeigeLinieOptDiv();
}

function setKartenstatus(kid,aktion,titel)
{
    var frage = "";
    var status = "";
    switch (aktion)
    {
        case "loeschen":
            frage = 'Are you sure that you want to delete the Map "'+titel+'" ?\n\nClick on OK to delete the Map. Click on Cancel to keep the Map.\nAttention: A deleted Map cannot be undeleted.';
            status = 'gesperrt';
            break;
        case "privat":
            frage = 'Are you sure you want to change the Map "'+titel+'" to "privat" status?\n\nThe Map can only be seen by you, the author, not by anyone else. The Map cannot be exported to other websites either.\n\nClick on OK to set the Map to "private" status. Click on cancel to leave it "public".';
            status = 'privat';
            break;
        case "oeffentlich":
            frage = 'Are you sure you want to change the Map "'+titel+'" to "public" status?\n\nThe Map will be visible to all in the StepMap Map-Directory and it can be exported to other websites. However, only you, the author, can edit the Map.\n\nClick on OK, to set the Map to "public" status. Click on cancel to leave it "private".';
            status = 'aktiv';
            break;
    }
    if ((status != "") && (frage != "") && (confirm(frage)))
    {
        with (document.setstatusform)
        {
            karteid.value = kid;
            setstatus.value = status;
            submit();
        }
    }
}