// Functie voor het aanmaken van het ajax object
function ajaxinit()
{
	var xmlhttp=false;
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	// JScript gives us Conditional compilation, we can cope with old IE versions.
	// and security blocked creation of the objects.
	 try {
	  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
	  try {
	   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	  } catch (E) {
	   xmlhttp = false;
	  }
	 }
	@end @*/
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp=false;
		}
	}
	if (!xmlhttp && window.createRequest) {
		try {
			xmlhttp = window.createRequest();
		} catch (e) {
			xmlhttp=false;
		}
	}

  	return xmlhttp;
}

function setEdit(reaction_id)
{
    // We gaan de request string maken
    var http = ajaxinit();
    if(http)
    {
        http.open('GET','/index.php?page=blog&blog=' + document.blogform.blog_id.value + '&ajax=1&action=getText&id=' + reaction_id,true);
        http.onreadystatechange = function() {
            if (http.readyState == 4)
            {
                if (http.status == 200)
                {
                    response = http.responseText;
                    document.blogform.bericht.value = response;
                    document.blogform.reaction_id.value = reaction_id;
                    document.blogform.parent.value = 'update';

                    getSubject(reaction_id);

                    window.scrollTo(0, 999999);
                } else {
                    alert("There was a problem retrieving the XML data:\n" + http.statusText);
                    return false;
                }
            }
        }
        http.send(0);
    }
}

function getSubject(reaction_id)
{
    // We gaan de request string maken
    var http = ajaxinit();
    if(http)
    {
        http.open('GET','/index.php?page=blog&blog=' + document.blogform.blog_id.value + '&ajax=1&action=getSubject&id=' + reaction_id,true);
        http.onreadystatechange = function() {
            if (http.readyState == 4)
            {
                if (http.status == 200)
                {
                    response = http.responseText;
                    document.blogform.onderwerp.value = response;
                    document.blogform.reaction_id.value = reaction_id;
                    document.blogform.parent.value = 'update';

                    window.scrollTo(0, 999999);
                } else {
                    alert("There was a problem retrieving the XML data:\n" + http.statusText);
                    return false;
                }
            }
        }
        http.send(0);
    }
}

function banUser(reaction_id)
{
    // We gaan de request string maken
    var http = ajaxinit();
    if(http)
    {
        http.open('GET','/index.php?page=blog&blog=' + document.blogform.blog_id.value + '&ajax=1&action=banuser&id=' + reaction_id,true);
        http.onreadystatechange = function() {
            if (http.readyState == 4)
            {
                if (http.status == 200)
                {
                    response = http.responseText;
                    alert(response);
                    window.location.href = window.location.href;
                } else {
                    alert("There was a problem retrieving the XML data:\n" + http.statusText);
                    return false;
                }
            }
        }
        http.send(0);
    }
}

function deleteReaction(reaction_id)
{
    // We gaan de request string maken
    var http = ajaxinit();
    if(http)
    {
        http.open('GET','/index.php?page=blog&blog=' + document.blogform.blog_id.value + '&ajax=1&action=delete&id=' + reaction_id,true);
        http.onreadystatechange = function() {
            if (http.readyState == 4)
            {
                if (http.status == 200)
                {
                    response = http.responseText;
                    alert(response);
                    window.location.href = window.location.href;
                } else {
                    alert("There was a problem retrieving the XML data:\n" + http.statusText);
                    return false;
                }
            }
        }
        http.send(0);
    }
}
