var gDivId;
var http_anfrage_bewertung;

function postEditComment(id, comment) {
		if (window.XMLHttpRequest) {
			http_anfrage_bewertung = new XMLHttpRequest(); // Mozilla, Safari, Opera
		} else if (window.ActiveXObject) {
			try {
				http_anfrage_bewertung = new ActiveXObject('Msxml2.XMLHTTP'); // IE 5
			} catch (e) {
				try {
					http_anfrage_bewertung = new ActiveXObject('Microsoft.XMLHTTP'); // IE 6
				} catch (e) {}
			}
		}
		
          var phpScript = 'tutorials_kommentar.php';
          var postData = 'action=editComment&id=' + id + '&comment=' + encodeURI(comment);
          
           /* Reihenfolge wichtig setRequestHeader erst NACH open ! */

           	http_anfrage_bewertung.open('post', phpScript , true);
            http_anfrage_bewertung.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        	http_anfrage_bewertung.send(postData);

        	/* Antwort */

        	http_anfrage_bewertung.onreadystatechange = editCommentHandler;
}

function editCommentHandler() {
	if(http_anfrage_bewertung.readyState == 4) {
        document.getElementById(gDivId).innerHTML = http_anfrage_bewertung.responseText;
	}
}

function editComment(commentId, divId) {
    gDivId = divId;
    document.getElementById('editField_' + divId).style.display = 'none';
    document.getElementById(divId).style.display = 'block';
    showAnimation(divId);
    postEditComment(commentId, document.getElementById('editComment_' + divId).value);
}

function showAnimation(id) {
    document.getElementById(id).innerHTML = '<img style="margin-left: 100px;" src="images/loader.gif">';
}