function startEditMode(anfrage,url){
    if (anfrage.readyState == 4) {
        if (anfrage.status == 200) {
            var naviObj = anfrage.responseXML;
            var aktionenArray = naviObj.getElementsByTagName("aktionen");
            //Aktionen aus XML holen
            for(var i=0;i<aktionenArray.length;i++){
                var aktion = aktionenArray[i];
                if(aktion != null){
                    var id = trim(aktion.getElementsByTagName("id")[0].firstChild.nodeValue);
                    var datum = trim(aktion.getElementsByTagName("datum")[0].firstChild.nodeValue);
                    var until = trim(aktion.getElementsByTagName("until")[0].firstChild.nodeValue);
                    var titel = trim(aktion.getElementsByTagName("titel")[0].firstChild.nodeValue);
                    var msg = trim(aktion.getElementsByTagName("msg")[0].firstChild.nodeValue);
                    var bild = trim(aktion.getElementsByTagName("bild")[0].firstChild.nodeValue);
                    if(aktion.getElementsByTagName("termin")[0].firstChild){
                    	var termin = trim(aktion.getElementsByTagName("termin")[0].firstChild.nodeValue);
                    }else{
                    	var termin = false;
                    }

                }
            }
            $('aktion_titel').value = titel;
            $('aktion_start').value = datum;
            $('aktion_ende').value = until;
            $('aktion_text').value = msg;
            $('aktionId').value = id;
            if(termin == "true"){
                $('aktion_termin').checked = true;            
            }
            $('saveButton').style.visibility = "hidden";
            $('editButton').style.visibility = "visible";
            $('newMode').style.visibility = "visible";
            var aktionText = $('aktionText');
            while(aktionText.hasChildNodes()){
                var firstChild = aktionText.firstChild;
                aktionText.removeChild(firstChild);
            }
            var neuerText = document.createTextNode("Aktion bearbeiten:");
            aktionText.appendChild(neuerText);

            var image = $('images');
            while(image.hasChildNodes()){
                var firstChild = image.firstChild;
                image.removeChild(firstChild);
            }
			if(bild != "keins"){
            	var newImage = document.createElement("img");
	            newImage.src = "module/aktionen/resize.php?pic=" + bild;
	            $('imageName').value = bild;
	            image.appendChild(newImage);
			}

        }
    }
}

function startNewMode(anfrage,url){
    if (anfrage.readyState == 4) {
        if (anfrage.status == 200) {
            //Text Ueberschrift aendern
            var aktionText = $('aktionText');
            while(aktionText.hasChildNodes()){
                var firstChild = aktionText.firstChild;
                aktionText.removeChild(firstChild);
            }
            var neuerText = document.createTextNode("Neue Aktion anlegen:");
            aktionText.appendChild(neuerText);

            //Bild entfernen
            var image = $('images');
            while(image.hasChildNodes()){
                var firstChild = image.firstChild;
                image.removeChild(firstChild);
            }

            $('aktion_titel').value = "";
            $('aktion_start').value = "";
            $('aktion_ende').value = "";
            $('aktion_text').value = "";
            $('aktionId').value = "";
            $('saveButton').style.visibility = "visible";
            $('editButton').style.visibility = "hidden";
            $('newMode').style.visibility = "hidden";

        }
    }
}

